@movk/nuxt 1.1.2 → 1.3.0
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/.nuxt/movk-ui.css +3 -0
- package/README.md +75 -104
- package/dist/module.d.mts +59 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +136 -56
- package/dist/runtime/components/AutoForm.d.vue.ts +10 -31
- package/dist/runtime/components/AutoForm.vue +114 -148
- package/dist/runtime/components/AutoForm.vue.d.ts +10 -31
- package/dist/runtime/components/ColorChooser.d.vue.ts +20 -17
- package/dist/runtime/components/ColorChooser.vue +305 -31
- package/dist/runtime/components/ColorChooser.vue.d.ts +20 -17
- package/dist/runtime/components/DataTable.d.vue.ts +57 -0
- package/dist/runtime/components/DataTable.vue +584 -0
- package/dist/runtime/components/DataTable.vue.d.ts +57 -0
- package/dist/runtime/components/DatePicker.d.vue.ts +15 -22
- package/dist/runtime/components/DatePicker.vue +173 -65
- package/dist/runtime/components/DatePicker.vue.d.ts +15 -22
- package/dist/runtime/components/MessageBox.d.vue.ts +36 -0
- package/dist/runtime/components/MessageBox.vue +113 -0
- package/dist/runtime/components/MessageBox.vue.d.ts +36 -0
- package/dist/runtime/components/PillGroup.d.vue.ts +33 -0
- package/dist/runtime/components/PillGroup.vue +291 -0
- package/dist/runtime/components/PillGroup.vue.d.ts +33 -0
- package/dist/runtime/components/Popconfirm.d.vue.ts +30 -0
- package/dist/runtime/components/Popconfirm.vue +143 -0
- package/dist/runtime/components/Popconfirm.vue.d.ts +30 -0
- package/dist/runtime/components/SearchForm.d.vue.ts +43 -0
- package/dist/runtime/components/SearchForm.vue +274 -0
- package/dist/runtime/components/SearchForm.vue.d.ts +43 -0
- package/dist/runtime/components/SlideVerify.d.vue.ts +13 -79
- package/dist/runtime/components/SlideVerify.vue +117 -90
- package/dist/runtime/components/SlideVerify.vue.d.ts +13 -79
- package/dist/runtime/components/StarRating.d.vue.ts +25 -82
- package/dist/runtime/components/StarRating.vue +128 -99
- package/dist/runtime/components/StarRating.vue.d.ts +25 -82
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +32 -0
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +48 -0
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +32 -0
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithCharacterLimit.vue +27 -15
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +13 -7
- package/dist/runtime/components/input/WithClear.d.vue.ts +11 -5
- package/dist/runtime/components/input/WithClear.vue +29 -10
- package/dist/runtime/components/input/WithClear.vue.d.ts +11 -5
- package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithCopy.vue +28 -11
- package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -7
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +33 -0
- package/dist/runtime/components/input/WithFloatingLabel.vue +75 -0
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +33 -0
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue +27 -10
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +13 -7
- package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +37 -28
- package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +5 -6
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +5 -6
- package/dist/runtime/composables/index.d.ts +9 -8
- package/dist/runtime/composables/index.js +2 -1
- package/dist/runtime/composables/useApiFetch.d.ts +23 -15
- package/dist/runtime/composables/useApiFetch.js +21 -28
- package/dist/runtime/composables/useAutoForm.d.ts +14 -98
- package/dist/runtime/composables/useAutoForm.js +55 -161
- package/dist/runtime/composables/useClientApiFetch.d.ts +7 -7
- package/dist/runtime/composables/useDateFormatter.d.ts +16 -3
- package/dist/runtime/composables/useDateFormatter.js +89 -30
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +26 -27
- package/dist/runtime/composables/useDownloadWithProgress.js +143 -42
- package/dist/runtime/composables/useLazyApiFetch.d.ts +19 -0
- package/dist/runtime/composables/useLazyApiFetch.js +4 -0
- package/dist/runtime/composables/useMessageBox.d.ts +6 -0
- package/dist/runtime/composables/useMessageBox.js +16 -0
- package/dist/runtime/composables/useTheme.d.ts +21 -8
- package/dist/runtime/composables/useTheme.js +109 -86
- package/dist/runtime/composables/useUploadWithProgress.d.ts +22 -28
- package/dist/runtime/composables/useUploadWithProgress.js +79 -68
- package/dist/runtime/domains/api/auth.d.ts +2 -0
- package/dist/runtime/domains/api/auth.js +31 -0
- package/dist/runtime/domains/api/endpoint-config.d.ts +11 -0
- package/dist/runtime/domains/api/endpoint-config.js +17 -0
- package/dist/runtime/domains/api/errors.d.ts +2 -0
- package/dist/runtime/domains/api/errors.js +10 -0
- package/dist/runtime/domains/api/fetch-key.d.ts +20 -0
- package/dist/runtime/domains/api/fetch-key.js +23 -0
- package/dist/runtime/domains/api/interceptors/error.d.ts +13 -0
- package/dist/runtime/domains/api/interceptors/error.js +49 -0
- package/dist/runtime/domains/api/interceptors/request.d.ts +12 -0
- package/dist/runtime/domains/api/interceptors/request.js +46 -0
- package/dist/runtime/domains/api/interceptors/response.d.ts +17 -0
- package/dist/runtime/domains/api/interceptors/response.js +27 -0
- package/dist/runtime/domains/api/response.d.ts +4 -0
- package/dist/runtime/domains/api/response.js +14 -0
- package/dist/runtime/domains/api/toast.d.ts +15 -0
- package/dist/runtime/domains/api/toast.js +46 -0
- package/dist/runtime/domains/api/transfer.d.ts +69 -0
- package/dist/runtime/domains/api/transfer.js +81 -0
- package/dist/runtime/domains/auto-form/actions.d.ts +2 -0
- package/dist/runtime/domains/auto-form/actions.js +4 -0
- package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +13 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererArray.vue → domains/auto-form/components/Array.vue} +37 -48
- package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +13 -0
- package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Children.vue +50 -0
- package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Field.vue +56 -0
- package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Layout.vue +89 -0
- package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Nested.vue +47 -0
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
- package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -2
- package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -25
- package/dist/runtime/domains/auto-form/controls.d.ts +41 -0
- package/dist/runtime/domains/auto-form/controls.js +73 -0
- package/dist/runtime/{utils/field-utils.d.ts → domains/auto-form/fields.d.ts} +7 -21
- package/dist/runtime/{utils/field-utils.js → domains/auto-form/fields.js} +19 -4
- package/dist/runtime/domains/auto-form/metadata.d.ts +22 -0
- package/dist/runtime/domains/auto-form/metadata.js +53 -0
- package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
- package/dist/runtime/{internal/useAutoFormProvider.js → domains/auto-form/provider.js} +6 -3
- package/dist/runtime/domains/auto-form/reactive.d.ts +12 -0
- package/dist/runtime/{utils/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
- package/dist/runtime/domains/auto-form/schema.d.ts +7 -0
- package/dist/runtime/{utils/schema-introspector.js → domains/auto-form/schema.js} +12 -10
- package/dist/runtime/domains/data-table/columns/constants.d.ts +50 -0
- package/dist/runtime/domains/data-table/columns/constants.js +19 -0
- package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resolve-columns.js +59 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +9 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +164 -0
- package/dist/runtime/domains/data-table/columns/resolve-group-column.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resolve-group-column.js +19 -0
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.d.ts +8 -0
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +232 -0
- package/dist/runtime/domains/data-table/columns/style.d.ts +11 -0
- package/dist/runtime/domains/data-table/columns/style.js +67 -0
- package/dist/runtime/domains/data-table/columns/utils.d.ts +6 -0
- package/dist/runtime/domains/data-table/columns/utils.js +16 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.d.vue.ts +10 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.vue +39 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.vue.d.ts +10 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.d.vue.ts +11 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.vue +91 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.vue.d.ts +11 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.d.vue.ts +9 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.vue +40 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.vue.d.ts +9 -0
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +26 -0
- package/dist/runtime/domains/data-table/components/Pagination.vue +132 -0
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +26 -0
- package/dist/runtime/domains/data-table/indent.d.ts +8 -0
- package/dist/runtime/domains/data-table/indent.js +19 -0
- package/dist/runtime/domains/data-table/tree-selection.d.ts +9 -0
- package/dist/runtime/domains/data-table/tree-selection.js +76 -0
- package/dist/runtime/{utils/theme.d.ts → domains/theme/theme-icons.d.ts} +0 -1
- package/dist/runtime/index.css +1 -0
- package/dist/runtime/plugins/api.factory.js +28 -171
- package/dist/runtime/plugins/theme.js +72 -70
- package/dist/runtime/types/api/config.d.ts +127 -0
- package/dist/runtime/types/api/fetch.d.ts +50 -0
- package/dist/runtime/types/api/index.d.ts +5 -0
- package/dist/runtime/types/api/module.d.ts +94 -0
- package/dist/runtime/types/api/response.d.ts +62 -0
- package/dist/runtime/types/api/transfer.d.ts +32 -0
- package/dist/runtime/types/api/transfer.js +0 -0
- package/dist/runtime/types/app.config.d.ts +6 -0
- package/dist/runtime/types/auto-form/base.d.ts +26 -0
- package/dist/runtime/types/auto-form/base.js +0 -0
- package/dist/runtime/types/auto-form/component.d.ts +28 -0
- package/dist/runtime/types/auto-form/component.js +0 -0
- package/dist/runtime/types/auto-form/controls.d.ts +45 -0
- package/dist/runtime/types/auto-form/controls.js +0 -0
- package/dist/runtime/types/auto-form/fields.d.ts +68 -0
- package/dist/runtime/types/auto-form/fields.js +0 -0
- package/dist/runtime/types/auto-form/index.d.ts +7 -0
- package/dist/runtime/types/auto-form/index.js +0 -0
- package/dist/runtime/types/auto-form/search-form.d.ts +84 -0
- package/dist/runtime/types/auto-form/search-form.js +0 -0
- package/dist/runtime/types/auto-form/slots.d.ts +85 -0
- package/dist/runtime/types/auto-form/slots.js +0 -0
- package/dist/runtime/types/auto-form/zod-factory.d.ts +127 -0
- package/dist/runtime/types/auto-form/zod-factory.js +0 -0
- package/dist/runtime/types/components/color-chooser.d.ts +109 -0
- package/dist/runtime/types/components/color-chooser.js +0 -0
- package/dist/runtime/types/components/date-picker.d.ts +41 -0
- package/dist/runtime/types/components/date-picker.js +0 -0
- package/dist/runtime/types/components/index.d.ts +8 -0
- package/dist/runtime/types/components/index.js +0 -0
- package/dist/runtime/types/components/input/as-phone-number-input.d.ts +17 -0
- package/dist/runtime/types/components/input/as-phone-number-input.js +0 -0
- package/dist/runtime/types/components/input/index.d.ts +6 -0
- package/dist/runtime/types/components/input/index.js +0 -0
- package/dist/runtime/types/components/input/with-character-limit.d.ts +11 -0
- package/dist/runtime/types/components/input/with-character-limit.js +0 -0
- package/dist/runtime/types/components/input/with-clear.d.ts +10 -0
- package/dist/runtime/types/components/input/with-clear.js +0 -0
- package/dist/runtime/types/components/input/with-copy.d.ts +11 -0
- package/dist/runtime/types/components/input/with-copy.js +0 -0
- package/dist/runtime/types/components/input/with-floating-label.d.ts +12 -0
- package/dist/runtime/types/components/input/with-floating-label.js +0 -0
- package/dist/runtime/types/components/input/with-password-toggle.d.ts +7 -0
- package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
- package/dist/runtime/types/components/message-box.d.ts +69 -0
- package/dist/runtime/types/components/message-box.js +0 -0
- package/dist/runtime/types/components/pill-group.d.ts +103 -0
- package/dist/runtime/types/components/pill-group.js +0 -0
- package/dist/runtime/types/components/popconfirm.d.ts +74 -0
- package/dist/runtime/types/components/popconfirm.js +0 -0
- package/dist/runtime/types/components/slide-verify.d.ts +54 -0
- package/dist/runtime/types/components/slide-verify.js +0 -0
- package/dist/runtime/types/components/star-rating.d.ts +55 -0
- package/dist/runtime/types/components/star-rating.js +0 -0
- package/dist/runtime/types/data-table/columns.d.ts +236 -0
- package/dist/runtime/types/data-table/columns.js +6 -0
- package/dist/runtime/types/data-table/component.d.ts +190 -0
- package/dist/runtime/types/data-table/component.js +0 -0
- package/dist/runtime/types/data-table/contexts.d.ts +44 -0
- package/dist/runtime/types/data-table/contexts.js +0 -0
- package/dist/runtime/types/data-table/index.d.ts +6 -0
- package/dist/runtime/types/data-table/index.js +1 -0
- package/dist/runtime/types/data-table/pagination.d.ts +87 -0
- package/dist/runtime/types/data-table/pagination.js +0 -0
- package/dist/runtime/types/index.d.ts +6 -5
- package/dist/runtime/types/index.js +5 -5
- package/dist/runtime/types/shared.d.ts +5 -0
- package/dist/runtime/types/shared.js +0 -0
- package/dist/runtime/types/zod.d.ts +19 -17
- package/dist/runtime/utils/extend-theme.d.ts +19 -0
- package/dist/runtime/utils/extend-theme.js +44 -0
- package/dist/runtime/utils/form-control.d.ts +33 -0
- package/dist/runtime/utils/form-control.js +54 -0
- package/dist/runtime/utils/meta.d.ts +4 -0
- package/dist/runtime/utils/meta.js +14 -0
- package/dist/runtime/utils/theme-defaults.d.ts +27 -0
- package/dist/runtime/utils/theme-defaults.js +28 -0
- package/dist/runtime/utils/tv.d.ts +1 -0
- package/dist/runtime/utils/tv.js +4 -0
- package/dist/runtime/vue/composables/useSiteConfig.d.ts +13 -0
- package/dist/runtime/vue/composables/useSiteConfig.js +11 -0
- package/dist/runtime/vue/plugins/theme.d.ts +6 -0
- package/dist/runtime/vue/plugins/theme.js +14 -0
- package/dist/runtime/vue/stubs/base.d.ts +2 -0
- package/dist/runtime/vue/stubs/base.js +2 -0
- package/dist/runtime/vue/stubs/inertia.d.ts +2 -0
- package/dist/runtime/vue/stubs/inertia.js +2 -0
- package/dist/runtime/vue/stubs/movk-extra.d.ts +2 -0
- package/dist/runtime/vue/stubs/movk-extra.js +2 -0
- package/dist/runtime/vue/stubs/none.d.ts +2 -0
- package/dist/runtime/vue/stubs/none.js +2 -0
- package/dist/runtime/vue/stubs/vue-router.d.ts +2 -0
- package/dist/runtime/vue/stubs/vue-router.js +2 -0
- package/dist/shared/nuxt.DfBEyjld.mjs +667 -0
- package/dist/types.d.mts +2 -6
- package/dist/unplugin.d.mts +28 -0
- package/dist/unplugin.mjs +292 -0
- package/dist/vite.d.mts +12 -0
- package/dist/vite.mjs +20 -0
- package/package.json +82 -42
- package/vue-plugin.d.ts +5 -0
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue +0 -125
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue +0 -105
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -20
- package/dist/runtime/composables/useApiAuth.d.ts +0 -47
- package/dist/runtime/composables/useApiAuth.js +0 -66
- package/dist/runtime/internal/useAutoFormProvider.d.ts +0 -50
- package/dist/runtime/schemas/api.d.ts +0 -590
- package/dist/runtime/schemas/api.js +0 -228
- package/dist/runtime/server/api/_movk/session.post.d.ts +0 -10
- package/dist/runtime/server/api/_movk/session.post.js +0 -18
- package/dist/runtime/style.css +0 -1
- package/dist/runtime/types/api.d.ts +0 -218
- package/dist/runtime/types/auth.d.ts +0 -34
- package/dist/runtime/types/auto-form-renderer.d.ts +0 -22
- package/dist/runtime/types/auto-form.d.ts +0 -548
- package/dist/runtime/types/components.d.ts +0 -43
- package/dist/runtime/types/module.d.ts +0 -39
- package/dist/runtime/utils/api-utils.d.ts +0 -79
- package/dist/runtime/utils/api-utils.js +0 -127
- package/dist/runtime/utils/auto-form.d.ts +0 -3
- package/dist/runtime/utils/auto-form.js +0 -18
- package/dist/runtime/utils/reactive-utils.d.ts +0 -30
- package/dist/runtime/utils/schema-introspector.d.ts +0 -13
- /package/dist/runtime/{utils/theme.js → domains/theme/theme-icons.js} +0 -0
- /package/dist/runtime/types/{api.js → api/config.js} +0 -0
- /package/dist/runtime/types/{auto-form-renderer.js → api/fetch.js} +0 -0
- /package/dist/runtime/types/{auto-form.js → api/index.js} +0 -0
- /package/dist/runtime/types/{module.js → api/module.js} +0 -0
- /package/dist/runtime/types/{components.js → api/response.js} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { UCollapsible } from "#components";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { useAutoFormInjector } from "../provider";
|
|
5
|
+
import { isLeafField } from "../fields";
|
|
6
|
+
import { VNodeRender } from "../reactive";
|
|
7
|
+
import AutoFormRendererField from "./Field.vue";
|
|
8
|
+
import AutoFormRendererChildren from "./Children.vue";
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
schema: { type: null, required: true },
|
|
11
|
+
field: { type: Object, required: true },
|
|
12
|
+
extraProps: { type: Object, required: false }
|
|
13
|
+
});
|
|
14
|
+
const { createSlotResolver, createSlotProps, createCollapsibleEnhancer, resolveFieldProp } = useAutoFormInjector();
|
|
15
|
+
const visibleFields = computed(() => {
|
|
16
|
+
if (isLeafField(props.field) || !props.field.children?.length) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
return props.field.children.filter(
|
|
20
|
+
(f) => f && (f.meta?.if === void 0 || resolveFieldProp(f, "if") === true)
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
const slotResolver = computed(() => createSlotResolver(props.field, props.extraProps));
|
|
24
|
+
const { collapsibleConfig, shouldShowCollapsible, isHidden, enhancedField } = createCollapsibleEnhancer(props.field, props.extraProps);
|
|
25
|
+
const slotProps = computed(() => createSlotProps(props.field, props.extraProps));
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<UCollapsible v-if="shouldShowCollapsible && visibleFields.length" v-show="!isHidden" v-bind="collapsibleConfig || {}">
|
|
30
|
+
<template #default="{ open }">
|
|
31
|
+
<AutoFormRendererField :field="enhancedField" :schema="props.schema" :extra-props="{ ...props.extraProps, open }" />
|
|
32
|
+
</template>
|
|
33
|
+
<template #content>
|
|
34
|
+
<VNodeRender v-if="slotResolver.hasSlot('before')" :node="slotResolver.renderSlot('before', slotProps)" />
|
|
35
|
+
<VNodeRender v-if="slotResolver.hasSlot('content')" :node="slotResolver.renderSlot('content', slotProps)" />
|
|
36
|
+
<AutoFormRendererChildren v-else :fields="visibleFields" :schema="props.schema" :extra-props="props.extraProps" />
|
|
37
|
+
<VNodeRender v-if="slotResolver.hasSlot('after')" :node="slotResolver.renderSlot('after', slotProps)" />
|
|
38
|
+
</template>
|
|
39
|
+
</UCollapsible>
|
|
40
|
+
|
|
41
|
+
<AutoFormRendererChildren
|
|
42
|
+
v-else-if="visibleFields.length"
|
|
43
|
+
:fields="visibleFields"
|
|
44
|
+
:schema="props.schema"
|
|
45
|
+
:extra-props="props.extraProps"
|
|
46
|
+
/>
|
|
47
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AutoFormField } from '../../../types';
|
|
3
|
+
import type { AnyObject } from '@movk/core';
|
|
4
|
+
interface AutoFormRendererNestedProps {
|
|
5
|
+
schema: z.ZodObject;
|
|
6
|
+
field: AutoFormField;
|
|
7
|
+
extraProps?: AnyObject;
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<AutoFormRendererNestedProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AutoFormRendererNestedProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -14,5 +14,3 @@ export declare const AUTOFORM_PATTERNS: {
|
|
|
14
14
|
/** 事件属性检测正则,匹配 onClick、onChange 等 Vue/React 事件命名模式 */
|
|
15
15
|
readonly EVENT_PROP: RegExp;
|
|
16
16
|
};
|
|
17
|
-
/** zod 克隆方法 */
|
|
18
|
-
export declare const CLONE_METHODS: readonly ["meta", "max", "min", "length", "regex", "startsWith", "endsWith", "includes", "uppercase", "lowercase", "optional", "nullable", "nullish", "describe", "refine", "superRefine", "check", "transform", "default", "mime", "readonly", "exclude", "extract"];
|
|
@@ -14,28 +14,3 @@ export const AUTOFORM_PATTERNS = {
|
|
|
14
14
|
/** 事件属性检测正则,匹配 onClick、onChange 等 Vue/React 事件命名模式 */
|
|
15
15
|
EVENT_PROP: /^on[A-Z]/
|
|
16
16
|
};
|
|
17
|
-
export const CLONE_METHODS = [
|
|
18
|
-
"meta",
|
|
19
|
-
"max",
|
|
20
|
-
"min",
|
|
21
|
-
"length",
|
|
22
|
-
"regex",
|
|
23
|
-
"startsWith",
|
|
24
|
-
"endsWith",
|
|
25
|
-
"includes",
|
|
26
|
-
"uppercase",
|
|
27
|
-
"lowercase",
|
|
28
|
-
"optional",
|
|
29
|
-
"nullable",
|
|
30
|
-
"nullish",
|
|
31
|
-
"describe",
|
|
32
|
-
"refine",
|
|
33
|
-
"superRefine",
|
|
34
|
-
"check",
|
|
35
|
-
"transform",
|
|
36
|
-
"default",
|
|
37
|
-
"mime",
|
|
38
|
-
"readonly",
|
|
39
|
-
"exclude",
|
|
40
|
-
"extract"
|
|
41
|
-
];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { IsComponent } from '@movk/core';
|
|
2
|
+
import type { AutoFormControl, _Unset } from '../../types/auto-form/controls';
|
|
3
|
+
import type { InputProps, InputSlots, TextareaProps, TextareaSlots } from '@nuxt/ui';
|
|
4
|
+
import { UInput, UTextarea } from '#components';
|
|
5
|
+
export declare function defineControl<C extends IsComponent, P = _Unset, S = _Unset>(e: AutoFormControl<C, P, S>): AutoFormControl<C, P, S>;
|
|
6
|
+
declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
7
|
+
readonly string: any;
|
|
8
|
+
readonly number: any;
|
|
9
|
+
readonly boolean: any;
|
|
10
|
+
readonly enum: any;
|
|
11
|
+
readonly file: any;
|
|
12
|
+
readonly calendarDate: any;
|
|
13
|
+
readonly inputDate: any;
|
|
14
|
+
readonly inputTime: any;
|
|
15
|
+
readonly withClear: any;
|
|
16
|
+
readonly withPasswordToggle: any;
|
|
17
|
+
readonly withCopy: any;
|
|
18
|
+
readonly withCharacterLimit: any;
|
|
19
|
+
readonly withFloatingLabel: any;
|
|
20
|
+
readonly asPhoneNumberInput: any;
|
|
21
|
+
readonly textarea: any;
|
|
22
|
+
readonly switch: any;
|
|
23
|
+
readonly slider: any;
|
|
24
|
+
readonly selectMenu: any;
|
|
25
|
+
readonly inputMenu: any;
|
|
26
|
+
readonly checkboxGroup: any;
|
|
27
|
+
readonly radioGroup: any;
|
|
28
|
+
readonly inputTags: any;
|
|
29
|
+
readonly pinInput: any;
|
|
30
|
+
readonly listbox: any;
|
|
31
|
+
readonly starRating: any;
|
|
32
|
+
readonly colorChooser: any;
|
|
33
|
+
readonly slideVerify: any;
|
|
34
|
+
readonly pillGroup: any;
|
|
35
|
+
};
|
|
36
|
+
type DefaultControlComponents = typeof DEFAULT_CONTROL_COMPONENTS;
|
|
37
|
+
type DefaultControlMap = {
|
|
38
|
+
readonly [K in keyof DefaultControlComponents]: K extends 'string' ? AutoFormControl<typeof UInput, InputProps, InputSlots> : K extends 'textarea' ? AutoFormControl<typeof UTextarea, TextareaProps, TextareaSlots> : AutoFormControl<DefaultControlComponents[K]>;
|
|
39
|
+
};
|
|
40
|
+
export declare const DEFAULT_CONTROLS: DefaultControlMap;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import WithClear from "../../components/input/WithClear.vue";
|
|
2
|
+
import WithPasswordToggle from "../../components/input/WithPasswordToggle.vue";
|
|
3
|
+
import WithCopy from "../../components/input/WithCopy.vue";
|
|
4
|
+
import WithCharacterLimit from "../../components/input/WithCharacterLimit.vue";
|
|
5
|
+
import AsPhoneNumberInput from "../../components/input/AsPhoneNumberInput.vue";
|
|
6
|
+
import WithFloatingLabel from "../../components/input/WithFloatingLabel.vue";
|
|
7
|
+
import DatePicker from "../../components/DatePicker.vue";
|
|
8
|
+
import ColorChooser from "../../components/ColorChooser.vue";
|
|
9
|
+
import StarRating from "../../components/StarRating.vue";
|
|
10
|
+
import SlideVerify from "../../components/SlideVerify.vue";
|
|
11
|
+
import PillGroup from "../../components/PillGroup.vue";
|
|
12
|
+
import {
|
|
13
|
+
UInput,
|
|
14
|
+
UInputNumber,
|
|
15
|
+
UCheckbox,
|
|
16
|
+
USwitch,
|
|
17
|
+
UTextarea,
|
|
18
|
+
USlider,
|
|
19
|
+
UPinInput,
|
|
20
|
+
UInputTags,
|
|
21
|
+
UFileUpload,
|
|
22
|
+
USelect,
|
|
23
|
+
USelectMenu,
|
|
24
|
+
UInputMenu,
|
|
25
|
+
UCheckboxGroup,
|
|
26
|
+
URadioGroup,
|
|
27
|
+
UInputDate,
|
|
28
|
+
UInputTime,
|
|
29
|
+
UListbox
|
|
30
|
+
} from "#components";
|
|
31
|
+
const DEFAULT_CONTROL_PROPS = { class: "w-full" };
|
|
32
|
+
export function defineControl(e) {
|
|
33
|
+
return e;
|
|
34
|
+
}
|
|
35
|
+
function createControlMap(components, defaultProps = DEFAULT_CONTROL_PROPS) {
|
|
36
|
+
return Object.fromEntries(
|
|
37
|
+
Object.entries(components).map(([key, component]) => [
|
|
38
|
+
key,
|
|
39
|
+
{ component, controlProps: defaultProps }
|
|
40
|
+
])
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const DEFAULT_CONTROL_COMPONENTS = {
|
|
44
|
+
string: UInput,
|
|
45
|
+
number: UInputNumber,
|
|
46
|
+
boolean: UCheckbox,
|
|
47
|
+
enum: USelect,
|
|
48
|
+
file: UFileUpload,
|
|
49
|
+
calendarDate: DatePicker,
|
|
50
|
+
inputDate: UInputDate,
|
|
51
|
+
inputTime: UInputTime,
|
|
52
|
+
withClear: WithClear,
|
|
53
|
+
withPasswordToggle: WithPasswordToggle,
|
|
54
|
+
withCopy: WithCopy,
|
|
55
|
+
withCharacterLimit: WithCharacterLimit,
|
|
56
|
+
withFloatingLabel: WithFloatingLabel,
|
|
57
|
+
asPhoneNumberInput: AsPhoneNumberInput,
|
|
58
|
+
textarea: UTextarea,
|
|
59
|
+
switch: USwitch,
|
|
60
|
+
slider: USlider,
|
|
61
|
+
selectMenu: USelectMenu,
|
|
62
|
+
inputMenu: UInputMenu,
|
|
63
|
+
checkboxGroup: UCheckboxGroup,
|
|
64
|
+
radioGroup: URadioGroup,
|
|
65
|
+
inputTags: UInputTags,
|
|
66
|
+
pinInput: UPinInput,
|
|
67
|
+
listbox: UListbox,
|
|
68
|
+
starRating: StarRating,
|
|
69
|
+
colorChooser: ColorChooser,
|
|
70
|
+
slideVerify: SlideVerify,
|
|
71
|
+
pillGroup: PillGroup
|
|
72
|
+
};
|
|
73
|
+
export const DEFAULT_CONTROLS = createControlMap(DEFAULT_CONTROL_COMPONENTS);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { VNode } from 'vue';
|
|
2
|
-
import type { AutoFormField } from '
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
*/
|
|
2
|
+
import type { AutoFormField } from '../../types/auto-form';
|
|
3
|
+
/** 沿字段树回填带 defaultValue 的叶子节点,已存在值的路径不覆盖 */
|
|
4
|
+
export declare function applyFieldDefaults(fields: AutoFormField[], target: Record<string, any>): void;
|
|
5
|
+
/** 将字段列表分类为叶子/嵌套/数组/布局四组 */
|
|
6
6
|
export declare function classifyFields(fields: AutoFormField[]): {
|
|
7
7
|
leafFields: AutoFormField[];
|
|
8
8
|
nestedFields: AutoFormField[];
|
|
@@ -10,25 +10,11 @@ export declare function classifyFields(fields: AutoFormField[]): {
|
|
|
10
10
|
layoutFields: AutoFormField[];
|
|
11
11
|
hasComplexFields: boolean;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
* 优化的字段类型检测 - 基于 meta.type 判断
|
|
15
|
-
* @param field - 自动表单字段
|
|
16
|
-
* @returns 是否为叶子字段(非 object 和 array)
|
|
17
|
-
*/
|
|
18
13
|
export declare function isLeafField(field: AutoFormField): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* 获取字段类型
|
|
21
|
-
* @param field - 自动表单字段
|
|
22
|
-
* @returns 字段类型
|
|
23
|
-
*/
|
|
24
14
|
export declare function getFieldType(field: AutoFormField): 'leaf' | 'nested';
|
|
25
|
-
/**
|
|
26
|
-
* 收集字段默认值
|
|
27
|
-
*/
|
|
15
|
+
/** 递归收集字段的默认值,object 类型返回嵌套结构,叶子类型直接返回值 */
|
|
28
16
|
export declare function collectFieldDefaults(field: AutoFormField): {} | null | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* 从 SelectMenuItem 数组中提取枚举值
|
|
31
|
-
*/
|
|
17
|
+
/** 从 items 选项中提取枚举值,支持对象格式(取 valueKey/value/label)和原始值 */
|
|
32
18
|
export declare function extractEnumValuesFromItems(items: any, valueKey?: string): string[];
|
|
33
|
-
/**
|
|
19
|
+
/** 创建数组项的 hint 插槽渲染函数,根据层级和字段类型组合删除按钮与折叠图标 */
|
|
34
20
|
export declare function createHintSlotFactory(removeCallback: (count?: number) => void): (field: AutoFormField, path: string, open?: boolean, count?: number) => VNode | undefined;
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import { UButton, UIcon } from "#components";
|
|
2
2
|
import { h } from "vue";
|
|
3
|
-
import { setPath } from "@movk/core";
|
|
4
|
-
import { AUTOFORM_META } from "
|
|
3
|
+
import { getPath, setPath } from "@movk/core";
|
|
4
|
+
import { AUTOFORM_META } from "./constants.js";
|
|
5
|
+
export function applyFieldDefaults(fields, target) {
|
|
6
|
+
if (!fields.length) return;
|
|
7
|
+
const updates = [];
|
|
8
|
+
function collect(items) {
|
|
9
|
+
for (const field of items) {
|
|
10
|
+
if (field?.decorators?.defaultValue !== void 0 && getPath(target, field.path) === void 0) {
|
|
11
|
+
updates.push({ path: field.path, value: field.decorators.defaultValue });
|
|
12
|
+
}
|
|
13
|
+
if (field?.children && Array.isArray(field.children) && field.children.length > 0) {
|
|
14
|
+
collect(field.children);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
collect(fields);
|
|
19
|
+
for (const { path, value } of updates) setPath(target, path, value);
|
|
20
|
+
}
|
|
5
21
|
export function classifyFields(fields) {
|
|
6
22
|
const leafFields = [];
|
|
7
23
|
const nestedFields = [];
|
|
@@ -95,7 +111,6 @@ export function createHintSlotFactory(removeCallback) {
|
|
|
95
111
|
color: "error",
|
|
96
112
|
variant: "ghost",
|
|
97
113
|
size: "xs",
|
|
98
|
-
square: true,
|
|
99
114
|
onClick: (event) => {
|
|
100
115
|
event?.stopPropagation();
|
|
101
116
|
removeCallback(count);
|
|
@@ -104,7 +119,7 @@ export function createHintSlotFactory(removeCallback) {
|
|
|
104
119
|
if (!isObject) {
|
|
105
120
|
return deleteButton;
|
|
106
121
|
}
|
|
107
|
-
return h("div", { class: "flex items-center gap-
|
|
122
|
+
return h("div", { class: "flex items-center gap-1.5" }, [
|
|
108
123
|
deleteButton,
|
|
109
124
|
chevronIcon
|
|
110
125
|
]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* 应用元数据到 Zod schema
|
|
4
|
+
*/
|
|
5
|
+
export declare function applyMeta<T extends z.ZodType>(schema: T, meta?: unknown): T;
|
|
6
|
+
/**
|
|
7
|
+
* 从 Zod schema 中提取 AutoForm 元数据
|
|
8
|
+
*
|
|
9
|
+
* 通过 BFS 遍历以下路径读取 meta:
|
|
10
|
+
* - schema.meta() — Zod v4 全局 registry
|
|
11
|
+
* - schema._zod.parent — .refine()/.check() 创建新实例时设置的父引用
|
|
12
|
+
* - schema.unwrap() — 可选/默认值等包装类型
|
|
13
|
+
* - schema.def.innerType / .in / .out / .schema — 结构性内层类型
|
|
14
|
+
*
|
|
15
|
+
* 收集所有层级的 meta 并合并,外层优先级更高。
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAutoFormMetadata(schema: z.ZodType): Record<string, any>;
|
|
18
|
+
/**
|
|
19
|
+
* 提取错误消息和元数据
|
|
20
|
+
* @returns [errorMessage, metadata]
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractErrorAndMeta(controlMeta?: any): [string | undefined, any];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isObject } from "@movk/core";
|
|
2
|
+
import { AUTOFORM_META } from "./constants.js";
|
|
3
|
+
export function applyMeta(schema, meta) {
|
|
4
|
+
const normalizedMeta = isObject(meta) ? meta : {};
|
|
5
|
+
return schema.meta(normalizedMeta);
|
|
6
|
+
}
|
|
7
|
+
export function getAutoFormMetadata(schema) {
|
|
8
|
+
const queue = [schema];
|
|
9
|
+
const visited = /* @__PURE__ */ new Set();
|
|
10
|
+
const collectedMetas = [];
|
|
11
|
+
while (queue.length > 0) {
|
|
12
|
+
const current = queue.shift();
|
|
13
|
+
if (!current || visited.has(current))
|
|
14
|
+
continue;
|
|
15
|
+
visited.add(current);
|
|
16
|
+
const meta = typeof current.meta === "function" ? current.meta() : void 0;
|
|
17
|
+
if (meta && isObject(meta)) {
|
|
18
|
+
const typedMeta = meta;
|
|
19
|
+
const normalizedMeta = typedMeta?.[AUTOFORM_META.KEY] && isObject(typedMeta[AUTOFORM_META.KEY]) ? typedMeta[AUTOFORM_META.KEY] : typedMeta;
|
|
20
|
+
collectedMetas.push(normalizedMeta);
|
|
21
|
+
}
|
|
22
|
+
if (typeof current.unwrap === "function") {
|
|
23
|
+
try {
|
|
24
|
+
queue.push(current.unwrap());
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (current?._zod?.parent)
|
|
29
|
+
queue.push(current._zod.parent);
|
|
30
|
+
const def = current?.def || current?._def;
|
|
31
|
+
if (def?.innerType)
|
|
32
|
+
queue.push(def.innerType);
|
|
33
|
+
if (def?.in)
|
|
34
|
+
queue.push(def.in);
|
|
35
|
+
if (def?.out)
|
|
36
|
+
queue.push(def.out);
|
|
37
|
+
if (def?.schema)
|
|
38
|
+
queue.push(def.schema);
|
|
39
|
+
}
|
|
40
|
+
if (collectedMetas.length === 0)
|
|
41
|
+
return {};
|
|
42
|
+
return Object.assign({}, ...collectedMetas.reverse());
|
|
43
|
+
}
|
|
44
|
+
export function extractErrorAndMeta(controlMeta) {
|
|
45
|
+
if (typeof controlMeta === "string") {
|
|
46
|
+
return [controlMeta, void 0];
|
|
47
|
+
}
|
|
48
|
+
if (controlMeta && isObject(controlMeta) && "error" in controlMeta) {
|
|
49
|
+
const { error, ...meta } = controlMeta;
|
|
50
|
+
return [error, meta];
|
|
51
|
+
}
|
|
52
|
+
return [void 0, controlMeta];
|
|
53
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { ReactiveValue } from '@movk/core';
|
|
3
|
+
import type { AutoFormField, AutoFormMergeMeta, ResolvedAutoFormFieldContext } from '../../types/auto-form';
|
|
4
|
+
type _ResolveReactive<T> = T extends ReactiveValue<infer V, any> ? V : T;
|
|
5
|
+
type ResolvedMetaValue<K extends keyof AutoFormMergeMeta> = _ResolveReactive<NonNullable<AutoFormMergeMeta[K]>>;
|
|
6
|
+
/** 初始化表单上下文工厂并通过 provide 注入给所有子渲染器 */
|
|
7
|
+
export declare function useAutoFormProvider(state: Ref<any>, slots: Record<string, any>): {
|
|
8
|
+
createFieldContext: (field: AutoFormField, extraProps?: Record<string, any>) => ResolvedAutoFormFieldContext;
|
|
9
|
+
createSlotProps: (field: AutoFormField, extraProps?: Record<string, any>) => ResolvedAutoFormFieldContext;
|
|
10
|
+
resolveFieldProp: {
|
|
11
|
+
<K extends keyof AutoFormMergeMeta>(field: AutoFormField, prop: K, defaultValue?: ResolvedMetaValue<K>, extraProps?: Record<string, any>): ResolvedMetaValue<K> | undefined;
|
|
12
|
+
<T>(field: AutoFormField, prop: keyof AutoFormMergeMeta, defaultValue?: T, extraProps?: Record<string, any>): T | undefined;
|
|
13
|
+
};
|
|
14
|
+
renderFieldSlot: (fn?: (props?: any) => any, slotProps?: any) => any;
|
|
15
|
+
getResolvedFieldSlots: (field: AutoFormField, extraProps?: Record<string, any>) => Record<string, ((props?: any) => any) | undefined> | undefined;
|
|
16
|
+
renderControl: (field: AutoFormField, extraProps?: Record<string, any>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}> | null;
|
|
19
|
+
createSlotResolver: (field: AutoFormField, extraProps?: Record<string, any>) => {
|
|
20
|
+
hasSlot(name: string): boolean;
|
|
21
|
+
renderSlot(name: string, slotProps: any): any;
|
|
22
|
+
};
|
|
23
|
+
createFormFieldSlots: (field: AutoFormField, slotResolver: ReturnType<(field: AutoFormField, extraProps?: Record<string, any>) => {
|
|
24
|
+
hasSlot(name: string): boolean;
|
|
25
|
+
renderSlot(name: string, slotProps: any): any;
|
|
26
|
+
}>, extraProps?: Record<string, any>) => Record<string, any>;
|
|
27
|
+
createCollapsibleEnhancer: (field: AutoFormField, extraProps?: Record<string, any>) => {
|
|
28
|
+
collapsibleConfig: import("vue").ComputedRef<import("../../types").AutoFormNestedCollapsible | undefined>;
|
|
29
|
+
shouldShowCollapsible: import("vue").ComputedRef<boolean>;
|
|
30
|
+
isHidden: import("vue").ComputedRef<boolean | undefined>;
|
|
31
|
+
enhancedField: import("vue").ComputedRef<AutoFormField>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** 注入表单上下文,必须在 AutoForm 子渲染器中调用 */
|
|
35
|
+
export declare function useAutoFormInjector(): {
|
|
36
|
+
createFieldContext: (field: AutoFormField, extraProps?: Record<string, any>) => ResolvedAutoFormFieldContext;
|
|
37
|
+
createSlotProps: (field: AutoFormField, extraProps?: Record<string, any>) => ResolvedAutoFormFieldContext;
|
|
38
|
+
resolveFieldProp: {
|
|
39
|
+
<K extends keyof AutoFormMergeMeta>(field: AutoFormField, prop: K, defaultValue?: ResolvedMetaValue<K>, extraProps?: Record<string, any>): ResolvedMetaValue<K> | undefined;
|
|
40
|
+
<T>(field: AutoFormField, prop: keyof AutoFormMergeMeta, defaultValue?: T, extraProps?: Record<string, any>): T | undefined;
|
|
41
|
+
};
|
|
42
|
+
renderFieldSlot: (fn?: (props?: any) => any, slotProps?: any) => any;
|
|
43
|
+
getResolvedFieldSlots: (field: AutoFormField, extraProps?: Record<string, any>) => Record<string, ((props?: any) => any) | undefined> | undefined;
|
|
44
|
+
renderControl: (field: AutoFormField, extraProps?: Record<string, any>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}> | null;
|
|
47
|
+
createSlotResolver: (field: AutoFormField, extraProps?: Record<string, any>) => {
|
|
48
|
+
hasSlot(name: string): boolean;
|
|
49
|
+
renderSlot(name: string, slotProps: any): any;
|
|
50
|
+
};
|
|
51
|
+
createFormFieldSlots: (field: AutoFormField, slotResolver: ReturnType<(field: AutoFormField, extraProps?: Record<string, any>) => {
|
|
52
|
+
hasSlot(name: string): boolean;
|
|
53
|
+
renderSlot(name: string, slotProps: any): any;
|
|
54
|
+
}>, extraProps?: Record<string, any>) => Record<string, any>;
|
|
55
|
+
createCollapsibleEnhancer: (field: AutoFormField, extraProps?: Record<string, any>) => {
|
|
56
|
+
collapsibleConfig: import("vue").ComputedRef<import("../../types").AutoFormNestedCollapsible | undefined>;
|
|
57
|
+
shouldShowCollapsible: import("vue").ComputedRef<boolean>;
|
|
58
|
+
isHidden: import("vue").ComputedRef<boolean | undefined>;
|
|
59
|
+
enhancedField: import("vue").ComputedRef<AutoFormField>;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { UIcon } from "#components";
|
|
|
2
2
|
import defu from "defu";
|
|
3
3
|
import { computed, h, inject, isVNode, provide, resolveDynamicComponent, unref } from "vue";
|
|
4
4
|
import { getPath, setPath } from "@movk/core";
|
|
5
|
-
import { enhanceEventProps, resolveReactiveValue } from "
|
|
5
|
+
import { enhanceEventProps, resolveReactiveValue } from "./reactive.js";
|
|
6
6
|
const AUTO_FORM_CONTEXT_KEY = Symbol("AUTO_FORM_CONTEXT_KEY");
|
|
7
7
|
export function useAutoFormProvider(state, slots) {
|
|
8
8
|
function createFieldContext(field, extraProps) {
|
|
@@ -17,7 +17,8 @@ export function useAutoFormProvider(state, slots) {
|
|
|
17
17
|
},
|
|
18
18
|
setValue: (pathOrValue, value) => {
|
|
19
19
|
if (value === void 0) {
|
|
20
|
-
|
|
20
|
+
const nextValue = typeof pathOrValue === "function" ? pathOrValue(getPath(state.value, path)) : pathOrValue;
|
|
21
|
+
setPath(state.value, path, nextValue);
|
|
21
22
|
} else {
|
|
22
23
|
const relativePath = String(pathOrValue);
|
|
23
24
|
let fullPath;
|
|
@@ -78,10 +79,12 @@ export function useAutoFormProvider(state, slots) {
|
|
|
78
79
|
const context = createFieldContext(field, extraProps);
|
|
79
80
|
const resolvedControlProps = resolveFieldProp(field, "controlProps", void 0, extraProps) || {};
|
|
80
81
|
const isReadonly = field.decorators?.isReadonly;
|
|
82
|
+
const resolvedSize = resolveFieldProp(field, "size", void 0, extraProps);
|
|
81
83
|
const finalProps = defu(
|
|
82
84
|
resolvedControlProps,
|
|
83
85
|
isReadonly ? { disabled: true } : {},
|
|
84
|
-
controlMeta?.mapped?.controlProps || {}
|
|
86
|
+
controlMeta?.mapped?.controlProps || {},
|
|
87
|
+
resolvedSize !== void 0 ? { size: resolvedSize } : {}
|
|
85
88
|
);
|
|
86
89
|
const slots2 = defu(
|
|
87
90
|
resolveFieldProp(field, "controlSlots", void 0, extraProps) || {},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AnyObject } from '@movk/core';
|
|
2
|
+
import type { ResolvedAutoFormFieldContext } from '../../types/auto-form';
|
|
3
|
+
/** 解析单个响应式值:函数则以 context 调用,ref 则解包,否则原样返回 */
|
|
4
|
+
export declare function resolveReactiveValue(value: unknown, context: ResolvedAutoFormFieldContext): any;
|
|
5
|
+
/** 递归解析对象/数组中所有响应式值,VNode 和 ref 不再展开以防止意外渲染 */
|
|
6
|
+
export declare function resolveReactiveObject<T extends Record<string, any>>(obj: T, context: ResolvedAutoFormFieldContext, depth?: number): T;
|
|
7
|
+
/** 为 onXxx 事件 prop 自动追加 context 作为最后一个参数,方便用户在事件回调中访问表单状态 */
|
|
8
|
+
export declare function enhanceEventProps(originalProps: AnyObject, ctx: ResolvedAutoFormFieldContext): Record<string, any>;
|
|
9
|
+
/** 渲染任意 VNode 内容(slot 函数返回值、h() 结果等),单子节点直接返回,多个节点包入 Fragment */
|
|
10
|
+
export declare function VNodeRender(props: {
|
|
11
|
+
node: unknown;
|
|
12
|
+
}): any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isFunction, isObject } from "@movk/core";
|
|
2
2
|
import { Fragment, h, isRef, isVNode, unref } from "vue";
|
|
3
|
-
import { AUTOFORM_LIMITS, AUTOFORM_PATTERNS } from "
|
|
3
|
+
import { AUTOFORM_LIMITS, AUTOFORM_PATTERNS } from "./constants.js";
|
|
4
4
|
function validateContext(context) {
|
|
5
5
|
if (!context || typeof context !== "object") {
|
|
6
6
|
throw new TypeError("AutoFormFieldContext must be a valid object");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AutoFormControls, AutoFormField } from '../../types/auto-form';
|
|
3
|
+
import type { ZodAutoFormFieldMeta } from '../../types/zod';
|
|
4
|
+
/** 将 Zod schema 递归解析为 AutoFormField 列表(schema 遍历的核心入口) */
|
|
5
|
+
export declare function introspectSchema(schema: z.ZodType, mapping: AutoFormControls, path: string, globalMeta?: ZodAutoFormFieldMeta): AutoFormField[];
|
|
6
|
+
/** 将含布局标记的 schema 还原为纯字段 schema,用于 Zod 表单校验 */
|
|
7
|
+
export declare function extractPureSchema<T extends z.ZodObject<any, any>>(schema: T): z.ZodObject<any, any>;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { markRaw } from "vue";
|
|
2
|
-
import { z as zod } from "zod
|
|
2
|
+
import { z as zod } from "zod";
|
|
3
3
|
import { joinPath, startCase, toPath, isFunction, isObject } from "@movk/core";
|
|
4
|
-
import {
|
|
5
|
-
import { AUTOFORM_LIMITS, AUTOFORM_META } from "
|
|
4
|
+
import { getAutoFormMetadata } from "./metadata.js";
|
|
5
|
+
import { AUTOFORM_LIMITS, AUTOFORM_META } from "./constants.js";
|
|
6
|
+
function getUnwrappedSchema(schema) {
|
|
7
|
+
const def = schema?.def || schema?._def;
|
|
8
|
+
return def?.innerType || def?.in || def?.schema || void 0;
|
|
9
|
+
}
|
|
6
10
|
function extractDecorators(schema) {
|
|
7
11
|
const decorators = {};
|
|
8
12
|
let cur = schema;
|
|
9
13
|
let coreSchema = schema;
|
|
10
14
|
while (cur) {
|
|
11
|
-
const def = cur?.def;
|
|
15
|
+
const def = cur?.def || cur?._def;
|
|
12
16
|
if (!def?.type)
|
|
13
17
|
break;
|
|
14
18
|
switch (def.type) {
|
|
@@ -22,9 +26,11 @@ function extractDecorators(schema) {
|
|
|
22
26
|
decorators.defaultValue = isFunction(def.defaultValue) ? def.defaultValue() : def.defaultValue;
|
|
23
27
|
break;
|
|
24
28
|
}
|
|
25
|
-
const next =
|
|
29
|
+
const next = getUnwrappedSchema(cur);
|
|
26
30
|
if (!next)
|
|
27
31
|
break;
|
|
32
|
+
if (next === cur)
|
|
33
|
+
break;
|
|
28
34
|
cur = next;
|
|
29
35
|
coreSchema = next;
|
|
30
36
|
}
|
|
@@ -34,7 +40,6 @@ function extractDecorators(schema) {
|
|
|
34
40
|
return { decorators, coreSchema };
|
|
35
41
|
}
|
|
36
42
|
function extractSchemaInfo(schema, globalMeta, autoGeneratedLabel) {
|
|
37
|
-
const { getAutoFormMetadata } = useAutoForm();
|
|
38
43
|
const customMeta = getAutoFormMetadata(schema);
|
|
39
44
|
const { decorators, coreSchema } = extractDecorators(schema);
|
|
40
45
|
const computedType = customMeta?.component ? void 0 : customMeta?.type ?? coreSchema?.type;
|
|
@@ -47,7 +52,6 @@ function extractSchemaInfo(schema, globalMeta, autoGeneratedLabel) {
|
|
|
47
52
|
...globalMeta,
|
|
48
53
|
...customMeta,
|
|
49
54
|
type: computedType,
|
|
50
|
-
// 如果有 overwrite,则进行合并
|
|
51
55
|
...customMeta?.overwrite && isObject(customMeta.overwrite) ? customMeta.overwrite : {}
|
|
52
56
|
};
|
|
53
57
|
return { decorators, mergedMeta, coreSchema };
|
|
@@ -162,14 +166,13 @@ export function introspectSchema(schema, mapping, path, globalMeta = {}) {
|
|
|
162
166
|
if (enumValues && enumValues.length > 0) {
|
|
163
167
|
field.meta.controlProps = {
|
|
164
168
|
items: enumValues,
|
|
165
|
-
...field.meta.controlProps
|
|
169
|
+
...field.meta.controlProps
|
|
166
170
|
};
|
|
167
171
|
}
|
|
168
172
|
}
|
|
169
173
|
return [field];
|
|
170
174
|
}
|
|
171
175
|
function isLayoutMarker(schema) {
|
|
172
|
-
const { getAutoFormMetadata } = useAutoForm();
|
|
173
176
|
const meta = getAutoFormMetadata(schema);
|
|
174
177
|
return meta?.type === AUTOFORM_META.LAYOUT_KEY;
|
|
175
178
|
}
|
|
@@ -177,7 +180,6 @@ function processLayoutShape(shape) {
|
|
|
177
180
|
const resultShape = {};
|
|
178
181
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
179
182
|
if (isLayoutMarker(fieldSchema)) {
|
|
180
|
-
const { getAutoFormMetadata } = useAutoForm();
|
|
181
183
|
const meta = getAutoFormMetadata(fieldSchema);
|
|
182
184
|
const layoutFields = meta?.layout?.fields;
|
|
183
185
|
if (layoutFields && isObject(layoutFields)) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ColumnDef, ColumnMeta, ColumnPinningState, ColumnSizingState, VisibilityState } from '@tanstack/vue-table';
|
|
2
|
+
import type { DataTableDensityPreset, DataTableSizePreset, DataTableTreeSelectionStrategy } from '../../../types/data-table';
|
|
3
|
+
import type { DataTableProps } from '../../../types/data-table/component';
|
|
4
|
+
export declare const DENSITY_PRESETS: Record<DataTableDensityPreset, {
|
|
5
|
+
th?: string;
|
|
6
|
+
td?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const SIZE_PRESET_MAP: Record<DataTableSizePreset, number>;
|
|
9
|
+
export interface SpecialColumnDefaults {
|
|
10
|
+
id: string;
|
|
11
|
+
fixed?: 'left' | 'right';
|
|
12
|
+
size?: number;
|
|
13
|
+
align?: 'left' | 'center' | 'right';
|
|
14
|
+
header?: string;
|
|
15
|
+
tdClass?: string;
|
|
16
|
+
}
|
|
17
|
+
export type SpecialColumnType = 'selection' | 'index' | 'expand' | 'row-pinning' | 'actions';
|
|
18
|
+
export declare const SPECIAL_COLUMN_DEFAULTS: Record<SpecialColumnType, SpecialColumnDefaults>;
|
|
19
|
+
export interface ResolvedColumnState<T> {
|
|
20
|
+
columnDefs: ColumnDef<T, unknown>[];
|
|
21
|
+
initialPinning: ColumnPinningState;
|
|
22
|
+
initialVisibility: VisibilityState;
|
|
23
|
+
initialSizing: ColumnSizingState;
|
|
24
|
+
hasColumnPinning: boolean;
|
|
25
|
+
hasColumnResizing: boolean;
|
|
26
|
+
hasColumnSort: boolean;
|
|
27
|
+
hasExpandColumn: boolean;
|
|
28
|
+
selectionMode?: 'single' | 'multiple';
|
|
29
|
+
selectionStrategy?: DataTableTreeSelectionStrategy;
|
|
30
|
+
subRowSelection?: boolean;
|
|
31
|
+
allColumnIds: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface ResolveContext<T> {
|
|
34
|
+
options: DataTableProps<T>;
|
|
35
|
+
density: ColumnMeta<T, unknown>['class'] | null;
|
|
36
|
+
pinning: ColumnPinningState;
|
|
37
|
+
visibility: VisibilityState;
|
|
38
|
+
sizing: ColumnSizingState;
|
|
39
|
+
flags: {
|
|
40
|
+
hasPinning: boolean;
|
|
41
|
+
hasResizing: boolean;
|
|
42
|
+
hasSort: boolean;
|
|
43
|
+
hasExpand: boolean;
|
|
44
|
+
};
|
|
45
|
+
selectionMode?: 'single' | 'multiple';
|
|
46
|
+
selectionStrategy?: DataTableTreeSelectionStrategy;
|
|
47
|
+
subRowSelection?: boolean;
|
|
48
|
+
nextGroupId: () => number;
|
|
49
|
+
allColumnIds: string[];
|
|
50
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const DENSITY_PRESETS = {
|
|
2
|
+
compact: { td: "px-3 py-1.5", th: "px-3 py-2" },
|
|
3
|
+
normal: { td: "px-4 py-2.5", th: "px-4 py-3" },
|
|
4
|
+
comfortable: { td: "p-4", th: "p-4" }
|
|
5
|
+
};
|
|
6
|
+
export const SIZE_PRESET_MAP = {
|
|
7
|
+
xs: 80,
|
|
8
|
+
sm: 120,
|
|
9
|
+
md: 180,
|
|
10
|
+
lg: 260,
|
|
11
|
+
xl: 400
|
|
12
|
+
};
|
|
13
|
+
export const SPECIAL_COLUMN_DEFAULTS = {
|
|
14
|
+
"selection": { id: "__selection", size: 60, align: "center" },
|
|
15
|
+
"index": { id: "__index", size: 60, align: "center", header: "#", tdClass: "text-muted" },
|
|
16
|
+
"expand": { id: "__expand", size: 60, align: "center" },
|
|
17
|
+
"row-pinning": { id: "__row_pinning", size: 60, align: "center" },
|
|
18
|
+
"actions": { id: "__actions", size: 60, header: "\u64CD\u4F5C", align: "center" }
|
|
19
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataTableColumn } from '../../../types/data-table';
|
|
2
|
+
import type { ResolvedColumnState } from './constants';
|
|
3
|
+
import type { DataTableProps } from '../../../types/data-table/component';
|
|
4
|
+
export declare function resolveColumns<T>(columns: DataTableColumn<T>[], options: DataTableProps<T>): ResolvedColumnState<T>;
|