@v-c/trigger 1.0.2 → 1.0.5
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/Popup/Arrow.cjs +3 -2
- package/dist/Popup/Mask.cjs +6 -3
- package/dist/Popup/PopupContent.cjs +4 -1
- package/dist/Popup/index.cjs +22 -21
- package/dist/Popup/index.d.ts +2 -0
- package/dist/Popup/index.js +12 -13
- package/dist/UniqueProvider/UniqueContainer.cjs +19 -18
- package/dist/UniqueProvider/UniqueContainer.js +12 -14
- package/dist/UniqueProvider/index.cjs +18 -14
- package/dist/UniqueProvider/index.js +1 -0
- package/dist/UniqueProvider/useTargetState.cjs +4 -1
- package/dist/context.cjs +1 -0
- package/dist/context.d.ts +2 -0
- package/dist/hooks/useAction.cjs +4 -1
- package/dist/hooks/useAlign.cjs +24 -17
- package/dist/hooks/useAlign.js +16 -12
- package/dist/hooks/useDelay.cjs +4 -1
- package/dist/hooks/useOffsetStyle.cjs +4 -2
- package/dist/hooks/useOffsetStyle.js +0 -1
- package/dist/hooks/useWatch.cjs +6 -3
- package/dist/hooks/useWatch.js +2 -2
- package/dist/hooks/useWinClick.cjs +8 -5
- package/dist/index.cjs +31 -39
- package/dist/index.js +14 -24
- package/dist/interface.cjs +1 -0
- package/dist/util.cjs +4 -2
- package/dist/util.js +3 -2
- package/package.json +4 -4
package/dist/Popup/Arrow.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
|
-
let
|
|
4
|
+
let _v_c_util = require("@v-c/util");
|
|
4
5
|
const Arrow = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
5
6
|
props: {
|
|
6
7
|
prefixCls: {
|
|
@@ -50,7 +51,7 @@ const Arrow = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
50
51
|
}
|
|
51
52
|
return (0, vue.createVNode)("div", {
|
|
52
53
|
"ref": arrowRef,
|
|
53
|
-
"class": (0,
|
|
54
|
+
"class": (0, _v_c_util.classNames)(`${prefixCls}-arrow`, className),
|
|
54
55
|
"style": {
|
|
55
56
|
...alignStyle,
|
|
56
57
|
...style
|
package/dist/Popup/Mask.cjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
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
|
|
7
|
+
let _v_c_util_dist_utils_transition = require("@v-c/util/dist/utils/transition");
|
|
5
8
|
var Mask = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
6
9
|
return () => {
|
|
7
10
|
const { prefixCls, open, zIndex, mask, motion, mobile } = props;
|
|
8
11
|
if (!mask) return null;
|
|
9
|
-
return (0, vue.createVNode)(vue.Transition, (0,
|
|
12
|
+
return (0, vue.createVNode)(vue.Transition, (0, _v_c_util_dist_utils_transition.getTransitionProps)(motion?.name, motion), { default: () => [open ? (0, vue.createVNode)("div", {
|
|
10
13
|
"style": { zIndex },
|
|
11
14
|
"class": [
|
|
12
15
|
`${prefixCls}-mask`,
|
|
@@ -1,4 +1,7 @@
|
|
|
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
7
|
var PopupContent = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
package/dist/Popup/index.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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_useOffsetStyle = require("../hooks/useOffsetStyle.cjs");
|
|
4
7
|
const require_Arrow = require("./Arrow.cjs");
|
|
5
8
|
const require_Mask = require("./Mask.cjs");
|
|
6
|
-
const require_PopupContent = require("./PopupContent.cjs");
|
|
7
9
|
let vue = require("vue");
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
let __v_c_util_dist_utils_transition = require("@v-c/util/dist/utils/transition");
|
|
10
|
+
let _v_c_resize_observer = require("@v-c/resize-observer");
|
|
11
|
+
let _v_c_util = require("@v-c/util");
|
|
12
|
+
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
13
|
+
let _v_c_util_dist_utils_transition = require("@v-c/util/dist/utils/transition");
|
|
13
14
|
var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, expose }) => {
|
|
14
|
-
const
|
|
15
|
-
const { offsetX, offsetR, offsetY, offsetB, open, ready, align } = (0, __v_c_util_dist_props_util.toPropsRefs)(props, "offsetX", "offsetB", "offsetY", "offsetR", "ready", "open", "align");
|
|
15
|
+
const { offsetX, offsetR, offsetY, offsetB, open, ready, align } = (0, _v_c_util_dist_props_util.toPropsRefs)(props, "offsetX", "offsetB", "offsetY", "offsetR", "ready", "open", "align");
|
|
16
16
|
const isNodeVisible = (0, vue.computed)(() => props.open || props.keepDom);
|
|
17
17
|
const isMobile = (0, vue.computed)(() => !!props.mobile);
|
|
18
18
|
const getPopupContainerNeedParams = props?.getPopupContainer?.length > 0;
|
|
@@ -46,9 +46,10 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
46
46
|
getElement: () => popupElementRef.value,
|
|
47
47
|
nativeElement: popupElementRef
|
|
48
48
|
});
|
|
49
|
+
(0, _v_c_resize_observer.useResizeObserver)(open, popupElementRef, onInternalResize);
|
|
49
50
|
return () => {
|
|
50
51
|
if (!show.value) return null;
|
|
51
|
-
const { stretch, targetHeight, targetWidth, portal: Portal, forceRender, getPopupContainer, target, autoDestroy, zIndex, prefixCls, arrow, arrowPos, align: align$1, onMouseEnter, onMouseLeave, onPointerEnter, onPointerDownCapture, onClick,
|
|
52
|
+
const { onEsc, stretch, targetHeight, targetWidth, portal: Portal, forceRender, getPopupContainer, target, autoDestroy, zIndex, prefixCls, arrow, arrowPos, align: align$1, onMouseEnter, onMouseLeave, onPointerEnter, onPointerDownCapture, onClick, onPrepare, onVisibleChanged } = props;
|
|
52
53
|
const miscStyle = {};
|
|
53
54
|
if (stretch) {
|
|
54
55
|
if (stretch.includes("height") && targetHeight) miscStyle.height = `${targetHeight}px`;
|
|
@@ -59,7 +60,7 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
59
60
|
if (!open.value) miscStyle.pointerEvents = "none";
|
|
60
61
|
const [mergedMask, mergedMaskMotion, mergedPopupMotion] = mergedProps.value;
|
|
61
62
|
const popupMotionName = mergedPopupMotion?.name ?? mergedPopupMotion?.motionName;
|
|
62
|
-
const baseTransitionProps = popupMotionName ? (0,
|
|
63
|
+
const baseTransitionProps = popupMotionName ? (0, _v_c_util_dist_utils_transition.getTransitionProps)(popupMotionName, mergedPopupMotion) : {
|
|
63
64
|
appear: true,
|
|
64
65
|
...mergedPopupMotion || {}
|
|
65
66
|
};
|
|
@@ -73,9 +74,7 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
73
74
|
onAfterEnter: (element) => {
|
|
74
75
|
baseTransitionProps?.onAfterEnter?.(element);
|
|
75
76
|
requestAnimationFrame(() => {
|
|
76
|
-
|
|
77
|
-
onVisibleChanged?.(true);
|
|
78
|
-
});
|
|
77
|
+
onVisibleChanged?.(true);
|
|
79
78
|
});
|
|
80
79
|
},
|
|
81
80
|
onAfterLeave: (element) => {
|
|
@@ -83,11 +82,12 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
83
82
|
onVisibleChanged?.(false);
|
|
84
83
|
}
|
|
85
84
|
};
|
|
86
|
-
const cls = (0,
|
|
85
|
+
const cls = (0, _v_c_util.classNames)(prefixCls, attrs.class, props.className, { [`${prefixCls}-mobile`]: isMobile.value });
|
|
87
86
|
return (0, vue.createVNode)(Portal, {
|
|
88
87
|
"open": forceRender || isNodeVisible.value,
|
|
89
88
|
"getContainer": getPopupContainer && (() => getPopupContainer(target)),
|
|
90
|
-
"autoDestroy": autoDestroy
|
|
89
|
+
"autoDestroy": autoDestroy,
|
|
90
|
+
"onEsc": onEsc
|
|
91
91
|
}, { default: () => [
|
|
92
92
|
(0, vue.createVNode)(require_Mask.default, {
|
|
93
93
|
"prefixCls": prefixCls,
|
|
@@ -97,10 +97,7 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
97
97
|
"motion": mergedMaskMotion,
|
|
98
98
|
"mobile": isMobile.value
|
|
99
99
|
}, null),
|
|
100
|
-
(0, vue.createVNode)(
|
|
101
|
-
"onResize": onInternalResize,
|
|
102
|
-
"disabled": !open.value
|
|
103
|
-
}, { default: () => [(0, vue.createVNode)(vue.Transition, mergedTransitionProps, { default: () => [(0, vue.withDirectives)((0, vue.createVNode)("div", (0, vue.mergeProps)({
|
|
100
|
+
(0, vue.createVNode)(vue.Transition, mergedTransitionProps, { default: () => [(0, vue.withDirectives)((0, vue.createVNode)("div", (0, vue.mergeProps)({
|
|
104
101
|
"ref": popupElementRef,
|
|
105
102
|
"class": cls,
|
|
106
103
|
"style": [
|
|
@@ -125,11 +122,15 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
125
122
|
"arrow": arrow === true ? {} : arrow,
|
|
126
123
|
"arrowPos": arrowPos,
|
|
127
124
|
"align": align$1
|
|
128
|
-
}, null),
|
|
125
|
+
}, null), typeof props?.popup === "function" ? props.popup() : props.popup]), [[vue.vShow, open.value]])] }),
|
|
129
126
|
slots?.default?.()
|
|
130
127
|
] });
|
|
131
128
|
};
|
|
132
129
|
}, { props: /* @__PURE__ */ (0, vue.mergeDefaults)({
|
|
130
|
+
onEsc: {
|
|
131
|
+
required: false,
|
|
132
|
+
default: void 0
|
|
133
|
+
},
|
|
133
134
|
prefixCls: {
|
|
134
135
|
type: String,
|
|
135
136
|
required: true,
|
package/dist/Popup/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PortalProps } from '@v-c/portal';
|
|
1
2
|
import { ResizeObserverProps } from '@v-c/resize-observer';
|
|
2
3
|
import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
|
|
3
4
|
import { CSSProperties } from 'vue';
|
|
@@ -11,6 +12,7 @@ export interface MobileConfig {
|
|
|
11
12
|
maskMotion?: CSSMotionProps;
|
|
12
13
|
}
|
|
13
14
|
export interface PopupProps {
|
|
15
|
+
onEsc?: PortalProps['onEsc'];
|
|
14
16
|
prefixCls: string;
|
|
15
17
|
className?: string;
|
|
16
18
|
style?: CSSProperties;
|
package/dist/Popup/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import useOffsetStyle from "../hooks/useOffsetStyle.js";
|
|
2
2
|
import { Arrow } from "./Arrow.js";
|
|
3
3
|
import Mask_default from "./Mask.js";
|
|
4
|
-
import PopupContent_default from "./PopupContent.js";
|
|
5
4
|
import { Transition, computed, createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, shallowRef, vShow, watchEffect, withDirectives } from "vue";
|
|
6
|
-
import
|
|
5
|
+
import { useResizeObserver } from "@v-c/resize-observer";
|
|
7
6
|
import { classNames } from "@v-c/util";
|
|
8
7
|
import { toPropsRefs } from "@v-c/util/dist/props-util";
|
|
9
8
|
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
10
9
|
var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expose }) => {
|
|
11
|
-
const popupContent = computed(() => typeof props.popup === "function" ? props.popup() : props.popup);
|
|
12
10
|
const { offsetX, offsetR, offsetY, offsetB, open, ready, align } = toPropsRefs(props, "offsetX", "offsetB", "offsetY", "offsetR", "ready", "open", "align");
|
|
13
11
|
const isNodeVisible = computed(() => props.open || props.keepDom);
|
|
14
12
|
const isMobile = computed(() => !!props.mobile);
|
|
@@ -43,9 +41,10 @@ var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expo
|
|
|
43
41
|
getElement: () => popupElementRef.value,
|
|
44
42
|
nativeElement: popupElementRef
|
|
45
43
|
});
|
|
44
|
+
useResizeObserver(open, popupElementRef, onInternalResize);
|
|
46
45
|
return () => {
|
|
47
46
|
if (!show.value) return null;
|
|
48
|
-
const { stretch, targetHeight, targetWidth, portal: Portal, forceRender, getPopupContainer, target, autoDestroy, zIndex, prefixCls, arrow, arrowPos, align: align$1, onMouseEnter, onMouseLeave, onPointerEnter, onPointerDownCapture, onClick,
|
|
47
|
+
const { onEsc, stretch, targetHeight, targetWidth, portal: Portal, forceRender, getPopupContainer, target, autoDestroy, zIndex, prefixCls, arrow, arrowPos, align: align$1, onMouseEnter, onMouseLeave, onPointerEnter, onPointerDownCapture, onClick, onPrepare, onVisibleChanged } = props;
|
|
49
48
|
const miscStyle = {};
|
|
50
49
|
if (stretch) {
|
|
51
50
|
if (stretch.includes("height") && targetHeight) miscStyle.height = `${targetHeight}px`;
|
|
@@ -70,9 +69,7 @@ var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expo
|
|
|
70
69
|
onAfterEnter: (element) => {
|
|
71
70
|
baseTransitionProps?.onAfterEnter?.(element);
|
|
72
71
|
requestAnimationFrame(() => {
|
|
73
|
-
|
|
74
|
-
onVisibleChanged?.(true);
|
|
75
|
-
});
|
|
72
|
+
onVisibleChanged?.(true);
|
|
76
73
|
});
|
|
77
74
|
},
|
|
78
75
|
onAfterLeave: (element) => {
|
|
@@ -84,7 +81,8 @@ var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expo
|
|
|
84
81
|
return createVNode(Portal, {
|
|
85
82
|
"open": forceRender || isNodeVisible.value,
|
|
86
83
|
"getContainer": getPopupContainer && (() => getPopupContainer(target)),
|
|
87
|
-
"autoDestroy": autoDestroy
|
|
84
|
+
"autoDestroy": autoDestroy,
|
|
85
|
+
"onEsc": onEsc
|
|
88
86
|
}, { default: () => [
|
|
89
87
|
createVNode(Mask_default, {
|
|
90
88
|
"prefixCls": prefixCls,
|
|
@@ -94,10 +92,7 @@ var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expo
|
|
|
94
92
|
"motion": mergedMaskMotion,
|
|
95
93
|
"mobile": isMobile.value
|
|
96
94
|
}, null),
|
|
97
|
-
createVNode(
|
|
98
|
-
"onResize": onInternalResize,
|
|
99
|
-
"disabled": !open.value
|
|
100
|
-
}, { default: () => [createVNode(Transition, mergedTransitionProps, { default: () => [withDirectives(createVNode("div", mergeProps({
|
|
95
|
+
createVNode(Transition, mergedTransitionProps, { default: () => [withDirectives(createVNode("div", mergeProps({
|
|
101
96
|
"ref": popupElementRef,
|
|
102
97
|
"class": cls,
|
|
103
98
|
"style": [
|
|
@@ -122,11 +117,15 @@ var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expo
|
|
|
122
117
|
"arrow": arrow === true ? {} : arrow,
|
|
123
118
|
"arrowPos": arrowPos,
|
|
124
119
|
"align": align$1
|
|
125
|
-
}, null),
|
|
120
|
+
}, null), typeof props?.popup === "function" ? props.popup() : props.popup]), [[vShow, open.value]])] }),
|
|
126
121
|
slots?.default?.()
|
|
127
122
|
] });
|
|
128
123
|
};
|
|
129
124
|
}, { props: /* @__PURE__ */ mergeDefaults({
|
|
125
|
+
onEsc: {
|
|
126
|
+
required: false,
|
|
127
|
+
default: void 0
|
|
128
|
+
},
|
|
130
129
|
prefixCls: {
|
|
131
130
|
type: String,
|
|
132
131
|
required: true,
|
|
@@ -1,19 +1,23 @@
|
|
|
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_useOffsetStyle = require("../hooks/useOffsetStyle.cjs");
|
|
4
7
|
let vue = require("vue");
|
|
5
|
-
let
|
|
6
|
-
let
|
|
8
|
+
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
9
|
+
let _v_c_util_dist_utils_transition = require("@v-c/util/dist/utils/transition");
|
|
7
10
|
var UniqueContainer = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
8
11
|
const motionVisible = (0, vue.shallowRef)(false);
|
|
9
|
-
const { open, isMobile, align, ready, offsetR, offsetB, offsetX, offsetY } = (0,
|
|
12
|
+
const { open, isMobile, align, ready, offsetR, offsetB, offsetX, offsetY } = (0, _v_c_util_dist_props_util.toPropsRefs)(props, "open", "isMobile", "align", "ready", "offsetR", "offsetB", "offsetX", "offsetY");
|
|
10
13
|
const offsetStyle = require_useOffsetStyle.default(isMobile, ready, open, align, offsetR, offsetB, offsetX, offsetY);
|
|
11
14
|
const cachedOffsetStyleRef = (0, vue.shallowRef)(offsetStyle.value);
|
|
12
15
|
(0, vue.watchEffect)(() => {
|
|
13
16
|
if (ready.value) cachedOffsetStyleRef.value = offsetStyle.value;
|
|
14
17
|
});
|
|
15
|
-
(0, vue.
|
|
16
|
-
if (
|
|
18
|
+
const mergedOffsetStyle = (0, vue.computed)(() => {
|
|
19
|
+
if (cachedOffsetStyleRef.value && Object.keys(cachedOffsetStyleRef.value).length > 0) return cachedOffsetStyleRef.value;
|
|
20
|
+
return offsetStyle.value;
|
|
17
21
|
});
|
|
18
22
|
return () => {
|
|
19
23
|
const { popupSize, motion, prefixCls, uniqueContainerClassName, arrowPos, uniqueContainerStyle } = props;
|
|
@@ -22,36 +26,33 @@ var UniqueContainer = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
|
22
26
|
sizeStyle.width = `${popupSize.width}px`;
|
|
23
27
|
sizeStyle.height = `${popupSize.height}px`;
|
|
24
28
|
}
|
|
25
|
-
const baseTransitionProps = (0,
|
|
26
|
-
const
|
|
29
|
+
const baseTransitionProps = (0, _v_c_util_dist_utils_transition.getTransitionProps)(motion?.name, motion);
|
|
30
|
+
const containerCls = `${prefixCls}-unique-container`;
|
|
31
|
+
return (0, vue.createVNode)(vue.Transition, {
|
|
27
32
|
...baseTransitionProps,
|
|
28
|
-
onBeforeEnter: (element) => {
|
|
29
|
-
motionVisible.value = true;
|
|
30
|
-
baseTransitionProps.onBeforeEnter?.(element);
|
|
31
|
-
},
|
|
32
33
|
onAfterEnter: (element) => {
|
|
33
34
|
motionVisible.value = true;
|
|
34
35
|
baseTransitionProps.onAfterEnter?.(element);
|
|
35
36
|
},
|
|
36
37
|
onAfterLeave: (element) => {
|
|
37
38
|
motionVisible.value = false;
|
|
38
|
-
cachedOffsetStyleRef.value = {};
|
|
39
39
|
baseTransitionProps.onAfterLeave?.(element);
|
|
40
40
|
}
|
|
41
|
-
}
|
|
42
|
-
const containerCls = `${prefixCls}-unique-container`;
|
|
43
|
-
return (0, vue.createVNode)(vue.Transition, mergedTransitionProps, { default: () => [(0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
41
|
+
}, { default: () => [(0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
44
42
|
"class": [
|
|
45
43
|
containerCls,
|
|
46
44
|
uniqueContainerClassName,
|
|
47
|
-
{
|
|
45
|
+
{
|
|
46
|
+
[`${containerCls}-visible`]: motionVisible.value,
|
|
47
|
+
[`${containerCls}-hidden`]: !open.value
|
|
48
|
+
}
|
|
48
49
|
],
|
|
49
50
|
"style": [
|
|
50
51
|
{
|
|
51
52
|
"--arrow-x": `${arrowPos?.x || 0}px`,
|
|
52
53
|
"--arrow-y": `${arrowPos?.y || 0}px`
|
|
53
54
|
},
|
|
54
|
-
|
|
55
|
+
mergedOffsetStyle.value,
|
|
55
56
|
sizeStyle,
|
|
56
57
|
uniqueContainerStyle
|
|
57
58
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import useOffsetStyle from "../hooks/useOffsetStyle.js";
|
|
2
|
-
import { Transition, createVNode, defineComponent, shallowRef, vShow,
|
|
2
|
+
import { Transition, computed, createVNode, defineComponent, shallowRef, vShow, watchEffect, withDirectives } from "vue";
|
|
3
3
|
import { toPropsRefs } from "@v-c/util/dist/props-util";
|
|
4
4
|
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
5
5
|
var UniqueContainer_default = /* @__PURE__ */ defineComponent((props) => {
|
|
@@ -10,8 +10,9 @@ var UniqueContainer_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
10
10
|
watchEffect(() => {
|
|
11
11
|
if (ready.value) cachedOffsetStyleRef.value = offsetStyle.value;
|
|
12
12
|
});
|
|
13
|
-
|
|
14
|
-
if (
|
|
13
|
+
const mergedOffsetStyle = computed(() => {
|
|
14
|
+
if (cachedOffsetStyleRef.value && Object.keys(cachedOffsetStyleRef.value).length > 0) return cachedOffsetStyleRef.value;
|
|
15
|
+
return offsetStyle.value;
|
|
15
16
|
});
|
|
16
17
|
return () => {
|
|
17
18
|
const { popupSize, motion, prefixCls, uniqueContainerClassName, arrowPos, uniqueContainerStyle } = props;
|
|
@@ -21,35 +22,32 @@ var UniqueContainer_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
21
22
|
sizeStyle.height = `${popupSize.height}px`;
|
|
22
23
|
}
|
|
23
24
|
const baseTransitionProps = getTransitionProps(motion?.name, motion);
|
|
24
|
-
const
|
|
25
|
+
const containerCls = `${prefixCls}-unique-container`;
|
|
26
|
+
return createVNode(Transition, {
|
|
25
27
|
...baseTransitionProps,
|
|
26
|
-
onBeforeEnter: (element) => {
|
|
27
|
-
motionVisible.value = true;
|
|
28
|
-
baseTransitionProps.onBeforeEnter?.(element);
|
|
29
|
-
},
|
|
30
28
|
onAfterEnter: (element) => {
|
|
31
29
|
motionVisible.value = true;
|
|
32
30
|
baseTransitionProps.onAfterEnter?.(element);
|
|
33
31
|
},
|
|
34
32
|
onAfterLeave: (element) => {
|
|
35
33
|
motionVisible.value = false;
|
|
36
|
-
cachedOffsetStyleRef.value = {};
|
|
37
34
|
baseTransitionProps.onAfterLeave?.(element);
|
|
38
35
|
}
|
|
39
|
-
}
|
|
40
|
-
const containerCls = `${prefixCls}-unique-container`;
|
|
41
|
-
return createVNode(Transition, mergedTransitionProps, { default: () => [withDirectives(createVNode("div", {
|
|
36
|
+
}, { default: () => [withDirectives(createVNode("div", {
|
|
42
37
|
"class": [
|
|
43
38
|
containerCls,
|
|
44
39
|
uniqueContainerClassName,
|
|
45
|
-
{
|
|
40
|
+
{
|
|
41
|
+
[`${containerCls}-visible`]: motionVisible.value,
|
|
42
|
+
[`${containerCls}-hidden`]: !open.value
|
|
43
|
+
}
|
|
46
44
|
],
|
|
47
45
|
"style": [
|
|
48
46
|
{
|
|
49
47
|
"--arrow-x": `${arrowPos?.x || 0}px`,
|
|
50
48
|
"--arrow-y": `${arrowPos?.y || 0}px`
|
|
51
49
|
},
|
|
52
|
-
|
|
50
|
+
mergedOffsetStyle.value,
|
|
53
51
|
sizeStyle,
|
|
54
52
|
uniqueContainerStyle
|
|
55
53
|
]
|
|
@@ -1,4 +1,7 @@
|
|
|
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_util = require("../util.cjs");
|
|
@@ -8,10 +11,10 @@ const require_index = require("../Popup/index.cjs");
|
|
|
8
11
|
const require_UniqueContainer = require("./UniqueContainer.cjs");
|
|
9
12
|
const require_useTargetState = require("./useTargetState.cjs");
|
|
10
13
|
let vue = require("vue");
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
let
|
|
14
|
-
let
|
|
14
|
+
let _v_c_portal = require("@v-c/portal");
|
|
15
|
+
_v_c_portal = require_rolldown_runtime.__toESM(_v_c_portal);
|
|
16
|
+
let _v_c_util = require("@v-c/util");
|
|
17
|
+
let _v_c_util_dist_Dom_findDOMNode = require("@v-c/util/dist/Dom/findDOMNode");
|
|
15
18
|
var UniqueProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
16
19
|
const [trigger, open, options, onTargetVisibleChanged] = require_useTargetState.default();
|
|
17
20
|
const mergedOptions = (0, vue.computed)(() => {
|
|
@@ -23,15 +26,15 @@ var UniqueProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots })
|
|
|
23
26
|
const externalPopupRef = (0, vue.shallowRef)(null);
|
|
24
27
|
const resolveToElement = (node) => {
|
|
25
28
|
if (!node) return null;
|
|
26
|
-
if ((0,
|
|
29
|
+
if ((0, _v_c_util_dist_Dom_findDOMNode.isDOM)(node)) return node;
|
|
27
30
|
const exposed = node;
|
|
28
|
-
if ((0,
|
|
31
|
+
if ((0, _v_c_util_dist_Dom_findDOMNode.isDOM)(exposed?.$el)) return exposed.$el;
|
|
29
32
|
const nativeEl = exposed?.nativeElement;
|
|
30
|
-
if ((0,
|
|
31
|
-
if ((0,
|
|
33
|
+
if ((0, _v_c_util_dist_Dom_findDOMNode.isDOM)(nativeEl?.value)) return nativeEl.value;
|
|
34
|
+
if ((0, _v_c_util_dist_Dom_findDOMNode.isDOM)(nativeEl)) return nativeEl;
|
|
32
35
|
if (typeof exposed?.getElement === "function") {
|
|
33
36
|
const el = exposed.getElement();
|
|
34
|
-
if ((0,
|
|
37
|
+
if ((0, _v_c_util_dist_Dom_findDOMNode.isDOM)(el)) return el;
|
|
35
38
|
}
|
|
36
39
|
return null;
|
|
37
40
|
};
|
|
@@ -70,7 +73,7 @@ var UniqueProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots })
|
|
|
70
73
|
};
|
|
71
74
|
const alignedClassName = (0, vue.computed)(() => {
|
|
72
75
|
if (!mergedOptions.value) return "";
|
|
73
|
-
return (0,
|
|
76
|
+
return (0, _v_c_util.classNames)(require_util.getAlignPopupClassName(mergedOptions.value?.builtinPlacements || {}, mergedOptions.value.prefixCls || "", alignInfo.value, false), mergedOptions.value?.getPopupClassNameFromAlign?.(alignInfo.value));
|
|
74
77
|
});
|
|
75
78
|
const contextValue = {
|
|
76
79
|
show,
|
|
@@ -96,10 +99,11 @@ var UniqueProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots })
|
|
|
96
99
|
const prefixCls = mergedOptions?.value?.prefixCls;
|
|
97
100
|
return (0, vue.createVNode)(require_context.UniqueContextProvider, contextValue, { default: () => [slots?.default?.(), !!mergedOptions.value && (0, vue.createVNode)(require_context.TriggerContextProvider, triggerContextValue.value, { default: () => [(0, vue.createVNode)(require_index.default, {
|
|
98
101
|
"ref": setPopupRef,
|
|
99
|
-
"portal":
|
|
102
|
+
"portal": _v_c_portal.default,
|
|
100
103
|
"prefixCls": prefixCls,
|
|
101
104
|
"popup": mergedOptions.value?.popup,
|
|
102
|
-
"
|
|
105
|
+
"onEsc": mergedOptions.value?.onEsc,
|
|
106
|
+
"className": (0, _v_c_util.classNames)(mergedOptions.value?.popupClassName, alignedClassName.value, `${prefixCls}-unique-controlled`),
|
|
103
107
|
"style": mergedOptions.value?.popupStyle,
|
|
104
108
|
"target": mergedOptions.value?.target,
|
|
105
109
|
"open": open.value,
|
|
@@ -147,7 +151,7 @@ var UniqueProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots })
|
|
|
147
151
|
},
|
|
148
152
|
"popupSize": popupSize.value,
|
|
149
153
|
"motion": mergedOptions.value?.popupMotion,
|
|
150
|
-
"uniqueContainerClassName": (0,
|
|
154
|
+
"uniqueContainerClassName": (0, _v_c_util.classNames)(mergedOptions.value?.uniqueContainerClassName, alignedClassName.value),
|
|
151
155
|
"uniqueContainerStyle": mergedOptions?.value?.uniqueContainerStyle
|
|
152
156
|
}, null)] })] })] });
|
|
153
157
|
};
|
|
@@ -96,6 +96,7 @@ var UniqueProvider_default = /* @__PURE__ */ defineComponent((props, { slots })
|
|
|
96
96
|
"portal": Portal,
|
|
97
97
|
"prefixCls": prefixCls,
|
|
98
98
|
"popup": mergedOptions.value?.popup,
|
|
99
|
+
"onEsc": mergedOptions.value?.onEsc,
|
|
99
100
|
"className": classNames(mergedOptions.value?.popupClassName, alignedClassName.value, `${prefixCls}-unique-controlled`),
|
|
100
101
|
"style": mergedOptions.value?.popupStyle,
|
|
101
102
|
"target": mergedOptions.value?.target,
|
|
@@ -1,4 +1,7 @@
|
|
|
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
7
|
function useTargetState() {
|
package/dist/context.cjs
CHANGED
package/dist/context.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PortalProps } from '@v-c/portal';
|
|
1
2
|
import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
|
|
2
3
|
import { CSSProperties, InjectionKey, Ref } from 'vue';
|
|
3
4
|
import { TriggerProps } from './index';
|
|
@@ -32,6 +33,7 @@ export interface UniqueShowOptions {
|
|
|
32
33
|
arrow?: ArrowTypeOuter;
|
|
33
34
|
getPopupContainer?: TriggerProps['getPopupContainer'];
|
|
34
35
|
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
36
|
+
onEsc?: PortalProps['onEsc'];
|
|
35
37
|
}
|
|
36
38
|
export interface UniqueContextProps {
|
|
37
39
|
show: (options: UniqueShowOptions, isOpen: () => boolean) => void;
|
package/dist/hooks/useAction.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_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
6
|
let vue = require("vue");
|
|
4
7
|
function toArray(val) {
|
package/dist/hooks/useAlign.cjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
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
|
let vue = require("vue");
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
+
let _v_c_util_dist_Dom_findDOMNode = require("@v-c/util/dist/Dom/findDOMNode");
|
|
9
|
+
let _v_c_util_dist_Dom_isVisible = require("@v-c/util/dist/Dom/isVisible");
|
|
10
|
+
_v_c_util_dist_Dom_isVisible = require_rolldown_runtime.__toESM(_v_c_util_dist_Dom_isVisible);
|
|
8
11
|
function getUnitOffset(size, offset = 0) {
|
|
9
12
|
const offsetStr = `${offset}`;
|
|
10
13
|
const cells = offsetStr.match(/^(.*)\%$/);
|
|
@@ -41,10 +44,12 @@ function reversePoints(points, index) {
|
|
|
41
44
|
l: "r",
|
|
42
45
|
r: "l"
|
|
43
46
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const clone = [...points];
|
|
48
|
+
clone[index] = reverseMap[points[index]] || "c";
|
|
49
|
+
return clone;
|
|
50
|
+
}
|
|
51
|
+
function flatPoints(points) {
|
|
52
|
+
return points.join("");
|
|
48
53
|
}
|
|
49
54
|
function shouldSwitchPlacement(isOverflow, isVisibleFirst, newVisibleArea, originVisibleArea, newRecommendArea, originRecommendArea) {
|
|
50
55
|
if (isOverflow) return newVisibleArea > originVisibleArea || newVisibleArea === originVisibleArea && (!isVisibleFirst || newRecommendArea >= originRecommendArea);
|
|
@@ -169,7 +174,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
169
174
|
const popupMirrorRect = rawPopupMirrorRect;
|
|
170
175
|
const scaleX$1 = require_util.toNum(Math.round(popupWidth / parseFloat(width) * 1e3) / 1e3);
|
|
171
176
|
const scaleY$1 = require_util.toNum(Math.round(popupHeight / parseFloat(height) * 1e3) / 1e3);
|
|
172
|
-
if (scaleX$1 === 0 || scaleY$1 === 0 || (0,
|
|
177
|
+
if (scaleX$1 === 0 || scaleY$1 === 0 || (0, _v_c_util_dist_Dom_findDOMNode.isDOM)(target) && !(0, _v_c_util_dist_Dom_isVisible.default)(target)) return;
|
|
173
178
|
const { offset, targetOffset } = placementInfo;
|
|
174
179
|
let [popupOffsetX, popupOffsetY] = getNumberOffset(popupRect, offset);
|
|
175
180
|
const [targetOffsetX, targetOffsetY] = getNumberOffset(targetRect, targetOffset);
|
|
@@ -181,6 +186,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
181
186
|
const targetAlignPoint = getAlignPoint(targetRect, targetPoints);
|
|
182
187
|
const popupAlignPoint = getAlignPoint(popupRect, popupPoints);
|
|
183
188
|
const nextAlignInfo = { ...placementInfo };
|
|
189
|
+
let nextPoints = [popupPoints, targetPoints];
|
|
184
190
|
let nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;
|
|
185
191
|
let nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY;
|
|
186
192
|
function getIntersectionVisibleArea(offsetX$1, offsetY$1, area = visibleArea) {
|
|
@@ -227,7 +233,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
227
233
|
prevFlipRef.value.bt = true;
|
|
228
234
|
nextOffsetY = tmpNextOffsetY;
|
|
229
235
|
popupOffsetY = -popupOffsetY;
|
|
230
|
-
|
|
236
|
+
nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
|
|
231
237
|
} else prevFlipRef.value.bt = false;
|
|
232
238
|
}
|
|
233
239
|
const overflowTop = nextPopupY < adjustCheckVisibleArea.top;
|
|
@@ -239,7 +245,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
239
245
|
prevFlipRef.value.tb = true;
|
|
240
246
|
nextOffsetY = tmpNextOffsetY;
|
|
241
247
|
popupOffsetY = -popupOffsetY;
|
|
242
|
-
|
|
248
|
+
nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
|
|
243
249
|
} else prevFlipRef.value.tb = false;
|
|
244
250
|
}
|
|
245
251
|
const needAdjustX = supportAdjust(adjustX);
|
|
@@ -253,7 +259,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
253
259
|
prevFlipRef.value.rl = true;
|
|
254
260
|
nextOffsetX = tmpNextOffsetX;
|
|
255
261
|
popupOffsetX = -popupOffsetX;
|
|
256
|
-
|
|
262
|
+
nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
|
|
257
263
|
} else prevFlipRef.value.rl = false;
|
|
258
264
|
}
|
|
259
265
|
const overflowLeft = nextPopupX < adjustCheckVisibleArea.left;
|
|
@@ -265,9 +271,10 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
265
271
|
prevFlipRef.value.lr = true;
|
|
266
272
|
nextOffsetX = tmpNextOffsetX;
|
|
267
273
|
popupOffsetX = -popupOffsetX;
|
|
268
|
-
|
|
274
|
+
nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
|
|
269
275
|
} else prevFlipRef.value.lr = false;
|
|
270
276
|
}
|
|
277
|
+
nextAlignInfo.points = [flatPoints(nextPoints[0]), flatPoints(nextPoints[1])];
|
|
271
278
|
syncNextPopupPosition();
|
|
272
279
|
const numShiftX = shiftX === true ? 0 : shiftX;
|
|
273
280
|
if (typeof numShiftX === "number") {
|
|
@@ -305,12 +312,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
305
312
|
let offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
|
|
306
313
|
let offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
|
|
307
314
|
if (scaleX$1 === 1) {
|
|
308
|
-
nextOffsetX = Math.
|
|
309
|
-
offsetX4Right = Math.
|
|
315
|
+
nextOffsetX = Math.floor(nextOffsetX);
|
|
316
|
+
offsetX4Right = Math.floor(offsetX4Right);
|
|
310
317
|
}
|
|
311
318
|
if (scaleY$1 === 1) {
|
|
312
|
-
nextOffsetY = Math.
|
|
313
|
-
offsetY4Bottom = Math.
|
|
319
|
+
nextOffsetY = Math.floor(nextOffsetY);
|
|
320
|
+
offsetY4Bottom = Math.floor(offsetY4Bottom);
|
|
314
321
|
}
|
|
315
322
|
const nextOffsetInfo = {
|
|
316
323
|
ready: true,
|
package/dist/hooks/useAlign.js
CHANGED
|
@@ -38,10 +38,12 @@ function reversePoints(points, index) {
|
|
|
38
38
|
l: "r",
|
|
39
39
|
r: "l"
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const clone = [...points];
|
|
42
|
+
clone[index] = reverseMap[points[index]] || "c";
|
|
43
|
+
return clone;
|
|
44
|
+
}
|
|
45
|
+
function flatPoints(points) {
|
|
46
|
+
return points.join("");
|
|
45
47
|
}
|
|
46
48
|
function shouldSwitchPlacement(isOverflow, isVisibleFirst, newVisibleArea, originVisibleArea, newRecommendArea, originRecommendArea) {
|
|
47
49
|
if (isOverflow) return newVisibleArea > originVisibleArea || newVisibleArea === originVisibleArea && (!isVisibleFirst || newRecommendArea >= originRecommendArea);
|
|
@@ -178,6 +180,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
178
180
|
const targetAlignPoint = getAlignPoint(targetRect, targetPoints);
|
|
179
181
|
const popupAlignPoint = getAlignPoint(popupRect, popupPoints);
|
|
180
182
|
const nextAlignInfo = { ...placementInfo };
|
|
183
|
+
let nextPoints = [popupPoints, targetPoints];
|
|
181
184
|
let nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;
|
|
182
185
|
let nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY;
|
|
183
186
|
function getIntersectionVisibleArea(offsetX$1, offsetY$1, area = visibleArea) {
|
|
@@ -224,7 +227,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
224
227
|
prevFlipRef.value.bt = true;
|
|
225
228
|
nextOffsetY = tmpNextOffsetY;
|
|
226
229
|
popupOffsetY = -popupOffsetY;
|
|
227
|
-
|
|
230
|
+
nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
|
|
228
231
|
} else prevFlipRef.value.bt = false;
|
|
229
232
|
}
|
|
230
233
|
const overflowTop = nextPopupY < adjustCheckVisibleArea.top;
|
|
@@ -236,7 +239,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
236
239
|
prevFlipRef.value.tb = true;
|
|
237
240
|
nextOffsetY = tmpNextOffsetY;
|
|
238
241
|
popupOffsetY = -popupOffsetY;
|
|
239
|
-
|
|
242
|
+
nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
|
|
240
243
|
} else prevFlipRef.value.tb = false;
|
|
241
244
|
}
|
|
242
245
|
const needAdjustX = supportAdjust(adjustX);
|
|
@@ -250,7 +253,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
250
253
|
prevFlipRef.value.rl = true;
|
|
251
254
|
nextOffsetX = tmpNextOffsetX;
|
|
252
255
|
popupOffsetX = -popupOffsetX;
|
|
253
|
-
|
|
256
|
+
nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
|
|
254
257
|
} else prevFlipRef.value.rl = false;
|
|
255
258
|
}
|
|
256
259
|
const overflowLeft = nextPopupX < adjustCheckVisibleArea.left;
|
|
@@ -262,9 +265,10 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
262
265
|
prevFlipRef.value.lr = true;
|
|
263
266
|
nextOffsetX = tmpNextOffsetX;
|
|
264
267
|
popupOffsetX = -popupOffsetX;
|
|
265
|
-
|
|
268
|
+
nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
|
|
266
269
|
} else prevFlipRef.value.lr = false;
|
|
267
270
|
}
|
|
271
|
+
nextAlignInfo.points = [flatPoints(nextPoints[0]), flatPoints(nextPoints[1])];
|
|
268
272
|
syncNextPopupPosition();
|
|
269
273
|
const numShiftX = shiftX === true ? 0 : shiftX;
|
|
270
274
|
if (typeof numShiftX === "number") {
|
|
@@ -302,12 +306,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
302
306
|
let offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
|
|
303
307
|
let offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
|
|
304
308
|
if (scaleX$1 === 1) {
|
|
305
|
-
nextOffsetX = Math.
|
|
306
|
-
offsetX4Right = Math.
|
|
309
|
+
nextOffsetX = Math.floor(nextOffsetX);
|
|
310
|
+
offsetX4Right = Math.floor(offsetX4Right);
|
|
307
311
|
}
|
|
308
312
|
if (scaleY$1 === 1) {
|
|
309
|
-
nextOffsetY = Math.
|
|
310
|
-
offsetY4Bottom = Math.
|
|
313
|
+
nextOffsetY = Math.floor(nextOffsetY);
|
|
314
|
+
offsetY4Bottom = Math.floor(offsetY4Bottom);
|
|
311
315
|
}
|
|
312
316
|
const nextOffsetInfo = {
|
|
313
317
|
ready: true,
|
package/dist/hooks/useDelay.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_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
6
|
let vue = require("vue");
|
|
4
7
|
function useDelay() {
|
|
@@ -1,4 +1,7 @@
|
|
|
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
7
|
function useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX, offsetY) {
|
|
@@ -10,7 +13,6 @@ function useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX,
|
|
|
10
13
|
right: AUTO,
|
|
11
14
|
bottom: AUTO
|
|
12
15
|
};
|
|
13
|
-
if (!(offsetX.value > 0 || offsetY.value > 0 || offsetR.value > 0 || offsetB.value > 0)) return {};
|
|
14
16
|
if (!isMobile.value && (ready.value || !open.value)) {
|
|
15
17
|
const { points } = align.value ?? {};
|
|
16
18
|
const dynamicInset = align.value?.dynamicInset || align.value?._experimental?.dynamicInset;
|
|
@@ -8,7 +8,6 @@ function useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX,
|
|
|
8
8
|
right: AUTO,
|
|
9
9
|
bottom: AUTO
|
|
10
10
|
};
|
|
11
|
-
if (!(offsetX.value > 0 || offsetY.value > 0 || offsetR.value > 0 || offsetB.value > 0)) return {};
|
|
12
11
|
if (!isMobile.value && (ready.value || !open.value)) {
|
|
13
12
|
const { points } = align.value ?? {};
|
|
14
13
|
const dynamicInset = align.value?.dynamicInset || align.value?._experimental?.dynamicInset;
|
package/dist/hooks/useWatch.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_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
6
|
const require_util = require("../util.cjs");
|
|
4
7
|
let vue = require("vue");
|
|
@@ -8,8 +11,8 @@ function useWatch(open, target, popup, onAlign, onScroll) {
|
|
|
8
11
|
target,
|
|
9
12
|
popup
|
|
10
13
|
], async (_n, _o, onCleanup) => {
|
|
11
|
-
await (0, vue.nextTick)();
|
|
12
14
|
if (open.value && target.value && popup.value) {
|
|
15
|
+
await (0, vue.nextTick)();
|
|
13
16
|
const targetElement = target.value;
|
|
14
17
|
const popupElement = popup.value;
|
|
15
18
|
const targetScrollList = require_util.collectScroller(targetElement);
|
|
@@ -36,6 +39,6 @@ function useWatch(open, target, popup, onAlign, onScroll) {
|
|
|
36
39
|
});
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
|
-
});
|
|
42
|
+
}, { flush: "post" });
|
|
40
43
|
}
|
|
41
44
|
exports.default = useWatch;
|
package/dist/hooks/useWatch.js
CHANGED
|
@@ -6,8 +6,8 @@ function useWatch(open, target, popup, onAlign, onScroll) {
|
|
|
6
6
|
target,
|
|
7
7
|
popup
|
|
8
8
|
], async (_n, _o, onCleanup) => {
|
|
9
|
-
await nextTick();
|
|
10
9
|
if (open.value && target.value && popup.value) {
|
|
10
|
+
await nextTick();
|
|
11
11
|
const targetElement = target.value;
|
|
12
12
|
const popupElement = popup.value;
|
|
13
13
|
const targetScrollList = collectScroller(targetElement);
|
|
@@ -34,6 +34,6 @@ function useWatch(open, target, popup, onAlign, onScroll) {
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
});
|
|
37
|
+
}, { flush: "post" });
|
|
38
38
|
}
|
|
39
39
|
export { useWatch as default };
|
|
@@ -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
|
let vue = require("vue");
|
|
5
|
-
let
|
|
6
|
-
let
|
|
8
|
+
let _v_c_util = require("@v-c/util");
|
|
9
|
+
let _v_c_util_dist_Dom_shadow = require("@v-c/util/dist/Dom/shadow");
|
|
7
10
|
function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable, inPopupOrChild, triggerOpen) {
|
|
8
11
|
const openRef = (0, vue.shallowRef)(open.value);
|
|
9
12
|
(0, vue.watchEffect)(() => {
|
|
@@ -28,7 +31,7 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
|
|
|
28
31
|
win.addEventListener("pointerdown", onPointerDown, true);
|
|
29
32
|
win.addEventListener("mousedown", onTriggerClose, true);
|
|
30
33
|
win.addEventListener("contextmenu", onTriggerClose, true);
|
|
31
|
-
const targetShadowRoot = (0,
|
|
34
|
+
const targetShadowRoot = (0, _v_c_util_dist_Dom_shadow.getShadowRoot)(targetEle$1);
|
|
32
35
|
if (targetShadowRoot) {
|
|
33
36
|
targetShadowRoot.addEventListener("mousedown", onTriggerClose, true);
|
|
34
37
|
targetShadowRoot.addEventListener("contextmenu", onTriggerClose, true);
|
|
@@ -36,7 +39,7 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
|
|
|
36
39
|
if (process.env.NODE_ENV !== "production" && targetEle$1) {
|
|
37
40
|
const targetRoot = targetEle$1.getRootNode?.();
|
|
38
41
|
const popupRoot = popupEle$1.getRootNode?.();
|
|
39
|
-
(0,
|
|
42
|
+
(0, _v_c_util.warning)(targetRoot === popupRoot, `trigger element and popup element should in same shadow root.`);
|
|
40
43
|
}
|
|
41
44
|
onCleanup(() => {
|
|
42
45
|
win.removeEventListener("pointerdown", onPointerDown, true);
|
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_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
3
6
|
const require_context = require("./context.cjs");
|
|
4
7
|
const require_useAction = require("./hooks/useAction.cjs");
|
|
@@ -10,17 +13,13 @@ const require_useWinClick = require("./hooks/useWinClick.cjs");
|
|
|
10
13
|
const require_index = require("./Popup/index.cjs");
|
|
11
14
|
const require_index$1 = require("./UniqueProvider/index.cjs");
|
|
12
15
|
let vue = require("vue");
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
let
|
|
19
|
-
let
|
|
20
|
-
let __v_c_util_dist_vnode = require("@v-c/util/dist/vnode");
|
|
21
|
-
function _isSlot(s) {
|
|
22
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
|
|
23
|
-
}
|
|
16
|
+
let _v_c_portal = require("@v-c/portal");
|
|
17
|
+
_v_c_portal = require_rolldown_runtime.__toESM(_v_c_portal);
|
|
18
|
+
let _v_c_resize_observer = require("@v-c/resize-observer");
|
|
19
|
+
let _v_c_util = require("@v-c/util");
|
|
20
|
+
let _v_c_util_dist_Dom_shadow = require("@v-c/util/dist/Dom/shadow");
|
|
21
|
+
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
22
|
+
let _v_c_util_dist_vnode = require("@v-c/util/dist/vnode");
|
|
24
23
|
var defaults = {
|
|
25
24
|
prefixCls: "vc-trigger-popup",
|
|
26
25
|
action: "hover",
|
|
@@ -30,7 +29,7 @@ var defaults = {
|
|
|
30
29
|
popupVisible: void 0,
|
|
31
30
|
defaultPopupVisible: void 0
|
|
32
31
|
};
|
|
33
|
-
function generateTrigger(PortalComponent =
|
|
32
|
+
function generateTrigger(PortalComponent = _v_c_portal.default) {
|
|
34
33
|
return /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots, attrs }) => {
|
|
35
34
|
const mergedAutoDestroy = (0, vue.computed)(() => props.autoDestroy ?? false);
|
|
36
35
|
const openUncontrolled = (0, vue.computed)(() => props.popupVisible === void 0);
|
|
@@ -49,20 +48,20 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
49
48
|
const popupEle = (0, vue.shallowRef)(null);
|
|
50
49
|
const externalPopupRef = (0, vue.shallowRef)(null);
|
|
51
50
|
const setPopupRef = (node) => {
|
|
52
|
-
const element = (0,
|
|
51
|
+
const element = (0, _v_c_util_dist_vnode.resolveToElement)(node);
|
|
53
52
|
externalPopupRef.value = element;
|
|
54
53
|
if (popupEle.value !== element) popupEle.value = element;
|
|
55
54
|
parentContext?.value?.registerSubPopup(id, element ?? null);
|
|
56
55
|
};
|
|
57
|
-
const targetEle = (0, vue.shallowRef)(
|
|
56
|
+
const targetEle = (0, vue.shallowRef)();
|
|
58
57
|
const externalForwardRef = (0, vue.shallowRef)(null);
|
|
59
58
|
const setTargetRef = (node) => {
|
|
60
|
-
const element = (0,
|
|
59
|
+
const element = (0, _v_c_util_dist_vnode.resolveToElement)(node);
|
|
61
60
|
if (element && targetEle.value !== element) {
|
|
62
61
|
targetEle.value = element;
|
|
63
62
|
externalForwardRef.value = element;
|
|
64
63
|
} else if (!element) {
|
|
65
|
-
targetEle.value =
|
|
64
|
+
targetEle.value = void 0;
|
|
66
65
|
externalForwardRef.value = null;
|
|
67
66
|
}
|
|
68
67
|
};
|
|
@@ -75,7 +74,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
75
74
|
}));
|
|
76
75
|
const inPopupOrChild = (ele) => {
|
|
77
76
|
const childDOM = targetEle.value;
|
|
78
|
-
return childDOM?.contains(ele) || childDOM && (0,
|
|
77
|
+
return childDOM?.contains(ele) || childDOM && (0, _v_c_util_dist_Dom_shadow.getShadowRoot)(childDOM)?.host === ele || ele === childDOM || popupEle.value?.contains(ele) || popupEle.value && (0, _v_c_util_dist_Dom_shadow.getShadowRoot)(popupEle.value)?.host === ele || ele === popupEle.value || Object.values(subPopupElements.value).some((subPopupEle) => subPopupEle?.contains(ele) || ele === subPopupEle);
|
|
79
78
|
};
|
|
80
79
|
const innerArrow = (0, vue.computed)(() => {
|
|
81
80
|
return props.arrow ? { ...props?.arrow !== true ? props?.arrow : {} } : null;
|
|
@@ -85,9 +84,6 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
85
84
|
const mergedOpen = (0, vue.computed)(() => {
|
|
86
85
|
return props?.popupVisible ?? internalOpen.value;
|
|
87
86
|
});
|
|
88
|
-
const setMergedOpen = (nextOpen) => {
|
|
89
|
-
if (openUncontrolled.value) internalOpen.value = nextOpen;
|
|
90
|
-
};
|
|
91
87
|
const isOpen = () => mergedOpen.value;
|
|
92
88
|
(0, vue.watch)(() => props.popupVisible, async (nextVisible) => {
|
|
93
89
|
if (nextVisible !== void 0) {
|
|
@@ -116,7 +112,8 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
116
112
|
arrow: innerArrow.value,
|
|
117
113
|
getPopupContainer: props.getPopupContainer,
|
|
118
114
|
getPopupClassNameFromAlign: props.getPopupClassNameFromAlign,
|
|
119
|
-
id
|
|
115
|
+
id,
|
|
116
|
+
onEsc
|
|
120
117
|
};
|
|
121
118
|
};
|
|
122
119
|
(0, vue.watch)([mergedOpen, targetEle], () => {
|
|
@@ -126,16 +123,9 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
126
123
|
} else uniqueContext?.hide(props.mouseLeaveDelay || 0);
|
|
127
124
|
});
|
|
128
125
|
const openRef = (0, vue.shallowRef)(mergedOpen.value);
|
|
129
|
-
const lastTriggerRef = (0, vue.shallowRef)([]);
|
|
130
|
-
lastTriggerRef.value = [];
|
|
131
|
-
(0, vue.watchEffect)(() => {
|
|
132
|
-
openRef.value = mergedOpen.value;
|
|
133
|
-
if (!mergedOpen.value) lastTriggerRef.value = [];
|
|
134
|
-
});
|
|
135
126
|
const internalTriggerOpen = (nextOpen) => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
lastTriggerRef.value.push(nextOpen);
|
|
127
|
+
if (mergedOpen.value !== nextOpen) {
|
|
128
|
+
internalOpen.value = nextOpen;
|
|
139
129
|
props?.onOpenChange?.(nextOpen);
|
|
140
130
|
props?.onPopupVisibleChange?.(nextOpen);
|
|
141
131
|
}
|
|
@@ -157,6 +147,9 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
157
147
|
internalTriggerOpen(nextOpen);
|
|
158
148
|
}, delay);
|
|
159
149
|
};
|
|
150
|
+
function onEsc({ top }) {
|
|
151
|
+
if (top) triggerOpen(false);
|
|
152
|
+
}
|
|
160
153
|
const inMotion = (0, vue.shallowRef)(false);
|
|
161
154
|
(0, vue.watch)(mergedOpen, () => {
|
|
162
155
|
if (mergedOpen.value) inMotion.value = true;
|
|
@@ -188,7 +181,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
188
181
|
if (mergedOpen.value && !builtinPlacements?.[popupPlacement]) triggerAlign();
|
|
189
182
|
});
|
|
190
183
|
const alignedClassName = (0, vue.computed)(() => {
|
|
191
|
-
return (0,
|
|
184
|
+
return (0, _v_c_util.classNames)(require_util.getAlignPopupClassName(props.builtinPlacements, props.prefixCls, alignInfo.value, props.alignPoint), props?.getPopupClassNameFromAlign?.(alignInfo.value));
|
|
192
185
|
});
|
|
193
186
|
expose({
|
|
194
187
|
nativeElement: externalForwardRef,
|
|
@@ -309,8 +302,9 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
309
302
|
(0, vue.watchEffect)(() => {
|
|
310
303
|
rendedRef.value ||= props.forceRender || mergedOpen.value || inMotion.value;
|
|
311
304
|
});
|
|
305
|
+
(0, _v_c_resize_observer.useResizeObserver)(mergedOpen, targetEle, onTargetResize);
|
|
312
306
|
return () => {
|
|
313
|
-
const child = (0,
|
|
307
|
+
const child = (0, _v_c_util_dist_props_util.filterEmpty)(slots?.default?.() ?? [])?.[0];
|
|
314
308
|
const mergedChildrenProps = {
|
|
315
309
|
...originChildProps,
|
|
316
310
|
...cloneProps.value
|
|
@@ -341,15 +335,12 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
341
335
|
ref: setTargetRef
|
|
342
336
|
});
|
|
343
337
|
const { unique, prefixCls, popup, popupClassName, popupStyle, zIndex, fresh, onPopupClick, mask, popupMotion, maskMotion, forceRender, getPopupContainer, stretch, mobile } = props;
|
|
344
|
-
return (0, vue.createVNode)(vue.Fragment, null, [(0, vue.createVNode)(
|
|
345
|
-
"disabled": !mergedOpen.value,
|
|
346
|
-
"onResize": onTargetResize
|
|
347
|
-
}, _isSlot(triggerNode) ? triggerNode : { default: () => [triggerNode] }), rendedRef.value && targetEle.value && (!uniqueContext || !unique) && (0, vue.createVNode)(require_context.TriggerContextProvider, context.value, { default: () => [(0, vue.createVNode)(require_index.default, {
|
|
338
|
+
return (0, vue.createVNode)(vue.Fragment, null, [triggerNode, rendedRef.value && targetEle.value && (!uniqueContext || !unique) && (0, vue.createVNode)(require_context.TriggerContextProvider, context.value, { default: () => [(0, vue.createVNode)(require_index.default, {
|
|
348
339
|
"portal": PortalComponent,
|
|
349
340
|
"ref": setPopupRef,
|
|
350
341
|
"prefixCls": prefixCls,
|
|
351
342
|
"popup": popup,
|
|
352
|
-
"className": (0,
|
|
343
|
+
"className": (0, _v_c_util.classNames)(popupClassName, !isMobile.value && alignedClassName.value),
|
|
353
344
|
"style": popupStyle,
|
|
354
345
|
"target": targetEle.value,
|
|
355
346
|
"onMouseEnter": onPopupMouseEnter,
|
|
@@ -360,6 +351,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
360
351
|
"keepDom": inMotion.value,
|
|
361
352
|
"fresh": fresh,
|
|
362
353
|
"onClick": onPopupClick,
|
|
354
|
+
"onEsc": onEsc,
|
|
363
355
|
"onPointerDownCapture": onPopupPointerDown,
|
|
364
356
|
"mask": mask,
|
|
365
357
|
"motion": popupMotion,
|
|
@@ -590,7 +582,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
590
582
|
}
|
|
591
583
|
}, defaults) });
|
|
592
584
|
}
|
|
593
|
-
var Trigger = generateTrigger(
|
|
585
|
+
var Trigger = generateTrigger(_v_c_portal.default);
|
|
594
586
|
var src_default = Trigger;
|
|
595
587
|
exports.Trigger = Trigger;
|
|
596
588
|
exports.UniqueProvider = require_index$1.default;
|
package/dist/index.js
CHANGED
|
@@ -7,16 +7,13 @@ import useWatch from "./hooks/useWatch.js";
|
|
|
7
7
|
import useWinClick from "./hooks/useWinClick.js";
|
|
8
8
|
import Popup_default from "./Popup/index.js";
|
|
9
9
|
import UniqueProvider_default from "./UniqueProvider/index.js";
|
|
10
|
-
import { Fragment, computed, createVNode, defineComponent,
|
|
10
|
+
import { Fragment, computed, createVNode, defineComponent, mergeDefaults, nextTick, reactive, ref, shallowRef, useId, watch, watchEffect } from "vue";
|
|
11
11
|
import Portal from "@v-c/portal";
|
|
12
|
-
import
|
|
12
|
+
import { useResizeObserver } from "@v-c/resize-observer";
|
|
13
13
|
import { classNames } from "@v-c/util";
|
|
14
14
|
import { getShadowRoot } from "@v-c/util/dist/Dom/shadow";
|
|
15
15
|
import { filterEmpty } from "@v-c/util/dist/props-util";
|
|
16
16
|
import { resolveToElement } from "@v-c/util/dist/vnode";
|
|
17
|
-
function _isSlot(s) {
|
|
18
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
19
|
-
}
|
|
20
17
|
var defaults = {
|
|
21
18
|
prefixCls: "vc-trigger-popup",
|
|
22
19
|
action: "hover",
|
|
@@ -50,7 +47,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
50
47
|
if (popupEle.value !== element) popupEle.value = element;
|
|
51
48
|
parentContext?.value?.registerSubPopup(id, element ?? null);
|
|
52
49
|
};
|
|
53
|
-
const targetEle = shallowRef(
|
|
50
|
+
const targetEle = shallowRef();
|
|
54
51
|
const externalForwardRef = shallowRef(null);
|
|
55
52
|
const setTargetRef = (node) => {
|
|
56
53
|
const element = resolveToElement(node);
|
|
@@ -58,7 +55,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
58
55
|
targetEle.value = element;
|
|
59
56
|
externalForwardRef.value = element;
|
|
60
57
|
} else if (!element) {
|
|
61
|
-
targetEle.value =
|
|
58
|
+
targetEle.value = void 0;
|
|
62
59
|
externalForwardRef.value = null;
|
|
63
60
|
}
|
|
64
61
|
};
|
|
@@ -81,9 +78,6 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
81
78
|
const mergedOpen = computed(() => {
|
|
82
79
|
return props?.popupVisible ?? internalOpen.value;
|
|
83
80
|
});
|
|
84
|
-
const setMergedOpen = (nextOpen) => {
|
|
85
|
-
if (openUncontrolled.value) internalOpen.value = nextOpen;
|
|
86
|
-
};
|
|
87
81
|
const isOpen = () => mergedOpen.value;
|
|
88
82
|
watch(() => props.popupVisible, async (nextVisible) => {
|
|
89
83
|
if (nextVisible !== void 0) {
|
|
@@ -112,7 +106,8 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
112
106
|
arrow: innerArrow.value,
|
|
113
107
|
getPopupContainer: props.getPopupContainer,
|
|
114
108
|
getPopupClassNameFromAlign: props.getPopupClassNameFromAlign,
|
|
115
|
-
id
|
|
109
|
+
id,
|
|
110
|
+
onEsc
|
|
116
111
|
};
|
|
117
112
|
};
|
|
118
113
|
watch([mergedOpen, targetEle], () => {
|
|
@@ -122,16 +117,9 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
122
117
|
} else uniqueContext?.hide(props.mouseLeaveDelay || 0);
|
|
123
118
|
});
|
|
124
119
|
const openRef = shallowRef(mergedOpen.value);
|
|
125
|
-
const lastTriggerRef = shallowRef([]);
|
|
126
|
-
lastTriggerRef.value = [];
|
|
127
|
-
watchEffect(() => {
|
|
128
|
-
openRef.value = mergedOpen.value;
|
|
129
|
-
if (!mergedOpen.value) lastTriggerRef.value = [];
|
|
130
|
-
});
|
|
131
120
|
const internalTriggerOpen = (nextOpen) => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
lastTriggerRef.value.push(nextOpen);
|
|
121
|
+
if (mergedOpen.value !== nextOpen) {
|
|
122
|
+
internalOpen.value = nextOpen;
|
|
135
123
|
props?.onOpenChange?.(nextOpen);
|
|
136
124
|
props?.onPopupVisibleChange?.(nextOpen);
|
|
137
125
|
}
|
|
@@ -153,6 +141,9 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
153
141
|
internalTriggerOpen(nextOpen);
|
|
154
142
|
}, delay);
|
|
155
143
|
};
|
|
144
|
+
function onEsc({ top }) {
|
|
145
|
+
if (top) triggerOpen(false);
|
|
146
|
+
}
|
|
156
147
|
const inMotion = shallowRef(false);
|
|
157
148
|
watch(mergedOpen, () => {
|
|
158
149
|
if (mergedOpen.value) inMotion.value = true;
|
|
@@ -305,6 +296,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
305
296
|
watchEffect(() => {
|
|
306
297
|
rendedRef.value ||= props.forceRender || mergedOpen.value || inMotion.value;
|
|
307
298
|
});
|
|
299
|
+
useResizeObserver(mergedOpen, targetEle, onTargetResize);
|
|
308
300
|
return () => {
|
|
309
301
|
const child = filterEmpty(slots?.default?.() ?? [])?.[0];
|
|
310
302
|
const mergedChildrenProps = {
|
|
@@ -337,10 +329,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
337
329
|
ref: setTargetRef
|
|
338
330
|
});
|
|
339
331
|
const { unique, prefixCls, popup, popupClassName, popupStyle, zIndex, fresh, onPopupClick, mask, popupMotion, maskMotion, forceRender, getPopupContainer, stretch, mobile } = props;
|
|
340
|
-
return createVNode(Fragment, null, [createVNode(
|
|
341
|
-
"disabled": !mergedOpen.value,
|
|
342
|
-
"onResize": onTargetResize
|
|
343
|
-
}, _isSlot(triggerNode) ? triggerNode : { default: () => [triggerNode] }), rendedRef.value && targetEle.value && (!uniqueContext || !unique) && createVNode(TriggerContextProvider, context.value, { default: () => [createVNode(Popup_default, {
|
|
332
|
+
return createVNode(Fragment, null, [triggerNode, rendedRef.value && targetEle.value && (!uniqueContext || !unique) && createVNode(TriggerContextProvider, context.value, { default: () => [createVNode(Popup_default, {
|
|
344
333
|
"portal": PortalComponent,
|
|
345
334
|
"ref": setPopupRef,
|
|
346
335
|
"prefixCls": prefixCls,
|
|
@@ -356,6 +345,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
356
345
|
"keepDom": inMotion.value,
|
|
357
346
|
"fresh": fresh,
|
|
358
347
|
"onClick": onPopupClick,
|
|
348
|
+
"onEsc": onEsc,
|
|
359
349
|
"onPointerDownCapture": onPopupPointerDown,
|
|
360
350
|
"mask": mask,
|
|
361
351
|
"motion": popupMotion,
|
package/dist/interface.cjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
package/dist/util.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
2
|
function isPointsEq(a1 = [], a2 = [], isAlignPoint) {
|
|
2
|
-
|
|
3
|
-
return a1
|
|
3
|
+
const getVal = (a, index) => a[index] || "";
|
|
4
|
+
if (isAlignPoint) return getVal(a1, 0) === getVal(a2, 0);
|
|
5
|
+
return getVal(a1, 0) === getVal(a2, 0) && getVal(a1, 1) === getVal(a2, 1);
|
|
4
6
|
}
|
|
5
7
|
function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
|
|
6
8
|
const { points } = align;
|
package/dist/util.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function isPointsEq(a1 = [], a2 = [], isAlignPoint) {
|
|
2
|
-
|
|
3
|
-
return a1
|
|
2
|
+
const getVal = (a, index) => a[index] || "";
|
|
3
|
+
if (isAlignPoint) return getVal(a1, 0) === getVal(a2, 0);
|
|
4
|
+
return getVal(a1, 0) === getVal(a2, 0) && getVal(a1, 1) === getVal(a2, 1);
|
|
4
5
|
}
|
|
5
6
|
function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
|
|
6
7
|
const { points } = align;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/trigger",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"vue": "^3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@v-c/
|
|
33
|
-
"@v-c/
|
|
34
|
-
"@v-c/
|
|
32
|
+
"@v-c/resize-observer": "^1.0.6",
|
|
33
|
+
"@v-c/util": "^1.0.8",
|
|
34
|
+
"@v-c/portal": "^1.0.4"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "vite build",
|