Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#1991
Browse files Browse the repository at this point in the history
  • Loading branch information
solarjoker committed Nov 10, 2021
2 parents b3ef7e6 + 6608fe4 commit d51aab2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

# 3.8.0-rc

- 新增 `Input` 组件的支持 placeholder 受控动态更新 [#1982](https://github.com/XiaoMi/hiui/issues/1982)
- 修复 `Select` 组件高亮词搜索存在正则注入 [#1972](https://github.com/XiaoMi/hiui/issues/1972)
- 修复 `Table` 组件 resizable 调节列宽功能失效 [#1970](https://github.com/XiaoMi/hiui/issues/1970)
- 修复 `Input` 组件的 placeholder 没法动态更新 [#1970](https://github.com/XiaoMi/hiui/issues/1982)
- 优化 `Dropdown` 组件 props 中的 data 消除副作用 [#1991](https://github.com/XiaoMi/hiui/issues/1991)
- 修复 `TimePicker` 组件使用 minusStep 当点击 clear 后会再次自动回显值 [#1986](https://github.com/XiaoMi/hiui/issues/1986)

# 3.8.0

Expand Down
4 changes: 4 additions & 0 deletions components/date-picker/components/Time.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ const Time = ({ date, onChange, timeRangePanelType, startDate, currentDate }) =>
}
const selectedEvent = useCallback(
(type, value, arrow, target) => {
// 避免空值时 点开 select 自动更新 input
// 这里的 `scroll` 是 TimeList 内部暴露的自定义事件,需要规避处理
if (target === 'scroll' && !currentDate) return

const cDate = moment(date)
const disabledList = _getDsiabledList()[type]
if (disabledList.includes(value) && arrow) {
Expand Down
12 changes: 7 additions & 5 deletions components/table/HeaderTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ const HeaderTable = ({ rightFixedIndex }) => {
indeterminate={!isAllChecked && rowSelection.selectedRowKeys.length > 0}
onChange={(e) => {
if (rowSelection.onChange) {
const selectedItems = isAllChecked
? []
: flatTreeData(_.cloneDeep(data)).filter((data) => !disabledData.current.includes(data.key))

rowSelection.onChange(
isAllChecked
? []
: flatTreeData(_.cloneDeep(data))
.filter((data) => !disabledData.current.includes(data.key))
.map((d) => d.key)
selectedItems.map((item) => item.key),
selectedItems,
!isAllChecked
)
}
}}
Expand Down
9 changes: 7 additions & 2 deletions components/table/Row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,16 @@ const Row = ({
onChange={(e) => {
const { selectedRowKeys = [], onChange } = rowSelection
const _selectedRowKeys = [...selectedRowKeys]

if (_selectedRowKeys.includes(rowData.key)) {
onChange(_selectedRowKeys.filter((key) => key !== rowData.key))
onChange(
_selectedRowKeys.filter((key) => key !== rowData.key),
rowData,
false
)
} else {
_selectedRowKeys.push(rowData.key)
onChange(_selectedRowKeys)
onChange(_selectedRowKeys, rowData, true)
}
}}
/>
Expand Down
3 changes: 2 additions & 1 deletion components/table/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export type TableFixedOption = {
}
export type TableRowSelection = {
selectedRowKeys?: string[] | number[]
onChange?: (selectedRowKeys: string | number) => void
getCheckboxConfig?: (rowData: object) => object
onChange?: (selectedRowKeys: string | number, targetRow?: object | object[], shouldChecked?: boolean) => void
}

export type TableHeaderRowReturn = {
Expand Down
5 changes: 4 additions & 1 deletion docs/demo/time-picker/section-range.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ class Demo extends React.Component {
<TimePicker
defaultValue={{start: new Date(), end: new Date()}}
type="timerange"
onChange={(date, dateString) => console.log(date, dateString)}
onChange={(date, dateString) => {
console.log('onChange: ', date, dateString)
}}
/>
)
}
}`

const DemoBase = () => <DocViewer code={code} scope={{ TimePicker }} prefix={prefix} desc={desc} />
export default DemoBase
2 changes: 1 addition & 1 deletion docs/zh-CN/components/table.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ import DemoAsync from '../../demo/table/section-async.jsx'
| ----------------- | ---------------------- | ----------------------------------- | ---------------- | ------ |
| selectedRowKeys | 选中的行(受控) | string[] | row 中对应的 key | - |
| getCheckboxConfig | 行选择的配置项 | rowData => object | - | - |
| onChange | 选中项发生变化时的回调 | (selectedRowKeys: string[]) => void | - | - |
| onChange | 选中项发生变化时的回调,如果是全选操作,`targetRow` 将是数组结构 | (selectedRowKeys: string[], targetRow?: object \| object[], shouldChecked?: boolean) => void | - | - |

0 comments on commit d51aab2

Please sign in to comment.