@vinicunca/taman-ui 0.1.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/README.md +95 -0
- package/dist/_virtual/_/plugin-vue/export-helper.mjs +8 -0
- package/dist/components/auth/index.d.ts +2 -0
- package/dist/components/auth/index.mjs +2 -0
- package/dist/components/auth/taman-auth-form.mjs +67 -0
- package/dist/components/auth/taman-auth-form.vue.d.ts +31 -0
- package/dist/components/back-to-top/index.mjs +2 -0
- package/dist/components/back-to-top/taman-back-to-top.mjs +70 -0
- package/dist/components/back-to-top/taman-back-to-top.vue.d.ts +18 -0
- package/dist/components/button/check-group-selection.mjs +17 -0
- package/dist/components/button/index.d.ts +4 -0
- package/dist/components/button/index.mjs +3 -0
- package/dist/components/button/taman-button-check-group.mjs +132 -0
- package/dist/components/button/taman-button-check-group.types.d.ts +22 -0
- package/dist/components/button/taman-button-check-group.vue.d.ts +41 -0
- package/dist/components/button/taman-button-icon.mjs +105 -0
- package/dist/components/button/taman-button-icon.vue.d.ts +17 -0
- package/dist/components/descriptions/index.d.ts +4 -0
- package/dist/components/descriptions/index.mjs +3 -0
- package/dist/components/descriptions/taman-description-cell.mjs +116 -0
- package/dist/components/descriptions/taman-description-item.mjs +10 -0
- package/dist/components/descriptions/taman-description-item.vue.d.ts +5 -0
- package/dist/components/descriptions/taman-description-row.mjs +131 -0
- package/dist/components/descriptions/taman-description.mjs +78 -0
- package/dist/components/descriptions/taman-description.types.d.ts +51 -0
- package/dist/components/descriptions/taman-description.vue.d.ts +23 -0
- package/dist/components/descriptions/use-taman-description.mjs +161 -0
- package/dist/components/file-upload/index.d.ts +3 -0
- package/dist/components/file-upload/index.mjs +2 -0
- package/dist/components/file-upload/taman-file-upload.mjs +88 -0
- package/dist/components/file-upload/taman-file-upload.types.d.ts +10 -0
- package/dist/components/file-upload/taman-file-upload.vue.d.ts +21 -0
- package/dist/components/full-screen/full-screen.mjs +27 -0
- package/dist/components/full-screen/full-screen.vue.d.ts +8 -0
- package/dist/components/full-screen/index.mjs +2 -0
- package/dist/components/icon/icon.mjs +27 -0
- package/dist/components/icon/icon.vue.d.ts +9 -0
- package/dist/components/icon/index.d.ts +2 -0
- package/dist/components/icon/index.mjs +2 -0
- package/dist/components/index.d.ts +34 -0
- package/dist/components/index.mjs +31 -0
- package/dist/components/input/index.d.ts +5 -0
- package/dist/components/input/index.mjs +4 -0
- package/dist/components/input/password-strength.d.ts +7 -0
- package/dist/components/input/password-strength.mjs +21 -0
- package/dist/components/input/taman-input-currency.mjs +76 -0
- package/dist/components/input/taman-input-currency.types.d.ts +8 -0
- package/dist/components/input/taman-input-currency.vue.d.ts +15 -0
- package/dist/components/input/taman-input-password.mjs +99 -0
- package/dist/components/input/taman-input-password.vue.d.ts +17 -0
- package/dist/components/input-date/format-calendar-input-value.mjs +26 -0
- package/dist/components/input-date/index.d.ts +3 -0
- package/dist/components/input-date/index.mjs +2 -0
- package/dist/components/input-date/taman-input-date.mjs +116 -0
- package/dist/components/input-date/taman-input-date.types.d.ts +14 -0
- package/dist/components/input-date/taman-input-date.vue.d.ts +21 -0
- package/dist/components/loading/index.d.ts +3 -0
- package/dist/components/loading/index.mjs +2 -0
- package/dist/components/loading/taman-loading.mjs +64 -0
- package/dist/components/loading/taman-loading.vue.d.ts +25 -0
- package/dist/components/loading/types.d.ts +13 -0
- package/dist/components/logo/index.mjs +2 -0
- package/dist/components/logo/taman-logo.mjs +60 -0
- package/dist/components/logo/taman-logo.vue.d.ts +32 -0
- package/dist/components/render-content/index.d.ts +2 -0
- package/dist/components/render-content/index.mjs +2 -0
- package/dist/components/render-content/render-content.mjs +42 -0
- package/dist/components/render-content/render-content.vue.d.ts +31 -0
- package/dist/components/scrollbar/index.d.ts +2 -0
- package/dist/components/scrollbar/index.mjs +2 -0
- package/dist/components/scrollbar/scrollbar.mjs +136 -0
- package/dist/components/scrollbar/scrollbar.vue.d.ts +50 -0
- package/dist/form/components/form-actions.mjs +151 -0
- package/dist/form/components/form-field-array.mjs +154 -0
- package/dist/form/components/form-field-array.types.d.ts +18 -0
- package/dist/form/form-render/form-render-field-collapsible.mjs +32 -0
- package/dist/form/form-render/form-render-field-control.mjs +44 -0
- package/dist/form/form-render/form-render-form-field.mjs +408 -0
- package/dist/form/form-render/form-render-form-label.mjs +46 -0
- package/dist/form/form-render/form-render-form.mjs +163 -0
- package/dist/form/form-render/form-render-group.mjs +89 -0
- package/dist/form/form-render/form-render.context.mjs +10 -0
- package/dist/form/form-render/form-render.dependencies.mjs +101 -0
- package/dist/form/form-render/form-render.helper.mjs +31 -0
- package/dist/form/form-render/form-render.schema.mjs +209 -0
- package/dist/form/form-render/index.mjs +4 -0
- package/dist/form/form.api.d.ts +54 -0
- package/dist/form/form.api.mjs +324 -0
- package/dist/form/form.built-ins.d.ts +36 -0
- package/dist/form/form.built-ins.mjs +48 -0
- package/dist/form/form.codec.d.ts +17 -0
- package/dist/form/form.codec.mjs +45 -0
- package/dist/form/form.config.d.ts +6 -0
- package/dist/form/form.config.mjs +43 -0
- package/dist/form/form.empty-value.d.ts +4 -0
- package/dist/form/form.empty-value.mjs +20 -0
- package/dist/form/form.field-name.mjs +25 -0
- package/dist/form/form.rule-registry.mjs +10 -0
- package/dist/form/form.runtime-field.mjs +56 -0
- package/dist/form/form.runtime.mjs +235 -0
- package/dist/form/form.schema-defaults.mjs +36 -0
- package/dist/form/form.types.d.ts +315 -0
- package/dist/form/form.use-delayed-flag.mjs +35 -0
- package/dist/form/form.use-form-context.mjs +44 -0
- package/dist/form/form.use-taman-form.d.ts +7 -0
- package/dist/form/form.use-taman-form.mjs +36 -0
- package/dist/form/index.d.ts +8 -0
- package/dist/form/index.mjs +6 -0
- package/dist/form/taman-use-form.mjs +146 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.mjs +56 -0
- package/dist/layout/components/index.mjs +6 -0
- package/dist/layout/components/taman-core-button-collapse.mjs +38 -0
- package/dist/layout/components/taman-core-button-fixed.mjs +29 -0
- package/dist/layout/components/taman-core-layout-content.mjs +50 -0
- package/dist/layout/components/taman-core-layout-footer.mjs +38 -0
- package/dist/layout/components/taman-core-layout-header.mjs +48 -0
- package/dist/layout/components/taman-core-layout-sidebar.mjs +319 -0
- package/dist/layout/components/taman-core-layout-tabbar.mjs +21 -0
- package/dist/layout/composables/use-layout.mjs +31 -0
- package/dist/layout/composables/use-sidebar-drag.mjs +103 -0
- package/dist/layout/header-scroll-state.mjs +9 -0
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/index.mjs +2 -0
- package/dist/layout/taman-core-layout.d.ts +41 -0
- package/dist/layout/taman-core-layout.mjs +603 -0
- package/dist/layout/taman-core-layout.vue.d.ts +99 -0
- package/dist/menu/components/collapse-transition.mjs +82 -0
- package/dist/menu/components/index.mjs +5 -0
- package/dist/menu/components/normal-menu/index.d.ts +3 -0
- package/dist/menu/components/normal-menu/index.mjs +2 -0
- package/dist/menu/components/normal-menu/normal-menu.d.ts +11 -0
- package/dist/menu/components/normal-menu/normal-menu.mjs +50 -0
- package/dist/menu/components/normal-menu/normal-menu.vue.d.ts +19 -0
- package/dist/menu/components/taman-menu-badge-dot.mjs +23 -0
- package/dist/menu/components/taman-menu-badge.mjs +49 -0
- package/dist/menu/components/taman-menu-badge.vue.d.ts +9 -0
- package/dist/menu/components/taman-menu-item.mjs +124 -0
- package/dist/menu/components/taman-menu-root.mjs +250 -0
- package/dist/menu/components/taman-menu-sub-menu-content.mjs +83 -0
- package/dist/menu/components/taman-menu-sub-menu.mjs +216 -0
- package/dist/menu/composables/index.mjs +3 -0
- package/dist/menu/composables/use-menu-context.mjs +36 -0
- package/dist/menu/composables/use-menu-scroll.mjs +23 -0
- package/dist/menu/composables/use-menu.mjs +33 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.mjs +5 -0
- package/dist/menu/menu.constants.mjs +5 -0
- package/dist/menu/menu.types.d.ts +63 -0
- package/dist/menu/menu.utils.mjs +27 -0
- package/dist/menu/taman-menu.mjs +41 -0
- package/dist/menu/taman-menu.vue.d.ts +12 -0
- package/dist/menu/taman-sub-menu.mjs +75 -0
- package/dist/popup/alert/alert-builder.d.ts +8 -0
- package/dist/popup/alert/alert-builder.mjs +98 -0
- package/dist/popup/alert/alert-overlay.mjs +55 -0
- package/dist/popup/alert/alert.d.ts +43 -0
- package/dist/popup/alert/alert.mjs +10 -0
- package/dist/popup/alert/alert.vue.d.ts +26 -0
- package/dist/popup/alert/alert2.mjs +238 -0
- package/dist/popup/alert/index.d.ts +4 -0
- package/dist/popup/alert/index.mjs +4 -0
- package/dist/popup/dialog/dialog.api.d.ts +23 -0
- package/dist/popup/dialog/dialog.api.mjs +133 -0
- package/dist/popup/dialog/dialog.mjs +336 -0
- package/dist/popup/dialog/dialog.types.d.ts +60 -0
- package/dist/popup/dialog/dialog.vue.d.ts +46 -0
- package/dist/popup/dialog/index.d.ts +4 -0
- package/dist/popup/dialog/index.mjs +3 -0
- package/dist/popup/dialog/use-dialog-draggable.mjs +93 -0
- package/dist/popup/dialog/use-taman-dialog.d.ts +13 -0
- package/dist/popup/dialog/use-taman-dialog.mjs +106 -0
- package/dist/popup/drawer/drawer.api.d.ts +23 -0
- package/dist/popup/drawer/drawer.api.mjs +124 -0
- package/dist/popup/drawer/drawer.mjs +277 -0
- package/dist/popup/drawer/drawer.types.d.ts +56 -0
- package/dist/popup/drawer/drawer.vue.d.ts +47 -0
- package/dist/popup/drawer/index.d.ts +4 -0
- package/dist/popup/drawer/index.mjs +3 -0
- package/dist/popup/drawer/use-taman-drawer.d.ts +13 -0
- package/dist/popup/drawer/use-taman-drawer.mjs +109 -0
- package/dist/popup/index.d.ts +13 -0
- package/dist/popup/index.mjs +11 -0
- package/dist/tabs/components/index.mjs +2 -0
- package/dist/tabs/components/taman-tabs.mjs +158 -0
- package/dist/tabs/components/widgets/index.d.ts +4 -0
- package/dist/tabs/components/widgets/index.mjs +4 -0
- package/dist/tabs/components/widgets/tool-more.mjs +45 -0
- package/dist/tabs/components/widgets/tool-more.vue.d.ts +7 -0
- package/dist/tabs/components/widgets/tool-refresh.mjs +25 -0
- package/dist/tabs/components/widgets/tool-refresh.vue.d.ts +9 -0
- package/dist/tabs/components/widgets/tool-screen.mjs +29 -0
- package/dist/tabs/components/widgets/tool-screen.vue.d.ts +12 -0
- package/dist/tabs/index.d.ts +8 -0
- package/dist/tabs/index.mjs +6 -0
- package/dist/tabs/strict-context-menu.d.ts +10 -0
- package/dist/tabs/tabs.types.d.ts +30 -0
- package/dist/tabs/taman-tabs-view.mjs +101 -0
- package/dist/tabs/taman-tabs-view.vue.d.ts +18 -0
- package/dist/tabs/use-tabs-drag.mjs +69 -0
- package/dist/tabs/use-tabs-view-scroll.mjs +114 -0
- package/dist/ui/alert-dialog/alert-dialog-action.mjs +21 -0
- package/dist/ui/alert-dialog/alert-dialog-action.vue.d.ts +16 -0
- package/dist/ui/alert-dialog/alert-dialog-cancel.mjs +21 -0
- package/dist/ui/alert-dialog/alert-dialog-cancel.vue.d.ts +16 -0
- package/dist/ui/alert-dialog/alert-dialog-content.mjs +111 -0
- package/dist/ui/alert-dialog/alert-dialog-content.vue.d.ts +49 -0
- package/dist/ui/alert-dialog/alert-dialog-description.mjs +30 -0
- package/dist/ui/alert-dialog/alert-dialog-description.vue.d.ts +20 -0
- package/dist/ui/alert-dialog/alert-dialog-footer.mjs +14 -0
- package/dist/ui/alert-dialog/alert-dialog-footer.vue.d.ts +15 -0
- package/dist/ui/alert-dialog/alert-dialog-header.mjs +14 -0
- package/dist/ui/alert-dialog/alert-dialog-header.vue.d.ts +15 -0
- package/dist/ui/alert-dialog/alert-dialog-overlay.mjs +29 -0
- package/dist/ui/alert-dialog/alert-dialog-root.mjs +23 -0
- package/dist/ui/alert-dialog/alert-dialog-root.vue.d.ts +23 -0
- package/dist/ui/alert-dialog/alert-dialog-title.mjs +30 -0
- package/dist/ui/alert-dialog/alert-dialog-title.vue.d.ts +20 -0
- package/dist/ui/alert-dialog/alert-dialog-trigger.mjs +21 -0
- package/dist/ui/alert-dialog/alert-dialog-trigger.vue.d.ts +16 -0
- package/dist/ui/alert-dialog/index.d.ts +10 -0
- package/dist/ui/alert-dialog/index.mjs +10 -0
- package/dist/ui/dialog/dialog-close.mjs +21 -0
- package/dist/ui/dialog/dialog-close.vue.d.ts +16 -0
- package/dist/ui/dialog/dialog-content.mjs +111 -0
- package/dist/ui/dialog/dialog-content.vue.d.ts +51 -0
- package/dist/ui/dialog/dialog-description.mjs +31 -0
- package/dist/ui/dialog/dialog-description.vue.d.ts +20 -0
- package/dist/ui/dialog/dialog-footer.mjs +14 -0
- package/dist/ui/dialog/dialog-footer.vue.d.ts +15 -0
- package/dist/ui/dialog/dialog-header.mjs +14 -0
- package/dist/ui/dialog/dialog-header.vue.d.ts +15 -0
- package/dist/ui/dialog/dialog-overlay.mjs +34 -0
- package/dist/ui/dialog/dialog-overlay.vue.d.ts +14 -0
- package/dist/ui/dialog/dialog-root.mjs +24 -0
- package/dist/ui/dialog/dialog-root.vue.d.ts +23 -0
- package/dist/ui/dialog/dialog-title.mjs +31 -0
- package/dist/ui/dialog/dialog-title.vue.d.ts +20 -0
- package/dist/ui/dialog/dialog-trigger.mjs +21 -0
- package/dist/ui/dialog/dialog-trigger.vue.d.ts +16 -0
- package/dist/ui/dialog/index.d.ts +10 -0
- package/dist/ui/dialog/index.mjs +10 -0
- package/dist/ui/dialog/use-dialog-state-events.mjs +60 -0
- package/dist/ui/form/form-control.mjs +27 -0
- package/dist/ui/form/form-control.vue.d.ts +15 -0
- package/dist/ui/form/form-description.mjs +27 -0
- package/dist/ui/form/form-description.vue.d.ts +19 -0
- package/dist/ui/form/form-field.mjs +37 -0
- package/dist/ui/form/form-field.vue.d.ts +27 -0
- package/dist/ui/form/form-item.mjs +27 -0
- package/dist/ui/form/form-item.vue.d.ts +19 -0
- package/dist/ui/form/form-label.mjs +41 -0
- package/dist/ui/form/form-label.vue.d.ts +20 -0
- package/dist/ui/form/form-message.mjs +28 -0
- package/dist/ui/form/form-message.vue.d.ts +9 -0
- package/dist/ui/form/index.d.ts +8 -0
- package/dist/ui/form/index.mjs +8 -0
- package/dist/ui/form/injection-keys.d.ts +13 -0
- package/dist/ui/form/injection-keys.mjs +5 -0
- package/dist/ui/form/use-form-field.mjs +27 -0
- package/dist/ui/index.d.ts +42 -0
- package/dist/ui/index.mjs +42 -0
- package/dist/ui/label/index.d.ts +2 -0
- package/dist/ui/label/index.mjs +2 -0
- package/dist/ui/label/label.mjs +31 -0
- package/dist/ui/label/label.vue.d.ts +20 -0
- package/dist/ui/scroll-area/index.d.ts +3 -0
- package/dist/ui/scroll-area/index.mjs +3 -0
- package/dist/ui/scroll-area/scroll-area.mjs +47 -0
- package/dist/ui/scroll-area/scroll-area.vue.d.ts +21 -0
- package/dist/ui/scroll-area/scroll-bar.mjs +38 -0
- package/dist/ui/scroll-area/scroll-bar.vue.d.ts +12 -0
- package/dist/ui/sheet/index.d.ts +8 -0
- package/dist/ui/sheet/index.mjs +8 -0
- package/dist/ui/sheet/sheet-close.mjs +21 -0
- package/dist/ui/sheet/sheet-close.vue.d.ts +16 -0
- package/dist/ui/sheet/sheet-content.mjs +105 -0
- package/dist/ui/sheet/sheet-content.vue.d.ts +48 -0
- package/dist/ui/sheet/sheet-description.mjs +30 -0
- package/dist/ui/sheet/sheet-description.vue.d.ts +20 -0
- package/dist/ui/sheet/sheet-footer.mjs +14 -0
- package/dist/ui/sheet/sheet-footer.vue.d.ts +15 -0
- package/dist/ui/sheet/sheet-header.mjs +14 -0
- package/dist/ui/sheet/sheet-header.vue.d.ts +15 -0
- package/dist/ui/sheet/sheet-overlay.mjs +32 -0
- package/dist/ui/sheet/sheet-root.mjs +24 -0
- package/dist/ui/sheet/sheet-root.vue.d.ts +23 -0
- package/dist/ui/sheet/sheet-title.mjs +31 -0
- package/dist/ui/sheet/sheet-title.vue.d.ts +20 -0
- package/dist/ui/sheet/sheet.variants.d.ts +27 -0
- package/dist/ui/sheet/sheet.variants.mjs +12 -0
- package/dist/unocss/content.d.ts +4 -0
- package/dist/unocss/content.mjs +9 -0
- package/dist/unocss/index.d.ts +2 -0
- package/dist/unocss/index.mjs +2 -0
- package/package.json +78 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import _sfc_main$1 from "../../components/render-content/render-content.mjs";
|
|
2
|
+
import _sfc_main$2 from "../../components/button/taman-button-icon.mjs";
|
|
3
|
+
import "../../index.mjs";
|
|
4
|
+
import { createArrayChildSchema } from "../form-render/form-render.schema.mjs";
|
|
5
|
+
import { injectRenderFormProps } from "../form-render/form-render.context.mjs";
|
|
6
|
+
import _sfc_main$3 from "../form-render/form-render-form-field.mjs";
|
|
7
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, openBlock, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
8
|
+
import PButton from "pohon-ui/components/Button.vue";
|
|
9
|
+
import { get, set } from "@vinicunca/taman-core/utils";
|
|
10
|
+
//#region src/form/components/form-field-array.vue
|
|
11
|
+
const _hoisted_1 = { class: "border border-border/70 rounded-md overflow-hidden" };
|
|
12
|
+
const _hoisted_2 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "text-sm color-text-muted font-normal px-2 py-2 text-left"
|
|
15
|
+
};
|
|
16
|
+
const _hoisted_3 = { class: "text-sm color-text-muted font-normal px-2 py-2 text-left" };
|
|
17
|
+
const _hoisted_4 = {
|
|
18
|
+
key: 0,
|
|
19
|
+
class: "text-sm color-text-muted mb-2 sm:mb-0 sm:px-4 sm:py-3"
|
|
20
|
+
};
|
|
21
|
+
const _hoisted_5 = { class: "text-xs color-text-muted font-medium mb-1 sm:hidden" };
|
|
22
|
+
const _hoisted_6 = { class: "pt-1 flex justify-end sm:px-2 sm:py-3 sm:block" };
|
|
23
|
+
const _hoisted_7 = {
|
|
24
|
+
key: 0,
|
|
25
|
+
class: "text-sm color-text-muted py-6 text-center"
|
|
26
|
+
};
|
|
27
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
28
|
+
name: "TamanFormFieldArray",
|
|
29
|
+
inheritAttrs: false,
|
|
30
|
+
__name: "form-field-array",
|
|
31
|
+
props: {
|
|
32
|
+
actionText: { default: "Action" },
|
|
33
|
+
addButtonText: { default: "Add a row" },
|
|
34
|
+
commonConfig: { default: () => ({}) },
|
|
35
|
+
createRow: {
|
|
36
|
+
type: Function,
|
|
37
|
+
default: void 0
|
|
38
|
+
},
|
|
39
|
+
disabled: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
43
|
+
emptyText: { default: "No data" },
|
|
44
|
+
globalCommonConfig: { default: () => ({}) },
|
|
45
|
+
max: { default: Number.POSITIVE_INFINITY },
|
|
46
|
+
min: { default: 0 },
|
|
47
|
+
name: { default: "" },
|
|
48
|
+
schema: { default: () => [] },
|
|
49
|
+
showIndex: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
setup(__props) {
|
|
55
|
+
const props = __props;
|
|
56
|
+
const arrayPath = computed(() => props.name);
|
|
57
|
+
const form = injectRenderFormProps().form;
|
|
58
|
+
if (!form) throw new Error("Form api is required in <TamanFormFieldArray />");
|
|
59
|
+
const formActions = form;
|
|
60
|
+
const arrayLength = formActions.useSelector((state) => {
|
|
61
|
+
const value = get(state.values, props.name);
|
|
62
|
+
return Array.isArray(value) ? value.length : 0;
|
|
63
|
+
});
|
|
64
|
+
const rowIndexes = computed(() => Array.from({ length: arrayLength.value }, (_, index) => index));
|
|
65
|
+
const canAdd = computed(() => arrayLength.value < props.max);
|
|
66
|
+
const canRemove = computed(() => arrayLength.value > props.min);
|
|
67
|
+
const gridStyle = computed(() => {
|
|
68
|
+
return { gridTemplateColumns: [
|
|
69
|
+
...props.showIndex ? ["3rem"] : [],
|
|
70
|
+
...props.schema.map(() => "minmax(0, 1fr)"),
|
|
71
|
+
"4rem"
|
|
72
|
+
].join(" ") };
|
|
73
|
+
});
|
|
74
|
+
function buildDefaultRow() {
|
|
75
|
+
if (props.createRow) return props.createRow();
|
|
76
|
+
const row = {};
|
|
77
|
+
props.schema.forEach((col) => {
|
|
78
|
+
let value = null;
|
|
79
|
+
if (Reflect.has(col, "defaultValue") && col.defaultValue !== void 0) value = col.defaultValue;
|
|
80
|
+
else if ("type" in col && col.type === "array") value = [];
|
|
81
|
+
set(row, col.fieldName, value);
|
|
82
|
+
});
|
|
83
|
+
return row;
|
|
84
|
+
}
|
|
85
|
+
function addRow() {
|
|
86
|
+
if (props.disabled || !canAdd.value) return;
|
|
87
|
+
formActions.pushFieldValue(arrayPath.value, buildDefaultRow());
|
|
88
|
+
}
|
|
89
|
+
function removeRow(index) {
|
|
90
|
+
if (props.disabled || !canRemove.value) return;
|
|
91
|
+
formActions.removeFieldValue(arrayPath.value, index);
|
|
92
|
+
}
|
|
93
|
+
function rowSchemas(index) {
|
|
94
|
+
return props.schema.map((col) => createArrayChildSchema(col, {
|
|
95
|
+
arrayField: arrayPath.value,
|
|
96
|
+
commonConfig: props.commonConfig,
|
|
97
|
+
disabled: props.disabled,
|
|
98
|
+
globalCommonConfig: props.globalCommonConfig,
|
|
99
|
+
index
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
const normalizedRowSchemas = computed(() => Array.from({ length: arrayLength.value }, (_, index) => rowSchemas(index)));
|
|
103
|
+
return (_ctx, _cache) => {
|
|
104
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass(["w-full", [_ctx.$attrs.class]]) }, [createElementVNode("div", _hoisted_1, [
|
|
105
|
+
createElementVNode("div", {
|
|
106
|
+
class: "px-2 border-b border-border bg-background-muted/30 hidden sm:grid",
|
|
107
|
+
style: normalizeStyle(gridStyle.value)
|
|
108
|
+
}, [
|
|
109
|
+
__props.showIndex ? (openBlock(), createElementBlock("div", _hoisted_2, " # ")) : createCommentVNode("v-if", true),
|
|
110
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.schema, (col) => {
|
|
111
|
+
return openBlock(), createElementBlock("div", {
|
|
112
|
+
key: col.fieldName,
|
|
113
|
+
class: "text-sm color-text-muted font-normal px-2 py-2 text-left"
|
|
114
|
+
}, [createVNode(unref(_sfc_main$1), { content: col.label }, null, 8, ["content"])]);
|
|
115
|
+
}), 128)),
|
|
116
|
+
createElementVNode("div", _hoisted_3, toDisplayString(__props.actionText), 1)
|
|
117
|
+
], 4),
|
|
118
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(rowIndexes.value, (index) => {
|
|
119
|
+
return openBlock(), createElementBlock("div", {
|
|
120
|
+
key: `${arrayPath.value}-${index}`,
|
|
121
|
+
class: "p-3 border-b border-border/60 sm:p-0 last:border-b-0 sm:grid",
|
|
122
|
+
style: normalizeStyle(gridStyle.value)
|
|
123
|
+
}, [
|
|
124
|
+
__props.showIndex ? (openBlock(), createElementBlock("div", _hoisted_4, [_cache[0] || (_cache[0] = createElementVNode("span", { class: "sm:hidden" }, "#", -1)), createTextVNode(" " + toDisplayString(index + 1), 1)])) : createCommentVNode("v-if", true),
|
|
125
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(normalizedRowSchemas.value[index], (childSchema, childIndex) => {
|
|
126
|
+
return openBlock(), createElementBlock("div", {
|
|
127
|
+
key: childSchema.fieldName,
|
|
128
|
+
class: "py-2 min-w-0 sm:px-2"
|
|
129
|
+
}, [createElementVNode("div", _hoisted_5, [createVNode(unref(_sfc_main$1), { content: __props.schema?.[childIndex]?.label }, null, 8, ["content"])]), createVNode(_sfc_main$3, mergeProps({ ref_for: true }, childSchema, { class: childSchema.formItemClass }), null, 16, ["class"])]);
|
|
130
|
+
}), 128)),
|
|
131
|
+
createElementVNode("div", _hoisted_6, [createVNode(unref(_sfc_main$2), {
|
|
132
|
+
disabled: __props.disabled || !canRemove.value,
|
|
133
|
+
"on-click": () => removeRow(index),
|
|
134
|
+
icon: "lucide:x"
|
|
135
|
+
}, null, 8, ["disabled", "on-click"])])
|
|
136
|
+
], 4);
|
|
137
|
+
}), 128)),
|
|
138
|
+
unref(arrayLength) === 0 ? (openBlock(), createElementBlock("div", _hoisted_7, toDisplayString(__props.emptyText), 1)) : createCommentVNode("v-if", true)
|
|
139
|
+
]), createVNode(PButton, {
|
|
140
|
+
variant: "outline",
|
|
141
|
+
size: "sm",
|
|
142
|
+
disabled: __props.disabled || !canAdd.value,
|
|
143
|
+
class: "mt-3 border-dashed w-full",
|
|
144
|
+
icon: "lucide:plus",
|
|
145
|
+
onClick: addRow
|
|
146
|
+
}, {
|
|
147
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.addButtonText), 1)]),
|
|
148
|
+
_: 1
|
|
149
|
+
}, 8, ["disabled"])], 2);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
//#endregion
|
|
154
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FormCommonConfig, FormFieldSchema } from "../form.types.js";
|
|
2
|
+
//#region src/form/components/form-field-array.types.d.ts
|
|
3
|
+
interface TamanFormFieldArrayProps {
|
|
4
|
+
actionText?: string;
|
|
5
|
+
addButtonText?: string;
|
|
6
|
+
commonConfig?: FormCommonConfig;
|
|
7
|
+
createRow?: () => Record<string, any>;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
emptyText?: string;
|
|
10
|
+
globalCommonConfig?: FormCommonConfig;
|
|
11
|
+
max?: number;
|
|
12
|
+
min?: number;
|
|
13
|
+
name?: string;
|
|
14
|
+
schema?: Array<FormFieldSchema>;
|
|
15
|
+
showIndex?: boolean;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { TamanFormFieldArrayProps };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createBlock, defineComponent, mergeModels, openBlock, renderSlot, useModel, withCtx } from "vue";
|
|
2
|
+
import PCollapsible from "pohon-ui/components/Collapsible.vue";
|
|
3
|
+
//#region src/form/form-render/form-render-field-collapsible.vue
|
|
4
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
__name: "form-render-field-collapsible",
|
|
7
|
+
props: /*@__PURE__*/ mergeModels({ collapsible: { type: Boolean } }, {
|
|
8
|
+
"open": {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: true
|
|
11
|
+
},
|
|
12
|
+
"openModifiers": {}
|
|
13
|
+
}),
|
|
14
|
+
emits: ["update:open"],
|
|
15
|
+
setup(__props) {
|
|
16
|
+
const props = __props;
|
|
17
|
+
const open = useModel(__props, "open");
|
|
18
|
+
return (_ctx, _cache) => {
|
|
19
|
+
return props.collapsible ? (openBlock(), createBlock(PCollapsible, {
|
|
20
|
+
key: 0,
|
|
21
|
+
open: open.value,
|
|
22
|
+
"onUpdate:open": _cache[0] || (_cache[0] = ($event) => open.value = $event),
|
|
23
|
+
"unmount-on-hide": false
|
|
24
|
+
}, {
|
|
25
|
+
content: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
26
|
+
_: 3
|
|
27
|
+
}, 8, ["open"])) : renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 1);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
//#endregion
|
|
32
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _sfc_main$1 from "../../components/render-content/render-content.mjs";
|
|
2
|
+
import _sfc_main$2 from "../../ui/form/form-control.mjs";
|
|
3
|
+
import "../../index.mjs";
|
|
4
|
+
import { createCommentVNode, createElementBlock, createVNode, defineComponent, normalizeClass, openBlock, renderSlot, unref, withCtx } from "vue";
|
|
5
|
+
//#region src/form/form-render/form-render-field-control.vue
|
|
6
|
+
const _hoisted_1 = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "ml-1"
|
|
9
|
+
};
|
|
10
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
11
|
+
__name: "form-render-field-control",
|
|
12
|
+
props: {
|
|
13
|
+
controlClass: { type: [
|
|
14
|
+
Boolean,
|
|
15
|
+
null,
|
|
16
|
+
String,
|
|
17
|
+
Object,
|
|
18
|
+
Array
|
|
19
|
+
] },
|
|
20
|
+
suffix: { type: [Function, String] },
|
|
21
|
+
wrapperClass: { type: [
|
|
22
|
+
Boolean,
|
|
23
|
+
null,
|
|
24
|
+
String,
|
|
25
|
+
Object,
|
|
26
|
+
Array
|
|
27
|
+
] }
|
|
28
|
+
},
|
|
29
|
+
setup(__props) {
|
|
30
|
+
const props = __props;
|
|
31
|
+
return (_ctx, _cache) => {
|
|
32
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass(["flex w-full items-center relative", [props.wrapperClass]]) }, [
|
|
33
|
+
createVNode(unref(_sfc_main$2), { class: normalizeClass(props.controlClass) }, {
|
|
34
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
35
|
+
_: 3
|
|
36
|
+
}, 8, ["class"]),
|
|
37
|
+
createCommentVNode(" Custom suffix "),
|
|
38
|
+
props.suffix ? (openBlock(), createElementBlock("div", _hoisted_1, [createVNode(unref(_sfc_main$1), { content: props.suffix }, null, 8, ["content"])])) : createCommentVNode("v-if", true)
|
|
39
|
+
], 2);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import _sfc_main$1 from "../../components/render-content/render-content.mjs";
|
|
2
|
+
import _sfc_main$2 from "../../ui/form/form-description.mjs";
|
|
3
|
+
import _sfc_main$3 from "../../ui/form/form-field.mjs";
|
|
4
|
+
import _sfc_main$4 from "../../ui/form/form-item.mjs";
|
|
5
|
+
import _sfc_main$5 from "../../ui/form/form-message.mjs";
|
|
6
|
+
import "../../index.mjs";
|
|
7
|
+
import { toFormFieldValue } from "../form.empty-value.mjs";
|
|
8
|
+
import { getFormRule } from "../form.rule-registry.mjs";
|
|
9
|
+
import { useDelayedFlag } from "../form.use-delayed-flag.mjs";
|
|
10
|
+
import { injectComponentRefMap } from "../form.use-form-context.mjs";
|
|
11
|
+
import _sfc_main$6 from "./form-render-field-collapsible.mjs";
|
|
12
|
+
import _sfc_main$7 from "./form-render-field-control.mjs";
|
|
13
|
+
import _sfc_main$8 from "./form-render-form-label.mjs";
|
|
14
|
+
import { injectRenderFormProps, useFormContext } from "./form-render.context.mjs";
|
|
15
|
+
import useDependencies from "./form-render.dependencies.mjs";
|
|
16
|
+
import { getBaseRules } from "./form-render.helper.mjs";
|
|
17
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createVNode, defineComponent, guardReactiveProps, markRaw, mergeProps, nextTick, normalizeClass, normalizeProps, onUnmounted, openBlock, ref, renderList, renderSlot, resolveDirective, resolveDynamicComponent, toRaw, unref, useTemplateRef, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
|
|
18
|
+
import PButton from "pohon-ui/components/Button.vue";
|
|
19
|
+
import { isFunction, isString } from "@vinicunca/taman-core/utils";
|
|
20
|
+
import { globalShareState } from "@vinicunca/taman-core/global-state";
|
|
21
|
+
//#region src/form/form-render/form-render-form-field.vue
|
|
22
|
+
const _hoisted_1 = {
|
|
23
|
+
key: 0,
|
|
24
|
+
class: "flex items-center"
|
|
25
|
+
};
|
|
26
|
+
const _hoisted_2 = { class: "p-px flex-auto w-full" };
|
|
27
|
+
const _hoisted_3 = { key: 1 };
|
|
28
|
+
const VALIDATION_LOADING_DELAY_MS = 150;
|
|
29
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
30
|
+
__name: "form-render-form-field",
|
|
31
|
+
props: {
|
|
32
|
+
component: {},
|
|
33
|
+
componentProps: {},
|
|
34
|
+
collapsed: { type: Boolean },
|
|
35
|
+
defaultValue: {},
|
|
36
|
+
dependencies: {},
|
|
37
|
+
description: {},
|
|
38
|
+
fieldName: {},
|
|
39
|
+
help: {},
|
|
40
|
+
hide: { type: Boolean },
|
|
41
|
+
label: {},
|
|
42
|
+
renderComponentContent: {},
|
|
43
|
+
rules: {},
|
|
44
|
+
suffix: {},
|
|
45
|
+
collapsible: { type: Boolean },
|
|
46
|
+
controlClass: {},
|
|
47
|
+
defaultCollapsed: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
disabled: { type: Boolean },
|
|
52
|
+
formFieldProps: {},
|
|
53
|
+
formItemClass: {},
|
|
54
|
+
hideLabel: { type: Boolean },
|
|
55
|
+
hideMessage: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
hideRequiredMark: { type: Boolean },
|
|
60
|
+
labelClass: {},
|
|
61
|
+
modelPropName: {},
|
|
62
|
+
wrapperClass: {},
|
|
63
|
+
commonComponentProps: {},
|
|
64
|
+
hidden: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
setup(__props) {
|
|
70
|
+
const props = __props;
|
|
71
|
+
const { componentMap } = useFormContext();
|
|
72
|
+
const formRenderProps = injectRenderFormProps();
|
|
73
|
+
const fieldComponentRef = useTemplateRef("fieldComponentRef");
|
|
74
|
+
const formApi = formRenderProps.form;
|
|
75
|
+
if (!formApi) throw new Error("Form api is required in <FormField />");
|
|
76
|
+
const error = formApi.useFieldError(props.fieldName);
|
|
77
|
+
const fieldValue = formApi.useFieldValue(props.fieldName);
|
|
78
|
+
const isFieldValidating = formApi.useFieldValidating(props.fieldName);
|
|
79
|
+
const validationLoading = useDelayedFlag(() => isFieldValidating.value, VALIDATION_LOADING_DELAY_MS);
|
|
80
|
+
const compact = computed(() => formRenderProps.compact);
|
|
81
|
+
const isInValid = computed(() => Boolean(error.value));
|
|
82
|
+
const shouldApplyInvalidStyle = computed(() => {
|
|
83
|
+
return isInValid.value && props.component !== "TamanFormFieldArray";
|
|
84
|
+
});
|
|
85
|
+
const collapseOpen = ref(!props.defaultCollapsed);
|
|
86
|
+
const FieldComponent = computed(() => {
|
|
87
|
+
const { component } = props;
|
|
88
|
+
const finalComponent = isString(component) ? componentMap.value[component] ?? globalShareState.getComponents()[component] : component;
|
|
89
|
+
if (!finalComponent) console.warn(`Component ${component} is not registered`);
|
|
90
|
+
return finalComponent ? markRaw(toRaw(finalComponent)) : finalComponent;
|
|
91
|
+
});
|
|
92
|
+
const { dynamicComponentProps, dynamicHelp, dynamicHelpResolved, dynamicRenderComponentContent, dynamicRenderComponentContentResolved, dynamicRules, dynamicRulesResolved, isDisabled, isIf, isRequired, isShow } = useDependencies(() => props.dependencies, () => ({ fieldName: props.fieldName }));
|
|
93
|
+
const currentRules = computed(() => {
|
|
94
|
+
const currentRule = dynamicRulesResolved.value ? dynamicRules.value : props.rules;
|
|
95
|
+
return currentRule && !isString(currentRule) ? toRaw(currentRule) : currentRule;
|
|
96
|
+
});
|
|
97
|
+
const visible = computed(() => {
|
|
98
|
+
return !props.hide && isIf.value && isShow.value;
|
|
99
|
+
});
|
|
100
|
+
const shouldRequired = computed(() => {
|
|
101
|
+
if (!visible.value) return false;
|
|
102
|
+
if (!currentRules.value) return isRequired.value;
|
|
103
|
+
if (isRequired.value) return true;
|
|
104
|
+
if (isString(currentRules.value)) return ["required", "selectRequired"].includes(currentRules.value);
|
|
105
|
+
return !currentRules.value.isOptional();
|
|
106
|
+
});
|
|
107
|
+
const fieldRules = computed(() => {
|
|
108
|
+
if (!visible.value) return null;
|
|
109
|
+
let rules = currentRules.value;
|
|
110
|
+
if (!rules) return isRequired.value ? "required" : null;
|
|
111
|
+
if (isString(rules)) return rules;
|
|
112
|
+
if (!!shouldRequired.value) rules = getBaseRules(rules) ?? rules;
|
|
113
|
+
return rules;
|
|
114
|
+
});
|
|
115
|
+
function createNamedRuleValidator(ruleName) {
|
|
116
|
+
return ({ value }) => {
|
|
117
|
+
const validator = getFormRule(ruleName);
|
|
118
|
+
if (!validator) {
|
|
119
|
+
console.warn(`Form rule ${ruleName} is not registered`);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const { label, fieldName } = props;
|
|
123
|
+
const result = validator(value, [], {
|
|
124
|
+
field: {
|
|
125
|
+
label: isString(label) ? label : void 0,
|
|
126
|
+
name: fieldName
|
|
127
|
+
},
|
|
128
|
+
label: isString(label) ? label : void 0,
|
|
129
|
+
name: fieldName
|
|
130
|
+
});
|
|
131
|
+
return result === true ? void 0 : result;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function validateDynamicRules({ value }) {
|
|
135
|
+
const activeRules = fieldRules.value;
|
|
136
|
+
if (!activeRules) return;
|
|
137
|
+
if (isString(activeRules)) return createNamedRuleValidator(activeRules)({ value });
|
|
138
|
+
const result = activeRules.safeParse(value);
|
|
139
|
+
return result.success ? void 0 : result.error.issues;
|
|
140
|
+
}
|
|
141
|
+
function createRuleValidator() {
|
|
142
|
+
const activeRules = fieldRules.value;
|
|
143
|
+
if (!activeRules) return props.dependencies ? validateDynamicRules : void 0;
|
|
144
|
+
if (props.dependencies) return validateDynamicRules;
|
|
145
|
+
if (isString(activeRules)) return createNamedRuleValidator(activeRules);
|
|
146
|
+
return activeRules;
|
|
147
|
+
}
|
|
148
|
+
const fieldValidators = computed(() => {
|
|
149
|
+
const validators = {};
|
|
150
|
+
const ruleValidator = createRuleValidator();
|
|
151
|
+
if (ruleValidator) {
|
|
152
|
+
const configuredTriggers = props.formFieldProps?.validateOn;
|
|
153
|
+
if (configuredTriggers === void 0) validators.onDynamic = ruleValidator;
|
|
154
|
+
else {
|
|
155
|
+
const validateOn = new Set(configuredTriggers);
|
|
156
|
+
if (validateOn.has("blur")) validators.onBlur = ruleValidator;
|
|
157
|
+
if (validateOn.has("change")) validators.onChange = ruleValidator;
|
|
158
|
+
if (validateOn.size === 0) validators.onSubmit = ruleValidator;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
...validators,
|
|
163
|
+
...props.formFieldProps?.validators
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
function normalizeIssues(errors) {
|
|
167
|
+
const issues = [];
|
|
168
|
+
const seen = /* @__PURE__ */ new Set();
|
|
169
|
+
function visit(error) {
|
|
170
|
+
if (Array.isArray(error)) {
|
|
171
|
+
error.forEach(visit);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
let message;
|
|
175
|
+
if (isString(error)) message = error;
|
|
176
|
+
else if (error && typeof error === "object" && "message" in error) message = Reflect.get(error, "message");
|
|
177
|
+
if (!isString(message)) return;
|
|
178
|
+
const rawPath = error && typeof error === "object" && "path" in error ? Reflect.get(error, "path") : void 0;
|
|
179
|
+
const path = Array.isArray(rawPath) ? [...rawPath] : [];
|
|
180
|
+
const key = `${message}:${JSON.stringify(path)}`;
|
|
181
|
+
if (!seen.has(key)) {
|
|
182
|
+
seen.add(key);
|
|
183
|
+
issues.push({
|
|
184
|
+
message,
|
|
185
|
+
path
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
errors.forEach(visit);
|
|
190
|
+
return issues;
|
|
191
|
+
}
|
|
192
|
+
const computedProps = computed(() => {
|
|
193
|
+
const { componentProps, commonComponentProps, fieldName } = props;
|
|
194
|
+
const finalComponentProps = isFunction(componentProps) ? componentProps({ fieldName }) : componentProps;
|
|
195
|
+
return {
|
|
196
|
+
...commonComponentProps,
|
|
197
|
+
...finalComponentProps,
|
|
198
|
+
...dynamicComponentProps.value
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
const computedHelp = computed(() => {
|
|
202
|
+
const helpContent = dynamicHelpResolved.value ? dynamicHelp.value : props.help;
|
|
203
|
+
if (!helpContent) return;
|
|
204
|
+
return () => isFunction(helpContent) ? helpContent({ fieldName: props.fieldName }) : helpContent;
|
|
205
|
+
});
|
|
206
|
+
watch(() => computedProps.value?.autofocus, (value) => {
|
|
207
|
+
if (value === true) nextTick(() => {
|
|
208
|
+
autofocus();
|
|
209
|
+
});
|
|
210
|
+
}, { immediate: true });
|
|
211
|
+
const shouldDisabled = computed(() => {
|
|
212
|
+
return Boolean(formRenderProps.disabled || isDisabled.value || props.disabled || computedProps.value?.disabled);
|
|
213
|
+
});
|
|
214
|
+
const customContentRender = computed(() => {
|
|
215
|
+
if (dynamicRenderComponentContentResolved.value) return dynamicRenderComponentContent.value ?? {};
|
|
216
|
+
if (!isFunction(props.renderComponentContent)) return {};
|
|
217
|
+
return props.renderComponentContent({ fieldName: props.fieldName });
|
|
218
|
+
});
|
|
219
|
+
const renderContentKey = computed(() => {
|
|
220
|
+
return Object.keys(customContentRender.value);
|
|
221
|
+
});
|
|
222
|
+
const fieldProps = computed(() => {
|
|
223
|
+
return {
|
|
224
|
+
asyncDebounceMs: props.formFieldProps?.asyncDebounceMs,
|
|
225
|
+
validators: fieldValidators.value
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
function createFieldSlotProps(slotProps) {
|
|
229
|
+
const { field } = slotProps;
|
|
230
|
+
function handleChange(value) {
|
|
231
|
+
field.handleChange(toFormFieldValue(value));
|
|
232
|
+
if (fieldRules.value) field.setErrorMap({ onBlur: void 0 });
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
...slotProps,
|
|
236
|
+
componentField: {
|
|
237
|
+
"name": props.fieldName,
|
|
238
|
+
"modelValue": fieldValue.value,
|
|
239
|
+
"onBlur": field.handleBlur,
|
|
240
|
+
"onChange": handleChange,
|
|
241
|
+
"onInput": handleChange,
|
|
242
|
+
"onUpdate:modelValue": handleChange
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function resolveModelPropName() {
|
|
247
|
+
return props.modelPropName;
|
|
248
|
+
}
|
|
249
|
+
function fieldBindEvent(componentField, bindEventField) {
|
|
250
|
+
const modelValue = componentField.modelValue;
|
|
251
|
+
const handler = componentField["onUpdate:modelValue"];
|
|
252
|
+
if (bindEventField) return {
|
|
253
|
+
[`onUpdate:${bindEventField}`]: handler,
|
|
254
|
+
[bindEventField]: modelValue,
|
|
255
|
+
onChange: void 0,
|
|
256
|
+
onInput: void 0
|
|
257
|
+
};
|
|
258
|
+
return {
|
|
259
|
+
onChange: void 0,
|
|
260
|
+
onInput: void 0
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function createComponentProps(slotProps) {
|
|
264
|
+
const normalizedSlotProps = createFieldSlotProps(slotProps);
|
|
265
|
+
const bindEventField = resolveModelPropName();
|
|
266
|
+
const bindEvents = fieldBindEvent(normalizedSlotProps.componentField, bindEventField);
|
|
267
|
+
const binds = {
|
|
268
|
+
...computedProps.value,
|
|
269
|
+
...shouldApplyInvalidStyle.value ? {
|
|
270
|
+
color: "error",
|
|
271
|
+
highlight: true
|
|
272
|
+
} : {},
|
|
273
|
+
loading: Boolean(computedProps.value?.loading) || validationLoading.value,
|
|
274
|
+
...normalizedSlotProps.componentField,
|
|
275
|
+
...bindEvents,
|
|
276
|
+
disabled: shouldDisabled.value,
|
|
277
|
+
...Reflect.has(computedProps.value, "onChange") ? { onChange: computedProps.value.onChange } : {},
|
|
278
|
+
...Reflect.has(computedProps.value, "onInput") ? { onInput: computedProps.value.onInput } : {}
|
|
279
|
+
};
|
|
280
|
+
if (bindEventField && bindEventField !== "modelValue") {
|
|
281
|
+
Reflect.deleteProperty(binds, "modelValue");
|
|
282
|
+
Reflect.deleteProperty(binds, "onUpdate:modelValue");
|
|
283
|
+
}
|
|
284
|
+
return binds;
|
|
285
|
+
}
|
|
286
|
+
function createFieldSlotScope(slotProps) {
|
|
287
|
+
return {
|
|
288
|
+
...createFieldSlotProps(slotProps),
|
|
289
|
+
componentProps: createComponentProps(slotProps),
|
|
290
|
+
disabled: shouldDisabled.value,
|
|
291
|
+
error: error.value,
|
|
292
|
+
isInValid: isInValid.value,
|
|
293
|
+
issues: normalizeIssues(slotProps.field.state.meta.errors),
|
|
294
|
+
modelValue: fieldValue.value,
|
|
295
|
+
name: props.fieldName
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function autofocus() {
|
|
299
|
+
if (fieldComponentRef.value && isFunction(fieldComponentRef.value.focus) && document.activeElement !== fieldComponentRef.value) fieldComponentRef.value?.focus?.();
|
|
300
|
+
}
|
|
301
|
+
function toggleCollapsed() {
|
|
302
|
+
collapseOpen.value = !collapseOpen.value;
|
|
303
|
+
}
|
|
304
|
+
const componentRefMap = injectComponentRefMap();
|
|
305
|
+
watch(fieldComponentRef, (componentRef) => {
|
|
306
|
+
componentRefMap?.set(props.fieldName, componentRef);
|
|
307
|
+
});
|
|
308
|
+
onUnmounted(() => {
|
|
309
|
+
if (componentRefMap?.has(props.fieldName)) componentRefMap.delete(props.fieldName);
|
|
310
|
+
});
|
|
311
|
+
return (_ctx, _cache) => {
|
|
312
|
+
const _directive_auto_animate = resolveDirective("auto-animate");
|
|
313
|
+
return !props.hide && unref(isIf) ? (openBlock(), createBlock(resolveDynamicComponent(unref(formApi).fieldComponent), mergeProps({ key: 0 }, fieldProps.value, { name: props.fieldName }), {
|
|
314
|
+
default: withCtx((slotProps) => [createVNode(unref(_sfc_main$3), {
|
|
315
|
+
dirty: slotProps.field.state.meta.isDirty,
|
|
316
|
+
error: unref(error),
|
|
317
|
+
name: props.fieldName,
|
|
318
|
+
touched: slotProps.field.state.meta.isTouched,
|
|
319
|
+
valid: slotProps.field.state.meta.isValid
|
|
320
|
+
}, {
|
|
321
|
+
default: withCtx(() => [withDirectives(createVNode(unref(_sfc_main$4), mergeProps({ class: [{
|
|
322
|
+
"form-valid-error": shouldApplyInvalidStyle.value,
|
|
323
|
+
"form-is-required": shouldRequired.value,
|
|
324
|
+
"pb-6": !compact.value && !props.hideMessage,
|
|
325
|
+
"pb-2": compact.value
|
|
326
|
+
}, "flex flex-col gap-2 relative"] }, _ctx.$attrs), {
|
|
327
|
+
default: withCtx(() => [!props.hideLabel || props.collapsible ? (openBlock(), createElementBlock("div", _hoisted_1, [!props.hideLabel ? (openBlock(), createBlock(_sfc_main$8, {
|
|
328
|
+
key: 0,
|
|
329
|
+
class: normalizeClass(["leading-6 flex", props.labelClass]),
|
|
330
|
+
help: computedHelp.value,
|
|
331
|
+
label: props.label,
|
|
332
|
+
required: shouldRequired.value && !props.hideRequiredMark
|
|
333
|
+
}, {
|
|
334
|
+
default: withCtx(() => [props.label ? (openBlock(), createBlock(unref(_sfc_main$1), {
|
|
335
|
+
key: 0,
|
|
336
|
+
content: props.label
|
|
337
|
+
}, null, 8, ["content"])) : createCommentVNode("v-if", true)]),
|
|
338
|
+
_: 1
|
|
339
|
+
}, 8, [
|
|
340
|
+
"class",
|
|
341
|
+
"help",
|
|
342
|
+
"label",
|
|
343
|
+
"required"
|
|
344
|
+
])) : createCommentVNode("v-if", true), props.collapsible ? (openBlock(), createBlock(PButton, {
|
|
345
|
+
key: 1,
|
|
346
|
+
"aria-label": "Toggle field",
|
|
347
|
+
class: normalizeClass(["ml-0.5", { "rotate-180": !collapseOpen.value }]),
|
|
348
|
+
icon: "lucide:chevron-down",
|
|
349
|
+
"aria-expanded": collapseOpen.value,
|
|
350
|
+
onClick: withModifiers(toggleCollapsed, ["prevent"])
|
|
351
|
+
}, null, 8, ["aria-expanded", "class"])) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_2, [
|
|
352
|
+
createVNode(_sfc_main$6, {
|
|
353
|
+
open: collapseOpen.value,
|
|
354
|
+
"onUpdate:open": _cache[0] || (_cache[0] = ($event) => collapseOpen.value = $event),
|
|
355
|
+
collapsible: props.collapsible
|
|
356
|
+
}, {
|
|
357
|
+
default: withCtx(() => [createVNode(_sfc_main$7, {
|
|
358
|
+
"control-class": props.controlClass,
|
|
359
|
+
suffix: props.suffix,
|
|
360
|
+
"wrapper-class": props.wrapperClass
|
|
361
|
+
}, {
|
|
362
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(createFieldSlotScope(slotProps))), () => [(openBlock(), createBlock(resolveDynamicComponent(FieldComponent.value), mergeProps({
|
|
363
|
+
ref_key: "fieldComponentRef",
|
|
364
|
+
ref: fieldComponentRef,
|
|
365
|
+
class: { "border-error hover:border-error/80 focus:border-error focus:shadow-[0_0_0_2px_rgba(255,38,5,0.06)]": shouldApplyInvalidStyle.value }
|
|
366
|
+
}, createComponentProps(slotProps)), createSlots({ _: 2 }, [renderList(renderContentKey.value, (name) => {
|
|
367
|
+
return {
|
|
368
|
+
name,
|
|
369
|
+
fn: withCtx((renderSlotProps) => [createVNode(unref(_sfc_main$1), mergeProps({ content: customContentRender.value[name] }, {
|
|
370
|
+
...renderSlotProps,
|
|
371
|
+
formContext: createFieldSlotProps(slotProps)
|
|
372
|
+
}), null, 16, ["content"])])
|
|
373
|
+
};
|
|
374
|
+
})]), 1040, ["class"]))])]),
|
|
375
|
+
_: 2
|
|
376
|
+
}, 1032, [
|
|
377
|
+
"control-class",
|
|
378
|
+
"suffix",
|
|
379
|
+
"wrapper-class"
|
|
380
|
+
])]),
|
|
381
|
+
_: 2
|
|
382
|
+
}, 1032, ["open", "collapsible"]),
|
|
383
|
+
props.description ? (openBlock(), createBlock(unref(_sfc_main$2), {
|
|
384
|
+
key: 0,
|
|
385
|
+
class: "text-xs"
|
|
386
|
+
}, {
|
|
387
|
+
default: withCtx(() => [createVNode(unref(_sfc_main$1), { content: props.description }, null, 8, ["content"])]),
|
|
388
|
+
_: 1
|
|
389
|
+
})) : createCommentVNode("v-if", true),
|
|
390
|
+
!compact.value && !props.hideMessage ? withDirectives((openBlock(), createElementBlock("div", _hoisted_3, [createVNode(unref(_sfc_main$5))])), [[_directive_auto_animate]]) : createCommentVNode("v-if", true)
|
|
391
|
+
])]),
|
|
392
|
+
_: 2
|
|
393
|
+
}, 1040, ["class"]), [[vShow, unref(isShow) && !props.hidden]])]),
|
|
394
|
+
_: 2
|
|
395
|
+
}, 1032, [
|
|
396
|
+
"dirty",
|
|
397
|
+
"error",
|
|
398
|
+
"name",
|
|
399
|
+
"touched",
|
|
400
|
+
"valid"
|
|
401
|
+
])]),
|
|
402
|
+
_: 3
|
|
403
|
+
}, 16, ["name"])) : createCommentVNode("v-if", true);
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
//#endregion
|
|
408
|
+
export { _sfc_main as default };
|