Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1564

Merged
merged 112 commits into from
Jan 29, 2021
Merged

Develop #1564

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
8f7eb87
fix: #1491
Jan 4, 2021
38fe9d7
chore: changelog
Jan 4, 2021
1631093
chore: changelog
Jan 4, 2021
507c2c7
fix: empty margin
Jan 4, 2021
be7b178
Merge pull request #1492 from XiaoMi/hotfix/#1491
solarjoker Jan 5, 2021
3bed342
feat: popper auto end&start
Jan 5, 2021
ac51585
Merge branch 'develop' into feature/#1494
Jan 5, 2021
7bdcd26
feat: #1494
Jan 5, 2021
d6c0933
feat: #1494
Jan 5, 2021
9f4a357
feat: #1494
Jan 5, 2021
658777d
fix: #1497
Jan 5, 2021
35f1fff
fix: #1497
Jan 5, 2021
a0322e7
fix: #1491
Jan 5, 2021
922acb3
fix: #1493
Jan 5, 2021
a7a480b
fix: #1493
Jan 5, 2021
bdd5b1c
chore: #1494
Jan 5, 2021
f50d209
chore: #1494
Jan 5, 2021
764fa75
Merge pull request #1500 from XiaoMi/hotfix/#1493
GleanCoder1116 Jan 5, 2021
e805ed2
Merge pull request #1499 from XiaoMi/hotfix/#1491
GleanCoder1116 Jan 5, 2021
8531a93
Merge branch 'develop' into hotfix/#1497
GleanCoder1116 Jan 5, 2021
4547b2f
Merge pull request #1498 from XiaoMi/hotfix/#1497
GleanCoder1116 Jan 5, 2021
a8031d7
Merge branch 'develop' into feature/#1494
GleanCoder1116 Jan 5, 2021
27c1434
Merge pull request #1496 from XiaoMi/feature/#1494
GleanCoder1116 Jan 5, 2021
d6e2b3a
fix: #1501
GleanCoder1116 Jan 5, 2021
733caad
fix: #1501
GleanCoder1116 Jan 5, 2021
682e7df
Merge branch 'hotfix/#1501' of https://github.com/XiaoMi/hiui into ho…
Jan 6, 2021
4a5f4d7
fix: #1501
Jan 6, 2021
773ec04
fix: SelectTree: processing asyn multiple choice compatible error
Jan 6, 2021
d506b68
feat: add uniqBy docs
Jan 6, 2021
b37e9d6
fix: #1501
Jan 6, 2021
076b988
Merge pull request #1503 from XiaoMi/hotfix/#1491
GleanCoder1116 Jan 6, 2021
6cc94ad
Merge pull request #1502 from XiaoMi/hotfix/#1501
GleanCoder1116 Jan 6, 2021
d254b53
feat: #1505
Jan 11, 2021
0eb4139
feat: #1505
Jan 11, 2021
8093622
feat: #1505
Jan 12, 2021
3fe761e
feat: #1505
Jan 12, 2021
4dba403
feat: #1505
Jan 12, 2021
df776ef
fix: #1482
Jan 12, 2021
8ea322a
feat: #1505
Jan 13, 2021
c454848
chore: remark
Jan 13, 2021
81b42fe
chore: remark
Jan 13, 2021
b1997e5
feat: #1508
Jan 13, 2021
db6b7d0
fix: #1510
Jan 13, 2021
17cd02a
fix: #1510
Jan 13, 2021
d6fd5c6
Merge pull request #1511 from XiaoMi/hotfix/#1510
GleanCoder1116 Jan 13, 2021
c434a07
feat: #1508
Jan 13, 2021
b3a35c2
Merge branch 'develop' into hotfix/#1482
GleanCoder1116 Jan 13, 2021
507ff6d
Merge pull request #1506 from XiaoMi/hotfix/#1482
GleanCoder1116 Jan 13, 2021
839c9a8
Merge pull request #1509 from XiaoMi/feature/#1508
GleanCoder1116 Jan 13, 2021
41320b7
feat: #1505
Jan 13, 2021
2640c72
Merge pull request #1507 from XiaoMi/feature/#1505
GleanCoder1116 Jan 13, 2021
180bc3b
fix: #1519
Jan 14, 2021
0d914af
fix: #1519
Jan 14, 2021
c6c4ce8
fix: #1519
Jan 14, 2021
4f39ab3
fix: ThemeContext value
Jan 14, 2021
4ee23cb
Merge pull request #1520 from XiaoMi/hotfix/#1519
GleanCoder1116 Jan 14, 2021
7e2b45f
feat: #1522
Jan 15, 2021
f7b18c4
feat: #1522
Jan 15, 2021
f55a13e
Merge pull request #1523 from XiaoMi/feature/#1522
GleanCoder1116 Jan 15, 2021
8f74d89
feat: #1522
Jan 18, 2021
2b7ad1f
Merge pull request #1525 from XiaoMi/feature/#1522
GleanCoder1116 Jan 18, 2021
54a6657
feat: #1512
Jan 19, 2021
f3ccb67
feat: #1512
Jan 19, 2021
934961a
feat: #1512
Jan 20, 2021
2b534ef
feat: #1512
Jan 20, 2021
23415e4
feat: #1512
Jan 20, 2021
a77b959
feat: #1512
Jan 20, 2021
f3631a1
feat: #1512
Jan 20, 2021
77c0a3a
feat: add index.d.ts
Jan 20, 2021
e452767
Merge pull request #1529 from XiaoMi/feature/#1512
chownchen Jan 20, 2021
3f8acae
feat: sticky
Jan 21, 2021
4b86a85
Merge branch 'develop' into feature/#1512
Jan 21, 2021
baca382
feat: sticky
Jan 21, 2021
862f333
fix: #1524
Jan 21, 2021
dc17ade
fix: #1524
Jan 21, 2021
090fa76
fix: #1526
Jan 21, 2021
742712e
feat: #1527
Jan 21, 2021
8fd5b39
feat: #1527
Jan 22, 2021
46d8c72
feat: popper docs
Jan 24, 2021
1f7b152
feat: #1536
Jan 25, 2021
dd8aba0
Merge pull request #1537 from XiaoMi/feature/#1536
Nice-Ming Jan 25, 2021
dbff7f8
Merge pull request #1531 from XiaoMi/feature/#1512
Nice-Ming Jan 25, 2021
c0c88c1
Merge pull request #1535 from XiaoMi/feature/#1534
Nice-Ming Jan 25, 2021
e8abf61
Merge branch 'develop' into feature/#1527
GleanCoder1116 Jan 25, 2021
d271008
Merge pull request #1533 from XiaoMi/feature/#1527
GleanCoder1116 Jan 25, 2021
9df58b5
Merge branch 'develop' into hotfix/#1524
GleanCoder1116 Jan 25, 2021
b12c865
Merge pull request #1532 from XiaoMi/hotfix/#1524
GleanCoder1116 Jan 25, 2021
d2c7d79
fix: _BaseTable.scss path
Jan 25, 2021
74b8df7
Merge pull request #1540 from XiaoMi/feature/#1512
GleanCoder1116 Jan 25, 2021
a49d8d9
fix: #1543
Jan 26, 2021
4f02a96
Merge pull request #1544 from XiaoMi/feature/#1543
Nice-Ming Jan 26, 2021
7c3319a
feat: #1546
Jan 28, 2021
2497f5f
fix: #1547
Jan 28, 2021
3ae266a
fix: #1547
Jan 28, 2021
47831d8
feat: #1553
Jan 28, 2021
e483cb7
chore: #1556
Jan 28, 2021
d634ddb
chore: #1546
Jan 28, 2021
e5cafeb
chore: #1553
Jan 28, 2021
998fe22
Merge pull request #1549 from XiaoMi/feature/#1546
GleanCoder1116 Jan 28, 2021
8bd93e2
Merge pull request #1552 from XiaoMi/hotfix/#1547
GleanCoder1116 Jan 28, 2021
a2affd1
Merge pull request #1557 from XiaoMi/feature/#1556
GleanCoder1116 Jan 28, 2021
806b3db
Merge branch 'develop' into feature/#1553
GleanCoder1116 Jan 28, 2021
7d27b9e
Merge pull request #1555 from XiaoMi/feature/#1553
GleanCoder1116 Jan 28, 2021
c056e0b
chore: #1553
Jan 28, 2021
9a4267e
chore: change version
Jan 28, 2021
ee8199e
Merge pull request #1560 from XiaoMi/feature/#1553
GleanCoder1116 Jan 28, 2021
4738028
chore: changelog id
Jan 29, 2021
44de4b2
Merge pull request #1561 from XiaoMi/hotfix/changelog
GleanCoder1116 Jan 29, 2021
2e6f8c8
chore: changelog id
Jan 29, 2021
32ffd8b
Merge pull request #1562 from XiaoMi/hotfix/changelog
GleanCoder1116 Jan 29, 2021
16122cd
fix: d.ts #1558
Jan 29, 2021
2febbe2
Merge pull request #1563 from XiaoMi/hotfix/#1558
GleanCoder1116 Jan 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Desktop.ini
Thumbs.db
.Spotlight-V100
.Trashes
postcss.config.js
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# 更新日志

## 3.4.0

- 优化组件弹出层自动计算合适的左右位置 [#1494](https://github.com/XiaoMi/hiui/issues/1494)
- 新增 `Select SelectTree Cascader DatePicker Input` 等组件无边框形态 [#1553](https://github.com/XiaoMi/hiui/issues/1553)
- 新增 `Preview` 预览组件 [#1546](https://github.com/XiaoMi/hiui/issues/1546)
- 新增 `Select` 组件 onSearch、onOverlayScroll 方法 [#1522](https://github.com/XiaoMi/hiui/issues/1522)
- 修复 `SelectTree` 搜索输入框在输入值时失焦问题 [#1491](https://github.com/XiaoMi/hiui/issues/1491)
- 修复 `SelectTree` 单选形态下受控问题 [#1519](https://github.com/XiaoMi/hiui/issues/1519)
- 修复 `Select` 组件分组形态 filterOption 函数无法使用问题 [#1497](https://github.com/XiaoMi/hiui/issues/1497)
- 修复 `Select` 组件分组形态全选以及受控问题 [#1501](https://github.com/XiaoMi/hiui/issues/1501)
- 修复 `Select` 异步数据请求返回结果顺序异常 [#1543](https://github.com/XiaoMi/hiui/issues/1543)
- 修复 `Tabs` 组件垂直方向样式显示异常问题 [#1493](https://github.com/XiaoMi/hiui/issues/1493)
- 修复 `Form` DatePicker、SelectTree 在 Form.Item 中点击清空Icon 无效问题 [#1524](https://github.com/XiaoMi/hiui/issues/1524)
- 修复 `DatePicker` minDate、maxDate、disabledDate 在非 date 类型下不生效问题 [#1547](https://github.com/XiaoMi/hiui/issues/1547)
- 优化 `Checkbox` 样式相关内容 [#1482](https://github.com/XiaoMi/hiui/issues/1482)
- 优化 `SelectTree` 异步受控数据返显问题 [#1510](https://github.com/XiaoMi/hiui/issues/1510)
- 优化 `Select SelectTree` 计数根据窗口自动调整 [#1527](https://github.com/XiaoMi/hiui/issues/1527)
- 优化 `Drawer` 组件支持className属性 [#1536](https://github.com/XiaoMi/hiui/issues/1536)

## 3.3.0

- 新增 `Card` 模式模式下 loading 加载中状态 [#1454](https://github.com/XiaoMi/hiui/issues/1454)
- 新增 `Table` loading 加载中状态 [#1466](https://github.com/XiaoMi/hiui/issues/1466)
- 新增 `Table` 列冻结结合树形使用 [#1424](https://github.com/XiaoMi/hiui/issues/1424)
Expand Down
1 change: 0 additions & 1 deletion components/_util/EventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class EventEmitter {

// 触发事件
emit(type, ...arg) {
console.log(this.event)
this.event[type] && this.event[type](...arg)
}

Expand Down
14 changes: 7 additions & 7 deletions components/button/ButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ class ButtonGroup extends Component {
prefixCls: 'hi-btn-group'
}

render () {
const {
prefixCls,
style,
className
} = this.props
render() {
const { prefixCls, style, className } = this.props
const classes = classNames(`${prefixCls}`, className)
return <div className={classes} style={style}>{this.props.children}</div>
return (
<div className={classes} style={style}>
{this.props.children}
</div>
)
}
}

Expand Down
11 changes: 10 additions & 1 deletion components/button/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@ interface ButtonProps {
icon?: string
onClick?: () => void
}
declare const Button: React.ComponentType<Props>
interface ButtonGroupProps {
className?: string
style?: object
prefixCls?: string
}
declare class ButtonGroup extends React.Component<ButtonGroupProps, any> {
}
declare class Button extends React.Component<ButtonProps, any> {
static Group = ButtonGroup
}
export default Button
2 changes: 2 additions & 0 deletions components/card/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface Props {
extraType?: 'default' | 'hover'
coverUrl?: string
content?: string | JSX.Element
style?: CSSProperties
className?: string
}
declare class Card extends React.Component<Props, any> {
}
Expand Down
2 changes: 2 additions & 0 deletions components/carousel/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ interface Props {
defaultActive?: number
showPages?: boolean
children: JSX.Element[]
style?: CSSProperties
className?: string
}
declare const Carousel: React.ComponentType<Props>
export default Carousel
11 changes: 11 additions & 0 deletions components/carousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class Carousel extends Component {
this.setState({ showArrow })
}

handleKeyDown = (evt) => {
const { keyCode } = evt
if ([39, 37].includes(keyCode)) {
evt.preventDefault()
evt.stopPropagation()
this.preNextEvent(keyCode === 37 ? -1 : 1)
}
}

render() {
const { rootWidth, active, showArrow } = this.state
const { showDots, showArrows, showPages } = this.props
Expand All @@ -81,6 +90,8 @@ class Carousel extends Component {
<div
className="hi-carousel"
ref={this.rootRef}
tabIndex="0"
onKeyDown={this.handleKeyDown}
onMouseOver={this.mouseEvent.bind(this, 'over')}
onMouseOut={this.mouseEvent.bind(this, 'out')}
>
Expand Down
2 changes: 2 additions & 0 deletions components/carousel/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
color: #fff;
overflow: hidden;
position: relative;
outline: none;

&__container {
height: 100%;
Expand Down Expand Up @@ -54,6 +55,7 @@
visibility: hidden;
height: 0;
z-index: 2;

&--show {
visibility: visible;
}
Expand Down
195 changes: 184 additions & 11 deletions components/cascader/Cascader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useRef, useState, useCallback, useEffect } from 'react'

import classNames from 'classnames'

import _ from 'lodash'
import Popper from '../popper'

import Menu from './Menu'
Expand All @@ -25,12 +25,9 @@ const Cascader = (props) => {
changeOnSelect = false,
localeDatas,
onChange = noop,
onActiveItemChange = noop
onActiveItemChange = noop,
bordered = true
} = props
const data = props.data || props.options // 兼容1.x API 2.x 改为data
const emptyContent = props.emptyContent || props.noFoundTip // 兼容1.x API 2.x改为 emptyContent
const expandTrigger = props.expandTrigger || props.trigger || 'click' // 兼容2.x API 1.x改为 expandTrigger

const getLabelKey = useCallback(() => {
return fieldNames.label || 'content'
}, [])
Expand All @@ -42,7 +39,25 @@ const Cascader = (props) => {
const getChildrenKey = useCallback(() => {
return fieldNames.children || 'children'
}, [])

const parseData = useCallback(
(data) => {
const _data = _.cloneDeep(data)
const setDataItemPath = (data = [], parent) => {
data.forEach((item, index) => {
item._path = parent ? parent._path + '-' + index : index
if (item[getChildrenKey()]) {
setDataItemPath(item[getChildrenKey()], item)
}
})
}
setDataItemPath(_data)
return _data
},
[props.data, props.options]
)
const data = parseData(props.data || props.options) // 兼容1.x API 2.x 改为data
const emptyContent = props.emptyContent || props.noFoundTip // 兼容1.x API 2.x改为 emptyContent
const expandTrigger = props.expandTrigger || props.trigger || 'click' // 兼容2.x API 1.x改为 expandTrigger
const getCascaderLabel = useCallback(
(values, dataList) => {
if (displayRender) {
Expand Down Expand Up @@ -83,7 +98,9 @@ const Cascader = (props) => {
const [cacheValue, setCacheValue] = useState(value || defaultValue || [])
const [cascaderValue, setCascaderValue] = useState(value || defaultValue || [])
const [cascaderLabel, setCascaderLabel] = useState(getCascaderLabel(value || defaultValue || []))

const [focusOptionIndex, setFocusOptionIndex] = useState(-1)
const targetByKeyDown = useRef(false)
const currentDeep = useRef(0)
const [popperShow, setPopperShow] = useState(false)
const [keyword, setKeyword] = useState('')

Expand All @@ -97,6 +114,10 @@ const Cascader = (props) => {
setCacheValue(value)
}
}, [value])
useEffect(() => {
setFocusOptionIndex(-1)
currentDeep.current = 0
}, [popperShow])

useEffect(() => {
setCascaderLabel(getCascaderLabel(cacheValue))
Expand Down Expand Up @@ -355,12 +376,160 @@ const Cascader = (props) => {
[popperShow, cacheValue, cascaderValue, keyword]
)

const parseFocusOptionIndex = useCallback(
(deep = currentDeep.current) => {
const optionIndexs = focusOptionIndex < 0 ? [focusOptionIndex] : String(focusOptionIndex).split('-')
return {
optionIndexs: optionIndexs.slice(0, deep + 1),
focusOptionIndex: optionIndexs[deep] || -1
}
},
[focusOptionIndex, currentDeep.current]
)
// 获取不同深度的数据, 该深度的全部数据而不是单条数据
const getDeepData = useCallback(
(deep = currentDeep.current) => {
const { optionIndexs } = parseFocusOptionIndex(deep)
let _data = data
if (optionIndexs.length <= 1) {
return _data
}
_data = optionIndexs.reduce((deepData, current, index) => {
if (index === 0) return deepData
const _index = optionIndexs[index - 1]
return deepData[_index][getChildrenKey()]
}, data)
return _data || []
},
[parseFocusOptionIndex, data, currentDeep.current]
)
// 上下按键
const moveFocusedIndex = useCallback(
(direction) => {
targetByKeyDown.current = true
const _data = currentDeep.current === 0 ? data : getDeepData()
const { focusOptionIndex: _focusOptionIndex } = parseFocusOptionIndex()
const isAllDisabled = _data.every((item) => {
return item.disabled
})
let index = direction === 'down' ? _focusOptionIndex / 1 + 1 : _focusOptionIndex / 1 - 1
if (index < 0) {
index = _data.length - 1
} else if (index >= _data.length) {
index = 0
}
if (!isAllDisabled) {
while (data[index] && data[index].disabled) {
index++
}
if (currentDeep.current > 0) {
const _focusOptionIndex = String(focusOptionIndex).split('-')
_focusOptionIndex[currentDeep.current] = index
index = _focusOptionIndex.join('-')
} else {
index = String(index)
}
setFocusOptionIndex(index)
} else {
setFocusOptionIndex(-1)
}
},
[targetByKeyDown.current, currentDeep.current, data, getDeepData, parseFocusOptionIndex, focusOptionIndex]
)
// 右方向按键
const rightHandle = useCallback(() => {
targetByKeyDown.current = true
currentDeep.current++
const { optionIndexs } = parseFocusOptionIndex()
const optionValues = []
const l = optionIndexs.length
optionIndexs.map((item, index) => {
const _data = getDeepData(index)
optionValues.push(_data[item].id)
})
const currentItem = getDeepData(l - 1)[optionIndexs[l - 1]] || {}
const children = currentItem[getChildrenKey()] || []
const hasChildren = !!children.length
onChangeValue(optionValues, hasChildren)
let index = 0
while (children[index] && children[index].disabled) {
index++
}
index = hasChildren ? focusOptionIndex + '-' + index : focusOptionIndex
setFocusOptionIndex(index)
}, [targetByKeyDown.current, parseFocusOptionIndex, focusOptionIndex, onChangeValue, currentDeep.current])
// 左方向按键
const leftHandle = useCallback(() => {
targetByKeyDown.current = true

const optionsIndex = focusOptionIndex.split('-')
if (cascaderValue.length === 0) {
currentDeep.current = 0
return
}
currentDeep.current--
setFocusOptionIndex(optionsIndex.splice(0, optionsIndex.length - 1).join('-'))
onChangeValue(cascaderValue.splice(0, cascaderValue.length - 1), true)
}, [focusOptionIndex, targetByKeyDown.current, onChangeValue, currentDeep.current, cascaderValue])
// 按键操作
const handleKeyDown = useCallback(
(evt) => {
// space
if (evt.keyCode === 32 && !searchable) {
evt.preventDefault()
evt.stopPropagation()
setPopperShow(!popperShow)
}
// esc
if (evt.keyCode === 27) {
evt.stopPropagation()
setPopperShow(false)
}
if (popperShow) {
// down
if (evt.keyCode === 40) {
evt.stopPropagation()
evt.preventDefault()
moveFocusedIndex('down')
}
// up
if (evt.keyCode === 38) {
evt.preventDefault()
evt.stopPropagation()
moveFocusedIndex('up')
}
// right
if (evt.keyCode === 39 || evt.keyCode === 13) {
evt.preventDefault()
evt.stopPropagation()
rightHandle()
}
// left
if (evt.keyCode === 37) {
evt.preventDefault()
evt.stopPropagation()
leftHandle()
}
}
},
[moveFocusedIndex, rightHandle, leftHandle]
)

const expandIcon = popperShow ? 'icon-up' : 'icon-down'
const placeholder = cascaderLabel || localeDatasProps('placeholder')

return (
<div className={classNames('hi-cascader', `theme__${theme}`, className, extraClass)} style={style} ref={hiCascader}>
<div className="hi-cascader__input-container" ref={inputContainer} onClick={handleClick}>
<div
className={classNames('hi-cascader', `theme__${theme}`, className, extraClass)}
style={style}
ref={hiCascader}
tabIndex="0"
onKeyDown={handleKeyDown}
>
<div
className={classNames('hi-cascader__input-container', { bordered })}
ref={inputContainer}
onClick={handleClick}
>
<input
ref={inputRef}
className="hi-cascader__input-keyword"
Expand Down Expand Up @@ -414,7 +583,11 @@ const Cascader = (props) => {
childrenKey={getChildrenKey()}
onSelect={onChangeValue}
onHover={onHover}
currentDeep={currentDeep}
expandTrigger={expandTrigger}
focusOptionIndex={focusOptionIndex}
setFocusOptionIndex={setFocusOptionIndex}
targetByKeyDown={targetByKeyDown}
emptyContent={emptyContent}
localeDatasProps={localeDatasProps}
/>
Expand Down
Loading