Skip to content

Commit

Permalink
chore: tmp of it
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Dec 5, 2023
1 parent 645ffc0 commit 3304389
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/NewPicker/PickerInput/RangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function RangePicker<DateType extends object = any>(
false,
]);

const onSelectorInvalid = (index: number, valid: boolean) => {
const onSelectorInvalid = (valid: boolean, index: number) => {
setFieldsInvalidates((ori) => fillIndex(ori, index, valid));
};

Expand Down
7 changes: 4 additions & 3 deletions src/NewPicker/PickerInput/Selector/RangeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export type SelectorIdType =
export interface RangeSelectorProps<DateType = any> extends SelectorProps<DateType> {
id?: SelectorIdType;

activeIndex: number | null;

separator?: React.ReactNode;

value?: [DateType?, DateType?];
Expand All @@ -31,7 +33,6 @@ export interface RangeSelectorProps<DateType = any> extends SelectorProps<DateTy

// Invalid
invalid: [boolean, boolean];
onInvalid: (index: number, valid: boolean) => void;

// Offset
/**
Expand Down Expand Up @@ -242,14 +243,14 @@ function RangeSelector<DateType = any>(
const parsed = validateFormat(text);

if (parsed) {
onInvalid(index, false);
onInvalid(false, index);
onChange(parsed, index);
return;
}

// Tell outer that the value typed is invalid.
// If text is empty, it means valid.
onInvalid(index, !!text);
onInvalid(!!text, index);
},
onHelp: () => {
triggerOpen(true, index);
Expand Down
2 changes: 2 additions & 0 deletions src/NewPicker/PickerInput/Selector/hooks/useInputProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function useInputProps<DateType extends object = any>(
invalid?: boolean | [boolean, boolean];
placeholder?: string | [string, string];
disabled?: boolean | [boolean, boolean];
activeIndex?: number | null;
},
) {
const {
Expand All @@ -45,6 +46,7 @@ export default function useInputProps<DateType extends object = any>(
invalid,
placeholder,
disabled,
activeIndex,
} = props;

// ======================== Parser ========================
Expand Down
2 changes: 1 addition & 1 deletion src/NewPicker/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ export interface SelectorProps<DateType = any> extends SharedHTMLAttrs {
suffixIcon?: React.ReactNode;
className?: string;
style?: React.CSSProperties;
activeIndex: number | null;
/** Add `-placeholder` className as a help info */
activeHelp?: boolean;
focused: boolean;
Expand Down Expand Up @@ -424,6 +423,7 @@ export interface SelectorProps<DateType = any> extends SharedHTMLAttrs {
maskFormat?: string;
onChange: (date: DateType, index?: number) => void;
onInputChange: VoidFunction;
onInvalid: (valid: boolean, index?: number) => void;
/** When user input invalidate date, keep it in the input field */
/**
* By default value in input field will be reset with previous valid value when blur.
Expand Down

0 comments on commit 3304389

Please sign in to comment.