@movk/nuxt 1.8.3 → 2.0.0-beta.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/README.en.md +16 -6
- package/README.md +16 -6
- package/dist/module.d.mts +6 -0
- package/dist/module.json +3 -3
- package/dist/module.mjs +15 -22
- package/dist/runtime/components/AutoForm.d.vue.ts +15 -1
- package/dist/runtime/components/AutoForm.vue +48 -50
- package/dist/runtime/components/AutoForm.vue.d.ts +15 -1
- package/dist/runtime/components/DataTable.d.vue.ts +4 -2
- package/dist/runtime/components/DataTable.vue +166 -174
- package/dist/runtime/components/DataTable.vue.d.ts +4 -2
- package/dist/runtime/components/DatePicker.d.vue.ts +6 -5
- package/dist/runtime/components/DatePicker.vue +96 -43
- package/dist/runtime/components/DatePicker.vue.d.ts +6 -5
- package/dist/runtime/components/MessageBox.d.vue.ts +1 -5
- package/dist/runtime/components/MessageBox.vue +9 -7
- package/dist/runtime/components/MessageBox.vue.d.ts +1 -5
- package/dist/runtime/components/SearchForm.d.vue.ts +12 -4
- package/dist/runtime/components/SearchForm.vue +130 -120
- package/dist/runtime/components/SearchForm.vue.d.ts +12 -4
- package/dist/runtime/components/Tree.d.vue.ts +3 -1
- package/dist/runtime/components/Tree.vue +102 -140
- package/dist/runtime/components/Tree.vue.d.ts +3 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +5 -3
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +15 -6
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/useApiFetch.d.ts +7 -7
- package/dist/runtime/composables/useApiFetch.js +5 -23
- package/dist/runtime/composables/useAutoForm.js +2 -2
- package/dist/runtime/composables/useClientApiFetch.d.ts +5 -5
- package/dist/runtime/composables/useDateFormatter.d.ts +32 -34
- package/dist/runtime/composables/useDateFormatter.js +75 -232
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +11 -8
- package/dist/runtime/composables/useDownloadWithProgress.js +49 -132
- package/dist/runtime/composables/useMessageBox.js +3 -2
- package/dist/runtime/composables/useMovkLocale.d.ts +16 -0
- package/dist/runtime/composables/useMovkLocale.js +20 -0
- package/dist/runtime/composables/useTheme.js +8 -18
- package/dist/runtime/composables/useUploadWithProgress.d.ts +9 -6
- package/dist/runtime/composables/useUploadWithProgress.js +50 -84
- package/dist/runtime/domains/ai/chat-transport.js +1 -0
- package/dist/runtime/domains/api/adapters/xhr.d.ts +17 -0
- package/dist/runtime/domains/api/adapters/xhr.js +55 -0
- package/dist/runtime/domains/api/auth.d.ts +4 -1
- package/dist/runtime/domains/api/auth.js +6 -7
- package/dist/runtime/domains/api/client.d.ts +13 -0
- package/dist/runtime/domains/api/client.js +35 -0
- package/dist/runtime/domains/api/download.d.ts +10 -0
- package/dist/runtime/domains/api/download.js +28 -0
- package/dist/runtime/domains/api/errors.d.ts +20 -2
- package/dist/runtime/domains/api/errors.js +61 -8
- package/dist/runtime/domains/api/fetch-key.d.ts +2 -2
- package/dist/runtime/domains/api/fetch-key.js +4 -4
- package/dist/runtime/domains/api/interceptors/request.d.ts +2 -6
- package/dist/runtime/domains/api/interceptors/request.js +3 -2
- package/dist/runtime/domains/api/interceptors/response.d.ts +8 -14
- package/dist/runtime/domains/api/interceptors/response.js +34 -25
- package/dist/runtime/domains/api/report.d.ts +25 -0
- package/dist/runtime/domains/api/report.js +51 -0
- package/dist/runtime/domains/api/response.d.ts +29 -4
- package/dist/runtime/domains/api/response.js +27 -6
- package/dist/runtime/domains/api/session.d.ts +1 -1
- package/dist/runtime/domains/api/session.js +1 -1
- package/dist/runtime/domains/api/stream.d.ts +2 -1
- package/dist/runtime/domains/api/stream.js +2 -1
- package/dist/runtime/domains/api/toast.d.ts +6 -3
- package/dist/runtime/domains/api/toast.js +7 -7
- package/dist/runtime/domains/auto-form/actions.d.ts +2 -1
- package/dist/runtime/domains/auto-form/actions.js +6 -4
- package/dist/runtime/domains/auto-form/array-ops.d.ts +3 -0
- package/dist/runtime/domains/auto-form/array-ops.js +9 -0
- package/dist/runtime/domains/auto-form/async-items.d.ts +10 -0
- package/dist/runtime/domains/auto-form/async-items.js +42 -0
- package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +0 -4
- package/dist/runtime/domains/auto-form/components/Array.vue +81 -73
- package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +0 -4
- package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Children.vue +0 -5
- package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Field.vue +9 -2
- package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Layout.vue +3 -6
- package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Nested.vue +5 -9
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/controls.d.ts +5 -572
- package/dist/runtime/domains/auto-form/controls.js +7 -20
- package/dist/runtime/domains/auto-form/fields.d.ts +21 -4
- package/dist/runtime/domains/auto-form/fields.js +52 -40
- package/dist/runtime/domains/auto-form/provider.d.ts +15 -6
- package/dist/runtime/domains/auto-form/provider.js +24 -10
- package/dist/runtime/domains/auto-form/schema.d.ts +9 -4
- package/dist/runtime/domains/auto-form/schema.js +91 -50
- package/dist/runtime/domains/auto-form/search-query.d.ts +10 -0
- package/dist/runtime/domains/auto-form/search-query.js +57 -0
- package/dist/runtime/domains/auto-form/useAutoFormCore.d.ts +62 -0
- package/dist/runtime/domains/auto-form/useAutoFormCore.js +108 -0
- package/dist/runtime/domains/auto-form/useSearchQuerySync.d.ts +11 -0
- package/dist/runtime/domains/auto-form/useSearchQuerySync.js +64 -0
- package/dist/runtime/domains/data-table/columns/constants.d.ts +2 -0
- package/dist/runtime/domains/data-table/columns/constants.js +1 -1
- package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +2 -1
- package/dist/runtime/domains/data-table/columns/resolve-columns.js +3 -2
- package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +7 -2
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +10 -5
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +14 -8
- package/dist/runtime/domains/data-table/components/ColumnSettings.d.vue.ts +20 -0
- package/dist/runtime/domains/data-table/components/ColumnSettings.vue +63 -0
- package/dist/runtime/domains/data-table/components/ColumnSettings.vue.d.ts +20 -0
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +2 -8
- package/dist/runtime/domains/data-table/components/Pagination.vue +34 -36
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +2 -8
- package/dist/runtime/domains/data-table/export.d.ts +23 -0
- package/dist/runtime/domains/data-table/export.js +43 -0
- package/dist/runtime/domains/data-table/load-more.d.ts +8 -0
- package/dist/runtime/domains/data-table/load-more.js +14 -0
- package/dist/runtime/domains/data-table/pagination.d.ts +29 -0
- package/dist/runtime/domains/data-table/pagination.js +42 -0
- package/dist/runtime/domains/data-table/persist.d.ts +12 -0
- package/dist/runtime/domains/data-table/persist.js +41 -0
- package/dist/runtime/domains/data-table/state/keys.d.ts +11 -0
- package/dist/runtime/domains/data-table/state/keys.js +44 -0
- package/dist/runtime/domains/data-table/state/models.d.ts +5 -0
- package/dist/runtime/domains/data-table/state/models.js +38 -0
- package/dist/runtime/domains/data-table/tree-layout.d.ts +13 -0
- package/dist/runtime/domains/data-table/tree-layout.js +30 -0
- package/dist/runtime/domains/theme/theme-color.d.ts +3 -0
- package/dist/runtime/domains/theme/theme-color.js +16 -0
- package/dist/runtime/domains/theme/theme-fouc.d.ts +5 -0
- package/dist/runtime/domains/theme/theme-fouc.js +43 -0
- package/dist/runtime/domains/tree/components/TreeToolbar.d.vue.ts +7 -5
- package/dist/runtime/domains/tree/components/TreeToolbar.vue +6 -4
- package/dist/runtime/domains/tree/components/TreeToolbar.vue.d.ts +7 -5
- package/dist/runtime/domains/tree/tree-disabled.d.ts +5 -0
- package/dist/runtime/domains/tree/tree-disabled.js +15 -0
- package/dist/runtime/domains/tree/tree-lazy.d.ts +8 -0
- package/dist/runtime/domains/tree/tree-lazy.js +19 -1
- package/dist/runtime/domains/tree/tree-search.d.ts +3 -1
- package/dist/runtime/domains/tree/tree-search.js +4 -0
- package/dist/runtime/domains/tree/useTreeLazy.d.ts +22 -0
- package/dist/runtime/domains/tree/useTreeLazy.js +57 -0
- package/dist/runtime/domains/tree/useTreeSearch.d.ts +27 -0
- package/dist/runtime/domains/tree/useTreeSearch.js +59 -0
- package/dist/runtime/domains/tree/useTreeSelection.d.ts +31 -0
- package/dist/runtime/domains/tree/useTreeSelection.js +89 -0
- package/dist/runtime/domains/zod/apply.d.ts +23 -0
- package/dist/runtime/domains/zod/apply.js +26 -0
- package/dist/runtime/domains/zod/error-map.d.ts +13 -0
- package/dist/runtime/domains/zod/error-map.js +19 -0
- package/dist/runtime/domains/zod/locale-map.d.ts +5 -0
- package/dist/runtime/domains/zod/locale-map.js +17 -0
- package/dist/runtime/domains/zod/sync.d.ts +12 -0
- package/dist/runtime/domains/zod/sync.js +30 -0
- package/dist/runtime/locale/en.d.ts +74 -0
- package/dist/runtime/locale/en.js +73 -0
- package/dist/runtime/locale/index.d.ts +8 -0
- package/dist/runtime/locale/index.js +15 -0
- package/dist/runtime/locale/zh_cn.d.ts +74 -0
- package/dist/runtime/locale/zh_cn.js +73 -0
- package/dist/runtime/plugins/api.factory.js +5 -22
- package/dist/runtime/plugins/theme.js +4 -42
- package/dist/runtime/plugins/zod.d.ts +2 -0
- package/dist/runtime/plugins/zod.js +16 -0
- package/dist/runtime/types/api/config.d.ts +12 -0
- package/dist/runtime/types/api/fetch.d.ts +3 -16
- package/dist/runtime/types/api/index.d.ts +1 -1
- package/dist/runtime/types/api/response.d.ts +33 -19
- package/dist/runtime/types/api/stream.d.ts +2 -3
- package/dist/runtime/types/api/transfer.d.ts +3 -7
- package/dist/runtime/types/auto-form/base.d.ts +9 -1
- package/dist/runtime/types/auto-form/component.d.ts +31 -3
- package/dist/runtime/types/auto-form/fields.d.ts +15 -1
- package/dist/runtime/types/auto-form/index.d.ts +3 -3
- package/dist/runtime/types/auto-form/search-form.d.ts +26 -12
- package/dist/runtime/types/auto-form/zod-factory.d.ts +2 -2
- package/dist/runtime/types/components/date-picker.d.ts +14 -3
- package/dist/runtime/types/components/index.d.ts +1 -6
- package/dist/runtime/types/components/message-box.d.ts +5 -18
- package/dist/runtime/types/components/tree.d.ts +17 -14
- package/dist/runtime/types/data-table/columns.d.ts +6 -14
- package/dist/runtime/types/data-table/component.d.ts +42 -1
- package/dist/runtime/types/data-table/index.d.ts +1 -1
- package/dist/runtime/types/data-table/pagination.d.ts +7 -8
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/locale.d.ts +82 -0
- package/dist/runtime/types/shared.d.ts +13 -0
- package/dist/runtime/types/zod-config.d.ts +38 -0
- package/dist/runtime/types/zod.d.ts +9 -1
- package/dist/runtime/utils/date/convert.d.ts +29 -0
- package/dist/runtime/utils/date/convert.js +93 -0
- package/dist/runtime/utils/date/guards.d.ts +10 -0
- package/dist/runtime/utils/date/guards.js +18 -0
- package/dist/runtime/utils/extend-theme.js +2 -1
- package/dist/runtime/utils/form-control.d.ts +0 -12
- package/dist/runtime/utils/form-control.js +3 -39
- package/dist/runtime/utils/interpolate.d.ts +2 -0
- package/dist/runtime/utils/interpolate.js +4 -0
- package/dist/runtime/utils/theme-defaults.d.ts +10 -0
- package/dist/runtime/utils/theme-defaults.js +9 -0
- package/dist/runtime/utils/tree-selection.d.ts +2 -15
- package/dist/runtime/utils/tv.d.ts +1 -1
- package/dist/runtime/vue/plugins/zod.d.ts +7 -0
- package/dist/runtime/vue/plugins/zod.js +12 -0
- package/dist/shared/{nuxt.DfVF6ZZv.mjs → nuxt.CbmfnBRt.mjs} +82 -236
- package/dist/unplugin.d.mts +3 -2
- package/dist/unplugin.mjs +22 -22
- package/dist/vite.d.mts +1 -0
- package/dist/vite.mjs +2 -1
- package/package.json +39 -34
- package/vue-plugin.d.ts +7 -1
- package/dist/runtime/components/ColorChooser.d.vue.ts +0 -36
- package/dist/runtime/components/ColorChooser.vue +0 -328
- package/dist/runtime/components/ColorChooser.vue.d.ts +0 -36
- package/dist/runtime/components/PillGroup.d.vue.ts +0 -33
- package/dist/runtime/components/PillGroup.vue +0 -291
- package/dist/runtime/components/PillGroup.vue.d.ts +0 -33
- package/dist/runtime/components/Popconfirm.d.vue.ts +0 -30
- package/dist/runtime/components/Popconfirm.vue +0 -143
- package/dist/runtime/components/Popconfirm.vue.d.ts +0 -30
- package/dist/runtime/components/SlideVerify.d.vue.ts +0 -41
- package/dist/runtime/components/SlideVerify.vue +0 -174
- package/dist/runtime/components/SlideVerify.vue.d.ts +0 -41
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +0 -32
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +0 -48
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +0 -32
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +0 -32
- package/dist/runtime/components/input/WithCharacterLimit.vue +0 -54
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +0 -32
- package/dist/runtime/components/input/WithClear.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithClear.vue +0 -60
- package/dist/runtime/components/input/WithClear.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithCopy.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithCopy.vue +0 -66
- package/dist/runtime/components/input/WithCopy.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithFloatingLabel.vue +0 -75
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +0 -32
- package/dist/runtime/components/input/WithPasswordToggle.vue +0 -61
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +0 -32
- package/dist/runtime/domains/api/interceptors/compose.d.ts +0 -24
- package/dist/runtime/domains/api/interceptors/compose.js +0 -18
- package/dist/runtime/domains/api/interceptors/error.d.ts +0 -13
- package/dist/runtime/domains/api/interceptors/error.js +0 -26
- package/dist/runtime/domains/api/interceptors/unauthorized.d.ts +0 -12
- package/dist/runtime/domains/api/interceptors/unauthorized.js +0 -34
- package/dist/runtime/domains/api/transfer.d.ts +0 -69
- package/dist/runtime/domains/api/transfer.js +0 -87
- package/dist/runtime/types/components/color-chooser.d.ts +0 -109
- package/dist/runtime/types/components/input/as-phone-number-input.d.ts +0 -17
- package/dist/runtime/types/components/input/index.d.ts +0 -6
- package/dist/runtime/types/components/input/index.js +0 -0
- package/dist/runtime/types/components/input/with-character-limit.d.ts +0 -11
- package/dist/runtime/types/components/input/with-character-limit.js +0 -0
- package/dist/runtime/types/components/input/with-clear.d.ts +0 -10
- package/dist/runtime/types/components/input/with-clear.js +0 -0
- package/dist/runtime/types/components/input/with-copy.d.ts +0 -11
- package/dist/runtime/types/components/input/with-copy.js +0 -0
- package/dist/runtime/types/components/input/with-floating-label.d.ts +0 -12
- package/dist/runtime/types/components/input/with-floating-label.js +0 -0
- package/dist/runtime/types/components/input/with-password-toggle.d.ts +0 -7
- package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
- package/dist/runtime/types/components/pill-group.d.ts +0 -103
- package/dist/runtime/types/components/pill-group.js +0 -0
- package/dist/runtime/types/components/popconfirm.d.ts +0 -74
- package/dist/runtime/types/components/popconfirm.js +0 -0
- package/dist/runtime/types/components/slide-verify.d.ts +0 -54
- package/dist/runtime/types/components/slide-verify.js +0 -0
- /package/dist/runtime/types/{components/color-chooser.js → locale.js} +0 -0
- /package/dist/runtime/types/{components/input/as-phone-number-input.js → zod-config.js} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CalendarDate } from '@internationalized/date';
|
|
2
|
+
import type { DateValue } from '@internationalized/date';
|
|
3
|
+
export type ValueFormat = 'date-value' | 'iso' | 'timestamp' | 'unix' | 'date';
|
|
4
|
+
type Nullable<T> = T | undefined | null;
|
|
5
|
+
/** 解析 ISO 8601 字符串,支持日期、日期时间、带偏移与带 IANA 时区的日期时间;非法时返回 null */
|
|
6
|
+
export declare function parseISO(value: string, timeZone: string): DateValue | null;
|
|
7
|
+
export declare function toISO(date: Nullable<DateValue>): string;
|
|
8
|
+
/**
|
|
9
|
+
* 转换为 JS Date:纯日期取 UTC 午夜,保证任何时区下日期不偏移;
|
|
10
|
+
* 带时间的值按 `timeZone` 解释,保留时分秒
|
|
11
|
+
*/
|
|
12
|
+
export declare function toDate(date: Nullable<DateValue>, timeZone: string): Date | null;
|
|
13
|
+
export declare function toTimestamp(date: Nullable<DateValue>, timeZone: string): number | null;
|
|
14
|
+
export declare function toUnixTimestamp(date: Nullable<DateValue>, timeZone: string): number | null;
|
|
15
|
+
export declare function toFormat(date: Nullable<DateValue>, format: ValueFormat, timeZone: string): unknown;
|
|
16
|
+
/** 从 JS Date 反解为 CalendarDate(用 UTC 字段,与纯日期的 toDate 互逆) */
|
|
17
|
+
export declare function fromDate(value: Nullable<Date>): CalendarDate | null;
|
|
18
|
+
export declare function fromTimestamp(value: Nullable<number>): CalendarDate | null;
|
|
19
|
+
export declare function fromUnixTimestamp(value: Nullable<number>): CalendarDate | null;
|
|
20
|
+
/** 按 format 把任意值反解为 DateValue;类型不匹配返回 null */
|
|
21
|
+
export declare function fromFormat(value: unknown, format: ValueFormat, timeZone: string): DateValue | null;
|
|
22
|
+
/**
|
|
23
|
+
* 递归转换数据中的日期:单个日期、日期范围、数组与普通对象;
|
|
24
|
+
* Date 与其他类实例原样保留
|
|
25
|
+
*/
|
|
26
|
+
export declare function convertData<T>(data: T, converter: (value: DateValue) => unknown): T;
|
|
27
|
+
/** 按 format 递归反解 single / range / array;date-value 时透传 */
|
|
28
|
+
export declare function convertFromFormat<T>(data: T, format: ValueFormat, timeZone: string): unknown;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CalendarDate, parseAbsolute, parseDate, parseDateTime, parseZonedDateTime } from "@internationalized/date";
|
|
2
|
+
import { isDateRange, isDateValue, isPlainObject, safe } from "./guards.js";
|
|
3
|
+
const ABSOLUTE_RE = /(?:Z|[+-]\d{2}:?\d{2})$/;
|
|
4
|
+
export function parseISO(value, timeZone) {
|
|
5
|
+
return safe(() => {
|
|
6
|
+
if (!value.includes("T")) return parseDate(value);
|
|
7
|
+
if (value.includes("[")) return parseZonedDateTime(value);
|
|
8
|
+
if (ABSOLUTE_RE.test(value)) return parseAbsolute(value, timeZone);
|
|
9
|
+
return parseDateTime(value);
|
|
10
|
+
}, null);
|
|
11
|
+
}
|
|
12
|
+
export function toISO(date) {
|
|
13
|
+
return date ? safe(() => date.toString(), "") : "";
|
|
14
|
+
}
|
|
15
|
+
export function toDate(date, timeZone) {
|
|
16
|
+
if (!date) return null;
|
|
17
|
+
return safe(() => "hour" in date ? date.toDate(timeZone) : new Date(Date.UTC(date.year, date.month - 1, date.day)), null);
|
|
18
|
+
}
|
|
19
|
+
export function toTimestamp(date, timeZone) {
|
|
20
|
+
return toDate(date, timeZone)?.getTime() ?? null;
|
|
21
|
+
}
|
|
22
|
+
export function toUnixTimestamp(date, timeZone) {
|
|
23
|
+
const timestamp = toTimestamp(date, timeZone);
|
|
24
|
+
return timestamp === null ? null : Math.floor(timestamp / 1e3);
|
|
25
|
+
}
|
|
26
|
+
export function toFormat(date, format, timeZone) {
|
|
27
|
+
if (!date) return void 0;
|
|
28
|
+
switch (format) {
|
|
29
|
+
case "date-value":
|
|
30
|
+
return date;
|
|
31
|
+
case "iso":
|
|
32
|
+
return toISO(date);
|
|
33
|
+
case "timestamp":
|
|
34
|
+
return toTimestamp(date, timeZone);
|
|
35
|
+
case "unix":
|
|
36
|
+
return toUnixTimestamp(date, timeZone);
|
|
37
|
+
case "date":
|
|
38
|
+
return toDate(date, timeZone);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function fromDate(value) {
|
|
42
|
+
if (!value || Number.isNaN(value.getTime())) return null;
|
|
43
|
+
return safe(() => new CalendarDate(value.getUTCFullYear(), value.getUTCMonth() + 1, value.getUTCDate()), null);
|
|
44
|
+
}
|
|
45
|
+
export function fromTimestamp(value) {
|
|
46
|
+
if (value === null || value === void 0 || Number.isNaN(value)) return null;
|
|
47
|
+
return fromDate(new Date(value));
|
|
48
|
+
}
|
|
49
|
+
export function fromUnixTimestamp(value) {
|
|
50
|
+
if (value === null || value === void 0 || Number.isNaN(value)) return null;
|
|
51
|
+
return fromTimestamp(value * 1e3);
|
|
52
|
+
}
|
|
53
|
+
export function fromFormat(value, format, timeZone) {
|
|
54
|
+
if (value === null || value === void 0) return null;
|
|
55
|
+
switch (format) {
|
|
56
|
+
case "date-value":
|
|
57
|
+
return isDateValue(value) ? value : null;
|
|
58
|
+
case "iso":
|
|
59
|
+
return typeof value === "string" && value ? parseISO(value, timeZone) : null;
|
|
60
|
+
case "timestamp":
|
|
61
|
+
return typeof value === "number" ? fromTimestamp(value) : null;
|
|
62
|
+
case "unix":
|
|
63
|
+
return typeof value === "number" ? fromUnixTimestamp(value) : null;
|
|
64
|
+
case "date":
|
|
65
|
+
return value instanceof Date ? fromDate(value) : null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function convertData(data, converter) {
|
|
69
|
+
if (!data) return data;
|
|
70
|
+
if (isDateValue(data)) return converter(data);
|
|
71
|
+
if (isDateRange(data)) {
|
|
72
|
+
const range = data;
|
|
73
|
+
return {
|
|
74
|
+
start: range.start ? converter(range.start) : range.start,
|
|
75
|
+
end: range.end ? converter(range.end) : range.end
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(data)) return data.map((item) => convertData(item, converter));
|
|
79
|
+
if (isPlainObject(data)) {
|
|
80
|
+
return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, convertData(value, converter)]));
|
|
81
|
+
}
|
|
82
|
+
return data;
|
|
83
|
+
}
|
|
84
|
+
export function convertFromFormat(data, format, timeZone) {
|
|
85
|
+
if (data === null || data === void 0 || format === "date-value") return data;
|
|
86
|
+
if (Array.isArray(data)) return data.map((item) => convertFromFormat(item, format, timeZone));
|
|
87
|
+
if (isDateRange(data)) {
|
|
88
|
+
const { start, end } = data;
|
|
89
|
+
const decode = (value) => value === void 0 || value === null ? value : fromFormat(value, format, timeZone);
|
|
90
|
+
return { start: decode(start), end: decode(end) };
|
|
91
|
+
}
|
|
92
|
+
return fromFormat(data, format, timeZone);
|
|
93
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DateValue } from '@internationalized/date';
|
|
2
|
+
import type { DateRange } from 'reka-ui';
|
|
3
|
+
/** 执行可能抛错的转换,失败时返回 fallback */
|
|
4
|
+
export declare function safe<T>(fn: () => T, fallback: T): T;
|
|
5
|
+
/** 判断是否为 @internationalized/date 的日期对象(CalendarDate / CalendarDateTime / ZonedDateTime) */
|
|
6
|
+
export declare function isDateValue(value: unknown): value is DateValue;
|
|
7
|
+
/** 判断是否为 `{ start, end }` 形态的日期范围 */
|
|
8
|
+
export declare function isDateRange(value: unknown): value is DateRange;
|
|
9
|
+
/** 仅普通对象与数组参与递归转换,Date、类实例等原样保留 */
|
|
10
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function safe(fn, fallback) {
|
|
2
|
+
try {
|
|
3
|
+
return fn();
|
|
4
|
+
} catch {
|
|
5
|
+
return fallback;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export function isDateValue(value) {
|
|
9
|
+
return value !== null && typeof value === "object" && "calendar" in value && "year" in value && "month" in value && "day" in value;
|
|
10
|
+
}
|
|
11
|
+
export function isDateRange(value) {
|
|
12
|
+
return value !== null && typeof value === "object" && "start" in value && "end" in value;
|
|
13
|
+
}
|
|
14
|
+
export function isPlainObject(value) {
|
|
15
|
+
if (value === null || typeof value !== "object") return false;
|
|
16
|
+
const proto = Object.getPrototypeOf(value);
|
|
17
|
+
return proto === Object.prototype || proto === null;
|
|
18
|
+
}
|
|
@@ -5,6 +5,7 @@ export function useExtendedTv(parentTheme, movkTheme, getOverride = () => ({}),
|
|
|
5
5
|
const emptySlots = Object.fromEntries(
|
|
6
6
|
Object.keys(parentTheme.slots).map((key) => [key, ""])
|
|
7
7
|
);
|
|
8
|
+
const movkTv = tv(movkTheme);
|
|
8
9
|
const extendUi = computed(() => {
|
|
9
10
|
const ov = getOverride() ?? {};
|
|
10
11
|
const { ui: uiOverride, variants } = getParams();
|
|
@@ -13,7 +14,7 @@ export function useExtendedTv(parentTheme, movkTheme, getOverride = () => ({}),
|
|
|
13
14
|
...ov.variants ? { variants: ov.variants } : {},
|
|
14
15
|
...ov.compoundVariants ? { compoundVariants: ov.compoundVariants } : {},
|
|
15
16
|
...ov.defaultVariants ? { defaultVariants: ov.defaultVariants } : {},
|
|
16
|
-
extend:
|
|
17
|
+
extend: movkTv
|
|
17
18
|
});
|
|
18
19
|
const cls = tvFn(variants);
|
|
19
20
|
const slotKeys = new Set(Object.keys(cls));
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import type { ComputedRef } from 'vue';
|
|
2
2
|
import { useFormField } from '@nuxt/ui/composables/useFormField';
|
|
3
3
|
import { useFieldGroup } from '@nuxt/ui/composables/useFieldGroup';
|
|
4
|
-
export declare function omitProps<T extends object, K extends keyof T>(props: T, keys: readonly K[]): Omit<T, K>;
|
|
5
|
-
export declare function useForwardedProps<T extends object, K extends keyof T>(props: T, keys: readonly K[]): ComputedRef<Omit<T, K>>;
|
|
6
|
-
type SizeProps = {
|
|
7
|
-
size?: unknown;
|
|
8
|
-
};
|
|
9
|
-
export declare function useFormFieldBridge<S = unknown, T extends SizeProps = SizeProps>(props?: T): {
|
|
10
|
-
size: ComputedRef<S | undefined>;
|
|
11
|
-
emitFormInput: () => void;
|
|
12
|
-
emitFormBlur: () => void;
|
|
13
|
-
emitFormChange: () => void;
|
|
14
|
-
emitFormFocus: () => void;
|
|
15
|
-
};
|
|
16
4
|
type FieldControlProps = {
|
|
17
5
|
size?: unknown;
|
|
18
6
|
color?: unknown;
|
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
import { computed
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
formFieldInjectionKey,
|
|
5
|
-
useFormField
|
|
6
|
-
} from "@nuxt/ui/composables/useFormField";
|
|
7
|
-
import { fieldGroupInjectionKey, useFieldGroup } from "@nuxt/ui/composables/useFieldGroup";
|
|
8
|
-
export function omitProps(props, keys) {
|
|
9
|
-
const omitted = new Set(keys);
|
|
10
|
-
return Object.fromEntries(
|
|
11
|
-
Object.entries(props).filter(([key, value]) => !omitted.has(key) && value !== void 0)
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
export function useForwardedProps(props, keys) {
|
|
15
|
-
return computed(() => omitProps(props, keys));
|
|
16
|
-
}
|
|
17
|
-
export function useFormFieldBridge(props) {
|
|
18
|
-
const formBus = inject(formBusInjectionKey, void 0);
|
|
19
|
-
const formField = inject(formFieldInjectionKey, void 0);
|
|
20
|
-
const fieldGroup = inject(fieldGroupInjectionKey, void 0);
|
|
21
|
-
function emitFormEvent(type) {
|
|
22
|
-
const field = formField?.value;
|
|
23
|
-
if (!formBus || !field?.name) return;
|
|
24
|
-
formBus.emit({
|
|
25
|
-
type,
|
|
26
|
-
name: field.name,
|
|
27
|
-
...type === "input" ? { eager: field.eagerValidation } : {}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
size: computed(
|
|
32
|
-
() => props?.size ?? fieldGroup?.value.size ?? formField?.value.size
|
|
33
|
-
),
|
|
34
|
-
emitFormInput: () => emitFormEvent("input"),
|
|
35
|
-
emitFormBlur: () => emitFormEvent("blur"),
|
|
36
|
-
emitFormChange: () => emitFormEvent("change"),
|
|
37
|
-
emitFormFocus: () => emitFormEvent("focus")
|
|
38
|
-
};
|
|
39
|
-
}
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useFormField } from "@nuxt/ui/composables/useFormField";
|
|
3
|
+
import { useFieldGroup } from "@nuxt/ui/composables/useFieldGroup";
|
|
40
4
|
export function useFieldControl(props) {
|
|
41
5
|
const formField = useFormField(props);
|
|
42
6
|
const fieldGroup = useFieldGroup(props);
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { Direction } from '@nuxt/ui';
|
|
2
2
|
import type { ModuleOptions } from '../../module';
|
|
3
|
+
/** movk 默认色板,Nuxt 模式 addTheme、Vue 模式 app-config 插件与 useTheme 共用 */
|
|
4
|
+
export declare const UI_COLOR_DEFAULTS: {
|
|
5
|
+
readonly primary: "blue";
|
|
6
|
+
readonly secondary: "blue";
|
|
7
|
+
readonly success: "green";
|
|
8
|
+
readonly info: "blue";
|
|
9
|
+
readonly warning: "yellow";
|
|
10
|
+
readonly error: "red";
|
|
11
|
+
readonly neutral: "slate";
|
|
12
|
+
};
|
|
3
13
|
/**
|
|
4
14
|
* movk 主题默认 app.config(Nuxt 模式 addTheme 与 Vue 模式 unplugin 共用)。
|
|
5
15
|
* 放在 runtime 内,避免 runtime 反向依赖构建期 `src/utils`(dist 运行时无法解析)。
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export const UI_COLOR_DEFAULTS = {
|
|
2
|
+
primary: "blue",
|
|
3
|
+
secondary: "blue",
|
|
4
|
+
success: "green",
|
|
5
|
+
info: "blue",
|
|
6
|
+
warning: "yellow",
|
|
7
|
+
error: "red",
|
|
8
|
+
neutral: "slate"
|
|
9
|
+
};
|
|
1
10
|
export function getDefaultConfig(theme) {
|
|
2
11
|
const pickerRadiuses = theme?.radiuses ?? [0, 0.125, 0.25, 0.375, 0.5];
|
|
3
12
|
const pickerNeutralColors = theme?.neutralColors ?? ["slate", "gray", "zinc", "neutral", "stone", "taupe", "mauve", "mist", "olive"];
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import type { TreeSelectionResult } from '../types/shared';
|
|
2
|
-
|
|
3
|
-
export type TreeSelectionStrategy = 'cascade' | 'isolated' | 'leaf';
|
|
4
|
-
/** 工具栏选中态摘要 */
|
|
5
|
-
export interface TreeSelectionSummary {
|
|
6
|
-
/** 已选节点数 */
|
|
7
|
-
checkedCount: number;
|
|
8
|
-
/** 可选节点总数 */
|
|
9
|
-
total: number;
|
|
10
|
-
/** 是否全部选中 */
|
|
11
|
-
allChecked: boolean;
|
|
12
|
-
/** 是否处于半选态 */
|
|
13
|
-
indeterminate: boolean;
|
|
14
|
-
}
|
|
1
|
+
import type { TreeSelectionResult, TreeSelectionStrategy, TreeSelectionSummary } from '../types/shared';
|
|
2
|
+
export type { TreeSelectionStrategy, TreeSelectionSummary };
|
|
15
3
|
/**
|
|
16
4
|
* 由已选数量与可选总数推导工具栏选中态摘要
|
|
17
5
|
*
|
|
@@ -34,4 +22,3 @@ interface SelectionOptions<T> {
|
|
|
34
22
|
* 通过 getKey / getChildren 适配不同数据形态。
|
|
35
23
|
*/
|
|
36
24
|
export declare function computeTreeSelection<T>(items: T[], selectedKeys: Iterable<string | number>, options: SelectionOptions<T>): TreeSelectionResult<T>;
|
|
37
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const tv: import("tailwind-variants").TV
|
|
1
|
+
export declare const tv: import("tailwind-variants").TV<import("tailwind-variants").TVConfig>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
import type { MovkZodRuntimeConfig } from '../../types/zod-config';
|
|
3
|
+
/** Vue 模式 zod 插件:`customError` 经 `app.use(movk, { zod: { customError } })` 传入 */
|
|
4
|
+
declare const _default: {
|
|
5
|
+
install(app: App, runtime?: MovkZodRuntimeConfig): void;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { zodLocales, zodOptions } from "#build/movk-zod";
|
|
2
|
+
import { installZod } from "../../domains/zod/apply.js";
|
|
3
|
+
import { ZOD_FORM_CONTEXT } from "../../domains/zod/sync.js";
|
|
4
|
+
export default {
|
|
5
|
+
install(app, runtime = {}) {
|
|
6
|
+
if (!zodOptions) return;
|
|
7
|
+
const options = zodOptions;
|
|
8
|
+
const locales = zodLocales;
|
|
9
|
+
installZod(options, locales);
|
|
10
|
+
app.provide(ZOD_FORM_CONTEXT, { options, locales, runtime });
|
|
11
|
+
}
|
|
12
|
+
};
|