@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,9 +1,9 @@
|
|
|
1
1
|
import { extractMessage } from "./response.js";
|
|
2
|
-
import {
|
|
3
|
-
function getToast() {
|
|
2
|
+
import { tryUseNuxtApp, useToast } from "#imports";
|
|
3
|
+
function getToast(nuxtApp = tryUseNuxtApp()) {
|
|
4
|
+
if (!nuxtApp) return null;
|
|
4
5
|
try {
|
|
5
|
-
|
|
6
|
-
return nuxtApp.vueApp.runWithContext(() => useToast());
|
|
6
|
+
return nuxtApp.runWithContext(() => useToast());
|
|
7
7
|
} catch {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
@@ -14,7 +14,7 @@ function pickMessage(type, source, requestOptions, responseConfig) {
|
|
|
14
14
|
if (custom) return custom;
|
|
15
15
|
}
|
|
16
16
|
if (typeof source === "string") return source;
|
|
17
|
-
if (
|
|
17
|
+
if (responseConfig) {
|
|
18
18
|
const extracted = extractMessage(source, responseConfig);
|
|
19
19
|
if (extracted) return extracted;
|
|
20
20
|
}
|
|
@@ -32,7 +32,7 @@ function compact(obj) {
|
|
|
32
32
|
}
|
|
33
33
|
return out;
|
|
34
34
|
}
|
|
35
|
-
export function showToast(type, source, requestOptions, globalConfig, responseConfig, method) {
|
|
35
|
+
export function showToast(type, source, requestOptions, globalConfig, responseConfig, method, nuxtApp) {
|
|
36
36
|
if (requestOptions === false) return;
|
|
37
37
|
const requestTypeOptions = requestOptions?.[type];
|
|
38
38
|
if (requestTypeOptions === false) return;
|
|
@@ -43,7 +43,7 @@ export function showToast(type, source, requestOptions, globalConfig, responseCo
|
|
|
43
43
|
if (requestShow === false || requestShow === void 0 && !globalShow && !hasRequestMessage) return;
|
|
44
44
|
const message = pickMessage(type, source, requestOptions, responseConfig);
|
|
45
45
|
if (!message) return;
|
|
46
|
-
const toast = getToast();
|
|
46
|
+
const toast = getToast(nuxtApp);
|
|
47
47
|
if (!toast) return;
|
|
48
48
|
const { show: _show, methods: _methods, ...typeConfigProps } = typeConfig ?? {};
|
|
49
49
|
const { show: _requestShow, ...requestTypeConfig } = requestTypeOptions ?? {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { SearchFormAction } from '../../types/auto-form/search-form';
|
|
2
|
-
|
|
2
|
+
import type { MovkTranslator } from '../../composables/useMovkLocale';
|
|
3
|
+
export declare function createDefaultSearchActions(t: MovkTranslator): SearchFormAction[];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export function createDefaultSearchActions(t) {
|
|
2
|
+
return [
|
|
3
|
+
{ key: "search", label: t("searchForm.search"), icon: "i-lucide-search", type: "submit" },
|
|
4
|
+
{ key: "reset", label: t("searchForm.reset"), icon: "i-lucide-rotate-ccw", color: "neutral", variant: "outline" }
|
|
5
|
+
];
|
|
6
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function withoutAt(list, index) {
|
|
2
|
+
return [...list.slice(0, index), ...list.slice(index + 1)];
|
|
3
|
+
}
|
|
4
|
+
export function swapAt(list, a, b) {
|
|
5
|
+
return list.map((item, i) => i === a ? list[b] : i === b ? list[a] : item);
|
|
6
|
+
}
|
|
7
|
+
export function insertAfter(list, index, value) {
|
|
8
|
+
return [...list.slice(0, index + 1), value, ...list.slice(index + 1)];
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Ref, ShallowRef } from 'vue';
|
|
2
|
+
import type { AutoFormAsyncItems } from '../../types/auto-form/fields';
|
|
3
|
+
type FormState = Record<string, any>;
|
|
4
|
+
export interface AsyncItemsState {
|
|
5
|
+
items: ShallowRef<unknown[] | undefined>;
|
|
6
|
+
loading: Ref<boolean>;
|
|
7
|
+
error: ShallowRef<unknown>;
|
|
8
|
+
}
|
|
9
|
+
export declare function useAsyncItems(getConfig: () => AutoFormAsyncItems, getState: () => FormState): AsyncItemsState;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { onScopeDispose, ref, shallowRef, watch } from "vue";
|
|
2
|
+
export function useAsyncItems(getConfig, getState) {
|
|
3
|
+
const items = shallowRef();
|
|
4
|
+
const loading = ref(false);
|
|
5
|
+
const error = shallowRef();
|
|
6
|
+
let controller;
|
|
7
|
+
let timer;
|
|
8
|
+
async function run() {
|
|
9
|
+
controller?.abort();
|
|
10
|
+
const current = new AbortController();
|
|
11
|
+
controller = current;
|
|
12
|
+
loading.value = true;
|
|
13
|
+
try {
|
|
14
|
+
const result = await getConfig().load({ state: getState(), signal: current.signal });
|
|
15
|
+
if (current.signal.aborted) return;
|
|
16
|
+
items.value = result;
|
|
17
|
+
error.value = void 0;
|
|
18
|
+
} catch (cause) {
|
|
19
|
+
if (current.signal.aborted) return;
|
|
20
|
+
error.value = cause;
|
|
21
|
+
if (import.meta.dev) console.error("[AutoForm] asyncItems.load failed:", cause);
|
|
22
|
+
} finally {
|
|
23
|
+
if (controller === current) loading.value = false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function schedule() {
|
|
27
|
+
clearTimeout(timer);
|
|
28
|
+
const delay = getConfig().debounce ?? 0;
|
|
29
|
+
if (delay > 0) {
|
|
30
|
+
loading.value = true;
|
|
31
|
+
timer = setTimeout(run, delay);
|
|
32
|
+
} else {
|
|
33
|
+
run();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
watch(() => getConfig().deps?.(getState()), schedule, { immediate: true });
|
|
37
|
+
onScopeDispose(() => {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
controller?.abort();
|
|
40
|
+
});
|
|
41
|
+
return { items, loading, error };
|
|
42
|
+
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
import type { ButtonProps } from '@nuxt/ui';
|
|
3
1
|
import type { AutoFormField } from '../../../types/auto-form';
|
|
4
2
|
import type { AnyObject } from '@movk/core';
|
|
5
3
|
interface AutoFormRendererArrayProps {
|
|
6
|
-
schema: z.ZodObject;
|
|
7
4
|
field: AutoFormField;
|
|
8
5
|
extraProps?: AnyObject;
|
|
9
|
-
addButtonProps?: Partial<ButtonProps>;
|
|
10
6
|
}
|
|
11
7
|
declare const __VLS_export: import("vue").DefineComponent<AutoFormRendererArrayProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AutoFormRendererArrayProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
8
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,73 +1,96 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { UButton, UCollapsible } from "#components";
|
|
3
|
-
import { computed, ref } from "vue";
|
|
3
|
+
import { computed, ref, watch } from "vue";
|
|
4
4
|
import { useAutoFormInjector } from "../provider";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useMovkLocale } from "../../../composables/useMovkLocale";
|
|
6
|
+
import { deepClone, joinPath } from "@movk/core";
|
|
7
|
+
import { collectFieldDefaults, createHintSlotFactory, remapFieldPath } from "../fields";
|
|
8
|
+
import { getArrayLengthBounds } from "../schema";
|
|
9
|
+
import { insertAfter, swapAt, withoutAt } from "../array-ops";
|
|
7
10
|
import { VNodeRender } from "../reactive";
|
|
8
11
|
import AutoFormRendererField from "./Field.vue";
|
|
9
12
|
import AutoFormRendererNested from "./Nested.vue";
|
|
10
13
|
const props = defineProps({
|
|
11
|
-
schema: { type: null, required: true },
|
|
12
14
|
field: { type: Object, required: true },
|
|
13
|
-
extraProps: { type: Object, required: false }
|
|
14
|
-
addButtonProps: { type: Object, required: false }
|
|
15
|
+
extraProps: { type: Object, required: false }
|
|
15
16
|
});
|
|
16
|
-
const {
|
|
17
|
-
const
|
|
17
|
+
const { t } = useMovkLocale();
|
|
18
|
+
const { addButtonProps: formAddButtonProps, createCollapsibleEnhancer, createFieldContext, createSlotResolver, createSlotProps, resolveFieldProp } = useAutoFormInjector();
|
|
19
|
+
const context = computed(() => createFieldContext(props.field));
|
|
18
20
|
const slotResolver = computed(() => createSlotResolver(props.field, props.extraProps));
|
|
19
21
|
const slotProps = computed(() => createSlotProps(props.field, props.extraProps));
|
|
20
22
|
const elementTemplate = computed(() => props.field.arrayElement);
|
|
21
23
|
const isObjectElement = computed(() => elementTemplate.value?.meta.type === "object");
|
|
22
24
|
const arrayValue = computed(() => {
|
|
23
|
-
const value = context.value;
|
|
25
|
+
const value = context.value.value;
|
|
24
26
|
return Array.isArray(value) ? value : [];
|
|
25
27
|
});
|
|
28
|
+
let idCounter = 0;
|
|
26
29
|
const itemIds = ref([]);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const updatedField = {
|
|
43
|
-
...template,
|
|
44
|
-
path,
|
|
45
|
-
meta: {
|
|
46
|
-
...template.meta,
|
|
47
|
-
fieldSlots: isNested && !isObject ? {
|
|
48
|
-
...template.meta?.fieldSlots
|
|
49
|
-
} : {
|
|
50
|
-
hint: (props2) => hintSlotFactory(template, props2.path, props2.open, props2.count),
|
|
51
|
-
...template.meta?.fieldSlots
|
|
30
|
+
watch(() => arrayValue.value.length, (length) => {
|
|
31
|
+
const current = itemIds.value;
|
|
32
|
+
if (length === current.length) return;
|
|
33
|
+
itemIds.value = length < current.length ? current.slice(0, length) : [...current, ...Array.from({ length: length - current.length }, () => `${props.field.path}-${idCounter++}`)];
|
|
34
|
+
}, { immediate: true });
|
|
35
|
+
function withHintSlots(field, isItemRoot, hintSlotFactory) {
|
|
36
|
+
const isObject = field.meta?.type === "object";
|
|
37
|
+
const needsHint = isItemRoot || isObject;
|
|
38
|
+
return {
|
|
39
|
+
...field,
|
|
40
|
+
meta: needsHint ? {
|
|
41
|
+
...field.meta,
|
|
42
|
+
fieldSlots: {
|
|
43
|
+
hint: (slotProps2) => hintSlotFactory(field, isItemRoot, slotProps2.open, slotProps2.count),
|
|
44
|
+
...field.meta?.fieldSlots
|
|
52
45
|
}
|
|
53
|
-
}
|
|
46
|
+
} : field.meta,
|
|
47
|
+
...field.children && { children: field.children.map((child) => withHintSlots(child, false, hintSlotFactory)) }
|
|
54
48
|
};
|
|
55
|
-
if (template.children) {
|
|
56
|
-
updatedField.children = template.children.map(
|
|
57
|
-
(child) => updateFieldPaths(child, oldBasePath, newBasePath, hintSlotFactory)
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return updatedField;
|
|
61
49
|
}
|
|
50
|
+
const bounds = computed(() => getArrayLengthBounds(props.field.schema));
|
|
51
|
+
const canAdd = computed(() => arrayValue.value.length < bounds.value.max);
|
|
52
|
+
const canRemove = computed(() => arrayValue.value.length > bounds.value.min);
|
|
53
|
+
function setItems(next, ids) {
|
|
54
|
+
itemIds.value = ids;
|
|
55
|
+
context.value.setValue(next);
|
|
56
|
+
}
|
|
57
|
+
function removeItem(index) {
|
|
58
|
+
if (!canRemove.value) return;
|
|
59
|
+
setItems(withoutAt(arrayValue.value, index), withoutAt(itemIds.value, index));
|
|
60
|
+
}
|
|
61
|
+
function moveItem(index, offset) {
|
|
62
|
+
const target = index + offset;
|
|
63
|
+
if (target < 0 || target >= arrayValue.value.length) return;
|
|
64
|
+
setItems(swapAt(arrayValue.value, index, target), swapAt(itemIds.value, index, target));
|
|
65
|
+
}
|
|
66
|
+
function duplicateItem(index) {
|
|
67
|
+
if (!canAdd.value) return;
|
|
68
|
+
setItems(
|
|
69
|
+
insertAfter(arrayValue.value, index, deepClone(arrayValue.value[index])),
|
|
70
|
+
insertAfter(itemIds.value, index, `${props.field.path}-${idCounter++}`)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
const itemActions = computed(() => ({
|
|
74
|
+
remove: removeItem,
|
|
75
|
+
move: props.field.meta.sortable ? moveItem : void 0,
|
|
76
|
+
duplicate: props.field.meta.duplicable ? duplicateItem : void 0,
|
|
77
|
+
canRemove: () => canRemove.value,
|
|
78
|
+
canAdd: () => canAdd.value,
|
|
79
|
+
length: () => arrayValue.value.length,
|
|
80
|
+
labels: {
|
|
81
|
+
moveUp: t("autoForm.moveUp"),
|
|
82
|
+
moveDown: t("autoForm.moveDown"),
|
|
83
|
+
duplicate: t("autoForm.duplicate"),
|
|
84
|
+
remove: t("autoForm.remove")
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
62
87
|
const arrayItemFields = computed(() => {
|
|
63
88
|
const template = elementTemplate.value;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const newBasePath = joinPath([props.field.path, index]);
|
|
70
|
-
return updateFieldPaths(template, props.field.path, newBasePath, factory);
|
|
89
|
+
if (!template) return [];
|
|
90
|
+
const factory = createHintSlotFactory(itemActions.value);
|
|
91
|
+
return arrayValue.value.map((_, index) => {
|
|
92
|
+
const item = remapFieldPath(template, template.path, joinPath([props.field.path, index]));
|
|
93
|
+
return withHintSlots(item, true, factory);
|
|
71
94
|
});
|
|
72
95
|
});
|
|
73
96
|
function createDefaultValue() {
|
|
@@ -75,20 +98,10 @@ function createDefaultValue() {
|
|
|
75
98
|
return template ? collectFieldDefaults(template) : void 0;
|
|
76
99
|
}
|
|
77
100
|
function addItem() {
|
|
78
|
-
if (!elementTemplate.value)
|
|
79
|
-
|
|
80
|
-
const newArray = [...arrayValue.value, createDefaultValue()];
|
|
81
|
-
context.setValue(newArray);
|
|
82
|
-
}
|
|
83
|
-
function removeItem(count) {
|
|
84
|
-
if (count === void 0)
|
|
85
|
-
return;
|
|
86
|
-
const arr = arrayValue.value;
|
|
87
|
-
const newArray = [...arr.slice(0, count), ...arr.slice(count + 1)];
|
|
88
|
-
itemIds.value = [...itemIds.value.slice(0, count), ...itemIds.value.slice(count + 1)];
|
|
89
|
-
context.setValue(newArray);
|
|
101
|
+
if (!elementTemplate.value || !canAdd.value) return;
|
|
102
|
+
context.value.setValue([...arrayValue.value, createDefaultValue()]);
|
|
90
103
|
}
|
|
91
|
-
const { collapsibleConfig, shouldShowCollapsible, isHidden, enhancedField } = createCollapsibleEnhancer(props.field, props.extraProps);
|
|
104
|
+
const { collapsibleConfig, shouldShowCollapsible, isHidden, enhancedField } = createCollapsibleEnhancer(() => props.field, () => props.extraProps);
|
|
92
105
|
const DEFAULT_ADD_BUTTON_PROPS = {
|
|
93
106
|
icon: "i-lucide-plus",
|
|
94
107
|
color: "info",
|
|
@@ -98,47 +111,42 @@ const DEFAULT_ADD_BUTTON_PROPS = {
|
|
|
98
111
|
const addButtonProps = computed(() => ({
|
|
99
112
|
...DEFAULT_ADD_BUTTON_PROPS,
|
|
100
113
|
size: resolveFieldProp(props.field, "size", "sm", props.extraProps),
|
|
101
|
-
|
|
114
|
+
disabled: !canAdd.value,
|
|
115
|
+
...formAddButtonProps.value
|
|
102
116
|
}));
|
|
103
117
|
</script>
|
|
104
118
|
|
|
105
119
|
<template>
|
|
106
120
|
<UCollapsible v-if="shouldShowCollapsible" v-show="!isHidden" v-bind="collapsibleConfig || {}">
|
|
107
121
|
<template #default="{ open }">
|
|
108
|
-
<AutoFormRendererField :field="enhancedField" :
|
|
122
|
+
<AutoFormRendererField :field="enhancedField" :extra-props="{ ...props.extraProps, open }" />
|
|
109
123
|
</template>
|
|
110
124
|
|
|
111
125
|
<template v-if="elementTemplate" #content>
|
|
112
126
|
<VNodeRender v-if="slotResolver.hasSlot('before')" :node="slotResolver.renderSlot('before', slotProps)" />
|
|
113
127
|
<VNodeRender v-if="slotResolver.hasSlot('content')" :node="slotResolver.renderSlot('content', slotProps)" />
|
|
114
128
|
<template v-else>
|
|
115
|
-
<template v-for="(itemField, count) in arrayItemFields" :key="
|
|
129
|
+
<template v-for="(itemField, count) in arrayItemFields" :key="itemIds[count] ?? count">
|
|
116
130
|
<component
|
|
117
131
|
:is="isObjectElement ? AutoFormRendererNested : AutoFormRendererField"
|
|
118
132
|
:field="itemField"
|
|
119
|
-
:schema="props.schema"
|
|
120
133
|
:extra-props="{ ...props.extraProps, count }"
|
|
121
134
|
/>
|
|
122
135
|
</template>
|
|
123
136
|
</template>
|
|
124
|
-
<UButton v-bind="addButtonProps" @click="addItem"
|
|
125
|
-
添加
|
|
126
|
-
</UButton>
|
|
137
|
+
<UButton :label="t('autoForm.add')" v-bind="addButtonProps" @click="addItem" />
|
|
127
138
|
<VNodeRender v-if="slotResolver.hasSlot('after')" :node="slotResolver.renderSlot('after', slotProps)" />
|
|
128
139
|
</template>
|
|
129
140
|
</UCollapsible>
|
|
130
141
|
|
|
131
142
|
<template v-else-if="elementTemplate">
|
|
132
|
-
<template v-for="(itemField, count) in arrayItemFields" :key="
|
|
143
|
+
<template v-for="(itemField, count) in arrayItemFields" :key="itemIds[count] ?? count">
|
|
133
144
|
<component
|
|
134
145
|
:is="isObjectElement ? AutoFormRendererNested : AutoFormRendererField"
|
|
135
146
|
:field="itemField"
|
|
136
|
-
:schema="props.schema"
|
|
137
147
|
:extra-props="{ ...props.extraProps, count }"
|
|
138
148
|
/>
|
|
139
149
|
</template>
|
|
140
|
-
<UButton v-bind="addButtonProps" @click="addItem"
|
|
141
|
-
添加
|
|
142
|
-
</UButton>
|
|
150
|
+
<UButton :label="t('autoForm.add')" v-bind="addButtonProps" @click="addItem" />
|
|
143
151
|
</template>
|
|
144
152
|
</template>
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
import type { ButtonProps } from '@nuxt/ui';
|
|
3
1
|
import type { AutoFormField } from '../../../types/auto-form';
|
|
4
2
|
import type { AnyObject } from '@movk/core';
|
|
5
3
|
interface AutoFormRendererArrayProps {
|
|
6
|
-
schema: z.ZodObject;
|
|
7
4
|
field: AutoFormField;
|
|
8
5
|
extraProps?: AnyObject;
|
|
9
|
-
addButtonProps?: Partial<ButtonProps>;
|
|
10
6
|
}
|
|
11
7
|
declare const __VLS_export: import("vue").DefineComponent<AutoFormRendererArrayProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AutoFormRendererArrayProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
8
|
declare const _default: typeof __VLS_export;
|
|
@@ -6,7 +6,6 @@ import AutoFormRendererArray from "./Array.vue";
|
|
|
6
6
|
import AutoFormRendererLayout from "./Layout.vue";
|
|
7
7
|
import AutoFormRendererNested from "./Nested.vue";
|
|
8
8
|
const props = defineProps({
|
|
9
|
-
schema: { type: null, required: true },
|
|
10
9
|
fields: { type: Array, required: true },
|
|
11
10
|
extraProps: { type: Object, required: false }
|
|
12
11
|
});
|
|
@@ -25,25 +24,21 @@ const fieldTypeMap = computed(() => {
|
|
|
25
24
|
<AutoFormRendererField
|
|
26
25
|
v-if="fieldTypeMap.get(childField) === 'leaf'"
|
|
27
26
|
:field="childField"
|
|
28
|
-
:schema="props.schema"
|
|
29
27
|
:extra-props="props.extraProps"
|
|
30
28
|
/>
|
|
31
29
|
<AutoFormRendererArray
|
|
32
30
|
v-else-if="fieldTypeMap.get(childField) === 'array'"
|
|
33
31
|
:field="childField"
|
|
34
|
-
:schema="props.schema"
|
|
35
32
|
:extra-props="props.extraProps"
|
|
36
33
|
/>
|
|
37
34
|
<AutoFormRendererLayout
|
|
38
35
|
v-else-if="fieldTypeMap.get(childField) === 'layout'"
|
|
39
36
|
:field="childField"
|
|
40
|
-
:schema="props.schema"
|
|
41
37
|
:extra-props="props.extraProps"
|
|
42
38
|
/>
|
|
43
39
|
<AutoFormRendererNested
|
|
44
40
|
v-else
|
|
45
41
|
:field="childField"
|
|
46
|
-
:schema="props.schema"
|
|
47
42
|
:extra-props="props.extraProps"
|
|
48
43
|
/>
|
|
49
44
|
</template>
|
|
@@ -3,18 +3,21 @@ import { UFormField } from "#components";
|
|
|
3
3
|
import { computed } from "vue";
|
|
4
4
|
import { useAutoFormInjector } from "../provider";
|
|
5
5
|
import { VNodeRender } from "../reactive";
|
|
6
|
+
import { useAsyncItems } from "../async-items";
|
|
6
7
|
const props = defineProps({
|
|
7
|
-
schema: { type: null, required: true },
|
|
8
8
|
field: { type: Object, required: true },
|
|
9
9
|
extraProps: { type: Object, required: false }
|
|
10
10
|
});
|
|
11
11
|
const {
|
|
12
12
|
resolveFieldProp,
|
|
13
13
|
renderControl,
|
|
14
|
+
createFieldContext,
|
|
14
15
|
createSlotResolver,
|
|
15
16
|
createFormFieldSlots,
|
|
16
17
|
createSlotProps
|
|
17
18
|
} = useAutoFormInjector();
|
|
19
|
+
const asyncConfig = props.field.meta?.asyncItems;
|
|
20
|
+
const asyncItems = asyncConfig ? useAsyncItems(() => props.field.meta.asyncItems ?? asyncConfig, () => createFieldContext(props.field).state) : void 0;
|
|
18
21
|
const slotResolver = computed(() => createSlotResolver(props.field, props.extraProps));
|
|
19
22
|
const fieldProps = computed(() => ({
|
|
20
23
|
hidden: resolveFieldProp(props.field, "hidden", void 0, props.extraProps),
|
|
@@ -35,7 +38,11 @@ const fieldProps = computed(() => ({
|
|
|
35
38
|
ui: resolveFieldProp(props.field, "ui", void 0, props.extraProps)
|
|
36
39
|
}));
|
|
37
40
|
const formFieldSlots = computed(() => createFormFieldSlots(props.field, slotResolver.value, props.extraProps));
|
|
38
|
-
const renderedControl = computed(() => renderControl(
|
|
41
|
+
const renderedControl = computed(() => renderControl(
|
|
42
|
+
props.field,
|
|
43
|
+
props.extraProps,
|
|
44
|
+
asyncItems && { items: asyncItems.items.value ?? [], loading: asyncItems.loading.value }
|
|
45
|
+
));
|
|
39
46
|
const defaultSlotProps = computed(() => createSlotProps(props.field, props.extraProps));
|
|
40
47
|
</script>
|
|
41
48
|
|
|
@@ -8,19 +8,16 @@ import { resolveReactiveValue } from "../reactive";
|
|
|
8
8
|
import { useAutoFormInjector } from "../provider";
|
|
9
9
|
import AutoFormRendererChildren from "./Children.vue";
|
|
10
10
|
const props = defineProps({
|
|
11
|
-
schema: { type: null, required: true },
|
|
12
11
|
field: { type: Object, required: true },
|
|
13
12
|
extraProps: { type: Object, required: false }
|
|
14
13
|
});
|
|
15
|
-
const { createFieldContext,
|
|
14
|
+
const { createFieldContext, isFieldVisible } = useAutoFormInjector();
|
|
16
15
|
function getFieldName(f) {
|
|
17
16
|
return f.path.split(".").pop() || f.path;
|
|
18
17
|
}
|
|
19
18
|
const visibleFields = computed(() => {
|
|
20
19
|
if (!props.field.children?.length) return [];
|
|
21
|
-
return props.field.children.filter(
|
|
22
|
-
(f) => f && (f.meta?.if === void 0 || resolveFieldProp(f, "if") === true)
|
|
23
|
-
);
|
|
20
|
+
return props.field.children.filter(isFieldVisible);
|
|
24
21
|
});
|
|
25
22
|
const layoutComponent = computed(() => {
|
|
26
23
|
if (!props.field.meta?.layout?.component) {
|
|
@@ -83,7 +80,7 @@ const fieldsBySlot = computed(() => {
|
|
|
83
80
|
</template>
|
|
84
81
|
|
|
85
82
|
<template v-for="[slotName, fields] in fieldsBySlot.entries()" :key="`fields-${slotName}`" #[slotName]>
|
|
86
|
-
<AutoFormRendererChildren :fields="fields" :
|
|
83
|
+
<AutoFormRendererChildren :fields="fields" :extra-props="props.extraProps" />
|
|
87
84
|
</template>
|
|
88
85
|
</component>
|
|
89
86
|
</template>
|
|
@@ -7,33 +7,30 @@ import { VNodeRender } from "../reactive";
|
|
|
7
7
|
import AutoFormRendererField from "./Field.vue";
|
|
8
8
|
import AutoFormRendererChildren from "./Children.vue";
|
|
9
9
|
const props = defineProps({
|
|
10
|
-
schema: { type: null, required: true },
|
|
11
10
|
field: { type: Object, required: true },
|
|
12
11
|
extraProps: { type: Object, required: false }
|
|
13
12
|
});
|
|
14
|
-
const { createSlotResolver, createSlotProps, createCollapsibleEnhancer,
|
|
13
|
+
const { createSlotResolver, createSlotProps, createCollapsibleEnhancer, isFieldVisible } = useAutoFormInjector();
|
|
15
14
|
const visibleFields = computed(() => {
|
|
16
15
|
if (isLeafField(props.field) || !props.field.children?.length) {
|
|
17
16
|
return [];
|
|
18
17
|
}
|
|
19
|
-
return props.field.children.filter(
|
|
20
|
-
(f) => f && (f.meta?.if === void 0 || resolveFieldProp(f, "if") === true)
|
|
21
|
-
);
|
|
18
|
+
return props.field.children.filter(isFieldVisible);
|
|
22
19
|
});
|
|
23
20
|
const slotResolver = computed(() => createSlotResolver(props.field, props.extraProps));
|
|
24
|
-
const { collapsibleConfig, shouldShowCollapsible, isHidden, enhancedField } = createCollapsibleEnhancer(props.field, props.extraProps);
|
|
21
|
+
const { collapsibleConfig, shouldShowCollapsible, isHidden, enhancedField } = createCollapsibleEnhancer(() => props.field, () => props.extraProps);
|
|
25
22
|
const slotProps = computed(() => createSlotProps(props.field, props.extraProps));
|
|
26
23
|
</script>
|
|
27
24
|
|
|
28
25
|
<template>
|
|
29
26
|
<UCollapsible v-if="shouldShowCollapsible && visibleFields.length" v-show="!isHidden" v-bind="collapsibleConfig || {}">
|
|
30
27
|
<template #default="{ open }">
|
|
31
|
-
<AutoFormRendererField :field="enhancedField" :
|
|
28
|
+
<AutoFormRendererField :field="enhancedField" :extra-props="{ ...props.extraProps, open }" />
|
|
32
29
|
</template>
|
|
33
30
|
<template #content>
|
|
34
31
|
<VNodeRender v-if="slotResolver.hasSlot('before')" :node="slotResolver.renderSlot('before', slotProps)" />
|
|
35
32
|
<VNodeRender v-if="slotResolver.hasSlot('content')" :node="slotResolver.renderSlot('content', slotProps)" />
|
|
36
|
-
<AutoFormRendererChildren v-else :fields="visibleFields" :
|
|
33
|
+
<AutoFormRendererChildren v-else :fields="visibleFields" :extra-props="props.extraProps" />
|
|
37
34
|
<VNodeRender v-if="slotResolver.hasSlot('after')" :node="slotResolver.renderSlot('after', slotProps)" />
|
|
38
35
|
</template>
|
|
39
36
|
</UCollapsible>
|
|
@@ -41,7 +38,6 @@ const slotProps = computed(() => createSlotProps(props.field, props.extraProps))
|
|
|
41
38
|
<AutoFormRendererChildren
|
|
42
39
|
v-else-if="visibleFields.length"
|
|
43
40
|
:fields="visibleFields"
|
|
44
|
-
:schema="props.schema"
|
|
45
41
|
:extra-props="props.extraProps"
|
|
46
42
|
/>
|
|
47
43
|
</template>
|