vft 0.0.1
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/package.json +54 -0
- package/src/app/index.ts +3 -0
- package/src/app/page-loading/assets/spin.gif +0 -0
- package/src/app/page-loading/index.less +10 -0
- package/src/app/page-loading/index.ts +3 -0
- package/src/app/page-loading/index.vue +38 -0
- package/src/app/table/assets/sort_triangle.png +0 -0
- package/src/app/table/demos/basic.vue +117 -0
- package/src/app/table/demos/complex.vue +2543 -0
- package/src/app/table/demos/index.vue +453 -0
- package/src/app/table/demos/rightAngle.png +0 -0
- package/src/app/table/header.vue +203 -0
- package/src/app/table/index.less +119 -0
- package/src/app/table/index.ts +5 -0
- package/src/app/table/index.vue +478 -0
- package/src/app/table/md/api.md +23 -0
- package/src/app/table/md/demo.md +3 -0
- package/src/app/table/types.ts +45 -0
- package/src/common/badge/index.scss +78 -0
- package/src/common/badge/index.ts +4 -0
- package/src/common/badge/index.vue +111 -0
- package/src/common/badge/types.ts +1 -0
- package/src/common/clamp/clamp-toggle.vue +91 -0
- package/src/common/clamp/index.ts +4 -0
- package/src/common/clamp/index.vue +247 -0
- package/src/common/code/index.less +321 -0
- package/src/common/code/index.ts +3 -0
- package/src/common/code/index.vue +60 -0
- package/src/common/config-provider/index.ts +4 -0
- package/src/common/config-provider/index.vue +94 -0
- package/src/common/config-provider/types.ts +29 -0
- package/src/common/icon/iconfont/iconfont.css +334 -0
- package/src/common/icon/index.scss +31 -0
- package/src/common/icon/index.ts +4 -0
- package/src/common/icon/index.vue +74 -0
- package/src/common/icon/types.ts +16 -0
- package/src/common/index.ts +6 -0
- package/src/common/message/index.ts +5 -0
- package/src/common/message/instance.ts +29 -0
- package/src/common/message/message.scss +108 -0
- package/src/common/message/message.ts +80 -0
- package/src/common/message/message.vue +162 -0
- package/src/common/message/method.ts +172 -0
- package/src/common/overlay/index.scss +14 -0
- package/src/common/overlay/index.ts +3 -0
- package/src/common/overlay/index.vue +117 -0
- package/src/constants/comp.ts +1 -0
- package/src/constants/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/page/index.ts +1 -0
- package/src/page/page-wrapper/index.scss +31 -0
- package/src/page/page-wrapper/index.ts +5 -0
- package/src/page/page-wrapper/index.vue +31 -0
- package/src/styles/vars.scss +500 -0
- package/src/use/index.ts +14 -0
- package/src/use/onPopupReopen.ts +15 -0
- package/src/use/use-delayed-toggle/index.ts +30 -0
- package/src/use/use-floating/index.ts +121 -0
- package/src/use/use-forward-ref.ts +35 -0
- package/src/use/use-global-config/index.ts +81 -0
- package/src/use/use-id/index.ts +43 -0
- package/src/use/use-model-toggle/index.ts +151 -0
- package/src/use/use-namespace/index.ts +91 -0
- package/src/use/use-ordered-children/index.ts +43 -0
- package/src/use/use-popper-container/index.ts +43 -0
- package/src/use/use-timeout/index.ts +18 -0
- package/src/use/use-z-index/index.ts +20 -0
- package/src/use/useGlobalZIndex.ts +24 -0
- package/src/use/useLazyRender.ts +17 -0
- package/src/use/useLockScroll.ts +66 -0
- package/src/utils/aria.ts +126 -0
- package/src/utils/arrays.ts +13 -0
- package/src/utils/error.ts +23 -0
- package/src/utils/event.ts +15 -0
- package/src/utils/helper.ts +7 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/interceptor.ts +39 -0
- package/src/utils/mount-component.ts +65 -0
- package/src/utils/popper.ts +6 -0
- package/src/utils/rand.ts +12 -0
- package/src/utils/scroll.ts +101 -0
- package/src/utils/vnode.ts +169 -0
- package/src/web/avatar/index.scss +50 -0
- package/src/web/avatar/index.ts +3 -0
- package/src/web/avatar/index.vue +83 -0
- package/src/web/back-top/index.scss +35 -0
- package/src/web/back-top/index.ts +3 -0
- package/src/web/back-top/index.vue +72 -0
- package/src/web/back-top/types.ts +14 -0
- package/src/web/back-top/use-back-top.ts +65 -0
- package/src/web/cascader/index.scss +214 -0
- package/src/web/cascader/index.ts +5 -0
- package/src/web/cascader/index.vue +767 -0
- package/src/web/cascader-panel/config.ts +44 -0
- package/src/web/cascader-panel/index.scss +134 -0
- package/src/web/cascader-panel/index.ts +5 -0
- package/src/web/cascader-panel/index.vue +319 -0
- package/src/web/cascader-panel/menu.vue +135 -0
- package/src/web/cascader-panel/node-content.ts +23 -0
- package/src/web/cascader-panel/node.ts +218 -0
- package/src/web/cascader-panel/node.vue +197 -0
- package/src/web/cascader-panel/store.ts +83 -0
- package/src/web/cascader-panel/types.ts +56 -0
- package/src/web/cascader-panel/utils.ts +40 -0
- package/src/web/cascader-select/README.md +31 -0
- package/src/web/cascader-select/index.scss +54 -0
- package/src/web/cascader-select/index.ts +5 -0
- package/src/web/cascader-select/index.vue +132 -0
- package/src/web/cascader-select/types.ts +9 -0
- package/src/web/context-menu/createContextMenu.ts +72 -0
- package/src/web/context-menu/index.ts +4 -0
- package/src/web/context-menu/index.vue +89 -0
- package/src/web/context-menu/types.ts +27 -0
- package/src/web/context-menu/useContextMenu.ts +14 -0
- package/src/web/descriptions/description-item.vue +34 -0
- package/src/web/descriptions/description.vue +124 -0
- package/src/web/descriptions/descriptions-cell.ts +95 -0
- package/src/web/descriptions/descriptions-item.scss +68 -0
- package/src/web/descriptions/descriptions-row.vue +49 -0
- package/src/web/descriptions/descriptions.scss +153 -0
- package/src/web/descriptions/descriptions.type.ts +19 -0
- package/src/web/descriptions/index.ts +4 -0
- package/src/web/descriptions/token.ts +4 -0
- package/src/web/divider/index.scss +53 -0
- package/src/web/divider/index.ts +5 -0
- package/src/web/divider/index.vue +60 -0
- package/src/web/divider/types.ts +2 -0
- package/src/web/empty/assets/no-collect.png +0 -0
- package/src/web/empty/assets/no-data.png +0 -0
- package/src/web/empty/assets/no-filter.png +0 -0
- package/src/web/empty/assets/no-page-data.png +0 -0
- package/src/web/empty/assets/no-search.png +0 -0
- package/src/web/empty/constants.ts +12 -0
- package/src/web/empty/index.scss +57 -0
- package/src/web/empty/index.ts +5 -0
- package/src/web/empty/index.vue +96 -0
- package/src/web/exception/exception.png +0 -0
- package/src/web/exception/index.ts +3 -0
- package/src/web/exception/index.vue +44 -0
- package/src/web/filter/README.md +25 -0
- package/src/web/filter/index.scss +14 -0
- package/src/web/filter/index.ts +5 -0
- package/src/web/filter/index.vue +60 -0
- package/src/web/filter/type.ts +13 -0
- package/src/web/focus-trap/index.ts +6 -0
- package/src/web/focus-trap/index.vue +328 -0
- package/src/web/focus-trap/tokens.ts +23 -0
- package/src/web/focus-trap/utils.ts +178 -0
- package/src/web/full-screen/index.scss +22 -0
- package/src/web/full-screen/index.ts +3 -0
- package/src/web/full-screen/index.vue +24 -0
- package/src/web/icon-text/index.ts +3 -0
- package/src/web/icon-text/index.vue +77 -0
- package/src/web/image/index.scss +46 -0
- package/src/web/image/index.ts +5 -0
- package/src/web/image/index.vue +251 -0
- package/src/web/image/types.ts +1 -0
- package/src/web/index.ts +33 -0
- package/src/web/input/index.scss +473 -0
- package/src/web/input/index.ts +3 -0
- package/src/web/input/index.vue +533 -0
- package/src/web/input/utils.ts +102 -0
- package/src/web/layouts/blank.vue +4 -0
- package/src/web/layouts/footer/index.scss +31 -0
- package/src/web/layouts/footer/index.ts +3 -0
- package/src/web/layouts/footer/index.vue +38 -0
- package/src/web/layouts/header/index.scss +35 -0
- package/src/web/layouts/header/index.ts +3 -0
- package/src/web/layouts/header/index.vue +47 -0
- package/src/web/layouts/iframe/index.scss +18 -0
- package/src/web/layouts/iframe/index.vue +36 -0
- package/src/web/layouts/iframe/page.vue +30 -0
- package/src/web/layouts/index.ts +8 -0
- package/src/web/layouts/router-view-content/index.vue +70 -0
- package/src/web/link/index.scss +95 -0
- package/src/web/link/index.ts +3 -0
- package/src/web/link/index.vue +68 -0
- package/src/web/loading/directive.ts +104 -0
- package/src/web/loading/index.ts +6 -0
- package/src/web/loading/loading.scss +108 -0
- package/src/web/loading/loading.ts +156 -0
- package/src/web/loading/service.ts +145 -0
- package/src/web/loading/types.ts +29 -0
- package/src/web/logo/index.scss +31 -0
- package/src/web/logo/index.ts +5 -0
- package/src/web/logo/index.vue +45 -0
- package/src/web/logo/types.ts +6 -0
- package/src/web/menu/index.scss +336 -0
- package/src/web/menu/index.ts +8 -0
- package/src/web/menu/menu-collapse-transition.vue +62 -0
- package/src/web/menu/menu-item-group.vue +27 -0
- package/src/web/menu/menu-item.vue +126 -0
- package/src/web/menu/menu.vue +459 -0
- package/src/web/menu/sub-menu.vue +440 -0
- package/src/web/menu/types.ts +66 -0
- package/src/web/menu/use-menu-css-var.ts +11 -0
- package/src/web/menu/use-menu.ts +60 -0
- package/src/web/menu/utils/menu-bar.ts +19 -0
- package/src/web/menu/utils/menu-item.ts +55 -0
- package/src/web/menu/utils/submenu.ts +66 -0
- package/src/web/multiple-select-flat/index.ts +5 -0
- package/src/web/multiple-select-flat/index.vue +53 -0
- package/src/web/multiple-select-flat/types.ts +5 -0
- package/src/web/multiple-tabs/index.scss +16 -0
- package/src/web/multiple-tabs/index.ts +5 -0
- package/src/web/multiple-tabs/index.vue +193 -0
- package/src/web/multiple-tabs/tab-content.vue +40 -0
- package/src/web/multiple-tabs/types.ts +3 -0
- package/src/web/multiple-tabs/use/index.ts +2 -0
- package/src/web/multiple-tabs/use/use-multiple-tabs.ts +86 -0
- package/src/web/multiple-tabs/use/use-tab-dropdown.ts +101 -0
- package/src/web/nodata/README.md +42 -0
- package/src/web/nodata/fail.vue +13 -0
- package/src/web/nodata/img/100.png +0 -0
- package/src/web/nodata/img/101.png +0 -0
- package/src/web/nodata/img/102.png +0 -0
- package/src/web/nodata/img/103.png +0 -0
- package/src/web/nodata/img/104.png +0 -0
- package/src/web/nodata/img/105.png +0 -0
- package/src/web/nodata/img/106.png +0 -0
- package/src/web/nodata/img/107.png +0 -0
- package/src/web/nodata/img/200.png +0 -0
- package/src/web/nodata/img/201.png +0 -0
- package/src/web/nodata/img/202.png +0 -0
- package/src/web/nodata/img/203.png +0 -0
- package/src/web/nodata/index.scss +37 -0
- package/src/web/nodata/index.ts +6 -0
- package/src/web/nodata/index.vue +46 -0
- package/src/web/nodata/types.ts +17 -0
- package/src/web/only-child/index.tsx +69 -0
- package/src/web/pagination/components/jumper.vue +49 -0
- package/src/web/pagination/components/next.vue +40 -0
- package/src/web/pagination/components/pager.vue +215 -0
- package/src/web/pagination/components/prev.vue +35 -0
- package/src/web/pagination/components/sizes.vue +76 -0
- package/src/web/pagination/components/total.vue +21 -0
- package/src/web/pagination/index.scss +231 -0
- package/src/web/pagination/index.ts +5 -0
- package/src/web/pagination/pagination.ts +363 -0
- package/src/web/pagination/usePagination.ts +13 -0
- package/src/web/popover/directive.ts +21 -0
- package/src/web/popover/index.scss +58 -0
- package/src/web/popover/index.ts +3 -0
- package/src/web/popover/index.vue +161 -0
- package/src/web/popover/types.ts +26 -0
- package/src/web/popper/arrow.vue +45 -0
- package/src/web/popper/content.vue +311 -0
- package/src/web/popper/index.scss +108 -0
- package/src/web/popper/index.ts +11 -0
- package/src/web/popper/popper.vue +57 -0
- package/src/web/popper/tokens.ts +28 -0
- package/src/web/popper/trigger.vue +166 -0
- package/src/web/popper/types.ts +49 -0
- package/src/web/popper/utils.ts +81 -0
- package/src/web/qrcode/drawCanvas.ts +32 -0
- package/src/web/qrcode/drawLogo.ts +82 -0
- package/src/web/qrcode/index.ts +5 -0
- package/src/web/qrcode/index.vue +107 -0
- package/src/web/qrcode/qrcodePlus.ts +4 -0
- package/src/web/qrcode/toCanvas.ts +11 -0
- package/src/web/qrcode/types.ts +38 -0
- package/src/web/result/index.scss +69 -0
- package/src/web/result/index.ts +3 -0
- package/src/web/result/index.vue +63 -0
- package/src/web/scrollbar/bar.vue +48 -0
- package/src/web/scrollbar/index.scss +91 -0
- package/src/web/scrollbar/index.ts +5 -0
- package/src/web/scrollbar/index.vue +236 -0
- package/src/web/scrollbar/thumb.vue +183 -0
- package/src/web/scrollbar/tokens.ts +10 -0
- package/src/web/scrollbar/types.ts +7 -0
- package/src/web/scrollbar/util.ts +38 -0
- package/src/web/select/constants.ts +13 -0
- package/src/web/select/index.ts +11 -0
- package/src/web/select/index.vue +555 -0
- package/src/web/select/option-group.scss +49 -0
- package/src/web/select/option-group.vue +97 -0
- package/src/web/select/option-item.scss +66 -0
- package/src/web/select/option.scss +32 -0
- package/src/web/select/option.vue +110 -0
- package/src/web/select/select-dropdown.scss +86 -0
- package/src/web/select/select-dropdown.vue +51 -0
- package/src/web/select/select.scss +213 -0
- package/src/web/select/token.ts +56 -0
- package/src/web/select/useOption.ts +146 -0
- package/src/web/select/useSelect.ts +942 -0
- package/src/web/select/utils.ts +5 -0
- package/src/web/side-menu/index.scss +66 -0
- package/src/web/side-menu/index.ts +4 -0
- package/src/web/side-menu/index.vue +228 -0
- package/src/web/side-menu/types.ts +20 -0
- package/src/web/single-select/index.scss +60 -0
- package/src/web/single-select/index.ts +5 -0
- package/src/web/single-select/index.vue +70 -0
- package/src/web/single-select/select@2x.png +0 -0
- package/src/web/single-select/types.ts +5 -0
- package/src/web/svg/index.ts +3 -0
- package/src/web/svg/index.vue +22 -0
- package/src/web/tabs/index.scss +579 -0
- package/src/web/tabs/index.ts +6 -0
- package/src/web/tabs/index.vue +236 -0
- package/src/web/tabs/tab-bar.vue +90 -0
- package/src/web/tabs/tab-nav.vue +403 -0
- package/src/web/tabs/tab-pane.vue +90 -0
- package/src/web/tabs/types.ts +66 -0
- package/src/web/tag/index.scss +182 -0
- package/src/web/tag/index.ts +5 -0
- package/src/web/tag/index.vue +78 -0
- package/src/web/tag/types.ts +2 -0
- package/src/web/tooltip/content.vue +239 -0
- package/src/web/tooltip/index.ts +4 -0
- package/src/web/tooltip/tokens.ts +21 -0
- package/src/web/tooltip/tooltip.vue +270 -0
- package/src/web/tooltip/trigger.vue +119 -0
- package/src/web/tooltip/types.ts +56 -0
- package/src/web/tooltip/utils.ts +20 -0
- package/src/web/transition/collapse-transition.vue +73 -0
- package/src/web/transition/index.ts +5 -0
- package/tsconfig.json +8 -0
- package/types/component.ts +1 -0
- package/types/index.d.ts +286 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { provide } from 'vue';
|
|
2
|
+
|
|
3
|
+
import type { InjectionKey, ObjectDirective, Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
type ForwardRefSetter = <T>(el: T) => void;
|
|
6
|
+
|
|
7
|
+
export type ForwardRefInjectionContext = {
|
|
8
|
+
setForwardRef: ForwardRefSetter;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const FORWARD_REF_INJECTION_KEY: InjectionKey<ForwardRefInjectionContext> = Symbol('elForwardRef');
|
|
12
|
+
|
|
13
|
+
export const useForwardRef = <T>(forwardRef: Ref<T | null>) => {
|
|
14
|
+
const setForwardRef = (el: T) => {
|
|
15
|
+
forwardRef.value = el;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
provide(FORWARD_REF_INJECTION_KEY, {
|
|
19
|
+
setForwardRef
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const useForwardRefDirective = (setForwardRef: ForwardRefSetter): ObjectDirective => {
|
|
24
|
+
return {
|
|
25
|
+
mounted(el) {
|
|
26
|
+
setForwardRef(el);
|
|
27
|
+
},
|
|
28
|
+
updated(el) {
|
|
29
|
+
setForwardRef(el);
|
|
30
|
+
},
|
|
31
|
+
unmounted() {
|
|
32
|
+
setForwardRef(null);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { keysOf } from '@vri/utils';
|
|
2
|
+
import { debugWarn } from '../../utils';
|
|
3
|
+
import { computed, getCurrentInstance, inject, provide, ref, unref } from 'vue';
|
|
4
|
+
import { CONFIG_PROVIDER_KEY, type ConfigProviderContext } from '../../common/config-provider/types';
|
|
5
|
+
|
|
6
|
+
import type { MaybeRef } from '@vueuse/core';
|
|
7
|
+
import type { App, Ref } from 'vue';
|
|
8
|
+
|
|
9
|
+
const globalConfig = ref<ConfigProviderContext>();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description 如果能拿到 vue 实例,则返回
|
|
13
|
+
* @author wfd
|
|
14
|
+
* @date 2022/10/18 13:06
|
|
15
|
+
* @example
|
|
16
|
+
* @param {K} key
|
|
17
|
+
* @param {D} defaultValue
|
|
18
|
+
* @returns {Ref<Exclude<ConfigProviderContext[K], undefined> | D>}
|
|
19
|
+
*/
|
|
20
|
+
export function useGlobalConfig<
|
|
21
|
+
K extends keyof ConfigProviderContext,
|
|
22
|
+
D extends ConfigProviderContext[K]
|
|
23
|
+
>(
|
|
24
|
+
key: K,
|
|
25
|
+
defaultValue?: D
|
|
26
|
+
): Ref<Exclude<ConfigProviderContext[K], undefined> | D>
|
|
27
|
+
export function useGlobalConfig(): Ref<ConfigProviderContext>
|
|
28
|
+
export function useGlobalConfig(
|
|
29
|
+
key?: keyof ConfigProviderContext,
|
|
30
|
+
defaultValue = undefined
|
|
31
|
+
) {
|
|
32
|
+
const config = getCurrentInstance()
|
|
33
|
+
? inject(CONFIG_PROVIDER_KEY, globalConfig)
|
|
34
|
+
: globalConfig;
|
|
35
|
+
if (key) {
|
|
36
|
+
return computed(() => config.value?.[key] ?? defaultValue);
|
|
37
|
+
} else {
|
|
38
|
+
return config;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const provideGlobalConfig = (
|
|
43
|
+
config: MaybeRef<ConfigProviderContext>,
|
|
44
|
+
app?: App,
|
|
45
|
+
global = false
|
|
46
|
+
) => {
|
|
47
|
+
const inSetup = !!getCurrentInstance();
|
|
48
|
+
const oldConfig = inSetup ? useGlobalConfig() : undefined;
|
|
49
|
+
|
|
50
|
+
const provideFn = app?.provide ?? (inSetup ? provide : undefined);
|
|
51
|
+
if (!provideFn) {
|
|
52
|
+
debugWarn(
|
|
53
|
+
'provideGlobalConfig',
|
|
54
|
+
'provideGlobalConfig() can only be used inside setup().'
|
|
55
|
+
);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const context = computed(() => {
|
|
60
|
+
const cfg = unref(config);
|
|
61
|
+
if (!oldConfig?.value) return cfg;
|
|
62
|
+
return mergeConfig(oldConfig.value, cfg);
|
|
63
|
+
});
|
|
64
|
+
provideFn(CONFIG_PROVIDER_KEY, context);
|
|
65
|
+
if (global || !globalConfig.value) {
|
|
66
|
+
globalConfig.value = context.value;
|
|
67
|
+
}
|
|
68
|
+
return context;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const mergeConfig = (
|
|
72
|
+
a: ConfigProviderContext,
|
|
73
|
+
b: ConfigProviderContext
|
|
74
|
+
): ConfigProviderContext => {
|
|
75
|
+
const keys = [...new Set([...keysOf(a), ...keysOf(b)])];
|
|
76
|
+
const obj: Record<string, any> = {};
|
|
77
|
+
for (const key of keys) {
|
|
78
|
+
obj[key] = b[key] ?? a[key];
|
|
79
|
+
}
|
|
80
|
+
return obj;
|
|
81
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { computed, getCurrentInstance, inject, unref } from 'vue';
|
|
2
|
+
import { isClient } from '@vueuse/core';
|
|
3
|
+
import { debugWarn } from '../../utils';
|
|
4
|
+
import { useGlobalConfig } from '../use-global-config';
|
|
5
|
+
import { defaultNamespace } from '../use-namespace';
|
|
6
|
+
|
|
7
|
+
import type { InjectionKey, Ref } from 'vue';
|
|
8
|
+
import type { MaybeRef } from '@vueuse/core';
|
|
9
|
+
|
|
10
|
+
export type ElIdInjectionContext = {
|
|
11
|
+
prefix: number;
|
|
12
|
+
current: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const defaultIdInjection = {
|
|
16
|
+
prefix: Math.floor(Math.random() * 10000),
|
|
17
|
+
current: 0
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const ID_INJECTION_KEY: InjectionKey<ElIdInjectionContext> = Symbol('elIdInjection');
|
|
21
|
+
|
|
22
|
+
export const useIdInjection = (): ElIdInjectionContext => {
|
|
23
|
+
return getCurrentInstance() ? inject(ID_INJECTION_KEY, defaultIdInjection) : defaultIdInjection;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const useId = (deterministicId?: MaybeRef<string>): Ref<string> => {
|
|
27
|
+
const idInjection = useIdInjection();
|
|
28
|
+
if (!isClient && idInjection === defaultIdInjection) {
|
|
29
|
+
debugWarn(
|
|
30
|
+
'IdInjection',
|
|
31
|
+
`Looks like you are using server rendering, you must provide a id provider to ensure the hydration process to be succeed
|
|
32
|
+
usage: app.provide(ID_INJECTION_KEY, {
|
|
33
|
+
prefix: number,
|
|
34
|
+
current: number,
|
|
35
|
+
})`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const namespace = useGlobalConfig('namespace', defaultNamespace);
|
|
40
|
+
const idRef = computed(() => unref(deterministicId) || `${namespace.value}-id-${idInjection.prefix}-${idInjection.current++}`);
|
|
41
|
+
|
|
42
|
+
return idRef;
|
|
43
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { computed, getCurrentInstance, onMounted, watch } from 'vue';
|
|
2
|
+
import { isFunction } from '@vue/shared';
|
|
3
|
+
import { isClient } from '@vueuse/core';
|
|
4
|
+
import { isBoolean } from '@vri/utils';
|
|
5
|
+
import type { RouteLocationNormalizedLoaded } from 'vue-router';
|
|
6
|
+
|
|
7
|
+
import type { ComponentPublicInstance, Ref } from 'vue';
|
|
8
|
+
|
|
9
|
+
export const createModelToggleComposable = <T extends string>(name: T) => {
|
|
10
|
+
const updateEventKey = `update:${name}` as const;
|
|
11
|
+
const updateEventKeyRaw = `onUpdate:${name}` as const;
|
|
12
|
+
|
|
13
|
+
const useModelToggle = ({ indicator, toggleReason, shouldHideWhenRouteChanges, shouldProceed, onShow, onHide }: ModelToggleParams) => {
|
|
14
|
+
const instance = getCurrentInstance()!;
|
|
15
|
+
const { emit } = instance;
|
|
16
|
+
const props = instance.props as any & {
|
|
17
|
+
disabled: boolean;
|
|
18
|
+
};
|
|
19
|
+
const hasUpdateHandler = computed(() => isFunction(props[updateEventKeyRaw]));
|
|
20
|
+
// when it matches the default value we say this is absent
|
|
21
|
+
// though this could be mistakenly passed from the user but we need to rule out that
|
|
22
|
+
// condition
|
|
23
|
+
const isModelBindingAbsent = computed(() => props[name] === null);
|
|
24
|
+
|
|
25
|
+
const doShow = (event?: Event) => {
|
|
26
|
+
if (indicator.value === true) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
indicator.value = true;
|
|
31
|
+
if (toggleReason) {
|
|
32
|
+
toggleReason.value = event;
|
|
33
|
+
}
|
|
34
|
+
if (isFunction(onShow)) {
|
|
35
|
+
onShow(event);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const doHide = (event?: Event) => {
|
|
40
|
+
if (indicator.value === false) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
indicator.value = false;
|
|
45
|
+
if (toggleReason) {
|
|
46
|
+
toggleReason.value = event;
|
|
47
|
+
}
|
|
48
|
+
if (isFunction(onHide)) {
|
|
49
|
+
onHide(event);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const show = (event?: Event) => {
|
|
54
|
+
if (props.disabled === true || (isFunction(shouldProceed) && !shouldProceed())) return;
|
|
55
|
+
|
|
56
|
+
const shouldEmit = hasUpdateHandler.value && isClient;
|
|
57
|
+
|
|
58
|
+
if (shouldEmit) {
|
|
59
|
+
emit(updateEventKey, true);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (isModelBindingAbsent.value || !shouldEmit) {
|
|
63
|
+
doShow(event);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const hide = (event?: Event) => {
|
|
68
|
+
if (props.disabled === true || !isClient) return;
|
|
69
|
+
|
|
70
|
+
const shouldEmit = hasUpdateHandler.value && isClient;
|
|
71
|
+
|
|
72
|
+
if (shouldEmit) {
|
|
73
|
+
emit(updateEventKey, false);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (isModelBindingAbsent.value || !shouldEmit) {
|
|
77
|
+
doHide(event);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const onChange = (val: boolean) => {
|
|
82
|
+
if (!isBoolean(val)) return;
|
|
83
|
+
if (props.disabled && val) {
|
|
84
|
+
if (hasUpdateHandler.value) {
|
|
85
|
+
emit(updateEventKey, false);
|
|
86
|
+
}
|
|
87
|
+
} else if (indicator.value !== val) {
|
|
88
|
+
if (val) {
|
|
89
|
+
doShow();
|
|
90
|
+
} else {
|
|
91
|
+
doHide();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const toggle = () => {
|
|
97
|
+
if (indicator.value) {
|
|
98
|
+
hide();
|
|
99
|
+
} else {
|
|
100
|
+
show();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
watch(() => props[name], onChange);
|
|
105
|
+
|
|
106
|
+
if (shouldHideWhenRouteChanges && instance.appContext.config.globalProperties.$route !== undefined) {
|
|
107
|
+
watch(
|
|
108
|
+
() => ({
|
|
109
|
+
...(
|
|
110
|
+
instance.proxy as ComponentPublicInstance<{
|
|
111
|
+
$route: RouteLocationNormalizedLoaded;
|
|
112
|
+
}>
|
|
113
|
+
).$route
|
|
114
|
+
}),
|
|
115
|
+
() => {
|
|
116
|
+
if (shouldHideWhenRouteChanges.value && indicator.value) {
|
|
117
|
+
hide();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
onMounted(() => {
|
|
124
|
+
onChange(props[name]);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
hide,
|
|
129
|
+
show,
|
|
130
|
+
toggle,
|
|
131
|
+
hasUpdateHandler
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
useModelToggle
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const { useModelToggle } = createModelToggleComposable('modelValue');
|
|
141
|
+
|
|
142
|
+
export { useModelToggle };
|
|
143
|
+
|
|
144
|
+
export type ModelToggleParams = {
|
|
145
|
+
indicator: Ref<boolean>;
|
|
146
|
+
toggleReason?: Ref<Event | undefined>;
|
|
147
|
+
shouldHideWhenRouteChanges?: Ref<boolean>;
|
|
148
|
+
shouldProceed?: () => boolean;
|
|
149
|
+
onShow?: (event?: Event) => void;
|
|
150
|
+
onHide?: (event?: Event) => void;
|
|
151
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useGlobalConfig } from '../use-global-config';
|
|
2
|
+
|
|
3
|
+
export const defaultNamespace = 'vri';
|
|
4
|
+
const statePrefix = 'is-';
|
|
5
|
+
|
|
6
|
+
export const _bem = (namespace: string, block: string, blockSuffix: string, element: string, modifier: string) => {
|
|
7
|
+
let cls = `${namespace}-${block}`;
|
|
8
|
+
if (blockSuffix) {
|
|
9
|
+
cls += `-${blockSuffix}`;
|
|
10
|
+
}
|
|
11
|
+
if (element) {
|
|
12
|
+
cls += `__${element}`;
|
|
13
|
+
}
|
|
14
|
+
if (modifier) {
|
|
15
|
+
cls += `--${modifier}`;
|
|
16
|
+
}
|
|
17
|
+
return cls;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const useNamespace = (block: string) => {
|
|
21
|
+
const namespace = useGlobalConfig('namespace', defaultNamespace);
|
|
22
|
+
// vri-button | (test) = vri-button-test
|
|
23
|
+
const b = (blockSuffix = '') => _bem(namespace.value, block, blockSuffix, '', '');
|
|
24
|
+
// e('test'): vri-button__test
|
|
25
|
+
const e = (element?: string) => (element ? _bem(namespace.value, block, '', element, '') : '');
|
|
26
|
+
// m('test'): vri-button--test
|
|
27
|
+
const m = (modifier?: string) => (modifier ? _bem(namespace.value, block, '', '', modifier) : '');
|
|
28
|
+
// be('test'): vri-button-par__sub
|
|
29
|
+
const be = (blockSuffix?: string, element?: string) => (blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, '') : '');
|
|
30
|
+
// em('test'): vri-button__par--sub
|
|
31
|
+
const em = (element?: string, modifier?: string) => (element && modifier ? _bem(namespace.value, block, '', element, modifier) : '');
|
|
32
|
+
// bm('test'): vri-button-par--sub
|
|
33
|
+
const bm = (blockSuffix?: string, modifier?: string) => (blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, '', modifier) : '');
|
|
34
|
+
// bem('test'): vri-button-par__sub--sun
|
|
35
|
+
const bem = (blockSuffix?: string, element?: string, modifier?: string) => (blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : '');
|
|
36
|
+
// is('show', true): is-show
|
|
37
|
+
const is: {
|
|
38
|
+
(name: string, state: boolean | undefined): string;
|
|
39
|
+
(name: string): string;
|
|
40
|
+
} = (name: string, ...args: [boolean | undefined] | []) => {
|
|
41
|
+
const state = args.length >= 1 ? args[0]! : true;
|
|
42
|
+
return name && state ? `${statePrefix}${name}` : '';
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// cssVar({'border-style': 'solid','border-width': '10px',}): { "--vri-border-style": "solid","--vri-border-width": "10px" }
|
|
46
|
+
const cssVar = (object: Record<string, string|undefined>) => {
|
|
47
|
+
const styles: Record<string, string> = {};
|
|
48
|
+
for (const key in object) {
|
|
49
|
+
if (object[key]) {
|
|
50
|
+
styles[`--${namespace.value}-${key}`] = object[key]!;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return styles;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// cssVarBlock({ 'border-style': 'solid', 'border-width': '10px' }):{ "--vri-button-border-style": "solid", "--vri-button-border-width": "10px" }
|
|
57
|
+
const cssVarBlock = (object: Record<string, string | undefined>) => {
|
|
58
|
+
const styles: Record<string, string> = {};
|
|
59
|
+
for (const key in object) {
|
|
60
|
+
if (object[key]) {
|
|
61
|
+
styles[`--${namespace.value}-${block}-${key}`] = object[key]!;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return styles;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// cssVarName('test'):--vri-test
|
|
68
|
+
const cssVarName = (name: string) => `--${namespace.value}-${name}`;
|
|
69
|
+
|
|
70
|
+
// cssVarBlockName('test'):--vri-button-test
|
|
71
|
+
const cssVarBlockName = (name: string) => `--${namespace.value}-${block}-${name}`;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
namespace,
|
|
75
|
+
b,
|
|
76
|
+
e,
|
|
77
|
+
m,
|
|
78
|
+
be,
|
|
79
|
+
em,
|
|
80
|
+
bm,
|
|
81
|
+
bem,
|
|
82
|
+
is,
|
|
83
|
+
// css
|
|
84
|
+
cssVar,
|
|
85
|
+
cssVarName,
|
|
86
|
+
cssVarBlock,
|
|
87
|
+
cssVarBlockName
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type UseNamespaceReturn = ReturnType<typeof useNamespace>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isVNode, shallowRef } from 'vue';
|
|
2
|
+
import { flattedChildren } from '../../utils';
|
|
3
|
+
|
|
4
|
+
import type { ComponentInternalInstance, VNode } from 'vue';
|
|
5
|
+
|
|
6
|
+
const getOrderedChildren = <T> (
|
|
7
|
+
vm: ComponentInternalInstance,
|
|
8
|
+
childComponentName: string,
|
|
9
|
+
children: Record<number, T>
|
|
10
|
+
): T[] => {
|
|
11
|
+
const nodes = flattedChildren(vm.subTree).filter((n): n is VNode =>
|
|
12
|
+
isVNode(n) && (n.type as any)?.name === childComponentName && !!n.component
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const uids = nodes.map((n) => n.component!.uid);
|
|
16
|
+
return uids.map((uid) => children[uid]).filter((p) => !!p);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const useOrderedChildren = <T extends {uid: number}> (
|
|
20
|
+
vm: ComponentInternalInstance,
|
|
21
|
+
childComponentName: string
|
|
22
|
+
) => {
|
|
23
|
+
const children: Record<number, T> = {};
|
|
24
|
+
const orderedChildren = shallowRef<T[]>([]);
|
|
25
|
+
|
|
26
|
+
const addChild = (child: T) => {
|
|
27
|
+
children[child.uid] = child;
|
|
28
|
+
orderedChildren.value = getOrderedChildren(vm, childComponentName, children);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const removeChild = (uid: number) => {
|
|
32
|
+
delete children[uid];
|
|
33
|
+
orderedChildren.value = orderedChildren.value.filter(
|
|
34
|
+
(children) => children.uid !== uid
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
children: orderedChildren,
|
|
40
|
+
addChild,
|
|
41
|
+
removeChild
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { computed, onBeforeMount } from 'vue';
|
|
2
|
+
import { isClient } from '@vueuse/core';
|
|
3
|
+
import { useGlobalConfig } from '../use-global-config';
|
|
4
|
+
import { defaultNamespace } from '../use-namespace';
|
|
5
|
+
import { useIdInjection } from '../use-id';
|
|
6
|
+
|
|
7
|
+
let cachedContainer: HTMLElement;
|
|
8
|
+
|
|
9
|
+
export const usePopperContainerId = () => {
|
|
10
|
+
const namespace = useGlobalConfig('namespace', defaultNamespace);
|
|
11
|
+
const idInjection = useIdInjection();
|
|
12
|
+
|
|
13
|
+
const id = computed(() => {
|
|
14
|
+
return `${namespace.value}-popper-container-${idInjection.prefix}`;
|
|
15
|
+
});
|
|
16
|
+
const selector = computed(() => `#${id.value}`);
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
id,
|
|
20
|
+
selector
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const createContainer = (id: string) => {
|
|
25
|
+
const container = document.createElement('div');
|
|
26
|
+
container.id = id;
|
|
27
|
+
document.body.appendChild(container);
|
|
28
|
+
return container;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const usePopperContainer = () => {
|
|
32
|
+
onBeforeMount(() => {
|
|
33
|
+
if (!isClient) return;
|
|
34
|
+
|
|
35
|
+
const { id, selector } = usePopperContainerId();
|
|
36
|
+
// This is for bypassing the error that when under testing env, we often encounter
|
|
37
|
+
// document.body.innerHTML = '' situation
|
|
38
|
+
// for this we need to disable the caching since it's not really needed
|
|
39
|
+
if (process.env.NODE_ENV === 'test' || (!cachedContainer && !document.body.querySelector(selector.value))) {
|
|
40
|
+
cachedContainer = createContainer(id.value);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from '@vueuse/core';
|
|
2
|
+
|
|
3
|
+
export function useTimeout() {
|
|
4
|
+
let timeoutHandle: number;
|
|
5
|
+
|
|
6
|
+
const registerTimeout = (fn: (...args: any[]) => any, delay: number) => {
|
|
7
|
+
cancelTimeout();
|
|
8
|
+
timeoutHandle = window.setTimeout(fn, delay);
|
|
9
|
+
};
|
|
10
|
+
const cancelTimeout = () => window.clearTimeout(timeoutHandle);
|
|
11
|
+
|
|
12
|
+
tryOnScopeDispose(() => cancelTimeout());
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
registerTimeout,
|
|
16
|
+
cancelTimeout
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { computed, ref } from 'vue';
|
|
2
|
+
import { useGlobalConfig } from '../use-global-config';
|
|
3
|
+
|
|
4
|
+
const zIndex = ref(0);
|
|
5
|
+
|
|
6
|
+
export const useZIndex = () => {
|
|
7
|
+
const initialZIndex = useGlobalConfig('zIndex', 2000); // TODO: move to @element-plus/constants
|
|
8
|
+
const currentZIndex = computed(() => initialZIndex.value + zIndex.value);
|
|
9
|
+
|
|
10
|
+
const nextZIndex = () => {
|
|
11
|
+
zIndex.value++;
|
|
12
|
+
return currentZIndex.value;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
initialZIndex,
|
|
17
|
+
currentZIndex,
|
|
18
|
+
nextZIndex
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Popup 组件的 z-index。
|
|
3
|
+
|
|
4
|
+
* 会影响以下组件:
|
|
5
|
+
* - ActionSheet
|
|
6
|
+
* - Calendar
|
|
7
|
+
* - Dialog
|
|
8
|
+
* - DropdownItem
|
|
9
|
+
* - ImagePreview
|
|
10
|
+
* - Notify
|
|
11
|
+
* - Popup
|
|
12
|
+
* - Popover
|
|
13
|
+
* - ShareSheet
|
|
14
|
+
* - Toast
|
|
15
|
+
*/
|
|
16
|
+
let globalZIndex = 2000;
|
|
17
|
+
|
|
18
|
+
/** 全局 z-index 读取后自动递增 */
|
|
19
|
+
export const useGlobalZIndex = () => ++globalZIndex;
|
|
20
|
+
|
|
21
|
+
/** 全局 z-index */
|
|
22
|
+
export const setGlobalZIndex = (val: number) => {
|
|
23
|
+
globalZIndex = val;
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ref, watch, type WatchSource } from 'vue';
|
|
2
|
+
|
|
3
|
+
export function useLazyRender(show: WatchSource<boolean | undefined>) {
|
|
4
|
+
const inited = ref(false);
|
|
5
|
+
|
|
6
|
+
watch(
|
|
7
|
+
show,
|
|
8
|
+
(value) => {
|
|
9
|
+
if (value) {
|
|
10
|
+
inited.value = value;
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{ immediate: true }
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return (render: () => JSX.Element) => () => inited.value ? render() : null;
|
|
17
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type Ref, watch, onBeforeUnmount, onDeactivated } from 'vue';
|
|
2
|
+
import { getScrollParent, useTouch, onMountedOrActivated } from '@vri/use';
|
|
3
|
+
import { preventDefault } from '@vri/utils';
|
|
4
|
+
|
|
5
|
+
let totalLockCount = 0;
|
|
6
|
+
|
|
7
|
+
const BODY_LOCK_CLASS = 'vri-overflow-hidden';
|
|
8
|
+
|
|
9
|
+
export function useLockScroll(rootRef: Ref<HTMLElement | undefined>, shouldLock: () => boolean) {
|
|
10
|
+
const touch = useTouch();
|
|
11
|
+
|
|
12
|
+
const onTouchMove = (event: TouchEvent) => {
|
|
13
|
+
touch.move(event);
|
|
14
|
+
|
|
15
|
+
const direction = touch.deltaY.value > 0 ? '10' : '01';
|
|
16
|
+
const el = getScrollParent(event.target as Element, rootRef.value) as HTMLElement;
|
|
17
|
+
const { scrollHeight, offsetHeight, scrollTop } = el;
|
|
18
|
+
let status = '11';
|
|
19
|
+
|
|
20
|
+
if (scrollTop === 0) {
|
|
21
|
+
status = offsetHeight >= scrollHeight ? '00' : '01';
|
|
22
|
+
} else if (scrollTop + offsetHeight >= scrollHeight) {
|
|
23
|
+
status = '10';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (status !== '11' && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
|
|
27
|
+
preventDefault(event, true);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const lock = () => {
|
|
32
|
+
document.addEventListener('touchstart', touch.start);
|
|
33
|
+
document.addEventListener('touchmove', onTouchMove, { passive: false });
|
|
34
|
+
|
|
35
|
+
if (!totalLockCount) {
|
|
36
|
+
document.body.classList.add(BODY_LOCK_CLASS);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
totalLockCount++;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const unlock = () => {
|
|
43
|
+
if (totalLockCount) {
|
|
44
|
+
document.removeEventListener('touchstart', touch.start);
|
|
45
|
+
document.removeEventListener('touchmove', onTouchMove);
|
|
46
|
+
|
|
47
|
+
totalLockCount--;
|
|
48
|
+
|
|
49
|
+
if (!totalLockCount) {
|
|
50
|
+
document.body.classList.remove(BODY_LOCK_CLASS);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const init = () => shouldLock() && lock();
|
|
56
|
+
|
|
57
|
+
const destroy = () => shouldLock() && unlock();
|
|
58
|
+
|
|
59
|
+
onMountedOrActivated(init);
|
|
60
|
+
onDeactivated(destroy);
|
|
61
|
+
onBeforeUnmount(destroy);
|
|
62
|
+
|
|
63
|
+
watch(shouldLock, (value) => {
|
|
64
|
+
value ? lock() : unlock();
|
|
65
|
+
});
|
|
66
|
+
}
|