@v-c/dialog 0.0.2 → 0.0.4
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/dist/Dialog/Content/Panel.cjs +37 -45
- package/dist/Dialog/Content/Panel.d.ts +2 -1
- package/dist/Dialog/Content/Panel.js +22 -33
- package/dist/Dialog/Content/index.cjs +16 -3
- package/dist/Dialog/Content/index.js +10 -0
- package/dist/Dialog/Mask.cjs +8 -5
- package/dist/Dialog/index.cjs +20 -24
- package/dist/Dialog/index.js +6 -12
- package/dist/DialogWrap.cjs +22 -9
- package/dist/DialogWrap.js +15 -5
- package/dist/IDialogPropTypes.cjs +1 -0
- package/dist/IDialogPropTypes.d.ts +1 -0
- package/dist/context.cjs +3 -1
- package/dist/context.d.ts +2 -1
- package/dist/context.js +2 -1
- package/dist/index.cjs +4 -1
- package/dist/util.cjs +1 -0
- package/package.json +3 -3
|
@@ -1,52 +1,41 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
|
|
3
6
|
const require_context = require("../../context.cjs");
|
|
4
7
|
let vue = require("vue");
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
width: 0,
|
|
11
|
-
height: 0,
|
|
12
|
-
overflow: "hidden",
|
|
13
|
-
outline: "none"
|
|
14
|
-
};
|
|
15
|
-
var entityStyle = { outline: "none" };
|
|
8
|
+
let _v_c_util = require("@v-c/util");
|
|
9
|
+
let _v_c_util_dist_pickAttrs = require("@v-c/util/dist/pickAttrs");
|
|
10
|
+
_v_c_util_dist_pickAttrs = require_rolldown_runtime.__toESM(_v_c_util_dist_pickAttrs);
|
|
11
|
+
let _v_c_util_dist_Dom_focus = require("@v-c/util/dist/Dom/focus");
|
|
12
|
+
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
16
13
|
var Panel = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots }) => {
|
|
17
14
|
const { setPanel } = require_context.useGetRefContext();
|
|
18
|
-
const
|
|
15
|
+
const internalRef = (0, vue.shallowRef)();
|
|
19
16
|
const mergeRefFun = (el) => {
|
|
20
|
-
|
|
21
|
-
setPanel(el);
|
|
17
|
+
internalRef.value = el;
|
|
18
|
+
setPanel?.(el);
|
|
22
19
|
props?.holderRef?.(el);
|
|
23
20
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
sentinelStartRef.value?.focus?.({ preventScroll: true });
|
|
29
|
-
},
|
|
30
|
-
changeActive: (next) => {
|
|
31
|
-
const { activeElement } = document;
|
|
32
|
-
if (next && activeElement === sentinelEndRef.value) sentinelStartRef.value?.focus?.({ preventScroll: true });
|
|
33
|
-
else if (!next && activeElement === sentinelStartRef.value) sentinelEndRef.value?.focus?.({ preventScroll: true });
|
|
34
|
-
}
|
|
35
|
-
});
|
|
21
|
+
(0, _v_c_util_dist_Dom_focus.useLockFocus)((0, vue.computed)(() => !!props.visible && !!props.isFixedPos && props.focusTrap !== false), () => internalRef.value);
|
|
22
|
+
expose({ focus: () => {
|
|
23
|
+
internalRef.value?.focus?.({ preventScroll: true });
|
|
24
|
+
} });
|
|
36
25
|
return () => {
|
|
37
26
|
const { width, height, footer, prefixCls, classNames: modalClassNames, styles: modalStyles, title, closable, closeIcon, bodyProps, bodyStyle, ariaId, style, className, forceRender, onClose, onMouseDown, onMouseUp, modalRender, animationVisible } = props;
|
|
38
27
|
const contentStyle = {};
|
|
39
|
-
if (width !== void 0) contentStyle.width = (0,
|
|
40
|
-
if (height !== void 0) contentStyle.height = (0,
|
|
28
|
+
if (width !== void 0) contentStyle.width = (0, _v_c_util_dist_props_util.getStylePxValue)(width);
|
|
29
|
+
if (height !== void 0) contentStyle.height = (0, _v_c_util_dist_props_util.getStylePxValue)(height);
|
|
41
30
|
const footerNode = footer ? (0, vue.createVNode)("div", {
|
|
42
|
-
"class": (0,
|
|
31
|
+
"class": (0, _v_c_util.classNames)(`${prefixCls}-footer`, modalClassNames?.footer),
|
|
43
32
|
"style": { ...modalStyles?.footer }
|
|
44
33
|
}, [footer]) : null;
|
|
45
34
|
const headerNode = title ? (0, vue.createVNode)("div", {
|
|
46
|
-
"class": (0,
|
|
35
|
+
"class": (0, _v_c_util.classNames)(`${prefixCls}-header`, modalClassNames?.header),
|
|
47
36
|
"style": { ...modalStyles?.header }
|
|
48
37
|
}, [(0, vue.createVNode)("div", {
|
|
49
|
-
"class": (0,
|
|
38
|
+
"class": (0, _v_c_util.clsx)(`${prefixCls}-title`, modalClassNames?.title),
|
|
50
39
|
"id": ariaId,
|
|
51
40
|
"style": { ...modalStyles?.title }
|
|
52
41
|
}, [title])]) : null;
|
|
@@ -56,7 +45,7 @@ var Panel = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
56
45
|
return {};
|
|
57
46
|
};
|
|
58
47
|
const closableObj = closableFun();
|
|
59
|
-
const ariaProps = (0,
|
|
48
|
+
const ariaProps = (0, _v_c_util_dist_pickAttrs.default)(closableObj, true);
|
|
60
49
|
const closeBtnIsDisabled = typeof closable === "object" && closable?.disabled;
|
|
61
50
|
const closerNode = closable ? (0, vue.createVNode)("button", (0, vue.mergeProps)({
|
|
62
51
|
"type": "button",
|
|
@@ -67,13 +56,13 @@ var Panel = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
67
56
|
"disabled": closeBtnIsDisabled
|
|
68
57
|
}), [closableObj.closeIcon]) : null;
|
|
69
58
|
const content = (0, vue.createVNode)("div", {
|
|
70
|
-
"class": (0,
|
|
59
|
+
"class": (0, _v_c_util.classNames)(`${prefixCls}-container`, modalClassNames?.container),
|
|
71
60
|
"style": modalStyles?.container
|
|
72
61
|
}, [
|
|
73
62
|
closerNode,
|
|
74
63
|
headerNode,
|
|
75
64
|
(0, vue.createVNode)("div", (0, vue.mergeProps)({
|
|
76
|
-
"class": (0,
|
|
65
|
+
"class": (0, _v_c_util.classNames)(`${prefixCls}-body`, modalClassNames?.body),
|
|
77
66
|
"style": {
|
|
78
67
|
...bodyStyle,
|
|
79
68
|
...modalStyles?.body
|
|
@@ -97,16 +86,9 @@ var Panel = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
97
86
|
},
|
|
98
87
|
"class": [prefixCls, className],
|
|
99
88
|
"onMousedown": onMouseDown,
|
|
100
|
-
"onMouseup": onMouseUp
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
"tabindex": 0,
|
|
104
|
-
"style": entityStyle
|
|
105
|
-
}, [renderContent()]), (0, vue.createVNode)("div", {
|
|
106
|
-
"tabindex": 0,
|
|
107
|
-
"ref": sentinelEndRef,
|
|
108
|
-
"style": sentinelStyle
|
|
109
|
-
}, null)]);
|
|
89
|
+
"onMouseup": onMouseUp,
|
|
90
|
+
"tabindex": -1
|
|
91
|
+
}), [renderContent()]);
|
|
110
92
|
};
|
|
111
93
|
}, {
|
|
112
94
|
props: {
|
|
@@ -135,6 +117,11 @@ var Panel = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
135
117
|
required: false,
|
|
136
118
|
default: void 0
|
|
137
119
|
},
|
|
120
|
+
isFixedPos: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
required: false,
|
|
123
|
+
default: void 0
|
|
124
|
+
},
|
|
138
125
|
className: {
|
|
139
126
|
type: String,
|
|
140
127
|
required: false,
|
|
@@ -357,6 +344,11 @@ var Panel = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
357
344
|
required: false,
|
|
358
345
|
default: void 0
|
|
359
346
|
},
|
|
347
|
+
focusTrap: {
|
|
348
|
+
type: Boolean,
|
|
349
|
+
required: false,
|
|
350
|
+
default: void 0
|
|
351
|
+
},
|
|
360
352
|
panelRef: {
|
|
361
353
|
required: false,
|
|
362
354
|
default: void 0
|
|
@@ -6,10 +6,11 @@ export interface PanelProps extends Omit<IDialogPropTypes, 'getOpenCount'> {
|
|
|
6
6
|
onMouseDown?: (e: MouseEvent) => void;
|
|
7
7
|
onMouseUp?: MouseEventHandler;
|
|
8
8
|
holderRef?: (el: HTMLDivElement) => void;
|
|
9
|
+
/** Used for focus lock. When true and open, focus will lock into the panel */
|
|
10
|
+
isFixedPos?: boolean;
|
|
9
11
|
}
|
|
10
12
|
export interface ContentRef {
|
|
11
13
|
focus: () => void;
|
|
12
|
-
changeActive: (next: boolean) => void;
|
|
13
14
|
}
|
|
14
15
|
declare const Panel: import('vue').DefineSetupFnComponent<PanelProps & {
|
|
15
16
|
animationVisible: boolean;
|
|
@@ -1,35 +1,21 @@
|
|
|
1
1
|
import { useGetRefContext } from "../../context.js";
|
|
2
|
-
import { createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
2
|
+
import { computed, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
3
3
|
import { classNames, clsx } from "@v-c/util";
|
|
4
4
|
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
5
|
+
import { useLockFocus } from "@v-c/util/dist/Dom/focus";
|
|
5
6
|
import { getStylePxValue } from "@v-c/util/dist/props-util";
|
|
6
|
-
var sentinelStyle = {
|
|
7
|
-
width: 0,
|
|
8
|
-
height: 0,
|
|
9
|
-
overflow: "hidden",
|
|
10
|
-
outline: "none"
|
|
11
|
-
};
|
|
12
|
-
var entityStyle = { outline: "none" };
|
|
13
7
|
var Panel_default = /* @__PURE__ */ defineComponent((props, { expose, slots }) => {
|
|
14
8
|
const { setPanel } = useGetRefContext();
|
|
15
|
-
const
|
|
9
|
+
const internalRef = shallowRef();
|
|
16
10
|
const mergeRefFun = (el) => {
|
|
17
|
-
|
|
18
|
-
setPanel(el);
|
|
11
|
+
internalRef.value = el;
|
|
12
|
+
setPanel?.(el);
|
|
19
13
|
props?.holderRef?.(el);
|
|
20
14
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
sentinelStartRef.value?.focus?.({ preventScroll: true });
|
|
26
|
-
},
|
|
27
|
-
changeActive: (next) => {
|
|
28
|
-
const { activeElement } = document;
|
|
29
|
-
if (next && activeElement === sentinelEndRef.value) sentinelStartRef.value?.focus?.({ preventScroll: true });
|
|
30
|
-
else if (!next && activeElement === sentinelStartRef.value) sentinelEndRef.value?.focus?.({ preventScroll: true });
|
|
31
|
-
}
|
|
32
|
-
});
|
|
15
|
+
useLockFocus(computed(() => !!props.visible && !!props.isFixedPos && props.focusTrap !== false), () => internalRef.value);
|
|
16
|
+
expose({ focus: () => {
|
|
17
|
+
internalRef.value?.focus?.({ preventScroll: true });
|
|
18
|
+
} });
|
|
33
19
|
return () => {
|
|
34
20
|
const { width, height, footer, prefixCls, classNames: modalClassNames, styles: modalStyles, title, closable, closeIcon, bodyProps, bodyStyle, ariaId, style, className, forceRender, onClose, onMouseDown, onMouseUp, modalRender, animationVisible } = props;
|
|
35
21
|
const contentStyle = {};
|
|
@@ -94,16 +80,9 @@ var Panel_default = /* @__PURE__ */ defineComponent((props, { expose, slots }) =
|
|
|
94
80
|
},
|
|
95
81
|
"class": [prefixCls, className],
|
|
96
82
|
"onMousedown": onMouseDown,
|
|
97
|
-
"onMouseup": onMouseUp
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"tabindex": 0,
|
|
101
|
-
"style": entityStyle
|
|
102
|
-
}, [renderContent()]), createVNode("div", {
|
|
103
|
-
"tabindex": 0,
|
|
104
|
-
"ref": sentinelEndRef,
|
|
105
|
-
"style": sentinelStyle
|
|
106
|
-
}, null)]);
|
|
83
|
+
"onMouseup": onMouseUp,
|
|
84
|
+
"tabindex": -1
|
|
85
|
+
}), [renderContent()]);
|
|
107
86
|
};
|
|
108
87
|
}, {
|
|
109
88
|
props: {
|
|
@@ -132,6 +111,11 @@ var Panel_default = /* @__PURE__ */ defineComponent((props, { expose, slots }) =
|
|
|
132
111
|
required: false,
|
|
133
112
|
default: void 0
|
|
134
113
|
},
|
|
114
|
+
isFixedPos: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
required: false,
|
|
117
|
+
default: void 0
|
|
118
|
+
},
|
|
135
119
|
className: {
|
|
136
120
|
type: String,
|
|
137
121
|
required: false,
|
|
@@ -354,6 +338,11 @@ var Panel_default = /* @__PURE__ */ defineComponent((props, { expose, slots }) =
|
|
|
354
338
|
required: false,
|
|
355
339
|
default: void 0
|
|
356
340
|
},
|
|
341
|
+
focusTrap: {
|
|
342
|
+
type: Boolean,
|
|
343
|
+
required: false,
|
|
344
|
+
default: void 0
|
|
345
|
+
},
|
|
357
346
|
panelRef: {
|
|
358
347
|
required: false,
|
|
359
348
|
default: void 0
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
|
|
3
6
|
const require_util = require("../../util.cjs");
|
|
4
7
|
const require_Panel = require("./Panel.cjs");
|
|
5
8
|
let vue = require("vue");
|
|
6
|
-
let
|
|
9
|
+
let _v_c_util_dist_utils_transition = require("@v-c/util/dist/utils/transition");
|
|
7
10
|
var Content = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
8
11
|
const dialogRef = (0, vue.shallowRef)();
|
|
9
12
|
const transformOrigin = (0, vue.shallowRef)("");
|
|
@@ -24,7 +27,7 @@ var Content = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
|
24
27
|
const { prefixCls, className, style, visible, destroyOnHidden, onVisibleChanged, ariaId, title, motionName } = props;
|
|
25
28
|
const contentStyle = {};
|
|
26
29
|
if (transformOrigin.value) contentStyle.transformOrigin = transformOrigin.value;
|
|
27
|
-
return (0, vue.createVNode)(vue.Transition, (0, vue.mergeProps)((0,
|
|
30
|
+
return (0, vue.createVNode)(vue.Transition, (0, vue.mergeProps)((0, _v_c_util_dist_utils_transition.getTransitionProps)(motionName), {
|
|
28
31
|
"onBeforeEnter": onPrepare,
|
|
29
32
|
"onAfterEnter": () => onVisibleChanged?.(true),
|
|
30
33
|
"onAfterLeave": () => {
|
|
@@ -83,6 +86,11 @@ var Content = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
|
83
86
|
required: false,
|
|
84
87
|
default: void 0
|
|
85
88
|
},
|
|
89
|
+
isFixedPos: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
required: false,
|
|
92
|
+
default: void 0
|
|
93
|
+
},
|
|
86
94
|
className: {
|
|
87
95
|
type: String,
|
|
88
96
|
required: false,
|
|
@@ -305,6 +313,11 @@ var Content = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
|
305
313
|
required: false,
|
|
306
314
|
default: void 0
|
|
307
315
|
},
|
|
316
|
+
focusTrap: {
|
|
317
|
+
type: Boolean,
|
|
318
|
+
required: false,
|
|
319
|
+
default: void 0
|
|
320
|
+
},
|
|
308
321
|
panelRef: {
|
|
309
322
|
required: false,
|
|
310
323
|
default: void 0
|
|
@@ -81,6 +81,11 @@ var Content_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
81
81
|
required: false,
|
|
82
82
|
default: void 0
|
|
83
83
|
},
|
|
84
|
+
isFixedPos: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
required: false,
|
|
87
|
+
default: void 0
|
|
88
|
+
},
|
|
84
89
|
className: {
|
|
85
90
|
type: String,
|
|
86
91
|
required: false,
|
|
@@ -303,6 +308,11 @@ var Content_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
303
308
|
required: false,
|
|
304
309
|
default: void 0
|
|
305
310
|
},
|
|
311
|
+
focusTrap: {
|
|
312
|
+
type: Boolean,
|
|
313
|
+
required: false,
|
|
314
|
+
default: void 0
|
|
315
|
+
},
|
|
306
316
|
panelRef: {
|
|
307
317
|
required: false,
|
|
308
318
|
default: void 0
|
package/dist/Dialog/Mask.cjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
6
|
let vue = require("vue");
|
|
4
|
-
let
|
|
5
|
-
let
|
|
7
|
+
let _v_c_util = require("@v-c/util");
|
|
8
|
+
let _v_c_util_dist_utils_transition = require("@v-c/util/dist/utils/transition");
|
|
6
9
|
var Mask = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
7
10
|
return () => {
|
|
8
11
|
const { maskProps, prefixCls, className, style, visible, motionName } = props;
|
|
9
|
-
return (0, vue.createVNode)(vue.Transition, (0, vue.mergeProps)((0,
|
|
12
|
+
return (0, vue.createVNode)(vue.Transition, (0, vue.mergeProps)((0, _v_c_util_dist_utils_transition.getTransitionProps)(motionName), { "key": "mask" }), { default: () => [visible && (0, vue.createVNode)("div", (0, vue.mergeProps)({
|
|
10
13
|
"style": [style],
|
|
11
|
-
"class": (0,
|
|
14
|
+
"class": (0, _v_c_util.classNames)(`${prefixCls}-mask`, className)
|
|
12
15
|
}, maskProps), null)] });
|
|
13
16
|
};
|
|
14
17
|
}, {
|
package/dist/Dialog/index.cjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
6
|
const require_util = require("../util.cjs");
|
|
4
7
|
const require_index = require("./Content/index.cjs");
|
|
5
8
|
const require_Mask = require("./Mask.cjs");
|
|
6
9
|
let vue = require("vue");
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
let __v_c_util_dist_pickAttrs = require("@v-c/util/dist/pickAttrs");
|
|
13
|
-
__v_c_util_dist_pickAttrs = require_rolldown_runtime.__toESM(__v_c_util_dist_pickAttrs);
|
|
10
|
+
let _v_c_util = require("@v-c/util");
|
|
11
|
+
let _v_c_util_dist_Dom_contains = require("@v-c/util/dist/Dom/contains");
|
|
12
|
+
_v_c_util_dist_Dom_contains = require_rolldown_runtime.__toESM(_v_c_util_dist_Dom_contains);
|
|
13
|
+
let _v_c_util_dist_pickAttrs = require("@v-c/util/dist/pickAttrs");
|
|
14
|
+
_v_c_util_dist_pickAttrs = require_rolldown_runtime.__toESM(_v_c_util_dist_pickAttrs);
|
|
14
15
|
var Dialog = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots }) => {
|
|
15
16
|
if (process.env.NODE_ENV !== "production") {
|
|
16
17
|
[
|
|
@@ -18,9 +19,9 @@ var Dialog = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
18
19
|
"bodyStyle",
|
|
19
20
|
"maskStyle"
|
|
20
21
|
].forEach((prop) => {
|
|
21
|
-
(0,
|
|
22
|
+
(0, _v_c_util.warning)(!(prop in props && props[prop]), `${prop} is deprecated, please use styles instead.`);
|
|
22
23
|
});
|
|
23
|
-
if ("wrapClassName" in props && props.wrapClassName) (0,
|
|
24
|
+
if ("wrapClassName" in props && props.wrapClassName) (0, _v_c_util.warning)(false, `wrapClassName is deprecated, please use classNames instead.`);
|
|
24
25
|
}
|
|
25
26
|
const lastOutSideActiveElementRef = (0, vue.shallowRef)(null);
|
|
26
27
|
const wrapperRef = (0, vue.shallowRef)();
|
|
@@ -28,10 +29,10 @@ var Dialog = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
28
29
|
const animatedVisible = (0, vue.shallowRef)(props.visible);
|
|
29
30
|
const ariaId = (0, vue.useId)();
|
|
30
31
|
function saveLastOutSideActiveElementRef() {
|
|
31
|
-
if (!(0,
|
|
32
|
+
if (!(0, _v_c_util_dist_Dom_contains.default)(wrapperRef.value, document.activeElement)) lastOutSideActiveElementRef.value = document.activeElement;
|
|
32
33
|
}
|
|
33
34
|
function focusDialogContent() {
|
|
34
|
-
if (!(0,
|
|
35
|
+
if (!(0, _v_c_util_dist_Dom_contains.default)(wrapperRef.value, document.activeElement)) contentRef.value?.focus?.();
|
|
35
36
|
}
|
|
36
37
|
function onDialogVisibleChanged(newVisible) {
|
|
37
38
|
if (newVisible) focusDialogContent();
|
|
@@ -69,13 +70,6 @@ var Dialog = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
69
70
|
else if (wrapperRef.value === e.target) onInternalClose(e);
|
|
70
71
|
};
|
|
71
72
|
}, { immediate: true });
|
|
72
|
-
function onWrapperKeyDown(e) {
|
|
73
|
-
if (props.keyboard && e === __v_c_util_dist_KeyCode.default.ESC) {
|
|
74
|
-
e.stopPropagation();
|
|
75
|
-
onInternalClose(e);
|
|
76
|
-
}
|
|
77
|
-
if (props.visible && e.keyCode === __v_c_util_dist_KeyCode.default.TAB) contentRef.value?.changeActive?.(!e.shiftKey);
|
|
78
|
-
}
|
|
79
73
|
(0, vue.watch)(() => props.visible, () => {
|
|
80
74
|
if (props.visible) {
|
|
81
75
|
animatedVisible.value = true;
|
|
@@ -94,7 +88,7 @@ var Dialog = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
94
88
|
...modalStyles?.wrapper,
|
|
95
89
|
display: !animatedVisible.value ? "none" : void 0
|
|
96
90
|
};
|
|
97
|
-
return (0, vue.createVNode)("div", (0, vue.mergeProps)({ "class": [`${prefixCls}-root`, rootClassName] }, (0,
|
|
91
|
+
return (0, vue.createVNode)("div", (0, vue.mergeProps)({ "class": [`${prefixCls}-root`, rootClassName] }, (0, _v_c_util_dist_pickAttrs.default)(props, { data: true })), [(0, vue.createVNode)(require_Mask.default, {
|
|
98
92
|
"prefixCls": prefixCls,
|
|
99
93
|
"visible": !!(mask && visible),
|
|
100
94
|
"motionName": require_util.getMotionName(prefixCls, maskTransitionName, maskAnimation),
|
|
@@ -106,8 +100,6 @@ var Dialog = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
106
100
|
"maskProps": maskProps,
|
|
107
101
|
"className": modalClassNames?.mask
|
|
108
102
|
}, null), (0, vue.createVNode)("div", (0, vue.mergeProps)({
|
|
109
|
-
"tabindex": -1,
|
|
110
|
-
"onKeydown": onWrapperKeyDown,
|
|
111
103
|
"class": [
|
|
112
104
|
`${prefixCls}-wrap`,
|
|
113
105
|
wrapClassName,
|
|
@@ -360,14 +352,18 @@ var Dialog = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots })
|
|
|
360
352
|
required: false,
|
|
361
353
|
default: void 0
|
|
362
354
|
},
|
|
355
|
+
focusTrap: {
|
|
356
|
+
type: Boolean,
|
|
357
|
+
required: false,
|
|
358
|
+
default: void 0
|
|
359
|
+
},
|
|
363
360
|
panelRef: {
|
|
364
361
|
required: false,
|
|
365
362
|
default: void 0
|
|
366
363
|
}
|
|
367
364
|
}, {
|
|
368
365
|
prefixCls: "vc-dialog",
|
|
369
|
-
visible:
|
|
370
|
-
keyboard: true,
|
|
366
|
+
visible: false,
|
|
371
367
|
focusTriggerAfterClose: true,
|
|
372
368
|
closable: true,
|
|
373
369
|
mask: true,
|
package/dist/Dialog/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import Mask_default from "./Mask.js";
|
|
|
4
4
|
import { createVNode, defineComponent, mergeDefaults, mergeProps, onUnmounted, shallowRef, useId, watch } from "vue";
|
|
5
5
|
import { warning } from "@v-c/util";
|
|
6
6
|
import contains from "@v-c/util/dist/Dom/contains";
|
|
7
|
-
import KeyCode from "@v-c/util/dist/KeyCode";
|
|
8
7
|
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
9
8
|
var Dialog_default = /* @__PURE__ */ defineComponent((props, { expose, slots }) => {
|
|
10
9
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -64,13 +63,6 @@ var Dialog_default = /* @__PURE__ */ defineComponent((props, { expose, slots })
|
|
|
64
63
|
else if (wrapperRef.value === e.target) onInternalClose(e);
|
|
65
64
|
};
|
|
66
65
|
}, { immediate: true });
|
|
67
|
-
function onWrapperKeyDown(e) {
|
|
68
|
-
if (props.keyboard && e === KeyCode.ESC) {
|
|
69
|
-
e.stopPropagation();
|
|
70
|
-
onInternalClose(e);
|
|
71
|
-
}
|
|
72
|
-
if (props.visible && e.keyCode === KeyCode.TAB) contentRef.value?.changeActive?.(!e.shiftKey);
|
|
73
|
-
}
|
|
74
66
|
watch(() => props.visible, () => {
|
|
75
67
|
if (props.visible) {
|
|
76
68
|
animatedVisible.value = true;
|
|
@@ -101,8 +93,6 @@ var Dialog_default = /* @__PURE__ */ defineComponent((props, { expose, slots })
|
|
|
101
93
|
"maskProps": maskProps,
|
|
102
94
|
"className": modalClassNames?.mask
|
|
103
95
|
}, null), createVNode("div", mergeProps({
|
|
104
|
-
"tabindex": -1,
|
|
105
|
-
"onKeydown": onWrapperKeyDown,
|
|
106
96
|
"class": [
|
|
107
97
|
`${prefixCls}-wrap`,
|
|
108
98
|
wrapClassName,
|
|
@@ -355,14 +345,18 @@ var Dialog_default = /* @__PURE__ */ defineComponent((props, { expose, slots })
|
|
|
355
345
|
required: false,
|
|
356
346
|
default: void 0
|
|
357
347
|
},
|
|
348
|
+
focusTrap: {
|
|
349
|
+
type: Boolean,
|
|
350
|
+
required: false,
|
|
351
|
+
default: void 0
|
|
352
|
+
},
|
|
358
353
|
panelRef: {
|
|
359
354
|
required: false,
|
|
360
355
|
default: void 0
|
|
361
356
|
}
|
|
362
357
|
}, {
|
|
363
358
|
prefixCls: "vc-dialog",
|
|
364
|
-
visible:
|
|
365
|
-
keyboard: true,
|
|
359
|
+
visible: false,
|
|
366
360
|
focusTriggerAfterClose: true,
|
|
367
361
|
closable: true,
|
|
368
362
|
mask: true,
|
package/dist/DialogWrap.cjs
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
3
6
|
const require_context = require("./context.cjs");
|
|
4
7
|
const require_index = require("./Dialog/index.cjs");
|
|
5
8
|
let vue = require("vue");
|
|
6
|
-
let
|
|
7
|
-
|
|
9
|
+
let _v_c_portal = require("@v-c/portal");
|
|
10
|
+
_v_c_portal = require_rolldown_runtime.__toESM(_v_c_portal);
|
|
8
11
|
var DialogWrap = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
9
12
|
const animatedVisible = (0, vue.shallowRef)(false);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
require_context.useRefProvide(props);
|
|
14
|
+
const onEsc = ({ top, event }) => {
|
|
15
|
+
const { keyboard = true } = props;
|
|
16
|
+
if (top && keyboard) {
|
|
17
|
+
event.stopPropagation();
|
|
18
|
+
props?.onClose?.(event);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
14
21
|
(0, vue.watch)(() => props.visible, () => {
|
|
15
22
|
if (props.visible) animatedVisible.value = true;
|
|
16
23
|
}, { immediate: true });
|
|
17
24
|
return () => {
|
|
18
25
|
const { visible, getContainer, forceRender, destroyOnHidden = false, afterClose } = props;
|
|
19
26
|
if (!forceRender && destroyOnHidden && !animatedVisible.value) return null;
|
|
20
|
-
return (0, vue.createVNode)(
|
|
27
|
+
return (0, vue.createVNode)(_v_c_portal.default, {
|
|
21
28
|
"open": visible || forceRender || animatedVisible.value,
|
|
22
29
|
"autoDestroy": false,
|
|
30
|
+
"onEsc": onEsc,
|
|
23
31
|
"getContainer": getContainer,
|
|
24
32
|
"autoLock": visible || animatedVisible.value
|
|
25
33
|
}, { default: () => [(0, vue.createVNode)(require_index.default, (0, vue.mergeProps)(props, {
|
|
@@ -259,6 +267,11 @@ var DialogWrap = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) =>
|
|
|
259
267
|
required: false,
|
|
260
268
|
default: void 0
|
|
261
269
|
},
|
|
270
|
+
focusTrap: {
|
|
271
|
+
type: Boolean,
|
|
272
|
+
required: false,
|
|
273
|
+
default: void 0
|
|
274
|
+
},
|
|
262
275
|
panelRef: {
|
|
263
276
|
required: false,
|
|
264
277
|
default: void 0
|
|
@@ -267,12 +280,12 @@ var DialogWrap = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) =>
|
|
|
267
280
|
getContainer: void 0,
|
|
268
281
|
closeIcon: void 0,
|
|
269
282
|
prefixCls: "vc-dialog",
|
|
270
|
-
visible: true,
|
|
271
283
|
keyboard: true,
|
|
272
284
|
focusTriggerAfterClose: true,
|
|
273
285
|
closable: true,
|
|
274
286
|
mask: true,
|
|
275
287
|
maskClosable: true,
|
|
288
|
+
destroyOnHidden: false,
|
|
276
289
|
forceRender: false
|
|
277
290
|
}),
|
|
278
291
|
name: "Dialog"
|
package/dist/DialogWrap.js
CHANGED
|
@@ -4,10 +4,14 @@ import { createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef, wa
|
|
|
4
4
|
import Portal from "@v-c/portal";
|
|
5
5
|
var DialogWrap_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
6
6
|
const animatedVisible = shallowRef(false);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
useRefProvide(props);
|
|
8
|
+
const onEsc = ({ top, event }) => {
|
|
9
|
+
const { keyboard = true } = props;
|
|
10
|
+
if (top && keyboard) {
|
|
11
|
+
event.stopPropagation();
|
|
12
|
+
props?.onClose?.(event);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
11
15
|
watch(() => props.visible, () => {
|
|
12
16
|
if (props.visible) animatedVisible.value = true;
|
|
13
17
|
}, { immediate: true });
|
|
@@ -17,6 +21,7 @@ var DialogWrap_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
17
21
|
return createVNode(Portal, {
|
|
18
22
|
"open": visible || forceRender || animatedVisible.value,
|
|
19
23
|
"autoDestroy": false,
|
|
24
|
+
"onEsc": onEsc,
|
|
20
25
|
"getContainer": getContainer,
|
|
21
26
|
"autoLock": visible || animatedVisible.value
|
|
22
27
|
}, { default: () => [createVNode(Dialog_default, mergeProps(props, {
|
|
@@ -256,6 +261,11 @@ var DialogWrap_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
256
261
|
required: false,
|
|
257
262
|
default: void 0
|
|
258
263
|
},
|
|
264
|
+
focusTrap: {
|
|
265
|
+
type: Boolean,
|
|
266
|
+
required: false,
|
|
267
|
+
default: void 0
|
|
268
|
+
},
|
|
259
269
|
panelRef: {
|
|
260
270
|
required: false,
|
|
261
271
|
default: void 0
|
|
@@ -264,12 +274,12 @@ var DialogWrap_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
264
274
|
getContainer: void 0,
|
|
265
275
|
closeIcon: void 0,
|
|
266
276
|
prefixCls: "vc-dialog",
|
|
267
|
-
visible: true,
|
|
268
277
|
keyboard: true,
|
|
269
278
|
focusTriggerAfterClose: true,
|
|
270
279
|
closable: true,
|
|
271
280
|
mask: true,
|
|
272
281
|
maskClosable: true,
|
|
282
|
+
destroyOnHidden: false,
|
|
273
283
|
forceRender: false
|
|
274
284
|
}),
|
|
275
285
|
name: "Dialog"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
package/dist/context.cjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
2
|
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
2
3
|
let vue = require("vue");
|
|
3
4
|
var RefContext = Symbol("RefContext");
|
|
4
|
-
function useRefProvide() {
|
|
5
|
+
function useRefProvide(props) {
|
|
5
6
|
const panel = (0, vue.shallowRef)();
|
|
6
7
|
const setPanelRef = (el) => {
|
|
8
|
+
if (typeof props.panelRef === "function") props.panelRef(el);
|
|
7
9
|
panel.value = el;
|
|
8
10
|
};
|
|
9
11
|
(0, vue.provide)(RefContext, {
|
package/dist/context.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ShallowRef } from 'vue';
|
|
2
|
+
import { IDialogPropTypes } from './IDialogPropTypes.ts';
|
|
2
3
|
export interface RefContextProps {
|
|
3
4
|
panel: ShallowRef<HTMLDivElement | undefined>;
|
|
4
5
|
setPanel: (panel: HTMLDivElement) => void;
|
|
5
6
|
}
|
|
6
|
-
export declare function useRefProvide(): {
|
|
7
|
+
export declare function useRefProvide(props: IDialogPropTypes): {
|
|
7
8
|
panel: ShallowRef<HTMLDivElement | undefined, HTMLDivElement | undefined>;
|
|
8
9
|
setPanelRef: (el: HTMLDivElement) => void;
|
|
9
10
|
};
|
package/dist/context.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { inject, provide, shallowRef } from "vue";
|
|
2
2
|
var RefContext = Symbol("RefContext");
|
|
3
|
-
function useRefProvide() {
|
|
3
|
+
function useRefProvide(props) {
|
|
4
4
|
const panel = shallowRef();
|
|
5
5
|
const setPanelRef = (el) => {
|
|
6
|
+
if (typeof props.panelRef === "function") props.panelRef(el);
|
|
6
7
|
panel.value = el;
|
|
7
8
|
};
|
|
8
9
|
provide(RefContext, {
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
Object.
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
2
5
|
const require_Panel = require("./Dialog/Content/Panel.cjs");
|
|
3
6
|
const require_DialogWrap = require("./DialogWrap.cjs");
|
|
4
7
|
var src_default = require_DialogWrap.default;
|
package/dist/util.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/dialog",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"vue": "^3.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@v-c/portal": "^1.0.
|
|
29
|
-
"@v-c/util": "^1.0.
|
|
28
|
+
"@v-c/portal": "^1.0.3",
|
|
29
|
+
"@v-c/util": "^1.0.8"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "vite build",
|