@v-c/trigger 1.0.3 → 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/index.cjs +3 -7
- package/dist/Popup/index.js +3 -7
- package/dist/UniqueProvider/UniqueContainer.cjs +11 -13
- package/dist/UniqueProvider/UniqueContainer.js +12 -14
- package/dist/hooks/useAlign.cjs +2 -2
- package/dist/hooks/useAlign.js +2 -2
- package/dist/hooks/useOffsetStyle.cjs +0 -1
- package/dist/hooks/useOffsetStyle.js +0 -1
- package/dist/hooks/useWatch.cjs +2 -2
- package/dist/hooks/useWatch.js +2 -2
- package/package.json +3 -3
package/dist/Popup/index.cjs
CHANGED
|
@@ -6,14 +6,12 @@ const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
|
6
6
|
const require_useOffsetStyle = require("../hooks/useOffsetStyle.cjs");
|
|
7
7
|
const require_Arrow = require("./Arrow.cjs");
|
|
8
8
|
const require_Mask = require("./Mask.cjs");
|
|
9
|
-
const require_PopupContent = require("./PopupContent.cjs");
|
|
10
9
|
let vue = require("vue");
|
|
11
10
|
let _v_c_resize_observer = require("@v-c/resize-observer");
|
|
12
11
|
let _v_c_util = require("@v-c/util");
|
|
13
12
|
let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
14
13
|
let _v_c_util_dist_utils_transition = require("@v-c/util/dist/utils/transition");
|
|
15
14
|
var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, expose }) => {
|
|
16
|
-
const popupContent = (0, vue.computed)(() => typeof props.popup === "function" ? props.popup() : props.popup);
|
|
17
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");
|
|
18
16
|
const isNodeVisible = (0, vue.computed)(() => props.open || props.keepDom);
|
|
19
17
|
const isMobile = (0, vue.computed)(() => !!props.mobile);
|
|
@@ -51,7 +49,7 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
51
49
|
(0, _v_c_resize_observer.useResizeObserver)(open, popupElementRef, onInternalResize);
|
|
52
50
|
return () => {
|
|
53
51
|
if (!show.value) return null;
|
|
54
|
-
const { onEsc, 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;
|
|
55
53
|
const miscStyle = {};
|
|
56
54
|
if (stretch) {
|
|
57
55
|
if (stretch.includes("height") && targetHeight) miscStyle.height = `${targetHeight}px`;
|
|
@@ -76,9 +74,7 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
76
74
|
onAfterEnter: (element) => {
|
|
77
75
|
baseTransitionProps?.onAfterEnter?.(element);
|
|
78
76
|
requestAnimationFrame(() => {
|
|
79
|
-
|
|
80
|
-
onVisibleChanged?.(true);
|
|
81
|
-
});
|
|
77
|
+
onVisibleChanged?.(true);
|
|
82
78
|
});
|
|
83
79
|
},
|
|
84
80
|
onAfterLeave: (element) => {
|
|
@@ -126,7 +122,7 @@ var Popup = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots, exp
|
|
|
126
122
|
"arrow": arrow === true ? {} : arrow,
|
|
127
123
|
"arrowPos": arrowPos,
|
|
128
124
|
"align": align$1
|
|
129
|
-
}, null),
|
|
125
|
+
}, null), typeof props?.popup === "function" ? props.popup() : props.popup]), [[vue.vShow, open.value]])] }),
|
|
130
126
|
slots?.default?.()
|
|
131
127
|
] });
|
|
132
128
|
};
|
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
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);
|
|
@@ -46,7 +44,7 @@ var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expo
|
|
|
46
44
|
useResizeObserver(open, popupElementRef, onInternalResize);
|
|
47
45
|
return () => {
|
|
48
46
|
if (!show.value) return null;
|
|
49
|
-
const { onEsc, 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;
|
|
50
48
|
const miscStyle = {};
|
|
51
49
|
if (stretch) {
|
|
52
50
|
if (stretch.includes("height") && targetHeight) miscStyle.height = `${targetHeight}px`;
|
|
@@ -71,9 +69,7 @@ var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expo
|
|
|
71
69
|
onAfterEnter: (element) => {
|
|
72
70
|
baseTransitionProps?.onAfterEnter?.(element);
|
|
73
71
|
requestAnimationFrame(() => {
|
|
74
|
-
|
|
75
|
-
onVisibleChanged?.(true);
|
|
76
|
-
});
|
|
72
|
+
onVisibleChanged?.(true);
|
|
77
73
|
});
|
|
78
74
|
},
|
|
79
75
|
onAfterLeave: (element) => {
|
|
@@ -121,7 +117,7 @@ var Popup_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, expo
|
|
|
121
117
|
"arrow": arrow === true ? {} : arrow,
|
|
122
118
|
"arrowPos": arrowPos,
|
|
123
119
|
"align": align$1
|
|
124
|
-
}, null),
|
|
120
|
+
}, null), typeof props?.popup === "function" ? props.popup() : props.popup]), [[vShow, open.value]])] }),
|
|
125
121
|
slots?.default?.()
|
|
126
122
|
] });
|
|
127
123
|
};
|
|
@@ -15,8 +15,9 @@ var UniqueContainer = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
|
15
15
|
(0, vue.watchEffect)(() => {
|
|
16
16
|
if (ready.value) cachedOffsetStyleRef.value = offsetStyle.value;
|
|
17
17
|
});
|
|
18
|
-
(0, vue.
|
|
19
|
-
if (
|
|
18
|
+
const mergedOffsetStyle = (0, vue.computed)(() => {
|
|
19
|
+
if (cachedOffsetStyleRef.value && Object.keys(cachedOffsetStyleRef.value).length > 0) return cachedOffsetStyleRef.value;
|
|
20
|
+
return offsetStyle.value;
|
|
20
21
|
});
|
|
21
22
|
return () => {
|
|
22
23
|
const { popupSize, motion, prefixCls, uniqueContainerClassName, arrowPos, uniqueContainerStyle } = props;
|
|
@@ -26,35 +27,32 @@ var UniqueContainer = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
|
26
27
|
sizeStyle.height = `${popupSize.height}px`;
|
|
27
28
|
}
|
|
28
29
|
const baseTransitionProps = (0, _v_c_util_dist_utils_transition.getTransitionProps)(motion?.name, motion);
|
|
29
|
-
const
|
|
30
|
+
const containerCls = `${prefixCls}-unique-container`;
|
|
31
|
+
return (0, vue.createVNode)(vue.Transition, {
|
|
30
32
|
...baseTransitionProps,
|
|
31
|
-
onBeforeEnter: (element) => {
|
|
32
|
-
motionVisible.value = true;
|
|
33
|
-
baseTransitionProps.onBeforeEnter?.(element);
|
|
34
|
-
},
|
|
35
33
|
onAfterEnter: (element) => {
|
|
36
34
|
motionVisible.value = true;
|
|
37
35
|
baseTransitionProps.onAfterEnter?.(element);
|
|
38
36
|
},
|
|
39
37
|
onAfterLeave: (element) => {
|
|
40
38
|
motionVisible.value = false;
|
|
41
|
-
cachedOffsetStyleRef.value = {};
|
|
42
39
|
baseTransitionProps.onAfterLeave?.(element);
|
|
43
40
|
}
|
|
44
|
-
}
|
|
45
|
-
const containerCls = `${prefixCls}-unique-container`;
|
|
46
|
-
return (0, vue.createVNode)(vue.Transition, mergedTransitionProps, { default: () => [(0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
41
|
+
}, { default: () => [(0, vue.withDirectives)((0, vue.createVNode)("div", {
|
|
47
42
|
"class": [
|
|
48
43
|
containerCls,
|
|
49
44
|
uniqueContainerClassName,
|
|
50
|
-
{
|
|
45
|
+
{
|
|
46
|
+
[`${containerCls}-visible`]: motionVisible.value,
|
|
47
|
+
[`${containerCls}-hidden`]: !open.value
|
|
48
|
+
}
|
|
51
49
|
],
|
|
52
50
|
"style": [
|
|
53
51
|
{
|
|
54
52
|
"--arrow-x": `${arrowPos?.x || 0}px`,
|
|
55
53
|
"--arrow-y": `${arrowPos?.y || 0}px`
|
|
56
54
|
},
|
|
57
|
-
|
|
55
|
+
mergedOffsetStyle.value,
|
|
58
56
|
sizeStyle,
|
|
59
57
|
uniqueContainerStyle
|
|
60
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
|
]
|
package/dist/hooks/useAlign.cjs
CHANGED
|
@@ -172,8 +172,8 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
172
172
|
const popupHeight = popupRect.height;
|
|
173
173
|
const popupWidth = popupRect.width;
|
|
174
174
|
const popupMirrorRect = rawPopupMirrorRect;
|
|
175
|
-
const scaleX$1 = require_util.toNum(Math.
|
|
176
|
-
const scaleY$1 = require_util.toNum(Math.
|
|
175
|
+
const scaleX$1 = require_util.toNum(Math.round(popupWidth / parseFloat(width) * 1e3) / 1e3);
|
|
176
|
+
const scaleY$1 = require_util.toNum(Math.round(popupHeight / parseFloat(height) * 1e3) / 1e3);
|
|
177
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;
|
|
178
178
|
const { offset, targetOffset } = placementInfo;
|
|
179
179
|
let [popupOffsetX, popupOffsetY] = getNumberOffset(popupRect, offset);
|
package/dist/hooks/useAlign.js
CHANGED
|
@@ -166,8 +166,8 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
166
166
|
const popupHeight = popupRect.height;
|
|
167
167
|
const popupWidth = popupRect.width;
|
|
168
168
|
const popupMirrorRect = rawPopupMirrorRect;
|
|
169
|
-
const scaleX$1 = toNum(Math.
|
|
170
|
-
const scaleY$1 = toNum(Math.
|
|
169
|
+
const scaleX$1 = toNum(Math.round(popupWidth / parseFloat(width) * 1e3) / 1e3);
|
|
170
|
+
const scaleY$1 = toNum(Math.round(popupHeight / parseFloat(height) * 1e3) / 1e3);
|
|
171
171
|
if (scaleX$1 === 0 || scaleY$1 === 0 || isDOM(target) && !isVisible(target)) return;
|
|
172
172
|
const { offset, targetOffset } = placementInfo;
|
|
173
173
|
let [popupOffsetX, popupOffsetY] = getNumberOffset(popupRect, offset);
|
|
@@ -13,7 +13,6 @@ function useOffsetStyle(isMobile, ready, open, align, offsetR, offsetB, offsetX,
|
|
|
13
13
|
right: AUTO,
|
|
14
14
|
bottom: AUTO
|
|
15
15
|
};
|
|
16
|
-
if (!ready.value && open.value) return {};
|
|
17
16
|
if (!isMobile.value && (ready.value || !open.value)) {
|
|
18
17
|
const { points } = align.value ?? {};
|
|
19
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 (!ready.value && open.value) 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
|
@@ -11,8 +11,8 @@ function useWatch(open, target, popup, onAlign, onScroll) {
|
|
|
11
11
|
target,
|
|
12
12
|
popup
|
|
13
13
|
], async (_n, _o, onCleanup) => {
|
|
14
|
-
await (0, vue.nextTick)();
|
|
15
14
|
if (open.value && target.value && popup.value) {
|
|
15
|
+
await (0, vue.nextTick)();
|
|
16
16
|
const targetElement = target.value;
|
|
17
17
|
const popupElement = popup.value;
|
|
18
18
|
const targetScrollList = require_util.collectScroller(targetElement);
|
|
@@ -39,6 +39,6 @@ function useWatch(open, target, popup, onAlign, onScroll) {
|
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
});
|
|
42
|
+
}, { flush: "post" });
|
|
43
43
|
}
|
|
44
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 };
|
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/
|
|
32
|
+
"@v-c/resize-observer": "^1.0.6",
|
|
33
33
|
"@v-c/util": "^1.0.8",
|
|
34
|
-
"@v-c/
|
|
34
|
+
"@v-c/portal": "^1.0.4"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "vite build",
|