File tree Expand file tree Collapse file tree 2 files changed +27
-10
lines changed
src/NewPicker/PickerInput Expand file tree Collapse file tree 2 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import PickerContext from './context';
26
26
import useCellRender from './hooks/useCellRender' ;
27
27
import useDisabledBoundary from './hooks/useDisabledBoundary' ;
28
28
import { useFieldFormat } from './hooks/useFieldFormat' ;
29
+ import useFilledProps from './hooks/useFilledProps' ;
29
30
import useInputReadOnly from './hooks/useInputReadOnly' ;
30
31
import useInvalidate from './hooks/useInvalidate' ;
31
32
import useOpen from './hooks/useOpen' ;
@@ -219,16 +220,10 @@ function RangePicker<DateType extends object = any>(
219
220
const mergedClearIcon = useClearIcon ( prefixCls , allowClear , clearIcon ) ;
220
221
221
222
// ========================= Prop =========================
222
- const filledProps = React . useMemo (
223
- ( ) => ( {
224
- ...props ,
225
- locale : filledLocale ,
226
- allowEmpty : mergedAllowEmpty ,
227
- order,
228
- picker,
229
- } ) ,
230
- [ props ] ,
231
- ) ;
223
+ const filledProps = useFilledProps ( props , {
224
+ allowEmpty : mergedAllowEmpty ,
225
+ order,
226
+ } ) ;
232
227
233
228
// ======================= ShowTime =======================
234
229
const mergedShowTime = useTimeConfig ( filledProps ) ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import useLocale from '../../hooks/useLocale' ;
3
+ import type { Locale , PickerMode } from '../../interface' ;
4
+
5
+ export default function useFilledProps < T extends { locale : Locale ; picker ?: PickerMode } > (
6
+ props : T ,
7
+ additionalProps ?: Partial < T > ,
8
+ ) : T {
9
+ const { locale, picker = 'date' } = props ;
10
+
11
+ const filledLocale = useLocale ( locale ) ;
12
+
13
+ return React . useMemo (
14
+ ( ) => ( {
15
+ ...props ,
16
+ locale : filledLocale ,
17
+ picker,
18
+ ...additionalProps ,
19
+ } ) ,
20
+ [ props ] ,
21
+ ) ;
22
+ }
You can’t perform that action at this time.
0 commit comments