Skip to content

Commit

Permalink
chore: more types
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Dec 7, 2023
1 parent 8973dee commit 77bd724
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/NewPicker/PickerInput/SinglePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function Picker<DateType extends object = any>(
activeIndex,
setActiveIndex,
nextActiveIndex,
activeIndexList,
// activeIndexList,
] = useRangeActive([disabled]);

const onSharedFocus = (event: React.FocusEvent<HTMLElement>) => {
Expand Down Expand Up @@ -278,6 +278,18 @@ function Picker<DateType extends object = any>(
// ===================== Picker Value =====================
const timeDefaultValue = showTime?.defaultValue;

// Proxy to single pickerValue
const onInternalPickerValueChange = (
dates: DateType[],
info: BaseInfo & { source: 'reset' | 'panel' },
) => {
if (onPickerValueChange) {
const cleanInfo = { ...info };
delete cleanInfo.range;
onPickerValueChange(dates[0], cleanInfo);
}
};

const [currentPickerValue, setCurrentPickerValue] = useRangePickerValue(
generateConfig,
locale,
Expand All @@ -289,7 +301,7 @@ function Picker<DateType extends object = any>(
defaultPickerValue,
pickerValue,
timeDefaultValue ? [timeDefaultValue] : undefined,
onPickerValueChange,
onInternalPickerValueChange,
minDate,
maxDate,
);
Expand Down

0 comments on commit 77bd724

Please sign in to comment.