From 555a775e9f2507b9ea0781fc376968dc394b663a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=87=E8=A7=81=E5=90=8C=E5=AD=A6?= <1875694521@qq.com> Date: Wed, 23 Jul 2025 22:17:34 +0800 Subject: [PATCH 1/6] feat: add showPreviewValue option --- docs/examples/basic.tsx | 9 +++++++++ docs/examples/range.tsx | 11 +++++++++++ docs/examples/time.tsx | 14 +++++++++++++- src/PickerInput/RangePicker.tsx | 5 ++++- src/PickerInput/SinglePicker.tsx | 6 +++++- src/interface.tsx | 2 ++ 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index 08d747111..1d8504760 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -154,6 +154,15 @@ export default () => {

Keyboard event with prevent default behaviors

{...sharedProps} locale={enUS} onKeyDown={keyDown} /> +
+

ShowPreviewValue is false

+ + {...sharedProps} + locale={enUS} + onKeyDown={keyDown} + showPreviewValue={false} + /> +
); diff --git a/docs/examples/range.tsx b/docs/examples/range.tsx index 1b137c8b0..8d14d098e 100644 --- a/docs/examples/range.tsx +++ b/docs/examples/range.tsx @@ -202,6 +202,17 @@ export default () => { disabledDate={disabledDate} /> +
+

ShowPreviewValue is false

+ + {...sharedProps} + showPreviewValue={false} + value={undefined} + locale={zhCN} + placeholder={['start...', 'end...']} + disabledDate={disabledDate} + /> +
); diff --git a/docs/examples/time.tsx b/docs/examples/time.tsx index d1332b99c..b27f9d69b 100644 --- a/docs/examples/time.tsx +++ b/docs/examples/time.tsx @@ -12,7 +12,7 @@ const testClassNames = { suffix: 'test-suffix', popupContent: 'test-popup-content', popupItem: 'test-popup-item', -} +}; export default () => { return ( @@ -53,6 +53,18 @@ export default () => { disabledHours: () => (type === 'start' ? [now.hours()] : [now.hours() - 5]), })} /> + +

ShowPreviewValue is false

+ ({ + disabledHours: () => (type === 'start' ? [now.hours()] : [now.hours() - 5]), + })} + /> ); }; diff --git a/src/PickerInput/RangePicker.tsx b/src/PickerInput/RangePicker.tsx index 7a0b57839..dca7fc3e7 100644 --- a/src/PickerInput/RangePicker.tsx +++ b/src/PickerInput/RangePicker.tsx @@ -164,6 +164,7 @@ function RangePicker( styles: propStyles, classNames: propClassNames, + showPreviewValue = true, // Value defaultValue, value, @@ -505,7 +506,9 @@ function RangePicker( // ======================== Panel ========================= const onPanelHover = (date: DateType) => { - setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null); + if (showPreviewValue) { + setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null); + } setHoverSource('cell'); }; diff --git a/src/PickerInput/SinglePicker.tsx b/src/PickerInput/SinglePicker.tsx index c773fbd09..521140829 100644 --- a/src/PickerInput/SinglePicker.tsx +++ b/src/PickerInput/SinglePicker.tsx @@ -128,6 +128,8 @@ function Picker( styles: propStyles, classNames: propClassNames, + showPreviewValue = true, + // Value order, defaultValue, @@ -433,7 +435,9 @@ function Picker( // ======================== Panel ========================= const onPanelHover = (date: DateType | null) => { - setInternalHoverValue(date); + if (showPreviewValue) { + setInternalHoverValue(date); + } setHoverSource('cell'); }; diff --git a/src/interface.tsx b/src/interface.tsx index 2fe3dae7d..7798caa2f 100644 --- a/src/interface.tsx +++ b/src/interface.tsx @@ -425,6 +425,8 @@ export interface SharedPickerProps */ preserveInvalidOnBlur?: boolean; + showPreviewValue?: boolean; + // Motion transitionName?: string; From 4e7525420901a347bb615fab4163b4b1fc2d48d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=87=E8=A7=81=E5=90=8C=E5=AD=A6?= <1875694521@qq.com> Date: Wed, 23 Jul 2025 23:25:08 +0800 Subject: [PATCH 2/6] feat: update test --- tests/range.spec.tsx | 28 ++++++++++++++++++++++++++ tests/time.spec.tsx | 48 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/tests/range.spec.tsx b/tests/range.spec.tsx index e584b75fc..7b4e5924e 100644 --- a/tests/range.spec.tsx +++ b/tests/range.spec.tsx @@ -2120,4 +2120,32 @@ describe('Picker.Range', () => { openPicker(container, 1); expect(container.querySelectorAll('.rc-picker-input')[0]).toHaveClass('rc-picker-input-active'); }); + + it('should not update preview value in input when showPreviewValue is false', () => { + const { container } = render( + , + ); + + // 找到第一个输入框并保存初始值 + const inputStart = container.querySelectorAll('.rc-picker-input input')[0]; + const initialValueStart = inputStart.value; + + // 打开第一个面板并 hover 一个新值(例如 2028 年) + const targetCell = document.querySelector('[title="2028"]') as HTMLElement; + expect(targetCell).toBeTruthy(); // 确保存在 + + // 2. 模拟鼠标移入(hover) + fireEvent.mouseEnter(targetCell); + + // 确保值未更新(仍为原值) + expect(inputStart.value).toBe(initialValueStart); + }); }); diff --git a/tests/time.spec.tsx b/tests/time.spec.tsx index e19837d0d..d427d081b 100644 --- a/tests/time.spec.tsx +++ b/tests/time.spec.tsx @@ -1,7 +1,8 @@ import { fireEvent, render } from '@testing-library/react'; import { resetWarned } from '@rc-component/util/lib/warning'; import React from 'react'; -import { DayPicker, getDay, openPicker, selectCell, findCell } from './util/commonUtil'; +import dayjs from 'dayjs'; +import { DayPicker, getDay, openPicker, selectCell } from './util/commonUtil'; describe('Picker.Time', () => { beforeEach(() => { @@ -68,4 +69,49 @@ describe('Picker.Time', () => { fireEvent.mouseEnter(getColCell(4, 1)); expect(container.querySelector('input')).toHaveValue('1990-09-03 12:00:00.000 PM'); }); + + it('hover should not update preview value in input when showPreviewValue is false', async () => { + const { container } = render( + , + ); + openPicker(container); + + const getColCell = (colIndex: number, cellIndex: number) => { + const column = document.querySelectorAll('.rc-picker-time-panel-column')[colIndex]; + const cell = column.querySelectorAll('.rc-picker-time-panel-cell-inner')[cellIndex]; + + return cell; + }; + + // Hour + fireEvent.mouseEnter(getColCell(0, 3)); + expect(container.querySelector('input')).toHaveValue('1990-09-03 01:02:03.000 AM'); + + // Let test for mouse leave + fireEvent.mouseLeave(getColCell(0, 3)); + expect(container.querySelector('input')).toHaveValue('1990-09-03 01:02:03.000 AM'); + + // Minute + fireEvent.mouseEnter(getColCell(1, 2)); + expect(container.querySelector('input')).toHaveValue('1990-09-03 01:02:03.000 AM'); + + // Second + fireEvent.mouseEnter(getColCell(2, 1)); + expect(container.querySelector('input')).toHaveValue('1990-09-03 01:02:03.000 AM'); + + // Millisecond + fireEvent.mouseEnter(getColCell(3, 1)); + expect(container.querySelector('input')).toHaveValue('1990-09-03 01:02:03.000 AM'); + + // Meridiem + fireEvent.mouseEnter(getColCell(4, 1)); + expect(container.querySelector('input')).toHaveValue('1990-09-03 01:02:03.000 AM'); + }); }); From 9bb291b29f8aeee6a0fbbc8c5044aa52794ea56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=87=E8=A7=81=E5=90=8C=E5=AD=A6?= <1875694521@qq.com> Date: Thu, 24 Jul 2025 13:46:52 +0800 Subject: [PATCH 3/6] feat: update --- README.md | 4 +++- docs/examples/basic.tsx | 4 ++-- docs/examples/range.tsx | 4 ++-- docs/examples/time.tsx | 4 ++-- src/PickerInput/RangePicker.tsx | 4 ++-- src/PickerInput/SinglePicker.tsx | 4 ++-- src/interface.tsx | 5 ++++- tests/range.spec.tsx | 4 ++-- tests/time.spec.tsx | 4 ++-- 9 files changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 16cb3e7f4..76792b8b5 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ render(, mountNode); | autoFocus | boolean | false | whether auto focus | | showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection | | picker | time \| date \| week \| month \| year | | control which kind of panel should be shown | +| showHoverValue | boolean | true | When the user selects the date hover option, the value of the input field undergoes a temporary change | | format | String \| String[] | depends on whether you set timePicker and your locale | use to format/parse date(without time) value to/from input. When an array is provided, all values are used for parsing and first value for display | | use12Hours | boolean | false | 12 hours display mode | | value | moment | | current value like input's value | @@ -102,7 +103,7 @@ render(, mountNode); ### RangePicker | Property | Type | Default | Description | -| --- | --- | --- | --- | +| --- | --- | --- | --- | --- | | prefixCls | String | rc-picker | prefixCls of this component | | className | String | '' | additional css class of root dom | | style | React.CSSProperties | | additional style of root dom node | @@ -112,6 +113,7 @@ render(, mountNode); | defaultPickerValue | moment | | Set default display picker view date | | separator | String | '~' | set separator between inputs | | picker | time \| date \| week \| month \| year | | control which kind of panel | +| showHoverValue | boolean | true | When the user selects the date hover option, the value of the input field undergoes a temporary change | | placeholder | [String, String] | | placeholder of date input | | showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection | | showTime.defaultValue | [moment, moment] | | to set default time of selected date | diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index 1d8504760..262b2922b 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -155,12 +155,12 @@ export default () => { {...sharedProps} locale={enUS} onKeyDown={keyDown} />
-

ShowPreviewValue is false

+

ShowHoverValue is false

{...sharedProps} locale={enUS} onKeyDown={keyDown} - showPreviewValue={false} + showHoverValue={false} />
diff --git a/docs/examples/range.tsx b/docs/examples/range.tsx index 8d14d098e..cfe347d15 100644 --- a/docs/examples/range.tsx +++ b/docs/examples/range.tsx @@ -203,10 +203,10 @@ export default () => { />
-

ShowPreviewValue is false

+

ShowHoverValue is false

{...sharedProps} - showPreviewValue={false} + showHoverValue={false} value={undefined} locale={zhCN} placeholder={['start...', 'end...']} diff --git a/docs/examples/time.tsx b/docs/examples/time.tsx index b27f9d69b..0a5e0fdb8 100644 --- a/docs/examples/time.tsx +++ b/docs/examples/time.tsx @@ -54,12 +54,12 @@ export default () => { })} /> -

ShowPreviewValue is false

+

showHoverValue is false

({ disabledHours: () => (type === 'start' ? [now.hours()] : [now.hours() - 5]), diff --git a/src/PickerInput/RangePicker.tsx b/src/PickerInput/RangePicker.tsx index dca7fc3e7..537a32435 100644 --- a/src/PickerInput/RangePicker.tsx +++ b/src/PickerInput/RangePicker.tsx @@ -164,7 +164,7 @@ function RangePicker( styles: propStyles, classNames: propClassNames, - showPreviewValue = true, + showHoverValue = true, // Value defaultValue, value, @@ -506,7 +506,7 @@ function RangePicker( // ======================== Panel ========================= const onPanelHover = (date: DateType) => { - if (showPreviewValue) { + if (showHoverValue) { setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null); } setHoverSource('cell'); diff --git a/src/PickerInput/SinglePicker.tsx b/src/PickerInput/SinglePicker.tsx index 521140829..e0f033869 100644 --- a/src/PickerInput/SinglePicker.tsx +++ b/src/PickerInput/SinglePicker.tsx @@ -128,7 +128,7 @@ function Picker( styles: propStyles, classNames: propClassNames, - showPreviewValue = true, + showHoverValue = true, // Value order, @@ -435,7 +435,7 @@ function Picker( // ======================== Panel ========================= const onPanelHover = (date: DateType | null) => { - if (showPreviewValue) { + if (showHoverValue) { setInternalHoverValue(date); } setHoverSource('cell'); diff --git a/src/interface.tsx b/src/interface.tsx index 7798caa2f..91814d080 100644 --- a/src/interface.tsx +++ b/src/interface.tsx @@ -425,7 +425,10 @@ export interface SharedPickerProps */ preserveInvalidOnBlur?: boolean; - showPreviewValue?: boolean; + /** + * When the user selects the date hover option, the value of the input field undergoes a temporary change + */ + showHoverValue?: boolean; // Motion transitionName?: string; diff --git a/tests/range.spec.tsx b/tests/range.spec.tsx index 7b4e5924e..7bd023cd0 100644 --- a/tests/range.spec.tsx +++ b/tests/range.spec.tsx @@ -2121,14 +2121,14 @@ describe('Picker.Range', () => { expect(container.querySelectorAll('.rc-picker-input')[0]).toHaveClass('rc-picker-input-active'); }); - it('should not update preview value in input when showPreviewValue is false', () => { + it('should not update preview value in input when showHoverValue is false', () => { const { container } = render( , diff --git a/tests/time.spec.tsx b/tests/time.spec.tsx index d427d081b..ba0f544ab 100644 --- a/tests/time.spec.tsx +++ b/tests/time.spec.tsx @@ -70,14 +70,14 @@ describe('Picker.Time', () => { expect(container.querySelector('input')).toHaveValue('1990-09-03 12:00:00.000 PM'); }); - it('hover should not update preview value in input when showPreviewValue is false', async () => { + it('hover should not update preview value in input when showHoverValue is false', async () => { const { container } = render( , ); From 99a78ed00352bf4902ecd11d603625bf9f052a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=87=E8=A7=81=E5=90=8C=E5=AD=A6?= <1875694521@qq.com> Date: Thu, 24 Jul 2025 21:54:52 +0800 Subject: [PATCH 4/6] feat: update onPanelHover --- src/PickerInput/RangePicker.tsx | 4 +++- src/PickerInput/SinglePicker.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PickerInput/RangePicker.tsx b/src/PickerInput/RangePicker.tsx index 537a32435..80500a81a 100644 --- a/src/PickerInput/RangePicker.tsx +++ b/src/PickerInput/RangePicker.tsx @@ -488,7 +488,9 @@ function RangePicker( const presetList = usePresets(presets, ranges); const onPresetHover = (nextValues: RangeValueType | null) => { - setInternalHoverValues(nextValues); + if (showHoverValue) { + setInternalHoverValues(nextValues); + } setHoverSource('preset'); }; diff --git a/src/PickerInput/SinglePicker.tsx b/src/PickerInput/SinglePicker.tsx index e0f033869..d7757960b 100644 --- a/src/PickerInput/SinglePicker.tsx +++ b/src/PickerInput/SinglePicker.tsx @@ -415,7 +415,9 @@ function Picker( const presetList = usePresets(presets); const onPresetHover = (nextValue: DateType | null) => { - setInternalHoverValue(nextValue); + if (showHoverValue) { + setInternalHoverValue(nextValue); + } setHoverSource('preset'); }; From bd871ce664c3425b7b14563c1b1c95792e5c4c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=87=E8=A7=81=E5=90=8C=E5=AD=A6?= <1875694521@qq.com> Date: Wed, 30 Jul 2025 11:26:57 +0800 Subject: [PATCH 5/6] feat: update test case --- tests/generateWithTZ.spec.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/generateWithTZ.spec.tsx b/tests/generateWithTZ.spec.tsx index d53b344d8..852601544 100644 --- a/tests/generateWithTZ.spec.tsx +++ b/tests/generateWithTZ.spec.tsx @@ -38,6 +38,16 @@ describe('dayjs: getNow', () => { const M_now = moment().tz(JP); expect(D_now.format()).toEqual(M_now.format()); - expect(D_now.get('hour') - D_now.utc().get('hour')).toEqual(9); + + const expectedOffset = M_now.utcOffset() / 60; + const actualOffset = D_now.get('hour') - D_now.utc().get('hour'); + + let normalizedOffset = actualOffset; + if (actualOffset > 12) { + normalizedOffset = actualOffset - 24; + } else if (actualOffset < -12) { + normalizedOffset = actualOffset + 24; + } + expect(normalizedOffset).toEqual(expectedOffset); }); }); From ca23b8a125446a370bee5f3b40608b23acc570a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=87=E8=A7=81=E5=90=8C=E5=AD=A6?= <1875694521@qq.com> Date: Thu, 31 Jul 2025 20:43:07 +0800 Subject: [PATCH 6/6] feat: update api key --- README.md | 4 ++-- docs/examples/basic.tsx | 9 ++------- docs/examples/range.tsx | 4 ++-- docs/examples/time.tsx | 4 ++-- src/PickerInput/RangePicker.tsx | 6 +++--- src/PickerInput/SinglePicker.tsx | 6 +++--- src/PickerInput/hooks/useFilledProps.ts | 3 +++ src/interface.tsx | 8 ++++++-- tests/range.spec.tsx | 4 ++-- tests/time.spec.tsx | 4 ++-- 10 files changed, 27 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 76792b8b5..9d66c2562 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ render(, mountNode); | autoFocus | boolean | false | whether auto focus | | showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection | | picker | time \| date \| week \| month \| year | | control which kind of panel should be shown | -| showHoverValue | boolean | true | When the user selects the date hover option, the value of the input field undergoes a temporary change | +| previewValue | false \| hover | hover | When the user selects the date hover option, the value of the input field undergoes a temporary change | | format | String \| String[] | depends on whether you set timePicker and your locale | use to format/parse date(without time) value to/from input. When an array is provided, all values are used for parsing and first value for display | | use12Hours | boolean | false | 12 hours display mode | | value | moment | | current value like input's value | @@ -113,7 +113,7 @@ render(, mountNode); | defaultPickerValue | moment | | Set default display picker view date | | separator | String | '~' | set separator between inputs | | picker | time \| date \| week \| month \| year | | control which kind of panel | -| showHoverValue | boolean | true | When the user selects the date hover option, the value of the input field undergoes a temporary change | +| previewValue | false \| hover | hover | When the user selects the date hover option, the value of the input field undergoes a temporary change | | placeholder | [String, String] | | placeholder of date input | | showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection | | showTime.defaultValue | [moment, moment] | | to set default time of selected date | diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index 262b2922b..acff81877 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -155,13 +155,8 @@ export default () => { {...sharedProps} locale={enUS} onKeyDown={keyDown} />
-

ShowHoverValue is false

- - {...sharedProps} - locale={enUS} - onKeyDown={keyDown} - showHoverValue={false} - /> +

PreviewValue is false

+ {...sharedProps} locale={enUS} onKeyDown={keyDown} previewValue={false} />
diff --git a/docs/examples/range.tsx b/docs/examples/range.tsx index cfe347d15..23f50ea00 100644 --- a/docs/examples/range.tsx +++ b/docs/examples/range.tsx @@ -203,10 +203,10 @@ export default () => { />
-

ShowHoverValue is false

+

PreviewValue is false

{...sharedProps} - showHoverValue={false} + previewValue={false} value={undefined} locale={zhCN} placeholder={['start...', 'end...']} diff --git a/docs/examples/time.tsx b/docs/examples/time.tsx index 0a5e0fdb8..419b519c8 100644 --- a/docs/examples/time.tsx +++ b/docs/examples/time.tsx @@ -54,12 +54,12 @@ export default () => { })} /> -

showHoverValue is false

+

PreviewValue is false

({ disabledHours: () => (type === 'start' ? [now.hours()] : [now.hours() - 5]), diff --git a/src/PickerInput/RangePicker.tsx b/src/PickerInput/RangePicker.tsx index 80500a81a..2c18130e2 100644 --- a/src/PickerInput/RangePicker.tsx +++ b/src/PickerInput/RangePicker.tsx @@ -164,7 +164,7 @@ function RangePicker( styles: propStyles, classNames: propClassNames, - showHoverValue = true, + previewValue, // Value defaultValue, value, @@ -488,7 +488,7 @@ function RangePicker( const presetList = usePresets(presets, ranges); const onPresetHover = (nextValues: RangeValueType | null) => { - if (showHoverValue) { + if (previewValue === 'hover') { setInternalHoverValues(nextValues); } setHoverSource('preset'); @@ -508,7 +508,7 @@ function RangePicker( // ======================== Panel ========================= const onPanelHover = (date: DateType) => { - if (showHoverValue) { + if (previewValue === 'hover') { setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null); } setHoverSource('cell'); diff --git a/src/PickerInput/SinglePicker.tsx b/src/PickerInput/SinglePicker.tsx index d7757960b..64991b951 100644 --- a/src/PickerInput/SinglePicker.tsx +++ b/src/PickerInput/SinglePicker.tsx @@ -128,7 +128,7 @@ function Picker( styles: propStyles, classNames: propClassNames, - showHoverValue = true, + previewValue, // Value order, @@ -415,7 +415,7 @@ function Picker( const presetList = usePresets(presets); const onPresetHover = (nextValue: DateType | null) => { - if (showHoverValue) { + if (previewValue === 'hover') { setInternalHoverValue(nextValue); } setHoverSource('preset'); @@ -437,7 +437,7 @@ function Picker( // ======================== Panel ========================= const onPanelHover = (date: DateType | null) => { - if (showHoverValue) { + if (previewValue === 'hover') { setInternalHoverValue(date); } setHoverSource('cell'); diff --git a/src/PickerInput/hooks/useFilledProps.ts b/src/PickerInput/hooks/useFilledProps.ts index 26178c967..8cdd895cd 100644 --- a/src/PickerInput/hooks/useFilledProps.ts +++ b/src/PickerInput/hooks/useFilledProps.ts @@ -33,6 +33,7 @@ type PickedProps = Pick< | 'minDate' | 'maxDate' | 'defaultOpenValue' + | 'previewValue' > & { multiple?: boolean; // RangePicker showTime definition is different with Picker @@ -96,6 +97,7 @@ export default function useFilledProps< locale, picker = 'date', prefixCls = 'rc-picker', + previewValue = 'hover', styles = {}, classNames = {}, order = true, @@ -161,6 +163,7 @@ export default function useFilledProps< const filledProps = React.useMemo( () => ({ ...props, + previewValue, prefixCls, locale: mergedLocale, picker, diff --git a/src/interface.tsx b/src/interface.tsx index 91814d080..99f9b6767 100644 --- a/src/interface.tsx +++ b/src/interface.tsx @@ -313,6 +313,8 @@ export type LegacyOnKeyDown = ( export type SemanticName = 'root' | 'prefix' | 'input' | 'suffix'; +export type PreviewValueType = 'hover'; + export type PanelSemanticName = 'root' | 'header' | 'body' | 'content' | 'item' | 'footer'; export interface SharedPickerProps @@ -426,9 +428,11 @@ export interface SharedPickerProps preserveInvalidOnBlur?: boolean; /** - * When the user selects the date hover option, the value of the input field undergoes a temporary change + * When the user selects the date hover option, the value of the input field undergoes a temporary change. + * `false` will not preview value. + * `hover` will preview value when hover. */ - showHoverValue?: boolean; + previewValue?: false | PreviewValueType; // Motion transitionName?: string; diff --git a/tests/range.spec.tsx b/tests/range.spec.tsx index 7bd023cd0..b5173a656 100644 --- a/tests/range.spec.tsx +++ b/tests/range.spec.tsx @@ -2121,14 +2121,14 @@ describe('Picker.Range', () => { expect(container.querySelectorAll('.rc-picker-input')[0]).toHaveClass('rc-picker-input-active'); }); - it('should not update preview value in input when showHoverValue is false', () => { + it('should not update preview value in input when previewValue is false', () => { const { container } = render( , diff --git a/tests/time.spec.tsx b/tests/time.spec.tsx index ba0f544ab..afcd4841c 100644 --- a/tests/time.spec.tsx +++ b/tests/time.spec.tsx @@ -70,14 +70,14 @@ describe('Picker.Time', () => { expect(container.querySelector('input')).toHaveValue('1990-09-03 12:00:00.000 PM'); }); - it('hover should not update preview value in input when showHoverValue is false', async () => { + it('hover should not update preview value in input when previewValue is false', async () => { const { container } = render( , );