@veltra/desktop 1.7.4 → 1.7.5
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/components/calendar/utils.js +5 -5
- package/dist/components/calendar/utils.js.map +1 -1
- package/dist/components/date-picker/date-picker.js +27 -4
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/types/date-panel.d.ts +1 -1
- package/dist/types/date-picker.d.ts +10 -2
- package/dist/types/date-range-picker.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +5 -5
- package/src/components/calendar/utils.ts +8 -8
- package/src/components/date-picker/__test__/date-picker.test.ts +235 -0
- package/src/components/date-picker/date-picker.vue +33 -3
- package/src/types/date-panel.ts +1 -1
- package/src/types/date-picker.ts +10 -1
- package/src/types/date-range-picker.ts +1 -1
|
@@ -25,7 +25,7 @@ function getMonthDays(d, disabledDate) {
|
|
|
25
25
|
type: "current"
|
|
26
26
|
};
|
|
27
27
|
day.isToday = day.date.format() === todayStr;
|
|
28
|
-
day.disabled = disabledDate?.(day.date);
|
|
28
|
+
day.disabled = disabledDate?.(day.date, day.date.raw);
|
|
29
29
|
return day;
|
|
30
30
|
});
|
|
31
31
|
const preMonthDays = [];
|
|
@@ -39,7 +39,7 @@ function getMonthDays(d, disabledDate) {
|
|
|
39
39
|
date: d.calc(-i, "days"),
|
|
40
40
|
type: "pre"
|
|
41
41
|
};
|
|
42
|
-
day.disabled = disabledDate?.(day.date);
|
|
42
|
+
day.disabled = disabledDate?.(day.date, day.date.raw);
|
|
43
43
|
preMonthDays.unshift(day);
|
|
44
44
|
i++;
|
|
45
45
|
}
|
|
@@ -52,7 +52,7 @@ function getMonthDays(d, disabledDate) {
|
|
|
52
52
|
date: d.calc(j++, "days"),
|
|
53
53
|
type: "next"
|
|
54
54
|
};
|
|
55
|
-
day.disabled = disabledDate?.(day.date);
|
|
55
|
+
day.disabled = disabledDate?.(day.date, day.date.raw);
|
|
56
56
|
nextMonthDays.push(day);
|
|
57
57
|
}
|
|
58
58
|
return [
|
|
@@ -80,7 +80,7 @@ function getYearMonths(d, disabledDate) {
|
|
|
80
80
|
key: ym,
|
|
81
81
|
month,
|
|
82
82
|
date: monthDate,
|
|
83
|
-
disabled: disabledDate?.(monthDate)
|
|
83
|
+
disabled: disabledDate?.(monthDate, monthDate.raw)
|
|
84
84
|
};
|
|
85
85
|
});
|
|
86
86
|
}
|
|
@@ -99,7 +99,7 @@ function getTenYears(d, disabledDate) {
|
|
|
99
99
|
return {
|
|
100
100
|
year,
|
|
101
101
|
date: yearDate,
|
|
102
|
-
disabled: disabledDate?.(yearDate)
|
|
102
|
+
disabled: disabledDate?.(yearDate, yearDate.raw)
|
|
103
103
|
};
|
|
104
104
|
});
|
|
105
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/calendar/utils.ts"],"sourcesContent":["import { type Dater, date } from '@cat-kit/core'\n\nimport type { CalendarDay, CalendarMonth, CalendarYear } from '../../types'\n\nexport const weekDays: string[] = ['日', '一', '二', '三', '四', '五', '六']\n\n/**\n * 获取一个月的天数\n * @param d 日期\n * @param disabledDate 禁用日期\n * @returns\n */\nexport function getMonthDays(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater) => boolean\n): CalendarDay[] {\n const todayStr = date().format()\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n // 本月天数\n d.setDay(1)\n const currentMonthDays: CalendarDay[] = Array.from({ length: d.getDays() }).map((_, i) => {\n const day: CalendarDay = { date: d.calc(i, 'days'), type: 'current' }\n day.isToday = day.date.format() === todayStr\n day.disabled = disabledDate?.(day.date)\n return day\n })\n\n const preMonthDays: CalendarDay[] = []\n\n const nextMonthDays: CalendarDay[] = []\n\n // 上月天数\n const firstDayWeek = d.weekDay\n\n if (firstDayWeek !== 0) {\n // 上个月最后一天\n d.setDay(0)\n let i = 0\n while (i < firstDayWeek) {\n const day: CalendarDay = { date: d.calc(-i, 'days'), type: 'pre' }\n day.disabled = disabledDate?.(day.date)\n preMonthDays.unshift(day)\n i++\n }\n }\n\n // 下个月的天数\n const nextMonthDaysAmount = 42 - currentMonthDays.length - preMonthDays.length\n\n let j = 0\n d.setMonth(d.month + 2).setDay(1)\n\n while (j < nextMonthDaysAmount) {\n const day: CalendarDay = { date: d.calc(j++, 'days'), type: 'next' }\n day.disabled = disabledDate?.(day.date)\n nextMonthDays.push(day)\n }\n\n return [...preMonthDays, ...currentMonthDays, ...nextMonthDays]\n}\n\n/**\n * 获取一年的月份\n * @param d 日期\n * @param disabledDate 禁用的日期\n * @returns\n */\nexport function getYearMonths(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater) => boolean\n): CalendarMonth[] {\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n const year = d.year\n\n return Array.from({ length: 12 }).map((_, i) => {\n const month = i + 1\n\n const ym = `${year}-${month}`\n\n const monthDate = date(ym).toEndOfMonth().setHours(23)\n\n monthDate.setMinutes(59)\n monthDate.setSeconds(59)\n\n return { key: ym, month, date: monthDate, disabled: disabledDate?.(monthDate) }\n })\n}\n\n/**\n * 获取当前年份所处的10年\n * @param d 日期\n * @param disabledDate 禁用的日期\n * @returns\n */\nexport function getTenYears(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater) => boolean\n): CalendarYear[] {\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n const startYear = d.year - (d.year % 10) + 1\n\n return Array.from({ length: 10 }).map((_, i) => {\n const year = startYear + i\n\n const yearDate = date(`${year}-12-31 23:59:59`)\n\n return { year, date: yearDate, disabled: disabledDate?.(yearDate) }\n })\n}\n"],"mappings":";;AAIA,MAAa,WAAqB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;;;;;;;AAQpE,SAAgB,aACd,GACA,cACe;CACf,MAAM,WAAW,KAAK,CAAC,CAAC,OAAO;CAC/B,IAAI,aAAa,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAC7D,IAAI,KAAK,CAAC;CAIZ,EAAE,OAAO,CAAC;CACV,MAAM,mBAAkC,MAAM,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM;EACxF,MAAM,MAAmB;GAAE,MAAM,EAAE,KAAK,GAAG,MAAM;GAAG,MAAM;EAAU;EACpE,IAAI,UAAU,IAAI,KAAK,OAAO,MAAM;EACpC,IAAI,WAAW,eAAe,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/calendar/utils.ts"],"sourcesContent":["import { type Dater, date } from '@cat-kit/core'\n\nimport type { CalendarDay, CalendarMonth, CalendarYear } from '../../types'\n\nexport const weekDays: string[] = ['日', '一', '二', '三', '四', '五', '六']\n\n/**\n * 获取一个月的天数\n * @param d 日期\n * @param disabledDate 禁用日期\n * @returns\n */\nexport function getMonthDays(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater, raw: Date) => boolean\n): CalendarDay[] {\n const todayStr = date().format()\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n // 本月天数\n d.setDay(1)\n const currentMonthDays: CalendarDay[] = Array.from({ length: d.getDays() }).map((_, i) => {\n const day: CalendarDay = { date: d.calc(i, 'days'), type: 'current' }\n day.isToday = day.date.format() === todayStr\n day.disabled = disabledDate?.(day.date, day.date.raw)\n return day\n })\n\n const preMonthDays: CalendarDay[] = []\n\n const nextMonthDays: CalendarDay[] = []\n\n // 上月天数\n const firstDayWeek = d.weekDay\n\n if (firstDayWeek !== 0) {\n // 上个月最后一天\n d.setDay(0)\n let i = 0\n while (i < firstDayWeek) {\n const day: CalendarDay = { date: d.calc(-i, 'days'), type: 'pre' }\n day.disabled = disabledDate?.(day.date, day.date.raw)\n preMonthDays.unshift(day)\n i++\n }\n }\n\n // 下个月的天数\n const nextMonthDaysAmount = 42 - currentMonthDays.length - preMonthDays.length\n\n let j = 0\n d.setMonth(d.month + 2).setDay(1)\n\n while (j < nextMonthDaysAmount) {\n const day: CalendarDay = { date: d.calc(j++, 'days'), type: 'next' }\n day.disabled = disabledDate?.(day.date, day.date.raw)\n nextMonthDays.push(day)\n }\n\n return [...preMonthDays, ...currentMonthDays, ...nextMonthDays]\n}\n\n/**\n * 获取一年的月份\n * @param d 日期\n * @param disabledDate 禁用的日期\n * @returns\n */\nexport function getYearMonths(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater, raw: Date) => boolean\n): CalendarMonth[] {\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n const year = d.year\n\n return Array.from({ length: 12 }).map((_, i) => {\n const month = i + 1\n\n const ym = `${year}-${month}`\n\n const monthDate = date(ym).toEndOfMonth().setHours(23)\n\n monthDate.setMinutes(59)\n monthDate.setSeconds(59)\n\n return { key: ym, month, date: monthDate, disabled: disabledDate?.(monthDate, monthDate.raw) }\n })\n}\n\n/**\n * 获取当前年份所处的10年\n * @param d 日期\n * @param disabledDate 禁用的日期\n * @returns\n */\nexport function getTenYears(\n d: Date | string | number | Dater,\n disabledDate?: (d: Dater, raw: Date) => boolean\n): CalendarYear[] {\n if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {\n d = date(d)\n }\n\n const startYear = d.year - (d.year % 10) + 1\n\n return Array.from({ length: 10 }).map((_, i) => {\n const year = startYear + i\n\n const yearDate = date(`${year}-12-31 23:59:59`)\n\n return { year, date: yearDate, disabled: disabledDate?.(yearDate, yearDate.raw) }\n })\n}\n"],"mappings":";;AAIA,MAAa,WAAqB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;;;;;;;AAQpE,SAAgB,aACd,GACA,cACe;CACf,MAAM,WAAW,KAAK,CAAC,CAAC,OAAO;CAC/B,IAAI,aAAa,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAC7D,IAAI,KAAK,CAAC;CAIZ,EAAE,OAAO,CAAC;CACV,MAAM,mBAAkC,MAAM,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM;EACxF,MAAM,MAAmB;GAAE,MAAM,EAAE,KAAK,GAAG,MAAM;GAAG,MAAM;EAAU;EACpE,IAAI,UAAU,IAAI,KAAK,OAAO,MAAM;EACpC,IAAI,WAAW,eAAe,IAAI,MAAM,IAAI,KAAK,GAAG;EACpD,OAAO;CACT,CAAC;CAED,MAAM,eAA8B,CAAC;CAErC,MAAM,gBAA+B,CAAC;CAGtC,MAAM,eAAe,EAAE;CAEvB,IAAI,iBAAiB,GAAG;EAEtB,EAAE,OAAO,CAAC;EACV,IAAI,IAAI;EACR,OAAO,IAAI,cAAc;GACvB,MAAM,MAAmB;IAAE,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM;IAAG,MAAM;GAAM;GACjE,IAAI,WAAW,eAAe,IAAI,MAAM,IAAI,KAAK,GAAG;GACpD,aAAa,QAAQ,GAAG;GACxB;EACF;CACF;CAGA,MAAM,sBAAsB,KAAK,iBAAiB,SAAS,aAAa;CAExE,IAAI,IAAI;CACR,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;CAEhC,OAAO,IAAI,qBAAqB;EAC9B,MAAM,MAAmB;GAAE,MAAM,EAAE,KAAK,KAAK,MAAM;GAAG,MAAM;EAAO;EACnE,IAAI,WAAW,eAAe,IAAI,MAAM,IAAI,KAAK,GAAG;EACpD,cAAc,KAAK,GAAG;CACxB;CAEA,OAAO;EAAC,GAAG;EAAc,GAAG;EAAkB,GAAG;CAAa;AAChE;;;;;;;AAQA,SAAgB,cACd,GACA,cACiB;CACjB,IAAI,aAAa,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAC7D,IAAI,KAAK,CAAC;CAGZ,MAAM,OAAO,EAAE;CAEf,OAAO,MAAM,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM;EAC9C,MAAM,QAAQ,IAAI;EAElB,MAAM,KAAK,GAAG,KAAK,GAAG;EAEtB,MAAM,YAAY,KAAK,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,EAAE;EAErD,UAAU,WAAW,EAAE;EACvB,UAAU,WAAW,EAAE;EAEvB,OAAO;GAAE,KAAK;GAAI;GAAO,MAAM;GAAW,UAAU,eAAe,WAAW,UAAU,GAAG;EAAE;CAC/F,CAAC;AACH;;;;;;;AAQA,SAAgB,YACd,GACA,cACgB;CAChB,IAAI,aAAa,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAC7D,IAAI,KAAK,CAAC;CAGZ,MAAM,YAAY,EAAE,OAAQ,EAAE,OAAO,KAAM;CAE3C,OAAO,MAAM,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM;EAC9C,MAAM,OAAO,YAAY;EAEzB,MAAM,WAAW,KAAK,GAAG,KAAK,gBAAgB;EAE9C,OAAO;GAAE;GAAM,MAAM;GAAU,UAAU,eAAe,UAAU,SAAS,GAAG;EAAE;CAClF,CAAC;AACH"}
|
|
@@ -6,7 +6,7 @@ import { Fragment, computed, createBlock, createElementBlock, createTextVNode, c
|
|
|
6
6
|
import { useFormFallbackProps, useUserAction } from "@veltra/compositions";
|
|
7
7
|
import { FORM_EMPTY_CONTENT, bem, injectFormContext } from "@veltra/utils";
|
|
8
8
|
import { Calendar } from "@veltra/icons/normal";
|
|
9
|
-
import { date } from "@cat-kit/core";
|
|
9
|
+
import { Dater, date } from "@cat-kit/core";
|
|
10
10
|
//#region src/components/date-picker/date-picker.vue
|
|
11
11
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
12
12
|
name: "UDatePicker",
|
|
@@ -18,6 +18,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
18
18
|
type: { default: "date" },
|
|
19
19
|
format: {},
|
|
20
20
|
valueFormat: {},
|
|
21
|
+
dataType: { default: "string" },
|
|
21
22
|
disabledDate: {},
|
|
22
23
|
clearable: {
|
|
23
24
|
type: Boolean,
|
|
@@ -38,7 +39,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
38
39
|
rules: {},
|
|
39
40
|
size: {}
|
|
40
41
|
},
|
|
41
|
-
emits: ["update:modelValue"],
|
|
42
|
+
emits: ["update:modelValue", "change"],
|
|
42
43
|
setup(__props, { emit: __emit }) {
|
|
43
44
|
const props = __props;
|
|
44
45
|
const emit = __emit;
|
|
@@ -63,16 +64,37 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
63
64
|
});
|
|
64
65
|
const currentDate = shallowRef();
|
|
65
66
|
const { userAction, isUserActive } = useUserAction();
|
|
67
|
+
function parseModelValue(val) {
|
|
68
|
+
if (val == null || val === "") return void 0;
|
|
69
|
+
if (val instanceof Date || typeof val === "number") {
|
|
70
|
+
const d = date(val);
|
|
71
|
+
return isNaN(d.timestamp) ? void 0 : d;
|
|
72
|
+
}
|
|
73
|
+
if (typeof val === "string") {
|
|
74
|
+
if (props.dataType === "string" && props.valueFormat) {
|
|
75
|
+
const parsed = Dater.parse(val, props.valueFormat);
|
|
76
|
+
if (!isNaN(parsed.timestamp)) return parsed;
|
|
77
|
+
}
|
|
78
|
+
const fallback = date(val);
|
|
79
|
+
return isNaN(fallback.timestamp) ? void 0 : fallback;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
66
82
|
watch(() => props.modelValue, (modelValue) => {
|
|
67
83
|
if (isUserActive()) return;
|
|
68
|
-
currentDate.value =
|
|
84
|
+
currentDate.value = parseModelValue(modelValue);
|
|
69
85
|
}, { immediate: true });
|
|
70
86
|
const displayedValue = computed(() => {
|
|
71
87
|
return currentDate.value?.format(formatStr.value) ?? "";
|
|
72
88
|
});
|
|
89
|
+
function formatModelValue(d) {
|
|
90
|
+
if (props.dataType === "date") return d.raw;
|
|
91
|
+
if (props.dataType === "timestamp") return d.timestamp;
|
|
92
|
+
return d.format(props.valueFormat ?? formatStr.value);
|
|
93
|
+
}
|
|
73
94
|
const commitSelectedDate = userAction((date) => {
|
|
74
95
|
currentDate.value = date;
|
|
75
|
-
emit("update:modelValue", date
|
|
96
|
+
emit("update:modelValue", formatModelValue(date));
|
|
97
|
+
emit("change", date.raw);
|
|
76
98
|
});
|
|
77
99
|
async function handleSelectDate(date) {
|
|
78
100
|
await commitSelectedDate(date);
|
|
@@ -81,6 +103,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
81
103
|
function handleClear() {
|
|
82
104
|
currentDate.value = void 0;
|
|
83
105
|
emit("update:modelValue", void 0);
|
|
106
|
+
emit("change", void 0);
|
|
84
107
|
}
|
|
85
108
|
return (_ctx, _cache) => {
|
|
86
109
|
return !unref(readonly) ? (openBlock(), createBlock(unref(_sfc_main$2), mergeProps({ key: 0 }, _ctx.$attrs, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.js","names":["$attrs"],"sources":["../../../src/components/date-picker/date-picker.vue"],"sourcesContent":["<template>\n <u-dropdown\n v-if=\"!readonly\"\n v-bind=\"$attrs\"\n :class=\"className\"\n trigger=\"click\"\n width=\"auto\"\n ref=\"dropdownRef\"\n @update:visible=\"\"\n :disabled=\"disabled\"\n >\n <template #trigger>\n <u-input\n :size=\"size\"\n native-readonly\n :clearable=\"clearable\"\n :placeholder=\"placeholder\"\n :model-value=\"displayedValue\"\n :disabled=\"disabled\"\n @clear=\"handleClear\"\n >\n <template #suffix>\n <u-icon :class=\"cls.e('icon')\"><Calendar /></u-icon>\n </template>\n </u-input>\n </template>\n\n <template #content>\n <UDatePanel :size :type :disabled-date :date=\"currentDate\" @select:date=\"handleSelectDate\" />\n </template>\n </u-dropdown>\n\n <template v-else>\n {{ displayedValue || FORM_EMPTY_CONTENT }}\n </template>\n</template>\n\n<script lang=\"ts\" setup>\nimport { date,
|
|
1
|
+
{"version":3,"file":"date-picker.js","names":["$attrs"],"sources":["../../../src/components/date-picker/date-picker.vue"],"sourcesContent":["<template>\n <u-dropdown\n v-if=\"!readonly\"\n v-bind=\"$attrs\"\n :class=\"className\"\n trigger=\"click\"\n width=\"auto\"\n ref=\"dropdownRef\"\n @update:visible=\"\"\n :disabled=\"disabled\"\n >\n <template #trigger>\n <u-input\n :size=\"size\"\n native-readonly\n :clearable=\"clearable\"\n :placeholder=\"placeholder\"\n :model-value=\"displayedValue\"\n :disabled=\"disabled\"\n @clear=\"handleClear\"\n >\n <template #suffix>\n <u-icon :class=\"cls.e('icon')\"><Calendar /></u-icon>\n </template>\n </u-input>\n </template>\n\n <template #content>\n <UDatePanel :size :type :disabled-date :date=\"currentDate\" @select:date=\"handleSelectDate\" />\n </template>\n </u-dropdown>\n\n <template v-else>\n {{ displayedValue || FORM_EMPTY_CONTENT }}\n </template>\n</template>\n\n<script lang=\"ts\" setup>\nimport { date, Dater } from '@cat-kit/core'\nimport { useFormFallbackProps, useUserAction } from '@veltra/compositions'\nimport { Calendar } from '@veltra/icons/normal'\nimport { bem, FORM_EMPTY_CONTENT } from '@veltra/utils'\nimport { injectFormContext } from '@veltra/utils'\nimport { computed, shallowRef, watch } from 'vue'\n\nimport type { DatePickerEmits, DatePickerProps } from '../../types'\nimport type { DropdownExposed } from '../../types'\nimport { UDatePanel } from '../date-panel'\nimport { UDropdown } from '../dropdown'\nimport { UIcon } from '../icon'\nimport { UInput } from '../input'\n\ndefineOptions({ name: 'UDatePicker', inheritAttrs: false })\n\nconst props = withDefaults(defineProps<DatePickerProps>(), {\n placeholder: '选择日期',\n type: 'date',\n dataType: 'string',\n disabled: undefined,\n readonly: undefined,\n clearable: true\n})\n\nconst emit = defineEmits<DatePickerEmits>()\n\nconst cls = bem('date-picker')\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {\n size: 'default',\n disabled: false,\n readonly: false\n})\n\nconst className = computed(() => {\n return [cls.b, cls.m(size.value)]\n})\n\nconst dropdownRef = shallowRef<DropdownExposed>()\n\nconst formatStr = computed(() => {\n const { format, type } = props\n if (format) return format\n if (type === 'date') return 'yyyy-MM-dd'\n if (type === 'month') return 'yyyy-MM'\n if (type === 'year') return 'yyyy'\n return 'yyyy-MM-dd'\n})\n\nconst currentDate = shallowRef<Dater>()\n\nconst { userAction, isUserActive } = useUserAction()\n\nfunction parseModelValue(val?: string | number | Date): Dater | undefined {\n if (val == null || val === '') return undefined\n if (val instanceof Date || typeof val === 'number') {\n const d = date(val)\n return isNaN(d.timestamp) ? undefined : d\n }\n if (typeof val === 'string') {\n if (props.dataType === 'string' && props.valueFormat) {\n const parsed = Dater.parse(val, props.valueFormat)\n if (!isNaN(parsed.timestamp)) return parsed\n }\n const fallback = date(val)\n return isNaN(fallback.timestamp) ? undefined : fallback\n }\n return undefined\n}\n\nwatch(\n () => props.modelValue,\n (modelValue) => {\n if (isUserActive()) return\n currentDate.value = parseModelValue(modelValue)\n },\n { immediate: true }\n)\n\nconst displayedValue = computed(() => {\n return currentDate.value?.format(formatStr.value) ?? ''\n})\n\nfunction formatModelValue(d: Dater) {\n if (props.dataType === 'date') {\n return d.raw\n }\n if (props.dataType === 'timestamp') {\n return d.timestamp\n }\n return d.format(props.valueFormat ?? formatStr.value)\n}\n\nconst commitSelectedDate = userAction((date: Dater) => {\n currentDate.value = date\n emit('update:modelValue', formatModelValue(date))\n emit('change', date.raw)\n})\n\nasync function handleSelectDate(date: Dater) {\n await commitSelectedDate(date)\n dropdownRef.value?.close()\n}\n\nfunction handleClear() {\n currentDate.value = undefined\n emit('update:modelValue', undefined)\n emit('change', undefined)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsDA,MAAM,QAAQ;EASd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,aAAa;EAE7B,MAAM,EAAE,cAAc,kBAAkB;EAExC,MAAM,EAAE,MAAM,UAAU,aAAa,qBAAqB,CAAC,aAAa,CAAC,GAAG,KAAK,GAAG;GAClF,MAAM;GACN,UAAU;GACV,UAAU;EACZ,CAAC;EAED,MAAM,YAAY,eAAe;GAC/B,OAAO,CAAC,IAAI,GAAG,IAAI,EAAE,KAAK,KAAK,CAAC;EAClC,CAAC;EAED,MAAM,cAAc,WAA4B;EAEhD,MAAM,YAAY,eAAe;GAC/B,MAAM,EAAE,QAAQ,SAAS;GACzB,IAAI,QAAQ,OAAO;GACnB,IAAI,SAAS,QAAQ,OAAO;GAC5B,IAAI,SAAS,SAAS,OAAO;GAC7B,IAAI,SAAS,QAAQ,OAAO;GAC5B,OAAO;EACT,CAAC;EAED,MAAM,cAAc,WAAkB;EAEtC,MAAM,EAAE,YAAY,iBAAiB,cAAc;EAEnD,SAAS,gBAAgB,KAAiD;GACxE,IAAI,OAAO,QAAQ,QAAQ,IAAI,OAAO,KAAA;GACtC,IAAI,eAAe,QAAQ,OAAO,QAAQ,UAAU;IAClD,MAAM,IAAI,KAAK,GAAG;IAClB,OAAO,MAAM,EAAE,SAAS,IAAI,KAAA,IAAY;GAC1C;GACA,IAAI,OAAO,QAAQ,UAAU;IAC3B,IAAI,MAAM,aAAa,YAAY,MAAM,aAAa;KACpD,MAAM,SAAS,MAAM,MAAM,KAAK,MAAM,WAAW;KACjD,IAAI,CAAC,MAAM,OAAO,SAAS,GAAG,OAAO;IACvC;IACA,MAAM,WAAW,KAAK,GAAG;IACzB,OAAO,MAAM,SAAS,SAAS,IAAI,KAAA,IAAY;GACjD;EAEF;EAEA,YACQ,MAAM,aACX,eAAe;GACd,IAAI,aAAa,GAAG;GACpB,YAAY,QAAQ,gBAAgB,UAAU;EAChD,GACA,EAAE,WAAW,KAAK,CACpB;EAEA,MAAM,iBAAiB,eAAe;GACpC,OAAO,YAAY,OAAO,OAAO,UAAU,KAAK,KAAK;EACvD,CAAC;EAED,SAAS,iBAAiB,GAAU;GAClC,IAAI,MAAM,aAAa,QACrB,OAAO,EAAE;GAEX,IAAI,MAAM,aAAa,aACrB,OAAO,EAAE;GAEX,OAAO,EAAE,OAAO,MAAM,eAAe,UAAU,KAAK;EACtD;EAEA,MAAM,qBAAqB,YAAY,SAAgB;GACrD,YAAY,QAAQ;GACpB,KAAK,qBAAqB,iBAAiB,IAAI,CAAC;GAChD,KAAK,UAAU,KAAK,GAAG;EACzB,CAAC;EAED,eAAe,iBAAiB,MAAa;GAC3C,MAAM,mBAAmB,IAAI;GAC7B,YAAY,OAAO,MAAM;EAC3B;EAEA,SAAS,cAAc;GACrB,YAAY,QAAQ,KAAA;GACpB,KAAK,qBAAqB,KAAA,CAAS;GACnC,KAAK,UAAU,KAAA,CAAS;EAC1B;;GAnJW,OAAA,CAAA,MAAA,QAAA,KADT,UAAA,GAAA,YA6Ba,MAAA,WAAA,GA7Bb,WA6Ba,EAAA,KAAA,EAAA,GA3BHA,KAAAA,QAAM;IACb,OAAO,UAAA;IACR,SAAQ;IACR,OAAM;IACF,SAAA;IAAJ,KAAI;IACH,oBAAc,OAAA,OAAA,OAAA,WAAf,CAAA;IACC,UAAU,MAAA,QAAA;;IAEA,SAAO,cAaN,CAZV,YAYU,MAAA,aAAA,GAAA;KAXP,MAAM,MAAA,IAAA;KACP,mBAAA;KACC,WAAW,QAAA;KACX,aAAa,QAAA;KACb,eAAa,eAAA;KACb,UAAU,MAAA,QAAA;KACV,SAAO;;KAEG,QAAM,cACqC,CAApD,YAAoD,MAAA,WAAA,GAAA,EAA3C,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,CAAA,EAAA,GAAA;MAAU,SAAA,cAAY,CAAZ,YAAY,MAAA,QAAA,CAAA,CAAA,CAAA;;;;;;;;;;;IAKtC,SAAO,cAC6E,CAA7F,YAA6F,MAAA,WAAA,GAAA;KAAhF,MAAA,MAAA,IAAA;KAAM,MAAA,QAAA;KAAM,iBAAA,QAAA;KAAe,MAAM,YAAA;KAAc,iBAAa;;;;;;;;GAI7E,GAAA,IAAA,CAAA,SAAA,UAAA,CAAA,MAAA,UAAA,GAAA,mBAEW,UAAA,EAAA,KAAA,EAAA,GAAA,CADN,gBAAA,gBAAA,eAAA,SAAkB,MAAA,kBAAA,CAAkB,GAAA,CAAA,CAAA,GAAA,EAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -140,7 +140,7 @@ import { NavEmits, NavExposed, NavItem, NavProps, _NavExposed } from "./types/na
|
|
|
140
140
|
import { DualNavEmits, DualNavExposed, DualNavProps, DualNavRailVariant, DualNavRootItem, _DualNavExposed } from "./types/dual-nav.js";
|
|
141
141
|
import { GroupNavEmits, GroupNavGroup, GroupNavProps } from "./types/group-nav.js";
|
|
142
142
|
import { PasswordInputEmits, PasswordInputExposed, PasswordInputProps, _PasswordInputExposed } from "./types/password-input.js";
|
|
143
|
-
import { DatePickerEmits, DatePickerExposed, DatePickerProps, _DatePickerExposed } from "./types/date-picker.js";
|
|
143
|
+
import { DatePickerDataType, DatePickerEmits, DatePickerExposed, DatePickerProps, _DatePickerExposed } from "./types/date-picker.js";
|
|
144
144
|
import { DropdownEmits, DropdownExposed, DropdownProps, _DropdownExposed } from "./types/dropdown.js";
|
|
145
145
|
import { ContextmenuEmits, ContextmenuExposed, ContextmenuItem, ContextmenuProps, _ContextmenuExposed } from "./types/contextmenu.js";
|
|
146
146
|
import { SelectEmits, SelectExposed, SelectProps, _SelectExposed } from "./types/select.js";
|
|
@@ -183,4 +183,4 @@ import { defineBatchEditColumns } from "./components/batch-edit/helper.js";
|
|
|
183
183
|
import { defineTableColumns } from "./components/table/use-columns.js";
|
|
184
184
|
import "./components/index.js";
|
|
185
185
|
export * from "@veltra/utils";
|
|
186
|
-
export { type ActionEmits, type ActionExposed, type ActionGroupExposed, type ActionGroupProps, type ActionProps, type AnimationEmits, type AnimationExposed, type AnimationProps, type AutoCompleteEmits, type AutoCompleteExposed, type AutoCompleteProps, type BadgeEmits, type BadgeExposed, type BadgeProps, type BarType, type BatchEditColumn, type BatchEditEmits, type BatchEditExposed, type BatchEditFeature, type BatchEditFormStatus, type BatchEditProps, type BatchEditSlots, type BatchEditStates, type BreadcrumbEmits, type BreadcrumbExposed, type BreadcrumbItem, type BreadcrumbProps, type BreadcrumbSlotScope, type BreakCols, type Breakpoint, type ButtonEmits, type ButtonExposed, type ButtonProps, type ButtonType, type CalendarDay, type CalendarEmits, type CalendarExposed, type CalendarMonth, type CalendarProps, type CalendarYear, type CardActionProps, type CardContentProps, type CardCoverProps, type CardEmits, type CardExposed, type CardProps, type CascadeEmits, type CascadeExposed, type CascadeNode, type CascadeProps, type CheckTagEmits, type CheckTagExposed, type CheckTagProps, type CheckboxButtonEmits, type CheckboxButtonProps, type CheckboxEmits, type CheckboxExposed, type CheckboxGroupEmits, type CheckboxGroupExposed, type CheckboxGroupProps, type CheckboxProps, type CodeEditorEmits, type CodeEditorExposed, type CodeEditorLang, type CodeEditorProps, type CollapseEmits, type CollapseItemEmits, type CollapseItemProps, type CollapseModelValue, type CollapseProps, type CollapseValue, type ConditionConnector, type ConditionEditorEmits, type ConditionEditorExposed, type ConditionEditorProps, type EvaluateOptions as ConditionEvaluateOptions, type ConditionExpression, type ConditionField, type ConditionGroup, type ConditionLeaf, type ConditionNode, type ConditionValue, type ContextmenuEmits, type ContextmenuExposed, type ContextmenuItem, ContextmenuPanelDIKey, type ContextmenuProps, ContextmenuRootDIKey, type CssTransitionEmits, type CssTransitionExposed, type CssTransitionProps, type DatePanelEmits, type DatePanelProps, type DatePickerEmits, type DatePickerExposed, type DatePickerProps, type DateRangePickerEmits, type DateRangePickerExposed, type DateRangePickerProps, type DialogEmits, type DialogExposed, type DialogProps, type DialogTransition, type DrawerDirection, type DrawerEmits, type DrawerExposed, type DrawerMode, type DrawerProps, type DropdownEmits, type DropdownExposed, type DropdownProps, type DualNavEmits, type DualNavExposed, type DualNavProps, type DualNavRailVariant, type DualNavRootItem, type EmptyEmits, type EmptyExposed, type EmptyProps, type ExpressionEditorEmits, type ExpressionEditorExposed, type ExpressionEditorProps, type ExpressionSelectableLevels, type FileViewerEmits, type FileViewerExposed, type FileViewerItem, type FileViewerKind, type FileViewerProps, type FloatButtonEmits, type FloatButtonExposed, type FloatButtonItem, type FloatButtonProps, type FormEmits, type FormExposed, type FormItemEmits, type FormItemExposed, type FormItemProps, type FormProps, type GanttChartEmits, type GanttChartExposed, type GanttChartProps, type GridEmits, type GridExposed, type GridInputEmits, type GridInputExposed, type GridInputProps, type GridItemProps, type GridProps, type GroupInputEmits, type GroupInputExposed, type GroupInputProps, type GroupNavEmits, type GroupNavGroup, type GroupNavProps, type IconEmits, type IconExposed, type IconProps, type InputEmits, type InputExposed, type InputProps, type LayoutEmits, type LayoutExposed, type LayoutProps, type ListEmits, type ListExposed, type ListProps, type LoadingEmits, type LoadingExposed, type LoadingProps, type LoadingType, type Message, type MessageConfirm, type MessageConfirmAction, type MessageConfirmEmits, type MessageConfirmExposed, type MessageConfirmInstance, type MessageConfirmOptions, type MessageConfirmProps, type MessageEmits, type MessageExposed, type MessageInstance, type MessageOptions, type MessageProps, type MessageType, type MultiAutoCompleteEmits, type MultiAutoCompleteExposed, type MultiAutoCompleteProps, type MultiSelectEmits, type MultiSelectExposed, type MultiSelectProps, type MultiTreeSelectEmits, type MultiTreeSelectExposed, type MultiTreeSelectProps, type NavEmits, type NavExposed, type NavItem, type NavProps, type NodeRenderExposed, type NodeRenderProps, type Notification, type NotificationEmits, type NotificationExposed, type NotificationInstance, type NotificationOptions, type NotificationPosition, type NotificationProps, type NumberEmits, type NumberExposed, type NumberInputEmits, type NumberInputExposed, type NumberInputProps, type NumberProps, type NumberRangeInputEmits, type NumberRangeInputExposed, type NumberRangeInputProps, type NumberRangeTuple, type PaginatorEmits, type PaginatorExposed, type PaginatorProps, type PaletteColorType, type PaletteEmits, type PaletteExposed, type PaletteHSV, type PaletteProps, type PaletteRGB, type PanelItem, type PanelType, type PasswordInputEmits, type PasswordInputExposed, type PasswordInputProps, type PopConfirmEmits, type PopConfirmExposed, type PopConfirmProps, type PopEmits, type PopExposed, type PopProps, type ProgressEmits, type ProgressExposed, type ProgressNodesEmits, type ProgressNodesExposed, type ProgressNodesProps, type ProgressProps, type QuickBatchEditEmits, type QuickBatchEditExposed, type QuickBatchEditProps, type RadioEmits, type RadioExposed, type RadioGroupEmits, type RadioGroupExposed, type RadioGroupProps, type RadioProps, type RichTextEditorEmits, type RichTextEditorExposed, type RichTextEditorProps, type RichTextFormat, type ScrollEmits, type ScrollExposed, type ScrollPosition, type ScrollProps, type SegmentEmits, type SegmentExposed, type SegmentItem, type SegmentProps, type SelectEmits, type SelectExposed, type SelectProps, type SliderEmits, type SliderExposed, type SliderProps, type StepsEmits, type StepsExposed, type StepsProps, type StepsSlotScope, type SwitchEmits, type SwitchExposed, type SwitchProps, type TabItem, type TableColumn, type TableColumnAlign, type TableColumnNode, type TableColumnRenderContext, type TableColumnSlotsScope, type TableEditorEmits, type TableEditorExposed, type TableEditorProps, type TableEmits, type TableExposed, type TableProps, type TableRow, type TableRowSlotsScope, type TableSummaryContext, type TabsEmits, type TabsExposed, type TabsHorizontalEmits, type TabsHorizontalExposed, type TabsHorizontalProps, type TabsProps, type TabsVerticalEmits, type TabsVerticalExposed, type TabsVerticalProps, type TagEmits, type TagExposed, type TagProps, type TextEditorEmits, type TextEditorExposed, type TextEditorProps, type TextEmits, type TextExposed, type TextProps, type TextareaEmits, type TextareaExposed, type TextareaProps, type ThemeExposed, type ThemeProps, type TipAlign, type TipDirection, type TipEmits, type TipExposed, type TipProps, type ToolbarItem, type TreeEmit, type TreeExposed, type TreeNode, type TreeNodeProps, type TreeProps, type TreeSelectEmits, type TreeSelectExposed, type TreeSelectProps, _sfc_main as UAction, action_group_default as UActionGroup, _sfc_main$1 as UAutoComplete, _sfc_main$2 as UBadge, _sfc_main$3 as UBatchEdit, _sfc_main$4 as UBreadcrumb, _sfc_main$5 as UButton, _sfc_main$6 as UButtonGroup, _sfc_main$7 as UCalendar, _sfc_main$8 as UCard, _sfc_main$9 as UCardAction, _sfc_main$10 as UCardContent, _sfc_main$11 as UCardCover, _sfc_main$12 as UCardHeader, _sfc_main$13 as UCascade, _sfc_main$14 as UCheckTag, _sfc_main$15 as UCheckbox, _sfc_main$16 as UCheckboxButton, _sfc_main$17 as UCheckboxGroup, _sfc_main$18 as UCodeEditor, _sfc_main$19 as UCollapse, _sfc_main$20 as UCollapseItem, _sfc_main$21 as UConditionEditor, _sfc_main$22 as UContextmenu, _sfc_main$23 as UDatePanel, _sfc_main$24 as UDatePicker, _sfc_main$25 as UDateRangePicker, _sfc_main$26 as UDialog, _sfc_main$27 as UDrawer, _sfc_main$28 as UDropdown, _sfc_main$29 as UDualNav, _sfc_main$30 as UEmpty, _sfc_main$31 as UExpressionEditor, _sfc_main$32 as UFilePicker, _sfc_main$33 as UFileViewer, _sfc_main$34 as UFloatButton, form_default as UForm, form_item_default as UFormItem, _sfc_main$35 as UGanttChart, _sfc_main$36 as UGrid, _sfc_main$37 as UGridInput, _sfc_main$38 as UGridItem, _sfc_main$39 as UGroupInput, _sfc_main$40 as UGroupNav, _sfc_main$41 as UIcon, input_default as UInput, _sfc_main$42 as UKbd, _sfc_main$43 as ULayout, _sfc_main$44 as UList, _sfc_main$45 as UListItem, _sfc_main$46 as ULoading, _sfc_main$47 as UMessage, _sfc_main$48 as UMessageConfirm, _sfc_main$49 as UMultiSelect, _sfc_main$50 as UMultiTreeSelect, _sfc_main$51 as UNav, _sfc_main$52 as UNavItem, _sfc_main$53 as UNavSub, NodeRender as UNodeRender, _sfc_main$54 as UNotification, _sfc_main$55 as UNumber, _sfc_main$56 as UNumberInput, _sfc_main$57 as UNumberRangeInput, _sfc_main$58 as UPaginator, _sfc_main$59 as UPalette, _sfc_main$60 as UPasswordInput, _sfc_main$61 as UPopConfirm, _sfc_main$62 as UProgress, _sfc_main$63 as UProgressNodes, _sfc_main$64 as URadio, _sfc_main$65 as URadioGroup, _sfc_main$66 as URichTextEditor, _sfc_main$67 as UScroll, _sfc_main$68 as USegment, _sfc_main$69 as USelect, _sfc_main$70 as USlider, _sfc_main$71 as USteps, _sfc_main$72 as USwitch, _sfc_main$73 as UTable, _sfc_main$74 as UTableEditor, _sfc_main$75 as UTabs, _sfc_main$76 as UTabsHorizontal, _sfc_main$77 as UTabsVertical, _sfc_main$78 as UTag, _sfc_main$79 as UText, _sfc_main$80 as UTextarea, _sfc_main$81 as UTheme, _sfc_main$82 as UTip, _sfc_main$83 as UTree, _sfc_main$84 as UTreeSelect, _sfc_main$85 as UWatermark, type UploaderEmits, type UploaderExposed, type UploaderProps, type VariableItem, type WatermarkEmits, type WatermarkExposed, type WatermarkProps, type _ActionExposed, type _ActionGroupExposed, type _AnimationExposed, type _AutoCompleteExposed, type _BadgeExposed, type _BatchEditExposed, type _BreadcrumbExposed, type _ButtonExposed, type _CalendarExposed, type _CardExposed, type _CascadeExposed, type _CheckTagExposed, type _CodeEditorExposed, type _ConditionEditorExposed, type _ContextmenuExposed, type _CssTransitionExposed, type _DatePickerExposed, type _DateRangePickerExposed, type _DialogExposed, type _DrawerExposed, type _DropdownExposed, type _DualNavExposed, type _EmptyExposed, type _ExpressionEditorExposed, type _FileViewerExposed, type _FloatButtonExposed, type _FormExposed, type _GanttChartExposed, type _GridExposed, type _GridInputExposed, type _GroupInputExposed, type _InputExposed, type _LayoutExposed, type _ListExposed, type _LoadingExposed, type _MessageConfirmExposed, type _MessageExposed, type _MultiAutoCompleteExposed, type _MultiSelectExposed, type _MultiTreeSelectExposed, type _NavExposed, type _NotificationExposed, type _PaginatorExposed, type _PaletteExposed, type _PasswordInputExposed, type _PopConfirmExposed, type _PopExposed, type _ProgressExposed, type _ProgressNodesExposed, type _QuickBatchEditExposed, type _RadioExposed, type _RadioGroupExposed, type _RichTextEditorExposed, type _ScrollExposed, type _SegmentExposed, type _SelectExposed, type _SliderExposed, type _StepsExposed, type _SwitchExposed, type _TableEditorExposed, type _TableExposed, type _TabsExposed, type _TabsHorizontalExposed, type _TabsVerticalExposed, type _TextEditorExposed, type _TextExposed, type _TextareaExposed, type _ThemeExposed, type _TipExposed, type _TreeExposed, type _TreeSelectExposed, type _UploaderExposed, type _WatermarkExposed, contextmenu, createEmptyGroup, createEmptyLeaf, defineBatchEditColumns, defineTableColumns, evaluate as evaluateConditionExpression, message, messageConfirm, notification, vLoading };
|
|
186
|
+
export { type ActionEmits, type ActionExposed, type ActionGroupExposed, type ActionGroupProps, type ActionProps, type AnimationEmits, type AnimationExposed, type AnimationProps, type AutoCompleteEmits, type AutoCompleteExposed, type AutoCompleteProps, type BadgeEmits, type BadgeExposed, type BadgeProps, type BarType, type BatchEditColumn, type BatchEditEmits, type BatchEditExposed, type BatchEditFeature, type BatchEditFormStatus, type BatchEditProps, type BatchEditSlots, type BatchEditStates, type BreadcrumbEmits, type BreadcrumbExposed, type BreadcrumbItem, type BreadcrumbProps, type BreadcrumbSlotScope, type BreakCols, type Breakpoint, type ButtonEmits, type ButtonExposed, type ButtonProps, type ButtonType, type CalendarDay, type CalendarEmits, type CalendarExposed, type CalendarMonth, type CalendarProps, type CalendarYear, type CardActionProps, type CardContentProps, type CardCoverProps, type CardEmits, type CardExposed, type CardProps, type CascadeEmits, type CascadeExposed, type CascadeNode, type CascadeProps, type CheckTagEmits, type CheckTagExposed, type CheckTagProps, type CheckboxButtonEmits, type CheckboxButtonProps, type CheckboxEmits, type CheckboxExposed, type CheckboxGroupEmits, type CheckboxGroupExposed, type CheckboxGroupProps, type CheckboxProps, type CodeEditorEmits, type CodeEditorExposed, type CodeEditorLang, type CodeEditorProps, type CollapseEmits, type CollapseItemEmits, type CollapseItemProps, type CollapseModelValue, type CollapseProps, type CollapseValue, type ConditionConnector, type ConditionEditorEmits, type ConditionEditorExposed, type ConditionEditorProps, type EvaluateOptions as ConditionEvaluateOptions, type ConditionExpression, type ConditionField, type ConditionGroup, type ConditionLeaf, type ConditionNode, type ConditionValue, type ContextmenuEmits, type ContextmenuExposed, type ContextmenuItem, ContextmenuPanelDIKey, type ContextmenuProps, ContextmenuRootDIKey, type CssTransitionEmits, type CssTransitionExposed, type CssTransitionProps, type DatePanelEmits, type DatePanelProps, type DatePickerDataType, type DatePickerEmits, type DatePickerExposed, type DatePickerProps, type DateRangePickerEmits, type DateRangePickerExposed, type DateRangePickerProps, type DialogEmits, type DialogExposed, type DialogProps, type DialogTransition, type DrawerDirection, type DrawerEmits, type DrawerExposed, type DrawerMode, type DrawerProps, type DropdownEmits, type DropdownExposed, type DropdownProps, type DualNavEmits, type DualNavExposed, type DualNavProps, type DualNavRailVariant, type DualNavRootItem, type EmptyEmits, type EmptyExposed, type EmptyProps, type ExpressionEditorEmits, type ExpressionEditorExposed, type ExpressionEditorProps, type ExpressionSelectableLevels, type FileViewerEmits, type FileViewerExposed, type FileViewerItem, type FileViewerKind, type FileViewerProps, type FloatButtonEmits, type FloatButtonExposed, type FloatButtonItem, type FloatButtonProps, type FormEmits, type FormExposed, type FormItemEmits, type FormItemExposed, type FormItemProps, type FormProps, type GanttChartEmits, type GanttChartExposed, type GanttChartProps, type GridEmits, type GridExposed, type GridInputEmits, type GridInputExposed, type GridInputProps, type GridItemProps, type GridProps, type GroupInputEmits, type GroupInputExposed, type GroupInputProps, type GroupNavEmits, type GroupNavGroup, type GroupNavProps, type IconEmits, type IconExposed, type IconProps, type InputEmits, type InputExposed, type InputProps, type LayoutEmits, type LayoutExposed, type LayoutProps, type ListEmits, type ListExposed, type ListProps, type LoadingEmits, type LoadingExposed, type LoadingProps, type LoadingType, type Message, type MessageConfirm, type MessageConfirmAction, type MessageConfirmEmits, type MessageConfirmExposed, type MessageConfirmInstance, type MessageConfirmOptions, type MessageConfirmProps, type MessageEmits, type MessageExposed, type MessageInstance, type MessageOptions, type MessageProps, type MessageType, type MultiAutoCompleteEmits, type MultiAutoCompleteExposed, type MultiAutoCompleteProps, type MultiSelectEmits, type MultiSelectExposed, type MultiSelectProps, type MultiTreeSelectEmits, type MultiTreeSelectExposed, type MultiTreeSelectProps, type NavEmits, type NavExposed, type NavItem, type NavProps, type NodeRenderExposed, type NodeRenderProps, type Notification, type NotificationEmits, type NotificationExposed, type NotificationInstance, type NotificationOptions, type NotificationPosition, type NotificationProps, type NumberEmits, type NumberExposed, type NumberInputEmits, type NumberInputExposed, type NumberInputProps, type NumberProps, type NumberRangeInputEmits, type NumberRangeInputExposed, type NumberRangeInputProps, type NumberRangeTuple, type PaginatorEmits, type PaginatorExposed, type PaginatorProps, type PaletteColorType, type PaletteEmits, type PaletteExposed, type PaletteHSV, type PaletteProps, type PaletteRGB, type PanelItem, type PanelType, type PasswordInputEmits, type PasswordInputExposed, type PasswordInputProps, type PopConfirmEmits, type PopConfirmExposed, type PopConfirmProps, type PopEmits, type PopExposed, type PopProps, type ProgressEmits, type ProgressExposed, type ProgressNodesEmits, type ProgressNodesExposed, type ProgressNodesProps, type ProgressProps, type QuickBatchEditEmits, type QuickBatchEditExposed, type QuickBatchEditProps, type RadioEmits, type RadioExposed, type RadioGroupEmits, type RadioGroupExposed, type RadioGroupProps, type RadioProps, type RichTextEditorEmits, type RichTextEditorExposed, type RichTextEditorProps, type RichTextFormat, type ScrollEmits, type ScrollExposed, type ScrollPosition, type ScrollProps, type SegmentEmits, type SegmentExposed, type SegmentItem, type SegmentProps, type SelectEmits, type SelectExposed, type SelectProps, type SliderEmits, type SliderExposed, type SliderProps, type StepsEmits, type StepsExposed, type StepsProps, type StepsSlotScope, type SwitchEmits, type SwitchExposed, type SwitchProps, type TabItem, type TableColumn, type TableColumnAlign, type TableColumnNode, type TableColumnRenderContext, type TableColumnSlotsScope, type TableEditorEmits, type TableEditorExposed, type TableEditorProps, type TableEmits, type TableExposed, type TableProps, type TableRow, type TableRowSlotsScope, type TableSummaryContext, type TabsEmits, type TabsExposed, type TabsHorizontalEmits, type TabsHorizontalExposed, type TabsHorizontalProps, type TabsProps, type TabsVerticalEmits, type TabsVerticalExposed, type TabsVerticalProps, type TagEmits, type TagExposed, type TagProps, type TextEditorEmits, type TextEditorExposed, type TextEditorProps, type TextEmits, type TextExposed, type TextProps, type TextareaEmits, type TextareaExposed, type TextareaProps, type ThemeExposed, type ThemeProps, type TipAlign, type TipDirection, type TipEmits, type TipExposed, type TipProps, type ToolbarItem, type TreeEmit, type TreeExposed, type TreeNode, type TreeNodeProps, type TreeProps, type TreeSelectEmits, type TreeSelectExposed, type TreeSelectProps, _sfc_main as UAction, action_group_default as UActionGroup, _sfc_main$1 as UAutoComplete, _sfc_main$2 as UBadge, _sfc_main$3 as UBatchEdit, _sfc_main$4 as UBreadcrumb, _sfc_main$5 as UButton, _sfc_main$6 as UButtonGroup, _sfc_main$7 as UCalendar, _sfc_main$8 as UCard, _sfc_main$9 as UCardAction, _sfc_main$10 as UCardContent, _sfc_main$11 as UCardCover, _sfc_main$12 as UCardHeader, _sfc_main$13 as UCascade, _sfc_main$14 as UCheckTag, _sfc_main$15 as UCheckbox, _sfc_main$16 as UCheckboxButton, _sfc_main$17 as UCheckboxGroup, _sfc_main$18 as UCodeEditor, _sfc_main$19 as UCollapse, _sfc_main$20 as UCollapseItem, _sfc_main$21 as UConditionEditor, _sfc_main$22 as UContextmenu, _sfc_main$23 as UDatePanel, _sfc_main$24 as UDatePicker, _sfc_main$25 as UDateRangePicker, _sfc_main$26 as UDialog, _sfc_main$27 as UDrawer, _sfc_main$28 as UDropdown, _sfc_main$29 as UDualNav, _sfc_main$30 as UEmpty, _sfc_main$31 as UExpressionEditor, _sfc_main$32 as UFilePicker, _sfc_main$33 as UFileViewer, _sfc_main$34 as UFloatButton, form_default as UForm, form_item_default as UFormItem, _sfc_main$35 as UGanttChart, _sfc_main$36 as UGrid, _sfc_main$37 as UGridInput, _sfc_main$38 as UGridItem, _sfc_main$39 as UGroupInput, _sfc_main$40 as UGroupNav, _sfc_main$41 as UIcon, input_default as UInput, _sfc_main$42 as UKbd, _sfc_main$43 as ULayout, _sfc_main$44 as UList, _sfc_main$45 as UListItem, _sfc_main$46 as ULoading, _sfc_main$47 as UMessage, _sfc_main$48 as UMessageConfirm, _sfc_main$49 as UMultiSelect, _sfc_main$50 as UMultiTreeSelect, _sfc_main$51 as UNav, _sfc_main$52 as UNavItem, _sfc_main$53 as UNavSub, NodeRender as UNodeRender, _sfc_main$54 as UNotification, _sfc_main$55 as UNumber, _sfc_main$56 as UNumberInput, _sfc_main$57 as UNumberRangeInput, _sfc_main$58 as UPaginator, _sfc_main$59 as UPalette, _sfc_main$60 as UPasswordInput, _sfc_main$61 as UPopConfirm, _sfc_main$62 as UProgress, _sfc_main$63 as UProgressNodes, _sfc_main$64 as URadio, _sfc_main$65 as URadioGroup, _sfc_main$66 as URichTextEditor, _sfc_main$67 as UScroll, _sfc_main$68 as USegment, _sfc_main$69 as USelect, _sfc_main$70 as USlider, _sfc_main$71 as USteps, _sfc_main$72 as USwitch, _sfc_main$73 as UTable, _sfc_main$74 as UTableEditor, _sfc_main$75 as UTabs, _sfc_main$76 as UTabsHorizontal, _sfc_main$77 as UTabsVertical, _sfc_main$78 as UTag, _sfc_main$79 as UText, _sfc_main$80 as UTextarea, _sfc_main$81 as UTheme, _sfc_main$82 as UTip, _sfc_main$83 as UTree, _sfc_main$84 as UTreeSelect, _sfc_main$85 as UWatermark, type UploaderEmits, type UploaderExposed, type UploaderProps, type VariableItem, type WatermarkEmits, type WatermarkExposed, type WatermarkProps, type _ActionExposed, type _ActionGroupExposed, type _AnimationExposed, type _AutoCompleteExposed, type _BadgeExposed, type _BatchEditExposed, type _BreadcrumbExposed, type _ButtonExposed, type _CalendarExposed, type _CardExposed, type _CascadeExposed, type _CheckTagExposed, type _CodeEditorExposed, type _ConditionEditorExposed, type _ContextmenuExposed, type _CssTransitionExposed, type _DatePickerExposed, type _DateRangePickerExposed, type _DialogExposed, type _DrawerExposed, type _DropdownExposed, type _DualNavExposed, type _EmptyExposed, type _ExpressionEditorExposed, type _FileViewerExposed, type _FloatButtonExposed, type _FormExposed, type _GanttChartExposed, type _GridExposed, type _GridInputExposed, type _GroupInputExposed, type _InputExposed, type _LayoutExposed, type _ListExposed, type _LoadingExposed, type _MessageConfirmExposed, type _MessageExposed, type _MultiAutoCompleteExposed, type _MultiSelectExposed, type _MultiTreeSelectExposed, type _NavExposed, type _NotificationExposed, type _PaginatorExposed, type _PaletteExposed, type _PasswordInputExposed, type _PopConfirmExposed, type _PopExposed, type _ProgressExposed, type _ProgressNodesExposed, type _QuickBatchEditExposed, type _RadioExposed, type _RadioGroupExposed, type _RichTextEditorExposed, type _ScrollExposed, type _SegmentExposed, type _SelectExposed, type _SliderExposed, type _StepsExposed, type _SwitchExposed, type _TableEditorExposed, type _TableExposed, type _TabsExposed, type _TabsHorizontalExposed, type _TabsVerticalExposed, type _TextEditorExposed, type _TextExposed, type _TextareaExposed, type _ThemeExposed, type _TipExposed, type _TreeExposed, type _TreeSelectExposed, type _UploaderExposed, type _WatermarkExposed, contextmenu, createEmptyGroup, createEmptyLeaf, defineBatchEditColumns, defineTableColumns, evaluate as evaluateConditionExpression, message, messageConfirm, notification, vLoading };
|
|
@@ -6,7 +6,7 @@ interface DatePanelProps {
|
|
|
6
6
|
date?: Dater;
|
|
7
7
|
rangeDate?: [Dater, Dater];
|
|
8
8
|
range?: boolean;
|
|
9
|
-
disabledDate?: (date: Dater) => boolean;
|
|
9
|
+
disabledDate?: (date: Dater, raw: Date) => boolean;
|
|
10
10
|
type?: 'date' | 'month' | 'year';
|
|
11
11
|
size?: FormComponentProps['size'];
|
|
12
12
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DeconstructValue, FormComponentProps } from "@veltra/utils";
|
|
2
2
|
import { Dater } from "@cat-kit/core";
|
|
3
3
|
//#region src/types/date-picker.d.ts
|
|
4
|
+
/** 绑定值类型 */
|
|
5
|
+
type DatePickerDataType = 'date' | 'timestamp' | 'string';
|
|
4
6
|
/** date-picker组件属性 */
|
|
5
7
|
interface DatePickerProps extends FormComponentProps {
|
|
6
8
|
modelValue?: string | number | Date;
|
|
@@ -12,19 +14,25 @@ interface DatePickerProps extends FormComponentProps {
|
|
|
12
14
|
format?: string;
|
|
13
15
|
/** 日期值格式化, 当没有指定时默认使用format属性,仅当值和显示的内容不一致时才需要使用到该属性 */
|
|
14
16
|
valueFormat?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 绑定值的类型,默认为字符串。
|
|
19
|
+
* 当 dataType 没有指定为字符串时,valueFormat 属性不生效
|
|
20
|
+
*/
|
|
21
|
+
dataType?: DatePickerDataType;
|
|
15
22
|
/** 最小可选日期 */
|
|
16
|
-
disabledDate?: (date: Dater) => boolean;
|
|
23
|
+
disabledDate?: (date: Dater, raw: Date) => boolean;
|
|
17
24
|
/** 是否显示清除按钮 */
|
|
18
25
|
clearable?: boolean;
|
|
19
26
|
}
|
|
20
27
|
/** date-picker组件定义的事件 */
|
|
21
28
|
interface DatePickerEmits {
|
|
22
29
|
(e: 'update:modelValue', value?: string | number | Date): void;
|
|
30
|
+
(e: 'change', date?: Date): void;
|
|
23
31
|
}
|
|
24
32
|
/** date-picker组件暴露的属性和方法(组件内部使用) */
|
|
25
33
|
interface _DatePickerExposed {}
|
|
26
34
|
/** date-picker组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
|
|
27
35
|
type DatePickerExposed = DeconstructValue<_DatePickerExposed>;
|
|
28
36
|
//#endregion
|
|
29
|
-
export { DatePickerEmits, DatePickerExposed, DatePickerProps, _DatePickerExposed };
|
|
37
|
+
export { DatePickerDataType, DatePickerEmits, DatePickerExposed, DatePickerProps, _DatePickerExposed };
|
|
30
38
|
//# sourceMappingURL=date-picker.d.ts.map
|
|
@@ -13,7 +13,7 @@ interface DateRangePickerProps extends FormComponentProps {
|
|
|
13
13
|
/** 日期值格式化, 当没有指定时默认使用format属性,仅当值和显示的内容不一致时才需要使用到该属性 */
|
|
14
14
|
valueFormat?: string;
|
|
15
15
|
/** 最小可选日期 */
|
|
16
|
-
disabledDate?: (date: Dater) => boolean;
|
|
16
|
+
disabledDate?: (date: Dater, raw: Date) => boolean;
|
|
17
17
|
/** 是否显示清除按钮 */
|
|
18
18
|
clearable?: boolean;
|
|
19
19
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ import { NavEmits, NavExposed, NavItem, NavProps, _NavExposed } from "./nav.js";
|
|
|
50
50
|
import { DualNavEmits, DualNavExposed, DualNavProps, DualNavRailVariant, DualNavRootItem, _DualNavExposed } from "./dual-nav.js";
|
|
51
51
|
import { GroupNavEmits, GroupNavGroup, GroupNavProps } from "./group-nav.js";
|
|
52
52
|
import { PasswordInputEmits, PasswordInputExposed, PasswordInputProps, _PasswordInputExposed } from "./password-input.js";
|
|
53
|
-
import { DatePickerEmits, DatePickerExposed, DatePickerProps, _DatePickerExposed } from "./date-picker.js";
|
|
53
|
+
import { DatePickerDataType, DatePickerEmits, DatePickerExposed, DatePickerProps, _DatePickerExposed } from "./date-picker.js";
|
|
54
54
|
import { DropdownEmits, DropdownExposed, DropdownProps, _DropdownExposed } from "./dropdown.js";
|
|
55
55
|
import { ContextmenuEmits, ContextmenuExposed, ContextmenuItem, ContextmenuProps, _ContextmenuExposed } from "./contextmenu.js";
|
|
56
56
|
import { SelectEmits, SelectExposed, SelectProps, _SelectExposed } from "./select.js";
|
|
@@ -81,4 +81,4 @@ import { FileViewerEmits, FileViewerExposed, FileViewerItem, FileViewerKind, Fil
|
|
|
81
81
|
import { CollapseEmits, CollapseItemEmits, CollapseItemProps, CollapseModelValue, CollapseProps, CollapseValue } from "./collapse.js";
|
|
82
82
|
import { SegmentEmits, SegmentExposed, SegmentItem, SegmentProps, _SegmentExposed } from "./segment.js";
|
|
83
83
|
export type * from "@veltra/utils";
|
|
84
|
-
export { ActionEmits, ActionExposed, ActionGroupExposed, ActionGroupProps, ActionProps, AnimationEmits, AnimationExposed, AnimationProps, AutoCompleteEmits, AutoCompleteExposed, AutoCompleteProps, BadgeEmits, BadgeExposed, BadgeProps, BarType, BatchEditColumn, BatchEditEmits, BatchEditExposed, BatchEditFeature, BatchEditFormStatus, BatchEditProps, BatchEditSlots, BatchEditStates, BreadcrumbEmits, BreadcrumbExposed, BreadcrumbItem, BreadcrumbProps, BreadcrumbSlotScope, BreakCols, Breakpoint, ButtonEmits, ButtonExposed, ButtonProps, ButtonType, CalendarDay, CalendarEmits, CalendarExposed, CalendarMonth, CalendarProps, CalendarYear, CardActionProps, CardContentProps, CardCoverProps, CardEmits, CardExposed, CardProps, CascadeEmits, CascadeExposed, CascadeNode, CascadeProps, CheckTagEmits, CheckTagExposed, CheckTagProps, CheckboxButtonEmits, CheckboxButtonProps, CheckboxEmits, CheckboxExposed, CheckboxGroupEmits, CheckboxGroupExposed, CheckboxGroupProps, CheckboxProps, CodeEditorEmits, CodeEditorExposed, CodeEditorLang, CodeEditorProps, CollapseEmits, CollapseItemEmits, CollapseItemProps, CollapseModelValue, CollapseProps, CollapseValue, ConditionConnector, ConditionEditorEmits, ConditionEditorExposed, ConditionEditorProps, ConditionExpression, ConditionField, ConditionGroup, ConditionLeaf, ConditionNode, ConditionValue, ContextmenuEmits, ContextmenuExposed, ContextmenuItem, ContextmenuProps, CssTransitionEmits, CssTransitionExposed, CssTransitionProps, DatePanelEmits, DatePanelProps, DatePickerEmits, DatePickerExposed, DatePickerProps, DateRangePickerEmits, DateRangePickerExposed, DateRangePickerProps, DialogEmits, DialogExposed, DialogProps, DialogTransition, DrawerDirection, DrawerEmits, DrawerExposed, DrawerMode, DrawerProps, DropdownEmits, DropdownExposed, DropdownProps, DualNavEmits, DualNavExposed, DualNavProps, DualNavRailVariant, DualNavRootItem, EmptyEmits, EmptyExposed, EmptyProps, ExpressionEditorEmits, ExpressionEditorExposed, ExpressionEditorProps, ExpressionSelectableLevels, FileViewerEmits, FileViewerExposed, FileViewerItem, FileViewerKind, FileViewerProps, FloatButtonEmits, FloatButtonExposed, FloatButtonItem, FloatButtonProps, FormEmits, FormExposed, FormItemEmits, FormItemExposed, FormItemProps, FormProps, GanttChartEmits, GanttChartExposed, GanttChartProps, GridEmits, GridExposed, GridInputEmits, GridInputExposed, GridInputProps, GridItemProps, GridProps, GroupInputEmits, GroupInputExposed, GroupInputProps, GroupNavEmits, GroupNavGroup, GroupNavProps, IconEmits, IconExposed, IconProps, InputEmits, InputExposed, InputProps, LayoutEmits, LayoutExposed, LayoutProps, ListEmits, ListExposed, ListProps, LoadingEmits, LoadingExposed, LoadingProps, LoadingType, Message, MessageConfirm, MessageConfirmAction, MessageConfirmEmits, MessageConfirmExposed, MessageConfirmInstance, MessageConfirmOptions, MessageConfirmProps, MessageEmits, MessageExposed, MessageInstance, MessageOptions, MessageProps, MessageType, MultiAutoCompleteEmits, MultiAutoCompleteExposed, MultiAutoCompleteProps, MultiSelectEmits, MultiSelectExposed, MultiSelectProps, MultiTreeSelectEmits, MultiTreeSelectExposed, MultiTreeSelectProps, NavEmits, NavExposed, NavItem, NavProps, NodeRenderExposed, NodeRenderProps, Notification, NotificationEmits, NotificationExposed, NotificationInstance, NotificationOptions, NotificationPosition, NotificationProps, NumberEmits, NumberExposed, NumberInputEmits, NumberInputExposed, NumberInputProps, NumberProps, NumberRangeInputEmits, NumberRangeInputExposed, NumberRangeInputProps, NumberRangeTuple, PaginatorEmits, PaginatorExposed, PaginatorProps, PaletteColorType, PaletteEmits, PaletteExposed, PaletteHSV, PaletteProps, PaletteRGB, PanelItem, PanelType, PasswordInputEmits, PasswordInputExposed, PasswordInputProps, PopConfirmEmits, PopConfirmExposed, PopConfirmProps, PopEmits, PopExposed, PopProps, ProgressEmits, ProgressExposed, ProgressNodesEmits, ProgressNodesExposed, ProgressNodesProps, ProgressProps, QuickBatchEditEmits, QuickBatchEditExposed, QuickBatchEditProps, RadioEmits, RadioExposed, RadioGroupEmits, RadioGroupExposed, RadioGroupProps, RadioProps, RichTextEditorEmits, RichTextEditorExposed, RichTextEditorProps, RichTextFormat, ScrollEmits, ScrollExposed, ScrollPosition, ScrollProps, SegmentEmits, SegmentExposed, SegmentItem, SegmentProps, SelectEmits, SelectExposed, SelectProps, SliderEmits, SliderExposed, SliderProps, StepsEmits, StepsExposed, StepsProps, StepsSlotScope, SwitchEmits, SwitchExposed, SwitchProps, TabItem, TableColumn, TableColumnAlign, TableColumnNode, TableColumnRenderContext, TableColumnSlotsScope, TableEditorEmits, TableEditorExposed, TableEditorProps, TableEmits, TableExposed, TableProps, TableRow, TableRowSlotsScope, TableSummaryContext, TabsEmits, TabsExposed, TabsHorizontalEmits, TabsHorizontalExposed, TabsHorizontalProps, TabsProps, TabsVerticalEmits, TabsVerticalExposed, TabsVerticalProps, TagEmits, TagExposed, TagProps, TextEditorEmits, TextEditorExposed, TextEditorProps, TextEmits, TextExposed, TextProps, TextareaEmits, TextareaExposed, TextareaProps, ThemeExposed, ThemeProps, TipAlign, TipDirection, TipEmits, TipExposed, TipProps, ToolbarItem, TreeEmit, TreeExposed, TreeNode, TreeNodeProps, TreeProps, TreeSelectEmits, TreeSelectExposed, TreeSelectProps, UploaderEmits, UploaderExposed, UploaderProps, VariableItem, WatermarkEmits, WatermarkExposed, WatermarkProps, _ActionExposed, _ActionGroupExposed, _AnimationExposed, _AutoCompleteExposed, _BadgeExposed, _BatchEditExposed, _BreadcrumbExposed, _ButtonExposed, _CalendarExposed, _CardExposed, _CascadeExposed, _CheckTagExposed, _CodeEditorExposed, _ConditionEditorExposed, _ContextmenuExposed, _CssTransitionExposed, _DatePickerExposed, _DateRangePickerExposed, _DialogExposed, _DrawerExposed, _DropdownExposed, _DualNavExposed, _EmptyExposed, _ExpressionEditorExposed, _FileViewerExposed, _FloatButtonExposed, _FormExposed, _GanttChartExposed, _GridExposed, _GridInputExposed, _GroupInputExposed, _InputExposed, _LayoutExposed, _ListExposed, _LoadingExposed, _MessageConfirmExposed, _MessageExposed, _MultiAutoCompleteExposed, _MultiSelectExposed, _MultiTreeSelectExposed, _NavExposed, _NotificationExposed, _PaginatorExposed, _PaletteExposed, _PasswordInputExposed, _PopConfirmExposed, _PopExposed, _ProgressExposed, _ProgressNodesExposed, _QuickBatchEditExposed, _RadioExposed, _RadioGroupExposed, _RichTextEditorExposed, _ScrollExposed, _SegmentExposed, _SelectExposed, _SliderExposed, _StepsExposed, _SwitchExposed, _TableEditorExposed, _TableExposed, _TabsExposed, _TabsHorizontalExposed, _TabsVerticalExposed, _TextEditorExposed, _TextExposed, _TextareaExposed, _ThemeExposed, _TipExposed, _TreeExposed, _TreeSelectExposed, _UploaderExposed, _WatermarkExposed };
|
|
84
|
+
export { ActionEmits, ActionExposed, ActionGroupExposed, ActionGroupProps, ActionProps, AnimationEmits, AnimationExposed, AnimationProps, AutoCompleteEmits, AutoCompleteExposed, AutoCompleteProps, BadgeEmits, BadgeExposed, BadgeProps, BarType, BatchEditColumn, BatchEditEmits, BatchEditExposed, BatchEditFeature, BatchEditFormStatus, BatchEditProps, BatchEditSlots, BatchEditStates, BreadcrumbEmits, BreadcrumbExposed, BreadcrumbItem, BreadcrumbProps, BreadcrumbSlotScope, BreakCols, Breakpoint, ButtonEmits, ButtonExposed, ButtonProps, ButtonType, CalendarDay, CalendarEmits, CalendarExposed, CalendarMonth, CalendarProps, CalendarYear, CardActionProps, CardContentProps, CardCoverProps, CardEmits, CardExposed, CardProps, CascadeEmits, CascadeExposed, CascadeNode, CascadeProps, CheckTagEmits, CheckTagExposed, CheckTagProps, CheckboxButtonEmits, CheckboxButtonProps, CheckboxEmits, CheckboxExposed, CheckboxGroupEmits, CheckboxGroupExposed, CheckboxGroupProps, CheckboxProps, CodeEditorEmits, CodeEditorExposed, CodeEditorLang, CodeEditorProps, CollapseEmits, CollapseItemEmits, CollapseItemProps, CollapseModelValue, CollapseProps, CollapseValue, ConditionConnector, ConditionEditorEmits, ConditionEditorExposed, ConditionEditorProps, ConditionExpression, ConditionField, ConditionGroup, ConditionLeaf, ConditionNode, ConditionValue, ContextmenuEmits, ContextmenuExposed, ContextmenuItem, ContextmenuProps, CssTransitionEmits, CssTransitionExposed, CssTransitionProps, DatePanelEmits, DatePanelProps, DatePickerDataType, DatePickerEmits, DatePickerExposed, DatePickerProps, DateRangePickerEmits, DateRangePickerExposed, DateRangePickerProps, DialogEmits, DialogExposed, DialogProps, DialogTransition, DrawerDirection, DrawerEmits, DrawerExposed, DrawerMode, DrawerProps, DropdownEmits, DropdownExposed, DropdownProps, DualNavEmits, DualNavExposed, DualNavProps, DualNavRailVariant, DualNavRootItem, EmptyEmits, EmptyExposed, EmptyProps, ExpressionEditorEmits, ExpressionEditorExposed, ExpressionEditorProps, ExpressionSelectableLevels, FileViewerEmits, FileViewerExposed, FileViewerItem, FileViewerKind, FileViewerProps, FloatButtonEmits, FloatButtonExposed, FloatButtonItem, FloatButtonProps, FormEmits, FormExposed, FormItemEmits, FormItemExposed, FormItemProps, FormProps, GanttChartEmits, GanttChartExposed, GanttChartProps, GridEmits, GridExposed, GridInputEmits, GridInputExposed, GridInputProps, GridItemProps, GridProps, GroupInputEmits, GroupInputExposed, GroupInputProps, GroupNavEmits, GroupNavGroup, GroupNavProps, IconEmits, IconExposed, IconProps, InputEmits, InputExposed, InputProps, LayoutEmits, LayoutExposed, LayoutProps, ListEmits, ListExposed, ListProps, LoadingEmits, LoadingExposed, LoadingProps, LoadingType, Message, MessageConfirm, MessageConfirmAction, MessageConfirmEmits, MessageConfirmExposed, MessageConfirmInstance, MessageConfirmOptions, MessageConfirmProps, MessageEmits, MessageExposed, MessageInstance, MessageOptions, MessageProps, MessageType, MultiAutoCompleteEmits, MultiAutoCompleteExposed, MultiAutoCompleteProps, MultiSelectEmits, MultiSelectExposed, MultiSelectProps, MultiTreeSelectEmits, MultiTreeSelectExposed, MultiTreeSelectProps, NavEmits, NavExposed, NavItem, NavProps, NodeRenderExposed, NodeRenderProps, Notification, NotificationEmits, NotificationExposed, NotificationInstance, NotificationOptions, NotificationPosition, NotificationProps, NumberEmits, NumberExposed, NumberInputEmits, NumberInputExposed, NumberInputProps, NumberProps, NumberRangeInputEmits, NumberRangeInputExposed, NumberRangeInputProps, NumberRangeTuple, PaginatorEmits, PaginatorExposed, PaginatorProps, PaletteColorType, PaletteEmits, PaletteExposed, PaletteHSV, PaletteProps, PaletteRGB, PanelItem, PanelType, PasswordInputEmits, PasswordInputExposed, PasswordInputProps, PopConfirmEmits, PopConfirmExposed, PopConfirmProps, PopEmits, PopExposed, PopProps, ProgressEmits, ProgressExposed, ProgressNodesEmits, ProgressNodesExposed, ProgressNodesProps, ProgressProps, QuickBatchEditEmits, QuickBatchEditExposed, QuickBatchEditProps, RadioEmits, RadioExposed, RadioGroupEmits, RadioGroupExposed, RadioGroupProps, RadioProps, RichTextEditorEmits, RichTextEditorExposed, RichTextEditorProps, RichTextFormat, ScrollEmits, ScrollExposed, ScrollPosition, ScrollProps, SegmentEmits, SegmentExposed, SegmentItem, SegmentProps, SelectEmits, SelectExposed, SelectProps, SliderEmits, SliderExposed, SliderProps, StepsEmits, StepsExposed, StepsProps, StepsSlotScope, SwitchEmits, SwitchExposed, SwitchProps, TabItem, TableColumn, TableColumnAlign, TableColumnNode, TableColumnRenderContext, TableColumnSlotsScope, TableEditorEmits, TableEditorExposed, TableEditorProps, TableEmits, TableExposed, TableProps, TableRow, TableRowSlotsScope, TableSummaryContext, TabsEmits, TabsExposed, TabsHorizontalEmits, TabsHorizontalExposed, TabsHorizontalProps, TabsProps, TabsVerticalEmits, TabsVerticalExposed, TabsVerticalProps, TagEmits, TagExposed, TagProps, TextEditorEmits, TextEditorExposed, TextEditorProps, TextEmits, TextExposed, TextProps, TextareaEmits, TextareaExposed, TextareaProps, ThemeExposed, ThemeProps, TipAlign, TipDirection, TipEmits, TipExposed, TipProps, ToolbarItem, TreeEmit, TreeExposed, TreeNode, TreeNodeProps, TreeProps, TreeSelectEmits, TreeSelectExposed, TreeSelectProps, UploaderEmits, UploaderExposed, UploaderProps, VariableItem, WatermarkEmits, WatermarkExposed, WatermarkProps, _ActionExposed, _ActionGroupExposed, _AnimationExposed, _AutoCompleteExposed, _BadgeExposed, _BatchEditExposed, _BreadcrumbExposed, _ButtonExposed, _CalendarExposed, _CardExposed, _CascadeExposed, _CheckTagExposed, _CodeEditorExposed, _ConditionEditorExposed, _ContextmenuExposed, _CssTransitionExposed, _DatePickerExposed, _DateRangePickerExposed, _DialogExposed, _DrawerExposed, _DropdownExposed, _DualNavExposed, _EmptyExposed, _ExpressionEditorExposed, _FileViewerExposed, _FloatButtonExposed, _FormExposed, _GanttChartExposed, _GridExposed, _GridInputExposed, _GroupInputExposed, _InputExposed, _LayoutExposed, _ListExposed, _LoadingExposed, _MessageConfirmExposed, _MessageExposed, _MultiAutoCompleteExposed, _MultiSelectExposed, _MultiTreeSelectExposed, _NavExposed, _NotificationExposed, _PaginatorExposed, _PaletteExposed, _PasswordInputExposed, _PopConfirmExposed, _PopExposed, _ProgressExposed, _ProgressNodesExposed, _QuickBatchEditExposed, _RadioExposed, _RadioGroupExposed, _RichTextEditorExposed, _ScrollExposed, _SegmentExposed, _SelectExposed, _SliderExposed, _StepsExposed, _SwitchExposed, _TableEditorExposed, _TableExposed, _TabsExposed, _TabsHorizontalExposed, _TabsVerticalExposed, _TextEditorExposed, _TextExposed, _TextareaExposed, _ThemeExposed, _TipExposed, _TreeExposed, _TreeSelectExposed, _UploaderExposed, _WatermarkExposed };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/desktop",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"homepage": "https://github.com/cabinet-fe/ultra-ui#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/cabinet-fe/ultra-ui/issues"
|
|
@@ -80,12 +80,12 @@
|
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@cat-kit/core": ">=1.2.1",
|
|
82
82
|
"@cat-kit/fe": ">=1.2.1",
|
|
83
|
-
"@veltra/compositions": "^1.7.
|
|
84
|
-
"@veltra/directives": "^1.7.
|
|
83
|
+
"@veltra/compositions": "^1.7.5",
|
|
84
|
+
"@veltra/directives": "^1.7.5",
|
|
85
85
|
"@veltra/icons": "^1.5.0",
|
|
86
86
|
"@veltra/sheet-core": "^2.5.4",
|
|
87
|
-
"@veltra/styles": "^1.7.
|
|
88
|
-
"@veltra/utils": "^1.7.
|
|
87
|
+
"@veltra/styles": "^1.7.5",
|
|
88
|
+
"@veltra/utils": "^1.7.5",
|
|
89
89
|
"vue": ">=3.5.42"
|
|
90
90
|
},
|
|
91
91
|
"peerDependenciesMeta": {
|
|
@@ -12,7 +12,7 @@ export const weekDays: string[] = ['日', '一', '二', '三', '四', '五', '
|
|
|
12
12
|
*/
|
|
13
13
|
export function getMonthDays(
|
|
14
14
|
d: Date | string | number | Dater,
|
|
15
|
-
disabledDate?: (d: Dater) => boolean
|
|
15
|
+
disabledDate?: (d: Dater, raw: Date) => boolean
|
|
16
16
|
): CalendarDay[] {
|
|
17
17
|
const todayStr = date().format()
|
|
18
18
|
if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {
|
|
@@ -24,7 +24,7 @@ export function getMonthDays(
|
|
|
24
24
|
const currentMonthDays: CalendarDay[] = Array.from({ length: d.getDays() }).map((_, i) => {
|
|
25
25
|
const day: CalendarDay = { date: d.calc(i, 'days'), type: 'current' }
|
|
26
26
|
day.isToday = day.date.format() === todayStr
|
|
27
|
-
day.disabled = disabledDate?.(day.date)
|
|
27
|
+
day.disabled = disabledDate?.(day.date, day.date.raw)
|
|
28
28
|
return day
|
|
29
29
|
})
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ export function getMonthDays(
|
|
|
41
41
|
let i = 0
|
|
42
42
|
while (i < firstDayWeek) {
|
|
43
43
|
const day: CalendarDay = { date: d.calc(-i, 'days'), type: 'pre' }
|
|
44
|
-
day.disabled = disabledDate?.(day.date)
|
|
44
|
+
day.disabled = disabledDate?.(day.date, day.date.raw)
|
|
45
45
|
preMonthDays.unshift(day)
|
|
46
46
|
i++
|
|
47
47
|
}
|
|
@@ -55,7 +55,7 @@ export function getMonthDays(
|
|
|
55
55
|
|
|
56
56
|
while (j < nextMonthDaysAmount) {
|
|
57
57
|
const day: CalendarDay = { date: d.calc(j++, 'days'), type: 'next' }
|
|
58
|
-
day.disabled = disabledDate?.(day.date)
|
|
58
|
+
day.disabled = disabledDate?.(day.date, day.date.raw)
|
|
59
59
|
nextMonthDays.push(day)
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -70,7 +70,7 @@ export function getMonthDays(
|
|
|
70
70
|
*/
|
|
71
71
|
export function getYearMonths(
|
|
72
72
|
d: Date | string | number | Dater,
|
|
73
|
-
disabledDate?: (d: Dater) => boolean
|
|
73
|
+
disabledDate?: (d: Dater, raw: Date) => boolean
|
|
74
74
|
): CalendarMonth[] {
|
|
75
75
|
if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {
|
|
76
76
|
d = date(d)
|
|
@@ -88,7 +88,7 @@ export function getYearMonths(
|
|
|
88
88
|
monthDate.setMinutes(59)
|
|
89
89
|
monthDate.setSeconds(59)
|
|
90
90
|
|
|
91
|
-
return { key: ym, month, date: monthDate, disabled: disabledDate?.(monthDate) }
|
|
91
|
+
return { key: ym, month, date: monthDate, disabled: disabledDate?.(monthDate, monthDate.raw) }
|
|
92
92
|
})
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -100,7 +100,7 @@ export function getYearMonths(
|
|
|
100
100
|
*/
|
|
101
101
|
export function getTenYears(
|
|
102
102
|
d: Date | string | number | Dater,
|
|
103
|
-
disabledDate?: (d: Dater) => boolean
|
|
103
|
+
disabledDate?: (d: Dater, raw: Date) => boolean
|
|
104
104
|
): CalendarYear[] {
|
|
105
105
|
if (d instanceof Date || typeof d === 'string' || typeof d === 'number') {
|
|
106
106
|
d = date(d)
|
|
@@ -113,6 +113,6 @@ export function getTenYears(
|
|
|
113
113
|
|
|
114
114
|
const yearDate = date(`${year}-12-31 23:59:59`)
|
|
115
115
|
|
|
116
|
-
return { year, date: yearDate, disabled: disabledDate?.(yearDate) }
|
|
116
|
+
return { year, date: yearDate, disabled: disabledDate?.(yearDate, yearDate.raw) }
|
|
117
117
|
})
|
|
118
118
|
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { date } from '@cat-kit/core'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { createApp, h, nextTick, ref } from 'vue'
|
|
4
|
+
|
|
5
|
+
import UDatePicker from '../date-picker.vue'
|
|
6
|
+
|
|
7
|
+
function mountDatePicker(
|
|
8
|
+
props: Record<string, unknown> = {},
|
|
9
|
+
emits: Record<string, Function> = {}
|
|
10
|
+
) {
|
|
11
|
+
const host = document.createElement('div')
|
|
12
|
+
document.body.appendChild(host)
|
|
13
|
+
|
|
14
|
+
const model = ref(props.modelValue)
|
|
15
|
+
const app = createApp({
|
|
16
|
+
render() {
|
|
17
|
+
return h(UDatePicker, {
|
|
18
|
+
...props,
|
|
19
|
+
modelValue: model.value,
|
|
20
|
+
'onUpdate:modelValue': (value: unknown) => {
|
|
21
|
+
model.value = value
|
|
22
|
+
emits['update:modelValue']?.(value)
|
|
23
|
+
},
|
|
24
|
+
onChange: (date?: Date) => {
|
|
25
|
+
emits.change?.(date)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
app.component('Transition', (_, { slots }) => slots.default?.())
|
|
32
|
+
|
|
33
|
+
app.mount(host)
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
host,
|
|
37
|
+
model,
|
|
38
|
+
app,
|
|
39
|
+
unmount() {
|
|
40
|
+
app.unmount()
|
|
41
|
+
host.remove()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('UDatePicker', () => {
|
|
47
|
+
it('defaults dataType to string and emits change with native Date', async () => {
|
|
48
|
+
let changedDate: Date | undefined
|
|
49
|
+
let updatedVal: unknown
|
|
50
|
+
|
|
51
|
+
const { host, unmount } = mountDatePicker(
|
|
52
|
+
{},
|
|
53
|
+
{
|
|
54
|
+
'update:modelValue': (val: unknown) => {
|
|
55
|
+
updatedVal = val
|
|
56
|
+
},
|
|
57
|
+
change: (d?: Date) => {
|
|
58
|
+
changedDate = d
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const inputEl = host.querySelector('input')
|
|
65
|
+
expect(inputEl).not.toBeNull()
|
|
66
|
+
inputEl?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
67
|
+
await nextTick()
|
|
68
|
+
await nextTick()
|
|
69
|
+
|
|
70
|
+
const cell = document.querySelector('.u-date-panel__cell.is-current') as HTMLElement
|
|
71
|
+
expect(cell).not.toBeNull()
|
|
72
|
+
cell.click()
|
|
73
|
+
await nextTick()
|
|
74
|
+
|
|
75
|
+
expect(typeof updatedVal).toBe('string')
|
|
76
|
+
expect(updatedVal).toMatch(/^\d{4}-\d{2}-\d{2}$/)
|
|
77
|
+
expect(changedDate instanceof Date).toBe(true)
|
|
78
|
+
} finally {
|
|
79
|
+
unmount()
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('supports dataType="date" and emits native Date for modelValue and change', async () => {
|
|
84
|
+
let changedDate: Date | undefined
|
|
85
|
+
let updatedVal: unknown
|
|
86
|
+
|
|
87
|
+
const { host, unmount } = mountDatePicker(
|
|
88
|
+
{ dataType: 'date', valueFormat: 'yyyyMMdd' },
|
|
89
|
+
{
|
|
90
|
+
'update:modelValue': (val: unknown) => {
|
|
91
|
+
updatedVal = val
|
|
92
|
+
},
|
|
93
|
+
change: (d?: Date) => {
|
|
94
|
+
changedDate = d
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
const inputEl = host.querySelector('input')
|
|
101
|
+
inputEl?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
102
|
+
await nextTick()
|
|
103
|
+
await nextTick()
|
|
104
|
+
|
|
105
|
+
const cell = document.querySelector('.u-date-panel__cell.is-current') as HTMLElement
|
|
106
|
+
cell.click()
|
|
107
|
+
await nextTick()
|
|
108
|
+
|
|
109
|
+
expect(updatedVal instanceof Date).toBe(true)
|
|
110
|
+
expect(changedDate instanceof Date).toBe(true)
|
|
111
|
+
} finally {
|
|
112
|
+
unmount()
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('supports dataType="timestamp" and emits timestamp for modelValue and native Date for change', async () => {
|
|
117
|
+
let changedDate: Date | undefined
|
|
118
|
+
let updatedVal: unknown
|
|
119
|
+
|
|
120
|
+
const { host, unmount } = mountDatePicker(
|
|
121
|
+
{ dataType: 'timestamp', valueFormat: 'yyyyMMdd' },
|
|
122
|
+
{
|
|
123
|
+
'update:modelValue': (val: unknown) => {
|
|
124
|
+
updatedVal = val
|
|
125
|
+
},
|
|
126
|
+
change: (d?: Date) => {
|
|
127
|
+
changedDate = d
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const inputEl = host.querySelector('input')
|
|
134
|
+
inputEl?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
135
|
+
await nextTick()
|
|
136
|
+
await nextTick()
|
|
137
|
+
|
|
138
|
+
const cell = document.querySelector('.u-date-panel__cell.is-current') as HTMLElement
|
|
139
|
+
cell.click()
|
|
140
|
+
await nextTick()
|
|
141
|
+
|
|
142
|
+
expect(typeof updatedVal).toBe('number')
|
|
143
|
+
expect(updatedVal).toBeGreaterThan(0)
|
|
144
|
+
expect(changedDate instanceof Date).toBe(true)
|
|
145
|
+
} finally {
|
|
146
|
+
unmount()
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('applies valueFormat when dataType="string"', async () => {
|
|
151
|
+
let changedDate: Date | undefined
|
|
152
|
+
let updatedVal: unknown
|
|
153
|
+
|
|
154
|
+
const { host, unmount } = mountDatePicker(
|
|
155
|
+
{ dataType: 'string', valueFormat: 'yyyy/MM/dd' },
|
|
156
|
+
{
|
|
157
|
+
'update:modelValue': (val: unknown) => {
|
|
158
|
+
updatedVal = val
|
|
159
|
+
},
|
|
160
|
+
change: (d?: Date) => {
|
|
161
|
+
changedDate = d
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
const inputEl = host.querySelector('input')
|
|
168
|
+
inputEl?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
169
|
+
await nextTick()
|
|
170
|
+
await nextTick()
|
|
171
|
+
|
|
172
|
+
const cell = document.querySelector('.u-date-panel__cell.is-current') as HTMLElement
|
|
173
|
+
cell.click()
|
|
174
|
+
await nextTick()
|
|
175
|
+
|
|
176
|
+
expect(typeof updatedVal).toBe('string')
|
|
177
|
+
expect(updatedVal).toMatch(/^\d{4}\/\d{2}\/\d{2}$/)
|
|
178
|
+
expect(changedDate instanceof Date).toBe(true)
|
|
179
|
+
} finally {
|
|
180
|
+
unmount()
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('emits undefined for modelValue and change when cleared', async () => {
|
|
185
|
+
let changedDate: Date | undefined = new Date()
|
|
186
|
+
let updatedVal: unknown = '2024-05-01'
|
|
187
|
+
|
|
188
|
+
const { host, unmount } = mountDatePicker(
|
|
189
|
+
{ modelValue: '2024-05-01', clearable: true },
|
|
190
|
+
{
|
|
191
|
+
'update:modelValue': (val: unknown) => {
|
|
192
|
+
updatedVal = val
|
|
193
|
+
},
|
|
194
|
+
change: (d?: Date) => {
|
|
195
|
+
changedDate = d
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
const inputWrapper = host.querySelector('.u-input') as HTMLElement
|
|
202
|
+
inputWrapper.dispatchEvent(new MouseEvent('mouseenter', { bubbles: true }))
|
|
203
|
+
await new Promise((r) => setTimeout(r, 50))
|
|
204
|
+
|
|
205
|
+
const clearBtn = host.querySelector('.u-input__clear') as HTMLElement
|
|
206
|
+
expect(clearBtn).not.toBeNull()
|
|
207
|
+
clearBtn.click()
|
|
208
|
+
await nextTick()
|
|
209
|
+
|
|
210
|
+
expect(updatedVal).toBeUndefined()
|
|
211
|
+
expect(changedDate).toBeUndefined()
|
|
212
|
+
} finally {
|
|
213
|
+
unmount()
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it('correctly parses modelValue of Date, timestamp, and custom formatted string', async () => {
|
|
218
|
+
const dateObj = new Date(2024, 4, 15)
|
|
219
|
+
const d1 = mountDatePicker({ modelValue: dateObj })
|
|
220
|
+
await nextTick()
|
|
221
|
+
expect(d1.host.querySelector('input')?.value).toBe('2024-05-15')
|
|
222
|
+
d1.unmount()
|
|
223
|
+
|
|
224
|
+
const ts = date('2024-06-20').timestamp
|
|
225
|
+
const d2 = mountDatePicker({ modelValue: ts })
|
|
226
|
+
await nextTick()
|
|
227
|
+
expect(d2.host.querySelector('input')?.value).toBe('2024-06-20')
|
|
228
|
+
d2.unmount()
|
|
229
|
+
|
|
230
|
+
const d3 = mountDatePicker({ modelValue: '20240725', valueFormat: 'yyyyMMdd' })
|
|
231
|
+
await nextTick()
|
|
232
|
+
expect(d3.host.querySelector('input')?.value).toBe('2024-07-25')
|
|
233
|
+
d3.unmount()
|
|
234
|
+
})
|
|
235
|
+
})
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
</template>
|
|
37
37
|
|
|
38
38
|
<script lang="ts" setup>
|
|
39
|
-
import { date,
|
|
39
|
+
import { date, Dater } from '@cat-kit/core'
|
|
40
40
|
import { useFormFallbackProps, useUserAction } from '@veltra/compositions'
|
|
41
41
|
import { Calendar } from '@veltra/icons/normal'
|
|
42
42
|
import { bem, FORM_EMPTY_CONTENT } from '@veltra/utils'
|
|
@@ -55,6 +55,7 @@ defineOptions({ name: 'UDatePicker', inheritAttrs: false })
|
|
|
55
55
|
const props = withDefaults(defineProps<DatePickerProps>(), {
|
|
56
56
|
placeholder: '选择日期',
|
|
57
57
|
type: 'date',
|
|
58
|
+
dataType: 'string',
|
|
58
59
|
disabled: undefined,
|
|
59
60
|
readonly: undefined,
|
|
60
61
|
clearable: true
|
|
@@ -91,11 +92,28 @@ const currentDate = shallowRef<Dater>()
|
|
|
91
92
|
|
|
92
93
|
const { userAction, isUserActive } = useUserAction()
|
|
93
94
|
|
|
95
|
+
function parseModelValue(val?: string | number | Date): Dater | undefined {
|
|
96
|
+
if (val == null || val === '') return undefined
|
|
97
|
+
if (val instanceof Date || typeof val === 'number') {
|
|
98
|
+
const d = date(val)
|
|
99
|
+
return isNaN(d.timestamp) ? undefined : d
|
|
100
|
+
}
|
|
101
|
+
if (typeof val === 'string') {
|
|
102
|
+
if (props.dataType === 'string' && props.valueFormat) {
|
|
103
|
+
const parsed = Dater.parse(val, props.valueFormat)
|
|
104
|
+
if (!isNaN(parsed.timestamp)) return parsed
|
|
105
|
+
}
|
|
106
|
+
const fallback = date(val)
|
|
107
|
+
return isNaN(fallback.timestamp) ? undefined : fallback
|
|
108
|
+
}
|
|
109
|
+
return undefined
|
|
110
|
+
}
|
|
111
|
+
|
|
94
112
|
watch(
|
|
95
113
|
() => props.modelValue,
|
|
96
114
|
(modelValue) => {
|
|
97
115
|
if (isUserActive()) return
|
|
98
|
-
currentDate.value =
|
|
116
|
+
currentDate.value = parseModelValue(modelValue)
|
|
99
117
|
},
|
|
100
118
|
{ immediate: true }
|
|
101
119
|
)
|
|
@@ -104,9 +122,20 @@ const displayedValue = computed(() => {
|
|
|
104
122
|
return currentDate.value?.format(formatStr.value) ?? ''
|
|
105
123
|
})
|
|
106
124
|
|
|
125
|
+
function formatModelValue(d: Dater) {
|
|
126
|
+
if (props.dataType === 'date') {
|
|
127
|
+
return d.raw
|
|
128
|
+
}
|
|
129
|
+
if (props.dataType === 'timestamp') {
|
|
130
|
+
return d.timestamp
|
|
131
|
+
}
|
|
132
|
+
return d.format(props.valueFormat ?? formatStr.value)
|
|
133
|
+
}
|
|
134
|
+
|
|
107
135
|
const commitSelectedDate = userAction((date: Dater) => {
|
|
108
136
|
currentDate.value = date
|
|
109
|
-
emit('update:modelValue', date
|
|
137
|
+
emit('update:modelValue', formatModelValue(date))
|
|
138
|
+
emit('change', date.raw)
|
|
110
139
|
})
|
|
111
140
|
|
|
112
141
|
async function handleSelectDate(date: Dater) {
|
|
@@ -117,5 +146,6 @@ async function handleSelectDate(date: Dater) {
|
|
|
117
146
|
function handleClear() {
|
|
118
147
|
currentDate.value = undefined
|
|
119
148
|
emit('update:modelValue', undefined)
|
|
149
|
+
emit('change', undefined)
|
|
120
150
|
}
|
|
121
151
|
</script>
|
package/src/types/date-panel.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface DatePanelProps {
|
|
|
7
7
|
date?: Dater
|
|
8
8
|
rangeDate?: [Dater, Dater]
|
|
9
9
|
range?: boolean
|
|
10
|
-
disabledDate?: (date: Dater) => boolean
|
|
10
|
+
disabledDate?: (date: Dater, raw: Date) => boolean
|
|
11
11
|
type?: 'date' | 'month' | 'year'
|
|
12
12
|
size?: FormComponentProps['size']
|
|
13
13
|
}
|
package/src/types/date-picker.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Dater } from '@cat-kit/core'
|
|
2
2
|
import type { DeconstructValue, FormComponentProps } from '@veltra/utils'
|
|
3
3
|
|
|
4
|
+
/** 绑定值类型 */
|
|
5
|
+
export type DatePickerDataType = 'date' | 'timestamp' | 'string'
|
|
6
|
+
|
|
4
7
|
/** date-picker组件属性 */
|
|
5
8
|
export interface DatePickerProps extends FormComponentProps {
|
|
6
9
|
modelValue?: string | number | Date
|
|
@@ -12,8 +15,13 @@ export interface DatePickerProps extends FormComponentProps {
|
|
|
12
15
|
format?: string
|
|
13
16
|
/** 日期值格式化, 当没有指定时默认使用format属性,仅当值和显示的内容不一致时才需要使用到该属性 */
|
|
14
17
|
valueFormat?: string
|
|
18
|
+
/**
|
|
19
|
+
* 绑定值的类型,默认为字符串。
|
|
20
|
+
* 当 dataType 没有指定为字符串时,valueFormat 属性不生效
|
|
21
|
+
*/
|
|
22
|
+
dataType?: DatePickerDataType
|
|
15
23
|
/** 最小可选日期 */
|
|
16
|
-
disabledDate?: (date: Dater) => boolean
|
|
24
|
+
disabledDate?: (date: Dater, raw: Date) => boolean
|
|
17
25
|
/** 是否显示清除按钮 */
|
|
18
26
|
clearable?: boolean
|
|
19
27
|
}
|
|
@@ -21,6 +29,7 @@ export interface DatePickerProps extends FormComponentProps {
|
|
|
21
29
|
/** date-picker组件定义的事件 */
|
|
22
30
|
export interface DatePickerEmits {
|
|
23
31
|
(e: 'update:modelValue', value?: string | number | Date): void
|
|
32
|
+
(e: 'change', date?: Date): void
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
/** date-picker组件暴露的属性和方法(组件内部使用) */
|
|
@@ -13,7 +13,7 @@ export interface DateRangePickerProps extends FormComponentProps {
|
|
|
13
13
|
/** 日期值格式化, 当没有指定时默认使用format属性,仅当值和显示的内容不一致时才需要使用到该属性 */
|
|
14
14
|
valueFormat?: string
|
|
15
15
|
/** 最小可选日期 */
|
|
16
|
-
disabledDate?: (date: Dater) => boolean
|
|
16
|
+
disabledDate?: (date: Dater, raw: Date) => boolean
|
|
17
17
|
/** 是否显示清除按钮 */
|
|
18
18
|
clearable?: boolean
|
|
19
19
|
}
|