diff --git a/.changeset/clean-donuts-attack.md b/.changeset/clean-donuts-attack.md new file mode 100644 index 000000000..a0ff6ccc1 --- /dev/null +++ b/.changeset/clean-donuts-attack.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +feat(date-picker): onSelect 回调中增加 panelIndex 参数 diff --git a/.changeset/tall-walls-doubt.md b/.changeset/tall-walls-doubt.md new file mode 100644 index 000000000..ea0727bcd --- /dev/null +++ b/.changeset/tall-walls-doubt.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/date-picker": minor +--- + +feat: onSelect 回调中增加 panelIndex 参数 diff --git a/packages/ui/date-picker/src/DatePicker.tsx b/packages/ui/date-picker/src/DatePicker.tsx index 8930de21b..59b103b7c 100644 --- a/packages/ui/date-picker/src/DatePicker.tsx +++ b/packages/ui/date-picker/src/DatePicker.tsx @@ -115,8 +115,8 @@ export const DatePicker = forwardRef( }, [propType]) const propsOnSelect = useCallback( - (data: moment.Moment, isCompleted: boolean) => { - propsOnSelectOriginal && propsOnSelectOriginal(moment(data).toDate(), isCompleted) + (data: moment.Moment, isCompleted: boolean, panelIndex?: number) => { + propsOnSelectOriginal?.(moment(data).toDate(), isCompleted, panelIndex) }, [propsOnSelectOriginal] ) diff --git a/packages/ui/date-picker/src/components/date-range-time-panel.tsx b/packages/ui/date-picker/src/components/date-range-time-panel.tsx index 4b988259c..ed7ea0e30 100644 --- a/packages/ui/date-picker/src/components/date-range-time-panel.tsx +++ b/packages/ui/date-picker/src/components/date-range-time-panel.tsx @@ -49,7 +49,7 @@ export const DateRangeTimePanel = (props: DateRangeTimePanelProps) => { const panelDisabledDate = useCallback( (date: Date, disposeView: CalendarViewEnum) => { - if (disabledDate(date, disposeView)) { + if (disabledDate(date, disposeView, nowIndex)) { return true } else { // 当正在操作开始,并且结束存在时,限制开始范围 @@ -99,6 +99,7 @@ export const DateRangeTimePanel = (props: DateRangeTimePanelProps) => { disabledDate={panelDisabledDate} outDate={panelData} range={range} + panelIndex={nowIndex} />