Skip to content

Commit

Permalink
chore: comment it
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Dec 6, 2023
1 parent c0bc3e5 commit 8365a39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
38 changes: 14 additions & 24 deletions src/NewPicker/PickerInput/SinglePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
import omit from 'rc-util/lib/omit';
import pickAttrs from 'rc-util/lib/pickAttrs';
import * as React from 'react';
import useLocale from '../hooks/useLocale';
import useTimeConfig from '../hooks/useTimeConfig';
import type {
BaseInfo,
Expand All @@ -22,6 +21,7 @@ import PickerContext from './context';
import useCellRender from './hooks/useCellRender';
import useDisabledBoundary from './hooks/useDisabledBoundary';
import { useFieldFormat } from './hooks/useFieldFormat';
import useFilledProps from './hooks/useFilledProps';
import useRangeValue, { useInnerValue } from './hooks/useFlexibleValue';
import useInputReadOnly from './hooks/useInputReadOnly';
import useInvalidate from './hooks/useInvalidate';
Expand Down Expand Up @@ -101,11 +101,14 @@ function Picker<DateType extends object = any>(
props: PickerProps<DateType>,
ref: React.Ref<PickerRef>,
) {
// ========================= Prop =========================
const filledProps = useFilledProps(props);

const {
// Style
prefixCls = 'rc-picker',
styles = {},
classNames = {},
prefixCls,
styles,
classNames,

// Value
defaultValue,
Expand All @@ -128,7 +131,7 @@ function Picker<DateType extends object = any>(
// Picker
locale,
generateConfig,
picker = 'date',
picker,
showNow,
showToday,

Expand Down Expand Up @@ -164,34 +167,21 @@ function Picker<DateType extends object = any>(
clearIcon,

// Render
components = {},
components,
cellRender,
dateRender,
monthCellRender,

// Native
onClick,
} = props;
} = filledProps;

// ========================= Refs =========================
const selectorRef = usePickerRef(ref);

// ======================== Locale ========================
const filledLocale = useLocale(locale);

// ========================= Icon =========================
const mergedClearIcon = useClearIcon(prefixCls, allowClear, clearIcon);

// ========================= Prop =========================
const filledProps = React.useMemo(
() => ({
...props,
locale: filledLocale,
picker,
}),
[props],
);

// ======================= ShowTime =======================
const mergedShowTime = useTimeConfig(filledProps);

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

// ======================== Format ========================
const [formatList, maskFormat] = useFieldFormat(internalPicker, filledLocale, format);
const [formatList, maskFormat] = useFieldFormat(internalPicker, locale, format);

// ======================== Values ========================
const [mergedValue, setInnerValue, getCalendarValue, triggerCalendarChange] = useInnerValue(
Expand Down Expand Up @@ -345,7 +335,7 @@ function Picker<DateType extends object = any>(
// ===================== Picker Value =====================
const [currentPickerValue, setCurrentPickerValue] = useRangePickerValue(
generateConfig,
filledLocale,
locale,
calendarValue,
mergedOpen,
activeIndex,
Expand Down Expand Up @@ -613,12 +603,12 @@ function Picker<DateType extends object = any>(
const context = React.useMemo(
() => ({
prefixCls,
locale: filledLocale,
locale,
generateConfig,
button: components.button,
input: components.input,
}),
[prefixCls, filledLocale, generateConfig, components.button, components.input],
[prefixCls, locale, generateConfig, components.button, components.input],
);

// ======================== Effect ========================
Expand Down
1 change: 1 addition & 0 deletions src/NewPicker/PickerInput/hooks/useFilledProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type PickedProps<DateType extends object = any> = Pick<
'locale' | 'picker' | 'prefixCls' | 'styles' | 'classNames' | 'order' | 'components'
>;

/** Align the outer props with unique typed and fill undefined props */
export default function useFilledProps<
DateType extends object = any,
InProps extends PickedProps<DateType> = PickedProps<DateType>,
Expand Down

0 comments on commit 8365a39

Please sign in to comment.