@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
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { UPopover, UButton, UCalendar
|
|
3
|
-
import { computed, useAttrs } from "vue";
|
|
2
|
+
import { UPopover, UButton, UCalendar } from "#components";
|
|
3
|
+
import { computed, getCurrentInstance, ref, useAttrs } from "vue";
|
|
4
4
|
import { useAppConfig } from "#imports";
|
|
5
5
|
import { useDateFormatter } from "../composables/useDateFormatter";
|
|
6
6
|
import { useExtendedTv } from "../utils/extend-theme";
|
|
7
|
+
import { useMovkLocale } from "../composables/useMovkLocale";
|
|
7
8
|
import { useFieldControl } from "../utils/form-control";
|
|
9
|
+
import { useLocale } from "@nuxt/ui/composables/useLocale";
|
|
8
10
|
import theme from "#build/movk-ui/date-picker";
|
|
9
11
|
import popoverTheme from "#build/ui/popover";
|
|
10
12
|
const props = defineProps({
|
|
11
13
|
id: { type: String, required: false },
|
|
12
14
|
name: { type: String, required: false },
|
|
13
|
-
|
|
15
|
+
size: { type: null, required: false },
|
|
16
|
+
color: { type: null, required: false },
|
|
17
|
+
disabled: { type: Boolean, required: false },
|
|
18
|
+
placeholder: { type: String, required: false },
|
|
14
19
|
buttonProps: { type: Object, required: false },
|
|
15
20
|
popoverProps: { type: Object, required: false },
|
|
16
21
|
labelFormat: { type: [String, Function], required: false, default: "formatted" },
|
|
@@ -22,12 +27,26 @@ const props = defineProps({
|
|
|
22
27
|
formatOptions: { type: null, required: false },
|
|
23
28
|
timeZone: { type: String, required: false }
|
|
24
29
|
});
|
|
25
|
-
const emits = defineEmits(["close:prevent", "update:
|
|
30
|
+
const emits = defineEmits(["close:prevent", "update:placeholder", "update:startValue", "update:validModelValue", "update:modelValue"]);
|
|
26
31
|
defineSlots();
|
|
27
32
|
defineOptions({ inheritAttrs: false });
|
|
28
33
|
const attrs = useAttrs();
|
|
29
34
|
const modelValue = defineModel({ type: null });
|
|
35
|
+
const openModel = defineModel("open", { type: Boolean, skipCheck: true, ...{ default: void 0 } });
|
|
36
|
+
const instance = getCurrentInstance();
|
|
37
|
+
const localOpen = ref(props.popoverProps?.defaultOpen ?? false);
|
|
38
|
+
const open = computed({
|
|
39
|
+
get: () => {
|
|
40
|
+
const controlled = instance?.props.open;
|
|
41
|
+
return typeof controlled === "boolean" ? controlled : props.popoverProps?.open ?? localOpen.value;
|
|
42
|
+
},
|
|
43
|
+
set: (value) => {
|
|
44
|
+
localOpen.value = value;
|
|
45
|
+
openModel.value = value;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
30
48
|
const appConfig = useAppConfig();
|
|
49
|
+
const { t } = useMovkLocale();
|
|
31
50
|
const {
|
|
32
51
|
id,
|
|
33
52
|
name,
|
|
@@ -40,38 +59,49 @@ const {
|
|
|
40
59
|
emitFormFocus,
|
|
41
60
|
emitFormInput
|
|
42
61
|
} = useFieldControl(props);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
const { code: uiLocale } = useLocale();
|
|
63
|
+
const calendarType = computed(() => attrs.type ?? "date");
|
|
64
|
+
const TYPE_FORMAT_OPTIONS = {
|
|
65
|
+
month: { year: "numeric", month: "long" },
|
|
66
|
+
year: { year: "numeric" }
|
|
67
|
+
};
|
|
68
|
+
const formatterRef = computed(() => useDateFormatter({
|
|
69
|
+
locale: props.locale ?? uiLocale.value,
|
|
70
|
+
formatOptions: props.formatOptions ?? TYPE_FORMAT_OPTIONS[calendarType.value],
|
|
46
71
|
timeZone: props.timeZone
|
|
47
|
-
});
|
|
72
|
+
}));
|
|
48
73
|
const asModel = (v) => v;
|
|
49
74
|
const isOn = (v) => v === "" || v === true || v === "true";
|
|
50
75
|
const valueFormat = computed(() => props.valueFormat ?? "date-value");
|
|
51
76
|
const isRange = computed(() => isOn(attrs.range));
|
|
52
77
|
const isMultiple = computed(() => isOn(attrs.multiple));
|
|
53
78
|
const calendarValue = computed({
|
|
54
|
-
get: () =>
|
|
79
|
+
get: () => formatterRef.value.convertFromFormat(modelValue.value, valueFormat.value),
|
|
55
80
|
set: (next) => {
|
|
56
|
-
modelValue.value =
|
|
81
|
+
modelValue.value = formatterRef.value.convertToFormat(next, valueFormat.value);
|
|
57
82
|
emitFormInput();
|
|
58
83
|
emitFormChange();
|
|
59
84
|
}
|
|
60
85
|
});
|
|
61
|
-
const emptyLabel = computed(() => props.placeholder
|
|
86
|
+
const emptyLabel = computed(() => props.placeholder ?? props.buttonProps?.label ?? t("datePicker.placeholder"));
|
|
62
87
|
const fromNumber = (n) => n === null ? "" : String(n);
|
|
63
|
-
const converters = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
88
|
+
const converters = computed(() => {
|
|
89
|
+
const formatter = formatterRef.value;
|
|
90
|
+
return {
|
|
91
|
+
iso: formatter.toISO,
|
|
92
|
+
formatted: formatter.format,
|
|
93
|
+
// 纯日期的 toDate 为 UTC 午夜,须按 UTC 展示,否则负时区会显示为前一天
|
|
94
|
+
date: (d) => formatter.toDate(d)?.toLocaleDateString(formatter.locale, { timeZone: "hour" in d ? formatter.timeZone : "UTC" }) ?? "",
|
|
95
|
+
timestamp: (d) => fromNumber(formatter.toTimestamp(d)),
|
|
96
|
+
unix: (d) => fromNumber(formatter.toUnixTimestamp(d))
|
|
97
|
+
};
|
|
98
|
+
});
|
|
70
99
|
const formattedDate = computed(() => {
|
|
100
|
+
const formatter = formatterRef.value;
|
|
71
101
|
const value = calendarValue.value;
|
|
72
102
|
if (typeof props.labelFormat === "function") return props.labelFormat(formatter, value);
|
|
73
103
|
if (!value) return emptyLabel.value;
|
|
74
|
-
const convert = converters[props.labelFormat] ?? formatter.format;
|
|
104
|
+
const convert = converters.value[props.labelFormat] ?? formatter.format;
|
|
75
105
|
if (Array.isArray(value)) {
|
|
76
106
|
return value.length === 0 ? emptyLabel.value : value.map(convert).join(", ");
|
|
77
107
|
}
|
|
@@ -85,40 +115,43 @@ const hasValue = computed(() => {
|
|
|
85
115
|
const value = calendarValue.value;
|
|
86
116
|
if (value === void 0 || value === null) return false;
|
|
87
117
|
if (Array.isArray(value)) return value.length > 0;
|
|
88
|
-
if (
|
|
118
|
+
if (formatterRef.value.isDateRange(value)) return !!value.start || !!value.end;
|
|
89
119
|
return true;
|
|
90
120
|
});
|
|
121
|
+
const calendarAttrs = computed(() => {
|
|
122
|
+
const { class: _class, style: _style, ...rest } = attrs;
|
|
123
|
+
return rest;
|
|
124
|
+
});
|
|
91
125
|
const triggerButtonAttrs = computed(() => ({
|
|
92
126
|
color: color.value === "error" ? "error" : "neutral",
|
|
93
127
|
variant: "subtle",
|
|
94
|
-
icon: "i-lucide-calendar",
|
|
128
|
+
icon: appConfig.ui?.icons?.calendar ?? "i-lucide-calendar",
|
|
95
129
|
size: effectiveSize.value,
|
|
96
|
-
label: formattedDate.value,
|
|
97
130
|
disabled: effectiveDisabled.value,
|
|
98
|
-
|
|
99
|
-
|
|
131
|
+
...props.buttonProps,
|
|
132
|
+
label: formattedDate.value,
|
|
133
|
+
class: ["w-full", attrs.class, props.buttonProps?.class]
|
|
100
134
|
}));
|
|
101
135
|
function handleClear(event) {
|
|
102
136
|
event.stopPropagation();
|
|
103
|
-
|
|
104
|
-
else if (isMultiple.value) calendarValue.value = asModel([]);
|
|
105
|
-
else calendarValue.value = asModel(void 0);
|
|
137
|
+
calendarValue.value = asModel(isMultiple.value ? [] : void 0);
|
|
106
138
|
}
|
|
107
139
|
function buildDefaultPresets() {
|
|
108
|
-
|
|
140
|
+
if (calendarType.value !== "date") return [];
|
|
141
|
+
const today = formatterRef.value.getToday();
|
|
109
142
|
const range = (start, end) => asModel({ start, end });
|
|
110
143
|
if (isRange.value) return [
|
|
111
|
-
{ label: "
|
|
112
|
-
{ label: "
|
|
113
|
-
{ label: "
|
|
114
|
-
{ label: "
|
|
115
|
-
{ label: "
|
|
144
|
+
{ label: t("datePicker.today"), value: () => range(today, today) },
|
|
145
|
+
{ label: t("datePicker.thisWeek"), value: (f) => range(f.getStartOfWeek(today), f.getEndOfWeek(today)) },
|
|
146
|
+
{ label: t("datePicker.thisMonth"), value: (f) => range(f.getStartOfMonth(today), f.getEndOfMonth(today)) },
|
|
147
|
+
{ label: t("datePicker.last7Days"), value: () => range(today.subtract({ days: 6 }), today) },
|
|
148
|
+
{ label: t("datePicker.last30Days"), value: () => range(today.subtract({ days: 29 }), today) }
|
|
116
149
|
];
|
|
117
150
|
if (isMultiple.value) return [];
|
|
118
151
|
return [
|
|
119
|
-
{ label: "
|
|
120
|
-
{ label: "
|
|
121
|
-
{ label: "
|
|
152
|
+
{ label: t("datePicker.today"), value: () => asModel(today) },
|
|
153
|
+
{ label: t("datePicker.yesterday"), value: () => asModel(today.subtract({ days: 1 })) },
|
|
154
|
+
{ label: t("datePicker.tomorrow"), value: () => asModel(today.add({ days: 1 })) }
|
|
122
155
|
];
|
|
123
156
|
}
|
|
124
157
|
const resolvedPresets = computed(() => {
|
|
@@ -127,9 +160,17 @@ const resolvedPresets = computed(() => {
|
|
|
127
160
|
return props.presets;
|
|
128
161
|
});
|
|
129
162
|
function applyPreset(preset) {
|
|
130
|
-
const value = typeof preset.value === "function" ? preset.value(
|
|
163
|
+
const value = typeof preset.value === "function" ? preset.value(formatterRef.value) : preset.value;
|
|
131
164
|
calendarValue.value = value;
|
|
132
165
|
}
|
|
166
|
+
defineExpose({
|
|
167
|
+
open: () => {
|
|
168
|
+
open.value = true;
|
|
169
|
+
},
|
|
170
|
+
close: () => {
|
|
171
|
+
open.value = false;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
133
174
|
const { baseUi, extraUi } = useExtendedTv(
|
|
134
175
|
popoverTheme,
|
|
135
176
|
theme,
|
|
@@ -144,9 +185,9 @@ const { baseUi, extraUi } = useExtendedTv(
|
|
|
144
185
|
<template>
|
|
145
186
|
<UPopover
|
|
146
187
|
v-bind="popoverProps"
|
|
188
|
+
v-model:open="open"
|
|
147
189
|
:ui="baseUi"
|
|
148
190
|
@close:prevent="emits('close:prevent')"
|
|
149
|
-
@update:open="emits('update:open', $event)"
|
|
150
191
|
>
|
|
151
192
|
<template #default="defaultSlotProps">
|
|
152
193
|
<slot v-bind="defaultSlotProps">
|
|
@@ -154,6 +195,7 @@ const { baseUi, extraUi } = useExtendedTv(
|
|
|
154
195
|
:id="id"
|
|
155
196
|
:name="name"
|
|
156
197
|
v-bind="{ ...triggerButtonAttrs, ...ariaAttrs }"
|
|
198
|
+
:style="attrs.style"
|
|
157
199
|
@blur="emitFormBlur"
|
|
158
200
|
@focus="emitFormFocus"
|
|
159
201
|
>
|
|
@@ -163,8 +205,16 @@ const { baseUi, extraUi } = useExtendedTv(
|
|
|
163
205
|
<template v-if="$slots.trailing" #trailing="trailing">
|
|
164
206
|
<slot name="trailing" v-bind="trailing" />
|
|
165
207
|
</template>
|
|
166
|
-
<template v-else-if="clearable && hasValue" #trailing>
|
|
167
|
-
<
|
|
208
|
+
<template v-else-if="clearable && hasValue && !effectiveDisabled" #trailing>
|
|
209
|
+
<UButton
|
|
210
|
+
:icon="appConfig.ui?.icons?.close ?? 'i-lucide-x'"
|
|
211
|
+
color="neutral"
|
|
212
|
+
variant="link"
|
|
213
|
+
size="xs"
|
|
214
|
+
:aria-label="t('datePicker.clear')"
|
|
215
|
+
:class="extraUi.clearIcon"
|
|
216
|
+
@click="handleClear"
|
|
217
|
+
/>
|
|
168
218
|
</template>
|
|
169
219
|
</UButton>
|
|
170
220
|
</slot>
|
|
@@ -174,8 +224,8 @@ const { baseUi, extraUi } = useExtendedTv(
|
|
|
174
224
|
<div :class="extraUi.wrapper">
|
|
175
225
|
<div v-if="resolvedPresets.length" :class="extraUi.presets">
|
|
176
226
|
<UButton
|
|
177
|
-
v-for="preset in resolvedPresets"
|
|
178
|
-
:key="
|
|
227
|
+
v-for="(preset, index) in resolvedPresets"
|
|
228
|
+
:key="index"
|
|
179
229
|
:label="preset.label"
|
|
180
230
|
size="sm"
|
|
181
231
|
color="neutral"
|
|
@@ -187,7 +237,10 @@ const { baseUi, extraUi } = useExtendedTv(
|
|
|
187
237
|
<UCalendar
|
|
188
238
|
v-model="calendarValue"
|
|
189
239
|
:class="extraUi.calendar"
|
|
190
|
-
v-bind="
|
|
240
|
+
v-bind="calendarAttrs"
|
|
241
|
+
:locale="props.locale"
|
|
242
|
+
:size="effectiveSize"
|
|
243
|
+
:color="props.color"
|
|
191
244
|
:disabled="effectiveDisabled"
|
|
192
245
|
@update:placeholder="(e) => emits('update:placeholder', e)"
|
|
193
246
|
@update:start-value="emits('update:startValue', $event)"
|
|
@@ -4,26 +4,27 @@ import type { DateValue } from '@internationalized/date';
|
|
|
4
4
|
import type { ValueFormat } from '../composables/useDateFormatter';
|
|
5
5
|
import theme from '#build/movk-ui/date-picker';
|
|
6
6
|
import popoverTheme from '#build/ui/popover';
|
|
7
|
-
import type { DatePickerProps, DatePickerSlots, FormattedValue } from '../types/components/date-picker';
|
|
7
|
+
import type { DatePickerExposed, DatePickerProps, DatePickerSlots, FormattedValue } from '../types/components/date-picker';
|
|
8
8
|
declare const __VLS_export: <R extends boolean, M extends boolean, P extends "click" | "hover", V extends ValueFormat = "date-value">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
9
9
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<(DatePickerProps<R, M, P, V> & {
|
|
10
10
|
ui?: ComponentConfig<typeof popoverTheme & typeof theme, AppConfig, "datePicker">["slots"];
|
|
11
11
|
} & {
|
|
12
12
|
modelValue?: FormattedValue<R, M, V>;
|
|
13
|
+
open?: boolean | undefined;
|
|
13
14
|
}) & {
|
|
15
|
+
"onUpdate:open"?: ((value: boolean | undefined) => any) | undefined;
|
|
16
|
+
"onClose:prevent"?: (() => any) | undefined;
|
|
14
17
|
"onUpdate:modelValue"?: ((value: FormattedValue<R, M, V> | undefined) => any) | undefined;
|
|
15
18
|
"onUpdate:placeholder"?: ((date: DateValue) => any) | undefined;
|
|
16
19
|
"onUpdate:validModelValue"?: ((date: import("reka-ui").DateRange) => any) | undefined;
|
|
17
20
|
"onUpdate:startValue"?: ((date: DateValue | undefined) => any) | undefined;
|
|
18
|
-
"onClose:prevent"?: (() => any) | undefined;
|
|
19
|
-
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
20
21
|
}> & (typeof globalThis extends {
|
|
21
22
|
__VLS_PROPS_FALLBACK: infer P_1;
|
|
22
23
|
} ? P_1 : {});
|
|
23
|
-
expose: (exposed:
|
|
24
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<DatePickerExposed>) => void;
|
|
24
25
|
attrs: any;
|
|
25
26
|
slots: DatePickerSlots<P>;
|
|
26
|
-
emit: (((evt: "update:modelValue", value: FormattedValue<R, M, V>) => void) & ((evt: "update:placeholder", date: DateValue) => void) & ((evt: "update:validModelValue", date: import("reka-ui").DateRange) => void) & ((evt: "update:startValue", date: DateValue | undefined) => void) & ((
|
|
27
|
+
emit: (((evt: "close:prevent") => void) & ((evt: "update:modelValue", value: FormattedValue<R, M, V>) => void) & ((evt: "update:placeholder", date: DateValue) => void) & ((evt: "update:validModelValue", date: import("reka-ui").DateRange) => void) & ((evt: "update:startValue", date: DateValue | undefined) => void)) & (((event: "update:open", value: boolean | undefined) => void) & ((event: "update:modelValue", value: FormattedValue<R, M, V> | undefined) => void));
|
|
27
28
|
}>) => import("vue").VNode & {
|
|
28
29
|
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
29
30
|
};
|
|
@@ -20,11 +20,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
20
20
|
"onUpdate:open"?: ((value: boolean | undefined) => any) | undefined;
|
|
21
21
|
}>, {
|
|
22
22
|
type: "primary" | "info" | "success" | "warning" | "error" | "neutral";
|
|
23
|
-
|
|
24
|
-
mode: "alert" | "confirm";
|
|
25
|
-
alertConfirmLabel: string;
|
|
26
|
-
confirmLabel: string;
|
|
27
|
-
cancelLabel: string;
|
|
23
|
+
mode: "confirm" | "alert";
|
|
28
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
29
25
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
30
26
|
declare const _default: typeof __VLS_export;
|
|
@@ -3,17 +3,18 @@ import { computed, ref, useAttrs } from "vue";
|
|
|
3
3
|
import { UModal, UButton, UIcon } from "#components";
|
|
4
4
|
import { useAppConfig } from "#imports";
|
|
5
5
|
import { useExtendedTv } from "../utils/extend-theme";
|
|
6
|
+
import { useMovkLocale } from "../composables/useMovkLocale";
|
|
6
7
|
import theme from "#build/movk-ui/message-box";
|
|
7
8
|
import modalTheme from "#build/ui/modal";
|
|
8
9
|
const props = defineProps({
|
|
9
|
-
title: { type: String, required: false
|
|
10
|
+
title: { type: String, required: false },
|
|
10
11
|
type: { type: String, required: false, default: "primary" },
|
|
11
12
|
icon: { type: null, required: false },
|
|
12
13
|
mode: { type: String, required: false, default: "alert" },
|
|
13
14
|
dismissible: { type: Boolean, required: false },
|
|
14
|
-
alertConfirmLabel: { type: String, required: false
|
|
15
|
-
confirmLabel: { type: String, required: false
|
|
16
|
-
cancelLabel: { type: String, required: false
|
|
15
|
+
alertConfirmLabel: { type: String, required: false },
|
|
16
|
+
confirmLabel: { type: String, required: false },
|
|
17
|
+
cancelLabel: { type: String, required: false },
|
|
17
18
|
confirmButton: { type: Object, required: false },
|
|
18
19
|
cancelButton: { type: Object, required: false },
|
|
19
20
|
ui: { type: Object, required: false }
|
|
@@ -24,6 +25,7 @@ defineSlots();
|
|
|
24
25
|
defineOptions({ inheritAttrs: false });
|
|
25
26
|
const attrs = useAttrs();
|
|
26
27
|
const appConfig = useAppConfig();
|
|
28
|
+
const { t } = useMovkLocale();
|
|
27
29
|
const iconMap = {
|
|
28
30
|
primary: "i-lucide-bell",
|
|
29
31
|
info: "i-lucide-info",
|
|
@@ -36,12 +38,12 @@ const resolvedIcon = computed(() => props.icon ?? iconMap[props.type]);
|
|
|
36
38
|
const cancelButtonAttrs = computed(() => ({
|
|
37
39
|
color: "neutral",
|
|
38
40
|
variant: "outline",
|
|
39
|
-
label: props.cancelLabel,
|
|
41
|
+
label: props.cancelLabel ?? t("messageBox.cancel"),
|
|
40
42
|
...props.cancelButton ?? {}
|
|
41
43
|
}));
|
|
42
44
|
const confirmButtonAttrs = computed(() => ({
|
|
43
45
|
color: props.type,
|
|
44
|
-
label: props.mode === "alert" ? props.alertConfirmLabel : props.confirmLabel,
|
|
46
|
+
label: props.mode === "alert" ? props.alertConfirmLabel ?? t("messageBox.acknowledge") : props.confirmLabel ?? t("messageBox.confirm"),
|
|
45
47
|
...props.confirmButton ?? {}
|
|
46
48
|
}));
|
|
47
49
|
const closingFromButton = ref(false);
|
|
@@ -83,7 +85,7 @@ const { baseUi, extraUi } = useExtendedTv(
|
|
|
83
85
|
<template #title="slotProps">
|
|
84
86
|
<slot name="title" v-bind="slotProps">
|
|
85
87
|
<UIcon :name="resolvedIcon" :class="extraUi.icon" />
|
|
86
|
-
<span>{{ props.title }}</span>
|
|
88
|
+
<span>{{ props.title ?? t("messageBox.title") }}</span>
|
|
87
89
|
</slot>
|
|
88
90
|
</template>
|
|
89
91
|
|
|
@@ -20,11 +20,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
20
20
|
"onUpdate:open"?: ((value: boolean | undefined) => any) | undefined;
|
|
21
21
|
}>, {
|
|
22
22
|
type: "primary" | "info" | "success" | "warning" | "error" | "neutral";
|
|
23
|
-
|
|
24
|
-
mode: "alert" | "confirm";
|
|
25
|
-
alertConfirmLabel: string;
|
|
26
|
-
confirmLabel: string;
|
|
27
|
-
cancelLabel: string;
|
|
23
|
+
mode: "confirm" | "alert";
|
|
28
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
29
25
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
30
26
|
declare const _default: typeof __VLS_export;
|
|
@@ -8,7 +8,7 @@ declare const __VLS_export: <S extends z.ZodObject>(__VLS_props: NonNullable<Awa
|
|
|
8
8
|
ui?: ComponentConfig<typeof theme, AppConfig, "searchForm">["slots"];
|
|
9
9
|
} & {
|
|
10
10
|
modelValue?: Partial<InferInput<S>>;
|
|
11
|
-
expanded?: boolean;
|
|
11
|
+
expanded?: boolean | undefined;
|
|
12
12
|
}) & {
|
|
13
13
|
onError?: ((event: import("@nuxt/ui").FormErrorEvent) => any) | undefined;
|
|
14
14
|
onClear?: ((state: Partial<InferInput<S>>) => any) | undefined;
|
|
@@ -16,21 +16,29 @@ declare const __VLS_export: <S extends z.ZodObject>(__VLS_props: NonNullable<Awa
|
|
|
16
16
|
"onUpdate:modelValue"?: ((value: Partial<InferInput<S>>) => any) | undefined;
|
|
17
17
|
onExpand?: ((expanded: boolean) => any) | undefined;
|
|
18
18
|
"onUpdate:expanded"?: ((value: boolean | undefined) => any) | undefined;
|
|
19
|
+
"onQuery-restore"?: ((state: Partial<InferInput<S>>) => any) | undefined;
|
|
19
20
|
}> & (typeof globalThis extends {
|
|
20
21
|
__VLS_PROPS_FALLBACK: infer P;
|
|
21
22
|
} ? P : {});
|
|
22
23
|
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
23
24
|
formRef: Readonly<import("vue").ShallowRef<any, any>>;
|
|
24
|
-
submit: () =>
|
|
25
|
+
submit: () => Promise<any>;
|
|
26
|
+
validate: any;
|
|
25
27
|
reset: () => void;
|
|
26
28
|
clear: () => void;
|
|
27
|
-
setBaseline: (value?:
|
|
29
|
+
setBaseline: (value?: {
|
|
30
|
+
[x: string]: any;
|
|
31
|
+
}) => void;
|
|
32
|
+
isDirty: import("vue").ComputedRef<boolean>;
|
|
33
|
+
dirtyFields: import("vue").ComputedRef<string[]>;
|
|
34
|
+
getFieldValue: (path: string) => unknown;
|
|
35
|
+
setFieldValue: (path: string, value: unknown) => void;
|
|
28
36
|
expanded: import("vue").WritableComputedRef<boolean, boolean>;
|
|
29
37
|
toggle: () => void;
|
|
30
38
|
}>) => void;
|
|
31
39
|
attrs: any;
|
|
32
40
|
slots: SearchFormSlots<S>;
|
|
33
|
-
emit: (((evt: "error", event: import("@nuxt/ui").FormErrorEvent) => void) & ((evt: "clear", state: Partial<InferInput<S>>) => void) & ((evt: "reset", state: Partial<InferInput<S>>) => void) & ((evt: "expand", expanded: boolean) => void) & ((evt: "
|
|
41
|
+
emit: (((evt: "error", event: import("@nuxt/ui").FormErrorEvent) => void) & ((evt: "clear", state: Partial<InferInput<S>>) => void) & ((evt: "reset", state: Partial<InferInput<S>>) => void) & ((evt: "expand", expanded: boolean) => void) & ((evt: "query-restore", state: Partial<InferInput<S>>) => void)) & (((event: "update:modelValue", value: Partial<InferInput<S>>) => void) & ((event: "update:expanded", value: boolean | undefined) => void));
|
|
34
42
|
}>) => import("vue").VNode & {
|
|
35
43
|
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
36
44
|
};
|