@v-c/picker 1.0.4-beta.1 → 1.1.0-rc.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/dist/PickerInput/Popup/Footer.js +12 -18
- package/dist/PickerInput/Popup/PopupPanel.js +14 -18
- package/dist/PickerInput/Popup/PresetPanel.js +8 -10
- package/dist/PickerInput/Popup/index.js +19 -29
- package/dist/PickerInput/RangePicker.js +25 -17
- package/dist/PickerInput/Selector/Icon.js +6 -9
- package/dist/PickerInput/Selector/Input.js +13 -14
- package/dist/PickerInput/Selector/MaskFormat.js +5 -1
- package/dist/PickerInput/Selector/RangeSelector.js +29 -53
- package/dist/PickerInput/Selector/SingleSelector/MultipleDates.d.ts +7 -0
- package/dist/PickerInput/Selector/SingleSelector/MultipleDates.js +22 -12
- package/dist/PickerInput/Selector/SingleSelector/index.d.ts +7 -0
- package/dist/PickerInput/Selector/SingleSelector/index.js +34 -48
- package/dist/PickerInput/Selector/hooks/useClearIcon.js +2 -0
- package/dist/PickerInput/Selector/hooks/useInputHooks.js +2 -0
- package/dist/PickerInput/Selector/hooks/useRootProps.js +2 -0
- package/dist/PickerInput/Selector/util.js +2 -0
- package/dist/PickerInput/SinglePicker.d.ts +9 -0
- package/dist/PickerInput/SinglePicker.js +24 -14
- package/dist/PickerInput/context.js +2 -0
- package/dist/PickerInput/hooks/useCellRender.js +2 -0
- package/dist/PickerInput/hooks/useDelayState.js +2 -0
- package/dist/PickerInput/hooks/useDisabledBoundary.js +5 -0
- package/dist/PickerInput/hooks/useFieldFormat.js +2 -0
- package/dist/PickerInput/hooks/useFieldsInvalidate.js +5 -0
- package/dist/PickerInput/hooks/useFilledProps.js +10 -0
- package/dist/PickerInput/hooks/useInputReadOnly.js +2 -0
- package/dist/PickerInput/hooks/useInvalidate.js +5 -0
- package/dist/PickerInput/hooks/useLockEffect.js +6 -0
- package/dist/PickerInput/hooks/useOpen.js +6 -0
- package/dist/PickerInput/hooks/usePresets.js +2 -0
- package/dist/PickerInput/hooks/useRangeActive.js +7 -0
- package/dist/PickerInput/hooks/useRangeDisabledDate.js +6 -0
- package/dist/PickerInput/hooks/useRangePickerValue.js +2 -0
- package/dist/PickerInput/hooks/useRangeValue.js +8 -2
- package/dist/PickerInput/hooks/useShowNow.js +2 -0
- package/dist/PickerPanel/DatePanel/index.js +15 -21
- package/dist/PickerPanel/DateTimePanel/index.js +13 -19
- package/dist/PickerPanel/DecadePanel/index.js +14 -20
- package/dist/PickerPanel/MonthPanel/index.js +14 -20
- package/dist/PickerPanel/PanelBody.js +10 -16
- package/dist/PickerPanel/PanelHeader.js +4 -2
- package/dist/PickerPanel/QuarterPanel/index.js +14 -20
- package/dist/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +8 -10
- package/dist/PickerPanel/TimePanel/TimePanelBody/index.js +10 -8
- package/dist/PickerPanel/TimePanel/TimePanelBody/useScrollTo.js +2 -0
- package/dist/PickerPanel/TimePanel/index.js +14 -20
- package/dist/PickerPanel/WeekPanel/index.js +12 -18
- package/dist/PickerPanel/YearPanel/index.js +14 -20
- package/dist/PickerPanel/context.js +2 -0
- package/dist/PickerPanel/index.js +23 -21
- package/dist/PickerTrigger/index.js +4 -2
- package/dist/PickerTrigger/util.js +2 -0
- package/dist/generate/dateFns.js +23 -10
- package/dist/generate/dayjs.js +4 -2
- package/dist/generate/luxon.js +29 -2
- package/dist/generate/moment.js +4 -2
- package/dist/hooks/useLocale.js +8 -3
- package/dist/hooks/useSemantic.js +5 -0
- package/dist/hooks/useSyncState.js +7 -0
- package/dist/hooks/useTimeConfig.js +11 -0
- package/dist/hooks/useTimeInfo.js +10 -2
- package/dist/hooks/useToggleDates.js +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -5
- package/dist/locale/am_ET.js +4 -2
- package/dist/locale/ar_EG.js +4 -2
- package/dist/locale/az_AZ.js +4 -2
- package/dist/locale/bg_BG.js +4 -2
- package/dist/locale/bn_BD.js +4 -2
- package/dist/locale/by_BY.js +4 -2
- package/dist/locale/ca_ES.js +4 -2
- package/dist/locale/common.js +3 -1
- package/dist/locale/cs_CZ.js +4 -2
- package/dist/locale/da_DK.js +4 -2
- package/dist/locale/de_DE.js +4 -2
- package/dist/locale/el_GR.js +4 -2
- package/dist/locale/en_GB.js +4 -2
- package/dist/locale/en_US.js +4 -2
- package/dist/locale/es_ES.js +4 -2
- package/dist/locale/es_MX.js +4 -2
- package/dist/locale/et_EE.js +4 -2
- package/dist/locale/eu_ES.js +4 -2
- package/dist/locale/fa_IR.js +4 -2
- package/dist/locale/fi_FI.js +4 -2
- package/dist/locale/fr_BE.js +4 -2
- package/dist/locale/fr_CA.js +4 -2
- package/dist/locale/fr_FR.js +4 -2
- package/dist/locale/ga_IE.js +4 -2
- package/dist/locale/gl_ES.js +4 -2
- package/dist/locale/he_IL.js +4 -2
- package/dist/locale/hi_IN.js +4 -2
- package/dist/locale/hr_HR.js +4 -2
- package/dist/locale/hu_HU.js +4 -2
- package/dist/locale/id_ID.js +4 -2
- package/dist/locale/is_IS.js +4 -2
- package/dist/locale/it_IT.js +4 -2
- package/dist/locale/ja_JP.js +4 -2
- package/dist/locale/ka_GE.js +4 -2
- package/dist/locale/kk_KZ.js +4 -2
- package/dist/locale/km_KH.js +4 -2
- package/dist/locale/kmr_IQ.js +4 -2
- package/dist/locale/kn_IN.js +4 -2
- package/dist/locale/ko_KR.js +4 -2
- package/dist/locale/lt_LT.js +4 -2
- package/dist/locale/lv_LV.js +4 -2
- package/dist/locale/mk_MK.js +4 -2
- package/dist/locale/ml_IN.js +4 -2
- package/dist/locale/mn_MN.js +4 -2
- package/dist/locale/mr_IN.js +4 -2
- package/dist/locale/ms_MY.js +4 -2
- package/dist/locale/my_MM.js +4 -2
- package/dist/locale/nb_NO.js +4 -2
- package/dist/locale/ne_NP.js +4 -2
- package/dist/locale/nl_BE.js +4 -2
- package/dist/locale/nl_NL.js +4 -2
- package/dist/locale/pl_PL.js +4 -2
- package/dist/locale/pt_BR.js +4 -2
- package/dist/locale/pt_PT.js +4 -2
- package/dist/locale/ro_RO.js +4 -2
- package/dist/locale/ru_RU.js +4 -2
- package/dist/locale/si_LK.js +4 -2
- package/dist/locale/sk_SK.js +4 -2
- package/dist/locale/sl_SI.js +4 -2
- package/dist/locale/sr_Cyrl_RS.js +4 -2
- package/dist/locale/sr_RS.js +4 -2
- package/dist/locale/sv_SE.js +4 -2
- package/dist/locale/ta_IN.js +4 -2
- package/dist/locale/te_IN.js +4 -2
- package/dist/locale/th_TH.js +4 -2
- package/dist/locale/tk_TK.js +4 -2
- package/dist/locale/tr_TR.js +4 -2
- package/dist/locale/ug_CN.js +4 -2
- package/dist/locale/uk_UA.js +4 -2
- package/dist/locale/ur_PK.js +4 -2
- package/dist/locale/uz_UZ.js +4 -2
- package/dist/locale/vi_VN.js +4 -2
- package/dist/locale/zh_CN.js +4 -2
- package/dist/locale/zh_TW.js +4 -2
- package/dist/utils/dateUtil.js +17 -1
- package/dist/utils/getClearIcon.js +2 -0
- package/dist/utils/miscUtil.js +6 -0
- package/dist/utils/uiUtil.js +2 -0
- package/dist/utils/valueUtil.js +2 -0
- package/dist/utils/warnUtil.js +2 -0
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useSemantic from "../hooks/useSemantic.js";
|
|
2
2
|
import { providePickerContext } from "./context.js";
|
|
3
|
-
import
|
|
3
|
+
import PickerTrigger from "../PickerTrigger/index.js";
|
|
4
4
|
import { toArray } from "../utils/miscUtil.js";
|
|
5
5
|
import { pickTriggerProps } from "../PickerTrigger/util.js";
|
|
6
6
|
import { formatValue, formatValues } from "../utils/valueUtil.js";
|
|
@@ -14,13 +14,14 @@ import useRangePickerValue from "./hooks/useRangePickerValue.js";
|
|
|
14
14
|
import useRangeValue, { useInnerValue } from "./hooks/useRangeValue.js";
|
|
15
15
|
import useShowNow from "./hooks/useShowNow.js";
|
|
16
16
|
import useToggleDates from "../hooks/useToggleDates.js";
|
|
17
|
-
import
|
|
18
|
-
import
|
|
17
|
+
import Popup from "./Popup/index.js";
|
|
18
|
+
import SingleSelector from "./Selector/SingleSelector/index.js";
|
|
19
19
|
import { computed, createVNode, defineComponent, mergeProps, ref, shallowRef, watch } from "vue";
|
|
20
20
|
import { clsx } from "@v-c/util";
|
|
21
21
|
import omit$1 from "@v-c/util/dist/omit";
|
|
22
22
|
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
23
|
-
|
|
23
|
+
//#region src/PickerInput/SinglePicker.tsx
|
|
24
|
+
var SinglePicker = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
24
25
|
const [filledProps, internalPicker, complexPicker, formatList, maskFormat, isInvalidateDate] = useFilledProps(computed(() => props));
|
|
25
26
|
const fp = computed(() => filledProps.value);
|
|
26
27
|
const prefixCls = computed(() => fp.value.prefixCls);
|
|
@@ -101,8 +102,8 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
101
102
|
};
|
|
102
103
|
const toggleDates = useToggleDates(generateConfig, locale, internalPicker);
|
|
103
104
|
const semanticCtx = useSemantic(classNames, styles);
|
|
104
|
-
const [mergedOpen, triggerOpen] = useOpen(open, defaultOpen, computed(() => [disabled.value]), (open
|
|
105
|
-
onOpenChange.value?.(open
|
|
105
|
+
const [mergedOpen, triggerOpen] = useOpen(open, defaultOpen, computed(() => [disabled.value]), (open) => {
|
|
106
|
+
onOpenChange.value?.(open);
|
|
106
107
|
});
|
|
107
108
|
const onInternalCalendarChange = (dates, dateStrings, info) => {
|
|
108
109
|
if (onCalendarChange.value) {
|
|
@@ -132,6 +133,7 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
132
133
|
const setMode = (val) => {
|
|
133
134
|
mergedMode.value = val;
|
|
134
135
|
};
|
|
136
|
+
/** Extends from `mergedMode` to patch `datetime` mode */
|
|
135
137
|
const internalMode = computed(() => mergedMode.value === "date" && showTime.value ? "datetime" : mergedMode.value);
|
|
136
138
|
const mergedShowNow = useShowNow(picker, mergedMode, showNow, showToday);
|
|
137
139
|
const onInternalChange = (dates, dateStrings) => {
|
|
@@ -163,6 +165,10 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
163
165
|
onPanelChange.value(lastPickerValue, nextMode);
|
|
164
166
|
}
|
|
165
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* Different with RangePicker, confirm should check `multiple` logic.
|
|
170
|
+
* This will never provide `date` instead.
|
|
171
|
+
*/
|
|
166
172
|
const triggerConfirm = () => {
|
|
167
173
|
triggerSubmitChange(getCalendarValue.value);
|
|
168
174
|
triggerOpen(false, { force: true });
|
|
@@ -320,7 +326,7 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
320
326
|
});
|
|
321
327
|
return () => {
|
|
322
328
|
const [mergedClassNames, mergedStyles] = semanticCtx.value;
|
|
323
|
-
const panel = createVNode(
|
|
329
|
+
const panel = createVNode(Popup, popupProps.value, null);
|
|
324
330
|
const singleSelectorProps = {
|
|
325
331
|
...omit$1(fp.value, [
|
|
326
332
|
"autoFocus",
|
|
@@ -368,13 +374,13 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
368
374
|
Object.keys(singleSelectorProps).forEach((key) => {
|
|
369
375
|
if (singleSelectorProps[key] === void 0) delete singleSelectorProps[key];
|
|
370
376
|
});
|
|
371
|
-
return createVNode(
|
|
377
|
+
return createVNode(PickerTrigger, mergeProps(pickTriggerProps(fp.value), {
|
|
372
378
|
"popupElement": panel,
|
|
373
379
|
"popupStyle": mergedStyles?.popup?.root,
|
|
374
380
|
"popupClassName": clsx(rootClassName.value, mergedClassNames?.popup?.root),
|
|
375
381
|
"visible": mergedOpen.value,
|
|
376
382
|
"onClose": onPopupClose
|
|
377
|
-
}), { default: () => [createVNode(
|
|
383
|
+
}), { default: () => [createVNode(SingleSelector, mergeProps(singleSelectorProps, { "ref": selectorRef }), null)] });
|
|
378
384
|
};
|
|
379
385
|
}, {
|
|
380
386
|
props: {
|
|
@@ -402,6 +408,11 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
402
408
|
required: false,
|
|
403
409
|
default: void 0
|
|
404
410
|
},
|
|
411
|
+
tagRender: {
|
|
412
|
+
type: Function,
|
|
413
|
+
required: false,
|
|
414
|
+
default: void 0
|
|
415
|
+
},
|
|
405
416
|
value: {
|
|
406
417
|
required: false,
|
|
407
418
|
default: void 0
|
|
@@ -500,13 +511,11 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
500
511
|
},
|
|
501
512
|
locale: {
|
|
502
513
|
type: Object,
|
|
503
|
-
required: true
|
|
504
|
-
default: void 0
|
|
514
|
+
required: true
|
|
505
515
|
},
|
|
506
516
|
generateConfig: {
|
|
507
517
|
type: Object,
|
|
508
|
-
required: true
|
|
509
|
-
default: void 0
|
|
518
|
+
required: true
|
|
510
519
|
},
|
|
511
520
|
picker: {
|
|
512
521
|
type: String,
|
|
@@ -1887,4 +1896,5 @@ var SinglePicker_default = /* @__PURE__ */ defineComponent((props, { expose }) =
|
|
|
1887
1896
|
name: "SinglePicker",
|
|
1888
1897
|
inheritAttrs: false
|
|
1889
1898
|
});
|
|
1890
|
-
|
|
1899
|
+
//#endregion
|
|
1900
|
+
export { SinglePicker as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { inject, provide, ref } from "vue";
|
|
2
|
+
//#region src/PickerInput/context.ts
|
|
2
3
|
var PickerContextKey = Symbol("PickerContext");
|
|
3
4
|
function providePickerContext(context) {
|
|
4
5
|
provide(PickerContextKey, context);
|
|
@@ -6,4 +7,5 @@ function providePickerContext(context) {
|
|
|
6
7
|
function usePickerContext() {
|
|
7
8
|
return inject(PickerContextKey, ref({}));
|
|
8
9
|
}
|
|
10
|
+
//#endregion
|
|
9
11
|
export { providePickerContext, usePickerContext };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { warning } from "@v-c/util";
|
|
2
|
+
//#region src/PickerInput/hooks/useCellRender.ts
|
|
2
3
|
function useCellRender(cellRender, dateRender, monthCellRender, range) {
|
|
3
4
|
if (process.env.NODE_ENV !== "production") {
|
|
4
5
|
warning(!dateRender?.value, `'dateRender' is deprecated. Please use 'cellRender' instead.`);
|
|
@@ -17,4 +18,5 @@ function useCellRender(cellRender, dateRender, monthCellRender, range) {
|
|
|
17
18
|
});
|
|
18
19
|
return onInternalCellRender;
|
|
19
20
|
}
|
|
21
|
+
//#endregion
|
|
20
22
|
export { useCellRender as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, nextTick, onBeforeUnmount, ref, watch } from "vue";
|
|
2
2
|
import raf from "@v-c/util/dist/raf";
|
|
3
|
+
//#region src/PickerInput/hooks/useDelayState.ts
|
|
3
4
|
function useDelayState(value, defaultValue, onChange) {
|
|
4
5
|
const internalValue = ref(defaultValue);
|
|
5
6
|
const state = computed(() => value.value !== void 0 ? value.value : internalValue.value);
|
|
@@ -28,4 +29,5 @@ function useDelayState(value, defaultValue, onChange) {
|
|
|
28
29
|
});
|
|
29
30
|
return [state, updateValue];
|
|
30
31
|
}
|
|
32
|
+
//#endregion
|
|
31
33
|
export { useDelayState as default };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { isSame } from "../../utils/dateUtil.js";
|
|
2
|
+
//#region src/PickerInput/hooks/useDisabledBoundary.ts
|
|
3
|
+
/**
|
|
4
|
+
* Merge `disabledDate` with `minDate` & `maxDate`.
|
|
5
|
+
*/
|
|
2
6
|
function useDisabledBoundary(generateConfig, locale, disabledDate, minDate, maxDate) {
|
|
3
7
|
const mergedDisabledDate = (date, info) => {
|
|
4
8
|
if (disabledDate.value && disabledDate.value(date, info)) return true;
|
|
@@ -8,4 +12,5 @@ function useDisabledBoundary(generateConfig, locale, disabledDate, minDate, maxD
|
|
|
8
12
|
};
|
|
9
13
|
return mergedDisabledDate;
|
|
10
14
|
}
|
|
15
|
+
//#endregion
|
|
11
16
|
export { useDisabledBoundary as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getRowFormat, toArray } from "../../utils/miscUtil.js";
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
//#region src/PickerInput/hooks/useFieldFormat.ts
|
|
3
4
|
function useFieldFormat(picker, locale, format) {
|
|
4
5
|
const info = computed(() => {
|
|
5
6
|
const formatList = toArray(getRowFormat(picker.value, locale.value, format?.value));
|
|
@@ -12,4 +13,5 @@ function useFieldFormat(picker, locale, format) {
|
|
|
12
13
|
});
|
|
13
14
|
return [computed(() => info.value.formatList), computed(() => info.value.maskFormat)];
|
|
14
15
|
}
|
|
16
|
+
//#endregion
|
|
15
17
|
export { useFieldFormat };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { fillIndex } from "../../utils/miscUtil.js";
|
|
2
2
|
import { computed, ref } from "vue";
|
|
3
|
+
//#region src/PickerInput/hooks/useFieldsInvalidate.ts
|
|
4
|
+
/**
|
|
5
|
+
* Used to control each fields invalidate status
|
|
6
|
+
*/
|
|
3
7
|
function useFieldsInvalidate(calendarValue, isInvalidateDate, allowEmpty = ref([])) {
|
|
4
8
|
const fieldsInvalidates = ref([false, false]);
|
|
5
9
|
const onSelectorInvalid = (invalid, index) => {
|
|
@@ -16,4 +20,5 @@ function useFieldsInvalidate(calendarValue, isInvalidateDate, allowEmpty = ref([
|
|
|
16
20
|
});
|
|
17
21
|
}), onSelectorInvalid];
|
|
18
22
|
}
|
|
23
|
+
//#endregion
|
|
19
24
|
export { useFieldsInvalidate as default };
|
|
@@ -9,6 +9,7 @@ import useInputReadOnly from "./useInputReadOnly.js";
|
|
|
9
9
|
import useInvalidate from "./useInvalidate.js";
|
|
10
10
|
import { computed } from "vue";
|
|
11
11
|
import { warning } from "@v-c/util";
|
|
12
|
+
//#region src/PickerInput/hooks/useFilledProps.ts
|
|
12
13
|
function useList(value, fillMode = false, transform) {
|
|
13
14
|
return computed(() => {
|
|
14
15
|
const val = value.value;
|
|
@@ -21,6 +22,12 @@ function useList(value, fillMode = false, transform) {
|
|
|
21
22
|
return list;
|
|
22
23
|
});
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Align the outer props with unique typed and fill undefined props.
|
|
27
|
+
* This is shared with both RangePicker and Picker. This will do:
|
|
28
|
+
* - Convert `value` & `defaultValue` to array
|
|
29
|
+
* - handle the legacy props fill like `clearIcon` + `allowClear` = `clearIcon`
|
|
30
|
+
*/
|
|
24
31
|
function useFilledProps(props, updater) {
|
|
25
32
|
const mergedPicker = computed(() => props.value.picker || "date");
|
|
26
33
|
const mergedPrefixCls = computed(() => props.value.prefixCls || "vc-picker");
|
|
@@ -32,7 +39,9 @@ function useFilledProps(props, updater) {
|
|
|
32
39
|
input: props.value.inputRender,
|
|
33
40
|
...props.value.components
|
|
34
41
|
}));
|
|
42
|
+
/** Almost same as `picker`, but add `datetime` for `date` with `showTime` */
|
|
35
43
|
const internalPicker = computed(() => mergedPicker.value === "date" && props.value.showTime ? "datetime" : mergedPicker.value);
|
|
44
|
+
/** The picker is `datetime` or `time` */
|
|
36
45
|
const multipleInteractivePicker = computed(() => internalPicker.value === "time" || internalPicker.value === "datetime");
|
|
37
46
|
const complexPicker = computed(() => multipleInteractivePicker.value || props.value.multiple);
|
|
38
47
|
const mergedNeedConfirm = computed(() => {
|
|
@@ -102,4 +111,5 @@ function useFilledProps(props, updater) {
|
|
|
102
111
|
isInvalidateDate
|
|
103
112
|
];
|
|
104
113
|
}
|
|
114
|
+
//#endregion
|
|
105
115
|
export { useFilledProps as default };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
|
+
//#region src/PickerInput/hooks/useInputReadOnly.ts
|
|
2
3
|
function useInputReadOnly(formatList, inputReadOnly, multiple) {
|
|
3
4
|
return computed(() => {
|
|
4
5
|
if (typeof formatList.value[0] === "function" || multiple.value) return true;
|
|
5
6
|
return inputReadOnly.value;
|
|
6
7
|
});
|
|
7
8
|
}
|
|
9
|
+
//#endregion
|
|
8
10
|
export { useInputReadOnly as default };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
//#region src/PickerInput/hooks/useInvalidate.ts
|
|
2
|
+
/**
|
|
3
|
+
* Check if provided date is valid for the `disabledDate` & `showTime.disabledTime`.
|
|
4
|
+
*/
|
|
1
5
|
function useInvalidate(generateConfig, picker, disabledDate, showTime) {
|
|
2
6
|
const isInvalidate = (date, info) => {
|
|
3
7
|
const outsideInfo = {
|
|
@@ -27,4 +31,5 @@ function useInvalidate(generateConfig, picker, disabledDate, showTime) {
|
|
|
27
31
|
};
|
|
28
32
|
return isInvalidate;
|
|
29
33
|
}
|
|
34
|
+
//#endregion
|
|
30
35
|
export { useInvalidate as default };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { raf } from "../Selector/util.js";
|
|
2
2
|
import { watch } from "vue";
|
|
3
|
+
//#region src/PickerInput/hooks/useLockEffect.ts
|
|
4
|
+
/**
|
|
5
|
+
* Trigger `callback` immediately when `condition` is `true`.
|
|
6
|
+
* But trigger `callback` in next frame when `condition` is `false`.
|
|
7
|
+
*/
|
|
3
8
|
function useLockEffect(condition, callback) {
|
|
4
9
|
watch(condition, (val) => {
|
|
5
10
|
if (val) callback(val);
|
|
@@ -8,4 +13,5 @@ function useLockEffect(condition, callback) {
|
|
|
8
13
|
});
|
|
9
14
|
}, { flush: "post" });
|
|
10
15
|
}
|
|
16
|
+
//#endregion
|
|
11
17
|
export { useLockEffect as default };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import useDelayState from "./useDelayState.js";
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
//#region src/PickerInput/hooks/useOpen.ts
|
|
4
|
+
/**
|
|
5
|
+
* Control the open state.
|
|
6
|
+
* Will not close if activeElement is on the popup.
|
|
7
|
+
*/
|
|
3
8
|
function useOpen(open, defaultOpen, disabledList, onOpenChange) {
|
|
4
9
|
const [rafOpen, setRafOpen] = useDelayState(computed(() => disabledList.value?.every((disabled) => disabled) ? false : open.value), defaultOpen.value || false, onOpenChange);
|
|
5
10
|
function setOpen(next, config = {}) {
|
|
@@ -7,4 +12,5 @@ function useOpen(open, defaultOpen, disabledList, onOpenChange) {
|
|
|
7
12
|
}
|
|
8
13
|
return [rafOpen, setOpen];
|
|
9
14
|
}
|
|
15
|
+
//#endregion
|
|
10
16
|
export { useOpen as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { warning } from "@v-c/util";
|
|
3
|
+
//#region src/PickerInput/hooks/usePresets.ts
|
|
3
4
|
function usePresets(presets, legacyRanges) {
|
|
4
5
|
return computed(() => {
|
|
5
6
|
if (presets.value) return presets.value;
|
|
@@ -13,4 +14,5 @@ function usePresets(presets, legacyRanges) {
|
|
|
13
14
|
return [];
|
|
14
15
|
});
|
|
15
16
|
}
|
|
17
|
+
//#endregion
|
|
16
18
|
export { usePresets as default };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import useLockEffect from "./useLockEffect.js";
|
|
2
2
|
import { computed, ref, watch } from "vue";
|
|
3
|
+
//#region src/PickerInput/hooks/useRangeActive.ts
|
|
4
|
+
/**
|
|
5
|
+
* When user first focus one input, any submit will trigger focus another one.
|
|
6
|
+
* When second time focus one input, submit will not trigger focus again.
|
|
7
|
+
* When click outside to close the panel, trigger event if it can trigger onChange.
|
|
8
|
+
*/
|
|
3
9
|
function useRangeActive(disabled, empty = ref([]), mergedOpen = ref(false)) {
|
|
4
10
|
const activeIndex = ref(0);
|
|
5
11
|
const focused = ref(false);
|
|
@@ -49,4 +55,5 @@ function useRangeActive(disabled, empty = ref([]), mergedOpen = ref(false)) {
|
|
|
49
55
|
hasActiveSubmitValue
|
|
50
56
|
];
|
|
51
57
|
}
|
|
58
|
+
//#endregion
|
|
52
59
|
export { useRangeActive as default };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { getFromDate } from "../../utils/miscUtil.js";
|
|
2
2
|
import { isSame } from "../../utils/dateUtil.js";
|
|
3
|
+
//#region src/PickerInput/hooks/useRangeDisabledDate.ts
|
|
4
|
+
/**
|
|
5
|
+
* RangePicker need additional logic to handle the `disabled` case. e.g.
|
|
6
|
+
* [disabled, enabled] should end date not before start date
|
|
7
|
+
*/
|
|
3
8
|
function useRangeDisabledDate(values, disabled, activeIndexList, generateConfig, locale, disabledDate) {
|
|
4
9
|
const rangeDisabledDate = (date, info) => {
|
|
5
10
|
const activeIndex = activeIndexList.value[activeIndexList.value.length - 1];
|
|
@@ -14,4 +19,5 @@ function useRangeDisabledDate(values, disabled, activeIndexList, generateConfig,
|
|
|
14
19
|
};
|
|
15
20
|
return rangeDisabledDate;
|
|
16
21
|
}
|
|
22
|
+
//#endregion
|
|
17
23
|
export { useRangeDisabledDate as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fillTime, isSame } from "../../utils/dateUtil.js";
|
|
2
2
|
import useSyncState from "../../hooks/useSyncState.js";
|
|
3
3
|
import { computed, ref, watch } from "vue";
|
|
4
|
+
//#region src/PickerInput/hooks/useRangePickerValue.ts
|
|
4
5
|
function offsetPanelDate(generateConfig, picker, date, offset) {
|
|
5
6
|
switch (picker) {
|
|
6
7
|
case "date":
|
|
@@ -91,4 +92,5 @@ function useRangePickerValue(generateConfig, locale, calendarValue, modes, open,
|
|
|
91
92
|
}, { flush: "post" });
|
|
92
93
|
return [currentPickerValue, setCurrentPickerValue];
|
|
93
94
|
}
|
|
95
|
+
//#endregion
|
|
94
96
|
export { useRangePickerValue as default, offsetPanelDate };
|
|
@@ -2,6 +2,7 @@ import { fillIndex } from "../../utils/miscUtil.js";
|
|
|
2
2
|
import { formatValue, isSame, isSameTimestamp } from "../../utils/dateUtil.js";
|
|
3
3
|
import useLockEffect from "./useLockEffect.js";
|
|
4
4
|
import { computed, ref, shallowRef, watch } from "vue";
|
|
5
|
+
//#region src/PickerInput/hooks/useRangeValue.ts
|
|
5
6
|
var EMPTY_VALUE = [];
|
|
6
7
|
function useUtil(generateConfig, locale, formatList) {
|
|
7
8
|
const getDateTexts = (dates) => {
|
|
@@ -29,10 +30,14 @@ function useUtil(generateConfig, locale, formatList) {
|
|
|
29
30
|
function orderDates(dates, generateConfig) {
|
|
30
31
|
return [...dates].sort((a, b) => generateConfig.isAfter(a, b) ? 1 : -1);
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Control the internal `value` align with prop `value` and provide a temp `calendarValue` for ui.
|
|
35
|
+
* `calendarValue` will be reset when blur & focus & open.
|
|
36
|
+
*/
|
|
32
37
|
function useInnerValue(generateConfig, locale, formatList, rangeValue, order, defaultValue, value, onCalendarChange, onOk) {
|
|
33
38
|
const mergedValue = shallowRef((value.value === void 0 ? defaultValue.value : value.value) || EMPTY_VALUE);
|
|
34
|
-
watch(value, (value
|
|
35
|
-
mergedValue.value = value
|
|
39
|
+
watch(value, (value) => {
|
|
40
|
+
mergedValue.value = value || EMPTY_VALUE;
|
|
36
41
|
});
|
|
37
42
|
const setInnerValue = (val) => {
|
|
38
43
|
if (value.value === void 0) mergedValue.value = val;
|
|
@@ -127,4 +132,5 @@ function useRangeValue(info, mergedValue, setInnerValue, getCalendarValue, trigg
|
|
|
127
132
|
});
|
|
128
133
|
return [flushSubmit, triggerSubmit];
|
|
129
134
|
}
|
|
135
|
+
//#endregion
|
|
130
136
|
export { useRangeValue as default, useInnerValue };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
|
+
//#region src/PickerInput/hooks/useShowNow.ts
|
|
2
3
|
function useShowNow(picker, mode, showNow, showToday, rangePicker) {
|
|
3
4
|
return computed(() => {
|
|
4
5
|
if (mode.value !== "date" && mode.value !== "time") return false;
|
|
@@ -7,4 +8,5 @@ function useShowNow(picker, mode, showNow, showToday, rangePicker) {
|
|
|
7
8
|
return !rangePicker?.value && (picker.value === "date" || picker.value === "time");
|
|
8
9
|
});
|
|
9
10
|
}
|
|
11
|
+
//#endregion
|
|
10
12
|
export { useShowNow as default };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatValue, getWeekStartDate, isSameDate, isSameMonth } from "../../utils/dateUtil.js";
|
|
2
2
|
import { providePanelContext, useInfo, useSharedPanelContext } from "../context.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import PanelBody from "../PanelBody.js";
|
|
4
|
+
import PanelHeader from "../PanelHeader.js";
|
|
5
5
|
import { computed, createVNode, defineComponent, isVNode, mergeProps } from "vue";
|
|
6
6
|
import { clsx } from "@v-c/util";
|
|
7
|
+
//#region src/PickerPanel/DatePanel/index.tsx
|
|
7
8
|
function _isSlot(s) {
|
|
8
9
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
9
10
|
}
|
|
10
|
-
var
|
|
11
|
+
var DatePanel = /* @__PURE__ */ defineComponent((props) => {
|
|
11
12
|
const sharedContext = useSharedPanelContext();
|
|
12
13
|
const panelContext = computed(() => {
|
|
13
14
|
const [info] = useInfo(props, props.mode || "date", sharedContext);
|
|
@@ -98,7 +99,7 @@ var DatePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
98
99
|
generateConfig
|
|
99
100
|
}) : monthsLocale[month]]);
|
|
100
101
|
const monthYearNodes = locale?.monthBeforeYear ? [monthNode, yearNode] : [yearNode, monthNode];
|
|
101
|
-
return createVNode("div", { "class": clsx(panelPrefixCls, showWeek && `${panelPrefixCls}-show-week`) }, [createVNode(
|
|
102
|
+
return createVNode("div", { "class": clsx(panelPrefixCls, showWeek && `${panelPrefixCls}-show-week`) }, [createVNode(PanelHeader, {
|
|
102
103
|
"offset": (distance, date) => generateConfig?.addMonth?.(date, distance),
|
|
103
104
|
"superOffset": (distance, date) => generateConfig?.addYear?.(date, distance),
|
|
104
105
|
"onChange": onPickerValueChange,
|
|
@@ -108,7 +109,7 @@ var DatePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
108
109
|
clone = generateConfig?.addMonth(clone, 1);
|
|
109
110
|
return generateConfig?.addDate(clone, -1);
|
|
110
111
|
}
|
|
111
|
-
}, _isSlot(monthYearNodes) ? monthYearNodes : { default: () => [monthYearNodes] }), createVNode(
|
|
112
|
+
}, _isSlot(monthYearNodes) ? monthYearNodes : { default: () => [monthYearNodes] }), createVNode(PanelBody, mergeProps(props, {
|
|
112
113
|
"titleFormat": locale?.fieldDateFormat,
|
|
113
114
|
"colNum": 7,
|
|
114
115
|
"rowNum": 6,
|
|
@@ -145,8 +146,7 @@ var DatePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
145
146
|
},
|
|
146
147
|
prefixCls: {
|
|
147
148
|
type: String,
|
|
148
|
-
required: true
|
|
149
|
-
default: void 0
|
|
149
|
+
required: true
|
|
150
150
|
},
|
|
151
151
|
locale: {
|
|
152
152
|
type: Object,
|
|
@@ -158,14 +158,10 @@ var DatePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
158
158
|
required: false,
|
|
159
159
|
default: void 0
|
|
160
160
|
},
|
|
161
|
-
pickerValue: {
|
|
162
|
-
required: true,
|
|
163
|
-
default: void 0
|
|
164
|
-
},
|
|
161
|
+
pickerValue: { required: true },
|
|
165
162
|
onPickerValueChange: {
|
|
166
163
|
type: Function,
|
|
167
|
-
required: true
|
|
168
|
-
default: void 0
|
|
164
|
+
required: true
|
|
169
165
|
},
|
|
170
166
|
value: {
|
|
171
167
|
required: false,
|
|
@@ -173,8 +169,7 @@ var DatePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
173
169
|
},
|
|
174
170
|
onSelect: {
|
|
175
171
|
type: Function,
|
|
176
|
-
required: true
|
|
177
|
-
default: void 0
|
|
172
|
+
required: true
|
|
178
173
|
},
|
|
179
174
|
values: {
|
|
180
175
|
type: Array,
|
|
@@ -183,8 +178,7 @@ var DatePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
183
178
|
},
|
|
184
179
|
onModeChange: {
|
|
185
180
|
type: Function,
|
|
186
|
-
required: true
|
|
187
|
-
default: void 0
|
|
181
|
+
required: true
|
|
188
182
|
},
|
|
189
183
|
disabledDate: {
|
|
190
184
|
type: Function,
|
|
@@ -206,8 +200,7 @@ var DatePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
206
200
|
},
|
|
207
201
|
hoverRangeValue: {
|
|
208
202
|
type: [Array, null],
|
|
209
|
-
required: true
|
|
210
|
-
default: void 0
|
|
203
|
+
required: true
|
|
211
204
|
},
|
|
212
205
|
hoverValue: {
|
|
213
206
|
type: [Array, null],
|
|
@@ -285,4 +278,5 @@ var DatePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
285
278
|
name: "DatePanel",
|
|
286
279
|
inheritAttrs: false
|
|
287
280
|
});
|
|
288
|
-
|
|
281
|
+
//#endregion
|
|
282
|
+
export { DatePanel as default };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { fillTime } from "../../utils/dateUtil.js";
|
|
2
2
|
import useTimeInfo from "../../hooks/useTimeInfo.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import DatePanel from "../DatePanel/index.js";
|
|
4
|
+
import TimePanel from "../TimePanel/index.js";
|
|
5
5
|
import { computed, createVNode, defineComponent } from "vue";
|
|
6
6
|
import { omit } from "@v-c/util";
|
|
7
|
-
|
|
7
|
+
//#region src/PickerPanel/DateTimePanel/index.tsx
|
|
8
|
+
var DateTimePanel = /* @__PURE__ */ defineComponent((props) => {
|
|
8
9
|
const [getValidTime] = useTimeInfo(computed(() => props.generateConfig), computed(() => typeof props.showTime === "object" ? props.showTime : {}));
|
|
9
10
|
return () => {
|
|
10
11
|
const { prefixCls, generateConfig, onSelect, value, pickerValue, onHover } = props;
|
|
@@ -25,14 +26,13 @@ var DateTimePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
25
26
|
onSelect: onDateSelect,
|
|
26
27
|
onHover: onDateHover
|
|
27
28
|
};
|
|
28
|
-
return createVNode("div", { "class": panelPrefixCls }, [createVNode(
|
|
29
|
+
return createVNode("div", { "class": panelPrefixCls }, [createVNode(DatePanel, datePanelProps, null), createVNode(TimePanel, props, null)]);
|
|
29
30
|
};
|
|
30
31
|
}, {
|
|
31
32
|
props: {
|
|
32
33
|
prefixCls: {
|
|
33
34
|
type: String,
|
|
34
|
-
required: true
|
|
35
|
-
default: void 0
|
|
35
|
+
required: true
|
|
36
36
|
},
|
|
37
37
|
locale: {
|
|
38
38
|
type: Object,
|
|
@@ -44,14 +44,10 @@ var DateTimePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
44
44
|
required: false,
|
|
45
45
|
default: void 0
|
|
46
46
|
},
|
|
47
|
-
pickerValue: {
|
|
48
|
-
required: true,
|
|
49
|
-
default: void 0
|
|
50
|
-
},
|
|
47
|
+
pickerValue: { required: true },
|
|
51
48
|
onPickerValueChange: {
|
|
52
49
|
type: Function,
|
|
53
|
-
required: true
|
|
54
|
-
default: void 0
|
|
50
|
+
required: true
|
|
55
51
|
},
|
|
56
52
|
value: {
|
|
57
53
|
required: false,
|
|
@@ -59,8 +55,7 @@ var DateTimePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
59
55
|
},
|
|
60
56
|
onSelect: {
|
|
61
57
|
type: Function,
|
|
62
|
-
required: true
|
|
63
|
-
default: void 0
|
|
58
|
+
required: true
|
|
64
59
|
},
|
|
65
60
|
values: {
|
|
66
61
|
type: Array,
|
|
@@ -69,8 +64,7 @@ var DateTimePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
69
64
|
},
|
|
70
65
|
onModeChange: {
|
|
71
66
|
type: Function,
|
|
72
|
-
required: true
|
|
73
|
-
default: void 0
|
|
67
|
+
required: true
|
|
74
68
|
},
|
|
75
69
|
disabledDate: {
|
|
76
70
|
type: Function,
|
|
@@ -92,8 +86,7 @@ var DateTimePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
92
86
|
},
|
|
93
87
|
hoverRangeValue: {
|
|
94
88
|
type: [Array, null],
|
|
95
|
-
required: true
|
|
96
|
-
default: void 0
|
|
89
|
+
required: true
|
|
97
90
|
},
|
|
98
91
|
hoverValue: {
|
|
99
92
|
type: [Array, null],
|
|
@@ -171,4 +164,5 @@ var DateTimePanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
171
164
|
name: "DateTimePanel",
|
|
172
165
|
inheritAttrs: false
|
|
173
166
|
});
|
|
174
|
-
|
|
167
|
+
//#endregion
|
|
168
|
+
export { DateTimePanel as default };
|