@melt-js/comps-vben 0.0.0-stage → 2026.11.8-2
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/LICENSE +10 -0
- package/README.md +91 -2
- package/hel_dist/assets/index-DaBGAjzb.js +478 -0
- package/hel_dist/assets/style-CcRbEt6_.css +2 -0
- package/hel_dist/entry.js +20 -0
- package/hel_dist/hel-meta.json +116 -0
- package/hel_dist/index.html +37 -0
- package/hel_proxy/entry.js +20 -0
- package/hel_proxy/entry.js.map +1 -0
- package/hel_proxy_es/entry.js +11 -0
- package/hel_proxy_es/entry.js.map +1 -0
- package/package.json +101 -3
- package/scripts/check-tdz.mjs +20 -0
- package/scripts/check.mjs +18 -0
- package/scripts/meta.mjs +28 -0
- package/scripts/prepublishOnly.mjs +42 -0
- package/scripts/publish-stage.mjs +25 -0
- package/src/common-ui/components/api-component/api-component.vue +273 -0
- package/src/common-ui/components/api-component/index.ts +7 -0
- package/src/common-ui/components/api-component/types.ts +72 -0
- package/src/common-ui/components/captcha/hooks/useCaptchaPoints.ts +19 -0
- package/src/common-ui/components/captcha/index.ts +7 -0
- package/src/common-ui/components/captcha/point-selection-captcha/index.vue +176 -0
- package/src/common-ui/components/captcha/point-selection-captcha/point-selection-captcha-card.vue +86 -0
- package/src/common-ui/components/captcha/slider-captcha/index.vue +254 -0
- package/src/common-ui/components/captcha/slider-captcha/slider-captcha-action.vue +65 -0
- package/src/common-ui/components/captcha/slider-captcha/slider-captcha-bar.vue +40 -0
- package/src/common-ui/components/captcha/slider-captcha/slider-captcha-content.vue +53 -0
- package/src/common-ui/components/captcha/slider-rotate-captcha/index.vue +213 -0
- package/src/common-ui/components/captcha/slider-translate-captcha/index.vue +311 -0
- package/src/common-ui/components/captcha/types.ts +210 -0
- package/src/common-ui/components/col-page/col-page.vue +111 -0
- package/src/common-ui/components/col-page/index.ts +2 -0
- package/src/common-ui/components/col-page/types.ts +26 -0
- package/src/common-ui/components/count-to/count-to.vue +123 -0
- package/src/common-ui/components/count-to/index.ts +2 -0
- package/src/common-ui/components/count-to/types.ts +53 -0
- package/src/common-ui/components/cropper/cropper.vue +981 -0
- package/src/common-ui/components/cropper/index.ts +1 -0
- package/src/common-ui/components/ellipsis-text/ellipsis-text.vue +232 -0
- package/src/common-ui/components/ellipsis-text/index.ts +1 -0
- package/src/common-ui/components/icon-picker/icon-picker.vue +322 -0
- package/src/common-ui/components/icon-picker/icons.ts +56 -0
- package/src/common-ui/components/icon-picker/index.ts +2 -0
- package/src/common-ui/components/icon-picker/types.ts +26 -0
- package/src/common-ui/components/index.ts +51 -0
- package/src/common-ui/components/json-viewer/index.ts +3 -0
- package/src/common-ui/components/json-viewer/index.vue +128 -0
- package/src/common-ui/components/json-viewer/style.scss +91 -0
- package/src/common-ui/components/json-viewer/types.ts +44 -0
- package/src/common-ui/components/loading/directive.ts +132 -0
- package/src/common-ui/components/loading/index.ts +3 -0
- package/src/common-ui/components/loading/loading.vue +39 -0
- package/src/common-ui/components/loading/spinner.vue +28 -0
- package/src/common-ui/components/page/index.ts +2 -0
- package/src/common-ui/components/page/page.vue +107 -0
- package/src/common-ui/components/page/types.ts +23 -0
- package/src/common-ui/components/resize/index.ts +1 -0
- package/src/common-ui/components/resize/resize.vue +1269 -0
- package/src/common-ui/components/tippy/directive.ts +100 -0
- package/src/common-ui/components/tippy/index.ts +67 -0
- package/src/common-ui/components/tree/index.ts +1 -0
- package/src/common-ui/components/tree/tree.vue +25 -0
- package/src/common-ui/index.ts +2 -0
- package/src/common-ui/ui/about/about.ts +14 -0
- package/src/common-ui/ui/about/about.vue +183 -0
- package/src/common-ui/ui/about/index.ts +1 -0
- package/src/common-ui/ui/authentication/auth-title.vue +13 -0
- package/src/common-ui/ui/authentication/code-login.vue +127 -0
- package/src/common-ui/ui/authentication/dingding-login.vue +113 -0
- package/src/common-ui/ui/authentication/forget-password.vue +116 -0
- package/src/common-ui/ui/authentication/index.ts +7 -0
- package/src/common-ui/ui/authentication/login-expired-modal.vue +95 -0
- package/src/common-ui/ui/authentication/login.vue +186 -0
- package/src/common-ui/ui/authentication/qrcode-login.vue +105 -0
- package/src/common-ui/ui/authentication/register.vue +121 -0
- package/src/common-ui/ui/authentication/third-party-login.vue +71 -0
- package/src/common-ui/ui/authentication/types.ts +70 -0
- package/src/common-ui/ui/dashboard/analysis/analysis-chart-card.vue +24 -0
- package/src/common-ui/ui/dashboard/analysis/analysis-charts-tabs.vue +40 -0
- package/src/common-ui/ui/dashboard/analysis/analysis-overview.vue +55 -0
- package/src/common-ui/ui/dashboard/analysis/index.ts +3 -0
- package/src/common-ui/ui/dashboard/index.ts +3 -0
- package/src/common-ui/ui/dashboard/typing.ts +50 -0
- package/src/common-ui/ui/dashboard/workbench/index.ts +5 -0
- package/src/common-ui/ui/dashboard/workbench/workbench-header.vue +48 -0
- package/src/common-ui/ui/dashboard/workbench/workbench-project.vue +73 -0
- package/src/common-ui/ui/dashboard/workbench/workbench-quick-nav.vue +56 -0
- package/src/common-ui/ui/dashboard/workbench/workbench-todo.vue +63 -0
- package/src/common-ui/ui/dashboard/workbench/workbench-trends.vue +64 -0
- package/src/common-ui/ui/fallback/fallback.ts +25 -0
- package/src/common-ui/ui/fallback/fallback.vue +164 -0
- package/src/common-ui/ui/fallback/icons/icon-403.vue +151 -0
- package/src/common-ui/ui/fallback/icons/icon-404.vue +154 -0
- package/src/common-ui/ui/fallback/icons/icon-500.vue +215 -0
- package/src/common-ui/ui/fallback/icons/icon-coming-soon.vue +262 -0
- package/src/common-ui/ui/fallback/icons/icon-offline.vue +112 -0
- package/src/common-ui/ui/fallback/icons/warning.svg +1 -0
- package/src/common-ui/ui/fallback/index.ts +2 -0
- package/src/common-ui/ui/index.ts +5 -0
- package/src/common-ui/ui/profile/base-setting.vue +58 -0
- package/src/common-ui/ui/profile/index.ts +6 -0
- package/src/common-ui/ui/profile/notification-setting.vue +52 -0
- package/src/common-ui/ui/profile/password-setting.vue +59 -0
- package/src/common-ui/ui/profile/profile.vue +64 -0
- package/src/common-ui/ui/profile/security-setting.vue +52 -0
- package/src/common-ui/ui/profile/types.ts +21 -0
- package/src/configs/subApp.ts +1 -0
- package/src/entrance/libProperties.ts +34 -0
- package/src/entrance/libTypes.js +9 -0
- package/src/form-ui/components/form-actions.vue +178 -0
- package/src/form-ui/components/form-field-array.vue +234 -0
- package/src/form-ui/config.ts +117 -0
- package/src/form-ui/deprecation.ts +18 -0
- package/src/form-ui/field-name.ts +106 -0
- package/src/form-ui/form-api.ts +766 -0
- package/src/form-ui/form-codec.ts +40 -0
- package/src/form-ui/form-render/context.ts +25 -0
- package/src/form-ui/form-render/dependencies.ts +305 -0
- package/src/form-ui/form-render/expandable.ts +105 -0
- package/src/form-ui/form-render/form-field.vue +644 -0
- package/src/form-ui/form-render/form-group.vue +126 -0
- package/src/form-ui/form-render/form-label.vue +35 -0
- package/src/form-ui/form-render/form.vue +205 -0
- package/src/form-ui/form-render/helper.ts +65 -0
- package/src/form-ui/form-render/index.ts +3 -0
- package/src/form-ui/form-render/schema.ts +534 -0
- package/src/form-ui/form-render/utils.ts +170 -0
- package/src/form-ui/form-runtime-field.ts +82 -0
- package/src/form-ui/form-runtime.ts +325 -0
- package/src/form-ui/form-value-transform.ts +235 -0
- package/src/form-ui/index.ts +39 -0
- package/src/form-ui/rule-registry.ts +17 -0
- package/src/form-ui/types.ts +1054 -0
- package/src/form-ui/use-custom-field-value.ts +124 -0
- package/src/form-ui/use-form-context.ts +148 -0
- package/src/form-ui/use-vben-form.ts +81 -0
- package/src/form-ui/vben-form.vue +79 -0
- package/src/form-ui/vben-use-form.vue +187 -0
- package/src/layout-ui/components/index.ts +5 -0
- package/src/layout-ui/components/layout-content.vue +75 -0
- package/src/layout-ui/components/layout-footer.vue +46 -0
- package/src/layout-ui/components/layout-header.vue +89 -0
- package/src/layout-ui/components/layout-sidebar.vue +484 -0
- package/src/layout-ui/components/layout-tabbar.vue +30 -0
- package/src/layout-ui/components/widgets/index.ts +2 -0
- package/src/layout-ui/components/widgets/sidebar-collapse-button.vue +25 -0
- package/src/layout-ui/components/widgets/sidebar-fixed-button.vue +27 -0
- package/src/layout-ui/header-scroll-state.ts +28 -0
- package/src/layout-ui/hooks/use-layout.ts +53 -0
- package/src/layout-ui/hooks/use-sidebar-drag.ts +152 -0
- package/src/layout-ui/index.ts +2 -0
- package/src/layout-ui/vben-layout.ts +188 -0
- package/src/layout-ui/vben-layout.vue +768 -0
- package/src/layouts/authentication/authentication.vue +196 -0
- package/src/layouts/authentication/form.vue +38 -0
- package/src/layouts/authentication/icons/slogan.vue +4568 -0
- package/src/layouts/authentication/index.ts +2 -0
- package/src/layouts/authentication/toolbar.vue +49 -0
- package/src/layouts/authentication/types.ts +1 -0
- package/src/layouts/basic/README.md +7 -0
- package/src/layouts/basic/content/content-spinner.vue +12 -0
- package/src/layouts/basic/content/content.vue +112 -0
- package/src/layouts/basic/content/index.ts +2 -0
- package/src/layouts/basic/content/use-content-spinner.ts +98 -0
- package/src/layouts/basic/copyright/copyright.vue +49 -0
- package/src/layouts/basic/copyright/index.ts +1 -0
- package/src/layouts/basic/footer/footer.vue +11 -0
- package/src/layouts/basic/footer/index.ts +1 -0
- package/src/layouts/basic/header/header.vue +408 -0
- package/src/layouts/basic/header/index.ts +1 -0
- package/src/layouts/basic/index.ts +1 -0
- package/src/layouts/basic/layout.vue +478 -0
- package/src/layouts/basic/menu/extra-menu.vue +41 -0
- package/src/layouts/basic/menu/index.ts +5 -0
- package/src/layouts/basic/menu/menu.vue +45 -0
- package/src/layouts/basic/menu/mixed-menu.vue +46 -0
- package/src/layouts/basic/menu/use-extra-menu.ts +179 -0
- package/src/layouts/basic/menu/use-mixed-menu.ts +181 -0
- package/src/layouts/basic/menu/use-navigation.ts +74 -0
- package/src/layouts/basic/tabbar/index.ts +2 -0
- package/src/layouts/basic/tabbar/tabbar.vue +84 -0
- package/src/layouts/basic/tabbar/use-tabbar.ts +229 -0
- package/src/layouts/basic/use-layout-scroll.ts +85 -0
- package/src/layouts/hooks/index.ts +98 -0
- package/src/layouts/iframe/iframe-router-view.vue +86 -0
- package/src/layouts/iframe/iframe-view.vue +3 -0
- package/src/layouts/iframe/index.ts +2 -0
- package/src/layouts/index.ts +4 -0
- package/src/layouts/route-cached/cached-tab-keys.ts +13 -0
- package/src/layouts/route-cached/index.ts +2 -0
- package/src/layouts/route-cached/route-cached-page.vue +36 -0
- package/src/layouts/route-cached/route-cached-view.vue +97 -0
- package/src/layouts/widgets/breadcrumb-routes.ts +41 -0
- package/src/layouts/widgets/breadcrumb.vue +78 -0
- package/src/layouts/widgets/check-updates/check-updates.vue +136 -0
- package/src/layouts/widgets/check-updates/index.ts +1 -0
- package/src/layouts/widgets/color-toggle.vue +64 -0
- package/src/layouts/widgets/global-search/global-search.vue +173 -0
- package/src/layouts/widgets/global-search/index.ts +1 -0
- package/src/layouts/widgets/global-search/search-panel.vue +299 -0
- package/src/layouts/widgets/index.ts +12 -0
- package/src/layouts/widgets/language-toggle.vue +48 -0
- package/src/layouts/widgets/layout-toggle.vue +64 -0
- package/src/layouts/widgets/lock-screen/index.ts +2 -0
- package/src/layouts/widgets/lock-screen/lock-screen-modal.vue +110 -0
- package/src/layouts/widgets/lock-screen/lock-screen.vue +167 -0
- package/src/layouts/widgets/notification/index.ts +3 -0
- package/src/layouts/widgets/notification/notification.vue +210 -0
- package/src/layouts/widgets/notification/types.ts +19 -0
- package/src/layouts/widgets/preferences/blocks/block.vue +22 -0
- package/src/layouts/widgets/preferences/blocks/checkbox-item.vue +63 -0
- package/src/layouts/widgets/preferences/blocks/custom/custom.vue +121 -0
- package/src/layouts/widgets/preferences/blocks/draggable-list.vue +138 -0
- package/src/layouts/widgets/preferences/blocks/general/animation.vue +56 -0
- package/src/layouts/widgets/preferences/blocks/general/general.vue +94 -0
- package/src/layouts/widgets/preferences/blocks/index.ts +21 -0
- package/src/layouts/widgets/preferences/blocks/input-item.vue +71 -0
- package/src/layouts/widgets/preferences/blocks/layout/breadcrumb.vue +61 -0
- package/src/layouts/widgets/preferences/blocks/layout/content.vue +53 -0
- package/src/layouts/widgets/preferences/blocks/layout/copyright.vue +56 -0
- package/src/layouts/widgets/preferences/blocks/layout/footer.vue +17 -0
- package/src/layouts/widgets/preferences/blocks/layout/header.vue +78 -0
- package/src/layouts/widgets/preferences/blocks/layout/layout.vue +112 -0
- package/src/layouts/widgets/preferences/blocks/layout/navigation.vue +50 -0
- package/src/layouts/widgets/preferences/blocks/layout/sidebar.vue +108 -0
- package/src/layouts/widgets/preferences/blocks/layout/tabbar.vue +106 -0
- package/src/layouts/widgets/preferences/blocks/layout/widget.vue +188 -0
- package/src/layouts/widgets/preferences/blocks/number-field-item.vue +74 -0
- package/src/layouts/widgets/preferences/blocks/select-item.vue +76 -0
- package/src/layouts/widgets/preferences/blocks/shortcut-keys/global.vue +55 -0
- package/src/layouts/widgets/preferences/blocks/switch-item.vue +55 -0
- package/src/layouts/widgets/preferences/blocks/theme/builtin.vue +162 -0
- package/src/layouts/widgets/preferences/blocks/theme/color-mode.vue +26 -0
- package/src/layouts/widgets/preferences/blocks/theme/font-size.vue +62 -0
- package/src/layouts/widgets/preferences/blocks/theme/radius.vue +38 -0
- package/src/layouts/widgets/preferences/blocks/theme/theme.vue +114 -0
- package/src/layouts/widgets/preferences/blocks/toggle-item.vue +46 -0
- package/src/layouts/widgets/preferences/icons/content-compact.vue +119 -0
- package/src/layouts/widgets/preferences/icons/full-content.vue +50 -0
- package/src/layouts/widgets/preferences/icons/header-mixed-nav.vue +202 -0
- package/src/layouts/widgets/preferences/icons/header-nav.vue +119 -0
- package/src/layouts/widgets/preferences/icons/header-sidebar-nav.vue +177 -0
- package/src/layouts/widgets/preferences/icons/index.ts +12 -0
- package/src/layouts/widgets/preferences/icons/mixed-nav.vue +161 -0
- package/src/layouts/widgets/preferences/icons/setting.vue +12 -0
- package/src/layouts/widgets/preferences/icons/sidebar-mixed-nav.vue +173 -0
- package/src/layouts/widgets/preferences/icons/sidebar-nav.vue +153 -0
- package/src/layouts/widgets/preferences/index.ts +3 -0
- package/src/layouts/widgets/preferences/preferences-button.vue +31 -0
- package/src/layouts/widgets/preferences/preferences-drawer.vue +674 -0
- package/src/layouts/widgets/preferences/preferences.vue +93 -0
- package/src/layouts/widgets/preferences/use-open-preferences.ts +16 -0
- package/src/layouts/widgets/theme-toggle/index.ts +1 -0
- package/src/layouts/widgets/theme-toggle/theme-button.vue +164 -0
- package/src/layouts/widgets/theme-toggle/theme-toggle.vue +83 -0
- package/src/layouts/widgets/timezone/index.ts +1 -0
- package/src/layouts/widgets/timezone/timezone-button.vue +92 -0
- package/src/layouts/widgets/user-dropdown/index.ts +1 -0
- package/src/layouts/widgets/user-dropdown/user-dropdown.vue +578 -0
- package/src/main.ts +17 -0
- package/src/menu-ui/components/collapse-transition.vue +96 -0
- package/src/menu-ui/components/index.ts +4 -0
- package/src/menu-ui/components/menu-badge-dot.vue +28 -0
- package/src/menu-ui/components/menu-badge.vue +57 -0
- package/src/menu-ui/components/menu-item.vue +140 -0
- package/src/menu-ui/components/menu.vue +880 -0
- package/src/menu-ui/components/normal-menu/index.ts +2 -0
- package/src/menu-ui/components/normal-menu/normal-menu.ts +27 -0
- package/src/menu-ui/components/normal-menu/normal-menu.vue +162 -0
- package/src/menu-ui/components/sub-menu-content.vue +105 -0
- package/src/menu-ui/components/sub-menu.vue +276 -0
- package/src/menu-ui/hooks/index.ts +2 -0
- package/src/menu-ui/hooks/use-menu-context.ts +55 -0
- package/src/menu-ui/hooks/use-menu-scroll.ts +46 -0
- package/src/menu-ui/hooks/use-menu.ts +48 -0
- package/src/menu-ui/index.ts +4 -0
- package/src/menu-ui/menu.vue +32 -0
- package/src/menu-ui/sub-menu.vue +71 -0
- package/src/menu-ui/types.ts +154 -0
- package/src/menu-ui/utils/index.ts +52 -0
- package/src/plugins/echarts/README.md +41 -0
- package/src/plugins/echarts/echarts-ui.vue +15 -0
- package/src/plugins/echarts/echarts.ts +40 -0
- package/src/plugins/echarts/index.ts +4 -0
- package/src/plugins/echarts/types.ts +28 -0
- package/src/plugins/echarts/use-echarts.ts +213 -0
- package/src/plugins/index.ts +2 -0
- package/src/plugins/motion/README.md +26 -0
- package/src/plugins/motion/index.ts +8 -0
- package/src/plugins/motion/types.ts +26 -0
- package/src/plugins/plugins-context.ts +39 -0
- package/src/plugins/tiptap/extensions.ts +452 -0
- package/src/plugins/tiptap/index.ts +4 -0
- package/src/plugins/tiptap/preview.vue +34 -0
- package/src/plugins/tiptap/style.css +112 -0
- package/src/plugins/tiptap/tiptap.vue +324 -0
- package/src/plugins/tiptap/toolbar.ts +374 -0
- package/src/plugins/tiptap/types.ts +87 -0
- package/src/plugins/tiptap/use-tiptap-toolbar.ts +176 -0
- package/src/plugins/types.ts +24 -0
- package/src/plugins/vxe-table/README.md +50 -0
- package/src/plugins/vxe-table/api.ts +202 -0
- package/src/plugins/vxe-table/extends.ts +150 -0
- package/src/plugins/vxe-table/index.ts +10 -0
- package/src/plugins/vxe-table/init.ts +151 -0
- package/src/plugins/vxe-table/style.css +128 -0
- package/src/plugins/vxe-table/types.ts +116 -0
- package/src/plugins/vxe-table/use-vxe-grid.ts +86 -0
- package/src/plugins/vxe-table/use-vxe-grid.vue +564 -0
- package/src/plugins/vxe-table/viewed-row/index.ts +8 -0
- package/src/plugins/vxe-table/viewed-row/types.ts +84 -0
- package/src/plugins/vxe-table/viewed-row/use-viewed-row.ts +590 -0
- package/src/popup-ui/alert/AlertBuilder.ts +244 -0
- package/src/popup-ui/alert/alert.ts +101 -0
- package/src/popup-ui/alert/alert.vue +220 -0
- package/src/popup-ui/alert/index.ts +14 -0
- package/src/popup-ui/drawer/drawer-api.ts +178 -0
- package/src/popup-ui/drawer/drawer.ts +192 -0
- package/src/popup-ui/drawer/drawer.vue +359 -0
- package/src/popup-ui/drawer/index.ts +7 -0
- package/src/popup-ui/drawer/use-drawer.ts +210 -0
- package/src/popup-ui/index.ts +3 -0
- package/src/popup-ui/modal/index.ts +7 -0
- package/src/popup-ui/modal/modal-api.ts +191 -0
- package/src/popup-ui/modal/modal.ts +212 -0
- package/src/popup-ui/modal/modal.vue +395 -0
- package/src/popup-ui/modal/use-modal-draggable.ts +141 -0
- package/src/popup-ui/modal/use-modal.ts +222 -0
- package/src/shadcn-ui/assets/index.css +1 -0
- package/src/shadcn-ui/components/avatar/avatar.vue +76 -0
- package/src/shadcn-ui/components/avatar/index.ts +1 -0
- package/src/shadcn-ui/components/back-top/back-top.vue +43 -0
- package/src/shadcn-ui/components/back-top/backtop.ts +38 -0
- package/src/shadcn-ui/components/back-top/index.ts +1 -0
- package/src/shadcn-ui/components/back-top/use-backtop.ts +45 -0
- package/src/shadcn-ui/components/breadcrumb/breadcrumb-background.vue +111 -0
- package/src/shadcn-ui/components/breadcrumb/breadcrumb-view.vue +39 -0
- package/src/shadcn-ui/components/breadcrumb/breadcrumb.vue +98 -0
- package/src/shadcn-ui/components/breadcrumb/index.ts +3 -0
- package/src/shadcn-ui/components/breadcrumb/types.ts +17 -0
- package/src/shadcn-ui/components/button/button-group.vue +98 -0
- package/src/shadcn-ui/components/button/button.ts +55 -0
- package/src/shadcn-ui/components/button/button.vue +42 -0
- package/src/shadcn-ui/components/button/check-button-group.vue +196 -0
- package/src/shadcn-ui/components/button/icon-button.vue +78 -0
- package/src/shadcn-ui/components/button/index.ts +5 -0
- package/src/shadcn-ui/components/checkbox/checkbox.vue +26 -0
- package/src/shadcn-ui/components/checkbox/index.ts +1 -0
- package/src/shadcn-ui/components/collapsible/collapsible-params-item.vue +123 -0
- package/src/shadcn-ui/components/collapsible/collapsible-params.vue +268 -0
- package/src/shadcn-ui/components/collapsible/collapsible.vue +79 -0
- package/src/shadcn-ui/components/collapsible/index.ts +4 -0
- package/src/shadcn-ui/components/collapsible/type.ts +22 -0
- package/src/shadcn-ui/components/context-menu/context-menu.vue +128 -0
- package/src/shadcn-ui/components/context-menu/index.ts +3 -0
- package/src/shadcn-ui/components/context-menu/interface.ts +42 -0
- package/src/shadcn-ui/components/count-to-animator/count-to-animator.vue +128 -0
- package/src/shadcn-ui/components/count-to-animator/index.ts +1 -0
- package/src/shadcn-ui/components/descriptions/descriptions-cell.vue +129 -0
- package/src/shadcn-ui/components/descriptions/descriptions-item.vue +57 -0
- package/src/shadcn-ui/components/descriptions/descriptions-row.vue +112 -0
- package/src/shadcn-ui/components/descriptions/descriptions.vue +91 -0
- package/src/shadcn-ui/components/descriptions/index.ts +4 -0
- package/src/shadcn-ui/components/descriptions/types.ts +93 -0
- package/src/shadcn-ui/components/descriptions/use-descriptions.ts +216 -0
- package/src/shadcn-ui/components/dropdown-menu/dropdown-menu.vue +49 -0
- package/src/shadcn-ui/components/dropdown-menu/dropdown-radio-menu.vue +52 -0
- package/src/shadcn-ui/components/dropdown-menu/index.ts +4 -0
- package/src/shadcn-ui/components/dropdown-menu/interface.ts +32 -0
- package/src/shadcn-ui/components/expandable-arrow/expandable-arrow.vue +31 -0
- package/src/shadcn-ui/components/expandable-arrow/index.ts +1 -0
- package/src/shadcn-ui/components/full-screen/full-screen.vue +41 -0
- package/src/shadcn-ui/components/full-screen/index.ts +1 -0
- package/src/shadcn-ui/components/hover-card/hover-card.vue +55 -0
- package/src/shadcn-ui/components/hover-card/index.ts +2 -0
- package/src/shadcn-ui/components/icon/icon.vue +35 -0
- package/src/shadcn-ui/components/icon/index.ts +1 -0
- package/src/shadcn-ui/components/index.ts +26 -0
- package/src/shadcn-ui/components/input-password/index.ts +1 -0
- package/src/shadcn-ui/components/input-password/input-password.vue +57 -0
- package/src/shadcn-ui/components/input-password/password-strength.vue +66 -0
- package/src/shadcn-ui/components/logo/index.ts +1 -0
- package/src/shadcn-ui/components/logo/logo.vue +152 -0
- package/src/shadcn-ui/components/pin-input/index.ts +3 -0
- package/src/shadcn-ui/components/pin-input/input.vue +122 -0
- package/src/shadcn-ui/components/pin-input/types.ts +30 -0
- package/src/shadcn-ui/components/popover/index.ts +1 -0
- package/src/shadcn-ui/components/popover/popover.vue +60 -0
- package/src/shadcn-ui/components/render-content/index.ts +1 -0
- package/src/shadcn-ui/components/render-content/render-content.vue +59 -0
- package/src/shadcn-ui/components/scrollbar/index.ts +1 -0
- package/src/shadcn-ui/components/scrollbar/scrollbar.vue +165 -0
- package/src/shadcn-ui/components/segmented/index.ts +3 -0
- package/src/shadcn-ui/components/segmented/segmented.vue +75 -0
- package/src/shadcn-ui/components/segmented/tabs-indicator.vue +37 -0
- package/src/shadcn-ui/components/segmented/types.ts +6 -0
- package/src/shadcn-ui/components/select/index.ts +1 -0
- package/src/shadcn-ui/components/select/select.vue +57 -0
- package/src/shadcn-ui/components/spine-text/index.ts +1 -0
- package/src/shadcn-ui/components/spine-text/spine-text.vue +49 -0
- package/src/shadcn-ui/components/spinner/index.ts +2 -0
- package/src/shadcn-ui/components/spinner/loading.vue +140 -0
- package/src/shadcn-ui/components/spinner/spinner.vue +138 -0
- package/src/shadcn-ui/components/table-action/action-dropdown-item.vue +116 -0
- package/src/shadcn-ui/components/table-action/action-item.vue +98 -0
- package/src/shadcn-ui/components/table-action/index.ts +3 -0
- package/src/shadcn-ui/components/table-action/table-action.vue +218 -0
- package/src/shadcn-ui/components/table-action/types.ts +75 -0
- package/src/shadcn-ui/components/tooltip/help-tooltip.vue +31 -0
- package/src/shadcn-ui/components/tooltip/index.ts +2 -0
- package/src/shadcn-ui/components/tooltip/tooltip.vue +44 -0
- package/src/shadcn-ui/components.json +15 -0
- package/src/shadcn-ui/index.ts +39 -0
- package/src/shadcn-ui/ui/accordion/Accordion.vue +16 -0
- package/src/shadcn-ui/ui/accordion/AccordionContent.vue +28 -0
- package/src/shadcn-ui/ui/accordion/AccordionItem.vue +29 -0
- package/src/shadcn-ui/ui/accordion/AccordionTrigger.vue +39 -0
- package/src/shadcn-ui/ui/accordion/index.ts +4 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialog.vue +20 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogAction.vue +13 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogCancel.vue +13 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogContent.vue +101 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogDescription.vue +28 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogFooter.vue +20 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogHeader.vue +18 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogOverlay.vue +31 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogTitle.vue +26 -0
- package/src/shadcn-ui/ui/alert-dialog/AlertDialogTrigger.vue +13 -0
- package/src/shadcn-ui/ui/alert-dialog/index.ts +9 -0
- package/src/shadcn-ui/ui/avatar/Avatar.vue +25 -0
- package/src/shadcn-ui/ui/avatar/AvatarFallback.vue +31 -0
- package/src/shadcn-ui/ui/avatar/AvatarImage.vue +17 -0
- package/src/shadcn-ui/ui/avatar/index.ts +3 -0
- package/src/shadcn-ui/ui/badge/Badge.vue +33 -0
- package/src/shadcn-ui/ui/badge/badge.ts +25 -0
- package/src/shadcn-ui/ui/badge/index.ts +3 -0
- package/src/shadcn-ui/ui/breadcrumb/Breadcrumb.vue +13 -0
- package/src/shadcn-ui/ui/breadcrumb/BreadcrumbEllipsis.vue +25 -0
- package/src/shadcn-ui/ui/breadcrumb/BreadcrumbItem.vue +18 -0
- package/src/shadcn-ui/ui/breadcrumb/BreadcrumbLink.vue +27 -0
- package/src/shadcn-ui/ui/breadcrumb/BreadcrumbList.vue +23 -0
- package/src/shadcn-ui/ui/breadcrumb/BreadcrumbPage.vue +21 -0
- package/src/shadcn-ui/ui/breadcrumb/BreadcrumbSeparator.vue +24 -0
- package/src/shadcn-ui/ui/breadcrumb/index.ts +7 -0
- package/src/shadcn-ui/ui/button/Button.vue +36 -0
- package/src/shadcn-ui/ui/button/button.ts +35 -0
- package/src/shadcn-ui/ui/button/index.ts +3 -0
- package/src/shadcn-ui/ui/card/Card.vue +23 -0
- package/src/shadcn-ui/ui/card/CardAction.vue +23 -0
- package/src/shadcn-ui/ui/card/CardContent.vue +15 -0
- package/src/shadcn-ui/ui/card/CardDescription.vue +18 -0
- package/src/shadcn-ui/ui/card/CardFooter.vue +18 -0
- package/src/shadcn-ui/ui/card/CardHeader.vue +23 -0
- package/src/shadcn-ui/ui/card/CardTitle.vue +18 -0
- package/src/shadcn-ui/ui/card/index.ts +7 -0
- package/src/shadcn-ui/ui/checkbox/Checkbox.vue +49 -0
- package/src/shadcn-ui/ui/checkbox/index.ts +1 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenu.vue +18 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuCheckboxItem.vue +51 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuContent.vue +44 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuGroup.vue +13 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuItem.vue +45 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuLabel.vue +32 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuPortal.vue +13 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuRadioGroup.vue +22 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuRadioItem.vue +51 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuSeparator.vue +24 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuShortcut.vue +20 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuSub.vue +16 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuSubContent.vue +37 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuSubTrigger.vue +39 -0
- package/src/shadcn-ui/ui/context-menu/ContextMenuTrigger.vue +15 -0
- package/src/shadcn-ui/ui/context-menu/index.ts +14 -0
- package/src/shadcn-ui/ui/dialog/Dialog.vue +16 -0
- package/src/shadcn-ui/ui/dialog/DialogClose.vue +13 -0
- package/src/shadcn-ui/ui/dialog/DialogContent.vue +149 -0
- package/src/shadcn-ui/ui/dialog/DialogDescription.vue +28 -0
- package/src/shadcn-ui/ui/dialog/DialogFooter.vue +33 -0
- package/src/shadcn-ui/ui/dialog/DialogHeader.vue +18 -0
- package/src/shadcn-ui/ui/dialog/DialogOverlay.vue +34 -0
- package/src/shadcn-ui/ui/dialog/DialogScrollContent.vue +69 -0
- package/src/shadcn-ui/ui/dialog/DialogTitle.vue +28 -0
- package/src/shadcn-ui/ui/dialog/DialogTrigger.vue +13 -0
- package/src/shadcn-ui/ui/dialog/index.ts +10 -0
- package/src/shadcn-ui/ui/dialog/use-dialog-state-events.ts +84 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenu.vue +20 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +51 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuContent.vue +50 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuGroup.vue +13 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuItem.vue +44 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuLabel.vue +30 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuRadioGroup.vue +22 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuRadioItem.vue +52 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuSeparator.vue +26 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuShortcut.vue +20 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuSub.vue +20 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuSubContent.vue +37 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuSubTrigger.vue +38 -0
- package/src/shadcn-ui/ui/dropdown-menu/DropdownMenuTrigger.vue +18 -0
- package/src/shadcn-ui/ui/dropdown-menu/index.ts +16 -0
- package/src/shadcn-ui/ui/form/FormControl.vue +20 -0
- package/src/shadcn-ui/ui/form/FormDescription.vue +23 -0
- package/src/shadcn-ui/ui/form/FormField.vue +35 -0
- package/src/shadcn-ui/ui/form/FormItem.vue +24 -0
- package/src/shadcn-ui/ui/form/FormLabel.vue +25 -0
- package/src/shadcn-ui/ui/form/FormMessage.vue +24 -0
- package/src/shadcn-ui/ui/form/index.ts +10 -0
- package/src/shadcn-ui/ui/form/injectionKeys.ts +16 -0
- package/src/shadcn-ui/ui/form/useFormField.ts +35 -0
- package/src/shadcn-ui/ui/hover-card/HoverCard.vue +16 -0
- package/src/shadcn-ui/ui/hover-card/HoverCardContent.vue +42 -0
- package/src/shadcn-ui/ui/hover-card/HoverCardTrigger.vue +13 -0
- package/src/shadcn-ui/ui/hover-card/index.ts +3 -0
- package/src/shadcn-ui/ui/index.ts +32 -0
- package/src/shadcn-ui/ui/input/Input.vue +54 -0
- package/src/shadcn-ui/ui/input/index.ts +1 -0
- package/src/shadcn-ui/ui/label/Label.vue +29 -0
- package/src/shadcn-ui/ui/label/index.ts +1 -0
- package/src/shadcn-ui/ui/number-field/NumberField.vue +29 -0
- package/src/shadcn-ui/ui/number-field/NumberFieldContent.vue +22 -0
- package/src/shadcn-ui/ui/number-field/NumberFieldDecrement.vue +36 -0
- package/src/shadcn-ui/ui/number-field/NumberFieldIncrement.vue +36 -0
- package/src/shadcn-ui/ui/number-field/NumberFieldInput.vue +23 -0
- package/src/shadcn-ui/ui/number-field/index.ts +5 -0
- package/src/shadcn-ui/ui/pagination/Pagination.vue +31 -0
- package/src/shadcn-ui/ui/pagination/PaginationContent.vue +27 -0
- package/src/shadcn-ui/ui/pagination/PaginationEllipsis.vue +29 -0
- package/src/shadcn-ui/ui/pagination/PaginationFirst.vue +50 -0
- package/src/shadcn-ui/ui/pagination/PaginationItem.vue +47 -0
- package/src/shadcn-ui/ui/pagination/PaginationLast.vue +50 -0
- package/src/shadcn-ui/ui/pagination/PaginationNext.vue +50 -0
- package/src/shadcn-ui/ui/pagination/PaginationPrevious.vue +50 -0
- package/src/shadcn-ui/ui/pagination/index.ts +8 -0
- package/src/shadcn-ui/ui/pin-input/PinInput.vue +38 -0
- package/src/shadcn-ui/ui/pin-input/PinInputGroup.vue +26 -0
- package/src/shadcn-ui/ui/pin-input/PinInputSeparator.vue +17 -0
- package/src/shadcn-ui/ui/pin-input/PinInputSlot.vue +31 -0
- package/src/shadcn-ui/ui/pin-input/index.ts +4 -0
- package/src/shadcn-ui/ui/popover/Popover.vue +16 -0
- package/src/shadcn-ui/ui/popover/PopoverAnchor.vue +13 -0
- package/src/shadcn-ui/ui/popover/PopoverContent.vue +44 -0
- package/src/shadcn-ui/ui/popover/PopoverTrigger.vue +13 -0
- package/src/shadcn-ui/ui/popover/index.ts +4 -0
- package/src/shadcn-ui/ui/progress/Progress.vue +58 -0
- package/src/shadcn-ui/ui/progress/index.ts +1 -0
- package/src/shadcn-ui/ui/radio-group/RadioGroup.vue +30 -0
- package/src/shadcn-ui/ui/radio-group/RadioGroupItem.vue +43 -0
- package/src/shadcn-ui/ui/radio-group/index.ts +2 -0
- package/src/shadcn-ui/ui/resizable/ResizableHandle.vue +48 -0
- package/src/shadcn-ui/ui/resizable/ResizablePanel.vue +32 -0
- package/src/shadcn-ui/ui/resizable/ResizablePanelGroup.vue +32 -0
- package/src/shadcn-ui/ui/resizable/index.ts +3 -0
- package/src/shadcn-ui/ui/scroll-area/ScrollArea.vue +40 -0
- package/src/shadcn-ui/ui/scroll-area/ScrollBar.vue +41 -0
- package/src/shadcn-ui/ui/scroll-area/index.ts +2 -0
- package/src/shadcn-ui/ui/select/Select.vue +16 -0
- package/src/shadcn-ui/ui/select/SelectContent.vue +65 -0
- package/src/shadcn-ui/ui/select/SelectGroup.vue +13 -0
- package/src/shadcn-ui/ui/select/SelectItem.vue +49 -0
- package/src/shadcn-ui/ui/select/SelectItemText.vue +13 -0
- package/src/shadcn-ui/ui/select/SelectLabel.vue +22 -0
- package/src/shadcn-ui/ui/select/SelectScrollDownButton.vue +33 -0
- package/src/shadcn-ui/ui/select/SelectScrollUpButton.vue +33 -0
- package/src/shadcn-ui/ui/select/SelectSeparator.vue +24 -0
- package/src/shadcn-ui/ui/select/SelectTrigger.vue +43 -0
- package/src/shadcn-ui/ui/select/SelectValue.vue +13 -0
- package/src/shadcn-ui/ui/select/index.ts +11 -0
- package/src/shadcn-ui/ui/separator/Separator.vue +33 -0
- package/src/shadcn-ui/ui/separator/index.ts +1 -0
- package/src/shadcn-ui/ui/sheet/Sheet.vue +16 -0
- package/src/shadcn-ui/ui/sheet/SheetClose.vue +13 -0
- package/src/shadcn-ui/ui/sheet/SheetContent.vue +110 -0
- package/src/shadcn-ui/ui/sheet/SheetDescription.vue +26 -0
- package/src/shadcn-ui/ui/sheet/SheetFooter.vue +16 -0
- package/src/shadcn-ui/ui/sheet/SheetHeader.vue +16 -0
- package/src/shadcn-ui/ui/sheet/SheetOverlay.vue +11 -0
- package/src/shadcn-ui/ui/sheet/SheetTitle.vue +26 -0
- package/src/shadcn-ui/ui/sheet/SheetTrigger.vue +13 -0
- package/src/shadcn-ui/ui/sheet/index.ts +10 -0
- package/src/shadcn-ui/ui/sheet/sheet.ts +24 -0
- package/src/shadcn-ui/ui/switch/Switch.vue +45 -0
- package/src/shadcn-ui/ui/switch/index.ts +1 -0
- package/src/shadcn-ui/ui/tabs/Tabs.vue +29 -0
- package/src/shadcn-ui/ui/tabs/TabsContent.vue +26 -0
- package/src/shadcn-ui/ui/tabs/TabsList.vue +31 -0
- package/src/shadcn-ui/ui/tabs/TabsTrigger.vue +33 -0
- package/src/shadcn-ui/ui/tabs/index.ts +5 -0
- package/src/shadcn-ui/ui/textarea/Textarea.vue +35 -0
- package/src/shadcn-ui/ui/textarea/index.ts +1 -0
- package/src/shadcn-ui/ui/toggle/Toggle.vue +45 -0
- package/src/shadcn-ui/ui/toggle/index.ts +2 -0
- package/src/shadcn-ui/ui/toggle/toggle.ts +27 -0
- package/src/shadcn-ui/ui/toggle-group/ToggleGroup.vue +64 -0
- package/src/shadcn-ui/ui/toggle-group/ToggleGroupItem.vue +56 -0
- package/src/shadcn-ui/ui/toggle-group/index.ts +2 -0
- package/src/shadcn-ui/ui/tooltip/Tooltip.vue +16 -0
- package/src/shadcn-ui/ui/tooltip/TooltipContent.vue +55 -0
- package/src/shadcn-ui/ui/tooltip/TooltipProvider.vue +13 -0
- package/src/shadcn-ui/ui/tooltip/TooltipTrigger.vue +13 -0
- package/src/shadcn-ui/ui/tooltip/index.ts +4 -0
- package/src/shadcn-ui/ui/tree/index.ts +4 -0
- package/src/shadcn-ui/ui/tree/tree.vue +689 -0
- package/src/shadcn-ui/ui/tree/types.ts +70 -0
- package/src/styles/index.css +9 -0
- package/src/tabs-ui/components/index.ts +2 -0
- package/src/tabs-ui/components/tabs/tabs.vue +150 -0
- package/src/tabs-ui/components/tabs-chrome/tabs.vue +211 -0
- package/src/tabs-ui/components/widgets/index.ts +3 -0
- package/src/tabs-ui/components/widgets/tool-more.vue +18 -0
- package/src/tabs-ui/components/widgets/tool-refresh.vue +18 -0
- package/src/tabs-ui/components/widgets/tool-screen.vue +19 -0
- package/src/tabs-ui/index.ts +3 -0
- package/src/tabs-ui/tabs-view.vue +106 -0
- package/src/tabs-ui/types.ts +73 -0
- package/src/tabs-ui/use-tabs-drag.ts +129 -0
- package/src/tabs-ui/use-tabs-view-scroll.ts +202 -0
- package/src/types/shims.d.ts +2 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey, Ref, ShallowRef } from 'vue';
|
|
2
|
+
|
|
3
|
+
import type { FormValidationTrigger } from './types';
|
|
4
|
+
|
|
5
|
+
import { computed, inject, onUnmounted, provide, toRaw, watch } from 'vue';
|
|
6
|
+
|
|
7
|
+
import { cloneDeep, isEqual } from '@melt-js/libs-vben/shared/utils';
|
|
8
|
+
|
|
9
|
+
export interface FormCustomFieldContext {
|
|
10
|
+
/** 已注册的取值函数,同一表单项只接受一个 */
|
|
11
|
+
customValue: ShallowRef<(() => any) | undefined>;
|
|
12
|
+
disabled: ComputedRef<boolean>;
|
|
13
|
+
error: Readonly<Ref<string | undefined>>;
|
|
14
|
+
fieldName: string;
|
|
15
|
+
resetValidation: () => void;
|
|
16
|
+
setValue: (value: any) => void;
|
|
17
|
+
validateWithTrigger: (trigger: FormValidationTrigger) => void;
|
|
18
|
+
value: Readonly<Ref>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface UseCustomFieldValueOptions {
|
|
22
|
+
/** 取值为对象/数组且原地修改时开启 */
|
|
23
|
+
deep?: boolean;
|
|
24
|
+
/** 挂载时把当前值写入表单(不触发校验) */
|
|
25
|
+
immediate?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface UseCustomFieldValueReturn<T> {
|
|
29
|
+
/** 表单项的禁用态(含表单级、schema 级、依赖计算) */
|
|
30
|
+
disabled: ComputedRef<boolean>;
|
|
31
|
+
/** 表单项当前的校验错误 */
|
|
32
|
+
error: Readonly<Ref<string | undefined>>;
|
|
33
|
+
/** 所在表单项的字段名,不在表单项内时为 undefined */
|
|
34
|
+
fieldName: string | undefined;
|
|
35
|
+
/** 清除该表单项的校验状态 */
|
|
36
|
+
resetValidation: () => void;
|
|
37
|
+
/** 表单中该字段的值,可用于响应 setValues / resetForm */
|
|
38
|
+
value: ComputedRef<T | undefined>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const CUSTOM_FIELD_INJECTION_KEY: InjectionKey<FormCustomFieldContext> = Symbol(
|
|
42
|
+
'VbenFormCustomField',
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export function provideFormCustomField(context: FormCustomFieldContext) {
|
|
46
|
+
provide(CUSTOM_FIELD_INJECTION_KEY, context);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 让 VbenForm 表单项内的自定义组件把自己的值交给表单。
|
|
51
|
+
*
|
|
52
|
+
* 组件既没有绑定 `componentProps`(插槽用法),也没有实现 `modelValue` 时,
|
|
53
|
+
* 表单拿不到它的值,schema 上的 rules 也就无从校验。调用该函数后,取值函数的
|
|
54
|
+
* 结果会写回表单字段,并按表单项的 `validateOn` 触发校验。
|
|
55
|
+
*
|
|
56
|
+
* 值仍归表单所有:组件应继续用 `modelValue` 接收表单下发的值(插槽用法就是
|
|
57
|
+
* `v-bind="slotProps.componentProps"`),`setValues`、重置才能顺着 props 流回组件。
|
|
58
|
+
* 只有完全自持内部状态的组件,才需要用返回的 `value` 自行同步。
|
|
59
|
+
*/
|
|
60
|
+
export function useCustomFieldValue<T = any>(
|
|
61
|
+
customValue: () => T,
|
|
62
|
+
options: UseCustomFieldValueOptions = {},
|
|
63
|
+
): UseCustomFieldValueReturn<T> {
|
|
64
|
+
const field = inject(CUSTOM_FIELD_INJECTION_KEY, null);
|
|
65
|
+
|
|
66
|
+
if (!field) {
|
|
67
|
+
console.warn('useCustomFieldValue 只能在 VbenForm 的表单项内部使用');
|
|
68
|
+
return {
|
|
69
|
+
disabled: computed(() => false),
|
|
70
|
+
error: computed(() => undefined),
|
|
71
|
+
fieldName: undefined,
|
|
72
|
+
resetValidation: () => {},
|
|
73
|
+
value: computed(() => undefined),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 一个字段只能有一个值来源,后来者会互相覆盖
|
|
78
|
+
if (field.customValue.value) {
|
|
79
|
+
console.warn(
|
|
80
|
+
`表单项 ${field.fieldName} 已存在自定义取值函数,本次注册被忽略`,
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
field.customValue.value = customValue;
|
|
84
|
+
|
|
85
|
+
onUnmounted(() => {
|
|
86
|
+
if (field.customValue.value === customValue) {
|
|
87
|
+
field.customValue.value = undefined;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// deep 时组件原地改的就是这个对象,存一份副本进表单,
|
|
92
|
+
// 下次比较才不是拿它跟自己比,原地改动也就不会被当成没变
|
|
93
|
+
const toFormValue = (value: T) =>
|
|
94
|
+
options.deep ? cloneDeep(toRaw(value)) : value;
|
|
95
|
+
|
|
96
|
+
if (options.immediate) {
|
|
97
|
+
field.setValue(toFormValue(customValue()));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
watch(
|
|
101
|
+
customValue,
|
|
102
|
+
(value) => {
|
|
103
|
+
// 组件由表单驱动(v-model / componentProps)时,setValues、重置下发的新值
|
|
104
|
+
// 会经组件再流回这里,此时值与表单一致:不重复写回,也不触发校验,
|
|
105
|
+
// 否则一点重置就立刻冒出必填错误
|
|
106
|
+
if (isEqual(value, toRaw(field.value.value))) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
field.setValue(toFormValue(value));
|
|
110
|
+
field.resetValidation();
|
|
111
|
+
field.validateWithTrigger('change');
|
|
112
|
+
},
|
|
113
|
+
{ deep: options.deep },
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
disabled: field.disabled,
|
|
119
|
+
error: field.error,
|
|
120
|
+
fieldName: field.fieldName,
|
|
121
|
+
resetValidation: field.resetValidation,
|
|
122
|
+
value: computed(() => field.value.value as T | undefined),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { ZodType } from 'zod';
|
|
2
|
+
|
|
3
|
+
import type { ComputedRef } from 'vue';
|
|
4
|
+
|
|
5
|
+
import type { ExtendedFormApi, FormActions, VbenFormProps } from './types';
|
|
6
|
+
|
|
7
|
+
import { computed, toRaw, unref, useSlots } from 'vue';
|
|
8
|
+
|
|
9
|
+
import { createContext } from '@melt-js/comps-vben/shadcn-ui';
|
|
10
|
+
import { isString, mergeWithArrayOverride, set } from '@melt-js/libs-vben/shared/utils';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
object,
|
|
14
|
+
ZodIntersection,
|
|
15
|
+
ZodNumber,
|
|
16
|
+
ZodObject,
|
|
17
|
+
ZodString,
|
|
18
|
+
string as zodString,
|
|
19
|
+
ZodStringFormat,
|
|
20
|
+
} from 'zod';
|
|
21
|
+
import { getDefaultsForSchema } from 'zod-defaults';
|
|
22
|
+
|
|
23
|
+
import { getFormFieldSchemas } from './form-render/schema';
|
|
24
|
+
import { useFormRuntime } from './form-runtime';
|
|
25
|
+
|
|
26
|
+
type ExtendFormProps = VbenFormProps & {
|
|
27
|
+
formApi?: ExtendedFormApi<any, any, any>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const [injectFormProps, provideFormProps] =
|
|
31
|
+
createContext<[ComputedRef<ExtendFormProps> | ExtendFormProps, FormActions]>(
|
|
32
|
+
'VbenFormProps',
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const [injectComponentRefMap, provideComponentRefMap] =
|
|
36
|
+
createContext<Map<string, unknown>>('ComponentRefMap');
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Rebuild the schema used by zod-defaults, replacing native format nodes that
|
|
40
|
+
* zod-defaults does not recognise while retaining supported wrappers.
|
|
41
|
+
*/
|
|
42
|
+
function normalizeSchemaForDefaults(rule: ZodType): ZodType {
|
|
43
|
+
const rawRule = toRaw(rule) as any;
|
|
44
|
+
|
|
45
|
+
if (rawRule instanceof ZodStringFormat) {
|
|
46
|
+
return zodString();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (rawRule instanceof ZodObject) {
|
|
50
|
+
const shape = Object.fromEntries(
|
|
51
|
+
Object.entries(rawRule.shape).map(([key, value]) => [
|
|
52
|
+
key,
|
|
53
|
+
normalizeSchemaForDefaults(value as ZodType),
|
|
54
|
+
]),
|
|
55
|
+
);
|
|
56
|
+
return object(shape);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (rawRule instanceof ZodIntersection) {
|
|
60
|
+
const { left, right } = (rawRule as any).def;
|
|
61
|
+
return normalizeSchemaForDefaults(left as ZodType).and(
|
|
62
|
+
normalizeSchemaForDefaults(right as ZodType),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (rawRule.constructor.name === 'ZodDefault') {
|
|
67
|
+
const inner = normalizeSchemaForDefaults(rawRule.unwrap());
|
|
68
|
+
return inner.default(rawRule.def.defaultValue);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (rawRule.constructor.name === 'ZodPipe') {
|
|
72
|
+
return normalizeSchemaForDefaults(rawRule.in).pipe(rawRule.out);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return rawRule;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function useFormInitial(
|
|
79
|
+
props: ComputedRef<VbenFormProps> | VbenFormProps,
|
|
80
|
+
) {
|
|
81
|
+
const slots = useSlots();
|
|
82
|
+
const initialValues = generateInitialValues();
|
|
83
|
+
|
|
84
|
+
const form = useFormRuntime(initialValues);
|
|
85
|
+
|
|
86
|
+
const delegatedSlots = computed(() => {
|
|
87
|
+
const resultSlots: string[] = [];
|
|
88
|
+
|
|
89
|
+
for (const key of Object.keys(slots)) {
|
|
90
|
+
if (key !== 'default') {
|
|
91
|
+
resultSlots.push(key);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return resultSlots;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
function generateInitialValues() {
|
|
98
|
+
const initialValues: Record<string, any> = {};
|
|
99
|
+
|
|
100
|
+
const zodObject: Record<string, ZodType> = {};
|
|
101
|
+
getFormFieldSchemas(unref(props).schema ?? []).forEach((item) => {
|
|
102
|
+
if (Reflect.has(item, 'defaultValue')) {
|
|
103
|
+
set(initialValues, item.fieldName, item.defaultValue);
|
|
104
|
+
} else if (item.rules && !isString(item.rules)) {
|
|
105
|
+
// 检查规则是否适合提取默认值
|
|
106
|
+
const rawRules = toRaw(item.rules);
|
|
107
|
+
const customDefaultValue = getCustomDefaultValue(rawRules);
|
|
108
|
+
zodObject[item.fieldName] = normalizeSchemaForDefaults(rawRules);
|
|
109
|
+
if (customDefaultValue !== undefined) {
|
|
110
|
+
initialValues[item.fieldName] = customDefaultValue;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const schemaInitialValues = getDefaultsForSchema(object(zodObject));
|
|
116
|
+
|
|
117
|
+
const zodDefaults: Record<string, any> = {};
|
|
118
|
+
for (const key in schemaInitialValues) {
|
|
119
|
+
set(zodDefaults, key, schemaInitialValues[key]);
|
|
120
|
+
}
|
|
121
|
+
return mergeWithArrayOverride(initialValues, zodDefaults);
|
|
122
|
+
}
|
|
123
|
+
// 自定义默认值提取逻辑
|
|
124
|
+
function getCustomDefaultValue(rule: any): any {
|
|
125
|
+
rule = toRaw(rule);
|
|
126
|
+
if (rule instanceof ZodString || rule instanceof ZodStringFormat) {
|
|
127
|
+
return ''; // 字符串及其格式校验默认为空字符串
|
|
128
|
+
} else if (rule instanceof ZodNumber) {
|
|
129
|
+
return null; // 默认为 null(避免显示 0)
|
|
130
|
+
} else if (rule instanceof ZodObject) {
|
|
131
|
+
// 递归提取嵌套对象的默认值
|
|
132
|
+
const defaultValues: Record<string, any> = {};
|
|
133
|
+
for (const [key, valueSchema] of Object.entries(rule.shape)) {
|
|
134
|
+
defaultValues[key] = getCustomDefaultValue(valueSchema);
|
|
135
|
+
}
|
|
136
|
+
return defaultValues;
|
|
137
|
+
} else if (rule instanceof ZodIntersection) {
|
|
138
|
+
return getDefaultsForSchema(normalizeSchemaForDefaults(rule) as any);
|
|
139
|
+
} else {
|
|
140
|
+
return undefined; // 其他类型不提供默认值
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
delegatedSlots,
|
|
146
|
+
form,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BaseFormComponentType,
|
|
3
|
+
ExtendedFormApi,
|
|
4
|
+
FormValues,
|
|
5
|
+
VbenFormComponent,
|
|
6
|
+
VbenFormProps,
|
|
7
|
+
} from './types';
|
|
8
|
+
|
|
9
|
+
import { defineComponent, h, isReactive, onBeforeUnmount, watch } from 'vue';
|
|
10
|
+
|
|
11
|
+
import { useSelector } from '@melt-js/libs-vben/shared/store';
|
|
12
|
+
|
|
13
|
+
import { FormApi } from './form-api';
|
|
14
|
+
import VbenUseForm from './vben-use-form.vue';
|
|
15
|
+
|
|
16
|
+
type UseVbenFormReturn<
|
|
17
|
+
TValues extends FormValues,
|
|
18
|
+
T extends BaseFormComponentType,
|
|
19
|
+
P extends Record<string, any>,
|
|
20
|
+
TSubmitValues extends FormValues = TValues,
|
|
21
|
+
> = readonly [
|
|
22
|
+
VbenFormComponent<TValues, T, P, TSubmitValues>,
|
|
23
|
+
ExtendedFormApi<TValues, T, P, TSubmitValues>,
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export function useVbenForm<
|
|
27
|
+
T extends BaseFormComponentType = BaseFormComponentType,
|
|
28
|
+
P extends Record<string, any> = Record<string, never>,
|
|
29
|
+
>(options: VbenFormProps<T, P>): UseVbenFormReturn<FormValues, T, P>;
|
|
30
|
+
|
|
31
|
+
export function useVbenForm<
|
|
32
|
+
TValues extends FormValues,
|
|
33
|
+
T extends BaseFormComponentType = BaseFormComponentType,
|
|
34
|
+
P extends Record<string, any> = Record<string, never>,
|
|
35
|
+
TSubmitValues extends FormValues = TValues,
|
|
36
|
+
>(
|
|
37
|
+
options: VbenFormProps<T, P, TValues, TSubmitValues>,
|
|
38
|
+
): UseVbenFormReturn<TValues, T, P, TSubmitValues>;
|
|
39
|
+
|
|
40
|
+
export function useVbenForm(
|
|
41
|
+
options: VbenFormProps<any, any, any, any>,
|
|
42
|
+
): UseVbenFormReturn<any, any, any, any> {
|
|
43
|
+
const IS_REACTIVE = isReactive(options);
|
|
44
|
+
const api = new FormApi<any, any, any, any>(options);
|
|
45
|
+
const extendedApi = api as ExtendedFormApi<any, any, any, any>;
|
|
46
|
+
extendedApi.useStore = (selector: any) => {
|
|
47
|
+
return useSelector(api.store, selector);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const Form = defineComponent(
|
|
51
|
+
(props: VbenFormProps, { attrs, slots }) => {
|
|
52
|
+
onBeforeUnmount(() => {
|
|
53
|
+
api.unmount();
|
|
54
|
+
});
|
|
55
|
+
api.setState({ ...props, ...attrs });
|
|
56
|
+
return () =>
|
|
57
|
+
h(VbenUseForm, { ...props, ...attrs, formApi: extendedApi }, slots);
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'VbenUseForm',
|
|
61
|
+
inheritAttrs: false,
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
// Add reactivity support
|
|
65
|
+
if (IS_REACTIVE) {
|
|
66
|
+
watch(
|
|
67
|
+
() => options.schema,
|
|
68
|
+
() => {
|
|
69
|
+
api.setState({ schema: options.schema });
|
|
70
|
+
},
|
|
71
|
+
{ immediate: true },
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return [Form, extendedApi] as unknown as UseVbenFormReturn<
|
|
76
|
+
any,
|
|
77
|
+
any,
|
|
78
|
+
any,
|
|
79
|
+
any
|
|
80
|
+
>;
|
|
81
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { VbenFormProps } from './types';
|
|
3
|
+
|
|
4
|
+
import { ref, watchEffect } from 'vue';
|
|
5
|
+
|
|
6
|
+
import { useForwardPropsEmits } from '@melt-js/libs-vben/composables';
|
|
7
|
+
|
|
8
|
+
import FormActions from './components/form-actions.vue';
|
|
9
|
+
import {
|
|
10
|
+
COMPONENT_BIND_EVENT_MAP,
|
|
11
|
+
COMPONENT_MAP,
|
|
12
|
+
DEFAULT_FORM_COMMON_CONFIG,
|
|
13
|
+
} from './config';
|
|
14
|
+
import { Form } from './form-render';
|
|
15
|
+
import { provideFormProps, useFormInitial } from './use-form-context';
|
|
16
|
+
|
|
17
|
+
// 通过 extends 会导致热更新卡死
|
|
18
|
+
interface Props extends VbenFormProps {}
|
|
19
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
20
|
+
actionWrapperClass: '',
|
|
21
|
+
collapsed: false,
|
|
22
|
+
collapsedRows: 1,
|
|
23
|
+
commonConfig: () => ({}),
|
|
24
|
+
handleReset: undefined,
|
|
25
|
+
handleSubmit: undefined,
|
|
26
|
+
layout: 'horizontal',
|
|
27
|
+
resetButtonOptions: () => ({}),
|
|
28
|
+
showCollapseButton: false,
|
|
29
|
+
showDefaultActions: true,
|
|
30
|
+
submitButtonOptions: () => ({}),
|
|
31
|
+
wrapperClass: 'grid-cols-1',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const forward = useForwardPropsEmits(props);
|
|
35
|
+
|
|
36
|
+
const currentCollapsed = ref(false);
|
|
37
|
+
|
|
38
|
+
const { delegatedSlots, form } = useFormInitial(props);
|
|
39
|
+
|
|
40
|
+
provideFormProps([props, form]);
|
|
41
|
+
|
|
42
|
+
const handleUpdateCollapsed = (value: boolean) => {
|
|
43
|
+
currentCollapsed.value = value;
|
|
44
|
+
// 触发收起展开状态变化回调
|
|
45
|
+
props.handleCollapsedChange?.(value);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
watchEffect(() => {
|
|
49
|
+
currentCollapsed.value = props.collapsed;
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<Form
|
|
55
|
+
v-bind="forward"
|
|
56
|
+
:collapsed="currentCollapsed"
|
|
57
|
+
:component-bind-event-map="COMPONENT_BIND_EVENT_MAP"
|
|
58
|
+
:component-map="COMPONENT_MAP"
|
|
59
|
+
:form="form"
|
|
60
|
+
:global-common-config="DEFAULT_FORM_COMMON_CONFIG"
|
|
61
|
+
>
|
|
62
|
+
<template
|
|
63
|
+
v-for="slotName in delegatedSlots"
|
|
64
|
+
:key="slotName"
|
|
65
|
+
#[slotName]="slotProps"
|
|
66
|
+
>
|
|
67
|
+
<slot :name="slotName" v-bind="slotProps"></slot>
|
|
68
|
+
</template>
|
|
69
|
+
<template #default="slotProps">
|
|
70
|
+
<slot v-bind="slotProps">
|
|
71
|
+
<FormActions
|
|
72
|
+
v-if="showDefaultActions"
|
|
73
|
+
:model-value="currentCollapsed"
|
|
74
|
+
@update:model-value="handleUpdateCollapsed"
|
|
75
|
+
/>
|
|
76
|
+
</slot>
|
|
77
|
+
</template>
|
|
78
|
+
</Form>
|
|
79
|
+
</template>
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ExtendedFormApi, VbenFormProps, VbenFormSlots } from './types';
|
|
3
|
+
|
|
4
|
+
import { nextTick, onMounted, readonly, watch } from 'vue';
|
|
5
|
+
|
|
6
|
+
import { useForwardPriorityValues } from '@melt-js/libs-vben/composables';
|
|
7
|
+
import { get, isEqual } from '@melt-js/libs-vben/shared/utils';
|
|
8
|
+
|
|
9
|
+
import { useDebounceFn } from '@vueuse/core';
|
|
10
|
+
|
|
11
|
+
import FormActions from './components/form-actions.vue';
|
|
12
|
+
import {
|
|
13
|
+
COMPONENT_BIND_EVENT_MAP,
|
|
14
|
+
COMPONENT_MAP,
|
|
15
|
+
DEFAULT_FORM_COMMON_CONFIG,
|
|
16
|
+
} from './config';
|
|
17
|
+
import { Form } from './form-render';
|
|
18
|
+
import { getFormFieldSchemas } from './form-render/schema';
|
|
19
|
+
import {
|
|
20
|
+
provideComponentRefMap,
|
|
21
|
+
provideFormProps,
|
|
22
|
+
useFormInitial,
|
|
23
|
+
} from './use-form-context';
|
|
24
|
+
|
|
25
|
+
// 通过 extends 会导致热更新卡死,所以重复写了一遍
|
|
26
|
+
interface Props extends VbenFormProps {
|
|
27
|
+
formApi?: ExtendedFormApi<any, any, any, any>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = defineProps<Props>();
|
|
31
|
+
defineSlots<
|
|
32
|
+
Record<string, ((props: Record<string, any>) => any) | undefined> &
|
|
33
|
+
VbenFormSlots<any, any, any>
|
|
34
|
+
>();
|
|
35
|
+
|
|
36
|
+
const formApi = props.formApi;
|
|
37
|
+
if (!formApi) {
|
|
38
|
+
throw new Error('Form api is required in <VbenUseForm />');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const state = formApi.useStore();
|
|
42
|
+
|
|
43
|
+
const forward = useForwardPriorityValues(props, state);
|
|
44
|
+
|
|
45
|
+
const componentRefMap = new Map<string, unknown>();
|
|
46
|
+
|
|
47
|
+
const { delegatedSlots, form } = useFormInitial(forward);
|
|
48
|
+
const values = form.useValues();
|
|
49
|
+
|
|
50
|
+
provideFormProps([forward, form]);
|
|
51
|
+
provideComponentRefMap(componentRefMap);
|
|
52
|
+
|
|
53
|
+
formApi.mount(form, componentRefMap);
|
|
54
|
+
|
|
55
|
+
function handleUpdateCollapsed(value: boolean) {
|
|
56
|
+
props.formApi?.setState({ collapsed: value });
|
|
57
|
+
// 触发收起展开状态变化回调
|
|
58
|
+
forward.value.handleCollapsedChange?.(value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handleKeyDownEnter(event: KeyboardEvent) {
|
|
62
|
+
if (!state?.value.submitOnEnter || !forward.value.formApi?.isMounted) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// 如果是 textarea 不阻止默认行为,否则会导致无法换行。
|
|
66
|
+
// 跳过 textarea 的回车提交处理
|
|
67
|
+
if (event.target instanceof HTMLTextAreaElement) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
|
|
72
|
+
forward.value.formApi?.validateAndSubmit();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const handleValuesChangeDebounced = useDebounceFn(async () => {
|
|
76
|
+
state?.value.submitOnChange && forward.value.formApi?.validateAndSubmit();
|
|
77
|
+
}, state?.value?.changeDebouncedTime ?? 300);
|
|
78
|
+
|
|
79
|
+
let valuesChangeReady = false;
|
|
80
|
+
|
|
81
|
+
onMounted(async () => {
|
|
82
|
+
// 只在挂载后开始监听,form.values会有一个初始化的过程
|
|
83
|
+
await nextTick();
|
|
84
|
+
valuesChangeReady = true;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
watch(values, (currentValues, previousValues) => {
|
|
88
|
+
if (!valuesChangeReady) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const handleValuesChange = forward.value.handleValuesChange;
|
|
92
|
+
const submitOnChange = state?.value.submitOnChange;
|
|
93
|
+
if (!handleValuesChange && !submitOnChange) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const fields = getFormFieldSchemas(state?.value.schema ?? []).map(
|
|
97
|
+
(item) => item.fieldName,
|
|
98
|
+
);
|
|
99
|
+
if (handleValuesChange && fields.length > 0) {
|
|
100
|
+
const changedFields = fields.filter((field) => {
|
|
101
|
+
return !isEqual(
|
|
102
|
+
get(currentValues, field),
|
|
103
|
+
get(previousValues ?? {}, field),
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
if (changedFields.length > 0) {
|
|
107
|
+
handleValuesChange(readonly(currentValues), changedFields, () =>
|
|
108
|
+
formApi.formatValues(currentValues),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (submitOnChange) {
|
|
113
|
+
handleValuesChangeDebounced();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<template>
|
|
119
|
+
<Form
|
|
120
|
+
@keydown.enter="handleKeyDownEnter"
|
|
121
|
+
v-bind="forward"
|
|
122
|
+
:collapsed="state?.collapsed"
|
|
123
|
+
:component-bind-event-map="COMPONENT_BIND_EVENT_MAP"
|
|
124
|
+
:component-map="COMPONENT_MAP"
|
|
125
|
+
:form="form"
|
|
126
|
+
:global-common-config="DEFAULT_FORM_COMMON_CONFIG"
|
|
127
|
+
>
|
|
128
|
+
<template
|
|
129
|
+
v-for="slotName in delegatedSlots"
|
|
130
|
+
:key="slotName"
|
|
131
|
+
#[slotName]="slotProps"
|
|
132
|
+
>
|
|
133
|
+
<slot
|
|
134
|
+
:name="slotName"
|
|
135
|
+
v-bind="slotProps"
|
|
136
|
+
:form-api="formApi"
|
|
137
|
+
:values="form.values"
|
|
138
|
+
></slot>
|
|
139
|
+
</template>
|
|
140
|
+
<template #default="slotProps">
|
|
141
|
+
<slot
|
|
142
|
+
v-if="$slots.default"
|
|
143
|
+
v-bind="slotProps"
|
|
144
|
+
:form-api="formApi"
|
|
145
|
+
:values="form.values"
|
|
146
|
+
></slot>
|
|
147
|
+
<FormActions
|
|
148
|
+
v-else-if="forward.showDefaultActions"
|
|
149
|
+
:model-value="state?.collapsed"
|
|
150
|
+
@update:model-value="handleUpdateCollapsed"
|
|
151
|
+
>
|
|
152
|
+
<template #reset-before="resetSlotProps">
|
|
153
|
+
<slot
|
|
154
|
+
name="reset-before"
|
|
155
|
+
v-bind="resetSlotProps"
|
|
156
|
+
:form-api="formApi"
|
|
157
|
+
:values="form.values"
|
|
158
|
+
></slot>
|
|
159
|
+
</template>
|
|
160
|
+
<template #submit-before="submitSlotProps">
|
|
161
|
+
<slot
|
|
162
|
+
name="submit-before"
|
|
163
|
+
v-bind="submitSlotProps"
|
|
164
|
+
:form-api="formApi"
|
|
165
|
+
:values="form.values"
|
|
166
|
+
></slot>
|
|
167
|
+
</template>
|
|
168
|
+
<template #expand-before="expandBeforeSlotProps">
|
|
169
|
+
<slot
|
|
170
|
+
name="expand-before"
|
|
171
|
+
v-bind="expandBeforeSlotProps"
|
|
172
|
+
:form-api="formApi"
|
|
173
|
+
:values="form.values"
|
|
174
|
+
></slot>
|
|
175
|
+
</template>
|
|
176
|
+
<template #expand-after="expandAfterSlotProps">
|
|
177
|
+
<slot
|
|
178
|
+
name="expand-after"
|
|
179
|
+
v-bind="expandAfterSlotProps"
|
|
180
|
+
:form-api="formApi"
|
|
181
|
+
:values="form.values"
|
|
182
|
+
></slot>
|
|
183
|
+
</template>
|
|
184
|
+
</FormActions>
|
|
185
|
+
</template>
|
|
186
|
+
</Form>
|
|
187
|
+
</template>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as LayoutContent } from './layout-content.vue';
|
|
2
|
+
export { default as LayoutFooter } from './layout-footer.vue';
|
|
3
|
+
export { default as LayoutHeader } from './layout-header.vue';
|
|
4
|
+
export { default as LayoutSidebar } from './layout-sidebar.vue';
|
|
5
|
+
export { default as LayoutTabbar } from './layout-tabbar.vue';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { CSSProperties } from 'vue';
|
|
3
|
+
|
|
4
|
+
import type { ContentCompactType } from '@melt-js/libs-vben/typings';
|
|
5
|
+
|
|
6
|
+
import { computed } from 'vue';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
/**
|
|
10
|
+
* 内容区域定宽
|
|
11
|
+
*/
|
|
12
|
+
contentCompact: ContentCompactType;
|
|
13
|
+
/**
|
|
14
|
+
* 定宽布局宽度
|
|
15
|
+
*/
|
|
16
|
+
contentCompactWidth: number;
|
|
17
|
+
padding: number;
|
|
18
|
+
paddingBottom: number;
|
|
19
|
+
paddingLeft: number;
|
|
20
|
+
paddingRight: number;
|
|
21
|
+
paddingTop: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(defineProps<Props>(), {});
|
|
25
|
+
|
|
26
|
+
const overlayViewportStyle: CSSProperties = {
|
|
27
|
+
height:
|
|
28
|
+
'calc(var(--vben-viewport-height) - var(--vben-header-height, 0px) - var(--vben-footer-height, 0px))',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const style = computed((): CSSProperties => {
|
|
32
|
+
const {
|
|
33
|
+
contentCompact,
|
|
34
|
+
padding,
|
|
35
|
+
paddingBottom,
|
|
36
|
+
paddingLeft,
|
|
37
|
+
paddingRight,
|
|
38
|
+
paddingTop,
|
|
39
|
+
} = props;
|
|
40
|
+
|
|
41
|
+
const compactStyle: CSSProperties =
|
|
42
|
+
contentCompact === 'compact'
|
|
43
|
+
? { margin: '0 auto', width: `${props.contentCompactWidth}px` }
|
|
44
|
+
: {};
|
|
45
|
+
return {
|
|
46
|
+
...compactStyle,
|
|
47
|
+
flex: 1,
|
|
48
|
+
minWidth: 0,
|
|
49
|
+
padding: `${padding}px`,
|
|
50
|
+
paddingBottom: `${paddingBottom}px`,
|
|
51
|
+
paddingLeft: `${paddingLeft}px`,
|
|
52
|
+
paddingRight: `${paddingRight}px`,
|
|
53
|
+
paddingTop: `${paddingTop}px`,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<template>
|
|
59
|
+
<main :style="style" class="relative min-w-0">
|
|
60
|
+
<div
|
|
61
|
+
v-if="$slots.overlay"
|
|
62
|
+
data-layout-region="content-overlay"
|
|
63
|
+
class="pointer-events-none sticky top-0 z-150 h-0 w-full"
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
:style="overlayViewportStyle"
|
|
67
|
+
data-layout-region="overlay-viewport"
|
|
68
|
+
class="pointer-events-none relative min-h-0 w-full"
|
|
69
|
+
>
|
|
70
|
+
<slot name="overlay"></slot>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
<slot></slot>
|
|
74
|
+
</main>
|
|
75
|
+
</template>
|