@v-c/picker 1.0.4 → 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 +4 -4
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { formatValue, isInRange, isSameYear } 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, createTextVNode, createVNode, defineComponent, isVNode, mergeProps } from "vue";
|
|
6
|
+
//#region src/PickerPanel/YearPanel/index.tsx
|
|
6
7
|
function _isSlot(s) {
|
|
7
8
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
8
9
|
}
|
|
9
|
-
var
|
|
10
|
+
var YearPanel = /* @__PURE__ */ defineComponent((props) => {
|
|
10
11
|
const sharedContext = useSharedPanelContext();
|
|
11
12
|
providePanelContext(computed(() => {
|
|
12
13
|
const [info] = useInfo(props, "year", sharedContext);
|
|
@@ -70,12 +71,12 @@ var YearPanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
70
71
|
generateConfig
|
|
71
72
|
})
|
|
72
73
|
]);
|
|
73
|
-
return createVNode("div", { "class": panelPrefixCls }, [createVNode(
|
|
74
|
+
return createVNode("div", { "class": panelPrefixCls }, [createVNode(PanelHeader, {
|
|
74
75
|
"superOffset": (distance, date) => generateConfig.addYear(date, distance * 10),
|
|
75
76
|
"onChange": onPickerValueChange,
|
|
76
77
|
"getStart": getStartYear,
|
|
77
78
|
"getEnd": getEndYear
|
|
78
|
-
}, _isSlot(yearNode) ? yearNode : { default: () => [yearNode] }), createVNode(
|
|
79
|
+
}, _isSlot(yearNode) ? yearNode : { default: () => [yearNode] }), createVNode(PanelBody, mergeProps(props, {
|
|
79
80
|
"disabledDate": mergedDisabledDate,
|
|
80
81
|
"titleFormat": locale.fieldYearFormat,
|
|
81
82
|
"colNum": 3,
|
|
@@ -90,8 +91,7 @@ var YearPanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
90
91
|
props: {
|
|
91
92
|
prefixCls: {
|
|
92
93
|
type: String,
|
|
93
|
-
required: true
|
|
94
|
-
default: void 0
|
|
94
|
+
required: true
|
|
95
95
|
},
|
|
96
96
|
locale: {
|
|
97
97
|
type: Object,
|
|
@@ -103,14 +103,10 @@ var YearPanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
103
103
|
required: false,
|
|
104
104
|
default: void 0
|
|
105
105
|
},
|
|
106
|
-
pickerValue: {
|
|
107
|
-
required: true,
|
|
108
|
-
default: void 0
|
|
109
|
-
},
|
|
106
|
+
pickerValue: { required: true },
|
|
110
107
|
onPickerValueChange: {
|
|
111
108
|
type: Function,
|
|
112
|
-
required: true
|
|
113
|
-
default: void 0
|
|
109
|
+
required: true
|
|
114
110
|
},
|
|
115
111
|
value: {
|
|
116
112
|
required: false,
|
|
@@ -118,8 +114,7 @@ var YearPanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
118
114
|
},
|
|
119
115
|
onSelect: {
|
|
120
116
|
type: Function,
|
|
121
|
-
required: true
|
|
122
|
-
default: void 0
|
|
117
|
+
required: true
|
|
123
118
|
},
|
|
124
119
|
values: {
|
|
125
120
|
type: Array,
|
|
@@ -128,8 +123,7 @@ var YearPanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
128
123
|
},
|
|
129
124
|
onModeChange: {
|
|
130
125
|
type: Function,
|
|
131
|
-
required: true
|
|
132
|
-
default: void 0
|
|
126
|
+
required: true
|
|
133
127
|
},
|
|
134
128
|
disabledDate: {
|
|
135
129
|
type: Function,
|
|
@@ -151,8 +145,7 @@ var YearPanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
151
145
|
},
|
|
152
146
|
hoverRangeValue: {
|
|
153
147
|
type: [Array, null],
|
|
154
|
-
required: true
|
|
155
|
-
default: void 0
|
|
148
|
+
required: true
|
|
156
149
|
},
|
|
157
150
|
hoverValue: {
|
|
158
151
|
type: [Array, null],
|
|
@@ -230,4 +223,5 @@ var YearPanel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
230
223
|
name: "YearPanel",
|
|
231
224
|
inheritAttrs: false
|
|
232
225
|
});
|
|
233
|
-
|
|
226
|
+
//#endregion
|
|
227
|
+
export { YearPanel as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { inject, provide } from "vue";
|
|
2
|
+
//#region src/PickerPanel/context.ts
|
|
2
3
|
var SharedPanelContextKey = Symbol("SharedPanelContext");
|
|
3
4
|
function provideSharedPanelContext(context) {
|
|
4
5
|
provide(SharedPanelContextKey, context);
|
|
@@ -50,4 +51,5 @@ function providePickerHackContext(context) {
|
|
|
50
51
|
function usePickerHackContext() {
|
|
51
52
|
return inject(PickerHackContextKey, null);
|
|
52
53
|
}
|
|
54
|
+
//#endregion
|
|
53
55
|
export { providePanelContext, providePickerHackContext, provideSharedPanelContext, useInfo, usePanelContext, usePickerHackContext, useSharedPanelContext };
|
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import { usePickerContext } from "../PickerInput/context.js";
|
|
2
2
|
import { pickProps, toArray } from "../utils/miscUtil.js";
|
|
3
3
|
import useCellRender from "../PickerInput/hooks/useCellRender.js";
|
|
4
|
-
import
|
|
4
|
+
import locale from "../locale/en_US.js";
|
|
5
5
|
import useLocale from "../hooks/useLocale.js";
|
|
6
6
|
import { fillShowTimeConfig, getTimeProps } from "../hooks/useTimeConfig.js";
|
|
7
7
|
import { isSame } from "../utils/dateUtil.js";
|
|
8
8
|
import useToggleDates from "../hooks/useToggleDates.js";
|
|
9
9
|
import { providePickerHackContext, provideSharedPanelContext, usePickerHackContext } from "./context.js";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
10
|
+
import DatePanel from "./DatePanel/index.js";
|
|
11
|
+
import TimePanel from "./TimePanel/index.js";
|
|
12
|
+
import DateTimePanel from "./DateTimePanel/index.js";
|
|
13
|
+
import DecadePanel from "./DecadePanel/index.js";
|
|
14
|
+
import MonthPanel from "./MonthPanel/index.js";
|
|
15
|
+
import QuarterPanel from "./QuarterPanel/index.js";
|
|
16
|
+
import WeekPanel from "./WeekPanel/index.js";
|
|
17
|
+
import YearPanel from "./YearPanel/index.js";
|
|
18
18
|
import { computed, createVNode, defineComponent, mergeProps, ref, toRef, watch } from "vue";
|
|
19
19
|
import { clsx, warning } from "@v-c/util";
|
|
20
|
+
//#region src/PickerPanel/index.tsx
|
|
20
21
|
var DefaultComponents = {
|
|
21
|
-
date:
|
|
22
|
-
datetime:
|
|
23
|
-
week:
|
|
24
|
-
month:
|
|
25
|
-
quarter:
|
|
26
|
-
year:
|
|
27
|
-
decade:
|
|
28
|
-
time:
|
|
22
|
+
date: DatePanel,
|
|
23
|
+
datetime: DateTimePanel,
|
|
24
|
+
week: WeekPanel,
|
|
25
|
+
month: MonthPanel,
|
|
26
|
+
quarter: QuarterPanel,
|
|
27
|
+
year: YearPanel,
|
|
28
|
+
decade: DecadePanel,
|
|
29
|
+
time: TimePanel
|
|
29
30
|
};
|
|
30
|
-
var
|
|
31
|
+
var PickerPanel = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
31
32
|
const pickerContext = usePickerContext();
|
|
32
33
|
const rootRef = ref();
|
|
33
34
|
const mergedPrefixCls = computed(() => pickerContext.value.prefixCls || props.prefixCls || "vc-picker");
|
|
34
35
|
const mergedGenerateConfig = computed(() => props.generateConfig || pickerContext.value.generateConfig);
|
|
35
|
-
const mergedLocale = computed(() => props.locale || pickerContext.value.locale ||
|
|
36
|
+
const mergedLocale = computed(() => props.locale || pickerContext.value.locale || locale);
|
|
36
37
|
const timePropsInfo = computed(() => getTimeProps({
|
|
37
38
|
...props,
|
|
38
39
|
locale: mergedLocale.value,
|
|
@@ -132,7 +133,7 @@ var PickerPanel_default = /* @__PURE__ */ defineComponent((props, { attrs }) =>
|
|
|
132
133
|
})));
|
|
133
134
|
if (process.env.NODE_ENV !== "production") warning(!mergedValue.value || mergedValue.value.every((val) => mergedGenerateConfig.value.isValidate(val)), "Invalidate date pass to `value` or `defaultValue`.");
|
|
134
135
|
return () => {
|
|
135
|
-
const PanelComponent = props.components?.[internalMode.value] || DefaultComponents[internalMode.value] ||
|
|
136
|
+
const PanelComponent = props.components?.[internalMode.value] || DefaultComponents[internalMode.value] || DatePanel;
|
|
136
137
|
const panelCls = `${mergedPrefixCls.value}-panel`;
|
|
137
138
|
const panelProps = pickProps(props, [
|
|
138
139
|
"showWeek",
|
|
@@ -464,4 +465,5 @@ var PickerPanel_default = /* @__PURE__ */ defineComponent((props, { attrs }) =>
|
|
|
464
465
|
name: "PickerPanel",
|
|
465
466
|
inheritAttrs: false
|
|
466
467
|
});
|
|
467
|
-
|
|
468
|
+
//#endregion
|
|
469
|
+
export { PickerPanel as default };
|
|
@@ -3,6 +3,7 @@ import { getRealPlacement } from "../utils/uiUtil.js";
|
|
|
3
3
|
import { computed, createVNode, defineComponent } from "vue";
|
|
4
4
|
import { clsx } from "@v-c/util";
|
|
5
5
|
import Trigger from "@v-c/trigger";
|
|
6
|
+
//#region src/PickerTrigger/index.tsx
|
|
6
7
|
var BUILT_IN_PLACEMENTS = {
|
|
7
8
|
bottomLeft: {
|
|
8
9
|
points: ["tl", "bl"],
|
|
@@ -37,7 +38,7 @@ var BUILT_IN_PLACEMENTS = {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
|
-
var
|
|
41
|
+
var PickerTrigger = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
41
42
|
const ctx = usePickerContext();
|
|
42
43
|
const dropdownPrefixCls = computed(() => `${ctx.value.prefixCls}-dropdown`);
|
|
43
44
|
const realPlacement = computed(() => getRealPlacement(props.placement, props.direction === "rtl"));
|
|
@@ -129,4 +130,5 @@ var PickerTrigger_default = /* @__PURE__ */ defineComponent((props, { slots }) =
|
|
|
129
130
|
name: "PickerTrigger",
|
|
130
131
|
inheritAttrs: false
|
|
131
132
|
});
|
|
132
|
-
|
|
133
|
+
//#endregion
|
|
134
|
+
export { PickerTrigger as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pickProps } from "../utils/miscUtil.js";
|
|
2
|
+
//#region src/PickerTrigger/util.ts
|
|
2
3
|
function pickTriggerProps(props) {
|
|
3
4
|
return pickProps(props, [
|
|
4
5
|
"placement",
|
|
@@ -9,4 +10,5 @@ function pickTriggerProps(props) {
|
|
|
9
10
|
"direction"
|
|
10
11
|
]);
|
|
11
12
|
}
|
|
13
|
+
//#endregion
|
|
12
14
|
export { pickTriggerProps };
|
package/dist/generate/dateFns.js
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import { addDays, addMonths, addYears, endOfMonth, format, getDate, getDay, getHours, getMilliseconds, getMinutes, getMonth, getSeconds, getWeek, getYear, isAfter, isValid, parse, setDate, setHours, setMilliseconds, setMinutes, setMonth, setSeconds, setYear, startOfWeek } from "date-fns";
|
|
2
2
|
import * as locales from "date-fns/locale";
|
|
3
|
+
//#region src/generate/dateFns.ts
|
|
3
4
|
function getLocale(locale) {
|
|
4
5
|
const tmpLocales = locales;
|
|
5
6
|
return tmpLocales[locale] || tmpLocales[locale.replace(/_/g, "")] || tmpLocales[locale.replace(/_.*$/g, "")];
|
|
6
7
|
}
|
|
7
|
-
function localeParse(format
|
|
8
|
-
return format
|
|
8
|
+
function localeParse(format) {
|
|
9
|
+
return format.replace(/Y/g, "y").replace(/D/g, "d").replace(/gggg/, "yyyy").replace(/g/g, "G").replace(/([Ww])o/g, "wo");
|
|
9
10
|
}
|
|
10
|
-
function parse$1(text, format
|
|
11
|
-
return parse(text, localeParse(format
|
|
11
|
+
function parse$1(text, format, locale) {
|
|
12
|
+
return parse(text, localeParse(format), /* @__PURE__ */ new Date(), { locale: getLocale(locale) });
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if the text is a valid date considering the format and locale
|
|
16
|
+
*
|
|
17
|
+
* This is a strict check, the date string must match the format exactly.
|
|
18
|
+
* Date-fns allows some flexibility in parsing dates, for example, it will parse "30/01/2" as "30/01/002".
|
|
19
|
+
* This behavior is not desirable in our case, so we need to check if the date string matches the format exactly.
|
|
20
|
+
*
|
|
21
|
+
* @param text the date string
|
|
22
|
+
* @param format the date format to use
|
|
23
|
+
* @param locale the locale to use
|
|
24
|
+
*/
|
|
13
25
|
function isStrictValidDate(text, format$1, locale) {
|
|
14
26
|
const date = parse$1(text, format$1, locale);
|
|
15
27
|
if (!isValid(date)) return false;
|
|
16
28
|
return text === format(date, format$1, { locale: getLocale(locale) });
|
|
17
29
|
}
|
|
18
|
-
var
|
|
30
|
+
var generateConfig = {
|
|
19
31
|
getNow: () => /* @__PURE__ */ new Date(),
|
|
20
32
|
getFixedDate: (string) => new Date(string),
|
|
21
33
|
getEndDate: (date) => endOfMonth(date),
|
|
@@ -57,17 +69,18 @@ var dateFns_default = {
|
|
|
57
69
|
const clone = getLocale(locale);
|
|
58
70
|
return Array.from({ length: 12 }).map((_, i) => clone.localize.month(i, { width: "abbreviated" }));
|
|
59
71
|
},
|
|
60
|
-
format: (locale, date, format$
|
|
72
|
+
format: (locale, date, format$2) => {
|
|
61
73
|
if (!isValid(date)) return null;
|
|
62
|
-
return format(date, localeParse(format$
|
|
74
|
+
return format(date, localeParse(format$2), { locale: getLocale(locale) });
|
|
63
75
|
},
|
|
64
76
|
parse: (locale, text, formats) => {
|
|
65
77
|
for (let i = 0; i < formats.length; i += 1) {
|
|
66
|
-
const format
|
|
67
|
-
if (isStrictValidDate(text, format
|
|
78
|
+
const format = localeParse(formats[i]);
|
|
79
|
+
if (isStrictValidDate(text, format, locale)) return parse$1(text, format, locale);
|
|
68
80
|
}
|
|
69
81
|
return null;
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
};
|
|
73
|
-
|
|
85
|
+
//#endregion
|
|
86
|
+
export { generateConfig as default };
|
package/dist/generate/dayjs.js
CHANGED
|
@@ -5,6 +5,7 @@ import localeData from "dayjs/plugin/localeData";
|
|
|
5
5
|
import weekday from "dayjs/plugin/weekday";
|
|
6
6
|
import weekOfYear from "dayjs/plugin/weekOfYear";
|
|
7
7
|
import weekYear from "dayjs/plugin/weekYear";
|
|
8
|
+
//#region src/generate/dayjs.ts
|
|
8
9
|
dayjs.extend(customParseFormat);
|
|
9
10
|
dayjs.extend(advancedFormat);
|
|
10
11
|
dayjs.extend(weekday);
|
|
@@ -39,7 +40,7 @@ function parseLocale(locale) {
|
|
|
39
40
|
}
|
|
40
41
|
/* istanbul ignore next */
|
|
41
42
|
function parseNoMatchNotice() {}
|
|
42
|
-
var
|
|
43
|
+
var generateConfig = {
|
|
43
44
|
getNow: () => {
|
|
44
45
|
const now = dayjs();
|
|
45
46
|
if ("tz" in now && typeof now.tz === "function") return now.tz();
|
|
@@ -101,4 +102,5 @@ var dayjs_default = {
|
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
};
|
|
104
|
-
|
|
105
|
+
//#endregion
|
|
106
|
+
export { generateConfig as default };
|
package/dist/generate/luxon.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DateTime, Info } from "luxon";
|
|
2
|
+
//#region src/generate/luxon.ts
|
|
2
3
|
var weekDayFormatMap = {
|
|
3
4
|
zh_CN: "narrow",
|
|
4
5
|
zh_TW: "narrow"
|
|
@@ -7,17 +8,42 @@ var weekDayLengthMap = {
|
|
|
7
8
|
en_US: 2,
|
|
8
9
|
en_GB: 2
|
|
9
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Normalizes part of a moment format string that should
|
|
13
|
+
* not be escaped to a luxon compatible format string.
|
|
14
|
+
*
|
|
15
|
+
* @param part string
|
|
16
|
+
* @returns string
|
|
17
|
+
*/
|
|
10
18
|
function normalizeFormatPart(part) {
|
|
11
19
|
return part.replace(/Y/g, "y").replace(/D/g, "d").replace(/gg/g, "kk").replace(/Q/g, "q").replace(/([Ww])o/g, "WW").replace(/A/g, "a");
|
|
12
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Normalizes a moment compatible format string to a luxon compatible format string
|
|
23
|
+
*
|
|
24
|
+
* @param format string
|
|
25
|
+
* @returns string
|
|
26
|
+
*/
|
|
13
27
|
function normalizeFormat(format) {
|
|
14
28
|
return format.split(/[[\]]/).map((part, index) => {
|
|
15
29
|
return index % 2 > 0 ? part : normalizeFormatPart(part);
|
|
16
30
|
}).join("'");
|
|
17
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Normalizes language tags used to luxon compatible
|
|
34
|
+
* language tags by replacing underscores with hyphen-minus.
|
|
35
|
+
*
|
|
36
|
+
* @param locale string
|
|
37
|
+
* @returns string
|
|
38
|
+
*/
|
|
18
39
|
var normalizeLocale = (locale) => locale.replace(/_/g, "-");
|
|
19
|
-
var
|
|
40
|
+
var generateConfig = {
|
|
20
41
|
getNow: () => {
|
|
42
|
+
/**
|
|
43
|
+
* The current time that can respond to tz settings is required. like `dayjs().tz()`.
|
|
44
|
+
* @see: https://github.com/ant-design/ant-design/issues/51282
|
|
45
|
+
* https://github.com/react-component/picker/pull/878
|
|
46
|
+
*/
|
|
21
47
|
return DateTime.now();
|
|
22
48
|
},
|
|
23
49
|
getFixedDate: (string) => DateTime.fromFormat(string, "yyyy-MM-dd"),
|
|
@@ -66,4 +92,5 @@ var luxon_default = {
|
|
|
66
92
|
}
|
|
67
93
|
}
|
|
68
94
|
};
|
|
69
|
-
|
|
95
|
+
//#endregion
|
|
96
|
+
export { generateConfig as default };
|
package/dist/generate/moment.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { noteOnce } from "@v-c/util/dist/warning";
|
|
2
2
|
import moment from "moment";
|
|
3
|
-
|
|
3
|
+
//#region src/generate/moment.ts
|
|
4
|
+
var generateConfig = {
|
|
4
5
|
getNow: () => moment(),
|
|
5
6
|
getFixedDate: (string) => moment(string, "YYYY-MM-DD"),
|
|
6
7
|
getEndDate: (date) => {
|
|
@@ -97,4 +98,5 @@ var moment_default = {
|
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
};
|
|
100
|
-
|
|
101
|
+
//#endregion
|
|
102
|
+
export { generateConfig as default };
|
package/dist/hooks/useLocale.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import locale from "../locale/en_US.js";
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
//#region src/hooks/useLocale.ts
|
|
3
4
|
function fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, showMeridiem) {
|
|
4
5
|
let timeFormat = "";
|
|
5
6
|
const cells = [];
|
|
@@ -11,8 +12,11 @@ function fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, showM
|
|
|
11
12
|
if (showMeridiem) timeFormat += " A";
|
|
12
13
|
return timeFormat;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Used for `useFilledProps` since it already in the React.useMemo
|
|
17
|
+
*/
|
|
18
|
+
function fillLocale(locale$1, showHour, showMinute, showSecond, showMillisecond, use12Hours) {
|
|
19
|
+
const mergedLocale = locale$1 || locale || {};
|
|
16
20
|
const { fieldDateTimeFormat, fieldDateFormat, fieldTimeFormat, fieldMonthFormat, fieldYearFormat, fieldWeekFormat, fieldQuarterFormat, yearFormat, cellYearFormat, cellQuarterFormat, dayFormat, cellDateFormat } = mergedLocale;
|
|
17
21
|
const timeFormat = fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, use12Hours);
|
|
18
22
|
return {
|
|
@@ -36,4 +40,5 @@ function useLocale(locale, showProps) {
|
|
|
36
40
|
return fillLocale(locale.value, showHour, showMinute, showSecond, showMillisecond, use12Hours);
|
|
37
41
|
});
|
|
38
42
|
}
|
|
43
|
+
//#endregion
|
|
39
44
|
export { useLocale as default, fillTimeFormat };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
|
+
//#region src/hooks/useSemantic.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert `classNames` & `styles` to a fully filled object
|
|
5
|
+
*/
|
|
2
6
|
function useSemantic(classNames, styles) {
|
|
3
7
|
return computed(() => {
|
|
4
8
|
return [{
|
|
@@ -10,4 +14,5 @@ function useSemantic(classNames, styles) {
|
|
|
10
14
|
}];
|
|
11
15
|
});
|
|
12
16
|
}
|
|
17
|
+
//#endregion
|
|
13
18
|
export { useSemantic as default };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { ref, watch } from "vue";
|
|
2
|
+
//#region src/hooks/useSyncState.ts
|
|
3
|
+
/**
|
|
4
|
+
* Sync value with state.
|
|
5
|
+
* This should only used for internal which not affect outside calculation.
|
|
6
|
+
* Since it's not safe for suspense.
|
|
7
|
+
*/
|
|
2
8
|
function useSyncState(defaultValue, controlledValue) {
|
|
3
9
|
const valueRef = ref(defaultValue);
|
|
4
10
|
const getControlledValue = () => {
|
|
@@ -21,4 +27,5 @@ function useSyncState(defaultValue, controlledValue) {
|
|
|
21
27
|
valueRef
|
|
22
28
|
];
|
|
23
29
|
}
|
|
30
|
+
//#endregion
|
|
24
31
|
export { useSyncState as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getRowFormat, pickProps, toArray } from "../utils/miscUtil.js";
|
|
2
2
|
import { fillTimeFormat } from "./useLocale.js";
|
|
3
|
+
//#region src/hooks/useTimeConfig.ts
|
|
3
4
|
function checkShow(format, keywords, show) {
|
|
4
5
|
return show ?? keywords.some((keyword) => format.includes(keyword));
|
|
5
6
|
}
|
|
@@ -24,6 +25,9 @@ var showTimeKeys = [
|
|
|
24
25
|
"changeOnScroll",
|
|
25
26
|
"defaultOpenValue"
|
|
26
27
|
];
|
|
28
|
+
/**
|
|
29
|
+
* Get SharedTimeProps from props.
|
|
30
|
+
*/
|
|
27
31
|
function pickTimeProps(props) {
|
|
28
32
|
const timeProps = pickProps(props, showTimeKeys);
|
|
29
33
|
const { format, picker } = props;
|
|
@@ -39,6 +43,7 @@ function pickTimeProps(props) {
|
|
|
39
43
|
function isStringFormat(format) {
|
|
40
44
|
return format && typeof format === "string";
|
|
41
45
|
}
|
|
46
|
+
/** Check if all the showXXX is `undefined` */
|
|
42
47
|
function existShowConfig(showHour, showMinute, showSecond, showMillisecond) {
|
|
43
48
|
return [
|
|
44
49
|
showHour,
|
|
@@ -47,6 +52,7 @@ function existShowConfig(showHour, showMinute, showSecond, showMillisecond) {
|
|
|
47
52
|
showMillisecond
|
|
48
53
|
].some((show) => show !== void 0);
|
|
49
54
|
}
|
|
55
|
+
/** Fill the showXXX if needed */
|
|
50
56
|
function fillShowConfig(hasShowConfig, showHour, showMinute, showSecond, showMillisecond) {
|
|
51
57
|
let parsedShowHour = showHour;
|
|
52
58
|
let parsedShowMinute = showMinute;
|
|
@@ -78,6 +84,10 @@ function fillShowConfig(hasShowConfig, showHour, showMinute, showSecond, showMil
|
|
|
78
84
|
showMillisecond
|
|
79
85
|
];
|
|
80
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Get `showHour`, `showMinute`, `showSecond` or other from the props.
|
|
89
|
+
* This is pure function, will not get `showXXX` from the `format` prop.
|
|
90
|
+
*/
|
|
81
91
|
function getTimeProps(componentProps) {
|
|
82
92
|
const { showTime } = componentProps;
|
|
83
93
|
const [pickedProps, propFormat] = pickTimeProps(componentProps);
|
|
@@ -156,4 +166,5 @@ function fillShowTimeConfig(picker, showTimeFormat, propFormat, timeConfig, loca
|
|
|
156
166
|
}
|
|
157
167
|
return null;
|
|
158
168
|
}
|
|
169
|
+
//#endregion
|
|
159
170
|
export { fillShowTimeConfig, getTimeProps };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { leftPad } from "../utils/miscUtil.js";
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import { warning } from "@v-c/util";
|
|
4
|
+
//#region src/hooks/useTimeInfo.ts
|
|
4
5
|
function emptyDisabled() {
|
|
5
6
|
return [];
|
|
6
7
|
}
|
|
@@ -17,6 +18,9 @@ function generateUnits(start, end, step = 1, hideDisabledOptions = false, disabl
|
|
|
17
18
|
}
|
|
18
19
|
return units;
|
|
19
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse time props to get util info
|
|
23
|
+
*/
|
|
20
24
|
function useTimeInfo(generateConfig, props, date) {
|
|
21
25
|
const mergedDate = computed(() => date?.value || generateConfig.value.getNow());
|
|
22
26
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -41,7 +45,7 @@ function useTimeInfo(generateConfig, props, date) {
|
|
|
41
45
|
const getAllUnits = (getDisabledHours, getDisabledMinutes, getDisabledSeconds, getDisabledMilliseconds) => {
|
|
42
46
|
const p = props?.value || {};
|
|
43
47
|
const hours = generateUnits(0, 23, p.hourStep ?? 1, !!p.hideDisabledOptions, getDisabledHours?.());
|
|
44
|
-
const rowHourUnits
|
|
48
|
+
const rowHourUnits = p.use12Hours ? hours.map((unit) => ({
|
|
45
49
|
...unit,
|
|
46
50
|
label: leftPad(unit.value % 12 || 12, 2)
|
|
47
51
|
})) : hours;
|
|
@@ -49,7 +53,7 @@ function useTimeInfo(generateConfig, props, date) {
|
|
|
49
53
|
const getSecondUnits = (nextHour, nextMinute) => generateUnits(0, 59, p.secondStep ?? 1, !!p.hideDisabledOptions, getDisabledSeconds?.(nextHour, nextMinute));
|
|
50
54
|
const getMillisecondUnits = (nextHour, nextMinute, nextSecond) => generateUnits(0, 999, p.millisecondStep ?? 100, !!p.hideDisabledOptions, getDisabledMilliseconds?.(nextHour, nextMinute, nextSecond), 3);
|
|
51
55
|
return [
|
|
52
|
-
rowHourUnits
|
|
56
|
+
rowHourUnits,
|
|
53
57
|
getMinuteUnits,
|
|
54
58
|
getSecondUnits,
|
|
55
59
|
getMillisecondUnits
|
|
@@ -63,6 +67,9 @@ function useTimeInfo(generateConfig, props, date) {
|
|
|
63
67
|
const minuteUnitsGetter = (nextHour) => defaultUnits.value[1](nextHour);
|
|
64
68
|
const secondUnitsGetter = (nextHour, nextMinute) => defaultUnits.value[2](nextHour, nextMinute);
|
|
65
69
|
const millisecondUnitsGetter = (nextHour, nextMinute, nextSecond) => defaultUnits.value[3](nextHour, nextMinute, nextSecond);
|
|
70
|
+
/**
|
|
71
|
+
* Get validate time with `disabledTime`, `certainDate` to specific the date need to check
|
|
72
|
+
*/
|
|
66
73
|
const getValidTime = (nextTime, certainDate) => {
|
|
67
74
|
let getCheckHourUnits = () => rowHourUnits.value;
|
|
68
75
|
let getCheckMinuteUnits = minuteUnitsGetter;
|
|
@@ -106,4 +113,5 @@ function findValidateTime(nextTime, getHourUnits, getMinuteUnits, getSecondUnits
|
|
|
106
113
|
alignValidate("getMillisecond", "setMillisecond", getMillisecondUnits(nextHour, nextMinute, alignValidate("getSecond", "setSecond", getSecondUnits(nextHour, nextMinute))));
|
|
107
114
|
return nextDate;
|
|
108
115
|
}
|
|
116
|
+
//#endregion
|
|
109
117
|
export { useTimeInfo as default };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { isSame } from "../utils/dateUtil.js";
|
|
2
|
+
//#region src/hooks/useToggleDates.ts
|
|
3
|
+
/**
|
|
4
|
+
* Toggles the presence of a value in an array.
|
|
5
|
+
* If the value exists in the array, removed it.
|
|
6
|
+
* Else add it.
|
|
7
|
+
*/
|
|
2
8
|
function useToggleDates(generateConfig, locale, panelMode) {
|
|
3
9
|
function toggleDates(list, target) {
|
|
4
10
|
const index = list.findIndex((date) => isSame(generateConfig.value, locale.value, date, target, panelMode.value));
|
|
@@ -9,4 +15,5 @@ function useToggleDates(generateConfig, locale, panelMode) {
|
|
|
9
15
|
}
|
|
10
16
|
return toggleDates;
|
|
11
17
|
}
|
|
18
|
+
//#endregion
|
|
12
19
|
export { useToggleDates as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Components, Locale, PickerMode, PickerRef, SharedTimeProps } from './interface';
|
|
2
2
|
import { RangePickerProps, default as RangePicker } from './PickerInput/RangePicker';
|
|
3
|
-
import { BasePickerProps, PickerProps, default as Picker } from './PickerInput/SinglePicker';
|
|
3
|
+
import { BasePickerProps, CustomTagProps, PickerProps, default as Picker } from './PickerInput/SinglePicker';
|
|
4
4
|
import { BasePickerPanelProps, PickerPanelProps, default as PickerPanel } from './PickerPanel';
|
|
5
5
|
export { Picker, PickerPanel, RangePicker };
|
|
6
|
-
export type { BasePickerPanelProps, BasePickerProps, Components, Locale, PickerMode, PickerPanelProps, PickerProps, PickerRef, RangePickerProps, SharedTimeProps, };
|
|
6
|
+
export type { BasePickerPanelProps, BasePickerProps, Components, CustomTagProps, Locale, PickerMode, PickerPanelProps, PickerProps, PickerRef, RangePickerProps, SharedTimeProps, };
|
|
7
7
|
export default Picker;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import PickerPanel from "./PickerPanel/index.js";
|
|
2
|
+
import RangePicker from "./PickerInput/RangePicker.js";
|
|
3
|
+
import SinglePicker from "./PickerInput/SinglePicker.js";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
var src_default = SinglePicker;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { SinglePicker as Picker, PickerPanel, RangePicker, src_default as default };
|
package/dist/locale/am_ET.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/am_ET.ts
|
|
2
|
+
var locale = {
|
|
2
3
|
locale: "am_ET",
|
|
3
4
|
today: "ዛሬ",
|
|
4
5
|
now: "አሁን",
|
|
@@ -26,4 +27,5 @@ var am_ET_default = {
|
|
|
26
27
|
previousCentury: "ያለፈው ክፍለ ዘመን",
|
|
27
28
|
nextCentury: "ቀጣይ ክፍለ ዘመን"
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
+
//#endregion
|
|
31
|
+
export { locale as default };
|
package/dist/locale/ar_EG.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { commonLocale } from "./common.js";
|
|
2
|
-
|
|
2
|
+
//#region src/locale/ar_EG.ts
|
|
3
|
+
var locale = {
|
|
3
4
|
...commonLocale,
|
|
4
5
|
locale: "ar_EG",
|
|
5
6
|
today: "اليوم",
|
|
@@ -24,4 +25,5 @@ var ar_EG_default = {
|
|
|
24
25
|
previousCentury: "القرن السابق",
|
|
25
26
|
nextCentury: "القرن التالى"
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
+
//#endregion
|
|
29
|
+
export { locale as default };
|
package/dist/locale/az_AZ.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { commonLocale } from "./common.js";
|
|
2
|
-
|
|
2
|
+
//#region src/locale/az_AZ.ts
|
|
3
|
+
var locale = {
|
|
3
4
|
...commonLocale,
|
|
4
5
|
locale: "az_AZ",
|
|
5
6
|
today: "Bugün",
|
|
@@ -25,4 +26,5 @@ var az_AZ_default = {
|
|
|
25
26
|
previousCentury: "Sonuncu əsr",
|
|
26
27
|
nextCentury: "Növbəti əsr"
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
+
//#endregion
|
|
30
|
+
export { locale as default };
|
package/dist/locale/bg_BG.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { commonLocale } from "./common.js";
|
|
2
|
-
|
|
2
|
+
//#region src/locale/bg_BG.ts
|
|
3
|
+
var locale = {
|
|
3
4
|
...commonLocale,
|
|
4
5
|
locale: "bg_BG",
|
|
5
6
|
today: "Днес",
|
|
@@ -24,4 +25,5 @@ var bg_BG_default = {
|
|
|
24
25
|
previousCentury: "Последен век",
|
|
25
26
|
nextCentury: "Следващ век"
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
+
//#endregion
|
|
29
|
+
export { locale as default };
|
package/dist/locale/bn_BD.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { commonLocale } from "./common.js";
|
|
2
|
-
|
|
2
|
+
//#region src/locale/bn_BD.ts
|
|
3
|
+
var locale = {
|
|
3
4
|
...commonLocale,
|
|
4
5
|
locale: "bn_BD",
|
|
5
6
|
today: "আজ",
|
|
@@ -25,4 +26,5 @@ var bn_BD_default = {
|
|
|
25
26
|
previousCentury: "গত শতাব্দী",
|
|
26
27
|
nextCentury: "পরের শতাব্দী"
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
+
//#endregion
|
|
30
|
+
export { locale as default };
|