vft 0.0.415 → 0.0.417
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/attributes.json +1 -1
- package/dist/index.css +1 -1
- package/es/components/autocomplete/autocomplete.vue.d.ts +8 -8
- package/es/components/autocomplete/index.d.ts +24 -24
- package/es/components/button/button.vue.d.ts +1 -1
- package/es/components/button/index.d.ts +30 -30
- package/es/components/button/use-button.d.ts +1 -1
- package/es/components/carousel/use-carousel.js +1 -1
- package/es/components/color-picker/composables/use-alpha-slider.d.ts +2 -2
- package/es/components/config-provider/config-provider.vue.d.ts +2 -0
- package/es/components/config-provider/config-provider.vue2.js +4 -3
- package/es/components/config-provider/index.d.ts +9 -0
- package/es/components/dialog/constants.d.ts +1 -0
- package/es/components/dialog/constants.js +2 -1
- package/es/components/dialog/dialog-content.vue.d.ts +4 -1
- package/es/components/dialog/dialog-content.vue2.js +59 -48
- package/es/components/dialog/dialog.vue.d.ts +4 -19
- package/es/components/dialog/dialog.vue2.js +104 -89
- package/es/components/dialog/index.d.ts +70 -3
- package/es/components/dialog/index.js +5 -4
- package/es/components/dialog/types.d.ts +69 -0
- package/es/components/dialog/{hooks/use-dialog.d.ts → use-dialog.d.ts} +11 -2
- package/es/components/dialog/use-dialog.js +138 -0
- package/es/components/drawer/composables/useResizable.d.ts +7 -0
- package/es/components/drawer/composables/useResizable.js +53 -0
- package/es/components/drawer/drawer.vue.d.ts +3 -7
- package/es/components/drawer/drawer.vue2.js +122 -97
- package/es/components/drawer/index.d.ts +78 -0
- package/es/components/drawer/types.d.ts +13 -0
- package/es/components/drawer/types.js +1 -0
- package/es/components/dropdown/dropdown.vue.d.ts +1 -1
- package/es/components/dropdown/index.d.ts +15 -15
- package/es/components/form/index.d.ts +6 -6
- package/es/components/index.js +172 -171
- package/es/components/input/input.vue2.js +4 -4
- package/es/components/input-tag/composables/use-input-tag.js +1 -1
- package/es/components/input-tag/input-tag.vue.d.ts +1 -1
- package/es/components/link/index.d.ts +3 -3
- package/es/components/md-code-demo/md-code-demo.js +10 -10
- package/es/components/modal/index.d.ts +87 -24
- package/es/components/modal/modal.vue.d.ts +1 -1
- package/es/components/modal/modal.vue2.js +24 -17
- package/es/components/multiple-tabs/multiple-tabs.vue2.js +82 -79
- package/es/components/popover/index.d.ts +0 -9
- package/es/components/popover/popover.vue2.js +4 -5
- package/es/components/popover/types.d.ts +23 -1
- package/es/components/search/search.vue2.js +3 -3
- package/es/components/select/index.d.ts +20 -20
- package/es/components/select/select.vue.d.ts +20 -20
- package/es/components/select/useSelect.d.ts +17 -17
- package/es/components/super-form/super-form-item.vue2.js +1 -1
- package/es/components/table/index.d.ts +9 -9
- package/es/components/time-picker/time-picker-com/panel-time-pick.vue.d.ts +1 -1
- package/es/components/time-picker/time-picker-com/panel-time-range.vue.d.ts +1 -1
- package/es/components/timeline/index.d.ts +6 -6
- package/es/components/tooltip/index.d.ts +3 -3
- package/es/components/tooltip/tooltip.vue2.js +1 -1
- package/es/components/tooltip/types.d.ts +81 -1
- package/es/hooks/use-draggable/index.d.ts +5 -1
- package/es/hooks/use-draggable/index.js +39 -34
- package/es/hooks/use-z-index/index.js +3 -3
- package/es/index.js +2 -2
- package/es/package.json.d.ts +1 -1
- package/es/package.json.js +1 -1
- package/es/utils/helper.d.ts +1 -1
- package/es/utils/ns-cover.d.ts +1 -1
- package/es/utils/vue/vnode.js +1 -1
- package/lib/components/autocomplete/autocomplete.vue.d.ts +8 -8
- package/lib/components/autocomplete/index.d.ts +24 -24
- package/lib/components/button/button.vue.d.ts +1 -1
- package/lib/components/button/index.d.ts +30 -30
- package/lib/components/button/use-button.d.ts +1 -1
- package/lib/components/color-picker/composables/use-alpha-slider.d.ts +2 -2
- package/lib/components/config-provider/config-provider.vue.d.ts +2 -0
- package/lib/components/config-provider/config-provider.vue2.cjs +1 -1
- package/lib/components/config-provider/index.d.ts +9 -0
- package/lib/components/dialog/constants.cjs +1 -1
- package/lib/components/dialog/constants.d.ts +1 -0
- package/lib/components/dialog/dialog-content.vue.d.ts +4 -1
- package/lib/components/dialog/dialog-content.vue2.cjs +1 -1
- package/lib/components/dialog/dialog.vue.d.ts +4 -19
- package/lib/components/dialog/dialog.vue2.cjs +1 -1
- package/lib/components/dialog/index.cjs +1 -1
- package/lib/components/dialog/index.d.ts +70 -3
- package/lib/components/dialog/types.d.ts +69 -0
- package/lib/components/dialog/use-dialog.cjs +1 -0
- package/lib/components/dialog/{hooks/use-dialog.d.ts → use-dialog.d.ts} +11 -2
- package/lib/components/drawer/composables/useResizable.cjs +1 -0
- package/lib/components/drawer/composables/useResizable.d.ts +7 -0
- package/lib/components/drawer/drawer.vue.d.ts +3 -7
- package/lib/components/drawer/drawer.vue2.cjs +1 -1
- package/lib/components/drawer/index.d.ts +78 -0
- package/lib/components/drawer/types.cjs +1 -0
- package/lib/components/drawer/types.d.ts +13 -0
- package/lib/components/dropdown/dropdown.vue.d.ts +1 -1
- package/lib/components/dropdown/index.d.ts +15 -15
- package/lib/components/form/index.d.ts +6 -6
- package/lib/components/index.cjs +1 -1
- package/lib/components/input/input.vue2.cjs +1 -1
- package/lib/components/input-tag/input-tag.vue.d.ts +1 -1
- package/lib/components/link/index.d.ts +3 -3
- package/lib/components/md-code-demo/md-code-demo.cjs +1 -1
- package/lib/components/modal/index.d.ts +87 -24
- package/lib/components/modal/modal.vue.d.ts +1 -1
- package/lib/components/modal/modal.vue2.cjs +1 -1
- package/lib/components/multiple-tabs/multiple-tabs.vue2.cjs +1 -1
- package/lib/components/popover/index.d.ts +0 -9
- package/lib/components/popover/popover.vue2.cjs +1 -1
- package/lib/components/popover/types.d.ts +23 -1
- package/lib/components/search/search.vue2.cjs +1 -1
- package/lib/components/select/index.d.ts +20 -20
- package/lib/components/select/select.vue.d.ts +20 -20
- package/lib/components/select/useSelect.d.ts +17 -17
- package/lib/components/table/index.d.ts +9 -9
- package/lib/components/time-picker/time-picker-com/panel-time-pick.vue.d.ts +1 -1
- package/lib/components/time-picker/time-picker-com/panel-time-range.vue.d.ts +1 -1
- package/lib/components/timeline/index.d.ts +6 -6
- package/lib/components/tooltip/index.d.ts +3 -3
- package/lib/components/tooltip/tooltip.vue2.cjs +1 -1
- package/lib/components/tooltip/types.d.ts +81 -1
- package/lib/hooks/use-draggable/index.cjs +1 -1
- package/lib/hooks/use-draggable/index.d.ts +5 -1
- package/lib/index.cjs +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/package.json.d.ts +1 -1
- package/lib/utils/helper.d.ts +1 -1
- package/lib/utils/ns-cover.d.ts +1 -1
- package/package.json +3 -3
- package/tags.json +1 -1
- package/theme-style/index.css +1 -1
- package/theme-style/src/card.scss +4 -4
- package/theme-style/src/dialog.scss +36 -35
- package/theme-style/src/drawer.scss +109 -21
- package/theme-style/src/md-container.scss +1 -0
- package/theme-style/src/tag.scss +1 -1
- package/theme-style/vft-card.css +1 -1
- package/theme-style/vft-dialog.css +1 -1
- package/theme-style/vft-drawer.css +1 -1
- package/theme-style/vft-md-container.css +1 -1
- package/theme-style/vft-tag.css +1 -1
- package/web-types.json +1 -1
- package/es/components/dialog/hooks/use-dialog.js +0 -106
- package/lib/components/dialog/hooks/use-dialog.cjs +0 -1
|
@@ -6,12 +6,13 @@ import { withInstall as o } from "../../utils/vue/install.js";
|
|
|
6
6
|
import "lodash-es";
|
|
7
7
|
import "../form/index.js";
|
|
8
8
|
import t from "./dialog.vue2.js";
|
|
9
|
-
import { dialogInjectionKey as
|
|
10
|
-
import { useDialog as
|
|
9
|
+
import { DEFAULT_DIALOG_TRANSITION as D, dialogInjectionKey as _ } from "./constants.js";
|
|
10
|
+
import { useDialog as g } from "./use-dialog.js";
|
|
11
11
|
const n = o(t);
|
|
12
12
|
export {
|
|
13
|
+
D as DEFAULT_DIALOG_TRANSITION,
|
|
13
14
|
n as VftDialog,
|
|
14
15
|
n as default,
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
_ as dialogInjectionKey,
|
|
17
|
+
g as useDialog
|
|
17
18
|
};
|
|
@@ -1,11 +1,80 @@
|
|
|
1
1
|
import type { IconProps } from 'vft/es/components/icon';
|
|
2
|
+
import type { TransitionProps } from 'vue';
|
|
3
|
+
type DoneFn = (cancel?: boolean) => void;
|
|
4
|
+
export interface DialogProps extends DialogContentProps {
|
|
5
|
+
/** 是否将对话框挂载到 body 元素上 */
|
|
6
|
+
appendToBody?: boolean;
|
|
7
|
+
/** 指定对话框挂载的容器元素 */
|
|
8
|
+
appendTo?: string | HTMLElement;
|
|
9
|
+
/** 关闭前的回调,会暂停对话框的关闭 */
|
|
10
|
+
beforeClose?: (done: DoneFn) => void;
|
|
11
|
+
/** 关闭时销毁对话框内的元素 */
|
|
12
|
+
destroyOnClose?: boolean;
|
|
13
|
+
/** 是否可以通过点击遮罩层关闭对话框 */
|
|
14
|
+
closeOnClickModal?: boolean;
|
|
15
|
+
/** 是否可以通过按下 ESC 键关闭对话框 */
|
|
16
|
+
closeOnPressEscape?: boolean;
|
|
17
|
+
/** 是否锁定页面滚动 */
|
|
18
|
+
lockScroll?: boolean;
|
|
19
|
+
/** 是否显示遮罩层 */
|
|
20
|
+
modal?: boolean;
|
|
21
|
+
/** 对话框打开的延时时间(毫秒) */
|
|
22
|
+
openDelay?: number;
|
|
23
|
+
/** 对话框关闭的延时时间(毫秒) */
|
|
24
|
+
closeDelay?: number;
|
|
25
|
+
/** 对话框距离顶部的距离 */
|
|
26
|
+
top?: string;
|
|
27
|
+
/** 遮罩层是否可穿透 */
|
|
28
|
+
modalPenetrable?: boolean;
|
|
29
|
+
/** 对话框是否可见 */
|
|
30
|
+
modelValue?: boolean;
|
|
31
|
+
/** 遮罩层的自定义类名 */
|
|
32
|
+
modalClass?: string;
|
|
33
|
+
/** 对话框的宽度 */
|
|
34
|
+
width?: string | number;
|
|
35
|
+
/** 对话框的层级 */
|
|
36
|
+
zIndex?: number;
|
|
37
|
+
/** 是否启用焦点陷阱 */
|
|
38
|
+
trapFocus?: boolean;
|
|
39
|
+
/** 是否允许对话框内容溢出 */
|
|
40
|
+
overflow?: boolean;
|
|
41
|
+
/** 对话框的过渡动画 */
|
|
42
|
+
transition?: string | TransitionProps;
|
|
43
|
+
}
|
|
2
44
|
export interface DialogContentProps {
|
|
45
|
+
/** 是否居中显示对话框 */
|
|
3
46
|
center?: boolean;
|
|
47
|
+
/** 是否垂直居中显示对话框 */
|
|
4
48
|
alignCenter?: boolean;
|
|
49
|
+
/** 关闭按钮的图标 */
|
|
5
50
|
closeIcon?: string | IconProps;
|
|
51
|
+
/** 对话框的自定义类名 */
|
|
6
52
|
customClass?: string;
|
|
53
|
+
/** 是否可拖拽对话框 */
|
|
7
54
|
draggable?: boolean;
|
|
55
|
+
/** 是否全屏显示对话框 */
|
|
8
56
|
fullscreen?: boolean;
|
|
57
|
+
/** 是否显示关闭按钮 */
|
|
9
58
|
showClose?: boolean;
|
|
59
|
+
/** 对话框标题 */
|
|
10
60
|
title?: string;
|
|
61
|
+
/** 是否允许对话框内容溢出 */
|
|
62
|
+
overflow?: boolean;
|
|
63
|
+
/** 对话框头部内容的自定义类名 */
|
|
64
|
+
headerClass?: string;
|
|
65
|
+
/** 对话框主体内容的自定义类名 */
|
|
66
|
+
bodyClass?: string;
|
|
67
|
+
/** 对话框底部内容的自定义类名 */
|
|
68
|
+
footerClass?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface DialogConfigContext {
|
|
71
|
+
/** 是否垂直居中显示对话框 */
|
|
72
|
+
alignCenter?: boolean;
|
|
73
|
+
/** 是否可拖拽对话框 */
|
|
74
|
+
draggable?: boolean;
|
|
75
|
+
/** 是否允许对话框内容溢出 */
|
|
76
|
+
overflow?: boolean;
|
|
77
|
+
/** 对话框的过渡动画 */
|
|
78
|
+
transition?: string | TransitionProps;
|
|
11
79
|
}
|
|
80
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CSSProperties, Ref } from 'vue';
|
|
2
|
-
import type { DialogProps } from '
|
|
1
|
+
import type { CSSProperties, Ref, TransitionProps } from 'vue';
|
|
2
|
+
import type { DialogProps } from './types';
|
|
3
3
|
export declare const useDialog: (props: DialogProps, targetRef: Ref<HTMLElement | undefined>) => {
|
|
4
4
|
afterEnter: () => void;
|
|
5
5
|
afterLeave: () => void;
|
|
@@ -20,4 +20,13 @@ export declare const useDialog: (props: DialogProps, targetRef: Ref<HTMLElement
|
|
|
20
20
|
rendered: Ref<boolean, boolean>;
|
|
21
21
|
visible: Ref<boolean, boolean>;
|
|
22
22
|
zIndex: Ref<number, number>;
|
|
23
|
+
transitionConfig: import("vue").ComputedRef<TransitionProps | {
|
|
24
|
+
name: string | TransitionProps;
|
|
25
|
+
onAfterEnter: () => void;
|
|
26
|
+
onBeforeLeave: () => void;
|
|
27
|
+
onAfterLeave: () => void;
|
|
28
|
+
}>;
|
|
29
|
+
_draggable: import("vue").ComputedRef<boolean>;
|
|
30
|
+
_alignCenter: import("vue").ComputedRef<boolean>;
|
|
31
|
+
_overflow: import("vue").ComputedRef<boolean>;
|
|
23
32
|
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { DEFAULT_DIALOG_TRANSITION as P } from "./constants.js";
|
|
2
|
+
import "../config-provider/index.js";
|
|
3
|
+
import { UPDATE_MODEL_EVENT as Y } from "../../constants/event.js";
|
|
4
|
+
import { useTimeoutFn as M, isClient as H } from "@vueuse/core";
|
|
5
|
+
import { isObject as R, isArray as p, isFunction as N } from "@vft/utils";
|
|
6
|
+
import { addUnit as ee } from "../../utils/helper.js";
|
|
7
|
+
import { getCurrentInstance as ne, ref as r, computed as l, watch as x, nextTick as oe, onMounted as te } from "vue";
|
|
8
|
+
import "lodash-es";
|
|
9
|
+
import "../form/index.js";
|
|
10
|
+
import { useId as k } from "../../hooks/use-id/index.js";
|
|
11
|
+
import { useLockscreen as le } from "../../hooks/use-lockscreen/index.js";
|
|
12
|
+
import "../../hooks/use-model-toggle/index.js";
|
|
13
|
+
import { defaultNamespace as ie } from "../../hooks/use-namespace/index.js";
|
|
14
|
+
import "@popperjs/core";
|
|
15
|
+
import { useZIndex as ae } from "../../hooks/use-z-index/index.js";
|
|
16
|
+
import { useGlobalConfig as fe } from "../config-provider/hooks/use-global-config.js";
|
|
17
|
+
const Te = (e, t) => {
|
|
18
|
+
const i = ne().emit, { nextZIndex: m } = ae();
|
|
19
|
+
let T = "";
|
|
20
|
+
const B = k(), S = k(), a = r(!1), v = r(!1), c = r(!1), d = r(e.zIndex ?? m());
|
|
21
|
+
let C, g;
|
|
22
|
+
const O = fe(), U = l(() => O.value?.namespace ?? ie), s = l(() => O.value?.dialog), V = l(() => {
|
|
23
|
+
const n = {}, f = `--${U.value}-dialog`;
|
|
24
|
+
return e.fullscreen || (e.top && (n[`${f}-margin-top`] = e.top), e.width && (n[`${f}-width`] = ee(e.width))), n;
|
|
25
|
+
}), $ = l(
|
|
26
|
+
() => (e.draggable ?? s.value?.draggable ?? !1) && !e.fullscreen
|
|
27
|
+
), F = l(
|
|
28
|
+
() => e.alignCenter ?? s.value?.alignCenter ?? !1
|
|
29
|
+
), G = l(
|
|
30
|
+
() => e.overflow ?? s.value?.overflow ?? !1
|
|
31
|
+
), Z = l(() => F.value ? { display: "flex" } : {}), j = l(() => {
|
|
32
|
+
const n = e.transition ?? s.value?.transition ?? P, f = {
|
|
33
|
+
name: n,
|
|
34
|
+
onAfterEnter: y,
|
|
35
|
+
onBeforeLeave: I,
|
|
36
|
+
onAfterLeave: A
|
|
37
|
+
};
|
|
38
|
+
if (R(n)) {
|
|
39
|
+
const o = { ...n }, b = (u, X) => (w) => {
|
|
40
|
+
p(u) ? u.forEach((z) => {
|
|
41
|
+
N(z) && z(w);
|
|
42
|
+
}) : N(u) && u(w), X();
|
|
43
|
+
};
|
|
44
|
+
return o.onAfterEnter = b(o.onAfterEnter, y), o.onBeforeLeave = b(o.onBeforeLeave, I), o.onAfterLeave = b(o.onAfterLeave, A), o.name || (o.name = P), o;
|
|
45
|
+
}
|
|
46
|
+
return f;
|
|
47
|
+
});
|
|
48
|
+
function y() {
|
|
49
|
+
i("opened");
|
|
50
|
+
}
|
|
51
|
+
function A() {
|
|
52
|
+
i("closed"), i(Y, !1), e.destroyOnClose && (c.value = !1);
|
|
53
|
+
}
|
|
54
|
+
function I() {
|
|
55
|
+
i("close");
|
|
56
|
+
}
|
|
57
|
+
function _() {
|
|
58
|
+
g?.(), C?.(), e.openDelay && e.openDelay > 0 ? { stop: C } = M(() => h(), e.openDelay) : h();
|
|
59
|
+
}
|
|
60
|
+
function D() {
|
|
61
|
+
C?.(), g?.(), e.closeDelay && e.closeDelay > 0 ? { stop: g } = M(() => L(), e.closeDelay) : L();
|
|
62
|
+
}
|
|
63
|
+
function E() {
|
|
64
|
+
function n(f) {
|
|
65
|
+
f || (v.value = !0, a.value = !1);
|
|
66
|
+
}
|
|
67
|
+
console.log(111), e.beforeClose ? e.beforeClose(n) : D();
|
|
68
|
+
}
|
|
69
|
+
function q() {
|
|
70
|
+
e.closeOnClickModal && E();
|
|
71
|
+
}
|
|
72
|
+
function h() {
|
|
73
|
+
H && (a.value = !0);
|
|
74
|
+
}
|
|
75
|
+
function L() {
|
|
76
|
+
a.value = !1;
|
|
77
|
+
}
|
|
78
|
+
function J() {
|
|
79
|
+
i("openAutoFocus");
|
|
80
|
+
}
|
|
81
|
+
function K() {
|
|
82
|
+
i("closeAutoFocus");
|
|
83
|
+
}
|
|
84
|
+
function Q(n) {
|
|
85
|
+
n.detail?.focusReason === "pointer" && n.preventDefault();
|
|
86
|
+
}
|
|
87
|
+
e.lockScroll && le(a);
|
|
88
|
+
function W() {
|
|
89
|
+
e.closeOnPressEscape && E();
|
|
90
|
+
}
|
|
91
|
+
return x(
|
|
92
|
+
() => e.zIndex,
|
|
93
|
+
() => {
|
|
94
|
+
d.value = e.zIndex ?? m();
|
|
95
|
+
}
|
|
96
|
+
), x(
|
|
97
|
+
() => e.modelValue,
|
|
98
|
+
(n) => {
|
|
99
|
+
n ? (v.value = !1, _(), c.value = !0, d.value = e.zIndex ?? m(), oe(() => {
|
|
100
|
+
i("open"), t.value && (t.value.parentElement.scrollTop = 0, t.value.parentElement.scrollLeft = 0, t.value.scrollTop = 0);
|
|
101
|
+
})) : a.value && D();
|
|
102
|
+
}
|
|
103
|
+
), x(
|
|
104
|
+
() => e.fullscreen,
|
|
105
|
+
(n) => {
|
|
106
|
+
t.value && (n ? (T = t.value.style.transform, t.value.style.transform = "") : t.value.style.transform = T);
|
|
107
|
+
}
|
|
108
|
+
), te(() => {
|
|
109
|
+
e.modelValue && (a.value = !0, c.value = !0, _());
|
|
110
|
+
}), {
|
|
111
|
+
afterEnter: y,
|
|
112
|
+
afterLeave: A,
|
|
113
|
+
beforeLeave: I,
|
|
114
|
+
handleClose: E,
|
|
115
|
+
onModalClick: q,
|
|
116
|
+
close: D,
|
|
117
|
+
doClose: L,
|
|
118
|
+
onOpenAutoFocus: J,
|
|
119
|
+
onCloseAutoFocus: K,
|
|
120
|
+
onCloseRequested: W,
|
|
121
|
+
onFocusoutPrevented: Q,
|
|
122
|
+
titleId: B,
|
|
123
|
+
bodyId: S,
|
|
124
|
+
closed: v,
|
|
125
|
+
style: V,
|
|
126
|
+
overlayDialogStyle: Z,
|
|
127
|
+
rendered: c,
|
|
128
|
+
visible: a,
|
|
129
|
+
zIndex: d,
|
|
130
|
+
transitionConfig: j,
|
|
131
|
+
_draggable: $,
|
|
132
|
+
_alignCenter: F,
|
|
133
|
+
_overflow: G
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export {
|
|
137
|
+
Te as useDialog
|
|
138
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DrawerProps } from '../types';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
export declare function useResizable(props: DrawerProps, target: Ref<HTMLElement | undefined>): {
|
|
4
|
+
size: import("vue").ComputedRef<string>;
|
|
5
|
+
isResizing: Ref<boolean, boolean>;
|
|
6
|
+
isHorizontal: import("vue").ComputedRef<boolean>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { computed as o, ref as i, watch as x, onBeforeUnmount as H } from "vue";
|
|
2
|
+
import { useWindowSize as R, clamp as W, useEventListener as f } from "@vueuse/core";
|
|
3
|
+
import "@vft/utils";
|
|
4
|
+
import { addUnit as A } from "../../../utils/helper.js";
|
|
5
|
+
import "lodash-es";
|
|
6
|
+
import "../../form/index.js";
|
|
7
|
+
function k(t, d) {
|
|
8
|
+
const { width: z, height: g } = R(), s = o(
|
|
9
|
+
() => ["ltr", "rtl"].includes(t.direction)
|
|
10
|
+
), w = o(
|
|
11
|
+
() => ["ltr", "ttb"].includes(t.direction) ? 1 : -1
|
|
12
|
+
), h = o(
|
|
13
|
+
() => s.value ? z.value : g.value
|
|
14
|
+
), m = o(() => W(
|
|
15
|
+
u.value + w.value * a.value,
|
|
16
|
+
4,
|
|
17
|
+
h.value
|
|
18
|
+
)), u = i(0), a = i(0), r = i(!1), n = i(!1);
|
|
19
|
+
let l = [], c = [];
|
|
20
|
+
const p = () => {
|
|
21
|
+
const e = d.value?.closest(
|
|
22
|
+
'[aria-modal="true"]'
|
|
23
|
+
);
|
|
24
|
+
return e ? s.value ? e.offsetWidth : e.offsetHeight : 100;
|
|
25
|
+
};
|
|
26
|
+
x(
|
|
27
|
+
() => [t.size, t.resizable],
|
|
28
|
+
() => {
|
|
29
|
+
n.value = !1, u.value = 0, a.value = 0, v();
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
const S = (e) => {
|
|
33
|
+
t.resizable && (n.value || (u.value = p(), n.value = !0), l = [e.pageX, e.pageY], r.value = !0, c.push(
|
|
34
|
+
f(window, "mouseup", v),
|
|
35
|
+
f(window, "mousemove", b)
|
|
36
|
+
));
|
|
37
|
+
}, b = (e) => {
|
|
38
|
+
const { pageX: E, pageY: U } = e, X = E - l[0], Y = U - l[1];
|
|
39
|
+
a.value = s.value ? X : Y;
|
|
40
|
+
}, v = () => {
|
|
41
|
+
l = [], u.value = m.value, a.value = 0, r.value = !1, c.forEach((e) => e?.()), c = [];
|
|
42
|
+
}, M = f(d, "mousedown", S);
|
|
43
|
+
return H(() => {
|
|
44
|
+
M(), v();
|
|
45
|
+
}), {
|
|
46
|
+
size: o(() => n.value ? `${m.value}px` : A(t.size)),
|
|
47
|
+
isResizing: r,
|
|
48
|
+
isHorizontal: s
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
k as useResizable
|
|
53
|
+
};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface DrawerProps extends DialogProps {
|
|
3
|
-
direction?: 'ltr' | 'rtl' | 'ttb' | 'btt';
|
|
4
|
-
size?: string | number;
|
|
5
|
-
withHeader?: boolean;
|
|
6
|
-
modalFade?: boolean;
|
|
7
|
-
}
|
|
1
|
+
import type { DrawerProps } from './types';
|
|
8
2
|
declare function __VLS_template(): {
|
|
9
3
|
header?(_: {
|
|
10
4
|
close: () => void;
|
|
@@ -17,6 +11,8 @@ declare function __VLS_template(): {
|
|
|
17
11
|
};
|
|
18
12
|
declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<DrawerProps>>, {
|
|
19
13
|
close: () => void;
|
|
14
|
+
afterEnter: () => void;
|
|
15
|
+
afterLeave: () => void;
|
|
20
16
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
17
|
"update:modelValue": (value: boolean) => void;
|
|
22
18
|
close: () => void;
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { isBoolean as U, singleAttrToObj as j } from "@vft/utils";
|
|
1
|
+
import { defineComponent as F, getCurrentInstance as q, ref as m, computed as H, createBlock as A, openBlock as l, unref as e, withCtx as r, createVNode as y, Transition as j, withDirectives as U, createElementVNode as b, mergeProps as R, withModifiers as _, createElementBlock as n, createCommentVNode as s, normalizeClass as a, renderSlot as d, toDisplayString as G, normalizeStyle as J, vShow as K } from "vue";
|
|
3
2
|
import "../dialog/index.js";
|
|
4
|
-
import
|
|
3
|
+
import Q from "../focus-trap/focus-trap.vue.js";
|
|
5
4
|
import "../focus-trap/utils.js";
|
|
6
|
-
import { VftIcon as
|
|
7
|
-
import { VftOverlay as
|
|
8
|
-
import {
|
|
5
|
+
import { VftIcon as W } from "../icon/index.js";
|
|
6
|
+
import { VftOverlay as X } from "../overlay/index.js";
|
|
7
|
+
import { VftTeleport as Y } from "../teleport/index.js";
|
|
8
|
+
import { UPDATE_MODEL_EVENT as Z } from "../../constants/event.js";
|
|
9
9
|
import "@vueuse/core";
|
|
10
|
-
import {
|
|
10
|
+
import { isBoolean as x, singleAttrToObj as ee } from "@vft/utils";
|
|
11
|
+
import "../config-provider/hooks/use-global-config.js";
|
|
11
12
|
import "lodash-es";
|
|
12
13
|
import "../form/index.js";
|
|
13
|
-
import { useNamespace as
|
|
14
|
+
import { useNamespace as oe } from "../../hooks/use-namespace/index.js";
|
|
14
15
|
import "../../hooks/use-model-toggle/index.js";
|
|
15
16
|
import "@popperjs/core";
|
|
16
17
|
import "../../hooks/use-z-index/index.js";
|
|
17
|
-
import {
|
|
18
|
-
import { useDialog as
|
|
19
|
-
const
|
|
20
|
-
name: "vft-drawer"
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
import { useResizable as te } from "./composables/useResizable.js";
|
|
19
|
+
import { useDialog as le } from "../dialog/use-dialog.js";
|
|
20
|
+
const ae = ["aria-label", "aria-labelledby", "aria-describedby"], se = ["id"], re = ["id"], ne = F({
|
|
21
|
+
name: "vft-drawer",
|
|
22
|
+
inheritAttrs: !1
|
|
23
|
+
}), Fe = /* @__PURE__ */ F({
|
|
24
|
+
...ne,
|
|
23
25
|
props: {
|
|
24
26
|
direction: { default: "rtl" },
|
|
25
27
|
size: { default: "30%" },
|
|
26
28
|
withHeader: { type: Boolean, default: !0 },
|
|
27
29
|
modalFade: { type: Boolean, default: !0 },
|
|
30
|
+
resizable: { type: Boolean, default: !1 },
|
|
28
31
|
appendToBody: { type: Boolean, default: !1 },
|
|
32
|
+
appendTo: { default: "body" },
|
|
29
33
|
beforeClose: {},
|
|
30
34
|
destroyOnClose: { type: Boolean, default: !1 },
|
|
31
35
|
closeOnClickModal: { type: Boolean, default: !0 },
|
|
@@ -35,11 +39,14 @@ const _ = ["aria-label", "aria-labelledby", "aria-describedby"], x = ["id"], ee
|
|
|
35
39
|
openDelay: { default: 0 },
|
|
36
40
|
closeDelay: { default: 0 },
|
|
37
41
|
top: {},
|
|
42
|
+
modalPenetrable: { type: Boolean },
|
|
38
43
|
modelValue: { type: Boolean, default: !1 },
|
|
39
44
|
modalClass: {},
|
|
40
45
|
width: {},
|
|
41
46
|
zIndex: {},
|
|
42
47
|
trapFocus: { type: Boolean, default: !1 },
|
|
48
|
+
overflow: { type: Boolean },
|
|
49
|
+
transition: {},
|
|
43
50
|
center: { type: Boolean, default: !1 },
|
|
44
51
|
alignCenter: { type: Boolean, default: !1 },
|
|
45
52
|
closeIcon: {},
|
|
@@ -47,10 +54,13 @@ const _ = ["aria-label", "aria-labelledby", "aria-describedby"], x = ["id"], ee
|
|
|
47
54
|
draggable: { type: Boolean, default: !1 },
|
|
48
55
|
fullscreen: { type: Boolean, default: !1 },
|
|
49
56
|
showClose: { type: Boolean, default: !0 },
|
|
50
|
-
title: { default: "" }
|
|
57
|
+
title: { default: "" },
|
|
58
|
+
headerClass: {},
|
|
59
|
+
bodyClass: {},
|
|
60
|
+
footerClass: {}
|
|
51
61
|
},
|
|
52
62
|
emits: {
|
|
53
|
-
[
|
|
63
|
+
[Z]: (i) => x(i),
|
|
54
64
|
open: () => !0,
|
|
55
65
|
opened: () => !0,
|
|
56
66
|
close: () => !0,
|
|
@@ -58,134 +68,149 @@ const _ = ["aria-label", "aria-labelledby", "aria-describedby"], x = ["id"], ee
|
|
|
58
68
|
openAutoFocus: () => !0,
|
|
59
69
|
closeAutoFocus: () => !0
|
|
60
70
|
},
|
|
61
|
-
setup(
|
|
62
|
-
const
|
|
63
|
-
afterEnter:
|
|
64
|
-
afterLeave:
|
|
65
|
-
beforeLeave:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} = Z(I.props, u), C = k(), $ = m(() => l.direction === "rtl" || l.direction === "ltr"), b = m(() => W(l.size)), L = m(() => j(l.closeIcon, "icon", {
|
|
71
|
+
setup(i, { expose: T }) {
|
|
72
|
+
const C = q(), f = m(), v = m(), B = m(), t = oe("drawer"), {
|
|
73
|
+
afterEnter: k,
|
|
74
|
+
afterLeave: h,
|
|
75
|
+
beforeLeave: I,
|
|
76
|
+
visible: u,
|
|
77
|
+
rendered: E,
|
|
78
|
+
titleId: p,
|
|
79
|
+
bodyId: g,
|
|
80
|
+
zIndex: w,
|
|
81
|
+
onModalClick: V,
|
|
82
|
+
onOpenAutoFocus: D,
|
|
83
|
+
onCloseAutoFocus: L,
|
|
84
|
+
onFocusoutPrevented: O,
|
|
85
|
+
onCloseRequested: P,
|
|
86
|
+
handleClose: c
|
|
87
|
+
} = le(C.props, f), {
|
|
88
|
+
isHorizontal: S,
|
|
89
|
+
size: $,
|
|
90
|
+
isResizing: N
|
|
91
|
+
} = te(C.props, B), M = H(() => ee(i.closeIcon, "icon", {
|
|
83
92
|
icon: "icon-close",
|
|
84
93
|
pointer: !0
|
|
85
94
|
}));
|
|
86
|
-
return
|
|
87
|
-
close:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
return T({
|
|
96
|
+
close: c,
|
|
97
|
+
afterEnter: k,
|
|
98
|
+
afterLeave: h
|
|
99
|
+
}), (o, z) => (l(), A(e(Y), {
|
|
100
|
+
to: o.appendTo,
|
|
101
|
+
disabled: o.appendTo !== "body" ? !1 : !o.appendToBody
|
|
91
102
|
}, {
|
|
92
|
-
default:
|
|
93
|
-
y(
|
|
103
|
+
default: r(() => [
|
|
104
|
+
y(j, {
|
|
94
105
|
name: e(t).b("fade"),
|
|
95
|
-
onAfterEnter: e(
|
|
96
|
-
onAfterLeave: e(
|
|
97
|
-
onBeforeLeave: e(
|
|
106
|
+
onAfterEnter: e(k),
|
|
107
|
+
onAfterLeave: e(h),
|
|
108
|
+
onBeforeLeave: e(I)
|
|
98
109
|
}, {
|
|
99
|
-
default:
|
|
100
|
-
|
|
110
|
+
default: r(() => [
|
|
111
|
+
U(y(e(X), {
|
|
101
112
|
mask: o.modal,
|
|
102
|
-
"overlay-class": o.modalClass,
|
|
103
|
-
"z-index": e(
|
|
104
|
-
onClick: e(
|
|
113
|
+
"overlay-class": [e(t).is("drawer"), o.modalClass ?? ""],
|
|
114
|
+
"z-index": e(w),
|
|
115
|
+
onClick: e(V)
|
|
105
116
|
}, {
|
|
106
|
-
default:
|
|
107
|
-
y(e(
|
|
117
|
+
default: r(() => [
|
|
118
|
+
y(e(Q), {
|
|
108
119
|
loop: "",
|
|
109
|
-
trapped: e(
|
|
110
|
-
"focus-trap-el":
|
|
111
|
-
"focus-start-el":
|
|
112
|
-
|
|
120
|
+
trapped: e(u),
|
|
121
|
+
"focus-trap-el": f.value,
|
|
122
|
+
"focus-start-el": v.value,
|
|
123
|
+
onFocusAfterTrapped: e(D),
|
|
124
|
+
onFocusAfterReleased: e(L),
|
|
125
|
+
onFocusoutPrevented: e(O),
|
|
126
|
+
onReleaseRequested: e(P)
|
|
113
127
|
}, {
|
|
114
|
-
default:
|
|
115
|
-
|
|
128
|
+
default: r(() => [
|
|
129
|
+
b("div", R({
|
|
116
130
|
ref_key: "drawerRef",
|
|
117
|
-
ref:
|
|
131
|
+
ref: f,
|
|
118
132
|
"aria-modal": "true",
|
|
119
133
|
"aria-label": o.title || void 0,
|
|
120
|
-
"aria-labelledby": o.title ? void 0 : e(
|
|
121
|
-
"aria-describedby": e(
|
|
134
|
+
"aria-labelledby": o.title ? void 0 : e(p),
|
|
135
|
+
"aria-describedby": e(g)
|
|
122
136
|
}, o.$attrs, {
|
|
123
|
-
class: [
|
|
124
|
-
|
|
137
|
+
class: [
|
|
138
|
+
e(t).b(),
|
|
139
|
+
o.direction,
|
|
140
|
+
e(u) && "open",
|
|
141
|
+
e(t).is("dragging", e(N))
|
|
142
|
+
],
|
|
143
|
+
style: { [e(S) ? "width" : "height"]: e($) },
|
|
125
144
|
role: "dialog",
|
|
126
|
-
onClick:
|
|
145
|
+
onClick: z[0] || (z[0] = _(() => {
|
|
127
146
|
}, ["stop"]))
|
|
128
147
|
}), [
|
|
129
|
-
|
|
148
|
+
b("span", {
|
|
130
149
|
ref_key: "focusStartRef",
|
|
131
|
-
ref:
|
|
132
|
-
class:
|
|
150
|
+
ref: v,
|
|
151
|
+
class: a(e(t).e("sr-focus")),
|
|
133
152
|
tabindex: "-1"
|
|
134
153
|
}, null, 2),
|
|
135
|
-
o.withHeader ? (
|
|
154
|
+
o.withHeader ? (l(), n("header", {
|
|
136
155
|
key: 0,
|
|
137
|
-
class:
|
|
156
|
+
class: a([e(t).e("header"), o.headerClass])
|
|
138
157
|
}, [
|
|
139
|
-
o.$slots.title ?
|
|
158
|
+
o.$slots.title ? d(o.$slots, "title", { key: 1 }) : d(o.$slots, "header", {
|
|
140
159
|
key: 0,
|
|
141
|
-
close: e(
|
|
142
|
-
titleId: e(
|
|
160
|
+
close: e(c),
|
|
161
|
+
titleId: e(p),
|
|
143
162
|
titleClass: e(t).e("title")
|
|
144
163
|
}, () => [
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
id: e(c),
|
|
164
|
+
b("span", {
|
|
165
|
+
id: e(p),
|
|
148
166
|
role: "heading",
|
|
149
|
-
class:
|
|
150
|
-
},
|
|
167
|
+
class: a(e(t).e("title"))
|
|
168
|
+
}, G(o.title), 11, se)
|
|
151
169
|
]),
|
|
152
|
-
o.showClose ? (
|
|
170
|
+
o.showClose ? (l(), A(e(W), R({
|
|
153
171
|
key: 2,
|
|
154
|
-
onClick: e(
|
|
155
|
-
},
|
|
172
|
+
onClick: e(c)
|
|
173
|
+
}, M.value, {
|
|
156
174
|
class: e(t).e("close")
|
|
157
175
|
}), null, 16, ["onClick", "class"])) : s("", !0)
|
|
158
176
|
], 2)) : s("", !0),
|
|
159
|
-
e(
|
|
177
|
+
e(E) ? (l(), n("div", {
|
|
160
178
|
key: 1,
|
|
161
|
-
id: e(
|
|
162
|
-
class:
|
|
179
|
+
id: e(g),
|
|
180
|
+
class: a([e(t).e("body"), o.bodyClass])
|
|
163
181
|
}, [
|
|
164
|
-
|
|
165
|
-
], 10,
|
|
166
|
-
o.$slots.footer ? (
|
|
182
|
+
d(o.$slots, "default")
|
|
183
|
+
], 10, re)) : s("", !0),
|
|
184
|
+
o.$slots.footer ? (l(), n("div", {
|
|
167
185
|
key: 2,
|
|
168
|
-
class:
|
|
186
|
+
class: a([e(t).e("footer"), o.footerClass])
|
|
169
187
|
}, [
|
|
170
|
-
|
|
171
|
-
], 2)) : s("", !0)
|
|
172
|
-
|
|
188
|
+
d(o.$slots, "footer")
|
|
189
|
+
], 2)) : s("", !0),
|
|
190
|
+
o.resizable ? (l(), n("div", {
|
|
191
|
+
key: 3,
|
|
192
|
+
ref_key: "draggerRef",
|
|
193
|
+
ref: B,
|
|
194
|
+
style: J({ zIndex: e(w) }),
|
|
195
|
+
class: a(e(t).e("dragger"))
|
|
196
|
+
}, null, 6)) : s("", !0)
|
|
197
|
+
], 16, ae)
|
|
173
198
|
]),
|
|
174
199
|
_: 3
|
|
175
|
-
}, 8, ["trapped", "focus-trap-el", "focus-start-el", "onReleaseRequested"])
|
|
200
|
+
}, 8, ["trapped", "focus-trap-el", "focus-start-el", "onFocusAfterTrapped", "onFocusAfterReleased", "onFocusoutPrevented", "onReleaseRequested"])
|
|
176
201
|
]),
|
|
177
202
|
_: 3
|
|
178
203
|
}, 8, ["mask", "overlay-class", "z-index", "onClick"]), [
|
|
179
|
-
[
|
|
204
|
+
[K, e(u)]
|
|
180
205
|
])
|
|
181
206
|
]),
|
|
182
207
|
_: 3
|
|
183
208
|
}, 8, ["name", "onAfterEnter", "onAfterLeave", "onBeforeLeave"])
|
|
184
209
|
]),
|
|
185
210
|
_: 3
|
|
186
|
-
}, 8, ["disabled"]));
|
|
211
|
+
}, 8, ["to", "disabled"]));
|
|
187
212
|
}
|
|
188
213
|
});
|
|
189
214
|
export {
|
|
190
|
-
|
|
215
|
+
Fe as default
|
|
191
216
|
};
|