@movk/nuxt 1.8.2 → 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 +21 -24
- 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 +9 -13
- 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 -12
- package/dist/runtime/domains/api/interceptors/response.js +34 -20
- 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 +12 -0
- package/dist/runtime/domains/api/session.js +9 -0
- 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.C7xx2FPO.mjs → nuxt.CbmfnBRt.mjs} +92 -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 +40 -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 -49
- package/dist/runtime/domains/api/transfer.d.ts +0 -69
- package/dist/runtime/domains/api/transfer.js +0 -82
- 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,52 +1,66 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { UButton, UCollapsible, UForm } from "#components";
|
|
3
|
-
import { computed,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { computed, ref, useAttrs, useTemplateRef, watch } from "vue";
|
|
4
|
+
import { useBreakpoints } from "@vueuse/core";
|
|
5
|
+
import { useAutoFormCore } from "../domains/auto-form/useAutoFormCore";
|
|
6
|
+
import { isLeafField } from "../domains/auto-form/fields";
|
|
7
|
+
import { AUTOFORM_META } from "../domains/auto-form/constants";
|
|
8
|
+
import { createDefaultSearchActions } from "../domains/auto-form/actions";
|
|
9
|
+
import { useMovkLocale } from "../composables/useMovkLocale";
|
|
10
10
|
import AutoFormRendererField from "../domains/auto-form/components/Field.vue";
|
|
11
11
|
import { useAppConfig } from "#imports";
|
|
12
|
+
import { cleanSearchPayload } from "../domains/auto-form/search-query";
|
|
13
|
+
import { useSearchQuerySync } from "../domains/auto-form/useSearchQuerySync";
|
|
12
14
|
import theme from "#build/movk-ui/search-form";
|
|
13
15
|
import { useExtendedTv } from "../utils/extend-theme";
|
|
16
|
+
const BREAKPOINTS = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
17
|
+
const BREAKPOINT_KEYS = Object.keys(BREAKPOINTS);
|
|
14
18
|
const props = defineProps({
|
|
19
|
+
syncQuery: { type: [Boolean, Object], required: false, default: false },
|
|
20
|
+
transformPayload: { type: [Boolean, Function], required: false, default: true },
|
|
15
21
|
cols: { type: [Number, Object], required: false, default: 3 },
|
|
16
22
|
visibleRows: { type: Number, required: false, default: 1 },
|
|
17
23
|
actions: { type: Array, required: false },
|
|
18
24
|
loading: { type: Boolean, required: false },
|
|
19
25
|
collapseButtonProps: { type: Object, required: false },
|
|
20
26
|
icon: { type: null, required: false, default: "i-lucide-chevron-down" },
|
|
21
|
-
expandText: { type: String, required: false
|
|
22
|
-
collapseText: { type: String, required: false
|
|
23
|
-
expanded: { type: Boolean, required: false },
|
|
27
|
+
expandText: { type: String, required: false },
|
|
28
|
+
collapseText: { type: String, required: false },
|
|
24
29
|
defaultExpanded: { type: Boolean, required: false, default: false },
|
|
25
30
|
schema: { type: null, required: true },
|
|
26
31
|
controls: { type: Object, required: false },
|
|
27
32
|
globalMeta: { type: Object, required: false },
|
|
28
33
|
loadingAuto: { type: Boolean, required: false, default: true },
|
|
29
34
|
validateOn: { type: Array, required: false, default: () => [] },
|
|
35
|
+
hiddenValue: { type: String, required: false },
|
|
36
|
+
onSubmit: { type: Function, required: false },
|
|
30
37
|
class: { type: [Array, String, null, Number, Boolean], required: false, skipCheck: true },
|
|
31
38
|
ui: { type: Object, required: false }
|
|
32
39
|
});
|
|
33
40
|
const modelValue = defineModel({ type: Object, ...{ default: () => ({}) } });
|
|
34
|
-
const expandedModel = defineModel("expanded", { type: Boolean });
|
|
35
|
-
const emits = defineEmits(["reset", "clear", "expand", "
|
|
41
|
+
const expandedModel = defineModel("expanded", { type: Boolean, skipCheck: true });
|
|
42
|
+
const emits = defineEmits(["reset", "clear", "expand", "query-restore", "error"]);
|
|
36
43
|
const slots = defineSlots();
|
|
37
44
|
defineOptions({ inheritAttrs: false });
|
|
38
45
|
const attrs = useAttrs();
|
|
39
|
-
|
|
46
|
+
const { t } = useMovkLocale();
|
|
40
47
|
const appConfig = useAppConfig();
|
|
41
48
|
const formRef = useTemplateRef("formRef");
|
|
42
|
-
const
|
|
49
|
+
const core = useAutoFormCore({
|
|
50
|
+
schema: () => props.schema,
|
|
51
|
+
controls: () => props.controls,
|
|
52
|
+
globalMeta: () => props.globalMeta,
|
|
53
|
+
hiddenValue: () => props.hiddenValue,
|
|
54
|
+
model: modelValue,
|
|
55
|
+
slots
|
|
56
|
+
});
|
|
57
|
+
const { validationSchema, resolvedButtonSize } = core;
|
|
58
|
+
const internalExpanded = ref(props.defaultExpanded);
|
|
43
59
|
const expanded = computed({
|
|
44
60
|
get: () => expandedModel.value ?? internalExpanded.value,
|
|
45
|
-
set: (
|
|
46
|
-
internalExpanded.value =
|
|
47
|
-
|
|
48
|
-
expandedModel.value = val;
|
|
49
|
-
}
|
|
61
|
+
set: (value) => {
|
|
62
|
+
internalExpanded.value = value;
|
|
63
|
+
expandedModel.value = value;
|
|
50
64
|
}
|
|
51
65
|
});
|
|
52
66
|
const { baseUi, extraUi } = useExtendedTv(
|
|
@@ -60,99 +74,111 @@ const { baseUi, extraUi } = useExtendedTv(
|
|
|
60
74
|
}
|
|
61
75
|
})
|
|
62
76
|
);
|
|
63
|
-
|
|
77
|
+
const activeBreakpoints = useBreakpoints(BREAKPOINTS, { ssrWidth: 0 }).current();
|
|
78
|
+
const currentCols = computed(() => {
|
|
79
|
+
const cols = props.cols;
|
|
64
80
|
if (typeof cols === "number") return cols;
|
|
65
81
|
if (!cols) return 1;
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
const base = cols.sm ?? cols.md ?? cols.lg ?? cols.xl ?? 1;
|
|
83
|
+
return activeBreakpoints.value.reduce((acc, key) => cols[key] ?? acc, base);
|
|
84
|
+
});
|
|
68
85
|
const gridStyle = computed(() => {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
vars["--m-search-cols"] = String(base);
|
|
76
|
-
if (c.sm !== void 0) vars["--m-search-cols-sm"] = String(c.sm);
|
|
77
|
-
if (c.md !== void 0) vars["--m-search-cols-md"] = String(c.md);
|
|
78
|
-
if (c.lg !== void 0) vars["--m-search-cols-lg"] = String(c.lg);
|
|
79
|
-
if (c.xl !== void 0) vars["--m-search-cols-xl"] = String(c.xl);
|
|
86
|
+
const cols = props.cols;
|
|
87
|
+
if (typeof cols === "number") return { "--m-search-cols": String(cols) };
|
|
88
|
+
if (!cols) return {};
|
|
89
|
+
const vars = { "--m-search-cols": String(cols.sm ?? cols.md ?? cols.lg ?? cols.xl ?? 1) };
|
|
90
|
+
for (const key of BREAKPOINT_KEYS) {
|
|
91
|
+
if (cols[key] !== void 0) vars[`--m-search-cols-${key}`] = String(cols[key]);
|
|
80
92
|
}
|
|
81
93
|
return vars;
|
|
82
94
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const size = props.globalMeta?.size;
|
|
86
|
-
if (size === void 0 || isFunction(size)) return void 0;
|
|
87
|
-
return unref(size);
|
|
88
|
-
});
|
|
89
|
-
const pureSchema = computed(() => extractPureSchema(props.schema));
|
|
90
|
-
const controlsMapping = computed(() => ({ ...DEFAULT_CONTROLS, ...props.controls }));
|
|
91
|
-
const fields = computed(() => introspectSchema(props.schema, controlsMapping.value, "", props.globalMeta));
|
|
92
|
-
const actionsBag = { toggle, search: submit, reset, clear };
|
|
93
|
-
function buildSlotProps(errors, loading) {
|
|
94
|
-
return {
|
|
95
|
-
...actionsBag,
|
|
96
|
-
expanded: expanded.value,
|
|
97
|
-
loading: props.loading || loading,
|
|
98
|
-
state: modelValue.value,
|
|
99
|
-
errors
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function resolveActions(slotCtx) {
|
|
103
|
-
const list = props.actions ?? DEFAULT_SEARCH_ACTIONS;
|
|
104
|
-
return list.filter((action) => {
|
|
105
|
-
if (action.visible === void 0) return true;
|
|
106
|
-
if (typeof action.visible === "function") {
|
|
107
|
-
return action.visible(slotCtx);
|
|
108
|
-
}
|
|
109
|
-
return action.visible;
|
|
110
|
-
});
|
|
95
|
+
function isSupportedField(field) {
|
|
96
|
+
return isLeafField(field) && field.meta?.type !== AUTOFORM_META.LAYOUT_KEY;
|
|
111
97
|
}
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
});
|
|
98
|
+
watch(core.fields, (fields) => {
|
|
99
|
+
const unsupported = fields.filter((field) => !isSupportedField(field)).map((field) => field.path);
|
|
100
|
+
if (import.meta.dev && unsupported.length) {
|
|
101
|
+
console.warn(`[SearchForm] Object, array and layout fields are not supported and will be skipped: ${unsupported.join(", ")}`);
|
|
102
|
+
}
|
|
103
|
+
}, { immediate: true });
|
|
104
|
+
const renderFields = computed(() => core.visibleFields.value.filter(isSupportedField));
|
|
105
|
+
const actionList = computed(() => props.actions ?? createDefaultSearchActions(t));
|
|
106
|
+
const showActionsCell = computed(() => actionList.value.length > 0 || !!slots.actions || !!slots.extraActions);
|
|
116
107
|
const visibleCount = computed(() => {
|
|
117
|
-
const total =
|
|
118
|
-
|
|
119
|
-
if (maxCols(props.cols) <= 1) return total;
|
|
120
|
-
return Math.max(0, total - 1);
|
|
108
|
+
const total = currentCols.value * props.visibleRows;
|
|
109
|
+
return showActionsCell.value && currentCols.value > 1 ? Math.max(0, total - 1) : total;
|
|
121
110
|
});
|
|
122
|
-
const visibleFields = computed(() =>
|
|
123
|
-
const collapsedFields = computed(() =>
|
|
111
|
+
const visibleFields = computed(() => renderFields.value.slice(0, visibleCount.value));
|
|
112
|
+
const collapsedFields = computed(() => renderFields.value.slice(visibleCount.value));
|
|
124
113
|
const needsCollapse = computed(() => collapsedFields.value.length > 0);
|
|
125
114
|
function toggle() {
|
|
126
|
-
|
|
127
|
-
expanded.value
|
|
128
|
-
emits("expand", next);
|
|
129
|
-
emits("update:expanded", next);
|
|
130
|
-
}
|
|
131
|
-
function submit() {
|
|
132
|
-
formRef.value?.submit();
|
|
115
|
+
expanded.value = !expanded.value;
|
|
116
|
+
emits("expand", expanded.value);
|
|
133
117
|
}
|
|
118
|
+
const submit = async () => formRef.value?.submit();
|
|
119
|
+
const validate = ((...args) => formRef.value?.validate(...args));
|
|
134
120
|
function buildFieldPayload(state) {
|
|
135
|
-
const keys = Object.keys(
|
|
136
|
-
return keys.
|
|
137
|
-
acc[key] = state[key];
|
|
138
|
-
return acc;
|
|
139
|
-
}, {});
|
|
121
|
+
const keys = Object.keys(core.pureSchema.value?.shape ?? {});
|
|
122
|
+
return Object.fromEntries(keys.map((key) => [key, state[key]]));
|
|
140
123
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
124
|
+
const syncQuery = useSearchQuerySync({
|
|
125
|
+
sync: () => props.syncQuery,
|
|
126
|
+
schema: () => core.pureSchema.value,
|
|
127
|
+
state: () => modelValue.value,
|
|
128
|
+
onRestore: (state) => {
|
|
129
|
+
formRef.value?.clear();
|
|
130
|
+
emits("query-restore", state);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
function writeQuery(state) {
|
|
134
|
+
syncQuery(state).catch((error) => console.error("[SearchForm] Failed to update the URL query.", error));
|
|
146
135
|
}
|
|
136
|
+
function applyTransform(data) {
|
|
137
|
+
const transform = props.transformPayload;
|
|
138
|
+
if (transform === false) return data;
|
|
139
|
+
return transform === true ? cleanSearchPayload(data) : transform(data);
|
|
140
|
+
}
|
|
141
|
+
const handleSubmit = ((event) => {
|
|
142
|
+
const data = applyTransform(event.data);
|
|
143
|
+
writeQuery(data);
|
|
144
|
+
return props.onSubmit?.({ ...event, data });
|
|
145
|
+
});
|
|
147
146
|
function reset() {
|
|
148
|
-
const next =
|
|
149
|
-
applyFieldDefaults(fields.value, next);
|
|
150
|
-
modelValue.value = next;
|
|
147
|
+
const next = core.reset();
|
|
151
148
|
formRef.value?.clear();
|
|
149
|
+
writeQuery(next);
|
|
152
150
|
emits("reset", buildFieldPayload(next));
|
|
153
151
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
152
|
+
function clear() {
|
|
153
|
+
const next = core.clear();
|
|
154
|
+
formRef.value?.clear();
|
|
155
|
+
writeQuery(next);
|
|
156
|
+
emits("clear", buildFieldPayload(next));
|
|
157
|
+
}
|
|
158
|
+
function buildSlotProps(errors, loading) {
|
|
159
|
+
return {
|
|
160
|
+
toggle,
|
|
161
|
+
search: submit,
|
|
162
|
+
reset,
|
|
163
|
+
clear,
|
|
164
|
+
expanded: expanded.value,
|
|
165
|
+
loading: props.loading || loading,
|
|
166
|
+
state: modelValue.value,
|
|
167
|
+
errors
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function resolveActions(ctx) {
|
|
171
|
+
return actionList.value.filter(({ visible }) => typeof visible === "function" ? visible(ctx) : visible !== false);
|
|
172
|
+
}
|
|
173
|
+
function actionButtonProps(action, ctx) {
|
|
174
|
+
const { key: _key, visible: _visible, onClick: _onClick, ...rest } = action;
|
|
175
|
+
const isSearch = action.key === "search" || action.type === "submit";
|
|
176
|
+
return {
|
|
177
|
+
size: resolvedButtonSize.value,
|
|
178
|
+
disabled: attrs.disabled,
|
|
179
|
+
...rest,
|
|
180
|
+
loading: isSearch ? ctx.loading : rest.loading
|
|
181
|
+
};
|
|
156
182
|
}
|
|
157
183
|
function handleAction(action, ctx) {
|
|
158
184
|
if (action.onClick) {
|
|
@@ -163,26 +189,18 @@ function handleAction(action, ctx) {
|
|
|
163
189
|
if (action.key === "reset") reset();
|
|
164
190
|
else if (action.key === "search") submit();
|
|
165
191
|
}
|
|
166
|
-
|
|
167
|
-
if (action.key === "search" || action.type === "submit") return ctx.loading;
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
watch(() => fields.value, () => {
|
|
171
|
-
applyFieldDefaults(fields.value, modelValue.value);
|
|
172
|
-
}, { flush: "post" });
|
|
173
|
-
watch(() => props.schema, () => {
|
|
174
|
-
formRef.value?.clear();
|
|
175
|
-
});
|
|
176
|
-
onMounted(() => {
|
|
177
|
-
applyFieldDefaults(fields.value, modelValue.value);
|
|
178
|
-
setBaseline();
|
|
179
|
-
});
|
|
192
|
+
watch(() => props.schema, () => formRef.value?.clear());
|
|
180
193
|
defineExpose({
|
|
181
194
|
formRef,
|
|
182
195
|
submit,
|
|
196
|
+
validate,
|
|
183
197
|
reset,
|
|
184
198
|
clear,
|
|
185
|
-
setBaseline,
|
|
199
|
+
setBaseline: core.setBaseline,
|
|
200
|
+
isDirty: core.isDirty,
|
|
201
|
+
dirtyFields: core.dirtyFields,
|
|
202
|
+
getFieldValue: core.getFieldValue,
|
|
203
|
+
setFieldValue: core.setFieldValue,
|
|
186
204
|
expanded,
|
|
187
205
|
toggle
|
|
188
206
|
});
|
|
@@ -193,12 +211,13 @@ defineExpose({
|
|
|
193
211
|
<UForm
|
|
194
212
|
ref="formRef"
|
|
195
213
|
:state="modelValue"
|
|
196
|
-
:schema="
|
|
214
|
+
:schema="validationSchema"
|
|
197
215
|
:loading-auto="props.loadingAuto"
|
|
198
216
|
:validate-on="props.validateOn"
|
|
199
217
|
:ui="baseUi"
|
|
200
218
|
data-slot="form"
|
|
201
219
|
v-bind="attrs"
|
|
220
|
+
:on-submit="handleSubmit"
|
|
202
221
|
@error="emits('error', $event)"
|
|
203
222
|
>
|
|
204
223
|
<template #default="{ errors, loading }">
|
|
@@ -212,7 +231,6 @@ defineExpose({
|
|
|
212
231
|
v-for="field in visibleFields"
|
|
213
232
|
:key="field.path"
|
|
214
233
|
:field="field"
|
|
215
|
-
:schema="props.schema"
|
|
216
234
|
:extra-props="{ errors, loading, state: modelValue }"
|
|
217
235
|
/>
|
|
218
236
|
|
|
@@ -224,14 +242,7 @@ defineExpose({
|
|
|
224
242
|
<div :class="extraUi.actions" data-slot="actions">
|
|
225
243
|
<template v-for="action in resolveActions(buildSlotProps(errors, loading))" :key="action.key">
|
|
226
244
|
<UButton
|
|
227
|
-
|
|
228
|
-
:type="action.type"
|
|
229
|
-
:icon="action.icon"
|
|
230
|
-
:color="action.color"
|
|
231
|
-
:variant="action.variant"
|
|
232
|
-
:loading="actionLoading(action, buildSlotProps(errors, loading))"
|
|
233
|
-
:size="resolvedButtonSize"
|
|
234
|
-
v-bind="action"
|
|
245
|
+
v-bind="actionButtonProps(action, buildSlotProps(errors, loading))"
|
|
235
246
|
@click="handleAction(action, buildSlotProps(errors, loading))"
|
|
236
247
|
/>
|
|
237
248
|
</template>
|
|
@@ -248,7 +259,6 @@ defineExpose({
|
|
|
248
259
|
v-for="field in collapsedFields"
|
|
249
260
|
:key="field.path"
|
|
250
261
|
:field="field"
|
|
251
|
-
:schema="props.schema"
|
|
252
262
|
:extra-props="{ errors, loading, state: modelValue }"
|
|
253
263
|
/>
|
|
254
264
|
</div>
|
|
@@ -262,7 +272,7 @@ defineExpose({
|
|
|
262
272
|
:size="resolvedButtonSize"
|
|
263
273
|
variant="ghost"
|
|
264
274
|
:data-state="expanded ? 'open' : 'closed'"
|
|
265
|
-
:label="expanded ? collapseText : expandText"
|
|
275
|
+
:label="expanded ? collapseText ?? t('searchForm.collapse') : expandText ?? t('searchForm.expand')"
|
|
266
276
|
tabindex="-1"
|
|
267
277
|
:class="extraUi.toggle"
|
|
268
278
|
v-bind="collapseButtonProps"
|
|
@@ -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
|
};
|
|
@@ -18,6 +18,8 @@ declare const __VLS_export: <T extends TreeItem[] = TreeItem[], M extends boolea
|
|
|
18
18
|
selection: import("../types").TreeSelectionResult<T[number]>;
|
|
19
19
|
}) => any) | undefined;
|
|
20
20
|
"onUpdate:modelValue"?: ((value: (M extends true ? T[number][] : T[number]) | undefined) => any) | undefined;
|
|
21
|
+
onLoadError?: ((node: T[number], error: unknown) => any) | undefined;
|
|
22
|
+
onSearchError?: ((term: string, error: unknown) => any) | undefined;
|
|
21
23
|
"onUpdate:expanded"?: ((val: string[]) => any) | undefined;
|
|
22
24
|
"onUpdate:search"?: ((value: string) => any) | undefined;
|
|
23
25
|
"onUpdate:selectedKeys"?: ((value: string[] | undefined) => any) | undefined;
|
|
@@ -31,7 +33,7 @@ declare const __VLS_export: <T extends TreeItem[] = TreeItem[], M extends boolea
|
|
|
31
33
|
value: (M extends true ? T[number][] : T[number]) | undefined;
|
|
32
34
|
keys: string[];
|
|
33
35
|
selection: import("../types").TreeSelectionResult<T[number]>;
|
|
34
|
-
}) => void) & ((evt: "update:modelValue", val: M extends true ? T[number][] : T[number]) => void) & ((evt: "update:expanded", val: string[]) => void) & ((evt: "update:search", value: string) => void)) & (((event: "update:modelValue", value: (M extends true ? T[number][] : T[number]) | undefined) => void) & ((event: "update:expanded", value: string[]) => void) & ((event: "update:search", value: string) => void) & ((event: "update:selectedKeys", value: string[] | undefined) => void));
|
|
36
|
+
}) => void) & ((evt: "update:modelValue", val: M extends true ? T[number][] : T[number]) => void) & ((evt: "loadError", node: T[number], error: unknown) => void) & ((evt: "searchError", term: string, error: unknown) => void) & ((evt: "update:expanded", val: string[]) => void) & ((evt: "update:search", value: string) => void)) & (((event: "update:modelValue", value: (M extends true ? T[number][] : T[number]) | undefined) => void) & ((event: "update:expanded", value: string[]) => void) & ((event: "update:search", value: string) => void) & ((event: "update:selectedKeys", value: string[] | undefined) => void));
|
|
35
37
|
}>) => import("vue").VNode & {
|
|
36
38
|
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
37
39
|
};
|