Skip to content

Commit 8365a39

Browse files
committed
chore: comment it
1 parent c0bc3e5 commit 8365a39

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

src/NewPicker/PickerInput/SinglePicker.tsx

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
33
import omit from 'rc-util/lib/omit';
44
import pickAttrs from 'rc-util/lib/pickAttrs';
55
import * as React from 'react';
6-
import useLocale from '../hooks/useLocale';
76
import useTimeConfig from '../hooks/useTimeConfig';
87
import type {
98
BaseInfo,
@@ -22,6 +21,7 @@ import PickerContext from './context';
2221
import useCellRender from './hooks/useCellRender';
2322
import useDisabledBoundary from './hooks/useDisabledBoundary';
2423
import { useFieldFormat } from './hooks/useFieldFormat';
24+
import useFilledProps from './hooks/useFilledProps';
2525
import useRangeValue, { useInnerValue } from './hooks/useFlexibleValue';
2626
import useInputReadOnly from './hooks/useInputReadOnly';
2727
import useInvalidate from './hooks/useInvalidate';
@@ -101,11 +101,14 @@ function Picker<DateType extends object = any>(
101101
props: PickerProps<DateType>,
102102
ref: React.Ref<PickerRef>,
103103
) {
104+
// ========================= Prop =========================
105+
const filledProps = useFilledProps(props);
106+
104107
const {
105108
// Style
106-
prefixCls = 'rc-picker',
107-
styles = {},
108-
classNames = {},
109+
prefixCls,
110+
styles,
111+
classNames,
109112

110113
// Value
111114
defaultValue,
@@ -128,7 +131,7 @@ function Picker<DateType extends object = any>(
128131
// Picker
129132
locale,
130133
generateConfig,
131-
picker = 'date',
134+
picker,
132135
showNow,
133136
showToday,
134137

@@ -164,34 +167,21 @@ function Picker<DateType extends object = any>(
164167
clearIcon,
165168

166169
// Render
167-
components = {},
170+
components,
168171
cellRender,
169172
dateRender,
170173
monthCellRender,
171174

172175
// Native
173176
onClick,
174-
} = props;
177+
} = filledProps;
175178

176179
// ========================= Refs =========================
177180
const selectorRef = usePickerRef(ref);
178181

179-
// ======================== Locale ========================
180-
const filledLocale = useLocale(locale);
181-
182182
// ========================= Icon =========================
183183
const mergedClearIcon = useClearIcon(prefixCls, allowClear, clearIcon);
184184

185-
// ========================= Prop =========================
186-
const filledProps = React.useMemo(
187-
() => ({
188-
...props,
189-
locale: filledLocale,
190-
picker,
191-
}),
192-
[props],
193-
);
194-
195185
// ======================= ShowTime =======================
196186
const mergedShowTime = useTimeConfig(filledProps);
197187

@@ -209,7 +199,7 @@ function Picker<DateType extends object = any>(
209199
const mergedNeedConfirm = needConfirm ?? complexPicker;
210200

211201
// ======================== Format ========================
212-
const [formatList, maskFormat] = useFieldFormat(internalPicker, filledLocale, format);
202+
const [formatList, maskFormat] = useFieldFormat(internalPicker, locale, format);
213203

214204
// ======================== Values ========================
215205
const [mergedValue, setInnerValue, getCalendarValue, triggerCalendarChange] = useInnerValue(
@@ -345,7 +335,7 @@ function Picker<DateType extends object = any>(
345335
// ===================== Picker Value =====================
346336
const [currentPickerValue, setCurrentPickerValue] = useRangePickerValue(
347337
generateConfig,
348-
filledLocale,
338+
locale,
349339
calendarValue,
350340
mergedOpen,
351341
activeIndex,
@@ -613,12 +603,12 @@ function Picker<DateType extends object = any>(
613603
const context = React.useMemo(
614604
() => ({
615605
prefixCls,
616-
locale: filledLocale,
606+
locale,
617607
generateConfig,
618608
button: components.button,
619609
input: components.input,
620610
}),
621-
[prefixCls, filledLocale, generateConfig, components.button, components.input],
611+
[prefixCls, locale, generateConfig, components.button, components.input],
622612
);
623613

624614
// ======================== Effect ========================

src/NewPicker/PickerInput/hooks/useFilledProps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type PickedProps<DateType extends object = any> = Pick<
77
'locale' | 'picker' | 'prefixCls' | 'styles' | 'classNames' | 'order' | 'components'
88
>;
99

10+
/** Align the outer props with unique typed and fill undefined props */
1011
export default function useFilledProps<
1112
DateType extends object = any,
1213
InProps extends PickedProps<DateType> = PickedProps<DateType>,

0 commit comments

Comments
 (0)