@v-c/trigger 1.0.6 → 1.0.7
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/index.d.ts +1 -1
- package/package.json +3 -3
- package/dist/Popup/Arrow.cjs +0 -63
- package/dist/Popup/Mask.cjs +0 -58
- package/dist/Popup/PopupContent.cjs +0 -27
- package/dist/Popup/index.cjs +0 -318
- package/dist/UniqueProvider/UniqueContainer.cjs +0 -134
- package/dist/UniqueProvider/index.cjs +0 -164
- package/dist/UniqueProvider/useTargetState.cjs +0 -44
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/context.cjs +0 -28
- package/dist/hooks/useAction.cjs +0 -29
- package/dist/hooks/useAlign.cjs +0 -378
- package/dist/hooks/useDelay.cjs +0 -27
- package/dist/hooks/useOffsetStyle.cjs +0 -39
- package/dist/hooks/useWatch.cjs +0 -44
- package/dist/hooks/useWinClick.cjs +0 -60
- package/dist/index.cjs +0 -590
- package/dist/interface.cjs +0 -1
- package/dist/util.cjs +0 -86
package/dist/index.cjs
DELETED
|
@@ -1,590 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_context = require("./context.cjs");
|
|
7
|
-
const require_useAction = require("./hooks/useAction.cjs");
|
|
8
|
-
const require_util = require("./util.cjs");
|
|
9
|
-
const require_useAlign = require("./hooks/useAlign.cjs");
|
|
10
|
-
const require_useDelay = require("./hooks/useDelay.cjs");
|
|
11
|
-
const require_useWatch = require("./hooks/useWatch.cjs");
|
|
12
|
-
const require_useWinClick = require("./hooks/useWinClick.cjs");
|
|
13
|
-
const require_index = require("./Popup/index.cjs");
|
|
14
|
-
const require_index$1 = require("./UniqueProvider/index.cjs");
|
|
15
|
-
let vue = require("vue");
|
|
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");
|
|
23
|
-
var defaults = {
|
|
24
|
-
prefixCls: "vc-trigger-popup",
|
|
25
|
-
action: "hover",
|
|
26
|
-
mouseLeaveDelay: .1,
|
|
27
|
-
maskClosable: true,
|
|
28
|
-
builtinPlacements: {},
|
|
29
|
-
popupVisible: void 0,
|
|
30
|
-
defaultPopupVisible: void 0
|
|
31
|
-
};
|
|
32
|
-
function generateTrigger(PortalComponent = _v_c_portal.default) {
|
|
33
|
-
return /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots, attrs }) => {
|
|
34
|
-
const mergedAutoDestroy = (0, vue.computed)(() => props.autoDestroy ?? false);
|
|
35
|
-
const openUncontrolled = (0, vue.computed)(() => props.popupVisible === void 0);
|
|
36
|
-
const isMobile = (0, vue.computed)(() => !!props.mobile);
|
|
37
|
-
const subPopupElements = (0, vue.ref)({});
|
|
38
|
-
const parentContext = require_context.useTriggerContext();
|
|
39
|
-
const context = (0, vue.computed)(() => {
|
|
40
|
-
return { registerSubPopup(id$1, subPopupEle) {
|
|
41
|
-
if (subPopupEle) subPopupElements.value[id$1] = subPopupEle;
|
|
42
|
-
else delete subPopupElements.value[id$1];
|
|
43
|
-
parentContext?.value.registerSubPopup(id$1, subPopupEle);
|
|
44
|
-
} };
|
|
45
|
-
});
|
|
46
|
-
const uniqueContext = require_context.useUniqueContext();
|
|
47
|
-
const id = (0, vue.useId)();
|
|
48
|
-
const popupEle = (0, vue.shallowRef)(null);
|
|
49
|
-
const externalPopupRef = (0, vue.shallowRef)(null);
|
|
50
|
-
const setPopupRef = (node) => {
|
|
51
|
-
const element = (0, _v_c_util_dist_vnode.resolveToElement)(node);
|
|
52
|
-
externalPopupRef.value = element;
|
|
53
|
-
if (popupEle.value !== element) popupEle.value = element;
|
|
54
|
-
parentContext?.value?.registerSubPopup(id, element ?? null);
|
|
55
|
-
};
|
|
56
|
-
const targetEle = (0, vue.shallowRef)();
|
|
57
|
-
const externalForwardRef = (0, vue.shallowRef)(null);
|
|
58
|
-
const setTargetRef = (node) => {
|
|
59
|
-
const element = (0, _v_c_util_dist_vnode.resolveToElement)(node);
|
|
60
|
-
if (element && targetEle.value !== element) {
|
|
61
|
-
targetEle.value = element;
|
|
62
|
-
externalForwardRef.value = element;
|
|
63
|
-
} else if (!element) {
|
|
64
|
-
targetEle.value = void 0;
|
|
65
|
-
externalForwardRef.value = null;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const originChildProps = (0, vue.reactive)({});
|
|
69
|
-
const baseActionProps = (0, vue.shallowRef)({});
|
|
70
|
-
const hoverActionProps = (0, vue.shallowRef)({});
|
|
71
|
-
const cloneProps = (0, vue.computed)(() => ({
|
|
72
|
-
...baseActionProps.value,
|
|
73
|
-
...hoverActionProps.value
|
|
74
|
-
}));
|
|
75
|
-
const inPopupOrChild = (ele) => {
|
|
76
|
-
const childDOM = targetEle.value;
|
|
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);
|
|
78
|
-
};
|
|
79
|
-
const innerArrow = (0, vue.computed)(() => {
|
|
80
|
-
return props.arrow ? { ...props?.arrow !== true ? props?.arrow : {} } : null;
|
|
81
|
-
});
|
|
82
|
-
const internalOpen = (0, vue.shallowRef)(props?.defaultPopupVisible ?? false);
|
|
83
|
-
if (props.popupVisible !== void 0) internalOpen.value = props.popupVisible;
|
|
84
|
-
const mergedOpen = (0, vue.computed)(() => {
|
|
85
|
-
return props?.popupVisible ?? internalOpen.value;
|
|
86
|
-
});
|
|
87
|
-
const isOpen = () => mergedOpen.value;
|
|
88
|
-
(0, vue.watch)(() => props.popupVisible, async (nextVisible) => {
|
|
89
|
-
if (nextVisible !== void 0) {
|
|
90
|
-
await (0, vue.nextTick)();
|
|
91
|
-
internalOpen.value = nextVisible;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
const getUniqueOptions = (delay = 0) => {
|
|
95
|
-
return {
|
|
96
|
-
popup: props.popup,
|
|
97
|
-
target: targetEle.value,
|
|
98
|
-
delay,
|
|
99
|
-
prefixCls: props.prefixCls,
|
|
100
|
-
popupClassName: props.popupClassName,
|
|
101
|
-
uniqueContainerClassName: props.uniqueContainerClassName,
|
|
102
|
-
uniqueContainerStyle: props.uniqueContainerStyle,
|
|
103
|
-
popupStyle: props.popupStyle,
|
|
104
|
-
popupPlacement: props.popupPlacement,
|
|
105
|
-
builtinPlacements: props.builtinPlacements,
|
|
106
|
-
popupAlign: props.popupAlign,
|
|
107
|
-
zIndex: props.zIndex,
|
|
108
|
-
mask: props.mask,
|
|
109
|
-
maskClosable: props.maskClosable,
|
|
110
|
-
popupMotion: props.popupMotion,
|
|
111
|
-
maskMotion: props.maskMotion,
|
|
112
|
-
arrow: innerArrow.value,
|
|
113
|
-
getPopupContainer: props.getPopupContainer,
|
|
114
|
-
getPopupClassNameFromAlign: props.getPopupClassNameFromAlign,
|
|
115
|
-
id,
|
|
116
|
-
onEsc
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
(0, vue.watch)([mergedOpen, targetEle], () => {
|
|
120
|
-
if (uniqueContext && props.unique && targetEle.value && !openUncontrolled.value && !parentContext?.value) if (mergedOpen.value) {
|
|
121
|
-
const enterDelay = props.mouseEnterDelay ?? 0;
|
|
122
|
-
uniqueContext?.show(getUniqueOptions(enterDelay), isOpen);
|
|
123
|
-
} else uniqueContext?.hide(props.mouseLeaveDelay || 0);
|
|
124
|
-
});
|
|
125
|
-
const openRef = (0, vue.shallowRef)(mergedOpen.value);
|
|
126
|
-
const internalTriggerOpen = (nextOpen) => {
|
|
127
|
-
if (mergedOpen.value !== nextOpen) {
|
|
128
|
-
internalOpen.value = nextOpen;
|
|
129
|
-
props?.onOpenChange?.(nextOpen);
|
|
130
|
-
props?.onPopupVisibleChange?.(nextOpen);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const delayInvoke = require_useDelay.default();
|
|
134
|
-
const triggerOpen = (nextOpen, delay = 0) => {
|
|
135
|
-
if (props.popupVisible !== void 0) {
|
|
136
|
-
delayInvoke(() => {
|
|
137
|
-
internalTriggerOpen(nextOpen);
|
|
138
|
-
}, delay);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (uniqueContext && props.unique && openUncontrolled.value && !parentContext?.value) {
|
|
142
|
-
if (nextOpen) uniqueContext?.show(getUniqueOptions(delay), isOpen);
|
|
143
|
-
else uniqueContext.hide(delay);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
delayInvoke(() => {
|
|
147
|
-
internalTriggerOpen(nextOpen);
|
|
148
|
-
}, delay);
|
|
149
|
-
};
|
|
150
|
-
function onEsc({ top }) {
|
|
151
|
-
if (top) triggerOpen(false);
|
|
152
|
-
}
|
|
153
|
-
const inMotion = (0, vue.shallowRef)(false);
|
|
154
|
-
(0, vue.watch)(mergedOpen, () => {
|
|
155
|
-
if (mergedOpen.value) inMotion.value = true;
|
|
156
|
-
});
|
|
157
|
-
const motionPrepareResolve = (0, vue.shallowRef)();
|
|
158
|
-
const mousePos = (0, vue.ref)(null);
|
|
159
|
-
const setMousePosByEvent = (event) => {
|
|
160
|
-
mousePos.value = [event.clientX, event.clientY];
|
|
161
|
-
};
|
|
162
|
-
const [ready, offsetX, offsetY, offsetR, offsetB, arrowX, arrowY, scaleX, scaleY, alignInfo, onAlign] = require_useAlign.default(mergedOpen, popupEle, (0, vue.computed)(() => props?.alignPoint && mousePos.value !== null ? mousePos.value : targetEle.value), (0, vue.computed)(() => props?.popupPlacement), (0, vue.computed)(() => props?.builtinPlacements), (0, vue.computed)(() => props?.popupAlign), props?.onPopupAlign, isMobile);
|
|
163
|
-
const [showActions, hideActions] = require_useAction.default((0, vue.computed)(() => props.action), (0, vue.computed)(() => props.showAction), (0, vue.computed)(() => props.hideAction));
|
|
164
|
-
const clickToShow = (0, vue.computed)(() => showActions.value?.has("click"));
|
|
165
|
-
const clickToHide = (0, vue.computed)(() => hideActions.value?.has("click") || hideActions.value?.has("contextmenu"));
|
|
166
|
-
const triggerAlign = () => {
|
|
167
|
-
if (!inMotion.value) onAlign();
|
|
168
|
-
else onAlign(true);
|
|
169
|
-
};
|
|
170
|
-
const onScroll = () => {
|
|
171
|
-
if (openRef.value && props?.alignPoint && clickToHide.value) triggerOpen(false);
|
|
172
|
-
};
|
|
173
|
-
require_useWatch.default(mergedOpen, targetEle, popupEle, triggerAlign, onScroll);
|
|
174
|
-
(0, vue.watch)([mousePos, () => props.popupPlacement], async () => {
|
|
175
|
-
await (0, vue.nextTick)();
|
|
176
|
-
triggerAlign();
|
|
177
|
-
});
|
|
178
|
-
(0, vue.watch)(() => JSON.stringify(props.popupAlign), async () => {
|
|
179
|
-
await (0, vue.nextTick)();
|
|
180
|
-
const { builtinPlacements, popupPlacement } = props;
|
|
181
|
-
if (mergedOpen.value && !builtinPlacements?.[popupPlacement]) triggerAlign();
|
|
182
|
-
});
|
|
183
|
-
const alignedClassName = (0, vue.computed)(() => {
|
|
184
|
-
return (0, _v_c_util.classNames)(require_util.getAlignPopupClassName(props.builtinPlacements, props.prefixCls, alignInfo.value, props.alignPoint), props?.getPopupClassNameFromAlign?.(alignInfo.value));
|
|
185
|
-
});
|
|
186
|
-
expose({
|
|
187
|
-
nativeElement: externalForwardRef,
|
|
188
|
-
popupElement: externalPopupRef,
|
|
189
|
-
forceAlign: triggerAlign
|
|
190
|
-
});
|
|
191
|
-
const targetWidth = (0, vue.shallowRef)(0);
|
|
192
|
-
const targetHeight = (0, vue.shallowRef)(0);
|
|
193
|
-
const syncTargetSize = () => {
|
|
194
|
-
if (props.stretch && targetEle.value) {
|
|
195
|
-
const rect = targetEle.value.getBoundingClientRect();
|
|
196
|
-
targetWidth.value = rect.width;
|
|
197
|
-
targetHeight.value = rect.height;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
const onTargetResize = () => {
|
|
201
|
-
syncTargetSize();
|
|
202
|
-
triggerAlign();
|
|
203
|
-
};
|
|
204
|
-
const onVisibleChanged = (visible) => {
|
|
205
|
-
inMotion.value = false;
|
|
206
|
-
onAlign();
|
|
207
|
-
props?.afterOpenChange?.(visible);
|
|
208
|
-
props?.afterPopupVisibleChange?.(visible);
|
|
209
|
-
};
|
|
210
|
-
const onPrepare = () => {
|
|
211
|
-
syncTargetSize();
|
|
212
|
-
return new Promise((resolve) => {
|
|
213
|
-
motionPrepareResolve.value = resolve;
|
|
214
|
-
inMotion.value = true;
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
(0, vue.watch)([motionPrepareResolve], () => {
|
|
218
|
-
if (motionPrepareResolve.value) {
|
|
219
|
-
onAlign();
|
|
220
|
-
motionPrepareResolve.value();
|
|
221
|
-
motionPrepareResolve.value = void 0;
|
|
222
|
-
}
|
|
223
|
-
}, { flush: "post" });
|
|
224
|
-
function wrapperAction(target, eventName, nextOpen, delay, callback, ignoreCheck) {
|
|
225
|
-
target[eventName] = (event, ...args) => {
|
|
226
|
-
if (!ignoreCheck || !ignoreCheck()) {
|
|
227
|
-
callback?.(event);
|
|
228
|
-
triggerOpen(nextOpen, delay);
|
|
229
|
-
}
|
|
230
|
-
originChildProps[eventName]?.(event, ...args);
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
const touchToShow = (0, vue.computed)(() => showActions.value?.has("touch"));
|
|
234
|
-
const touchToHide = (0, vue.computed)(() => hideActions.value?.has("touch"));
|
|
235
|
-
const touchedRef = (0, vue.shallowRef)(false);
|
|
236
|
-
(0, vue.watchEffect)(() => {
|
|
237
|
-
const nextCloneProps = {};
|
|
238
|
-
if (touchToShow.value || touchToHide.value) nextCloneProps.onTouchstart = (...args) => {
|
|
239
|
-
touchedRef.value = true;
|
|
240
|
-
if (openRef.value && touchToHide.value) triggerOpen(false);
|
|
241
|
-
else if (!openRef.value && touchToShow.value) triggerOpen(true);
|
|
242
|
-
originChildProps.onTouchstart?.(...args);
|
|
243
|
-
};
|
|
244
|
-
if (clickToShow.value || clickToHide.value) nextCloneProps.onClick = (event, ...args) => {
|
|
245
|
-
if (openRef.value && clickToHide.value) triggerOpen(false);
|
|
246
|
-
else if (!openRef.value && clickToShow.value) {
|
|
247
|
-
setMousePosByEvent(event);
|
|
248
|
-
triggerOpen(true);
|
|
249
|
-
}
|
|
250
|
-
originChildProps?.onClick?.(event, ...args);
|
|
251
|
-
touchedRef.value = false;
|
|
252
|
-
};
|
|
253
|
-
baseActionProps.value = nextCloneProps;
|
|
254
|
-
});
|
|
255
|
-
const onPopupPointerDown = require_useWinClick.default(mergedOpen, (0, vue.computed)(() => clickToHide.value || touchToHide.value), targetEle, popupEle, (0, vue.computed)(() => props.mask), (0, vue.computed)(() => props.maskClosable), inPopupOrChild, triggerOpen);
|
|
256
|
-
const hoverToShow = (0, vue.computed)(() => showActions.value?.has("hover"));
|
|
257
|
-
const hoverToHide = (0, vue.computed)(() => hideActions.value?.has("hover"));
|
|
258
|
-
let onPopupMouseEnter;
|
|
259
|
-
let onPopupMouseLeave;
|
|
260
|
-
const ignoreMouseTrigger = () => {
|
|
261
|
-
return touchedRef.value;
|
|
262
|
-
};
|
|
263
|
-
(0, vue.watchEffect)(() => {
|
|
264
|
-
const { mouseEnterDelay, mouseLeaveDelay, alignPoint, focusDelay, blurDelay } = props;
|
|
265
|
-
const nextHoverProps = {};
|
|
266
|
-
if (hoverToShow.value) {
|
|
267
|
-
const onMouseEnterCallback = (event) => {
|
|
268
|
-
setMousePosByEvent(event);
|
|
269
|
-
};
|
|
270
|
-
wrapperAction(nextHoverProps, "onMouseenter", true, mouseEnterDelay, onMouseEnterCallback, ignoreMouseTrigger);
|
|
271
|
-
wrapperAction(nextHoverProps, "onPointerenter", true, mouseEnterDelay, onMouseEnterCallback, ignoreMouseTrigger);
|
|
272
|
-
onPopupMouseEnter = (event) => {
|
|
273
|
-
if ((mergedOpen.value || inMotion.value) && popupEle?.value?.contains(event.target)) triggerOpen(true, mouseEnterDelay);
|
|
274
|
-
};
|
|
275
|
-
if (alignPoint) nextHoverProps.onMouseMove = (event) => {
|
|
276
|
-
originChildProps.onMousemove?.(event);
|
|
277
|
-
};
|
|
278
|
-
} else onPopupMouseEnter = void 0;
|
|
279
|
-
if (hoverToHide.value) {
|
|
280
|
-
wrapperAction(nextHoverProps, "onMouseleave", false, mouseLeaveDelay, void 0, ignoreMouseTrigger);
|
|
281
|
-
wrapperAction(nextHoverProps, "onPointerleave", false, mouseLeaveDelay, void 0, ignoreMouseTrigger);
|
|
282
|
-
onPopupMouseLeave = (event) => {
|
|
283
|
-
const { relatedTarget } = event;
|
|
284
|
-
if (relatedTarget && inPopupOrChild(relatedTarget)) return;
|
|
285
|
-
triggerOpen(false, mouseLeaveDelay);
|
|
286
|
-
};
|
|
287
|
-
} else onPopupMouseLeave = void 0;
|
|
288
|
-
if (showActions.value.has("focus")) wrapperAction(nextHoverProps, "onFocus", true, focusDelay);
|
|
289
|
-
if (hideActions.value.has("focus")) wrapperAction(nextHoverProps, "onBlur", false, blurDelay);
|
|
290
|
-
if (showActions.value.has("contextmenu")) nextHoverProps.onContextmenu = (event, ...args) => {
|
|
291
|
-
if (openRef.value && hideActions.value.has("contextmenu")) triggerOpen(false);
|
|
292
|
-
else {
|
|
293
|
-
setMousePosByEvent(event);
|
|
294
|
-
triggerOpen(true);
|
|
295
|
-
}
|
|
296
|
-
event.preventDefault();
|
|
297
|
-
originChildProps.onContextmenu?.(event, ...args);
|
|
298
|
-
};
|
|
299
|
-
hoverActionProps.value = nextHoverProps;
|
|
300
|
-
});
|
|
301
|
-
const rendedRef = (0, vue.shallowRef)(false);
|
|
302
|
-
(0, vue.watchEffect)(() => {
|
|
303
|
-
rendedRef.value ||= props.forceRender || mergedOpen.value || inMotion.value;
|
|
304
|
-
});
|
|
305
|
-
(0, _v_c_resize_observer.useResizeObserver)(mergedOpen, targetEle, onTargetResize);
|
|
306
|
-
return () => {
|
|
307
|
-
const child = (0, _v_c_util_dist_props_util.filterEmpty)(slots?.default?.({ open: mergedOpen.value }) ?? [])?.[0];
|
|
308
|
-
const mergedChildrenProps = {
|
|
309
|
-
...originChildProps,
|
|
310
|
-
...cloneProps.value
|
|
311
|
-
};
|
|
312
|
-
const passedProps = {};
|
|
313
|
-
[
|
|
314
|
-
"onContextmenu",
|
|
315
|
-
"onClick",
|
|
316
|
-
"onMousedown",
|
|
317
|
-
"onTouchstart",
|
|
318
|
-
"onMouseenter",
|
|
319
|
-
"onMouseleave",
|
|
320
|
-
"onFocus",
|
|
321
|
-
"onBlur"
|
|
322
|
-
].forEach((eventName) => {
|
|
323
|
-
if (attrs[eventName]) passedProps[eventName] = (...args) => {
|
|
324
|
-
mergedChildrenProps[eventName]?.(...args);
|
|
325
|
-
attrs[eventName](...args);
|
|
326
|
-
};
|
|
327
|
-
});
|
|
328
|
-
const arrowPos = {
|
|
329
|
-
x: arrowX.value,
|
|
330
|
-
y: arrowY.value
|
|
331
|
-
};
|
|
332
|
-
const triggerNode = (0, vue.createVNode)(child, {
|
|
333
|
-
...mergedChildrenProps,
|
|
334
|
-
...passedProps,
|
|
335
|
-
ref: setTargetRef
|
|
336
|
-
});
|
|
337
|
-
const { unique, prefixCls, popup, popupClassName, popupStyle, zIndex, fresh, onPopupClick, mask, popupMotion, maskMotion, forceRender, getPopupContainer, stretch, mobile } = props;
|
|
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, {
|
|
339
|
-
"portal": PortalComponent,
|
|
340
|
-
"ref": setPopupRef,
|
|
341
|
-
"prefixCls": prefixCls,
|
|
342
|
-
"popup": popup,
|
|
343
|
-
"className": (0, _v_c_util.classNames)(popupClassName, !isMobile.value && alignedClassName.value),
|
|
344
|
-
"style": popupStyle,
|
|
345
|
-
"target": targetEle.value,
|
|
346
|
-
"onMouseEnter": onPopupMouseEnter,
|
|
347
|
-
"onMouseLeave": onPopupMouseLeave,
|
|
348
|
-
"onPointerEnter": onPopupMouseEnter,
|
|
349
|
-
"zIndex": zIndex,
|
|
350
|
-
"open": mergedOpen.value,
|
|
351
|
-
"keepDom": inMotion.value,
|
|
352
|
-
"fresh": fresh,
|
|
353
|
-
"onClick": onPopupClick,
|
|
354
|
-
"onEsc": onEsc,
|
|
355
|
-
"onPointerDownCapture": onPopupPointerDown,
|
|
356
|
-
"mask": mask,
|
|
357
|
-
"motion": popupMotion,
|
|
358
|
-
"maskMotion": maskMotion,
|
|
359
|
-
"onVisibleChanged": onVisibleChanged,
|
|
360
|
-
"onPrepare": onPrepare,
|
|
361
|
-
"forceRender": forceRender,
|
|
362
|
-
"autoDestroy": mergedAutoDestroy.value,
|
|
363
|
-
"getPopupContainer": getPopupContainer,
|
|
364
|
-
"align": alignInfo.value,
|
|
365
|
-
"arrow": innerArrow.value,
|
|
366
|
-
"arrowPos": arrowPos,
|
|
367
|
-
"ready": ready.value,
|
|
368
|
-
"offsetX": offsetX.value,
|
|
369
|
-
"offsetY": offsetY.value,
|
|
370
|
-
"offsetR": offsetR.value,
|
|
371
|
-
"offsetB": offsetB.value,
|
|
372
|
-
"onAlign": triggerAlign,
|
|
373
|
-
"stretch": stretch,
|
|
374
|
-
"targetWidth": targetWidth.value / scaleX.value,
|
|
375
|
-
"targetHeight": targetHeight.value / scaleY.value,
|
|
376
|
-
"mobile": mobile
|
|
377
|
-
}, null)] })]);
|
|
378
|
-
};
|
|
379
|
-
}, { props: /* @__PURE__ */ (0, vue.mergeDefaults)({
|
|
380
|
-
action: {
|
|
381
|
-
type: [String, Array],
|
|
382
|
-
required: false,
|
|
383
|
-
default: void 0
|
|
384
|
-
},
|
|
385
|
-
showAction: {
|
|
386
|
-
type: Array,
|
|
387
|
-
required: false,
|
|
388
|
-
default: void 0
|
|
389
|
-
},
|
|
390
|
-
hideAction: {
|
|
391
|
-
type: Array,
|
|
392
|
-
required: false,
|
|
393
|
-
default: void 0
|
|
394
|
-
},
|
|
395
|
-
prefixCls: {
|
|
396
|
-
type: String,
|
|
397
|
-
required: false,
|
|
398
|
-
default: void 0
|
|
399
|
-
},
|
|
400
|
-
zIndex: {
|
|
401
|
-
type: Number,
|
|
402
|
-
required: false,
|
|
403
|
-
default: void 0
|
|
404
|
-
},
|
|
405
|
-
onPopupAlign: {
|
|
406
|
-
type: Function,
|
|
407
|
-
required: false,
|
|
408
|
-
default: void 0
|
|
409
|
-
},
|
|
410
|
-
stretch: {
|
|
411
|
-
type: String,
|
|
412
|
-
required: false,
|
|
413
|
-
default: void 0
|
|
414
|
-
},
|
|
415
|
-
popupVisible: {
|
|
416
|
-
type: Boolean,
|
|
417
|
-
required: false,
|
|
418
|
-
default: void 0
|
|
419
|
-
},
|
|
420
|
-
defaultPopupVisible: {
|
|
421
|
-
type: Boolean,
|
|
422
|
-
required: false,
|
|
423
|
-
default: void 0
|
|
424
|
-
},
|
|
425
|
-
onOpenChange: {
|
|
426
|
-
type: Function,
|
|
427
|
-
required: false,
|
|
428
|
-
default: void 0
|
|
429
|
-
},
|
|
430
|
-
afterOpenChange: {
|
|
431
|
-
type: Function,
|
|
432
|
-
required: false,
|
|
433
|
-
default: void 0
|
|
434
|
-
},
|
|
435
|
-
onPopupVisibleChange: {
|
|
436
|
-
type: Function,
|
|
437
|
-
required: false,
|
|
438
|
-
default: void 0
|
|
439
|
-
},
|
|
440
|
-
afterPopupVisibleChange: {
|
|
441
|
-
type: Function,
|
|
442
|
-
required: false,
|
|
443
|
-
default: void 0
|
|
444
|
-
},
|
|
445
|
-
getPopupContainer: {
|
|
446
|
-
type: Function,
|
|
447
|
-
required: false,
|
|
448
|
-
default: void 0
|
|
449
|
-
},
|
|
450
|
-
forceRender: {
|
|
451
|
-
type: Boolean,
|
|
452
|
-
required: false,
|
|
453
|
-
default: void 0
|
|
454
|
-
},
|
|
455
|
-
autoDestroy: {
|
|
456
|
-
type: Boolean,
|
|
457
|
-
required: false,
|
|
458
|
-
default: void 0
|
|
459
|
-
},
|
|
460
|
-
mask: {
|
|
461
|
-
type: Boolean,
|
|
462
|
-
required: false,
|
|
463
|
-
default: void 0
|
|
464
|
-
},
|
|
465
|
-
maskClosable: {
|
|
466
|
-
type: Boolean,
|
|
467
|
-
required: false,
|
|
468
|
-
default: void 0
|
|
469
|
-
},
|
|
470
|
-
popupMotion: {
|
|
471
|
-
type: Object,
|
|
472
|
-
required: false,
|
|
473
|
-
default: void 0
|
|
474
|
-
},
|
|
475
|
-
maskMotion: {
|
|
476
|
-
type: Object,
|
|
477
|
-
required: false,
|
|
478
|
-
default: void 0
|
|
479
|
-
},
|
|
480
|
-
mouseEnterDelay: {
|
|
481
|
-
type: Number,
|
|
482
|
-
required: false,
|
|
483
|
-
default: void 0
|
|
484
|
-
},
|
|
485
|
-
mouseLeaveDelay: {
|
|
486
|
-
type: Number,
|
|
487
|
-
required: false,
|
|
488
|
-
default: void 0
|
|
489
|
-
},
|
|
490
|
-
focusDelay: {
|
|
491
|
-
type: Number,
|
|
492
|
-
required: false,
|
|
493
|
-
default: void 0
|
|
494
|
-
},
|
|
495
|
-
blurDelay: {
|
|
496
|
-
type: Number,
|
|
497
|
-
required: false,
|
|
498
|
-
default: void 0
|
|
499
|
-
},
|
|
500
|
-
popup: {
|
|
501
|
-
type: [
|
|
502
|
-
Object,
|
|
503
|
-
Function,
|
|
504
|
-
String,
|
|
505
|
-
Number,
|
|
506
|
-
null,
|
|
507
|
-
Boolean,
|
|
508
|
-
Array
|
|
509
|
-
],
|
|
510
|
-
required: true,
|
|
511
|
-
default: void 0
|
|
512
|
-
},
|
|
513
|
-
popupPlacement: {
|
|
514
|
-
type: String,
|
|
515
|
-
required: false,
|
|
516
|
-
default: void 0
|
|
517
|
-
},
|
|
518
|
-
builtinPlacements: {
|
|
519
|
-
type: Object,
|
|
520
|
-
required: false,
|
|
521
|
-
default: void 0
|
|
522
|
-
},
|
|
523
|
-
popupAlign: {
|
|
524
|
-
type: Object,
|
|
525
|
-
required: false,
|
|
526
|
-
default: void 0
|
|
527
|
-
},
|
|
528
|
-
popupClassName: {
|
|
529
|
-
type: String,
|
|
530
|
-
required: false,
|
|
531
|
-
default: void 0
|
|
532
|
-
},
|
|
533
|
-
uniqueContainerClassName: {
|
|
534
|
-
type: String,
|
|
535
|
-
required: false,
|
|
536
|
-
default: void 0
|
|
537
|
-
},
|
|
538
|
-
uniqueContainerStyle: {
|
|
539
|
-
type: Object,
|
|
540
|
-
required: false,
|
|
541
|
-
default: void 0
|
|
542
|
-
},
|
|
543
|
-
popupStyle: {
|
|
544
|
-
type: Object,
|
|
545
|
-
required: false,
|
|
546
|
-
default: void 0
|
|
547
|
-
},
|
|
548
|
-
getPopupClassNameFromAlign: {
|
|
549
|
-
type: Function,
|
|
550
|
-
required: false,
|
|
551
|
-
default: void 0
|
|
552
|
-
},
|
|
553
|
-
onPopupClick: {
|
|
554
|
-
type: Function,
|
|
555
|
-
required: false,
|
|
556
|
-
default: void 0
|
|
557
|
-
},
|
|
558
|
-
alignPoint: {
|
|
559
|
-
type: Boolean,
|
|
560
|
-
required: false,
|
|
561
|
-
default: void 0
|
|
562
|
-
},
|
|
563
|
-
fresh: {
|
|
564
|
-
type: Boolean,
|
|
565
|
-
required: false,
|
|
566
|
-
default: void 0
|
|
567
|
-
},
|
|
568
|
-
unique: {
|
|
569
|
-
type: Boolean,
|
|
570
|
-
required: false,
|
|
571
|
-
default: void 0
|
|
572
|
-
},
|
|
573
|
-
arrow: {
|
|
574
|
-
type: [Boolean, Object],
|
|
575
|
-
required: false,
|
|
576
|
-
default: void 0
|
|
577
|
-
},
|
|
578
|
-
mobile: {
|
|
579
|
-
type: Object,
|
|
580
|
-
required: false,
|
|
581
|
-
default: void 0
|
|
582
|
-
}
|
|
583
|
-
}, defaults) });
|
|
584
|
-
}
|
|
585
|
-
var Trigger = generateTrigger(_v_c_portal.default);
|
|
586
|
-
var src_default = Trigger;
|
|
587
|
-
exports.Trigger = Trigger;
|
|
588
|
-
exports.UniqueProvider = require_index$1.default;
|
|
589
|
-
exports.default = src_default;
|
|
590
|
-
exports.generateTrigger = generateTrigger;
|
package/dist/interface.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
package/dist/util.cjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
function isPointsEq(a1 = [], a2 = [], isAlignPoint) {
|
|
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);
|
|
6
|
-
}
|
|
7
|
-
function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
|
|
8
|
-
const { points } = align;
|
|
9
|
-
const placements = Object.keys(builtinPlacements);
|
|
10
|
-
for (let i = 0; i < placements.length; i += 1) {
|
|
11
|
-
const placement = placements[i];
|
|
12
|
-
if (isPointsEq(builtinPlacements[placement]?.points, points, isAlignPoint)) return `${prefixCls}-placement-${placement}`;
|
|
13
|
-
}
|
|
14
|
-
return "";
|
|
15
|
-
}
|
|
16
|
-
function getWin(ele) {
|
|
17
|
-
return ele.ownerDocument.defaultView;
|
|
18
|
-
}
|
|
19
|
-
function collectScroller(ele) {
|
|
20
|
-
const scrollerList = [];
|
|
21
|
-
let current = ele?.parentElement;
|
|
22
|
-
const scrollStyle = [
|
|
23
|
-
"hidden",
|
|
24
|
-
"scroll",
|
|
25
|
-
"clip",
|
|
26
|
-
"auto"
|
|
27
|
-
];
|
|
28
|
-
while (current) {
|
|
29
|
-
const { overflowX, overflowY, overflow } = getWin(current).getComputedStyle(current);
|
|
30
|
-
if ([
|
|
31
|
-
overflowX,
|
|
32
|
-
overflowY,
|
|
33
|
-
overflow
|
|
34
|
-
].some((o) => scrollStyle.includes(o))) scrollerList.push(current);
|
|
35
|
-
current = current.parentElement;
|
|
36
|
-
}
|
|
37
|
-
return scrollerList;
|
|
38
|
-
}
|
|
39
|
-
function toNum(num, defaultValue = 1) {
|
|
40
|
-
return Number.isNaN(num) ? defaultValue : num;
|
|
41
|
-
}
|
|
42
|
-
function getPxValue(val) {
|
|
43
|
-
return toNum(parseFloat(val), 0);
|
|
44
|
-
}
|
|
45
|
-
function getVisibleArea(initArea, scrollerList) {
|
|
46
|
-
const visibleArea = { ...initArea };
|
|
47
|
-
(scrollerList || []).forEach((ele) => {
|
|
48
|
-
if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) return;
|
|
49
|
-
const { overflow, overflowClipMargin, borderTopWidth, borderBottomWidth, borderLeftWidth, borderRightWidth } = getWin(ele).getComputedStyle(ele);
|
|
50
|
-
const eleRect = ele.getBoundingClientRect();
|
|
51
|
-
const { offsetHeight: eleOutHeight, clientHeight: eleInnerHeight, offsetWidth: eleOutWidth, clientWidth: eleInnerWidth } = ele;
|
|
52
|
-
const borderTopNum = getPxValue(borderTopWidth);
|
|
53
|
-
const borderBottomNum = getPxValue(borderBottomWidth);
|
|
54
|
-
const borderLeftNum = getPxValue(borderLeftWidth);
|
|
55
|
-
const borderRightNum = getPxValue(borderRightWidth);
|
|
56
|
-
const scaleX = toNum(Math.round(eleRect.width / eleOutWidth * 1e3) / 1e3);
|
|
57
|
-
const scaleY = toNum(Math.round(eleRect.height / eleOutHeight * 1e3) / 1e3);
|
|
58
|
-
const eleScrollWidth = (eleOutWidth - eleInnerWidth - borderLeftNum - borderRightNum) * scaleX;
|
|
59
|
-
const eleScrollHeight = (eleOutHeight - eleInnerHeight - borderTopNum - borderBottomNum) * scaleY;
|
|
60
|
-
const scaledBorderTopWidth = borderTopNum * scaleY;
|
|
61
|
-
const scaledBorderBottomWidth = borderBottomNum * scaleY;
|
|
62
|
-
const scaledBorderLeftWidth = borderLeftNum * scaleX;
|
|
63
|
-
const scaledBorderRightWidth = borderRightNum * scaleX;
|
|
64
|
-
let clipMarginWidth = 0;
|
|
65
|
-
let clipMarginHeight = 0;
|
|
66
|
-
if (overflow === "clip") {
|
|
67
|
-
const clipNum = getPxValue(overflowClipMargin);
|
|
68
|
-
clipMarginWidth = clipNum * scaleX;
|
|
69
|
-
clipMarginHeight = clipNum * scaleY;
|
|
70
|
-
}
|
|
71
|
-
const eleLeft = eleRect.x + scaledBorderLeftWidth - clipMarginWidth;
|
|
72
|
-
const eleTop = eleRect.y + scaledBorderTopWidth - clipMarginHeight;
|
|
73
|
-
const eleRight = eleLeft + eleRect.width + 2 * clipMarginWidth - scaledBorderLeftWidth - scaledBorderRightWidth - eleScrollWidth;
|
|
74
|
-
const eleBottom = eleTop + eleRect.height + 2 * clipMarginHeight - scaledBorderTopWidth - scaledBorderBottomWidth - eleScrollHeight;
|
|
75
|
-
visibleArea.left = Math.max(visibleArea.left, eleLeft);
|
|
76
|
-
visibleArea.top = Math.max(visibleArea.top, eleTop);
|
|
77
|
-
visibleArea.right = Math.min(visibleArea.right, eleRight);
|
|
78
|
-
visibleArea.bottom = Math.min(visibleArea.bottom, eleBottom);
|
|
79
|
-
});
|
|
80
|
-
return visibleArea;
|
|
81
|
-
}
|
|
82
|
-
exports.collectScroller = collectScroller;
|
|
83
|
-
exports.getAlignPopupClassName = getAlignPopupClassName;
|
|
84
|
-
exports.getVisibleArea = getVisibleArea;
|
|
85
|
-
exports.getWin = getWin;
|
|
86
|
-
exports.toNum = toNum;
|