@movk/nuxt 1.2.0 → 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 +74 -79
- package/dist/module.d.mts +57 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +120 -126
- package/dist/runtime/components/AutoForm.d.vue.ts +10 -30
- package/dist/runtime/components/AutoForm.vue +114 -125
- package/dist/runtime/components/AutoForm.vue.d.ts +10 -30
- package/dist/runtime/components/ColorChooser.d.vue.ts +21 -22
- package/dist/runtime/components/ColorChooser.vue +304 -27
- package/dist/runtime/components/ColorChooser.vue.d.ts +21 -22
- 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 +20 -33
- package/dist/runtime/components/DatePicker.vue +173 -65
- package/dist/runtime/components/DatePicker.vue.d.ts +20 -33
- 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 +21 -149
- package/dist/runtime/components/SearchForm.vue +211 -153
- package/dist/runtime/components/SearchForm.vue.d.ts +21 -149
- package/dist/runtime/components/SlideVerify.d.vue.ts +31 -70
- package/dist/runtime/components/SlideVerify.vue +117 -90
- package/dist/runtime/components/SlideVerify.vue.d.ts +31 -70
- package/dist/runtime/components/StarRating.d.vue.ts +38 -87
- package/dist/runtime/components/StarRating.vue +118 -74
- package/dist/runtime/components/StarRating.vue.d.ts +38 -87
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +11 -15
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +22 -9
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +11 -15
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +11 -13
- package/dist/runtime/components/input/WithCharacterLimit.vue +23 -11
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +11 -13
- package/dist/runtime/components/input/WithClear.d.vue.ts +13 -11
- package/dist/runtime/components/input/WithClear.vue +27 -8
- package/dist/runtime/components/input/WithClear.vue.d.ts +13 -11
- package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -13
- package/dist/runtime/components/input/WithCopy.vue +25 -8
- package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -13
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +13 -16
- package/dist/runtime/components/input/WithFloatingLabel.vue +35 -27
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +13 -16
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +11 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue +24 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +11 -7
- package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +27 -12
- package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +9 -4
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +9 -4
- package/dist/runtime/composables/index.d.ts +9 -8
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/useApiFetch.d.ts +10 -5
- package/dist/runtime/composables/useApiFetch.js +20 -2
- package/dist/runtime/composables/useAutoForm.d.ts +4 -4
- package/dist/runtime/composables/useAutoForm.js +23 -9
- package/dist/runtime/composables/useClientApiFetch.d.ts +3 -2
- 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 +142 -40
- package/dist/runtime/composables/useLazyApiFetch.d.ts +3 -2
- package/dist/runtime/composables/useMessageBox.d.ts +6 -0
- package/dist/runtime/composables/useMessageBox.js +16 -0
- package/dist/runtime/composables/useTheme.d.ts +26 -16
- package/dist/runtime/composables/useTheme.js +98 -71
- package/dist/runtime/composables/useUploadWithProgress.d.ts +23 -29
- package/dist/runtime/composables/useUploadWithProgress.js +78 -67
- 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} +25 -29
- 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/{components/auto-form-renderer/AutoFormRendererChildren.vue → domains/auto-form/components/Children.vue} +18 -18
- 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/{components/auto-form-renderer/AutoFormRendererLayout.vue → domains/auto-form/components/Layout.vue} +24 -25
- 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/{components/auto-form-renderer/AutoFormRendererNested.vue → domains/auto-form/components/Nested.vue} +17 -21
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/controls.d.ts +41 -0
- package/dist/runtime/{auto-form → domains/auto-form}/controls.js +27 -24
- package/dist/runtime/{auto-form/field-utils.d.ts → domains/auto-form/fields.d.ts} +3 -1
- package/dist/runtime/{auto-form/field-utils.js → domains/auto-form/fields.js} +18 -2
- package/dist/runtime/{auto-form → domains/auto-form}/metadata.js +1 -1
- package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
- package/dist/runtime/{auto-form → domains/auto-form}/provider.js +6 -3
- package/dist/runtime/{auto-form/reactive-utils.d.ts → domains/auto-form/reactive.d.ts} +5 -5
- package/dist/runtime/{auto-form/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
- package/dist/runtime/{auto-form/schema-introspector.d.ts → domains/auto-form/schema.d.ts} +2 -2
- package/dist/runtime/{auto-form/schema-introspector.js → domains/auto-form/schema.js} +1 -1
- 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 +17 -117
- package/dist/runtime/plugins/theme.js +49 -27
- 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/response.js +0 -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 +11 -10
- 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 +2 -5
- package/dist/runtime/utils/meta.js +1 -3
- 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 +75 -36
- package/vue-plugin.d.ts +5 -0
- package/dist/runtime/auto-form/controls.d.ts +0 -221
- package/dist/runtime/auto-form/provider.d.ts +0 -27
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -28
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -28
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -26
- package/dist/runtime/constants/api-defaults.d.ts +0 -9
- package/dist/runtime/constants/api-defaults.js +0 -32
- package/dist/runtime/constants/grid-cols.d.ts +0 -7
- package/dist/runtime/constants/grid-cols.js +0 -44
- package/dist/runtime/style.css +0 -1
- package/dist/runtime/types/api.d.ts +0 -349
- package/dist/runtime/types/auto-form.d.ts +0 -259
- package/dist/runtime/types/module.d.ts +0 -96
- package/dist/runtime/types/theme.d.ts +0 -2
- package/dist/runtime/utils/api-utils.d.ts +0 -58
- package/dist/runtime/utils/api-utils.js +0 -98
- /package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -0
- /package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -0
- /package/dist/runtime/{auto-form → domains/auto-form}/metadata.d.ts +0 -0
- /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.js → api/fetch.js} +0 -0
- /package/dist/runtime/types/{module.js → api/index.js} +0 -0
- /package/dist/runtime/types/{theme.js → api/module.js} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
-
import { classifyFields } from "
|
|
4
|
-
import AutoFormRendererField from "./
|
|
5
|
-
import AutoFormRendererArray from "./
|
|
6
|
-
import AutoFormRendererLayout from "./
|
|
7
|
-
import AutoFormRendererNested from "./
|
|
8
|
-
const
|
|
3
|
+
import { classifyFields } from "../fields";
|
|
4
|
+
import AutoFormRendererField from "./Field.vue";
|
|
5
|
+
import AutoFormRendererArray from "./Array.vue";
|
|
6
|
+
import AutoFormRendererLayout from "./Layout.vue";
|
|
7
|
+
import AutoFormRendererNested from "./Nested.vue";
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
schema: { type: null, required: true },
|
|
9
10
|
fields: { type: Array, required: true },
|
|
10
|
-
extraProps: { type: Object, required: false }
|
|
11
|
-
schema: { type: null, required: false }
|
|
11
|
+
extraProps: { type: Object, required: false }
|
|
12
12
|
});
|
|
13
13
|
const fieldTypeMap = computed(() => {
|
|
14
|
-
const { leafFields, arrayFields, layoutFields } = classifyFields(fields);
|
|
14
|
+
const { leafFields, arrayFields, layoutFields } = classifyFields(props.fields);
|
|
15
15
|
const map = /* @__PURE__ */ new Map();
|
|
16
16
|
for (const f of leafFields) map.set(f, "leaf");
|
|
17
17
|
for (const f of arrayFields) map.set(f, "array");
|
|
@@ -21,30 +21,30 @@ const fieldTypeMap = computed(() => {
|
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
<template>
|
|
24
|
-
<template v-for="childField in fields" :key="childField.path">
|
|
24
|
+
<template v-for="childField in props.fields" :key="childField.path">
|
|
25
25
|
<AutoFormRendererField
|
|
26
26
|
v-if="fieldTypeMap.get(childField) === 'leaf'"
|
|
27
27
|
:field="childField"
|
|
28
|
-
:schema="schema"
|
|
29
|
-
:extra-props="extraProps"
|
|
28
|
+
:schema="props.schema"
|
|
29
|
+
:extra-props="props.extraProps"
|
|
30
30
|
/>
|
|
31
31
|
<AutoFormRendererArray
|
|
32
32
|
v-else-if="fieldTypeMap.get(childField) === 'array'"
|
|
33
33
|
:field="childField"
|
|
34
|
-
:schema="schema"
|
|
35
|
-
:extra-props="extraProps"
|
|
34
|
+
:schema="props.schema"
|
|
35
|
+
:extra-props="props.extraProps"
|
|
36
36
|
/>
|
|
37
37
|
<AutoFormRendererLayout
|
|
38
38
|
v-else-if="fieldTypeMap.get(childField) === 'layout'"
|
|
39
39
|
:field="childField"
|
|
40
|
-
:schema="schema"
|
|
41
|
-
:extra-props="extraProps"
|
|
40
|
+
:schema="props.schema"
|
|
41
|
+
:extra-props="props.extraProps"
|
|
42
42
|
/>
|
|
43
43
|
<AutoFormRendererNested
|
|
44
44
|
v-else
|
|
45
45
|
:field="childField"
|
|
46
|
-
:schema="schema"
|
|
47
|
-
:extra-props="extraProps"
|
|
46
|
+
:schema="props.schema"
|
|
47
|
+
:extra-props="props.extraProps"
|
|
48
48
|
/>
|
|
49
49
|
</template>
|
|
50
50
|
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AutoFormField } from '../../../types/auto-form';
|
|
3
|
+
import type { AnyObject } from '@movk/core';
|
|
4
|
+
interface AutoFormRendererChildrenProps {
|
|
5
|
+
schema: z.ZodObject;
|
|
6
|
+
fields: AutoFormField[];
|
|
7
|
+
extraProps?: AnyObject;
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<AutoFormRendererChildrenProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AutoFormRendererChildrenProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AnyObject } from '@movk/core';
|
|
3
|
+
import type { AutoFormField } from '../../../types';
|
|
4
|
+
interface AutoFormFieldProps {
|
|
5
|
+
schema: z.ZodObject;
|
|
6
|
+
field: AutoFormField;
|
|
7
|
+
extraProps?: AnyObject;
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<AutoFormFieldProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AutoFormFieldProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { UFormField } from "#components";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { useAutoFormInjector } from "../provider";
|
|
5
|
+
import { VNodeRender } from "../reactive";
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
schema: { type: null, required: true },
|
|
8
|
+
field: { type: Object, required: true },
|
|
9
|
+
extraProps: { type: Object, required: false }
|
|
10
|
+
});
|
|
11
|
+
const {
|
|
12
|
+
resolveFieldProp,
|
|
13
|
+
renderControl,
|
|
14
|
+
createSlotResolver,
|
|
15
|
+
createFormFieldSlots,
|
|
16
|
+
createSlotProps
|
|
17
|
+
} = useAutoFormInjector();
|
|
18
|
+
const slotResolver = computed(() => createSlotResolver(props.field, props.extraProps));
|
|
19
|
+
const fieldProps = computed(() => ({
|
|
20
|
+
hidden: resolveFieldProp(props.field, "hidden", void 0, props.extraProps),
|
|
21
|
+
as: resolveFieldProp(props.field, "as", void 0, props.extraProps),
|
|
22
|
+
name: resolveFieldProp(props.field, "name", props.field.path, props.extraProps),
|
|
23
|
+
errorPattern: resolveFieldProp(props.field, "errorPattern", void 0, props.extraProps),
|
|
24
|
+
label: resolveFieldProp(props.field, "label", void 0, props.extraProps),
|
|
25
|
+
description: resolveFieldProp(props.field, "description", void 0, props.extraProps),
|
|
26
|
+
help: resolveFieldProp(props.field, "help", void 0, props.extraProps),
|
|
27
|
+
error: resolveFieldProp(props.field, "error", void 0, props.extraProps),
|
|
28
|
+
hint: resolveFieldProp(props.field, "hint", void 0, props.extraProps),
|
|
29
|
+
size: resolveFieldProp(props.field, "size", void 0, props.extraProps),
|
|
30
|
+
required: resolveFieldProp(props.field, "required", void 0, props.extraProps),
|
|
31
|
+
eagerValidation: resolveFieldProp(props.field, "eagerValidation", void 0, props.extraProps),
|
|
32
|
+
validateOnInputDelay: resolveFieldProp(props.field, "validateOnInputDelay", void 0, props.extraProps),
|
|
33
|
+
orientation: resolveFieldProp(props.field, "orientation", void 0, props.extraProps),
|
|
34
|
+
class: resolveFieldProp(props.field, "class", void 0, props.extraProps),
|
|
35
|
+
ui: resolveFieldProp(props.field, "ui", void 0, props.extraProps)
|
|
36
|
+
}));
|
|
37
|
+
const formFieldSlots = computed(() => createFormFieldSlots(props.field, slotResolver.value, props.extraProps));
|
|
38
|
+
const renderedControl = computed(() => renderControl(props.field, props.extraProps));
|
|
39
|
+
const defaultSlotProps = computed(() => createSlotProps(props.field, props.extraProps));
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<UFormField v-show="!fieldProps.hidden" v-bind="fieldProps">
|
|
44
|
+
<template v-for="(slotComponent, slotName) in formFieldSlots" :key="slotName" #[slotName]="slotData">
|
|
45
|
+
<VNodeRender :node="slotComponent(slotData)" />
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<template #default="{ error }">
|
|
49
|
+
<VNodeRender
|
|
50
|
+
v-if="slotResolver.hasSlot('default')"
|
|
51
|
+
:node="slotResolver.renderSlot('default', { ...defaultSlotProps, error })"
|
|
52
|
+
/>
|
|
53
|
+
<VNodeRender v-else :node="renderedControl" />
|
|
54
|
+
</template>
|
|
55
|
+
</UFormField>
|
|
56
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AnyObject } from '@movk/core';
|
|
3
|
+
import type { AutoFormField } from '../../../types';
|
|
4
|
+
interface AutoFormFieldProps {
|
|
5
|
+
schema: z.ZodObject;
|
|
6
|
+
field: AutoFormField;
|
|
7
|
+
extraProps?: AnyObject;
|
|
8
|
+
}
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<AutoFormFieldProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AutoFormFieldProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AutoFormField } from '../../../types/auto-form';
|
|
3
|
+
import type { AnyObject } from '@movk/core';
|
|
4
|
+
interface AutoFormRendererLayoutProps {
|
|
5
|
+
schema: z.ZodObject;
|
|
6
|
+
field: AutoFormField;
|
|
7
|
+
extraProps?: AnyObject;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
declare const __VLS_export: import("vue").DefineComponent<AutoFormRendererLayoutProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AutoFormRendererLayoutProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
|
|
3
|
+
</script>
|
|
4
|
+
|
|
1
5
|
<script setup>
|
|
2
6
|
import { computed, resolveDynamicComponent } from "vue";
|
|
3
|
-
import { resolveReactiveValue } from "
|
|
4
|
-
import { useAutoFormInjector } from "
|
|
5
|
-
import AutoFormRendererChildren from "./
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
schema,
|
|
9
|
-
extraProps
|
|
10
|
-
} = defineProps({
|
|
7
|
+
import { resolveReactiveValue } from "../reactive";
|
|
8
|
+
import { useAutoFormInjector } from "../provider";
|
|
9
|
+
import AutoFormRendererChildren from "./Children.vue";
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
schema: { type: null, required: true },
|
|
11
12
|
field: { type: Object, required: true },
|
|
12
|
-
extraProps: { type: Object, required: false }
|
|
13
|
-
schema: { type: null, required: false }
|
|
13
|
+
extraProps: { type: Object, required: false }
|
|
14
14
|
});
|
|
15
15
|
const { createFieldContext, resolveFieldProp } = useAutoFormInjector();
|
|
16
16
|
function getFieldName(f) {
|
|
17
17
|
return f.path.split(".").pop() || f.path;
|
|
18
18
|
}
|
|
19
19
|
const visibleFields = computed(() => {
|
|
20
|
-
if (!field.children?.length) return [];
|
|
21
|
-
return field.children.filter(
|
|
20
|
+
if (!props.field.children?.length) return [];
|
|
21
|
+
return props.field.children.filter(
|
|
22
22
|
(f) => f && (f.meta?.if === void 0 || resolveFieldProp(f, "if") === true)
|
|
23
23
|
);
|
|
24
24
|
});
|
|
25
25
|
const layoutComponent = computed(() => {
|
|
26
|
-
if (!field.meta?.layout?.component) {
|
|
26
|
+
if (!props.field.meta?.layout?.component) {
|
|
27
27
|
return "div";
|
|
28
28
|
}
|
|
29
|
-
return resolveDynamicComponent(field.meta.layout.component);
|
|
29
|
+
return resolveDynamicComponent(props.field.meta.layout.component);
|
|
30
30
|
});
|
|
31
31
|
const layoutProps = computed(() => {
|
|
32
|
-
const config = field.meta.layout;
|
|
32
|
+
const config = props.field.meta.layout;
|
|
33
33
|
if (!config) return {};
|
|
34
|
-
const context = createFieldContext(field);
|
|
34
|
+
const context = createFieldContext(props.field);
|
|
35
35
|
return {
|
|
36
36
|
...resolveReactiveValue(config.props, context),
|
|
37
37
|
...config.class && { class: resolveReactiveValue(config.class, context) }
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
40
|
const layoutSlots = computed(() => {
|
|
41
|
-
const config = field.meta.layout;
|
|
41
|
+
const config = props.field.meta.layout;
|
|
42
42
|
if (!config?.slots) return {};
|
|
43
|
-
const context = createFieldContext(field);
|
|
43
|
+
const context = createFieldContext(props.field);
|
|
44
44
|
const resolvedSlots = resolveReactiveValue(config.slots, context);
|
|
45
45
|
return Object.entries(resolvedSlots).reduce((acc, [name, fn]) => {
|
|
46
46
|
if (typeof fn === "function") acc[name] = fn;
|
|
@@ -48,10 +48,9 @@ const layoutSlots = computed(() => {
|
|
|
48
48
|
}, {});
|
|
49
49
|
});
|
|
50
50
|
const fieldsBySlot = computed(() => {
|
|
51
|
-
const config = field.meta.layout;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const context = createFieldContext(field);
|
|
51
|
+
const config = props.field.meta.layout;
|
|
52
|
+
if (!config || !visibleFields.value.length) return /* @__PURE__ */ new Map();
|
|
53
|
+
const context = createFieldContext(props.field);
|
|
55
54
|
let slotMapping;
|
|
56
55
|
if (config.fieldSlots) {
|
|
57
56
|
const resolved = resolveReactiveValue(config.fieldSlots, context);
|
|
@@ -63,12 +62,12 @@ const fieldsBySlot = computed(() => {
|
|
|
63
62
|
const slot = resolveReactiveValue(config.fieldSlot, context);
|
|
64
63
|
if (slot && typeof slot === "string") {
|
|
65
64
|
slotMapping = /* @__PURE__ */ new Map();
|
|
66
|
-
for (const f of
|
|
65
|
+
for (const f of visibleFields.value) {
|
|
67
66
|
slotMapping.set(getFieldName(f), slot);
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
|
-
return
|
|
70
|
+
return visibleFields.value.reduce((map, f) => {
|
|
72
71
|
const slot = slotMapping?.get(getFieldName(f)) || "default";
|
|
73
72
|
if (!map.has(slot)) map.set(slot, []);
|
|
74
73
|
map.get(slot).push(f);
|
|
@@ -84,7 +83,7 @@ const fieldsBySlot = computed(() => {
|
|
|
84
83
|
</template>
|
|
85
84
|
|
|
86
85
|
<template v-for="[slotName, fields] in fieldsBySlot.entries()" :key="`fields-${slotName}`" #[slotName]>
|
|
87
|
-
<AutoFormRendererChildren :fields="fields" :schema="schema" :extra-props="extraProps" />
|
|
86
|
+
<AutoFormRendererChildren :fields="fields" :schema="props.schema" :extra-props="props.extraProps" />
|
|
88
87
|
</template>
|
|
89
88
|
</component>
|
|
90
89
|
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { AutoFormField } from '../../../types/auto-form';
|
|
3
|
+
import type { AnyObject } from '@movk/core';
|
|
4
|
+
interface AutoFormRendererLayoutProps {
|
|
5
|
+
schema: z.ZodObject;
|
|
6
|
+
field: AutoFormField;
|
|
7
|
+
extraProps?: AnyObject;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
declare const __VLS_export: import("vue").DefineComponent<AutoFormRendererLayoutProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AutoFormRendererLayoutProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -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;
|
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { UCollapsible } from "#components";
|
|
3
3
|
import { computed } from "vue";
|
|
4
|
-
import { useAutoFormInjector } from "
|
|
5
|
-
import { isLeafField } from "
|
|
6
|
-
import { VNodeRender } from "
|
|
7
|
-
import AutoFormRendererField from "./
|
|
8
|
-
import AutoFormRendererChildren from "./
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
schema,
|
|
12
|
-
extraProps
|
|
13
|
-
} = defineProps({
|
|
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 },
|
|
14
11
|
field: { type: Object, required: true },
|
|
15
|
-
extraProps: { type: Object, required: false }
|
|
16
|
-
schema: { type: null, required: false }
|
|
12
|
+
extraProps: { type: Object, required: false }
|
|
17
13
|
});
|
|
18
14
|
const { createSlotResolver, createSlotProps, createCollapsibleEnhancer, resolveFieldProp } = useAutoFormInjector();
|
|
19
15
|
const visibleFields = computed(() => {
|
|
20
|
-
if (isLeafField(field) || !field.children?.length) {
|
|
16
|
+
if (isLeafField(props.field) || !props.field.children?.length) {
|
|
21
17
|
return [];
|
|
22
18
|
}
|
|
23
|
-
return field.children.filter(
|
|
19
|
+
return props.field.children.filter(
|
|
24
20
|
(f) => f && (f.meta?.if === void 0 || resolveFieldProp(f, "if") === true)
|
|
25
21
|
);
|
|
26
22
|
});
|
|
27
|
-
const slotResolver = computed(() => createSlotResolver(field, extraProps));
|
|
28
|
-
const { collapsibleConfig, shouldShowCollapsible, isHidden, enhancedField } = createCollapsibleEnhancer(field, extraProps);
|
|
29
|
-
const slotProps = computed(() => createSlotProps(field, extraProps));
|
|
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));
|
|
30
26
|
</script>
|
|
31
27
|
|
|
32
28
|
<template>
|
|
33
29
|
<UCollapsible v-if="shouldShowCollapsible && visibleFields.length" v-show="!isHidden" v-bind="collapsibleConfig || {}">
|
|
34
30
|
<template #default="{ open }">
|
|
35
|
-
<AutoFormRendererField :field="enhancedField" :schema="schema" :extra-props="{ ...extraProps, open }" />
|
|
31
|
+
<AutoFormRendererField :field="enhancedField" :schema="props.schema" :extra-props="{ ...props.extraProps, open }" />
|
|
36
32
|
</template>
|
|
37
33
|
<template #content>
|
|
38
34
|
<VNodeRender v-if="slotResolver.hasSlot('before')" :node="slotResolver.renderSlot('before', slotProps)" />
|
|
39
35
|
<VNodeRender v-if="slotResolver.hasSlot('content')" :node="slotResolver.renderSlot('content', slotProps)" />
|
|
40
|
-
<AutoFormRendererChildren v-else :fields="visibleFields" :schema="schema" :extra-props="extraProps" />
|
|
36
|
+
<AutoFormRendererChildren v-else :fields="visibleFields" :schema="props.schema" :extra-props="props.extraProps" />
|
|
41
37
|
<VNodeRender v-if="slotResolver.hasSlot('after')" :node="slotResolver.renderSlot('after', slotProps)" />
|
|
42
38
|
</template>
|
|
43
39
|
</UCollapsible>
|
|
@@ -45,7 +41,7 @@ const slotProps = computed(() => createSlotProps(field, extraProps));
|
|
|
45
41
|
<AutoFormRendererChildren
|
|
46
42
|
v-else-if="visibleFields.length"
|
|
47
43
|
:fields="visibleFields"
|
|
48
|
-
:schema="schema"
|
|
49
|
-
:extra-props="extraProps"
|
|
44
|
+
:schema="props.schema"
|
|
45
|
+
:extra-props="props.extraProps"
|
|
50
46
|
/>
|
|
51
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;
|
|
@@ -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 {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import WithClear from "
|
|
2
|
-
import WithPasswordToggle from "
|
|
3
|
-
import WithCopy from "
|
|
4
|
-
import WithCharacterLimit from "
|
|
5
|
-
import AsPhoneNumberInput from "
|
|
6
|
-
import WithFloatingLabel from "
|
|
7
|
-
import DatePicker from "
|
|
8
|
-
import ColorChooser from "
|
|
9
|
-
import StarRating from "
|
|
10
|
-
import SlideVerify from "
|
|
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";
|
|
11
12
|
import {
|
|
12
13
|
UInput,
|
|
13
14
|
UInputNumber,
|
|
@@ -24,7 +25,8 @@ import {
|
|
|
24
25
|
UCheckboxGroup,
|
|
25
26
|
URadioGroup,
|
|
26
27
|
UInputDate,
|
|
27
|
-
UInputTime
|
|
28
|
+
UInputTime,
|
|
29
|
+
UListbox
|
|
28
30
|
} from "#components";
|
|
29
31
|
const DEFAULT_CONTROL_PROPS = { class: "w-full" };
|
|
30
32
|
export function defineControl(e) {
|
|
@@ -45,26 +47,27 @@ const DEFAULT_CONTROL_COMPONENTS = {
|
|
|
45
47
|
enum: USelect,
|
|
46
48
|
file: UFileUpload,
|
|
47
49
|
calendarDate: DatePicker,
|
|
48
|
-
datePicker: DatePicker,
|
|
49
|
-
switch: USwitch,
|
|
50
|
-
textarea: UTextarea,
|
|
51
|
-
slider: USlider,
|
|
52
|
-
pinInput: UPinInput,
|
|
53
|
-
inputTags: UInputTags,
|
|
54
|
-
selectMenu: USelectMenu,
|
|
55
|
-
inputMenu: UInputMenu,
|
|
56
|
-
checkboxGroup: UCheckboxGroup,
|
|
57
|
-
radioGroup: URadioGroup,
|
|
58
50
|
inputDate: UInputDate,
|
|
59
51
|
inputTime: UInputTime,
|
|
60
52
|
withClear: WithClear,
|
|
61
53
|
withPasswordToggle: WithPasswordToggle,
|
|
62
54
|
withCopy: WithCopy,
|
|
63
55
|
withCharacterLimit: WithCharacterLimit,
|
|
64
|
-
asPhoneNumberInput: AsPhoneNumberInput,
|
|
65
56
|
withFloatingLabel: WithFloatingLabel,
|
|
66
|
-
|
|
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,
|
|
67
68
|
starRating: StarRating,
|
|
68
|
-
|
|
69
|
+
colorChooser: ColorChooser,
|
|
70
|
+
slideVerify: SlideVerify,
|
|
71
|
+
pillGroup: PillGroup
|
|
69
72
|
};
|
|
70
73
|
export const DEFAULT_CONTROLS = createControlMap(DEFAULT_CONTROL_COMPONENTS);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { VNode } from 'vue';
|
|
2
|
-
import type { AutoFormField } from '
|
|
2
|
+
import type { AutoFormField } from '../../types/auto-form';
|
|
3
|
+
/** 沿字段树回填带 defaultValue 的叶子节点,已存在值的路径不覆盖 */
|
|
4
|
+
export declare function applyFieldDefaults(fields: AutoFormField[], target: Record<string, any>): void;
|
|
3
5
|
/** 将字段列表分类为叶子/嵌套/数组/布局四组 */
|
|
4
6
|
export declare function classifyFields(fields: AutoFormField[]): {
|
|
5
7
|
leafFields: AutoFormField[];
|
|
@@ -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 = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObject } from "@movk/core";
|
|
2
|
-
import { AUTOFORM_META } from "
|
|
2
|
+
import { AUTOFORM_META } from "./constants.js";
|
|
3
3
|
export function applyMeta(schema, meta) {
|
|
4
4
|
const normalizedMeta = isObject(meta) ? meta : {};
|
|
5
5
|
return schema.meta(normalizedMeta);
|
|
@@ -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 "./reactive
|
|
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) || {},
|