@v-c/trigger 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/Popup/Arrow.cjs +3 -2
- package/dist/Popup/Mask.cjs +6 -3
- package/dist/Popup/PopupContent.cjs +4 -1
- package/dist/Popup/index.cjs +27 -22
- package/dist/Popup/index.d.ts +2 -0
- package/dist/Popup/index.js +17 -14
- package/dist/UniqueProvider/UniqueContainer.cjs +11 -8
- package/dist/UniqueProvider/UniqueContainer.js +4 -4
- package/dist/UniqueProvider/index.cjs +30 -17
- package/dist/UniqueProvider/index.js +13 -3
- package/dist/UniqueProvider/useTargetState.cjs +4 -2
- package/dist/UniqueProvider/useTargetState.js +0 -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 +48 -79
- package/dist/hooks/useAlign.d.ts +1 -1
- package/dist/hooks/useAlign.js +41 -75
- package/dist/hooks/useDelay.cjs +4 -1
- package/dist/hooks/useOffsetStyle.cjs +5 -2
- package/dist/hooks/useOffsetStyle.js +1 -1
- package/dist/hooks/useWatch.cjs +4 -1
- package/dist/hooks/useWinClick.cjs +8 -5
- package/dist/index.cjs +40 -46
- package/dist/index.js +23 -31
- 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/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;
|
|
@@ -172,6 +165,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
172
165
|
const clickToHide = (0, vue.computed)(() => hideActions.value?.has("click") || hideActions.value?.has("contextmenu"));
|
|
173
166
|
const triggerAlign = () => {
|
|
174
167
|
if (!inMotion.value) onAlign();
|
|
168
|
+
else onAlign(true);
|
|
175
169
|
};
|
|
176
170
|
const onScroll = () => {
|
|
177
171
|
if (openRef.value && props?.alignPoint && clickToHide.value) triggerOpen(false);
|
|
@@ -187,7 +181,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
187
181
|
if (mergedOpen.value && !builtinPlacements?.[popupPlacement]) triggerAlign();
|
|
188
182
|
});
|
|
189
183
|
const alignedClassName = (0, vue.computed)(() => {
|
|
190
|
-
return (0,
|
|
184
|
+
return (0, _v_c_util.classNames)(require_util.getAlignPopupClassName(props.builtinPlacements, props.prefixCls, alignInfo.value, props.alignPoint), props?.getPopupClassNameFromAlign?.(alignInfo.value));
|
|
191
185
|
});
|
|
192
186
|
expose({
|
|
193
187
|
nativeElement: externalForwardRef,
|
|
@@ -214,9 +208,10 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
214
208
|
props?.afterPopupVisibleChange?.(visible);
|
|
215
209
|
};
|
|
216
210
|
const onPrepare = () => {
|
|
211
|
+
syncTargetSize();
|
|
217
212
|
return new Promise((resolve) => {
|
|
218
|
-
syncTargetSize();
|
|
219
213
|
motionPrepareResolve.value = resolve;
|
|
214
|
+
inMotion.value = true;
|
|
220
215
|
});
|
|
221
216
|
};
|
|
222
217
|
(0, vue.watch)([motionPrepareResolve], () => {
|
|
@@ -225,7 +220,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
225
220
|
motionPrepareResolve.value();
|
|
226
221
|
motionPrepareResolve.value = void 0;
|
|
227
222
|
}
|
|
228
|
-
});
|
|
223
|
+
}, { flush: "post" });
|
|
229
224
|
function wrapperAction(target, eventName, nextOpen, delay, callback, ignoreCheck) {
|
|
230
225
|
target[eventName] = (event, ...args) => {
|
|
231
226
|
if (!ignoreCheck || !ignoreCheck()) {
|
|
@@ -307,8 +302,9 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
307
302
|
(0, vue.watchEffect)(() => {
|
|
308
303
|
rendedRef.value ||= props.forceRender || mergedOpen.value || inMotion.value;
|
|
309
304
|
});
|
|
305
|
+
(0, _v_c_resize_observer.useResizeObserver)(mergedOpen, targetEle, onTargetResize);
|
|
310
306
|
return () => {
|
|
311
|
-
const child = (0,
|
|
307
|
+
const child = (0, _v_c_util_dist_props_util.filterEmpty)(slots?.default?.() ?? [])?.[0];
|
|
312
308
|
const mergedChildrenProps = {
|
|
313
309
|
...originChildProps,
|
|
314
310
|
...cloneProps.value
|
|
@@ -339,15 +335,12 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
339
335
|
ref: setTargetRef
|
|
340
336
|
});
|
|
341
337
|
const { unique, prefixCls, popup, popupClassName, popupStyle, zIndex, fresh, onPopupClick, mask, popupMotion, maskMotion, forceRender, getPopupContainer, stretch, mobile } = props;
|
|
342
|
-
return (0, vue.createVNode)(vue.Fragment, null, [(0, vue.createVNode)(
|
|
343
|
-
"disabled": !mergedOpen.value,
|
|
344
|
-
"onResize": onTargetResize
|
|
345
|
-
}, _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, {
|
|
346
339
|
"portal": PortalComponent,
|
|
347
340
|
"ref": setPopupRef,
|
|
348
341
|
"prefixCls": prefixCls,
|
|
349
342
|
"popup": popup,
|
|
350
|
-
"className": (0,
|
|
343
|
+
"className": (0, _v_c_util.classNames)(popupClassName, !isMobile.value && alignedClassName.value),
|
|
351
344
|
"style": popupStyle,
|
|
352
345
|
"target": targetEle.value,
|
|
353
346
|
"onMouseEnter": onPopupMouseEnter,
|
|
@@ -358,6 +351,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
358
351
|
"keepDom": inMotion.value,
|
|
359
352
|
"fresh": fresh,
|
|
360
353
|
"onClick": onPopupClick,
|
|
354
|
+
"onEsc": onEsc,
|
|
361
355
|
"onPointerDownCapture": onPopupPointerDown,
|
|
362
356
|
"mask": mask,
|
|
363
357
|
"motion": popupMotion,
|
|
@@ -505,15 +499,15 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
505
499
|
},
|
|
506
500
|
popup: {
|
|
507
501
|
type: [
|
|
502
|
+
Object,
|
|
503
|
+
Function,
|
|
508
504
|
String,
|
|
509
505
|
Number,
|
|
510
506
|
null,
|
|
511
507
|
Boolean,
|
|
512
|
-
Array
|
|
513
|
-
Function
|
|
508
|
+
Array
|
|
514
509
|
],
|
|
515
510
|
required: true,
|
|
516
|
-
skipCheck: true,
|
|
517
511
|
default: void 0
|
|
518
512
|
},
|
|
519
513
|
popupPlacement: {
|
|
@@ -542,12 +536,12 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
542
536
|
default: void 0
|
|
543
537
|
},
|
|
544
538
|
uniqueContainerStyle: {
|
|
545
|
-
type:
|
|
539
|
+
type: Object,
|
|
546
540
|
required: false,
|
|
547
541
|
default: void 0
|
|
548
542
|
},
|
|
549
543
|
popupStyle: {
|
|
550
|
-
type:
|
|
544
|
+
type: Object,
|
|
551
545
|
required: false,
|
|
552
546
|
default: void 0
|
|
553
547
|
},
|
|
@@ -588,7 +582,7 @@ function generateTrigger(PortalComponent = __v_c_portal.default) {
|
|
|
588
582
|
}
|
|
589
583
|
}, defaults) });
|
|
590
584
|
}
|
|
591
|
-
var Trigger = generateTrigger(
|
|
585
|
+
var Trigger = generateTrigger(_v_c_portal.default);
|
|
592
586
|
var src_default = Trigger;
|
|
593
587
|
exports.Trigger = Trigger;
|
|
594
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;
|
|
@@ -168,6 +159,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
168
159
|
const clickToHide = computed(() => hideActions.value?.has("click") || hideActions.value?.has("contextmenu"));
|
|
169
160
|
const triggerAlign = () => {
|
|
170
161
|
if (!inMotion.value) onAlign();
|
|
162
|
+
else onAlign(true);
|
|
171
163
|
};
|
|
172
164
|
const onScroll = () => {
|
|
173
165
|
if (openRef.value && props?.alignPoint && clickToHide.value) triggerOpen(false);
|
|
@@ -210,9 +202,10 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
210
202
|
props?.afterPopupVisibleChange?.(visible);
|
|
211
203
|
};
|
|
212
204
|
const onPrepare = () => {
|
|
205
|
+
syncTargetSize();
|
|
213
206
|
return new Promise((resolve) => {
|
|
214
|
-
syncTargetSize();
|
|
215
207
|
motionPrepareResolve.value = resolve;
|
|
208
|
+
inMotion.value = true;
|
|
216
209
|
});
|
|
217
210
|
};
|
|
218
211
|
watch([motionPrepareResolve], () => {
|
|
@@ -221,7 +214,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
221
214
|
motionPrepareResolve.value();
|
|
222
215
|
motionPrepareResolve.value = void 0;
|
|
223
216
|
}
|
|
224
|
-
});
|
|
217
|
+
}, { flush: "post" });
|
|
225
218
|
function wrapperAction(target, eventName, nextOpen, delay, callback, ignoreCheck) {
|
|
226
219
|
target[eventName] = (event, ...args) => {
|
|
227
220
|
if (!ignoreCheck || !ignoreCheck()) {
|
|
@@ -303,6 +296,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
303
296
|
watchEffect(() => {
|
|
304
297
|
rendedRef.value ||= props.forceRender || mergedOpen.value || inMotion.value;
|
|
305
298
|
});
|
|
299
|
+
useResizeObserver(mergedOpen, targetEle, onTargetResize);
|
|
306
300
|
return () => {
|
|
307
301
|
const child = filterEmpty(slots?.default?.() ?? [])?.[0];
|
|
308
302
|
const mergedChildrenProps = {
|
|
@@ -335,10 +329,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
335
329
|
ref: setTargetRef
|
|
336
330
|
});
|
|
337
331
|
const { unique, prefixCls, popup, popupClassName, popupStyle, zIndex, fresh, onPopupClick, mask, popupMotion, maskMotion, forceRender, getPopupContainer, stretch, mobile } = props;
|
|
338
|
-
return createVNode(Fragment, null, [createVNode(
|
|
339
|
-
"disabled": !mergedOpen.value,
|
|
340
|
-
"onResize": onTargetResize
|
|
341
|
-
}, _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, {
|
|
342
333
|
"portal": PortalComponent,
|
|
343
334
|
"ref": setPopupRef,
|
|
344
335
|
"prefixCls": prefixCls,
|
|
@@ -354,6 +345,7 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
354
345
|
"keepDom": inMotion.value,
|
|
355
346
|
"fresh": fresh,
|
|
356
347
|
"onClick": onPopupClick,
|
|
348
|
+
"onEsc": onEsc,
|
|
357
349
|
"onPointerDownCapture": onPopupPointerDown,
|
|
358
350
|
"mask": mask,
|
|
359
351
|
"motion": popupMotion,
|
|
@@ -501,15 +493,15 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
501
493
|
},
|
|
502
494
|
popup: {
|
|
503
495
|
type: [
|
|
496
|
+
Object,
|
|
497
|
+
Function,
|
|
504
498
|
String,
|
|
505
499
|
Number,
|
|
506
500
|
null,
|
|
507
501
|
Boolean,
|
|
508
|
-
Array
|
|
509
|
-
Function
|
|
502
|
+
Array
|
|
510
503
|
],
|
|
511
504
|
required: true,
|
|
512
|
-
skipCheck: true,
|
|
513
505
|
default: void 0
|
|
514
506
|
},
|
|
515
507
|
popupPlacement: {
|
|
@@ -538,12 +530,12 @@ function generateTrigger(PortalComponent = Portal) {
|
|
|
538
530
|
default: void 0
|
|
539
531
|
},
|
|
540
532
|
uniqueContainerStyle: {
|
|
541
|
-
type:
|
|
533
|
+
type: Object,
|
|
542
534
|
required: false,
|
|
543
535
|
default: void 0
|
|
544
536
|
},
|
|
545
537
|
popupStyle: {
|
|
546
|
-
type:
|
|
538
|
+
type: Object,
|
|
547
539
|
required: false,
|
|
548
540
|
default: void 0
|
|
549
541
|
},
|
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.3",
|
|
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/portal": "^1.0.
|
|
33
|
-
"@v-c/
|
|
34
|
-
"@v-c/
|
|
32
|
+
"@v-c/portal": "^1.0.3",
|
|
33
|
+
"@v-c/util": "^1.0.8",
|
|
34
|
+
"@v-c/resize-observer": "^1.0.4"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "vite build",
|