@king-design/react 3.5.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/cascader/index.spec.js +18 -19
- package/components/datepicker/basepicker.d.ts +6 -25
- package/components/datepicker/basepicker.js +22 -234
- package/components/datepicker/calendar.d.ts +36 -6
- package/components/datepicker/calendar.js +4 -0
- package/components/datepicker/calendar.vdt.js +21 -5
- package/components/datepicker/dayjs.d.ts +2 -2
- package/components/datepicker/dayjs.js +6 -0
- package/components/datepicker/helpers.d.ts +8 -7
- package/components/datepicker/helpers.js +2 -3
- package/components/datepicker/index.d.ts +26 -19
- package/components/datepicker/index.js +21 -13
- package/components/datepicker/index.spec.js +1389 -633
- package/components/datepicker/index.vdt.js +43 -46
- package/components/datepicker/shortcuts.d.ts +1 -1
- package/components/datepicker/styles.d.ts +22 -0
- package/components/datepicker/styles.js +26 -4
- package/components/datepicker/useConfirm.d.ts +6 -0
- package/components/datepicker/useConfirm.js +65 -0
- package/components/datepicker/useDisabled.d.ts +7 -5
- package/components/datepicker/useDisabled.js +22 -27
- package/components/datepicker/useFormats.d.ts +2 -2
- package/components/datepicker/useFormats.js +9 -3
- package/components/datepicker/useHighlight.d.ts +14 -0
- package/components/datepicker/useHighlight.js +60 -0
- package/components/datepicker/useKeyboards.js +2 -1
- package/components/datepicker/useMergeRange.d.ts +5 -0
- package/components/datepicker/useMergeRange.js +45 -0
- package/components/datepicker/useMonths.js +5 -3
- package/components/datepicker/usePanel.d.ts +1 -10
- package/components/datepicker/usePanel.js +19 -32
- package/components/datepicker/useQuarters.d.ts +15 -0
- package/components/datepicker/useQuarters.js +36 -0
- package/components/datepicker/useShowDate.js +10 -2
- package/components/datepicker/useStatus.d.ts +1 -1
- package/components/datepicker/useStatus.js +33 -16
- package/components/datepicker/useValue.d.ts +12 -6
- package/components/datepicker/useValue.js +49 -45
- package/components/datepicker/useValueBase.d.ts +28 -0
- package/components/datepicker/useValueBase.js +277 -0
- package/components/datepicker/useWeeks.d.ts +19 -0
- package/components/datepicker/useWeeks.js +48 -0
- package/components/datepicker/useYears.js +6 -3
- package/components/dialog/useFixBody.js +6 -58
- package/components/dropdown/dropdown.d.ts +1 -0
- package/components/dropdown/dropdown.js +7 -4
- package/components/ellipsis/styles.js +1 -1
- package/components/form/styles.js +1 -1
- package/components/input/index.d.ts +2 -0
- package/components/input/index.js +6 -0
- package/components/input/index.spec.js +45 -0
- package/components/input/index.vdt.js +4 -3
- package/components/input/useAutoWidth.d.ts +2 -0
- package/components/input/useAutoWidth.js +19 -1
- package/components/scrollSelect/index.spec.js +4 -6
- package/components/scrollSelect/useMouseEvents.js +22 -9
- package/components/select/base.d.ts +1 -1
- package/components/select/base.js +3 -2
- package/components/select/base.vdt.js +5 -2
- package/components/select/index.spec.js +329 -82
- package/components/select/option.d.ts +1 -0
- package/components/select/option.js +10 -2
- package/components/select/select.d.ts +1 -0
- package/components/select/select.js +4 -2
- package/components/select/styles.d.ts +79 -0
- package/components/select/styles.js +1 -0
- package/components/select/useFilterable.js +2 -1
- package/components/select/useInput.d.ts +1 -1
- package/components/select/useInput.js +7 -4
- package/components/select/useSearchable.js +1 -0
- package/components/table/index.spec.js +84 -6
- package/components/table/useStickyHeader.js +1 -1
- package/components/timepicker/index.spec.js +298 -128
- package/components/timepicker/panelPicker.d.ts +23 -17
- package/components/timepicker/panelPicker.js +7 -4
- package/components/timepicker/panelPicker.vdt.js +8 -4
- package/components/timepicker/selectPicker.d.ts +5 -4
- package/components/timepicker/useConfirm.d.ts +6 -0
- package/components/timepicker/useConfirm.js +19 -0
- package/components/timepicker/useDefaultValue.d.ts +4 -0
- package/components/timepicker/useDefaultValue.js +27 -0
- package/components/timepicker/useDisabled.d.ts +7 -4
- package/components/timepicker/useDisabled.js +13 -4
- package/components/timepicker/useFormats.d.ts +1 -1
- package/components/timepicker/useValue.d.ts +14 -8
- package/components/timepicker/useValue.js +14 -15
- package/components/tour/index.d.ts +2 -0
- package/components/tour/index.js +2 -0
- package/components/tour/index.spec.d.ts +1 -0
- package/components/tour/index.spec.js +356 -0
- package/components/tour/step.d.ts +23 -0
- package/components/tour/step.js +46 -0
- package/components/tour/step.vdt.js +74 -0
- package/components/tour/styles.d.ts +7 -0
- package/components/tour/styles.js +84 -0
- package/components/tour/tour.d.ts +73 -0
- package/components/tour/tour.js +70 -0
- package/components/tour/tour.vdt.js +66 -0
- package/components/tour/useArrow.d.ts +4 -0
- package/components/tour/useArrow.js +40 -0
- package/components/tour/useFixBody.d.ts +4 -0
- package/components/tour/useFixBody.js +17 -0
- package/components/tour/useHighlight.d.ts +4 -0
- package/components/tour/useHighlight.js +31 -0
- package/components/tour/useMaskClosable.d.ts +1 -0
- package/components/tour/useMaskClosable.js +25 -0
- package/components/tour/useNavigation.d.ts +5 -0
- package/components/tour/useNavigation.js +103 -0
- package/components/tour/usePosition.d.ts +6 -0
- package/components/tour/usePosition.js +93 -0
- package/components/tour/useSteps.d.ts +6 -0
- package/components/tour/useSteps.js +68 -0
- package/hooks/useFixBody.d.ts +11 -0
- package/hooks/useFixBody.js +72 -0
- package/index.d.ts +3 -2
- package/index.js +3 -2
- package/package.json +2 -2
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { DatepickerCalendar } from './calendar';
|
|
2
|
-
export declare enum PanelTypes {
|
|
3
|
-
Date = 0,
|
|
4
|
-
Time = 1
|
|
5
|
-
}
|
|
6
2
|
export declare enum PanelFlags {
|
|
7
3
|
Start = 0,
|
|
8
4
|
End = 1
|
|
9
5
|
}
|
|
10
|
-
export declare function usePanel(
|
|
11
|
-
startPanel: import("../../hooks/useState").State<PanelTypes>;
|
|
12
|
-
endPanel: import("../../hooks/useState").State<PanelTypes>;
|
|
13
|
-
changePanel: (type: PanelTypes, flag?: PanelFlags) => void;
|
|
14
|
-
getPanel: (flag: PanelFlags) => import("../../hooks/useState").State<PanelTypes>;
|
|
15
|
-
reset: () => void;
|
|
6
|
+
export declare function usePanel(): {
|
|
16
7
|
startRef: import('intact-react').RefObject<DatepickerCalendar>;
|
|
17
8
|
endRef: import('intact-react').RefObject<DatepickerCalendar>;
|
|
18
9
|
};
|
|
@@ -1,45 +1,32 @@
|
|
|
1
1
|
import { useInstance, createRef } from 'intact-react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
PanelTypes[PanelTypes["Time"] = 1] = "Time";
|
|
7
|
-
})(PanelTypes || (PanelTypes = {}));
|
|
2
|
+
// export enum PanelTypes {
|
|
3
|
+
// Date,
|
|
4
|
+
// Time
|
|
5
|
+
// }
|
|
8
6
|
export var PanelFlags;
|
|
9
7
|
(function (PanelFlags) {
|
|
10
8
|
PanelFlags[PanelFlags["Start"] = 0] = "Start";
|
|
11
9
|
PanelFlags[PanelFlags["End"] = 1] = "End";
|
|
12
10
|
})(PanelFlags || (PanelFlags = {}));
|
|
13
|
-
export function usePanel(
|
|
14
|
-
if (type === void 0) {
|
|
15
|
-
type = PanelTypes.Date;
|
|
16
|
-
}
|
|
11
|
+
export function usePanel() {
|
|
17
12
|
var instance = useInstance();
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
// const startPanel = useState<PanelTypes>(type);
|
|
14
|
+
// const endPanel = useState<PanelTypes>(type);
|
|
20
15
|
var startRef = createRef();
|
|
21
16
|
var endRef = createRef();
|
|
22
|
-
function changePanel(type, flag) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
endPanel.set(type);
|
|
34
|
-
}
|
|
35
|
-
instance.on('show', reset);
|
|
17
|
+
// function changePanel(type: PanelTypes, flag: PanelFlags = PanelFlags.Start) {
|
|
18
|
+
// getPanel(flag).set(type);
|
|
19
|
+
// }
|
|
20
|
+
// function getPanel(flag: PanelFlags) {
|
|
21
|
+
// return flag === PanelFlags.Start ? startPanel : endPanel;
|
|
22
|
+
// }
|
|
23
|
+
// function reset() {
|
|
24
|
+
// startPanel.set(type);
|
|
25
|
+
// endPanel.set(type);
|
|
26
|
+
// }
|
|
27
|
+
// instance.on('show', reset);
|
|
36
28
|
return {
|
|
37
|
-
startPanel:
|
|
38
|
-
endPanel: endPanel,
|
|
39
|
-
changePanel: changePanel,
|
|
40
|
-
getPanel: getPanel,
|
|
41
|
-
reset: reset,
|
|
42
|
-
startRef: startRef,
|
|
29
|
+
/* startPanel, endPanel, changePanel, getPanel, reset, */startRef: startRef,
|
|
43
30
|
endRef: endRef
|
|
44
31
|
};
|
|
45
32
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
2
|
+
import { State } from '../../hooks/useState';
|
|
3
|
+
import type { useStatus } from './useStatus';
|
|
4
|
+
export declare function useQuarters(showDate: State<Dayjs>, status: ReturnType<typeof useStatus>, focusDate: State<Dayjs | null>): {
|
|
5
|
+
getQuarters: (now: Dayjs) => {
|
|
6
|
+
isActive: boolean;
|
|
7
|
+
isToday: boolean;
|
|
8
|
+
isDisabled: boolean;
|
|
9
|
+
isHover: boolean;
|
|
10
|
+
isInRange: boolean;
|
|
11
|
+
label: string;
|
|
12
|
+
value: dayjs.Dayjs;
|
|
13
|
+
}[];
|
|
14
|
+
onClick: (date: Dayjs) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useInstance } from 'intact-react';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { isEqual } from './helpers';
|
|
4
|
+
import { _$ } from '../../i18n';
|
|
5
|
+
export function useQuarters(showDate, status, focusDate) {
|
|
6
|
+
var instance = useInstance();
|
|
7
|
+
function getQuarters(now) {
|
|
8
|
+
var ret = [];
|
|
9
|
+
var year = showDate.value.year();
|
|
10
|
+
for (var i = 1; i <= 4; i++) {
|
|
11
|
+
var quarterStart = dayjs().year(year).quarter(i).startOf('quarter');
|
|
12
|
+
ret.push({
|
|
13
|
+
isActive: status.isActive(quarterStart, 'quarter'),
|
|
14
|
+
isToday: now.isSame(quarterStart, 'quarter'),
|
|
15
|
+
isDisabled: status.isDisabled(quarterStart),
|
|
16
|
+
isHover: isEqual(quarterStart, focusDate.value, 'quarter'),
|
|
17
|
+
isInRange: status.isInRange(quarterStart, 'quarter'),
|
|
18
|
+
label: _$("Q" + i),
|
|
19
|
+
value: quarterStart
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return ret;
|
|
23
|
+
}
|
|
24
|
+
function onClick(date) {
|
|
25
|
+
var quarterStart = date.startOf('quarter');
|
|
26
|
+
showDate.set(quarterStart);
|
|
27
|
+
var datepickerType = instance.datepicker.get('type');
|
|
28
|
+
if (datepickerType === 'quarter') {
|
|
29
|
+
instance.triggerChange(quarterStart);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
getQuarters: getQuarters,
|
|
34
|
+
onClick: onClick
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -35,6 +35,8 @@ export function useShowDate(panel) {
|
|
|
35
35
|
});
|
|
36
36
|
// ensure the start panel's date is before the end panel's
|
|
37
37
|
watchState(showDate, function (v) {
|
|
38
|
+
// only check on dual panels
|
|
39
|
+
if (!panel.startRef.value || !panel.endRef.value) return;
|
|
38
40
|
if (flag === PanelFlags.Start) {
|
|
39
41
|
var endPanel = anotherPanel.value;
|
|
40
42
|
if (endPanel) {
|
|
@@ -66,10 +68,12 @@ export function useShowDate(panel) {
|
|
|
66
68
|
return date.add(isEnd ? 10 : -10, 'year');
|
|
67
69
|
case 'month':
|
|
68
70
|
return date.add(isEnd ? 1 : -1, 'year');
|
|
69
|
-
|
|
71
|
+
case 'week':
|
|
72
|
+
return date.add(isEnd ? 1 : -1, 'week');
|
|
73
|
+
case 'quarter':
|
|
74
|
+
return date.add(isEnd ? 1 : -1, 'quarter');
|
|
70
75
|
default:
|
|
71
76
|
return date.add(isEnd ? 1 : -1, 'month');
|
|
72
|
-
break;
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
function getDateLabel() {
|
|
@@ -83,6 +87,10 @@ export function useShowDate(panel) {
|
|
|
83
87
|
if (yearMonthFormat === 'yearMonthFormat') {
|
|
84
88
|
yearMonthFormat = 'YYYY MM';
|
|
85
89
|
}
|
|
90
|
+
// quarter类型只显示年份
|
|
91
|
+
if (instance.get('type') === 'quarter') {
|
|
92
|
+
yearMonthFormat = 'YYYY';
|
|
93
|
+
}
|
|
86
94
|
var format = yearMonthFormat.split(' ');
|
|
87
95
|
return _mapInstanceProperty(format).call(format, function (item) {
|
|
88
96
|
return {
|
|
@@ -4,5 +4,5 @@ import type { DatepickerCalendarProps } from './calendar';
|
|
|
4
4
|
export declare function useStatus(focusDate: State<Dayjs | null>): {
|
|
5
5
|
isActive: (date: Dayjs, type: DatepickerCalendarProps['type']) => boolean;
|
|
6
6
|
isInRange: (date: Dayjs, type: DatepickerCalendarProps['type']) => boolean;
|
|
7
|
-
isDisabled: (value: Dayjs, type?:
|
|
7
|
+
isDisabled: (value: Dayjs, type?: "h" | "s" | "y" | "date" | "month" | "week" | "millisecond" | "second" | "minute" | "hour" | "day" | "year" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "months" | "years" | "dates" | "d" | "D" | "M" | "m" | "ms" | "weeks" | "w" | "quarter" | "quarters" | "Q") => boolean;
|
|
8
8
|
};
|
|
@@ -1,38 +1,55 @@
|
|
|
1
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
1
3
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js/instance/find";
|
|
2
4
|
import { useInstance } from 'intact-react';
|
|
3
|
-
import { isGT, isLT, isEqual } from './helpers';
|
|
5
|
+
import { isGT, isLT, isEqual, last } from './helpers';
|
|
6
|
+
import { Position } from './useHighlight';
|
|
4
7
|
export function useStatus(focusDate) {
|
|
5
8
|
var instance = useInstance();
|
|
9
|
+
// if focusDate exists, use it as the active date in range mode
|
|
10
|
+
function getValueByFocusDate() {
|
|
11
|
+
var _context;
|
|
12
|
+
var _instance$get = instance.get(),
|
|
13
|
+
value = _instance$get.value,
|
|
14
|
+
highlightPosition = _instance$get.highlightPosition;
|
|
15
|
+
var _instance$datepicker$ = instance.datepicker.get(),
|
|
16
|
+
range = _instance$datepicker$.range,
|
|
17
|
+
multiple = _instance$datepicker$.multiple;
|
|
18
|
+
if (!focusDate.value || !range || multiple) return value;
|
|
19
|
+
var lastValue = last(value);
|
|
20
|
+
if (!lastValue) return value;
|
|
21
|
+
lastValue = _sliceInstanceProperty(lastValue).call(lastValue);
|
|
22
|
+
if (highlightPosition === Position.Start) {
|
|
23
|
+
lastValue[0] = focusDate.value;
|
|
24
|
+
} else {
|
|
25
|
+
lastValue[1] = focusDate.value;
|
|
26
|
+
}
|
|
27
|
+
return _concatInstanceProperty(_context = _sliceInstanceProperty(value).call(value, 0, -1)).call(_context, [lastValue]);
|
|
28
|
+
}
|
|
6
29
|
function isActive(date, type) {
|
|
7
|
-
var
|
|
30
|
+
var _isActive = function _isActive(values) {
|
|
8
31
|
return Array.isArray(values) ? !!_findInstanceProperty(values).call(values, function (v) {
|
|
9
|
-
return
|
|
32
|
+
return _isActive(v);
|
|
10
33
|
}) : isEqual(values, date, type);
|
|
11
34
|
};
|
|
12
|
-
return
|
|
35
|
+
return _isActive(getValueByFocusDate());
|
|
13
36
|
}
|
|
14
37
|
function isInRange(date, type) {
|
|
15
|
-
var _instance$datepicker$ = instance.datepicker.get(),
|
|
16
|
-
range = _instance$datepicker
|
|
17
|
-
|
|
18
|
-
var value = instance.get('value');
|
|
38
|
+
var _instance$datepicker$2 = instance.datepicker.get(),
|
|
39
|
+
range = _instance$datepicker$2.range;
|
|
40
|
+
var value = getValueByFocusDate();
|
|
19
41
|
if (range) {
|
|
20
|
-
if (!value)
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
42
|
+
if (!value) return false;
|
|
23
43
|
return value.some(function (_ref) {
|
|
24
44
|
var start = _ref[0],
|
|
25
45
|
end = _ref[1];
|
|
26
|
-
if (
|
|
27
|
-
end
|
|
28
|
-
if (end && isLT(end, start, type)) {
|
|
46
|
+
if (start && end) {
|
|
47
|
+
if (isLT(end, start, type)) {
|
|
29
48
|
// maybe the focusDate is less than start date
|
|
30
49
|
var tmp = start;
|
|
31
50
|
start = end;
|
|
32
51
|
end = tmp;
|
|
33
52
|
}
|
|
34
|
-
}
|
|
35
|
-
if (start && end) {
|
|
36
53
|
return isGT(date, start, type) && isLT(date, end, type);
|
|
37
54
|
}
|
|
38
55
|
return false;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { StateValueItem, DayjsValue } from './
|
|
1
|
+
import { StateValueItem, DayjsValue } from './useValueBase';
|
|
2
2
|
import dayjs, { Dayjs } from 'dayjs';
|
|
3
3
|
import type { useFormats } from './useFormats';
|
|
4
4
|
import type { useDisabled } from './useDisabled';
|
|
5
5
|
import { PanelFlags, usePanel } from './usePanel';
|
|
6
|
-
|
|
6
|
+
import { State } from '../../hooks/useState';
|
|
7
|
+
import { Position } from './useHighlight';
|
|
8
|
+
export declare function useValue(formats: ReturnType<typeof useFormats>, disabled: ReturnType<typeof useDisabled>, panel: ReturnType<typeof usePanel>, getHighlightPosition: () => State<Position>): {
|
|
7
9
|
format: () => string | string[];
|
|
8
|
-
|
|
10
|
+
formatSingleValue: (value: StateValueItem) => string;
|
|
9
11
|
onChangeTime: (date: dayjs.Dayjs, flag: PanelFlags) => void;
|
|
10
12
|
getTimeValue: (flag: PanelFlags) => dayjs.Dayjs | null | undefined;
|
|
11
|
-
convertToDayjs: (v: import("./
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
convertToDayjs: (v: import("./useValueBase").Value | [import("./useValueBase").Value, import("./useValueBase").Value] | import("./useValueBase").Value[] | [import("./useValueBase").Value, import("./useValueBase").Value][] | null | undefined) => DayjsValue;
|
|
14
|
+
unique: () => void;
|
|
15
|
+
setMoment: () => void;
|
|
16
|
+
updateValue: () => void;
|
|
17
|
+
value: State<import("./useValueBase").StateValue>;
|
|
14
18
|
setValue: (v: StateValueItem, fromInput: boolean) => void;
|
|
15
19
|
onChangeDate: (v: Dayjs, flag: PanelFlags) => void;
|
|
20
|
+
getDayjsValue: () => DayjsValue;
|
|
21
|
+
allValuesUpdatedInMultipleMode: () => boolean | undefined;
|
|
16
22
|
};
|
|
@@ -1,37 +1,47 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime-corejs3/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["setValue", "value"];
|
|
4
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
var _excluded = ["setValue", "value", "getDayjsValue", "allValuesUpdatedInMultipleMode"];
|
|
5
4
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
6
|
-
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort";
|
|
7
5
|
import { useInstance } from 'intact-react';
|
|
8
|
-
import {
|
|
9
|
-
import dayjs from 'dayjs';
|
|
6
|
+
import { useValueBase } from './useValueBase';
|
|
10
7
|
import { last } from '../utils';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
export function useValue(formats, disabled, panel) {
|
|
8
|
+
import { Position } from './useHighlight';
|
|
9
|
+
export function useValue(formats, disabled, panel, getHighlightPosition) {
|
|
14
10
|
var instance = useInstance();
|
|
15
|
-
var _useValueBase = useValueBase(formats, disabled, panel,
|
|
11
|
+
var _useValueBase = useValueBase(formats, disabled, panel,
|
|
12
|
+
// shouldUpdateValue
|
|
13
|
+
function (v) {
|
|
16
14
|
var _instance$get = instance.get(),
|
|
17
15
|
type = _instance$get.type,
|
|
18
16
|
range = _instance$get.range;
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
if (type === 'datetime') return false;
|
|
18
|
+
if (range) {
|
|
19
|
+
var start = v[0],
|
|
20
|
+
end = v[1];
|
|
21
|
+
if (!start || !end || end.isBefore(start)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
},
|
|
27
|
+
// updateValueOnInput
|
|
28
|
+
function (v) {
|
|
21
29
|
setValue(v, true);
|
|
22
|
-
},
|
|
30
|
+
},
|
|
31
|
+
// getEqualType
|
|
32
|
+
function () {
|
|
23
33
|
var _instance$get2 = instance.get(),
|
|
24
34
|
type = _instance$get2.type;
|
|
25
35
|
return type === 'datetime' ? 'second' : type;
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
value.set(_sliceInstanceProperty(dayjsValue).call(dayjsValue, 0));
|
|
31
|
-
}
|
|
36
|
+
},
|
|
37
|
+
// updateStateValue
|
|
38
|
+
function (dayjsValue, value) {
|
|
39
|
+
value.set(_sliceInstanceProperty(dayjsValue).call(dayjsValue, 0));
|
|
32
40
|
}),
|
|
33
41
|
setValue = _useValueBase.setValue,
|
|
34
42
|
value = _useValueBase.value,
|
|
43
|
+
getDayjsValue = _useValueBase.getDayjsValue,
|
|
44
|
+
allValuesUpdatedInMultipleMode = _useValueBase.allValuesUpdatedInMultipleMode,
|
|
35
45
|
rest = _objectWithoutPropertiesLoose(_useValueBase, _excluded);
|
|
36
46
|
function onChangeDate(v, flag) {
|
|
37
47
|
var _instance$get3 = instance.get(),
|
|
@@ -41,36 +51,27 @@ export function useValue(formats, disabled, panel) {
|
|
|
41
51
|
var _value;
|
|
42
52
|
if (range) {
|
|
43
53
|
var oldValue = last(value.value);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* if we select the first value or re-select the value
|
|
47
|
-
* no matter what the flag is, we should set flag to start panel
|
|
48
|
-
* #877
|
|
49
|
-
*/
|
|
50
|
-
flag = PanelFlags.Start;
|
|
54
|
+
var position = getHighlightPosition().value;
|
|
55
|
+
if (!oldValue || allValuesUpdatedInMultipleMode()) {
|
|
51
56
|
_value = [fixDatetimeWithMinDate(v)];
|
|
57
|
+
} else if (position === Position.Start) {
|
|
58
|
+
if (oldValue.length === 1) {
|
|
59
|
+
_value = [fixDatetimeWithMinDate(v)];
|
|
60
|
+
} else {
|
|
61
|
+
_value = [fixDatetimeWithMinDate(v), oldValue[1]];
|
|
62
|
+
}
|
|
52
63
|
} else {
|
|
53
64
|
_value = [oldValue[0], fixDatetimeWithMaxDate(v)];
|
|
54
|
-
_sortInstanceProperty(_value).call(_value, function (a, b) {
|
|
55
|
-
return a.isAfter(b) ? 1 : -1;
|
|
56
|
-
});
|
|
57
65
|
}
|
|
58
|
-
|
|
66
|
+
// fix after selection is completed, refer to the updateValue function in useValueBase
|
|
67
|
+
// (_value as DayjsValueRange).sort((a, b) => a.isAfter(b) ? 1 : -1);
|
|
59
68
|
} else {
|
|
60
69
|
_value = fixDatetimeWithMinDate(v);
|
|
61
70
|
}
|
|
62
71
|
setValue(_value, false);
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (_value.length === 2) {
|
|
67
|
-
panel.changePanel(PanelTypes.Time, PanelFlags.Start);
|
|
68
|
-
panel.changePanel(PanelTypes.Time, PanelFlags.End);
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
panel.changePanel(PanelTypes.Time, flag);
|
|
72
|
-
}
|
|
73
|
-
} else if (!multiple && (!range || _value.length === 2)) {
|
|
72
|
+
if (range) {
|
|
73
|
+
instance.trigger('selecting', _value, false);
|
|
74
|
+
} else if (!multiple && type !== 'datetime') {
|
|
74
75
|
instance.hide();
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -83,11 +84,12 @@ export function useValue(formats, disabled, panel) {
|
|
|
83
84
|
return v;
|
|
84
85
|
}
|
|
85
86
|
function fixDatetimeWithMaxDate(v) {
|
|
86
|
-
// the
|
|
87
|
+
// the time of end datetime should be set to 23:59:59, #878
|
|
88
|
+
// @modify: don't set to 23:59:59 in new UE
|
|
87
89
|
var maxDate = disabled.maxDate.value;
|
|
88
|
-
|
|
89
|
-
endTime(date);
|
|
90
|
-
v = dayjs(date);
|
|
90
|
+
// const date = v.toDate();
|
|
91
|
+
// endTime(date);
|
|
92
|
+
// v = dayjs(date);
|
|
91
93
|
if (maxDate && v.isAfter(maxDate)) {
|
|
92
94
|
return maxDate;
|
|
93
95
|
}
|
|
@@ -96,6 +98,8 @@ export function useValue(formats, disabled, panel) {
|
|
|
96
98
|
return _extends({
|
|
97
99
|
value: value,
|
|
98
100
|
setValue: setValue,
|
|
99
|
-
onChangeDate: onChangeDate
|
|
101
|
+
onChangeDate: onChangeDate,
|
|
102
|
+
getDayjsValue: getDayjsValue,
|
|
103
|
+
allValuesUpdatedInMultipleMode: allValuesUpdatedInMultipleMode
|
|
100
104
|
}, rest);
|
|
101
105
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { State } from '../../hooks/useState';
|
|
2
|
+
import { Dayjs, OpUnitType, QUnitType } from './dayjs';
|
|
3
|
+
import type { useFormats } from './useFormats';
|
|
4
|
+
import type { useDisabled } from './useDisabled';
|
|
5
|
+
import { PanelFlags, usePanel } from './usePanel';
|
|
6
|
+
import type { BasePickerProps } from './basepicker';
|
|
7
|
+
export type Value = string | Date | number | Dayjs;
|
|
8
|
+
export type StateValueRange = [Dayjs] | [Dayjs, Dayjs];
|
|
9
|
+
export type StateValueItem = Dayjs | StateValueRange;
|
|
10
|
+
export type StateValue = StateValueItem[];
|
|
11
|
+
export type StringValue = string | string[] | [string, string] | [string, string][];
|
|
12
|
+
export type DayjsValueRange = [Dayjs, Dayjs];
|
|
13
|
+
export type DayjsValueItem = Dayjs | DayjsValueRange;
|
|
14
|
+
export type DayjsValue = DayjsValueItem[];
|
|
15
|
+
export declare function useValueBase({ createDateByValueFormat, createDateByShowFormat, getShowString, getValueString, }: ReturnType<typeof useFormats>, { isDisabled, minDate }: ReturnType<typeof useDisabled>, panel: ReturnType<typeof usePanel>, shouldUpdateValue: (v: StateValueItem) => boolean, updateValueOnInput: (v: DayjsValueItem) => void, getEqualType: () => OpUnitType | QUnitType, updateStateValue: (v: DayjsValue, value: State<StateValue>) => void): {
|
|
16
|
+
value: State<StateValue>;
|
|
17
|
+
format: () => string | string[];
|
|
18
|
+
formatSingleValue: (value: StateValueItem) => string;
|
|
19
|
+
onChangeTime: (date: Dayjs, flag: PanelFlags) => void;
|
|
20
|
+
getTimeValue: (flag: PanelFlags) => Dayjs | null | undefined;
|
|
21
|
+
setValue: (v: StateValueItem, fromInput: boolean) => void;
|
|
22
|
+
convertToDayjs: (v: BasePickerProps<Value>['value']) => DayjsValue;
|
|
23
|
+
getDayjsValue: () => DayjsValue;
|
|
24
|
+
unique: () => void;
|
|
25
|
+
setMoment: () => void;
|
|
26
|
+
updateValue: () => void;
|
|
27
|
+
allValuesUpdatedInMultipleMode: () => boolean | undefined;
|
|
28
|
+
};
|