@king-design/intact 3.6.0-beta.0 → 3.6.1
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/button/demos/basic.md +0 -1
- package/components/cascader/index.spec.ts +7 -6
- package/components/copy/index.spec.ts +9 -14
- package/components/datepicker/basepicker.ts +26 -314
- package/components/datepicker/calendar.ts +3 -1
- package/components/datepicker/calendar.vdt +5 -2
- package/components/datepicker/dayjs.ts +2 -16
- package/components/datepicker/demos/multiple.md +5 -0
- package/components/datepicker/demos/yearMonth.md +2 -8
- package/components/datepicker/helpers.ts +5 -7
- package/components/datepicker/index.md +1 -2
- package/components/datepicker/index.spec.ts +596 -157
- package/components/datepicker/index.ts +16 -33
- package/components/datepicker/index.vdt +41 -35
- package/components/datepicker/shortcuts.ts +1 -1
- package/components/datepicker/styles.ts +27 -18
- package/components/datepicker/useConfirm.ts +82 -0
- package/components/datepicker/useDisabled.ts +29 -31
- package/components/datepicker/useFormats.ts +8 -4
- package/components/datepicker/useHighlight.ts +81 -0
- package/components/datepicker/useKeyboards.ts +2 -1
- package/components/datepicker/useMergeRange.ts +12 -12
- package/components/datepicker/useMonths.ts +6 -3
- package/components/datepicker/usePanel.ts +19 -19
- package/components/datepicker/useShowDate.ts +21 -41
- package/components/datepicker/useStatus.ts +34 -15
- package/components/datepicker/useValue.ts +43 -72
- package/components/datepicker/useValueBase.ts +312 -0
- package/components/datepicker/useWeeks.ts +1 -1
- package/components/datepicker/useYears.ts +7 -3
- package/components/dropdown/dropdown.ts +5 -4
- package/components/dropdown/index.md +1 -0
- package/components/dropdown/item.ts +1 -1
- package/components/dropdown/useKeyboard.ts +0 -1
- package/components/form/form.ts +4 -0
- package/components/form/index.md +2 -1
- package/components/form/index.spec.ts +2 -0
- package/components/input/index.spec.ts +42 -0
- package/components/input/index.ts +8 -0
- package/components/input/index.vdt +3 -4
- package/components/input/useAutoWidth.ts +19 -1
- package/components/menu/demos/horizontal.md +7 -1
- package/components/menu/index.spec.ts +19 -0
- package/components/menu/styles.ts +2 -1
- package/components/scrollSelect/useMouseEvents.ts +5 -4
- package/components/select/base.ts +3 -2
- package/components/select/base.vdt +2 -1
- package/components/select/demos/creatable.md +2 -2
- package/components/select/index.md +1 -1
- package/components/select/index.spec.ts +142 -36
- package/components/select/menu.ts +1 -1
- package/components/select/option.ts +2 -1
- package/components/select/select.ts +1 -0
- package/components/select/styles.ts +3 -1
- package/components/select/useCard.ts +22 -4
- package/components/select/useInput.ts +5 -9
- package/components/spinner/index.spec.ts +18 -0
- package/components/spinner/useValue.ts +2 -1
- package/components/table/index.spec.ts +69 -1
- package/components/table/useStickyHeader.ts +1 -1
- package/components/timepicker/index.spec.ts +145 -27
- package/components/timepicker/panelPicker.ts +10 -4
- package/components/timepicker/panelPicker.vdt +3 -5
- package/components/timepicker/styles.ts +1 -0
- package/components/timepicker/useConfirm.ts +33 -0
- package/components/timepicker/useDefaultValue.ts +30 -0
- package/components/timepicker/useDisabled.ts +17 -4
- package/components/timepicker/useFormats.ts +1 -1
- package/components/timepicker/useValue.ts +22 -19
- package/components/tour/index.spec.ts +1 -1
- package/es/components/cascader/index.spec.js +18 -19
- package/es/components/copy/index.spec.js +14 -31
- package/es/components/datepicker/basepicker.d.ts +6 -27
- package/es/components/datepicker/basepicker.js +23 -268
- package/es/components/datepicker/calendar.d.ts +4 -2
- package/es/components/datepicker/dayjs.d.ts +2 -13
- package/es/components/datepicker/helpers.d.ts +3 -2
- package/es/components/datepicker/helpers.js +2 -3
- package/es/components/datepicker/index.d.ts +21 -29
- package/es/components/datepicker/index.js +22 -32
- package/es/components/datepicker/index.spec.js +1277 -484
- package/es/components/datepicker/index.vdt.js +39 -38
- package/es/components/datepicker/shortcuts.d.ts +1 -1
- package/es/components/datepicker/styles.d.ts +7 -2
- package/es/components/datepicker/styles.js +10 -15
- package/es/components/datepicker/useConfirm.d.ts +6 -0
- package/es/components/datepicker/useConfirm.js +65 -0
- package/es/components/datepicker/useDisabled.d.ts +5 -3
- package/es/components/datepicker/useDisabled.js +22 -27
- package/es/components/datepicker/useFormats.d.ts +2 -2
- package/es/components/datepicker/useFormats.js +6 -2
- package/es/components/datepicker/useHighlight.d.ts +14 -0
- package/es/components/datepicker/useHighlight.js +60 -0
- package/es/components/datepicker/useKeyboards.js +2 -1
- package/es/components/datepicker/useMergeRange.d.ts +1 -1
- package/es/components/datepicker/useMergeRange.js +11 -16
- package/es/components/datepicker/useMonths.js +5 -3
- package/es/components/datepicker/usePanel.d.ts +1 -10
- package/es/components/datepicker/usePanel.js +19 -32
- package/es/components/datepicker/useShowDate.d.ts +1 -1
- package/es/components/datepicker/useShowDate.js +15 -40
- package/es/components/datepicker/useStatus.js +33 -16
- package/es/components/datepicker/useValue.d.ts +11 -6
- package/es/components/datepicker/useValue.js +49 -69
- package/es/components/datepicker/useValueBase.d.ts +28 -0
- package/es/components/datepicker/useValueBase.js +280 -0
- package/es/components/datepicker/useYears.js +6 -3
- package/es/components/dropdown/dropdown.d.ts +1 -0
- package/es/components/dropdown/dropdown.js +7 -4
- package/es/components/form/form.d.ts +1 -0
- package/es/components/form/form.js +7 -0
- package/es/components/form/index.spec.js +10 -8
- package/es/components/input/index.d.ts +2 -0
- package/es/components/input/index.js +6 -0
- package/es/components/input/index.spec.js +45 -0
- package/es/components/input/index.vdt.js +4 -3
- package/es/components/input/useAutoWidth.d.ts +2 -0
- package/es/components/input/useAutoWidth.js +19 -1
- package/es/components/menu/index.spec.js +28 -0
- package/es/components/menu/styles.js +2 -2
- package/es/components/scrollSelect/useMouseEvents.js +5 -4
- package/es/components/select/base.d.ts +1 -1
- package/es/components/select/base.js +3 -2
- package/es/components/select/base.vdt.js +4 -3
- package/es/components/select/index.spec.js +346 -218
- package/es/components/select/menu.js +1 -1
- package/es/components/select/option.js +2 -1
- package/es/components/select/select.js +2 -1
- package/es/components/select/styles.d.ts +79 -0
- package/es/components/select/styles.js +1 -0
- package/es/components/select/useCard.d.ts +4 -3
- package/es/components/select/useCard.js +15 -4
- package/es/components/select/useInput.d.ts +1 -1
- package/es/components/select/useInput.js +4 -4
- package/es/components/spinner/index.spec.js +82 -44
- package/es/components/spinner/useValue.js +2 -1
- package/es/components/table/index.spec.js +84 -6
- package/es/components/table/useStickyHeader.js +1 -1
- package/es/components/timepicker/index.spec.js +298 -128
- package/es/components/timepicker/panelPicker.d.ts +21 -16
- package/es/components/timepicker/panelPicker.js +7 -4
- package/es/components/timepicker/panelPicker.vdt.js +5 -9
- package/es/components/timepicker/selectPicker.d.ts +4 -3
- package/es/components/timepicker/styles.js +1 -1
- package/es/components/timepicker/useConfirm.d.ts +6 -0
- package/es/components/timepicker/useConfirm.js +19 -0
- package/es/components/timepicker/useDefaultValue.d.ts +4 -0
- package/es/components/timepicker/useDefaultValue.js +27 -0
- package/es/components/timepicker/useDisabled.d.ts +6 -3
- package/es/components/timepicker/useDisabled.js +13 -4
- package/es/components/timepicker/useFormats.d.ts +1 -1
- package/es/components/timepicker/useValue.d.ts +13 -8
- package/es/components/timepicker/useValue.js +14 -15
- package/es/components/tour/index.spec.js +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/button/demos/basic/react.js +0 -2
- package/es/site/data/components/datepicker/demos/multiple/index.d.ts +1 -0
- package/es/site/data/components/datepicker/demos/multiple/index.js +2 -1
- package/es/site/data/components/datepicker/demos/multiple/react.d.ts +1 -0
- package/es/site/data/components/datepicker/demos/multiple/react.js +13 -2
- package/es/site/data/components/datepicker/demos/yearMonth/index.d.ts +0 -2
- package/es/site/data/components/datepicker/demos/yearMonth/index.js +1 -3
- package/es/site/data/components/datepicker/demos/yearMonth/react.d.ts +0 -2
- package/es/site/data/components/datepicker/demos/yearMonth/react.js +1 -21
- package/es/site/data/components/menu/demos/horizontal/react.js +5 -1
- package/es/site/data/components/select/demos/creatable/react.js +2 -2
- package/es/site/data/components/select/demos/searchable/index.js +1 -1
- package/es/site/data/components/select/demos/searchable/react.js +1 -1
- package/es/site/data/components/tour/demos/customText/index.d.ts +19 -6
- package/es/site/data/components/tour/demos/customText/index.js +18 -17
- package/es/site/data/components/tour/demos/customText/react.d.ts +20 -6
- package/es/site/data/components/tour/demos/customText/react.js +31 -27
- package/es/test/demos.js +1 -1
- package/index.ts +2 -2
- package/package.json +2 -2
- package/components/datepicker/demos/nowrap.md +0 -35
- package/components/datepicker/usePosition.ts +0 -169
- package/es/components/datepicker/usePosition.d.ts +0 -10
- package/es/components/datepicker/usePosition.js +0 -166
- package/es/site/data/components/datepicker/demos/nowrap/index.d.ts +0 -10
- package/es/site/data/components/datepicker/demos/nowrap/index.js +0 -19
- package/es/site/data/components/datepicker/demos/nowrap/react.d.ts +0 -10
- package/es/site/data/components/datepicker/demos/nowrap/react.js +0 -49
- package/es/site/data/components/tour/demos/customButtons/index.d.ts +0 -33
- package/es/site/data/components/tour/demos/customButtons/index.js +0 -55
- package/es/site/data/components/tour/demos/customButtons/react.d.ts +0 -33
- package/es/site/data/components/tour/demos/customButtons/react.js +0 -99
|
@@ -1,45 +1,32 @@
|
|
|
1
1
|
import { useInstance, createRef } from 'intact';
|
|
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
|
}
|
|
@@ -5,7 +5,7 @@ export declare function useShowDate(panel: ReturnType<typeof usePanel>): {
|
|
|
5
5
|
date: import("../../hooks/useState").State<Dayjs>;
|
|
6
6
|
getDateLabel: () => {
|
|
7
7
|
value: string;
|
|
8
|
-
onClick
|
|
8
|
+
onClick(e: IgnoreClickEvent): void;
|
|
9
9
|
}[];
|
|
10
10
|
prevMonth: () => void;
|
|
11
11
|
nextMonth: () => void;
|
|
@@ -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,63 +68,36 @@ 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
|
-
break;
|
|
70
71
|
case 'week':
|
|
71
72
|
return date.add(isEnd ? 1 : -1, 'week');
|
|
72
|
-
break;
|
|
73
73
|
case 'quarter':
|
|
74
74
|
return date.add(isEnd ? 1 : -1, 'quarter');
|
|
75
|
-
break;
|
|
76
75
|
default:
|
|
77
76
|
return date.add(isEnd ? 1 : -1, 'month');
|
|
78
|
-
break;
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
79
|
function getDateLabel() {
|
|
82
|
-
var year = showDate.value.get('year');
|
|
83
|
-
var month = showDate.value.get('month') + 1;
|
|
84
80
|
var map = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
n: year
|
|
88
|
-
})
|
|
89
|
-
'YYYY MM': _$("{n}\u5E74{y}\u6708", {
|
|
90
|
-
n: year,
|
|
91
|
-
y: month
|
|
92
|
-
}) // 年月组合标签
|
|
81
|
+
MM: _$(showDate.value.get('month') + 1 + "\u6708"),
|
|
82
|
+
YYYY: _$("{n}\u5E74", {
|
|
83
|
+
n: showDate.value.get('year')
|
|
84
|
+
})
|
|
93
85
|
};
|
|
94
|
-
var
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
break;
|
|
102
|
-
default:
|
|
103
|
-
var yearMonthFormat = _$('yearMonthFormat');
|
|
104
|
-
if (yearMonthFormat === 'yearMonthFormat') {
|
|
105
|
-
yearMonthFormat = 'YYYY MM'; // 默认格式
|
|
106
|
-
}
|
|
107
|
-
format = yearMonthFormat.split(' '); // 其他类型按配置拆分
|
|
108
|
-
break;
|
|
86
|
+
var yearMonthFormat = _$('yearMonthFormat');
|
|
87
|
+
if (yearMonthFormat === 'yearMonthFormat') {
|
|
88
|
+
yearMonthFormat = 'YYYY MM';
|
|
89
|
+
}
|
|
90
|
+
// quarter类型只显示年份
|
|
91
|
+
if (instance.get('type') === 'quarter') {
|
|
92
|
+
yearMonthFormat = 'YYYY';
|
|
109
93
|
}
|
|
110
|
-
|
|
94
|
+
var format = yearMonthFormat.split(' ');
|
|
111
95
|
return _mapInstanceProperty(format).call(format, function (item) {
|
|
112
96
|
return {
|
|
113
97
|
value: map[item],
|
|
114
98
|
onClick: function onClick(e) {
|
|
115
99
|
e._ignore = true;
|
|
116
|
-
|
|
117
|
-
if (item === 'YYYY MM') {
|
|
118
|
-
instance.type.set('week'); // 点击年月组合,保持 week
|
|
119
|
-
} else if (item === 'YYYY') {
|
|
120
|
-
instance.type.set(type === 'quarter' ? 'quarter' : 'year'); // 根据当前 type 决定
|
|
121
|
-
} else if (item === 'MM') {
|
|
122
|
-
instance.type.set('month'); // 点击月,切换到 month
|
|
123
|
-
} else {
|
|
124
|
-
instance.type.set('date'); // 默认切换到 date
|
|
125
|
-
}
|
|
100
|
+
instance.type.set(item === 'YYYY' ? 'year' : 'month');
|
|
126
101
|
}
|
|
127
102
|
};
|
|
128
103
|
});
|
|
@@ -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';
|
|
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,17 +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
|
+
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;
|
|
13
15
|
setMoment: () => void;
|
|
14
|
-
|
|
16
|
+
updateValue: () => void;
|
|
17
|
+
value: State<import("./useValueBase").StateValue>;
|
|
15
18
|
setValue: (v: StateValueItem, fromInput: boolean) => void;
|
|
16
19
|
onChangeDate: (v: Dayjs, flag: PanelFlags) => void;
|
|
20
|
+
getDayjsValue: () => DayjsValue;
|
|
21
|
+
allValuesUpdatedInMultipleMode: () => boolean | undefined;
|
|
17
22
|
};
|
|
@@ -1,100 +1,77 @@
|
|
|
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';
|
|
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(),
|
|
38
48
|
multiple = _instance$get3.multiple,
|
|
39
49
|
type = _instance$get3.type,
|
|
40
50
|
range = _instance$get3.range;
|
|
41
|
-
var activePosition = instance.activePosition.position.value;
|
|
42
51
|
var _value;
|
|
43
52
|
if (range) {
|
|
44
53
|
var oldValue = last(value.value);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*/
|
|
51
|
-
flag = PanelFlags.Start;
|
|
52
|
-
if ((type === 'datetime' || type === 'date') && (oldValue == null ? void 0 : oldValue.length) === 2) {
|
|
53
|
-
// Use activePosition instead of Coordinate
|
|
54
|
-
_value = activePosition === 'end' ? [oldValue[0], fixDatetimeWithMinDate(v)] : multiple ? [fixDatetimeWithMinDate(v)] : [fixDatetimeWithMinDate(v), oldValue[1]];
|
|
55
|
-
} else {
|
|
54
|
+
var position = getHighlightPosition().value;
|
|
55
|
+
if (!oldValue || allValuesUpdatedInMultipleMode()) {
|
|
56
|
+
_value = [fixDatetimeWithMinDate(v)];
|
|
57
|
+
} else if (position === Position.Start) {
|
|
58
|
+
if (oldValue.length === 1) {
|
|
56
59
|
_value = [fixDatetimeWithMinDate(v)];
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
if (type === 'datetime') {
|
|
60
|
-
if (oldValue.length === 1) {
|
|
61
|
-
// 如果只有开始日期,根据activePosition决定是替换开始日期还是设置结束日期
|
|
62
|
-
_value = activePosition === 'end' ? [oldValue[0], fixDatetimeWithMaxDate(v)] : [fixDatetimeWithMaxDate(v)];
|
|
63
|
-
} else {
|
|
64
|
-
// oldValue.length === 2的情况
|
|
65
|
-
_value = activePosition === 'end' ? [oldValue[0], fixDatetimeWithMaxDate(v)] : multiple ? [fixDatetimeWithMaxDate(v)] : [fixDatetimeWithMaxDate(v), oldValue[1]];
|
|
66
|
-
}
|
|
67
60
|
} else {
|
|
68
|
-
_value = [
|
|
61
|
+
_value = [fixDatetimeWithMinDate(v), oldValue[1]];
|
|
69
62
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
63
|
+
} else {
|
|
64
|
+
_value = [oldValue[0], fixDatetimeWithMaxDate(v)];
|
|
73
65
|
}
|
|
74
|
-
|
|
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);
|
|
75
68
|
} else {
|
|
76
69
|
_value = fixDatetimeWithMinDate(v);
|
|
77
70
|
}
|
|
78
71
|
setValue(_value, false);
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (_value.length === 2) {
|
|
83
|
-
panel.changePanel(PanelTypes.Time, PanelFlags.Start);
|
|
84
|
-
panel.changePanel(PanelTypes.Time, PanelFlags.End);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
panel.changePanel(PanelTypes.Time, flag);
|
|
88
|
-
}
|
|
89
|
-
} else if (type === 'week') {
|
|
90
|
-
_value = v.startOf('week');
|
|
91
|
-
setValue(_value, false);
|
|
92
|
-
instance.hide();
|
|
93
|
-
} else if (type === 'quarter') {
|
|
94
|
-
_value = v.startOf('quarter');
|
|
95
|
-
setValue(_value, false);
|
|
96
|
-
instance.hide();
|
|
97
|
-
} else if (!multiple && (!range || _value.length === 2)) {
|
|
72
|
+
if (range) {
|
|
73
|
+
instance.trigger('selecting', _value, false);
|
|
74
|
+
} else if (!multiple && type !== 'datetime') {
|
|
98
75
|
instance.hide();
|
|
99
76
|
}
|
|
100
77
|
}
|
|
@@ -107,11 +84,12 @@ export function useValue(formats, disabled, panel) {
|
|
|
107
84
|
return v;
|
|
108
85
|
}
|
|
109
86
|
function fixDatetimeWithMaxDate(v) {
|
|
110
|
-
// 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
|
|
111
89
|
var maxDate = disabled.maxDate.value;
|
|
112
|
-
|
|
113
|
-
endTime(date);
|
|
114
|
-
v = dayjs(date);
|
|
90
|
+
// const date = v.toDate();
|
|
91
|
+
// endTime(date);
|
|
92
|
+
// v = dayjs(date);
|
|
115
93
|
if (maxDate && v.isAfter(maxDate)) {
|
|
116
94
|
return maxDate;
|
|
117
95
|
}
|
|
@@ -120,6 +98,8 @@ export function useValue(formats, disabled, panel) {
|
|
|
120
98
|
return _extends({
|
|
121
99
|
value: value,
|
|
122
100
|
setValue: setValue,
|
|
123
|
-
onChangeDate: onChangeDate
|
|
101
|
+
onChangeDate: onChangeDate,
|
|
102
|
+
getDayjsValue: getDayjsValue,
|
|
103
|
+
allValuesUpdatedInMultipleMode: allValuesUpdatedInMultipleMode
|
|
124
104
|
}, rest);
|
|
125
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
|
+
};
|