Skip to content

Commit 9bb291b

Browse files
committed
feat: update
1 parent 4e75254 commit 9bb291b

File tree

9 files changed

+21
-16
lines changed

9 files changed

+21
-16
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +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 |
5758
| 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 |
5859
| use12Hours | boolean | false | 12 hours display mode |
5960
| value | moment | | current value like input's value |
@@ -102,7 +103,7 @@ render(<Picker />, mountNode);
102103
### RangePicker
103104

104105
| Property | Type | Default | Description |
105-
| --- | --- | --- | --- |
106+
| --- | --- | --- | --- | --- |
106107
| prefixCls | String | rc-picker | prefixCls of this component |
107108
| className | String | '' | additional css class of root dom |
108109
| style | React.CSSProperties | | additional style of root dom node |
@@ -112,6 +113,7 @@ render(<Picker />, mountNode);
112113
| defaultPickerValue | moment | | Set default display picker view date |
113114
| separator | String | '~' | set separator between inputs |
114115
| 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 |
115117
| placeholder | [String, String] | | placeholder of date input |
116118
| showTime | boolean \| Object | [showTime options](#showTime-options) | to provide an additional time selection |
117119
| showTime.defaultValue | [moment, moment] | | to set default time of selected date |

docs/examples/basic.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ export default () => {
155155
<Picker<Moment> {...sharedProps} locale={enUS} onKeyDown={keyDown} />
156156
</div>
157157
<div style={{ margin: '0 8px' }}>
158-
<h3>ShowPreviewValue is false</h3>
158+
<h3>ShowHoverValue is false</h3>
159159
<Picker<Moment>
160160
{...sharedProps}
161161
locale={enUS}
162162
onKeyDown={keyDown}
163-
showPreviewValue={false}
163+
showHoverValue={false}
164164
/>
165165
</div>
166166
</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>ShowPreviewValue is false</h3>
206+
<h3>ShowHoverValue is false</h3>
207207
<RangePicker<Moment>
208208
{...sharedProps}
209-
showPreviewValue={false}
209+
showHoverValue={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>ShowPreviewValue is false</h3>
57+
<h3>showHoverValue is false</h3>
5858
<RangePicker
5959
defaultValue={[defaultValue, defaultValue]}
6060
picker="time"
6161
locale={zhCN}
62-
showPreviewValue={false}
62+
showHoverValue={false}
6363
generateConfig={momentGenerateConfig}
6464
disabledTime={(now, type) => ({
6565
disabledHours: () => (type === 'start' ? [now.hours()] : [now.hours() - 5]),

src/PickerInput/RangePicker.tsx

Lines changed: 2 additions & 2 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-
showPreviewValue = true,
167+
showHoverValue = true,
168168
// Value
169169
defaultValue,
170170
value,
@@ -506,7 +506,7 @@ function RangePicker<DateType extends object = any>(
506506

507507
// ======================== Panel =========================
508508
const onPanelHover = (date: DateType) => {
509-
if (showPreviewValue) {
509+
if (showHoverValue) {
510510
setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null);
511511
}
512512
setHoverSource('cell');

src/PickerInput/SinglePicker.tsx

Lines changed: 2 additions & 2 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-
showPreviewValue = true,
131+
showHoverValue = true,
132132

133133
// Value
134134
order,
@@ -435,7 +435,7 @@ function Picker<DateType extends object = any>(
435435

436436
// ======================== Panel =========================
437437
const onPanelHover = (date: DateType | null) => {
438-
if (showPreviewValue) {
438+
if (showHoverValue) {
439439
setInternalHoverValue(date);
440440
}
441441
setHoverSource('cell');

src/interface.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,10 @@ export interface SharedPickerProps<DateType extends object = any>
425425
*/
426426
preserveInvalidOnBlur?: boolean;
427427

428-
showPreviewValue?: boolean;
428+
/**
429+
* When the user selects the date hover option, the value of the input field undergoes a temporary change
430+
*/
431+
showHoverValue?: boolean;
429432

430433
// Motion
431434
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 showPreviewValue is false', () => {
2124+
it('should not update preview value in input when showHoverValue is false', () => {
21252125
const { container } = render(
21262126
<DayRangePicker
21272127
minDate={dayjs('2024')}
21282128
open
21292129
mode={['year', 'year']}
21302130
showTime
2131-
showPreviewValue={false}
2131+
showHoverValue={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 showPreviewValue is false', async () => {
73+
it('hover should not update preview value in input when showHoverValue is false', async () => {
7474
const { container } = render(
7575
<DayPicker
7676
showTime={{
7777
showMillisecond: true,
7878
use12Hours: true,
7979
}}
80-
showPreviewValue={false}
80+
showHoverValue={false}
8181
defaultValue={dayjs('1990-09-03 01:02:03')}
8282
/>,
8383
);

0 commit comments

Comments
 (0)