@go-wind/admin-vben 0.0.0-stage → 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/LICENSE +21 -0
- package/package.json +38 -3
- package/src/base/design/css/global.css +169 -0
- package/src/base/design/css/nprogress.css +59 -0
- package/src/base/design/css/transition.css +236 -0
- package/src/base/design/css/ui.css +83 -0
- package/src/base/design/design-tokens/dark.css +448 -0
- package/src/base/design/design-tokens/default.css +396 -0
- package/src/base/design/design-tokens/index.ts +4 -0
- package/src/base/design/index.ts +8 -0
- package/src/base/design/scss-bem/bem.scss +34 -0
- package/src/base/design/scss-bem/constants.scss +5 -0
- package/src/base/icons/create-icon.ts +14 -0
- package/src/base/icons/index.ts +11 -0
- package/src/base/icons/lucide.ts +62 -0
- package/src/base/shared/cache/__tests__/storage-manager.test.ts +130 -0
- package/src/base/shared/cache/index.ts +1 -0
- package/src/base/shared/cache/storage-manager.ts +118 -0
- package/src/base/shared/cache/types.ts +17 -0
- package/src/base/shared/color/__tests__/convert.test.ts +58 -0
- package/src/base/shared/color/color.ts +10 -0
- package/src/base/shared/color/convert.ts +62 -0
- package/src/base/shared/color/generator.ts +45 -0
- package/src/base/shared/color/index.ts +3 -0
- package/src/base/shared/constants/globals.ts +16 -0
- package/src/base/shared/constants/index.ts +2 -0
- package/src/base/shared/constants/vben.ts +25 -0
- package/src/base/shared/global-state.ts +45 -0
- package/src/base/shared/store.ts +1 -0
- package/src/base/shared/utils/__tests__/diff.test.ts +53 -0
- package/src/base/shared/utils/__tests__/dom.test.ts +127 -0
- package/src/base/shared/utils/__tests__/inference.test.ts +183 -0
- package/src/base/shared/utils/__tests__/letter.test.ts +116 -0
- package/src/base/shared/utils/__tests__/state-handler.test.ts +60 -0
- package/src/base/shared/utils/__tests__/tree.test.ts +196 -0
- package/src/base/shared/utils/__tests__/unique.test.ts +60 -0
- package/src/base/shared/utils/__tests__/update-css-variables.test.ts +30 -0
- package/src/base/shared/utils/__tests__/util.test.ts +156 -0
- package/src/base/shared/utils/__tests__/window.test.ts +33 -0
- package/src/base/shared/utils/cn.ts +8 -0
- package/src/base/shared/utils/date.ts +57 -0
- package/src/base/shared/utils/diff.ts +96 -0
- package/src/base/shared/utils/dom.ts +95 -0
- package/src/base/shared/utils/download.ts +156 -0
- package/src/base/shared/utils/index.ts +19 -0
- package/src/base/shared/utils/inference.ts +164 -0
- package/src/base/shared/utils/letter.ts +47 -0
- package/src/base/shared/utils/merge.ts +10 -0
- package/src/base/shared/utils/nprogress.ts +43 -0
- package/src/base/shared/utils/state-handler.ts +50 -0
- package/src/base/shared/utils/to.ts +21 -0
- package/src/base/shared/utils/tree.ts +97 -0
- package/src/base/shared/utils/unique.ts +15 -0
- package/src/base/shared/utils/update-css-variables.ts +35 -0
- package/src/base/shared/utils/util.ts +44 -0
- package/src/base/shared/utils/window.ts +37 -0
- package/src/base/typings/app.d.ts +106 -0
- package/src/base/typings/basic.d.ts +39 -0
- package/src/base/typings/helper.d.ts +133 -0
- package/src/base/typings/index.ts +6 -0
- package/src/base/typings/menu-record.ts +77 -0
- package/src/base/typings/tabs.ts +3 -0
- package/src/base/typings/vue-router.d.ts +143 -0
- package/src/constants/core.ts +31 -0
- package/src/constants/index.ts +2 -0
- package/src/core/composables/__tests__/use-sortable.test.ts +48 -0
- package/src/core/composables/index.ts +13 -0
- package/src/core/composables/use-is-mobile.ts +7 -0
- package/src/core/composables/use-layout-style.ts +87 -0
- package/src/core/composables/use-namespace.ts +106 -0
- package/src/core/composables/use-priority-value.ts +93 -0
- package/src/core/composables/use-scroll-lock.ts +54 -0
- package/src/core/composables/use-simple-locale/README.md +3 -0
- package/src/core/composables/use-simple-locale/index.ts +25 -0
- package/src/core/composables/use-simple-locale/messages.ts +22 -0
- package/src/core/composables/use-sortable.ts +29 -0
- package/src/core/preferences/config.ts +115 -0
- package/src/core/preferences/constants.ts +88 -0
- package/src/core/preferences/index.ts +35 -0
- package/src/core/preferences/preferences.ts +231 -0
- package/src/core/preferences/types.ts +281 -0
- package/src/core/preferences/update-css-variables.ts +116 -0
- package/src/core/preferences/use-preferences.ts +232 -0
- package/src/effects/access/access-control.vue +47 -0
- package/src/effects/access/accessible.ts +86 -0
- package/src/effects/access/directive.ts +42 -0
- package/src/effects/access/index.ts +4 -0
- package/src/effects/access/use-access.ts +53 -0
- package/src/effects/common-ui/components/api-component/api-component.vue +205 -0
- package/src/effects/common-ui/components/api-component/index.ts +1 -0
- package/src/effects/common-ui/components/captcha/hooks/useCaptchaPoints.ts +19 -0
- package/src/effects/common-ui/components/captcha/index.ts +6 -0
- package/src/effects/common-ui/components/captcha/point-selection-captcha/index.vue +175 -0
- package/src/effects/common-ui/components/captcha/point-selection-captcha/point-selection-captcha-card.vue +83 -0
- package/src/effects/common-ui/components/captcha/slider-captcha/index.vue +243 -0
- package/src/effects/common-ui/components/captcha/slider-captcha/slider-captcha-action.vue +63 -0
- package/src/effects/common-ui/components/captcha/slider-captcha/slider-captcha-bar.vue +38 -0
- package/src/effects/common-ui/components/captcha/slider-captcha/slider-captcha-content.vue +52 -0
- package/src/effects/common-ui/components/captcha/slider-rotate-captcha/index.vue +213 -0
- package/src/effects/common-ui/components/captcha/types.ts +175 -0
- package/src/effects/common-ui/components/col-page/col-page.vue +107 -0
- package/src/effects/common-ui/components/col-page/index.ts +2 -0
- package/src/effects/common-ui/components/col-page/types.ts +26 -0
- package/src/effects/common-ui/components/ellipsis-text/ellipsis-text.vue +142 -0
- package/src/effects/common-ui/components/ellipsis-text/index.ts +1 -0
- package/src/effects/common-ui/components/icon-picker/icon-picker.vue +230 -0
- package/src/effects/common-ui/components/icon-picker/index.ts +1 -0
- package/src/effects/common-ui/components/index.ts +23 -0
- package/src/effects/common-ui/components/json-viewer/index.ts +3 -0
- package/src/effects/common-ui/components/json-viewer/index.vue +114 -0
- package/src/effects/common-ui/components/json-viewer/style.scss +98 -0
- package/src/effects/common-ui/components/json-viewer/types.ts +44 -0
- package/src/effects/common-ui/components/page/__tests__/page.test.ts +89 -0
- package/src/effects/common-ui/components/page/index.ts +2 -0
- package/src/effects/common-ui/components/page/page.vue +99 -0
- package/src/effects/common-ui/components/page/types.ts +17 -0
- package/src/effects/common-ui/components/resize/index.ts +1 -0
- package/src/effects/common-ui/components/resize/resize.vue +1122 -0
- package/src/effects/common-ui/index.ts +2 -0
- package/src/effects/common-ui/ui/about/about.ts +14 -0
- package/src/effects/common-ui/ui/about/about.vue +182 -0
- package/src/effects/common-ui/ui/about/index.ts +1 -0
- package/src/effects/common-ui/ui/authentication/auth-title.vue +13 -0
- package/src/effects/common-ui/ui/authentication/code-login.vue +118 -0
- package/src/effects/common-ui/ui/authentication/forget-password.vue +115 -0
- package/src/effects/common-ui/ui/authentication/index.ts +7 -0
- package/src/effects/common-ui/ui/authentication/login-expired-modal.vue +56 -0
- package/src/effects/common-ui/ui/authentication/login.vue +184 -0
- package/src/effects/common-ui/ui/authentication/qrcode-login.vue +94 -0
- package/src/effects/common-ui/ui/authentication/register.vue +119 -0
- package/src/effects/common-ui/ui/authentication/third-party-login.vue +36 -0
- package/src/effects/common-ui/ui/authentication/types.ts +70 -0
- package/src/effects/common-ui/ui/dashboard/analysis/analysis-chart-card.vue +24 -0
- package/src/effects/common-ui/ui/dashboard/analysis/analysis-charts-tabs.vue +40 -0
- package/src/effects/common-ui/ui/dashboard/analysis/analysis-overview.vue +55 -0
- package/src/effects/common-ui/ui/dashboard/analysis/index.ts +3 -0
- package/src/effects/common-ui/ui/dashboard/index.ts +3 -0
- package/src/effects/common-ui/ui/dashboard/typing.ts +32 -0
- package/src/effects/common-ui/ui/dashboard/workbench/index.ts +3 -0
- package/src/effects/common-ui/ui/dashboard/workbench/workbench-header.vue +46 -0
- package/src/effects/common-ui/ui/dashboard/workbench/workbench-project.vue +63 -0
- package/src/effects/common-ui/ui/dashboard/workbench/workbench-quick-nav.vue +54 -0
- package/src/effects/common-ui/ui/fallback/fallback.ts +25 -0
- package/src/effects/common-ui/ui/fallback/fallback.vue +163 -0
- package/src/effects/common-ui/ui/fallback/icons/icon-403.vue +151 -0
- package/src/effects/common-ui/ui/fallback/icons/icon-404.vue +154 -0
- package/src/effects/common-ui/ui/fallback/icons/icon-500.vue +215 -0
- package/src/effects/common-ui/ui/fallback/icons/icon-coming-soon.vue +262 -0
- package/src/effects/common-ui/ui/fallback/icons/icon-offline.vue +112 -0
- package/src/effects/common-ui/ui/fallback/index.ts +2 -0
- package/src/effects/common-ui/ui/index.ts +4 -0
- package/src/effects/hooks/index.ts +8 -0
- package/src/effects/hooks/use-app-config.ts +23 -0
- package/src/effects/hooks/use-content-maximize.ts +24 -0
- package/src/effects/hooks/use-design-tokens.ts +280 -0
- package/src/effects/hooks/use-pagination.ts +57 -0
- package/src/effects/hooks/use-refresh.ts +16 -0
- package/src/effects/hooks/use-tabs.ts +113 -0
- package/src/effects/hooks/use-watermark.ts +88 -0
- package/src/icons/iconify/index.ts +79 -0
- package/src/icons/icons/empty-icon.vue +27 -0
- package/src/icons/index.ts +3 -0
- package/src/icons/svg/icons/antdv-logo.svg +29 -0
- package/src/icons/svg/icons/avatar-1.svg +1 -0
- package/src/icons/svg/icons/avatar-2.svg +1 -0
- package/src/icons/svg/icons/avatar-3.svg +1 -0
- package/src/icons/svg/icons/avatar-4.svg +1 -0
- package/src/icons/svg/icons/bell.svg +1 -0
- package/src/icons/svg/icons/cake.svg +1 -0
- package/src/icons/svg/icons/card.svg +1 -0
- package/src/icons/svg/icons/download.svg +1 -0
- package/src/icons/svg/icons/language.svg +1 -0
- package/src/icons/svg/icons/setting.svg +1 -0
- package/src/icons/svg/index.ts +29 -0
- package/src/icons/svg/load.ts +61 -0
- package/src/locales/i18n.ts +146 -0
- package/src/locales/index.ts +30 -0
- package/src/locales/langs/en-US/authentication.json +97 -0
- package/src/locales/langs/en-US/common.json +27 -0
- package/src/locales/langs/en-US/preferences.json +169 -0
- package/src/locales/langs/en-US/ui.json +87 -0
- package/src/locales/langs/zh-CN/authentication.json +97 -0
- package/src/locales/langs/zh-CN/common.json +27 -0
- package/src/locales/langs/zh-CN/preferences.json +169 -0
- package/src/locales/langs/zh-CN/ui.json +87 -0
- package/src/locales/typing.ts +25 -0
- package/src/preferences/index.ts +17 -0
- package/src/stores/index.ts +3 -0
- package/src/stores/modules/access.test.ts +46 -0
- package/src/stores/modules/access.ts +130 -0
- package/src/stores/modules/index.ts +4 -0
- package/src/stores/modules/lock.test.ts +31 -0
- package/src/stores/modules/lock.ts +38 -0
- package/src/stores/modules/tabbar.test.ts +295 -0
- package/src/stores/modules/tabbar.ts +558 -0
- package/src/stores/modules/user.test.ts +37 -0
- package/src/stores/modules/user.ts +92 -0
- package/src/stores/setup.ts +43 -0
- package/src/styles/antd/index.css +292 -0
- package/src/styles/ele/index.css +3 -0
- package/src/styles/global/index.scss +1 -0
- package/src/styles/index.ts +1 -0
- package/src/types/global.d.ts +23 -0
- package/src/types/index.ts +2 -0
- package/src/types/user.ts +26 -0
- package/src/ui-kit/form-ui/components/form-actions.vue +205 -0
- package/src/ui-kit/form-ui/config.ts +82 -0
- package/src/ui-kit/form-ui/form-api.ts +351 -0
- package/src/ui-kit/form-ui/form-render/context.ts +24 -0
- package/src/ui-kit/form-ui/form-render/dependencies.ts +124 -0
- package/src/ui-kit/form-ui/form-render/expandable.ts +99 -0
- package/src/ui-kit/form-ui/form-render/form-field.vue +350 -0
- package/src/ui-kit/form-ui/form-render/form-label.vue +22 -0
- package/src/ui-kit/form-ui/form-render/form.vue +160 -0
- package/src/ui-kit/form-ui/form-render/helper.ts +60 -0
- package/src/ui-kit/form-ui/form-render/index.ts +3 -0
- package/src/ui-kit/form-ui/index.ts +12 -0
- package/src/ui-kit/form-ui/types.ts +395 -0
- package/src/ui-kit/form-ui/use-form-context.ts +59 -0
- package/src/ui-kit/form-ui/use-vben-form.ts +50 -0
- package/src/ui-kit/form-ui/vben-form.vue +77 -0
- package/src/ui-kit/form-ui/vben-use-form.vue +113 -0
- package/src/ui-kit/layout-ui/components/index.ts +5 -0
- package/src/ui-kit/layout-ui/components/layout-content.vue +63 -0
- package/src/ui-kit/layout-ui/components/layout-footer.vue +43 -0
- package/src/ui-kit/layout-ui/components/layout-header.vue +76 -0
- package/src/ui-kit/layout-ui/components/layout-sidebar.vue +315 -0
- package/src/ui-kit/layout-ui/components/layout-tabbar.vue +29 -0
- package/src/ui-kit/layout-ui/components/widgets/index.ts +2 -0
- package/src/ui-kit/layout-ui/components/widgets/sidebar-collapse-button.vue +19 -0
- package/src/ui-kit/layout-ui/components/widgets/sidebar-fixed-button.vue +19 -0
- package/src/ui-kit/layout-ui/hooks/use-layout.ts +41 -0
- package/src/ui-kit/layout-ui/index.ts +2 -0
- package/src/ui-kit/layout-ui/vben-layout.ts +165 -0
- package/src/ui-kit/layout-ui/vben-layout.vue +596 -0
- package/src/ui-kit/menu-ui/components/collapse-transition.vue +96 -0
- package/src/ui-kit/menu-ui/components/index.ts +4 -0
- package/src/ui-kit/menu-ui/components/menu-badge-dot.vue +28 -0
- package/src/ui-kit/menu-ui/components/menu-badge.vue +57 -0
- package/src/ui-kit/menu-ui/components/menu-item.vue +122 -0
- package/src/ui-kit/menu-ui/components/menu.vue +859 -0
- package/src/ui-kit/menu-ui/components/normal-menu/index.ts +2 -0
- package/src/ui-kit/menu-ui/components/normal-menu/normal-menu.ts +27 -0
- package/src/ui-kit/menu-ui/components/normal-menu/normal-menu.vue +162 -0
- package/src/ui-kit/menu-ui/components/sub-menu-content.vue +105 -0
- package/src/ui-kit/menu-ui/components/sub-menu.vue +273 -0
- package/src/ui-kit/menu-ui/hooks/index.ts +2 -0
- package/src/ui-kit/menu-ui/hooks/use-menu-context.ts +55 -0
- package/src/ui-kit/menu-ui/hooks/use-menu.ts +48 -0
- package/src/ui-kit/menu-ui/index.ts +3 -0
- package/src/ui-kit/menu-ui/menu.vue +38 -0
- package/src/ui-kit/menu-ui/sub-menu.vue +71 -0
- package/src/ui-kit/menu-ui/types.ts +139 -0
- package/src/ui-kit/menu-ui/utils/index.ts +51 -0
- package/src/ui-kit/popup-ui/drawer/__tests__/drawer-api.test.ts +132 -0
- package/src/ui-kit/popup-ui/drawer/drawer-api.ts +144 -0
- package/src/ui-kit/popup-ui/drawer/drawer.ts +152 -0
- package/src/ui-kit/popup-ui/drawer/drawer.vue +251 -0
- package/src/ui-kit/popup-ui/drawer/index.ts +3 -0
- package/src/ui-kit/popup-ui/drawer/use-drawer.ts +105 -0
- package/src/ui-kit/popup-ui/index.ts +2 -0
- package/src/ui-kit/popup-ui/modal/__tests__/modal-api.test.ts +128 -0
- package/src/ui-kit/popup-ui/modal/index.ts +3 -0
- package/src/ui-kit/popup-ui/modal/modal-api.ts +172 -0
- package/src/ui-kit/popup-ui/modal/modal.ts +175 -0
- package/src/ui-kit/popup-ui/modal/modal.vue +311 -0
- package/src/ui-kit/popup-ui/modal/use-modal-draggable.ts +116 -0
- package/src/ui-kit/popup-ui/modal/use-modal.ts +117 -0
- package/src/ui-kit/shadcn-ui/components/avatar/avatar.vue +49 -0
- package/src/ui-kit/shadcn-ui/components/avatar/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/back-top/back-top.vue +43 -0
- package/src/ui-kit/shadcn-ui/components/back-top/backtop.ts +38 -0
- package/src/ui-kit/shadcn-ui/components/back-top/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/back-top/use-backtop.ts +45 -0
- package/src/ui-kit/shadcn-ui/components/breadcrumb/breadcrumb-background.vue +109 -0
- package/src/ui-kit/shadcn-ui/components/breadcrumb/breadcrumb-view.vue +22 -0
- package/src/ui-kit/shadcn-ui/components/breadcrumb/breadcrumb.vue +98 -0
- package/src/ui-kit/shadcn-ui/components/breadcrumb/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/components/breadcrumb/types.ts +17 -0
- package/src/ui-kit/shadcn-ui/components/button/button.ts +24 -0
- package/src/ui-kit/shadcn-ui/components/button/button.vue +42 -0
- package/src/ui-kit/shadcn-ui/components/button/icon-button.vue +78 -0
- package/src/ui-kit/shadcn-ui/components/button/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/components/checkbox/checkbox.vue +26 -0
- package/src/ui-kit/shadcn-ui/components/checkbox/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/context-menu/context-menu.vue +96 -0
- package/src/ui-kit/shadcn-ui/components/context-menu/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/components/context-menu/interface.ts +38 -0
- package/src/ui-kit/shadcn-ui/components/count-to-animator/count-to-animator.vue +111 -0
- package/src/ui-kit/shadcn-ui/components/count-to-animator/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/dropdown-menu/dropdown-menu.vue +49 -0
- package/src/ui-kit/shadcn-ui/components/dropdown-menu/dropdown-radio-menu.vue +52 -0
- package/src/ui-kit/shadcn-ui/components/dropdown-menu/index.ts +4 -0
- package/src/ui-kit/shadcn-ui/components/dropdown-menu/interface.ts +32 -0
- package/src/ui-kit/shadcn-ui/components/expandable-arrow/expandable-arrow.vue +31 -0
- package/src/ui-kit/shadcn-ui/components/expandable-arrow/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/full-screen/full-screen.vue +51 -0
- package/src/ui-kit/shadcn-ui/components/full-screen/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/hover-card/hover-card.vue +54 -0
- package/src/ui-kit/shadcn-ui/components/hover-card/index.ts +2 -0
- package/src/ui-kit/shadcn-ui/components/icon/icon.vue +33 -0
- package/src/ui-kit/shadcn-ui/components/icon/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/index.ts +23 -0
- package/src/ui-kit/shadcn-ui/components/input-password/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/input-password/input-password.vue +57 -0
- package/src/ui-kit/shadcn-ui/components/input-password/password-strength.vue +66 -0
- package/src/ui-kit/shadcn-ui/components/logo/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/logo/logo.vue +65 -0
- package/src/ui-kit/shadcn-ui/components/pin-input/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/components/pin-input/input.vue +116 -0
- package/src/ui-kit/shadcn-ui/components/pin-input/types.ts +30 -0
- package/src/ui-kit/shadcn-ui/components/popover/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/popover/popover.vue +57 -0
- package/src/ui-kit/shadcn-ui/components/render-content/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/render-content/render-content.vue +39 -0
- package/src/ui-kit/shadcn-ui/components/scrollbar/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/scrollbar/scrollbar.vue +153 -0
- package/src/ui-kit/shadcn-ui/components/segmented/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/components/segmented/segmented.vue +59 -0
- package/src/ui-kit/shadcn-ui/components/segmented/tabs-indicator.vue +37 -0
- package/src/ui-kit/shadcn-ui/components/segmented/types.ts +6 -0
- package/src/ui-kit/shadcn-ui/components/select/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/select/select.vue +29 -0
- package/src/ui-kit/shadcn-ui/components/spine-text/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/components/spine-text/spine-text.vue +49 -0
- package/src/ui-kit/shadcn-ui/components/spinner/index.ts +2 -0
- package/src/ui-kit/shadcn-ui/components/spinner/loading.vue +137 -0
- package/src/ui-kit/shadcn-ui/components/spinner/spinner.vue +125 -0
- package/src/ui-kit/shadcn-ui/components/tooltip/help-tooltip.vue +31 -0
- package/src/ui-kit/shadcn-ui/components/tooltip/index.ts +2 -0
- package/src/ui-kit/shadcn-ui/components/tooltip/tooltip.vue +43 -0
- package/src/ui-kit/shadcn-ui/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/ui/accordion/Accordion.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/accordion/AccordionContent.vue +26 -0
- package/src/ui-kit/shadcn-ui/ui/accordion/AccordionItem.vue +27 -0
- package/src/ui-kit/shadcn-ui/ui/accordion/AccordionTrigger.vue +41 -0
- package/src/ui-kit/shadcn-ui/ui/accordion/index.ts +4 -0
- package/src/ui-kit/shadcn-ui/ui/alert-dialog/AlertDialog.vue +16 -0
- package/src/ui-kit/shadcn-ui/ui/alert-dialog/AlertDialogAction.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/alert-dialog/AlertDialogCancel.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/alert-dialog/AlertDialogContent.vue +101 -0
- package/src/ui-kit/shadcn-ui/ui/alert-dialog/AlertDialogDescription.vue +28 -0
- package/src/ui-kit/shadcn-ui/ui/alert-dialog/AlertDialogOverlay.vue +8 -0
- package/src/ui-kit/shadcn-ui/ui/alert-dialog/AlertDialogTitle.vue +30 -0
- package/src/ui-kit/shadcn-ui/ui/alert-dialog/index.ts +6 -0
- package/src/ui-kit/shadcn-ui/ui/avatar/Avatar.vue +25 -0
- package/src/ui-kit/shadcn-ui/ui/avatar/AvatarFallback.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/avatar/AvatarImage.vue +9 -0
- package/src/ui-kit/shadcn-ui/ui/avatar/avatar.ts +20 -0
- package/src/ui-kit/shadcn-ui/ui/avatar/index.ts +4 -0
- package/src/ui-kit/shadcn-ui/ui/badge/Badge.vue +16 -0
- package/src/ui-kit/shadcn-ui/ui/badge/badge.ts +23 -0
- package/src/ui-kit/shadcn-ui/ui/badge/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/ui/breadcrumb/Breadcrumb.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/breadcrumb/BreadcrumbEllipsis.vue +22 -0
- package/src/ui-kit/shadcn-ui/ui/breadcrumb/BreadcrumbItem.vue +17 -0
- package/src/ui-kit/shadcn-ui/ui/breadcrumb/BreadcrumbLink.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/breadcrumb/BreadcrumbList.vue +20 -0
- package/src/ui-kit/shadcn-ui/ui/breadcrumb/BreadcrumbPage.vue +18 -0
- package/src/ui-kit/shadcn-ui/ui/breadcrumb/BreadcrumbSeparator.vue +21 -0
- package/src/ui-kit/shadcn-ui/ui/breadcrumb/index.ts +7 -0
- package/src/ui-kit/shadcn-ui/ui/button/Button.vue +30 -0
- package/src/ui-kit/shadcn-ui/ui/button/button.ts +34 -0
- package/src/ui-kit/shadcn-ui/ui/button/index.ts +5 -0
- package/src/ui-kit/shadcn-ui/ui/button/types.ts +20 -0
- package/src/ui-kit/shadcn-ui/ui/card/Card.vue +20 -0
- package/src/ui-kit/shadcn-ui/ui/card/CardContent.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/card/CardDescription.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/card/CardFooter.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/card/CardHeader.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/card/CardTitle.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/card/index.ts +6 -0
- package/src/ui-kit/shadcn-ui/ui/checkbox/Checkbox.vue +45 -0
- package/src/ui-kit/shadcn-ui/ui/checkbox/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenu.vue +18 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuCheckboxItem.vue +44 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuContent.vue +40 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuGroup.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuItem.vue +40 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuLabel.vue +32 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuPortal.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuRadioGroup.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuRadioItem.vue +44 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuSeparator.vue +25 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuShortcut.vue +17 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuSub.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuSubContent.vue +37 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuSubTrigger.vue +43 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/ContextMenuTrigger.vue +17 -0
- package/src/ui-kit/shadcn-ui/ui/context-menu/index.ts +14 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/Dialog.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogClose.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogContent.vue +117 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogDescription.vue +30 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogFooter.vue +15 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogHeader.vue +15 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogOverlay.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogScrollContent.vue +71 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogTitle.vue +28 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/DialogTrigger.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/dialog/index.ts +9 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenu.vue +21 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +44 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuContent.vue +45 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuGroup.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuItem.vue +38 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuLabel.vue +34 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuRadioGroup.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuRadioItem.vue +45 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuSeparator.vue +29 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuShortcut.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuSubContent.vue +37 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuSubTrigger.vue +37 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
- package/src/ui-kit/shadcn-ui/ui/dropdown-menu/index.ts +16 -0
- package/src/ui-kit/shadcn-ui/ui/form/FormControl.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/form/FormDescription.vue +20 -0
- package/src/ui-kit/shadcn-ui/ui/form/FormItem.vue +20 -0
- package/src/ui-kit/shadcn-ui/ui/form/FormLabel.vue +18 -0
- package/src/ui-kit/shadcn-ui/ui/form/FormMessage.vue +18 -0
- package/src/ui-kit/shadcn-ui/ui/form/index.ts +11 -0
- package/src/ui-kit/shadcn-ui/ui/form/injectionKeys.ts +4 -0
- package/src/ui-kit/shadcn-ui/ui/form/useFormField.ts +38 -0
- package/src/ui-kit/shadcn-ui/ui/hover-card/HoverCard.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/hover-card/HoverCardContent.vue +43 -0
- package/src/ui-kit/shadcn-ui/ui/hover-card/HoverCardTrigger.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/hover-card/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/ui/index.ts +30 -0
- package/src/ui-kit/shadcn-ui/ui/input/Input.vue +32 -0
- package/src/ui-kit/shadcn-ui/ui/input/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/ui/label/Label.vue +29 -0
- package/src/ui-kit/shadcn-ui/ui/label/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/ui/number-field/NumberField.vue +26 -0
- package/src/ui-kit/shadcn-ui/ui/number-field/NumberFieldContent.vue +20 -0
- package/src/ui-kit/shadcn-ui/ui/number-field/NumberFieldDecrement.vue +37 -0
- package/src/ui-kit/shadcn-ui/ui/number-field/NumberFieldIncrement.vue +37 -0
- package/src/ui-kit/shadcn-ui/ui/number-field/NumberFieldInput.vue +16 -0
- package/src/ui-kit/shadcn-ui/ui/number-field/index.ts +5 -0
- package/src/ui-kit/shadcn-ui/ui/pagination/PaginationEllipsis.vue +27 -0
- package/src/ui-kit/shadcn-ui/ui/pagination/PaginationFirst.vue +33 -0
- package/src/ui-kit/shadcn-ui/ui/pagination/PaginationLast.vue +33 -0
- package/src/ui-kit/shadcn-ui/ui/pagination/PaginationNext.vue +33 -0
- package/src/ui-kit/shadcn-ui/ui/pagination/PaginationPrev.vue +33 -0
- package/src/ui-kit/shadcn-ui/ui/pagination/index.ts +10 -0
- package/src/ui-kit/shadcn-ui/ui/pin-input/PinInput.vue +31 -0
- package/src/ui-kit/shadcn-ui/ui/pin-input/PinInputGroup.vue +23 -0
- package/src/ui-kit/shadcn-ui/ui/pin-input/PinInputInput.vue +32 -0
- package/src/ui-kit/shadcn-ui/ui/pin-input/PinInputSeparator.vue +15 -0
- package/src/ui-kit/shadcn-ui/ui/pin-input/index.ts +4 -0
- package/src/ui-kit/shadcn-ui/ui/popover/Popover.vue +16 -0
- package/src/ui-kit/shadcn-ui/ui/popover/PopoverContent.vue +50 -0
- package/src/ui-kit/shadcn-ui/ui/popover/PopoverTrigger.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/popover/index.ts +4 -0
- package/src/ui-kit/shadcn-ui/ui/radio-group/RadioGroup.vue +29 -0
- package/src/ui-kit/shadcn-ui/ui/radio-group/RadioGroupItem.vue +39 -0
- package/src/ui-kit/shadcn-ui/ui/radio-group/index.ts +2 -0
- package/src/ui-kit/shadcn-ui/ui/resizable/ResizableHandle.vue +49 -0
- package/src/ui-kit/shadcn-ui/ui/resizable/ResizablePanelGroup.vue +37 -0
- package/src/ui-kit/shadcn-ui/ui/resizable/index.ts +3 -0
- package/src/ui-kit/shadcn-ui/ui/scroll-area/ScrollArea.vue +49 -0
- package/src/ui-kit/shadcn-ui/ui/scroll-area/ScrollBar.vue +42 -0
- package/src/ui-kit/shadcn-ui/ui/scroll-area/index.ts +2 -0
- package/src/ui-kit/shadcn-ui/ui/select/Select.vue +16 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectContent.vue +67 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectGroup.vue +21 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectItem.vue +46 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectItemText.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectLabel.vue +13 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectScrollDownButton.vue +35 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectScrollUpButton.vue +35 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectSeparator.vue +22 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectTrigger.vue +40 -0
- package/src/ui-kit/shadcn-ui/ui/select/SelectValue.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/select/index.ts +11 -0
- package/src/ui-kit/shadcn-ui/ui/separator/Separator.vue +42 -0
- package/src/ui-kit/shadcn-ui/ui/separator/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/Sheet.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/SheetClose.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/SheetContent.vue +83 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/SheetDescription.vue +24 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/SheetFooter.vue +15 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/SheetHeader.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/SheetOverlay.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/SheetTitle.vue +24 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/SheetTrigger.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/index.ts +10 -0
- package/src/ui-kit/shadcn-ui/ui/sheet/sheet.ts +22 -0
- package/src/ui-kit/shadcn-ui/ui/switch/Switch.vue +45 -0
- package/src/ui-kit/shadcn-ui/ui/switch/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/ui/tabs/Tabs.vue +16 -0
- package/src/ui-kit/shadcn-ui/ui/tabs/TabsContent.vue +29 -0
- package/src/ui-kit/shadcn-ui/ui/tabs/TabsList.vue +29 -0
- package/src/ui-kit/shadcn-ui/ui/tabs/TabsTrigger.vue +31 -0
- package/src/ui-kit/shadcn-ui/ui/tabs/index.ts +5 -0
- package/src/ui-kit/shadcn-ui/ui/textarea/Textarea.vue +32 -0
- package/src/ui-kit/shadcn-ui/ui/textarea/index.ts +1 -0
- package/src/ui-kit/shadcn-ui/ui/toggle/Toggle.vue +48 -0
- package/src/ui-kit/shadcn-ui/ui/toggle/index.ts +2 -0
- package/src/ui-kit/shadcn-ui/ui/toggle/toggle.ts +25 -0
- package/src/ui-kit/shadcn-ui/ui/toggle-group/ToggleGroup.vue +48 -0
- package/src/ui-kit/shadcn-ui/ui/toggle-group/ToggleGroupItem.vue +51 -0
- package/src/ui-kit/shadcn-ui/ui/toggle-group/index.ts +2 -0
- package/src/ui-kit/shadcn-ui/ui/tooltip/Tooltip.vue +19 -0
- package/src/ui-kit/shadcn-ui/ui/tooltip/TooltipContent.vue +52 -0
- package/src/ui-kit/shadcn-ui/ui/tooltip/TooltipProvider.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/tooltip/TooltipTrigger.vue +11 -0
- package/src/ui-kit/shadcn-ui/ui/tooltip/index.ts +4 -0
- package/src/ui-kit/shadcn-ui/ui/tree/index.ts +4 -0
- package/src/ui-kit/shadcn-ui/ui/tree/tree.vue +464 -0
- package/src/ui-kit/shadcn-ui/ui/tree/types.ts +62 -0
- package/src/ui-kit/tabs-ui/components/index.ts +2 -0
- package/src/ui-kit/tabs-ui/components/tabs/tabs.vue +133 -0
- package/src/ui-kit/tabs-ui/components/tabs-chrome/tabs.vue +195 -0
- package/src/ui-kit/tabs-ui/components/widgets/index.ts +2 -0
- package/src/ui-kit/tabs-ui/components/widgets/tool-more.vue +18 -0
- package/src/ui-kit/tabs-ui/components/widgets/tool-screen.vue +19 -0
- package/src/ui-kit/tabs-ui/index.ts +3 -0
- package/src/ui-kit/tabs-ui/tabs-view.vue +95 -0
- package/src/ui-kit/tabs-ui/types.ts +64 -0
- package/src/ui-kit/tabs-ui/use-tabs-drag.ts +127 -0
- package/src/ui-kit/tabs-ui/use-tabs-view-scroll.ts +194 -0
- package/src/utils/helpers/__tests__/find-menu-by-path.test.ts +88 -0
- package/src/utils/helpers/__tests__/generate-menus.test.ts +236 -0
- package/src/utils/helpers/__tests__/generate-routes-frontend.test.ts +105 -0
- package/src/utils/helpers/__tests__/merge-route-modules.test.ts +68 -0
- package/src/utils/helpers/find-menu-by-path.ts +37 -0
- package/src/utils/helpers/generate-menus.ts +80 -0
- package/src/utils/helpers/generate-routes-backend.ts +81 -0
- package/src/utils/helpers/generate-routes-frontend.ts +58 -0
- package/src/utils/helpers/get-popup-container.ts +6 -0
- package/src/utils/helpers/index.ts +8 -0
- package/src/utils/helpers/merge-route-modules.ts +28 -0
- package/src/utils/helpers/reset-routes.ts +31 -0
- package/src/utils/helpers/unmount-global-loading.ts +31 -0
- package/src/utils/index.ts +4 -0
- package/README.md +0 -3
|
@@ -0,0 +1,1122 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
/**
|
|
3
|
+
* This components is refactored from vue-drag-resize: https://github.com/kirillmurashov/vue-drag-resize
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
computed,
|
|
8
|
+
getCurrentInstance,
|
|
9
|
+
nextTick,
|
|
10
|
+
onBeforeUnmount,
|
|
11
|
+
onMounted,
|
|
12
|
+
ref,
|
|
13
|
+
toRefs,
|
|
14
|
+
watch,
|
|
15
|
+
} from 'vue';
|
|
16
|
+
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
stickSize: {
|
|
19
|
+
type: Number,
|
|
20
|
+
default: 8,
|
|
21
|
+
},
|
|
22
|
+
parentScaleX: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: 1,
|
|
25
|
+
},
|
|
26
|
+
parentScaleY: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 1,
|
|
29
|
+
},
|
|
30
|
+
isActive: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
34
|
+
preventActiveBehavior: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false,
|
|
37
|
+
},
|
|
38
|
+
isDraggable: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true,
|
|
41
|
+
},
|
|
42
|
+
isResizable: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: true,
|
|
45
|
+
},
|
|
46
|
+
aspectRatio: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
50
|
+
parentLimitation: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
snapToGrid: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: false,
|
|
57
|
+
},
|
|
58
|
+
gridX: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 50,
|
|
61
|
+
validator(val: number) {
|
|
62
|
+
return val >= 0;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
gridY: {
|
|
66
|
+
type: Number,
|
|
67
|
+
default: 50,
|
|
68
|
+
validator(val: number) {
|
|
69
|
+
return val >= 0;
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
parentW: {
|
|
73
|
+
type: Number,
|
|
74
|
+
default: 0,
|
|
75
|
+
validator(val: number) {
|
|
76
|
+
return val >= 0;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
parentH: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: 0,
|
|
82
|
+
validator(val: number) {
|
|
83
|
+
return val >= 0;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
w: {
|
|
87
|
+
type: [String, Number],
|
|
88
|
+
default: 200,
|
|
89
|
+
validator(val: number) {
|
|
90
|
+
return typeof val === 'string' ? val === 'auto' : val >= 0;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
h: {
|
|
94
|
+
type: [String, Number],
|
|
95
|
+
default: 200,
|
|
96
|
+
validator(val: number) {
|
|
97
|
+
return typeof val === 'string' ? val === 'auto' : val >= 0;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
minw: {
|
|
101
|
+
type: Number,
|
|
102
|
+
default: 50,
|
|
103
|
+
validator(val: number) {
|
|
104
|
+
return val >= 0;
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
minh: {
|
|
108
|
+
type: Number,
|
|
109
|
+
default: 50,
|
|
110
|
+
validator(val: number) {
|
|
111
|
+
return val >= 0;
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
x: {
|
|
115
|
+
type: Number,
|
|
116
|
+
default: 0,
|
|
117
|
+
validator(val: number) {
|
|
118
|
+
return typeof val === 'number';
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
y: {
|
|
122
|
+
type: Number,
|
|
123
|
+
default: 0,
|
|
124
|
+
validator(val: number) {
|
|
125
|
+
return typeof val === 'number';
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
z: {
|
|
129
|
+
type: [String, Number],
|
|
130
|
+
default: 'auto',
|
|
131
|
+
validator(val: number) {
|
|
132
|
+
return typeof val === 'string' ? val === 'auto' : val >= 0;
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
dragHandle: {
|
|
136
|
+
type: String,
|
|
137
|
+
default: null,
|
|
138
|
+
},
|
|
139
|
+
dragCancel: {
|
|
140
|
+
type: String,
|
|
141
|
+
default: null,
|
|
142
|
+
},
|
|
143
|
+
sticks: {
|
|
144
|
+
type: Array<'bl' | 'bm' | 'br' | 'ml' | 'mr' | 'tl' | 'tm' | 'tr'>,
|
|
145
|
+
default() {
|
|
146
|
+
return ['tl', 'tm', 'tr', 'mr', 'br', 'bm', 'bl', 'ml'];
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
axis: {
|
|
150
|
+
type: String,
|
|
151
|
+
default: 'both',
|
|
152
|
+
validator(val: string) {
|
|
153
|
+
return ['both', 'none', 'x', 'y'].includes(val);
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
contentClass: {
|
|
157
|
+
type: String,
|
|
158
|
+
required: false,
|
|
159
|
+
default: '',
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const emit = defineEmits([
|
|
164
|
+
'clicked',
|
|
165
|
+
'dragging',
|
|
166
|
+
'dragstop',
|
|
167
|
+
'resizing',
|
|
168
|
+
'resizestop',
|
|
169
|
+
'activated',
|
|
170
|
+
'deactivated',
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
const styleMapping = {
|
|
174
|
+
y: {
|
|
175
|
+
t: 'top',
|
|
176
|
+
m: 'marginTop',
|
|
177
|
+
b: 'bottom',
|
|
178
|
+
},
|
|
179
|
+
x: {
|
|
180
|
+
l: 'left',
|
|
181
|
+
m: 'marginLeft',
|
|
182
|
+
r: 'right',
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
function addEvents(events: Map<string, (...args: any[]) => void>) {
|
|
187
|
+
events.forEach((cb, eventName) => {
|
|
188
|
+
document.documentElement.addEventListener(eventName, cb);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function removeEvents(events: Map<string, (...args: any[]) => void>) {
|
|
193
|
+
events.forEach((cb, eventName) => {
|
|
194
|
+
document.documentElement.removeEventListener(eventName, cb);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const {
|
|
199
|
+
stickSize,
|
|
200
|
+
parentScaleX,
|
|
201
|
+
parentScaleY,
|
|
202
|
+
isActive,
|
|
203
|
+
preventActiveBehavior,
|
|
204
|
+
isDraggable,
|
|
205
|
+
isResizable,
|
|
206
|
+
aspectRatio,
|
|
207
|
+
parentLimitation,
|
|
208
|
+
snapToGrid,
|
|
209
|
+
gridX,
|
|
210
|
+
gridY,
|
|
211
|
+
parentW,
|
|
212
|
+
parentH,
|
|
213
|
+
w,
|
|
214
|
+
h,
|
|
215
|
+
minw,
|
|
216
|
+
minh,
|
|
217
|
+
x,
|
|
218
|
+
y,
|
|
219
|
+
z,
|
|
220
|
+
dragHandle,
|
|
221
|
+
dragCancel,
|
|
222
|
+
sticks,
|
|
223
|
+
axis,
|
|
224
|
+
contentClass,
|
|
225
|
+
} = toRefs(props);
|
|
226
|
+
|
|
227
|
+
// states
|
|
228
|
+
const active = ref(false);
|
|
229
|
+
const zIndex = ref<null | number>(null);
|
|
230
|
+
const parentWidth = ref<null | number>(null);
|
|
231
|
+
const parentHeight = ref<null | number>(null);
|
|
232
|
+
const left = ref<null | number>(null);
|
|
233
|
+
const top = ref<null | number>(null);
|
|
234
|
+
const right = ref<null | number>(null);
|
|
235
|
+
const bottom = ref<null | number>(null);
|
|
236
|
+
|
|
237
|
+
const aspectFactor = ref<null | number>(null);
|
|
238
|
+
|
|
239
|
+
// state end
|
|
240
|
+
|
|
241
|
+
const stickDrag = ref(false);
|
|
242
|
+
const bodyDrag = ref(false);
|
|
243
|
+
const dimensionsBeforeMove = ref({
|
|
244
|
+
pointerX: 0,
|
|
245
|
+
pointerY: 0,
|
|
246
|
+
x: 0,
|
|
247
|
+
y: 0,
|
|
248
|
+
w: 0,
|
|
249
|
+
h: 0,
|
|
250
|
+
top: 0,
|
|
251
|
+
right: 0,
|
|
252
|
+
bottom: 0,
|
|
253
|
+
left: 0,
|
|
254
|
+
width: 0,
|
|
255
|
+
height: 0,
|
|
256
|
+
});
|
|
257
|
+
const limits = ref({
|
|
258
|
+
left: { min: null as null | number, max: null as null | number },
|
|
259
|
+
right: { min: null as null | number, max: null as null | number },
|
|
260
|
+
top: { min: null as null | number, max: null as null | number },
|
|
261
|
+
bottom: { min: null as null | number, max: null as null | number },
|
|
262
|
+
});
|
|
263
|
+
const currentStick = ref<null | string>(null);
|
|
264
|
+
|
|
265
|
+
const parentElement = ref<HTMLElement | null>(null);
|
|
266
|
+
|
|
267
|
+
const width = computed(() => parentWidth.value! - left.value! - right.value!);
|
|
268
|
+
|
|
269
|
+
const height = computed(() => parentHeight.value! - top.value! - bottom.value!);
|
|
270
|
+
|
|
271
|
+
const rect = computed(() => ({
|
|
272
|
+
left: Math.round(left.value!),
|
|
273
|
+
top: Math.round(top.value!),
|
|
274
|
+
width: Math.round(width.value),
|
|
275
|
+
height: Math.round(height.value),
|
|
276
|
+
}));
|
|
277
|
+
|
|
278
|
+
const saveDimensionsBeforeMove = ({
|
|
279
|
+
pointerX,
|
|
280
|
+
pointerY,
|
|
281
|
+
}: {
|
|
282
|
+
pointerX: number;
|
|
283
|
+
pointerY: number;
|
|
284
|
+
}) => {
|
|
285
|
+
dimensionsBeforeMove.value.pointerX = pointerX;
|
|
286
|
+
dimensionsBeforeMove.value.pointerY = pointerY;
|
|
287
|
+
|
|
288
|
+
dimensionsBeforeMove.value.left = left.value as number;
|
|
289
|
+
dimensionsBeforeMove.value.right = right.value as number;
|
|
290
|
+
dimensionsBeforeMove.value.top = top.value as number;
|
|
291
|
+
dimensionsBeforeMove.value.bottom = bottom.value as number;
|
|
292
|
+
|
|
293
|
+
dimensionsBeforeMove.value.width = width.value as number;
|
|
294
|
+
dimensionsBeforeMove.value.height = height.value as number;
|
|
295
|
+
|
|
296
|
+
aspectFactor.value = width.value / height.value;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const sideCorrectionByLimit = (
|
|
300
|
+
limit: { max: number; min: number },
|
|
301
|
+
current: number,
|
|
302
|
+
) => {
|
|
303
|
+
let value = current;
|
|
304
|
+
|
|
305
|
+
if (limit.min !== null && current < limit.min) {
|
|
306
|
+
value = limit.min;
|
|
307
|
+
} else if (limit.max !== null && limit.max < current) {
|
|
308
|
+
value = limit.max;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return value;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const rectCorrectionByLimit = (rect: {
|
|
315
|
+
newBottom: number;
|
|
316
|
+
newLeft: number;
|
|
317
|
+
newRight: number;
|
|
318
|
+
newTop: number;
|
|
319
|
+
}) => {
|
|
320
|
+
// const { limits } = this;
|
|
321
|
+
let { newRight, newLeft, newBottom, newTop } = rect;
|
|
322
|
+
|
|
323
|
+
type RectRange = {
|
|
324
|
+
max: number;
|
|
325
|
+
min: number;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
newLeft = sideCorrectionByLimit(limits.value.left as RectRange, newLeft);
|
|
329
|
+
newRight = sideCorrectionByLimit(limits.value.right as RectRange, newRight);
|
|
330
|
+
newTop = sideCorrectionByLimit(limits.value.top as RectRange, newTop);
|
|
331
|
+
newBottom = sideCorrectionByLimit(
|
|
332
|
+
limits.value.bottom as RectRange,
|
|
333
|
+
newBottom,
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
return {
|
|
337
|
+
newLeft,
|
|
338
|
+
newRight,
|
|
339
|
+
newTop,
|
|
340
|
+
newBottom,
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const rectCorrectionByAspectRatio = (rect: {
|
|
345
|
+
newBottom: number;
|
|
346
|
+
newLeft: number;
|
|
347
|
+
newRight: number;
|
|
348
|
+
newTop: number;
|
|
349
|
+
}) => {
|
|
350
|
+
let { newLeft, newRight, newTop, newBottom } = rect;
|
|
351
|
+
// const { parentWidth, parentHeight, currentStick, aspectFactor, dimensionsBeforeMove } = this;
|
|
352
|
+
|
|
353
|
+
let newWidth = parentWidth.value! - newLeft - newRight;
|
|
354
|
+
let newHeight = parentHeight.value! - newTop - newBottom;
|
|
355
|
+
|
|
356
|
+
if (currentStick.value![1] === 'm') {
|
|
357
|
+
const deltaHeight = newHeight - dimensionsBeforeMove.value.height;
|
|
358
|
+
|
|
359
|
+
newLeft -= (deltaHeight * aspectFactor.value!) / 2;
|
|
360
|
+
newRight -= (deltaHeight * aspectFactor.value!) / 2;
|
|
361
|
+
} else if (currentStick.value![0] === 'm') {
|
|
362
|
+
const deltaWidth = newWidth - dimensionsBeforeMove.value.width;
|
|
363
|
+
|
|
364
|
+
newTop -= deltaWidth / aspectFactor.value! / 2;
|
|
365
|
+
newBottom -= deltaWidth / aspectFactor.value! / 2;
|
|
366
|
+
} else if (newWidth / newHeight > aspectFactor.value!) {
|
|
367
|
+
newWidth = aspectFactor.value! * newHeight;
|
|
368
|
+
|
|
369
|
+
if (currentStick.value![1] === 'l') {
|
|
370
|
+
newLeft = parentWidth.value! - newRight - newWidth;
|
|
371
|
+
} else {
|
|
372
|
+
newRight = parentWidth.value! - newLeft - newWidth;
|
|
373
|
+
}
|
|
374
|
+
} else {
|
|
375
|
+
newHeight = newWidth / aspectFactor.value!;
|
|
376
|
+
|
|
377
|
+
if (currentStick.value![0] === 't') {
|
|
378
|
+
newTop = parentHeight.value! - newBottom - newHeight;
|
|
379
|
+
} else {
|
|
380
|
+
newBottom = parentHeight.value! - newTop - newHeight;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return { newLeft, newRight, newTop, newBottom };
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const stickMove = (delta: { x: number; y: number }) => {
|
|
388
|
+
let newTop = dimensionsBeforeMove.value.top;
|
|
389
|
+
let newBottom = dimensionsBeforeMove.value.bottom;
|
|
390
|
+
let newLeft = dimensionsBeforeMove.value.left;
|
|
391
|
+
let newRight = dimensionsBeforeMove.value.right;
|
|
392
|
+
switch (currentStick.value![0]) {
|
|
393
|
+
case 'b': {
|
|
394
|
+
newBottom = dimensionsBeforeMove.value.bottom + delta.y;
|
|
395
|
+
|
|
396
|
+
if (snapToGrid.value) {
|
|
397
|
+
newBottom =
|
|
398
|
+
(parentHeight.value as number) -
|
|
399
|
+
Math.round(
|
|
400
|
+
((parentHeight.value as number) - newBottom) / gridY.value,
|
|
401
|
+
) *
|
|
402
|
+
gridY.value;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
case 't': {
|
|
409
|
+
newTop = dimensionsBeforeMove.value.top - delta.y;
|
|
410
|
+
|
|
411
|
+
if (snapToGrid.value) {
|
|
412
|
+
newTop = Math.round(newTop / gridY.value) * gridY.value;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
default: {
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
switch (currentStick.value![1]) {
|
|
423
|
+
case 'l': {
|
|
424
|
+
newLeft = dimensionsBeforeMove.value.left - delta.x;
|
|
425
|
+
|
|
426
|
+
if (snapToGrid.value) {
|
|
427
|
+
newLeft = Math.round(newLeft / gridX.value) * gridX.value;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
case 'r': {
|
|
434
|
+
newRight = dimensionsBeforeMove.value.right + delta.x;
|
|
435
|
+
|
|
436
|
+
if (snapToGrid.value) {
|
|
437
|
+
newRight =
|
|
438
|
+
(parentWidth.value as number) -
|
|
439
|
+
Math.round(((parentWidth.value as number) - newRight) / gridX.value) *
|
|
440
|
+
gridX.value;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
default: {
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
({ newLeft, newRight, newTop, newBottom } = rectCorrectionByLimit({
|
|
451
|
+
newLeft,
|
|
452
|
+
newRight,
|
|
453
|
+
newTop,
|
|
454
|
+
newBottom,
|
|
455
|
+
}));
|
|
456
|
+
|
|
457
|
+
if (aspectRatio.value) {
|
|
458
|
+
({ newLeft, newRight, newTop, newBottom } = rectCorrectionByAspectRatio({
|
|
459
|
+
newLeft,
|
|
460
|
+
newRight,
|
|
461
|
+
newTop,
|
|
462
|
+
newBottom,
|
|
463
|
+
}));
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
left.value = newLeft;
|
|
467
|
+
right.value = newRight;
|
|
468
|
+
top.value = newTop;
|
|
469
|
+
bottom.value = newBottom;
|
|
470
|
+
|
|
471
|
+
emit('resizing', rect.value);
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
const stickUp = () => {
|
|
475
|
+
stickDrag.value = false;
|
|
476
|
+
// dimensionsBeforeMove.value = {
|
|
477
|
+
// pointerX: 0,
|
|
478
|
+
// pointerY: 0,
|
|
479
|
+
// x: 0,
|
|
480
|
+
// y: 0,
|
|
481
|
+
// w: 0,
|
|
482
|
+
// h: 0,
|
|
483
|
+
// };
|
|
484
|
+
|
|
485
|
+
Object.assign(dimensionsBeforeMove.value, {
|
|
486
|
+
pointerX: 0,
|
|
487
|
+
pointerY: 0,
|
|
488
|
+
x: 0,
|
|
489
|
+
y: 0,
|
|
490
|
+
w: 0,
|
|
491
|
+
h: 0,
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
limits.value = {
|
|
495
|
+
left: { min: null, max: null },
|
|
496
|
+
right: { min: null, max: null },
|
|
497
|
+
top: { min: null, max: null },
|
|
498
|
+
bottom: { min: null, max: null },
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
emit('resizing', rect.value);
|
|
502
|
+
emit('resizestop', rect.value);
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
const calcDragLimitation = () => {
|
|
506
|
+
return {
|
|
507
|
+
left: { min: 0, max: (parentWidth.value as number) - width.value },
|
|
508
|
+
right: { min: 0, max: (parentWidth.value as number) - width.value },
|
|
509
|
+
top: { min: 0, max: (parentHeight.value as number) - height.value },
|
|
510
|
+
bottom: { min: 0, max: (parentHeight.value as number) - height.value },
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
const calcResizeLimits = () => {
|
|
515
|
+
// const { aspectFactor, width, height, bottom, top, left, right } = this;
|
|
516
|
+
|
|
517
|
+
const parentLim = parentLimitation.value ? 0 : null;
|
|
518
|
+
|
|
519
|
+
if (aspectRatio.value) {
|
|
520
|
+
if (minw.value / minh.value > (aspectFactor.value as number)) {
|
|
521
|
+
minh.value = minw.value / (aspectFactor.value as number);
|
|
522
|
+
} else {
|
|
523
|
+
minw.value = ((aspectFactor.value as number) * minh.value) as number;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const limits = {
|
|
528
|
+
left: {
|
|
529
|
+
min: parentLim,
|
|
530
|
+
max: (left.value as number) + (width.value - minw.value),
|
|
531
|
+
},
|
|
532
|
+
right: {
|
|
533
|
+
min: parentLim,
|
|
534
|
+
max: (right.value as number) + (width.value - minw.value),
|
|
535
|
+
},
|
|
536
|
+
top: {
|
|
537
|
+
min: parentLim,
|
|
538
|
+
max: (top.value as number) + (height.value - minh.value),
|
|
539
|
+
},
|
|
540
|
+
bottom: {
|
|
541
|
+
min: parentLim,
|
|
542
|
+
max: (bottom.value as number) + (height.value - minh.value),
|
|
543
|
+
},
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
if (aspectRatio.value) {
|
|
547
|
+
const aspectLimits = {
|
|
548
|
+
left: {
|
|
549
|
+
min:
|
|
550
|
+
left.value! -
|
|
551
|
+
Math.min(top.value!, bottom.value!) * aspectFactor.value! * 2,
|
|
552
|
+
max:
|
|
553
|
+
left.value! +
|
|
554
|
+
((height.value - minh.value!) / 2) * aspectFactor.value! * 2,
|
|
555
|
+
},
|
|
556
|
+
right: {
|
|
557
|
+
min:
|
|
558
|
+
right.value! -
|
|
559
|
+
Math.min(top.value!, bottom.value!) * aspectFactor.value! * 2,
|
|
560
|
+
max:
|
|
561
|
+
right.value! +
|
|
562
|
+
((height.value - minh.value!) / 2) * aspectFactor.value! * 2,
|
|
563
|
+
},
|
|
564
|
+
top: {
|
|
565
|
+
min:
|
|
566
|
+
top.value! -
|
|
567
|
+
(Math.min(left.value!, right.value!) / aspectFactor.value!) * 2,
|
|
568
|
+
max:
|
|
569
|
+
top.value! +
|
|
570
|
+
((width.value - minw.value) / 2 / aspectFactor.value!) * 2,
|
|
571
|
+
},
|
|
572
|
+
bottom: {
|
|
573
|
+
min:
|
|
574
|
+
bottom.value! -
|
|
575
|
+
(Math.min(left.value!, right.value!) / aspectFactor.value!) * 2,
|
|
576
|
+
max:
|
|
577
|
+
bottom.value! +
|
|
578
|
+
((width.value - minw.value) / 2 / aspectFactor.value!) * 2,
|
|
579
|
+
},
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
if (currentStick.value![0] === 'm') {
|
|
583
|
+
limits.left = {
|
|
584
|
+
min: Math.max(limits.left.min!, aspectLimits.left.min),
|
|
585
|
+
max: Math.min(limits.left.max, aspectLimits.left.max),
|
|
586
|
+
};
|
|
587
|
+
limits.right = {
|
|
588
|
+
min: Math.max(limits.right.min!, aspectLimits.right.min),
|
|
589
|
+
max: Math.min(limits.right.max, aspectLimits.right.max),
|
|
590
|
+
};
|
|
591
|
+
} else if (currentStick.value![1] === 'm') {
|
|
592
|
+
limits.top = {
|
|
593
|
+
min: Math.max(limits.top.min!, aspectLimits.top.min),
|
|
594
|
+
max: Math.min(limits.top.max, aspectLimits.top.max),
|
|
595
|
+
};
|
|
596
|
+
limits.bottom = {
|
|
597
|
+
min: Math.max(limits.bottom.min!, aspectLimits.bottom.min),
|
|
598
|
+
max: Math.min(limits.bottom.max, aspectLimits.bottom.max),
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
return limits;
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
const positionStyle = computed(() => ({
|
|
607
|
+
top: `${top.value}px`,
|
|
608
|
+
left: `${left.value}px`,
|
|
609
|
+
zIndex: zIndex.value!,
|
|
610
|
+
}));
|
|
611
|
+
|
|
612
|
+
const sizeStyle = computed(() => ({
|
|
613
|
+
width: w.value === 'auto' ? 'auto' : `${width.value}px`,
|
|
614
|
+
height: h.value === 'auto' ? 'auto' : `${height.value}px`,
|
|
615
|
+
}));
|
|
616
|
+
|
|
617
|
+
const stickStyles = computed(() => (stick: string) => {
|
|
618
|
+
const stickStyle = {
|
|
619
|
+
width: `${stickSize.value / parentScaleX.value}px`,
|
|
620
|
+
height: `${stickSize.value / parentScaleY.value}px`,
|
|
621
|
+
};
|
|
622
|
+
stickStyle[
|
|
623
|
+
styleMapping.y[stick[0] as 'b' | 'm' | 't'] as 'height' | 'width'
|
|
624
|
+
] = `${stickSize.value / parentScaleX.value / -2}px`;
|
|
625
|
+
stickStyle[
|
|
626
|
+
styleMapping.x[stick[1] as 'l' | 'm' | 'r'] as 'height' | 'width'
|
|
627
|
+
] = `${stickSize.value / parentScaleX.value / -2}px`;
|
|
628
|
+
return stickStyle;
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
const bodyMove = (delta: { x: number; y: number }) => {
|
|
632
|
+
let newTop = dimensionsBeforeMove.value.top - delta.y;
|
|
633
|
+
let newBottom = dimensionsBeforeMove.value.bottom + delta.y;
|
|
634
|
+
let newLeft = dimensionsBeforeMove.value.left - delta.x;
|
|
635
|
+
let newRight = dimensionsBeforeMove.value.right + delta.x;
|
|
636
|
+
|
|
637
|
+
if (snapToGrid.value) {
|
|
638
|
+
let alignTop = true;
|
|
639
|
+
let alignLeft = true;
|
|
640
|
+
|
|
641
|
+
let diffT = newTop - Math.floor(newTop / gridY.value) * gridY.value;
|
|
642
|
+
let diffB =
|
|
643
|
+
(parentHeight.value as number) -
|
|
644
|
+
newBottom -
|
|
645
|
+
Math.floor(((parentHeight.value as number) - newBottom) / gridY.value) *
|
|
646
|
+
gridY.value;
|
|
647
|
+
let diffL = newLeft - Math.floor(newLeft / gridX.value) * gridX.value;
|
|
648
|
+
let diffR =
|
|
649
|
+
(parentWidth.value as number) -
|
|
650
|
+
newRight -
|
|
651
|
+
Math.floor(((parentWidth.value as number) - newRight) / gridX.value) *
|
|
652
|
+
gridX.value;
|
|
653
|
+
|
|
654
|
+
if (diffT > gridY.value / 2) {
|
|
655
|
+
diffT -= gridY.value;
|
|
656
|
+
}
|
|
657
|
+
if (diffB > gridY.value / 2) {
|
|
658
|
+
diffB -= gridY.value;
|
|
659
|
+
}
|
|
660
|
+
if (diffL > gridX.value / 2) {
|
|
661
|
+
diffL -= gridX.value;
|
|
662
|
+
}
|
|
663
|
+
if (diffR > gridX.value / 2) {
|
|
664
|
+
diffR -= gridX.value;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if (Math.abs(diffB) < Math.abs(diffT)) {
|
|
668
|
+
alignTop = false;
|
|
669
|
+
}
|
|
670
|
+
if (Math.abs(diffR) < Math.abs(diffL)) {
|
|
671
|
+
alignLeft = false;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
newTop -= alignTop ? diffT : diffB;
|
|
675
|
+
newBottom = (parentHeight.value as number) - height.value - newTop;
|
|
676
|
+
newLeft -= alignLeft ? diffL : diffR;
|
|
677
|
+
newRight = (parentWidth.value as number) - width.value - newLeft;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
({
|
|
681
|
+
newLeft: left.value,
|
|
682
|
+
newRight: right.value,
|
|
683
|
+
newTop: top.value,
|
|
684
|
+
newBottom: bottom.value,
|
|
685
|
+
} = rectCorrectionByLimit({ newLeft, newRight, newTop, newBottom }));
|
|
686
|
+
|
|
687
|
+
emit('dragging', rect.value);
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
const bodyUp = () => {
|
|
691
|
+
bodyDrag.value = false;
|
|
692
|
+
emit('dragging', rect.value);
|
|
693
|
+
emit('dragstop', rect.value);
|
|
694
|
+
|
|
695
|
+
// dimensionsBeforeMove.value = { pointerX: 0, pointerY: 0, x: 0, y: 0, w: 0, h: 0 };
|
|
696
|
+
Object.assign(dimensionsBeforeMove.value, {
|
|
697
|
+
pointerX: 0,
|
|
698
|
+
pointerY: 0,
|
|
699
|
+
x: 0,
|
|
700
|
+
y: 0,
|
|
701
|
+
w: 0,
|
|
702
|
+
h: 0,
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
limits.value = {
|
|
706
|
+
left: { min: null, max: null },
|
|
707
|
+
right: { min: null, max: null },
|
|
708
|
+
top: { min: null, max: null },
|
|
709
|
+
bottom: { min: null, max: null },
|
|
710
|
+
};
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
const stickDown = (
|
|
714
|
+
stick: string,
|
|
715
|
+
ev: { pageX: any; pageY: any; touches?: any },
|
|
716
|
+
force = false,
|
|
717
|
+
) => {
|
|
718
|
+
if ((!isResizable.value || !active.value) && !force) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
stickDrag.value = true;
|
|
723
|
+
|
|
724
|
+
const pointerX = ev.pageX === undefined ? ev.touches[0].pageX : ev.pageX;
|
|
725
|
+
const pointerY = ev.pageY === undefined ? ev.touches[0].pageY : ev.pageY;
|
|
726
|
+
|
|
727
|
+
saveDimensionsBeforeMove({ pointerX, pointerY });
|
|
728
|
+
|
|
729
|
+
currentStick.value = stick;
|
|
730
|
+
|
|
731
|
+
limits.value = calcResizeLimits();
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
const move = (ev: MouseEvent & TouchEvent) => {
|
|
735
|
+
if (!stickDrag.value && !bodyDrag.value) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
ev.stopPropagation();
|
|
740
|
+
|
|
741
|
+
// touches 兼容性代码
|
|
742
|
+
const pageX = ev.pageX === undefined ? ev.touches![0]!.pageX : ev.pageX;
|
|
743
|
+
const pageY = ev.pageY === undefined ? ev.touches![0]!.pageY : ev.pageY;
|
|
744
|
+
|
|
745
|
+
const delta = {
|
|
746
|
+
x: (dimensionsBeforeMove.value.pointerX - pageX) / parentScaleX.value,
|
|
747
|
+
y: (dimensionsBeforeMove.value.pointerY - pageY) / parentScaleY.value,
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
if (stickDrag.value) {
|
|
751
|
+
stickMove(delta);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
if (bodyDrag.value) {
|
|
755
|
+
switch (axis.value) {
|
|
756
|
+
case 'none': {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
case 'x': {
|
|
760
|
+
delta.y = 0;
|
|
761
|
+
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
case 'y': {
|
|
765
|
+
delta.x = 0;
|
|
766
|
+
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
// No default
|
|
770
|
+
}
|
|
771
|
+
bodyMove(delta);
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
const up = () => {
|
|
776
|
+
if (stickDrag.value) {
|
|
777
|
+
stickUp();
|
|
778
|
+
} else if (bodyDrag.value) {
|
|
779
|
+
bodyUp();
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
const deselect = () => {
|
|
784
|
+
if (preventActiveBehavior.value) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
active.value = false;
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
const domEvents = ref(
|
|
791
|
+
new Map([
|
|
792
|
+
['mousedown', deselect],
|
|
793
|
+
['mouseleave', up],
|
|
794
|
+
['mousemove', move],
|
|
795
|
+
['mouseup', up],
|
|
796
|
+
['touchcancel', up],
|
|
797
|
+
['touchend', up],
|
|
798
|
+
['touchmove', move],
|
|
799
|
+
['touchstart', up],
|
|
800
|
+
]),
|
|
801
|
+
);
|
|
802
|
+
|
|
803
|
+
const container = ref<HTMLDivElement>();
|
|
804
|
+
|
|
805
|
+
onMounted(() => {
|
|
806
|
+
const currentInstance = getCurrentInstance();
|
|
807
|
+
const $el = currentInstance?.vnode.el as HTMLElement;
|
|
808
|
+
|
|
809
|
+
parentElement.value = $el?.parentNode as HTMLElement;
|
|
810
|
+
parentWidth.value = parentW.value ?? parentElement.value?.clientWidth;
|
|
811
|
+
parentHeight.value = parentH.value ?? parentElement.value?.clientHeight;
|
|
812
|
+
|
|
813
|
+
left.value = x.value;
|
|
814
|
+
top.value = y.value;
|
|
815
|
+
right.value = (parentWidth.value -
|
|
816
|
+
(w.value === 'auto' ? container.value!.scrollWidth : (w.value as number)) -
|
|
817
|
+
left.value) as number;
|
|
818
|
+
bottom.value = (parentHeight.value -
|
|
819
|
+
(h.value === 'auto' ? container.value!.scrollHeight : (h.value as number)) -
|
|
820
|
+
top.value) as number;
|
|
821
|
+
|
|
822
|
+
addEvents(domEvents.value);
|
|
823
|
+
|
|
824
|
+
if (dragHandle.value) {
|
|
825
|
+
[...($el?.querySelectorAll(dragHandle.value) || [])].forEach(
|
|
826
|
+
(dragHandle) => {
|
|
827
|
+
(dragHandle as HTMLElement).dataset.dragHandle = String(
|
|
828
|
+
currentInstance?.uid,
|
|
829
|
+
);
|
|
830
|
+
},
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
if (dragCancel.value) {
|
|
835
|
+
[...($el?.querySelectorAll(dragCancel.value) || [])].forEach(
|
|
836
|
+
(cancelHandle) => {
|
|
837
|
+
(cancelHandle as HTMLElement).dataset.dragCancel = String(
|
|
838
|
+
currentInstance?.uid,
|
|
839
|
+
);
|
|
840
|
+
},
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
onBeforeUnmount(() => {
|
|
846
|
+
removeEvents(domEvents.value);
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
const bodyDown = (ev: MouseEvent & TouchEvent) => {
|
|
850
|
+
const { target, button } = ev;
|
|
851
|
+
|
|
852
|
+
if (!preventActiveBehavior.value) {
|
|
853
|
+
active.value = true;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
if (button && button !== 0) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
emit('clicked', ev);
|
|
861
|
+
|
|
862
|
+
if (!active.value) {
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
if (
|
|
867
|
+
dragHandle.value &&
|
|
868
|
+
(target! as HTMLElement).dataset.dragHandle !==
|
|
869
|
+
getCurrentInstance()?.uid.toString()
|
|
870
|
+
) {
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
if (
|
|
875
|
+
dragCancel.value &&
|
|
876
|
+
(target! as HTMLElement).dataset.dragCancel ===
|
|
877
|
+
getCurrentInstance()?.uid.toString()
|
|
878
|
+
) {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
if (ev.stopPropagation !== undefined) {
|
|
883
|
+
ev.stopPropagation();
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
if (ev.preventDefault !== undefined) {
|
|
887
|
+
ev.preventDefault();
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
if (isDraggable.value) {
|
|
891
|
+
bodyDrag.value = true;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
const pointerX = ev.pageX === undefined ? ev.touches[0]!.pageX : ev.pageX;
|
|
895
|
+
const pointerY = ev.pageY === undefined ? ev.touches[0]!.pageY : ev.pageY;
|
|
896
|
+
|
|
897
|
+
saveDimensionsBeforeMove({ pointerX, pointerY });
|
|
898
|
+
|
|
899
|
+
if (parentLimitation.value) {
|
|
900
|
+
limits.value = calcDragLimitation();
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
watch(
|
|
905
|
+
() => active.value,
|
|
906
|
+
(isActive) => {
|
|
907
|
+
if (isActive) {
|
|
908
|
+
emit('activated');
|
|
909
|
+
} else {
|
|
910
|
+
emit('deactivated');
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
);
|
|
914
|
+
|
|
915
|
+
watch(
|
|
916
|
+
() => isActive.value,
|
|
917
|
+
(val) => {
|
|
918
|
+
active.value = val;
|
|
919
|
+
},
|
|
920
|
+
{ immediate: true },
|
|
921
|
+
);
|
|
922
|
+
|
|
923
|
+
watch(
|
|
924
|
+
() => z.value,
|
|
925
|
+
(val) => {
|
|
926
|
+
if ((val as number) >= 0 || val === 'auto') {
|
|
927
|
+
zIndex.value = val as number;
|
|
928
|
+
}
|
|
929
|
+
},
|
|
930
|
+
{ immediate: true },
|
|
931
|
+
);
|
|
932
|
+
|
|
933
|
+
watch(
|
|
934
|
+
() => x.value,
|
|
935
|
+
(newVal, oldVal) => {
|
|
936
|
+
if (stickDrag.value || bodyDrag.value || newVal === left.value) {
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
const delta = oldVal - newVal;
|
|
941
|
+
|
|
942
|
+
bodyDown({ pageX: left.value!, pageY: top.value! } as MouseEvent &
|
|
943
|
+
TouchEvent);
|
|
944
|
+
bodyMove({ x: delta, y: 0 });
|
|
945
|
+
|
|
946
|
+
nextTick(() => {
|
|
947
|
+
bodyUp();
|
|
948
|
+
});
|
|
949
|
+
},
|
|
950
|
+
);
|
|
951
|
+
|
|
952
|
+
watch(
|
|
953
|
+
() => y.value,
|
|
954
|
+
(newVal, oldVal) => {
|
|
955
|
+
if (stickDrag.value || bodyDrag.value || newVal === top.value) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
const delta = oldVal - newVal;
|
|
960
|
+
|
|
961
|
+
bodyDown({ pageX: left.value, pageY: top.value } as MouseEvent &
|
|
962
|
+
TouchEvent);
|
|
963
|
+
bodyMove({ x: 0, y: delta });
|
|
964
|
+
|
|
965
|
+
nextTick(() => {
|
|
966
|
+
bodyUp();
|
|
967
|
+
});
|
|
968
|
+
},
|
|
969
|
+
);
|
|
970
|
+
|
|
971
|
+
watch(
|
|
972
|
+
() => w.value,
|
|
973
|
+
(newVal, oldVal) => {
|
|
974
|
+
if (stickDrag.value || bodyDrag.value || newVal === width.value) {
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
const stick = 'mr';
|
|
979
|
+
const delta = (oldVal as number) - (newVal as number);
|
|
980
|
+
|
|
981
|
+
stickDown(
|
|
982
|
+
stick,
|
|
983
|
+
{ pageX: right.value, pageY: top.value! + height.value / 2 },
|
|
984
|
+
true,
|
|
985
|
+
);
|
|
986
|
+
stickMove({ x: delta, y: 0 });
|
|
987
|
+
|
|
988
|
+
nextTick(() => {
|
|
989
|
+
stickUp();
|
|
990
|
+
});
|
|
991
|
+
},
|
|
992
|
+
);
|
|
993
|
+
|
|
994
|
+
watch(
|
|
995
|
+
() => h.value,
|
|
996
|
+
(newVal, oldVal) => {
|
|
997
|
+
if (stickDrag.value || bodyDrag.value || newVal === height.value) {
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
const stick = 'bm';
|
|
1002
|
+
const delta = (oldVal as number) - (newVal as number);
|
|
1003
|
+
|
|
1004
|
+
stickDown(
|
|
1005
|
+
stick,
|
|
1006
|
+
{ pageX: left.value! + width.value / 2, pageY: bottom.value },
|
|
1007
|
+
true,
|
|
1008
|
+
);
|
|
1009
|
+
stickMove({ x: 0, y: delta });
|
|
1010
|
+
|
|
1011
|
+
nextTick(() => {
|
|
1012
|
+
stickUp();
|
|
1013
|
+
});
|
|
1014
|
+
},
|
|
1015
|
+
);
|
|
1016
|
+
|
|
1017
|
+
watch(
|
|
1018
|
+
() => parentW.value,
|
|
1019
|
+
(val) => {
|
|
1020
|
+
right.value = val - width.value - left.value!;
|
|
1021
|
+
parentWidth.value = val;
|
|
1022
|
+
},
|
|
1023
|
+
);
|
|
1024
|
+
|
|
1025
|
+
watch(
|
|
1026
|
+
() => parentH.value,
|
|
1027
|
+
(val) => {
|
|
1028
|
+
bottom.value = val - height.value - top.value!;
|
|
1029
|
+
parentHeight.value = val;
|
|
1030
|
+
},
|
|
1031
|
+
);
|
|
1032
|
+
</script>
|
|
1033
|
+
|
|
1034
|
+
<template>
|
|
1035
|
+
<div
|
|
1036
|
+
:class="`${active || isActive ? 'active' : 'inactive'} ${contentClass ? contentClass : ''}`"
|
|
1037
|
+
:style="positionStyle"
|
|
1038
|
+
class="resize"
|
|
1039
|
+
@mousedown="bodyDown($event as TouchEvent & MouseEvent)"
|
|
1040
|
+
@touchend="up"
|
|
1041
|
+
@touchstart="bodyDown($event as TouchEvent & MouseEvent)"
|
|
1042
|
+
>
|
|
1043
|
+
<div ref="container" :style="sizeStyle" class="content-container">
|
|
1044
|
+
<slot></slot>
|
|
1045
|
+
</div>
|
|
1046
|
+
<div
|
|
1047
|
+
v-for="(stick, index) of sticks"
|
|
1048
|
+
:key="index"
|
|
1049
|
+
:class="[`resize-stick-${stick}`, isResizable ? '' : 'not-resizable']"
|
|
1050
|
+
:style="stickStyles(stick)"
|
|
1051
|
+
class="resize-stick"
|
|
1052
|
+
@mousedown.stop.prevent="
|
|
1053
|
+
stickDown(stick, $event as TouchEvent & MouseEvent)
|
|
1054
|
+
"
|
|
1055
|
+
@touchstart.stop.prevent="
|
|
1056
|
+
stickDown(stick, $event as TouchEvent & MouseEvent)
|
|
1057
|
+
"
|
|
1058
|
+
></div>
|
|
1059
|
+
</div>
|
|
1060
|
+
</template>
|
|
1061
|
+
|
|
1062
|
+
<style lang="css" scoped>
|
|
1063
|
+
.resize {
|
|
1064
|
+
position: absolute;
|
|
1065
|
+
box-sizing: border-box;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
.resize.active::before {
|
|
1069
|
+
position: absolute;
|
|
1070
|
+
top: 0;
|
|
1071
|
+
left: 0;
|
|
1072
|
+
box-sizing: border-box;
|
|
1073
|
+
width: 100%;
|
|
1074
|
+
height: 100%;
|
|
1075
|
+
content: '';
|
|
1076
|
+
outline: 1px dashed #d6d6d6;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
.resize-stick {
|
|
1080
|
+
position: absolute;
|
|
1081
|
+
box-sizing: border-box;
|
|
1082
|
+
font-size: 1px;
|
|
1083
|
+
background: #fff;
|
|
1084
|
+
border: 1px solid #6c6c6c;
|
|
1085
|
+
box-shadow: 0 0 2px #bbb;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
.inactive .resize-stick {
|
|
1089
|
+
display: none;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
.resize-stick-tl,
|
|
1093
|
+
.resize-stick-br {
|
|
1094
|
+
cursor: nwse-resize;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
.resize-stick-tm,
|
|
1098
|
+
.resize-stick-bm {
|
|
1099
|
+
left: 50%;
|
|
1100
|
+
cursor: ns-resize;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.resize-stick-tr,
|
|
1104
|
+
.resize-stick-bl {
|
|
1105
|
+
cursor: nesw-resize;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
.resize-stick-ml,
|
|
1109
|
+
.resize-stick-mr {
|
|
1110
|
+
top: 50%;
|
|
1111
|
+
cursor: ew-resize;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
.resize-stick.not-resizable {
|
|
1115
|
+
display: none;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
.content-container {
|
|
1119
|
+
position: relative;
|
|
1120
|
+
display: block;
|
|
1121
|
+
}
|
|
1122
|
+
</style>
|