@v-c/dialog 1.0.1 → 1.0.3
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.js +5 -2
- package/dist/Dialog/index.js +19 -23
- package/dist/DialogWrap.js +1 -0
- package/dist/IDialogPropTypes.d.ts +7 -5
- package/package.json +3 -3
|
@@ -3,6 +3,7 @@ import { computed, createVNode, defineComponent, mergeProps, shallowRef } from "
|
|
|
3
3
|
import { classNames, clsx } from "@v-c/util";
|
|
4
4
|
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
5
5
|
import { useLockFocus } from "@v-c/util/dist/Dom/focus";
|
|
6
|
+
import { useFocusBoundaryProvider } from "@v-c/util/dist/Dom/focusBoundary";
|
|
6
7
|
import { getStylePxValue } from "@v-c/util/dist/props-util";
|
|
7
8
|
var Panel_default = /* @__PURE__ */ defineComponent((props, { expose, slots }) => {
|
|
8
9
|
const { setPanel } = useGetRefContext();
|
|
@@ -12,7 +13,8 @@ var Panel_default = /* @__PURE__ */ defineComponent((props, { expose, slots }) =
|
|
|
12
13
|
setPanel?.(el);
|
|
13
14
|
props?.holderRef?.(el);
|
|
14
15
|
};
|
|
15
|
-
useLockFocus(computed(() => !!props.visible && !!props.isFixedPos && props.focusTrap !== false), () => internalRef.value);
|
|
16
|
+
const [, registerAllowedElement] = useLockFocus(computed(() => !!props.visible && !!props.isFixedPos && props.focusTrap !== false), () => internalRef.value);
|
|
17
|
+
useFocusBoundaryProvider({ registerAllowedElement });
|
|
16
18
|
expose({ focus: () => {
|
|
17
19
|
internalRef.value?.focus?.({ preventScroll: true });
|
|
18
20
|
} });
|
|
@@ -46,7 +48,8 @@ var Panel_default = /* @__PURE__ */ defineComponent((props, { expose, slots }) =
|
|
|
46
48
|
"onClick": onClose,
|
|
47
49
|
"aria-label": "Close"
|
|
48
50
|
}, ariaProps, {
|
|
49
|
-
"class": `${prefixCls}-close`,
|
|
51
|
+
"class": classNames(`${prefixCls}-close`, modalClassNames?.close),
|
|
52
|
+
"style": modalStyles?.close,
|
|
50
53
|
"disabled": closeBtnIsDisabled
|
|
51
54
|
}), [closableObj.closeIcon]) : null;
|
|
52
55
|
const content = createVNode("div", {
|
package/dist/Dialog/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getMotionName } from "../util.js";
|
|
2
2
|
import Content_default from "./Content/index.js";
|
|
3
3
|
import Mask_default from "./Mask.js";
|
|
4
|
-
import { createVNode, defineComponent, mergeDefaults, mergeProps, nextTick,
|
|
4
|
+
import { createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, 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
7
|
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
@@ -40,53 +40,50 @@ var Dialog_default = /* @__PURE__ */ defineComponent((props, { expose, slots })
|
|
|
40
40
|
lastOutSideActiveElementRef.value = null;
|
|
41
41
|
}
|
|
42
42
|
if (_animatedVisible) props?.afterClose?.();
|
|
43
|
-
props?.afterOpenChange?.(newVisible);
|
|
44
43
|
}
|
|
44
|
+
props?.afterOpenChange?.(newVisible);
|
|
45
45
|
}
|
|
46
46
|
function onInternalClose(e) {
|
|
47
47
|
props?.onClose?.(e);
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
const contentTimeoutRef = shallowRef();
|
|
51
|
-
const onContentMouseDown = () => {
|
|
52
|
-
clearTimeout(contentTimeoutRef.value);
|
|
53
|
-
contentClickRef.value = true;
|
|
54
|
-
};
|
|
55
|
-
const onContentMouseUp = () => {
|
|
56
|
-
contentTimeoutRef.value = setTimeout(() => {
|
|
57
|
-
contentClickRef.value = false;
|
|
58
|
-
});
|
|
59
|
-
};
|
|
49
|
+
const mouseDownOnMaskRef = shallowRef(false);
|
|
60
50
|
let onWrapperClick = null;
|
|
61
51
|
watch(() => props.maskClosable, () => {
|
|
62
52
|
if (props.maskClosable) onWrapperClick = (e) => {
|
|
63
|
-
if (
|
|
64
|
-
else if (wrapperRef.value === e.target) onInternalClose(e);
|
|
53
|
+
if (wrapperRef.value === e.target && mouseDownOnMaskRef.value) onInternalClose(e);
|
|
65
54
|
};
|
|
55
|
+
else onWrapperClick = null;
|
|
66
56
|
}, { immediate: true });
|
|
57
|
+
function onWrapperMouseDown(e) {
|
|
58
|
+
mouseDownOnMaskRef.value = e.target === wrapperRef.value;
|
|
59
|
+
}
|
|
67
60
|
watch(() => props.visible, () => {
|
|
68
61
|
if (props.visible) {
|
|
62
|
+
mouseDownOnMaskRef.value = false;
|
|
69
63
|
animatedVisible.value = true;
|
|
70
64
|
saveLastOutSideActiveElementRef();
|
|
71
65
|
nextTick(() => {
|
|
72
66
|
const wrapEl = wrapperRef.value;
|
|
73
67
|
if (wrapEl) isFixedPos.value = getComputedStyle(wrapEl).position === "fixed";
|
|
74
68
|
});
|
|
75
|
-
|
|
69
|
+
if (!getMotionName(props.prefixCls, props.transitionName, props.animation)) nextTick(() => {
|
|
70
|
+
onDialogVisibleChanged(true);
|
|
71
|
+
});
|
|
72
|
+
} else if (animatedVisible.value && !getMotionName(props.prefixCls, props.transitionName, props.animation)) onDialogVisibleChanged(false);
|
|
76
73
|
}, { immediate: true });
|
|
77
|
-
onUnmounted(() => {
|
|
78
|
-
clearTimeout(contentTimeoutRef.value);
|
|
79
|
-
});
|
|
80
74
|
expose({});
|
|
81
75
|
return () => {
|
|
82
|
-
const { zIndex, wrapStyle, wrapProps, wrapClassName, closable, transitionName, animation, styles: modalStyles, prefixCls, rootClassName, visible, mask, maskAnimation, maskTransitionName, maskStyle, maskProps, classNames: modalClassNames } = props;
|
|
76
|
+
const { zIndex, wrapStyle, wrapProps, wrapClassName, closable, transitionName, animation, styles: modalStyles, prefixCls, rootClassName, visible, mask, maskAnimation, maskTransitionName, maskStyle, maskProps, classNames: modalClassNames, rootStyle } = props;
|
|
83
77
|
const mergedStyle = {
|
|
84
78
|
zIndex,
|
|
85
79
|
...wrapStyle,
|
|
86
80
|
...modalStyles?.wrapper,
|
|
87
81
|
display: !animatedVisible.value ? "none" : void 0
|
|
88
82
|
};
|
|
89
|
-
return createVNode("div", mergeProps({
|
|
83
|
+
return createVNode("div", mergeProps({
|
|
84
|
+
"class": [`${prefixCls}-root`, rootClassName],
|
|
85
|
+
"style": rootStyle
|
|
86
|
+
}, pickAttrs(props, { data: true })), [createVNode(Mask_default, {
|
|
90
87
|
"prefixCls": prefixCls,
|
|
91
88
|
"visible": !!(mask && visible),
|
|
92
89
|
"motionName": getMotionName(prefixCls, maskTransitionName, maskAnimation),
|
|
@@ -105,11 +102,10 @@ var Dialog_default = /* @__PURE__ */ defineComponent((props, { expose, slots })
|
|
|
105
102
|
],
|
|
106
103
|
"ref": wrapperRef,
|
|
107
104
|
"onClick": onWrapperClick,
|
|
105
|
+
"onMousedown": onWrapperMouseDown,
|
|
108
106
|
"style": mergedStyle
|
|
109
107
|
}, wrapProps), [createVNode(Content_default, mergeProps({
|
|
110
108
|
...props,
|
|
111
|
-
onMouseDown: onContentMouseDown,
|
|
112
|
-
onMouseUp: onContentMouseUp,
|
|
113
109
|
onClose: onInternalClose,
|
|
114
110
|
onVisibleChanged: onDialogVisibleChanged
|
|
115
111
|
}, {
|
package/dist/DialogWrap.js
CHANGED
|
@@ -27,6 +27,7 @@ var DialogWrap_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
27
27
|
}, { default: () => [createVNode(Dialog_default, mergeProps(props, {
|
|
28
28
|
"destroyOnHidden": destroyOnHidden,
|
|
29
29
|
"afterClose": () => {
|
|
30
|
+
(props.closable && typeof props.closable === "object" ? props.closable : {}).afterClose?.();
|
|
30
31
|
afterClose?.();
|
|
31
32
|
animatedVisible.value = false;
|
|
32
33
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { GetContainer } from '@v-c/util/dist/PortalWrapper';
|
|
2
2
|
import { VueNode } from '@v-c/util/dist/type';
|
|
3
3
|
import { CSSProperties } from 'vue';
|
|
4
|
-
export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask';
|
|
4
|
+
export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask' | 'close';
|
|
5
5
|
export type ModalClassNames = Partial<Record<SemanticName, string>>;
|
|
6
6
|
export type ModalStyles = Partial<Record<SemanticName, CSSProperties>>;
|
|
7
|
+
export type ClosableType = {
|
|
8
|
+
closeIcon?: VueNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
afterClose?: () => any;
|
|
11
|
+
};
|
|
7
12
|
export interface IDialogPropTypes {
|
|
8
13
|
className?: string;
|
|
9
14
|
keyboard?: boolean;
|
|
@@ -14,10 +19,7 @@ export interface IDialogPropTypes {
|
|
|
14
19
|
afterClose?: () => any;
|
|
15
20
|
afterOpenChange?: (open: boolean) => void;
|
|
16
21
|
onClose?: (e: any) => any;
|
|
17
|
-
closable?: boolean | (
|
|
18
|
-
closeIcon?: VueNode;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
} & Record<string, any>);
|
|
22
|
+
closable?: boolean | (ClosableType & Record<string, any>);
|
|
21
23
|
maskClosable?: boolean;
|
|
22
24
|
visible?: boolean;
|
|
23
25
|
destroyOnHidden?: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/dialog",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
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.8",
|
|
29
|
+
"@v-c/util": "^1.0.19"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "vite build",
|