Skip to content

Commit 6c68505

Browse files
committed
chore: more info
1 parent a71aed3 commit 6c68505

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

src/NewPicker/PickerInput/hooks/useFlexibleValue.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEvent, useMergedState } from 'rc-util';
22
import * as React from 'react';
33
import type { GenerateConfig } from '../../../generate';
4-
import { formatValue, isSame, isSameTimestamp } from '../../../utils/dateUtil';
4+
import { isSame } from '../../../utils/dateUtil';
55
import useSyncState from '../../hooks/useSyncState';
66
import type { FormatType, Locale } from '../../interface';
77
import { fillIndex } from '../../util';
@@ -88,7 +88,7 @@ export default function useFlexibleValue<DateType extends object = any>(
8888
setInnerValue: (nextValue: DateType) => void,
8989
getCalendarValue: () => DateType,
9090
triggerCalendarChange: TriggerCalendarChange<DateType>,
91-
disabled: [boolean, boolean],
91+
disabled: boolean,
9292
formatList: FormatType[],
9393
focused: boolean,
9494
open: boolean,
@@ -113,25 +113,10 @@ export default function useFlexibleValue<DateType extends object = any>(
113113
order,
114114
} = info;
115115

116-
const orderOnChange = disabled.some((d) => d) ? false : order;
116+
const orderOnChange = true;
117117

118118
// ============================= Util =============================
119-
const getDateTexts = ([start, end]: DateType) => {
120-
return [start, end].map((date) =>
121-
formatValue(date, { generateConfig, locale, format: formatList[0] }),
122-
) as [string, string];
123-
};
124-
125-
const isSameDates = (source: DateType, target: DateType) => {
126-
const [prevStart = null, prevEnd = null] = source;
127-
const [nextStart = null, nextEnd = null] = target;
128-
129-
const isSameStart =
130-
prevStart === nextStart || isSameTimestamp(generateConfig, prevStart, nextStart);
131-
const isSameEnd = prevEnd === nextEnd || isSameTimestamp(generateConfig, prevEnd, nextEnd);
132-
133-
return [isSameStart && isSameEnd, isSameStart, isSameEnd];
134-
};
119+
const [getDateTexts, isSameDates] = useUtil(generateConfig, locale, formatList);
135120

136121
// ============================ Values ============================
137122
// Used for trigger `onChange` event.

0 commit comments

Comments
 (0)