@king-design/intact 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/.DS_Store +0 -0
- package/components/button/index.md +1 -0
- package/components/cascader/index.spec.ts +7 -6
- package/components/datepicker/basepicker.ts +26 -267
- package/components/datepicker/calendar.ts +8 -2
- package/components/datepicker/calendar.vdt +23 -6
- package/components/datepicker/dayjs.ts +8 -2
- package/components/datepicker/demos/multiple.md +1 -1
- package/components/datepicker/demos/yearMonth.md +1 -1
- package/components/datepicker/helpers.ts +10 -12
- package/components/datepicker/index.md +2 -2
- package/components/datepicker/index.spec.ts +619 -190
- package/components/datepicker/index.ts +22 -21
- package/components/datepicker/index.vdt +47 -42
- package/components/datepicker/shortcuts.ts +1 -1
- package/components/datepicker/styles.ts +112 -4
- package/components/datepicker/useConfirm.ts +82 -0
- package/components/datepicker/useDisabled.ts +31 -33
- package/components/datepicker/useFormats.ts +10 -4
- package/components/datepicker/useHighlight.ts +81 -0
- package/components/datepicker/useKeyboards.ts +2 -1
- package/components/datepicker/useMergeRange.ts +54 -0
- package/components/datepicker/useMonths.ts +6 -3
- package/components/datepicker/usePanel.ts +19 -19
- package/components/datepicker/useQuarters.ts +47 -0
- package/components/datepicker/useShowDate.ts +14 -3
- package/components/datepicker/useStatus.ts +34 -15
- package/components/datepicker/useValue.ts +41 -39
- package/components/datepicker/useValueBase.ts +309 -0
- package/components/datepicker/useWeeks.ts +58 -0
- package/components/datepicker/useYears.ts +7 -3
- package/components/descriptions/.DS_Store +0 -0
- package/components/dialog/useFixBody.ts +7 -64
- 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/ellipsis/styles.ts +4 -0
- package/components/form/styles.ts +1 -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/.DS_Store +0 -0
- package/components/menu/demos/.DS_Store +0 -0
- package/components/scrollSelect/index.spec.ts +3 -3
- package/components/scrollSelect/useMouseEvents.ts +24 -10
- package/components/select/base.ts +3 -2
- package/components/select/base.vdt +3 -1
- package/components/select/demos/creatable.md +13 -0
- package/components/select/index.md +1 -0
- package/components/select/index.spec.ts +225 -6
- package/components/select/option.ts +10 -1
- package/components/select/select.ts +3 -0
- package/components/select/styles.ts +3 -1
- package/components/select/useFilterable.ts +1 -1
- package/components/select/useInput.ts +7 -9
- package/components/select/useSearchable.ts +2 -2
- package/components/table/.DS_Store +0 -0
- package/components/table/index.spec.ts +69 -1
- package/components/table/useStickyHeader.ts +1 -1
- package/components/timepicker/demos/step.md +1 -1
- package/components/timepicker/index.spec.ts +145 -27
- package/components/timepicker/panelPicker.ts +10 -4
- package/components/timepicker/panelPicker.vdt +5 -3
- 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/.DS_Store +0 -0
- package/components/tour/demos/basic.md +73 -0
- package/components/tour/demos/beforeChange.md +109 -0
- package/components/tour/demos/closable.md +70 -0
- package/components/tour/demos/custom.md +98 -0
- package/components/tour/demos/customText.md +94 -0
- package/components/tour/demos/declarative.md +72 -0
- package/components/tour/demos/events.md +101 -0
- package/components/tour/demos/maskClosable.md +76 -0
- package/components/tour/demos/notarget.md +59 -0
- package/components/tour/index.md +48 -0
- package/components/tour/index.spec.ts +259 -0
- package/components/tour/index.ts +2 -0
- package/components/tour/step.ts +55 -0
- package/components/tour/step.vdt +75 -0
- package/components/tour/styles.ts +283 -0
- package/components/tour/tour.ts +107 -0
- package/components/tour/tour.vdt +83 -0
- package/components/tour/useArrow.ts +46 -0
- package/components/tour/useFixBody.ts +22 -0
- package/components/tour/useHighlight.ts +36 -0
- package/components/tour/useMaskClosable.ts +26 -0
- package/components/tour/useNavigation.ts +46 -0
- package/components/tour/usePosition.ts +91 -0
- package/components/tour/useSteps.ts +80 -0
- package/components/virtualList/.DS_Store +0 -0
- package/components/virtualList/demos/.DS_Store +0 -0
- package/es/components/cascader/index.spec.js +18 -19
- package/es/components/datepicker/basepicker.d.ts +6 -25
- package/es/components/datepicker/basepicker.js +22 -234
- package/es/components/datepicker/calendar.d.ts +36 -6
- package/es/components/datepicker/calendar.js +4 -0
- package/es/components/datepicker/calendar.vdt.js +21 -5
- package/es/components/datepicker/dayjs.d.ts +2 -2
- package/es/components/datepicker/dayjs.js +6 -0
- package/es/components/datepicker/helpers.d.ts +8 -7
- package/es/components/datepicker/helpers.js +2 -3
- package/es/components/datepicker/index.d.ts +26 -19
- package/es/components/datepicker/index.js +21 -13
- package/es/components/datepicker/index.spec.js +1389 -633
- package/es/components/datepicker/index.vdt.js +43 -46
- package/es/components/datepicker/shortcuts.d.ts +1 -1
- package/es/components/datepicker/styles.d.ts +22 -0
- package/es/components/datepicker/styles.js +26 -4
- package/es/components/datepicker/useConfirm.d.ts +6 -0
- package/es/components/datepicker/useConfirm.js +65 -0
- package/es/components/datepicker/useDisabled.d.ts +7 -5
- package/es/components/datepicker/useDisabled.js +22 -27
- package/es/components/datepicker/useFormats.d.ts +2 -2
- package/es/components/datepicker/useFormats.js +9 -3
- 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 +5 -0
- package/es/components/datepicker/useMergeRange.js +45 -0
- 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/useQuarters.d.ts +15 -0
- package/es/components/datepicker/useQuarters.js +36 -0
- package/es/components/datepicker/useShowDate.js +10 -2
- package/es/components/datepicker/useStatus.d.ts +1 -1
- package/es/components/datepicker/useStatus.js +33 -16
- package/es/components/datepicker/useValue.d.ts +12 -6
- package/es/components/datepicker/useValue.js +49 -45
- package/es/components/datepicker/useValueBase.d.ts +28 -0
- package/es/components/datepicker/useValueBase.js +277 -0
- package/es/components/datepicker/useWeeks.d.ts +19 -0
- package/es/components/datepicker/useWeeks.js +48 -0
- package/es/components/datepicker/useYears.js +6 -3
- package/es/components/dialog/useFixBody.js +6 -58
- package/es/components/dropdown/dropdown.d.ts +1 -0
- package/es/components/dropdown/dropdown.js +7 -4
- package/es/components/ellipsis/styles.js +1 -1
- package/es/components/form/styles.js +1 -1
- 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/scrollSelect/index.spec.js +4 -6
- package/es/components/scrollSelect/useMouseEvents.js +22 -9
- package/es/components/select/base.d.ts +1 -1
- package/es/components/select/base.js +3 -2
- package/es/components/select/base.vdt.js +5 -2
- package/es/components/select/index.spec.js +329 -82
- package/es/components/select/option.d.ts +1 -0
- package/es/components/select/option.js +10 -2
- package/es/components/select/select.d.ts +1 -0
- package/es/components/select/select.js +4 -2
- package/es/components/select/styles.d.ts +79 -0
- package/es/components/select/styles.js +1 -0
- package/es/components/select/useFilterable.js +2 -1
- package/es/components/select/useInput.d.ts +1 -1
- package/es/components/select/useInput.js +7 -4
- package/es/components/select/useSearchable.js +1 -0
- 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 +23 -17
- package/es/components/timepicker/panelPicker.js +7 -4
- package/es/components/timepicker/panelPicker.vdt.js +8 -4
- package/es/components/timepicker/selectPicker.d.ts +5 -4
- 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 +7 -4
- package/es/components/timepicker/useDisabled.js +13 -4
- package/es/components/timepicker/useFormats.d.ts +1 -1
- package/es/components/timepicker/useValue.d.ts +14 -8
- package/es/components/timepicker/useValue.js +14 -15
- package/es/components/tour/index.d.ts +2 -0
- package/es/components/tour/index.js +2 -0
- package/es/components/tour/index.spec.d.ts +1 -0
- package/es/components/tour/index.spec.js +356 -0
- package/es/components/tour/step.d.ts +23 -0
- package/es/components/tour/step.js +46 -0
- package/es/components/tour/step.vdt.js +74 -0
- package/es/components/tour/styles.d.ts +7 -0
- package/es/components/tour/styles.js +84 -0
- package/es/components/tour/tour.d.ts +73 -0
- package/es/components/tour/tour.js +70 -0
- package/es/components/tour/tour.vdt.js +66 -0
- package/es/components/tour/useArrow.d.ts +4 -0
- package/es/components/tour/useArrow.js +40 -0
- package/es/components/tour/useFixBody.d.ts +4 -0
- package/es/components/tour/useFixBody.js +17 -0
- package/es/components/tour/useHighlight.d.ts +4 -0
- package/es/components/tour/useHighlight.js +31 -0
- package/es/components/tour/useMaskClosable.d.ts +1 -0
- package/es/components/tour/useMaskClosable.js +25 -0
- package/es/components/tour/useNavigation.d.ts +5 -0
- package/es/components/tour/useNavigation.js +103 -0
- package/es/components/tour/usePosition.d.ts +6 -0
- package/es/components/tour/usePosition.js +93 -0
- package/es/components/tour/useSteps.d.ts +6 -0
- package/es/components/tour/useSteps.js +68 -0
- package/es/hooks/useFixBody.d.ts +11 -0
- package/es/hooks/useFixBody.js +72 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +3 -2
- package/es/site/data/components/datepicker/demos/multiple/react.js +2 -2
- package/es/site/data/components/select/demos/creatable/index.d.ts +1 -0
- package/es/site/data/components/select/demos/creatable/index.js +2 -1
- package/es/site/data/components/select/demos/creatable/react.d.ts +1 -0
- package/es/site/data/components/select/demos/creatable/react.js +31 -2
- package/es/site/data/components/tour/demos/basic/index.d.ts +17 -0
- package/es/site/data/components/tour/demos/basic/index.js +46 -0
- package/es/site/data/components/tour/demos/basic/react.d.ts +16 -0
- package/es/site/data/components/tour/demos/basic/react.js +82 -0
- package/es/site/data/components/tour/demos/beforeChange/index.d.ts +20 -0
- package/es/site/data/components/tour/demos/beforeChange/index.js +69 -0
- package/es/site/data/components/tour/demos/beforeChange/react.d.ts +19 -0
- package/es/site/data/components/tour/demos/beforeChange/react.js +129 -0
- package/es/site/data/components/tour/demos/closable/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/closable/index.js +42 -0
- package/es/site/data/components/tour/demos/closable/react.d.ts +17 -0
- package/es/site/data/components/tour/demos/closable/react.js +85 -0
- package/es/site/data/components/tour/demos/custom/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/custom/index.js +35 -0
- package/es/site/data/components/tour/demos/custom/react.d.ts +11 -0
- package/es/site/data/components/tour/demos/custom/react.js +108 -0
- package/es/site/data/components/tour/demos/customText/index.d.ts +33 -0
- package/es/site/data/components/tour/demos/customText/index.js +55 -0
- package/es/site/data/components/tour/demos/customText/react.d.ts +33 -0
- package/es/site/data/components/tour/demos/customText/react.js +99 -0
- package/es/site/data/components/tour/demos/declarative/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/declarative/index.js +36 -0
- package/es/site/data/components/tour/demos/declarative/react.d.ts +10 -0
- package/es/site/data/components/tour/demos/declarative/react.js +80 -0
- package/es/site/data/components/tour/demos/events/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/events/index.js +58 -0
- package/es/site/data/components/tour/demos/events/react.d.ts +18 -0
- package/es/site/data/components/tour/demos/events/react.js +101 -0
- package/es/site/data/components/tour/demos/maskClosable/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/maskClosable/index.js +47 -0
- package/es/site/data/components/tour/demos/maskClosable/react.d.ts +17 -0
- package/es/site/data/components/tour/demos/maskClosable/react.js +95 -0
- package/es/site/data/components/tour/demos/notarget/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/notarget/index.js +35 -0
- package/es/site/data/components/tour/demos/notarget/react.d.ts +10 -0
- package/es/site/data/components/tour/demos/notarget/react.js +61 -0
- package/es/site/data/components/tour/index.d.ts +57 -0
- package/es/site/data/components/tour/index.js +32 -0
- package/hooks/useFixBody.ts +87 -0
- package/index.ts +3 -2
- package/package.json +2 -2
- package/styles/.DS_Store +0 -0
|
@@ -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").RefObject<DatepickerCalendar>;
|
|
17
8
|
endRef: import("intact").RefObject<DatepickerCalendar>;
|
|
18
9
|
};
|
|
@@ -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
|
}
|
|
@@ -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';
|
|
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';
|
|
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';
|
|
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
|
+
};
|