Skip to content

Commit ca23b8a

Browse files
committed
feat: update api key
1 parent bd871ce commit ca23b8a

File tree

10 files changed

+27
-25
lines changed

10 files changed

+27
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ render(<Picker />, mountNode);
5454
| autoFocus | boolean | false | whether auto focus |
5555
| showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection |
5656
| picker | time \| date \| week \| month \| year | | control which kind of panel should be shown |
57-
| showHoverValue | boolean | true | When the user selects the date hover option, the value of the input field undergoes a temporary change |
57+
| previewValue | false \| hover | hover | When the user selects the date hover option, the value of the input field undergoes a temporary change |
5858
| 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 |
5959
| use12Hours | boolean | false | 12 hours display mode |
6060
| value | moment | | current value like input's value |
@@ -113,7 +113,7 @@ render(<Picker />, mountNode);
113113
| defaultPickerValue | moment | | Set default display picker view date |
114114
| separator | String | '~' | set separator between inputs |
115115
| picker | time \| date \| week \| month \| year | | control which kind of panel |
116-
| showHoverValue | boolean | true | When the user selects the date hover option, the value of the input field undergoes a temporary change |
116+
| previewValue | false \| hover | hover | When the user selects the date hover option, the value of the input field undergoes a temporary change |
117117
| placeholder | [String, String] | | placeholder of date input |
118118
| showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection |
119119
| showTime.defaultValue | [moment, moment] | | to set default time of selected date |

docs/examples/basic.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,8 @@ export default () => {
155155
<Picker<Moment> {...sharedProps} locale={enUS} onKeyDown={keyDown} />
156156
</div>
157157
<div style={{ margin: '0 8px' }}>
158-
<h3>ShowHoverValue is false</h3>
159-
<Picker<Moment>
160-
{...sharedProps}
161-
locale={enUS}
162-
onKeyDown={keyDown}
163-
showHoverValue={false}
164-
/>
158+
<h3>PreviewValue is false</h3>
159+
<Picker<Moment> {...sharedProps} locale={enUS} onKeyDown={keyDown} previewValue={false} />
165160
</div>
166161
</div>
167162
</div>

docs/examples/range.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ export default () => {
203203
/>
204204
</div>
205205
<div style={{ margin: '0 8px' }}>
206-
<h3>ShowHoverValue is false</h3>
206+
<h3>PreviewValue is false</h3>
207207
<RangePicker<Moment>
208208
{...sharedProps}
209-
showHoverValue={false}
209+
previewValue={false}
210210
value={undefined}
211211
locale={zhCN}
212212
placeholder={['start...', 'end...']}

docs/examples/time.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ export default () => {
5454
})}
5555
/>
5656

57-
<h3>showHoverValue is false</h3>
57+
<h3>PreviewValue is false</h3>
5858
<RangePicker
5959
defaultValue={[defaultValue, defaultValue]}
6060
picker="time"
6161
locale={zhCN}
62-
showHoverValue={false}
62+
previewValue={false}
6363
generateConfig={momentGenerateConfig}
6464
disabledTime={(now, type) => ({
6565
disabledHours: () => (type === 'start' ? [now.hours()] : [now.hours() - 5]),

src/PickerInput/RangePicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function RangePicker<DateType extends object = any>(
164164
styles: propStyles,
165165
classNames: propClassNames,
166166

167-
showHoverValue = true,
167+
previewValue,
168168
// Value
169169
defaultValue,
170170
value,
@@ -488,7 +488,7 @@ function RangePicker<DateType extends object = any>(
488488
const presetList = usePresets(presets, ranges);
489489

490490
const onPresetHover = (nextValues: RangeValueType<DateType> | null) => {
491-
if (showHoverValue) {
491+
if (previewValue === 'hover') {
492492
setInternalHoverValues(nextValues);
493493
}
494494
setHoverSource('preset');
@@ -508,7 +508,7 @@ function RangePicker<DateType extends object = any>(
508508

509509
// ======================== Panel =========================
510510
const onPanelHover = (date: DateType) => {
511-
if (showHoverValue) {
511+
if (previewValue === 'hover') {
512512
setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null);
513513
}
514514
setHoverSource('cell');

src/PickerInput/SinglePicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function Picker<DateType extends object = any>(
128128
styles: propStyles,
129129
classNames: propClassNames,
130130

131-
showHoverValue = true,
131+
previewValue,
132132

133133
// Value
134134
order,
@@ -415,7 +415,7 @@ function Picker<DateType extends object = any>(
415415
const presetList = usePresets(presets);
416416

417417
const onPresetHover = (nextValue: DateType | null) => {
418-
if (showHoverValue) {
418+
if (previewValue === 'hover') {
419419
setInternalHoverValue(nextValue);
420420
}
421421
setHoverSource('preset');
@@ -437,7 +437,7 @@ function Picker<DateType extends object = any>(
437437

438438
// ======================== Panel =========================
439439
const onPanelHover = (date: DateType | null) => {
440-
if (showHoverValue) {
440+
if (previewValue === 'hover') {
441441
setInternalHoverValue(date);
442442
}
443443
setHoverSource('cell');

src/PickerInput/hooks/useFilledProps.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type PickedProps<DateType extends object = any> = Pick<
3333
| 'minDate'
3434
| 'maxDate'
3535
| 'defaultOpenValue'
36+
| 'previewValue'
3637
> & {
3738
multiple?: boolean;
3839
// RangePicker showTime definition is different with Picker
@@ -96,6 +97,7 @@ export default function useFilledProps<
9697
locale,
9798
picker = 'date',
9899
prefixCls = 'rc-picker',
100+
previewValue = 'hover',
99101
styles = {},
100102
classNames = {},
101103
order = true,
@@ -161,6 +163,7 @@ export default function useFilledProps<
161163
const filledProps = React.useMemo(
162164
() => ({
163165
...props,
166+
previewValue,
164167
prefixCls,
165168
locale: mergedLocale,
166169
picker,

src/interface.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ export type LegacyOnKeyDown = (
313313

314314
export type SemanticName = 'root' | 'prefix' | 'input' | 'suffix';
315315

316+
export type PreviewValueType = 'hover';
317+
316318
export type PanelSemanticName = 'root' | 'header' | 'body' | 'content' | 'item' | 'footer';
317319

318320
export interface SharedPickerProps<DateType extends object = any>
@@ -426,9 +428,11 @@ export interface SharedPickerProps<DateType extends object = any>
426428
preserveInvalidOnBlur?: boolean;
427429

428430
/**
429-
* When the user selects the date hover option, the value of the input field undergoes a temporary change
431+
* When the user selects the date hover option, the value of the input field undergoes a temporary change.
432+
* `false` will not preview value.
433+
* `hover` will preview value when hover.
430434
*/
431-
showHoverValue?: boolean;
435+
previewValue?: false | PreviewValueType;
432436

433437
// Motion
434438
transitionName?: string;

tests/range.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,14 +2121,14 @@ describe('Picker.Range', () => {
21212121
expect(container.querySelectorAll('.rc-picker-input')[0]).toHaveClass('rc-picker-input-active');
21222122
});
21232123

2124-
it('should not update preview value in input when showHoverValue is false', () => {
2124+
it('should not update preview value in input when previewValue is false', () => {
21252125
const { container } = render(
21262126
<DayRangePicker
21272127
minDate={dayjs('2024')}
21282128
open
21292129
mode={['year', 'year']}
21302130
showTime
2131-
showHoverValue={false}
2131+
previewValue={false}
21322132
needConfirm
21332133
value={[dayjs('2024-01-01'), dayjs('2025-01-01')]}
21342134
/>,

tests/time.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ describe('Picker.Time', () => {
7070
expect(container.querySelector('input')).toHaveValue('1990-09-03 12:00:00.000 PM');
7171
});
7272

73-
it('hover should not update preview value in input when showHoverValue is false', async () => {
73+
it('hover should not update preview value in input when previewValue is false', async () => {
7474
const { container } = render(
7575
<DayPicker
7676
showTime={{
7777
showMillisecond: true,
7878
use12Hours: true,
7979
}}
80-
showHoverValue={false}
80+
previewValue={false}
8181
defaultValue={dayjs('1990-09-03 01:02:03')}
8282
/>,
8383
);

0 commit comments

Comments
 (0)