@v-c/trigger 0.0.1
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/LICENSE +21 -0
- package/dist/Popup/Arrow.cjs +1 -0
- package/dist/Popup/Arrow.d.ts +8 -0
- package/dist/Popup/Arrow.js +66 -0
- package/dist/Popup/Mask.cjs +1 -0
- package/dist/Popup/Mask.d.ts +11 -0
- package/dist/Popup/Mask.js +57 -0
- package/dist/Popup/PopupContent.cjs +1 -0
- package/dist/Popup/PopupContent.d.ts +5 -0
- package/dist/Popup/PopupContent.js +21 -0
- package/dist/Popup/index.cjs +1 -0
- package/dist/Popup/index.d.ts +54 -0
- package/dist/Popup/index.js +295 -0
- package/dist/UniqueProvider/UniqueContainer.cjs +1 -0
- package/dist/UniqueProvider/UniqueContainer.d.ts +24 -0
- package/dist/UniqueProvider/UniqueContainer.js +125 -0
- package/dist/UniqueProvider/index.cjs +1 -0
- package/dist/UniqueProvider/index.d.ts +7 -0
- package/dist/UniqueProvider/index.js +167 -0
- package/dist/UniqueProvider/useTargetState.cjs +1 -0
- package/dist/UniqueProvider/useTargetState.d.ts +11 -0
- package/dist/UniqueProvider/useTargetState.js +13 -0
- package/dist/context.cjs +1 -0
- package/dist/context.d.ts +48 -0
- package/dist/context.js +27 -0
- package/dist/hooks/useAction.cjs +1 -0
- package/dist/hooks/useAction.d.ts +6 -0
- package/dist/hooks/useAction.js +17 -0
- package/dist/hooks/useAlign.cjs +1 -0
- package/dist/hooks/useAlign.d.ts +4 -0
- package/dist/hooks/useAlign.js +257 -0
- package/dist/hooks/useDelay.cjs +1 -0
- package/dist/hooks/useDelay.d.ts +1 -0
- package/dist/hooks/useDelay.js +16 -0
- package/dist/hooks/useOffsetStyle.cjs +1 -0
- package/dist/hooks/useOffsetStyle.d.ts +3 -0
- package/dist/hooks/useOffsetStyle.js +20 -0
- package/dist/hooks/useWatch.cjs +1 -0
- package/dist/hooks/useWatch.d.ts +2 -0
- package/dist/hooks/useWatch.js +26 -0
- package/dist/hooks/useWinClick.cjs +1 -0
- package/dist/hooks/useWinClick.d.ts +6 -0
- package/dist/hooks/useWinClick.js +50 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +470 -0
- package/dist/interface.cjs +1 -0
- package/dist/interface.d.ts +94 -0
- package/dist/interface.js +1 -0
- package/dist/portal/dist/Context.cjs +1 -0
- package/dist/portal/dist/Context.js +14 -0
- package/dist/portal/dist/Portal.cjs +1 -0
- package/dist/portal/dist/Portal.js +73 -0
- package/dist/portal/dist/useDom.cjs +1 -0
- package/dist/portal/dist/useDom.js +34 -0
- package/dist/portal/dist/useScrollLocker.cjs +5 -0
- package/dist/portal/dist/useScrollLocker.js +28 -0
- package/dist/portal/dist/util.cjs +1 -0
- package/dist/portal/dist/util.js +6 -0
- package/dist/resize-observer/dist/Collection.cjs +1 -0
- package/dist/resize-observer/dist/Collection.js +32 -0
- package/dist/resize-observer/dist/SingleObserver/DomWrapper.cjs +1 -0
- package/dist/resize-observer/dist/SingleObserver/DomWrapper.js +11 -0
- package/dist/resize-observer/dist/SingleObserver/index.cjs +1 -0
- package/dist/resize-observer/dist/SingleObserver/index.js +81 -0
- package/dist/resize-observer/dist/index.cjs +1 -0
- package/dist/resize-observer/dist/index.js +44 -0
- package/dist/resize-observer/dist/utils/observerUtil.cjs +1 -0
- package/dist/resize-observer/dist/utils/observerUtil.js +21 -0
- package/dist/util/dist/Children/isFragment.cjs +1 -0
- package/dist/util/dist/Children/isFragment.js +7 -0
- package/dist/util/dist/Children/toArray.cjs +1 -0
- package/dist/util/dist/Children/toArray.js +11 -0
- package/dist/util/dist/Dom/canUseDom.cjs +1 -0
- package/dist/util/dist/Dom/canUseDom.js +6 -0
- package/dist/util/dist/Dom/contains.cjs +1 -0
- package/dist/util/dist/Dom/contains.js +16 -0
- package/dist/util/dist/Dom/dynamicCSS.cjs +1 -0
- package/dist/util/dist/Dom/dynamicCSS.js +73 -0
- package/dist/util/dist/Dom/findDOMNode.cjs +1 -0
- package/dist/util/dist/Dom/findDOMNode.js +12 -0
- package/dist/util/dist/Dom/isVisible.cjs +1 -0
- package/dist/util/dist/Dom/isVisible.js +22 -0
- package/dist/util/dist/Dom/shadow.cjs +1 -0
- package/dist/util/dist/Dom/shadow.js +13 -0
- package/dist/util/dist/classnames.cjs +1 -0
- package/dist/util/dist/classnames.js +30 -0
- package/dist/util/dist/getScrollBarSize.cjs +1 -0
- package/dist/util/dist/getScrollBarSize.js +37 -0
- package/dist/util/dist/props-util/index.cjs +1 -0
- package/dist/util/dist/props-util/index.js +21 -0
- package/dist/util/dist/raf.cjs +1 -0
- package/dist/util/dist/raf.js +37 -0
- package/dist/util/dist/utils/transition.cjs +1 -0
- package/dist/util/dist/utils/transition.js +21 -0
- package/dist/util/dist/warning.cjs +1 -0
- package/dist/util/dist/warning.js +48 -0
- package/dist/util.cjs +1 -0
- package/dist/util.d.ts +44 -0
- package/dist/util.js +69 -0
- package/package.json +41 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { defineComponent as et, computed as o, ref as ve, useId as tt, shallowRef as u, watch as q, nextTick as F, watchEffect as B, createVNode as S, Fragment as nt, mergeDefaults as ot, isVNode as lt } from "vue";
|
|
2
|
+
import ge from "./portal/dist/Portal.js";
|
|
3
|
+
import ut from "./resize-observer/dist/index.js";
|
|
4
|
+
import "./util/dist/warning.js";
|
|
5
|
+
import de from "./util/dist/classnames.js";
|
|
6
|
+
import { isDOM as x } from "./util/dist/Dom/findDOMNode.js";
|
|
7
|
+
import { getShadowRoot as me } from "./util/dist/Dom/shadow.js";
|
|
8
|
+
import { filterEmpty as at } from "./util/dist/props-util/index.js";
|
|
9
|
+
import { useTriggerContext as it, useUniqueContext as rt, TriggerContextProvider as st } from "./context.js";
|
|
10
|
+
import ct from "./hooks/useAction.js";
|
|
11
|
+
import ft from "./hooks/useAlign.js";
|
|
12
|
+
import pt from "./hooks/useDelay.js";
|
|
13
|
+
import vt from "./hooks/useWatch.js";
|
|
14
|
+
import dt from "./hooks/useWinClick.js";
|
|
15
|
+
import mt from "./Popup/index.js";
|
|
16
|
+
import { getAlignPopupClassName as gt } from "./util.js";
|
|
17
|
+
import { default as It } from "./UniqueProvider/index.js";
|
|
18
|
+
function yt(w) {
|
|
19
|
+
return typeof w == "function" || Object.prototype.toString.call(w) === "[object Object]" && !lt(w);
|
|
20
|
+
}
|
|
21
|
+
const ht = {
|
|
22
|
+
prefixCls: "vc-trigger-popup",
|
|
23
|
+
action: "hover",
|
|
24
|
+
mouseLeaveDelay: 0.1,
|
|
25
|
+
maskClosable: !0,
|
|
26
|
+
builtinPlacements: {},
|
|
27
|
+
popupVisible: void 0,
|
|
28
|
+
defaultPopupVisible: void 0
|
|
29
|
+
};
|
|
30
|
+
function Ct(w = ge) {
|
|
31
|
+
return /* @__PURE__ */ et((t, {
|
|
32
|
+
expose: ye,
|
|
33
|
+
slots: he,
|
|
34
|
+
attrs: $
|
|
35
|
+
}) => {
|
|
36
|
+
const Ce = o(() => t.autoDestroy ?? !1), j = o(() => t.popupVisible === void 0), J = o(() => !!t.mobile), z = ve({}), D = it(), Pe = o(() => ({
|
|
37
|
+
registerSubPopup(e, n) {
|
|
38
|
+
n ? z.value[e] = n : delete z.value[e], D?.value.registerSubPopup(e, n);
|
|
39
|
+
}
|
|
40
|
+
})), d = rt(), _ = tt(), p = u(null), G = u(null), K = (e) => {
|
|
41
|
+
if (!e)
|
|
42
|
+
return null;
|
|
43
|
+
if (x(e))
|
|
44
|
+
return e;
|
|
45
|
+
const n = e;
|
|
46
|
+
if (x(n?.$el))
|
|
47
|
+
return n.$el;
|
|
48
|
+
const i = n?.nativeElement;
|
|
49
|
+
if (x(i?.value))
|
|
50
|
+
return i.value;
|
|
51
|
+
if (x(i))
|
|
52
|
+
return i;
|
|
53
|
+
if (typeof n?.getElement == "function") {
|
|
54
|
+
const v = n.getElement();
|
|
55
|
+
if (x(v))
|
|
56
|
+
return v;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}, be = (e) => {
|
|
60
|
+
const n = K(e);
|
|
61
|
+
G.value = n, p.value !== n && (p.value = n), D?.value?.registerSubPopup(_, n ?? null);
|
|
62
|
+
}, a = u(null), I = u(null), qe = (e) => {
|
|
63
|
+
const n = K(e);
|
|
64
|
+
n && a.value !== n ? (a.value = n, I.value = n) : n || (a.value = null, I.value = null);
|
|
65
|
+
}, Q = o(() => at(he?.default?.() ?? [])?.[0]), h = o(() => Q?.value?.props || {}), Z = u({}), ee = u({}), we = o(() => ({
|
|
66
|
+
...Z.value,
|
|
67
|
+
...ee.value
|
|
68
|
+
})), Ae = (e) => {
|
|
69
|
+
const n = a.value;
|
|
70
|
+
return n?.contains(e) || n && me(n)?.host === e || e === n || p.value?.contains(e) || p.value && me(p.value)?.host === e || e === p.value || Object.values(z.value).some((i) => i?.contains(e) || e === i);
|
|
71
|
+
}, te = o(() => t.arrow ? {
|
|
72
|
+
...t?.arrow !== !0 ? t?.arrow : {}
|
|
73
|
+
} : null), N = u(t?.defaultPopupVisible ?? !1);
|
|
74
|
+
t.popupVisible !== void 0 && (N.value = t.popupVisible);
|
|
75
|
+
const l = o(() => t?.popupVisible ?? N.value), Me = (e) => {
|
|
76
|
+
j.value && (N.value = e);
|
|
77
|
+
}, ne = () => l.value;
|
|
78
|
+
q(() => t.popupVisible, async (e) => {
|
|
79
|
+
e !== void 0 && (await F(), N.value = e);
|
|
80
|
+
});
|
|
81
|
+
const oe = (e = 0) => ({
|
|
82
|
+
popup: t.popup,
|
|
83
|
+
target: a.value,
|
|
84
|
+
delay: e,
|
|
85
|
+
prefixCls: t.prefixCls,
|
|
86
|
+
popupClassName: t.popupClassName,
|
|
87
|
+
uniqueContainerClassName: t.uniqueContainerClassName,
|
|
88
|
+
uniqueContainerStyle: t.uniqueContainerStyle,
|
|
89
|
+
popupStyle: t.popupStyle,
|
|
90
|
+
popupPlacement: t.popupPlacement,
|
|
91
|
+
builtinPlacements: t.builtinPlacements,
|
|
92
|
+
popupAlign: t.popupAlign,
|
|
93
|
+
zIndex: t.zIndex,
|
|
94
|
+
mask: t.mask,
|
|
95
|
+
maskClosable: t.maskClosable,
|
|
96
|
+
popupMotion: t.popupMotion,
|
|
97
|
+
maskMotion: t.maskMotion,
|
|
98
|
+
arrow: te.value,
|
|
99
|
+
getPopupContainer: t.getPopupContainer,
|
|
100
|
+
getPopupClassNameFromAlign: t.getPopupClassNameFromAlign,
|
|
101
|
+
id: _
|
|
102
|
+
});
|
|
103
|
+
q([l, a], () => {
|
|
104
|
+
if (d && t.unique && a.value && !j.value && !D?.value)
|
|
105
|
+
if (l.value) {
|
|
106
|
+
const e = t.mouseEnterDelay ?? 0;
|
|
107
|
+
d?.show(oe(e), ne);
|
|
108
|
+
} else
|
|
109
|
+
d?.hide(t.mouseLeaveDelay || 0);
|
|
110
|
+
});
|
|
111
|
+
const m = u(l.value), A = u([]);
|
|
112
|
+
A.value = [], B(() => {
|
|
113
|
+
m.value = l.value, l.value || (A.value = []);
|
|
114
|
+
});
|
|
115
|
+
const le = (e) => {
|
|
116
|
+
Me(e), (A.value[A.value.length - 1] ?? l.value) !== e && (A.value.push(e), t?.onOpenChange?.(e), t?.onPopupVisibleChange?.(e));
|
|
117
|
+
}, ue = pt(), s = (e, n = 0) => {
|
|
118
|
+
if (t.popupVisible !== void 0) {
|
|
119
|
+
ue(() => {
|
|
120
|
+
le(e);
|
|
121
|
+
}, n);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (d && t.unique && j.value && !D?.value) {
|
|
125
|
+
e ? d?.show(oe(n), ne) : d.hide(n);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
ue(() => {
|
|
129
|
+
le(e);
|
|
130
|
+
}, n);
|
|
131
|
+
}, g = u(!1);
|
|
132
|
+
console.log("inMotion"), q(l, async () => {
|
|
133
|
+
await F(), l.value && (console.log("inMotion opened"), g.value = !0);
|
|
134
|
+
});
|
|
135
|
+
const M = u(), T = ve(null), L = (e) => {
|
|
136
|
+
T.value = [e.clientX, e.clientY];
|
|
137
|
+
}, [ke, Se, xe, De, Ne, Te, Ee, Re, Oe, H, X] = ft(l, p, o(() => t?.alignPoint && T.value !== null ? T.value : a.value), o(() => t?.popupPlacement), o(() => t?.builtinPlacements), o(() => t?.popupAlign), t?.onPopupAlign, J), [k, C] = ct(o(() => t.action), o(() => t.showAction), o(() => t.hideAction)), ae = o(() => k.value?.has("click")), E = o(() => C.value?.has("click") || C.value?.has("contextmenu")), P = () => {
|
|
138
|
+
g.value || X();
|
|
139
|
+
};
|
|
140
|
+
vt(l, a, p, P, () => {
|
|
141
|
+
m.value && t?.alignPoint && E.value && s(!1);
|
|
142
|
+
}), q([T, () => t.popupPlacement], async () => {
|
|
143
|
+
await F(), P();
|
|
144
|
+
}), q(() => JSON.stringify(t.popupAlign), async () => {
|
|
145
|
+
await F();
|
|
146
|
+
const {
|
|
147
|
+
builtinPlacements: e,
|
|
148
|
+
popupPlacement: n
|
|
149
|
+
} = t;
|
|
150
|
+
l.value && !e?.[n] && P();
|
|
151
|
+
});
|
|
152
|
+
const Ve = o(() => {
|
|
153
|
+
const e = gt(t.builtinPlacements, t.prefixCls, H.value, t.alignPoint);
|
|
154
|
+
return de(e, t?.getPopupClassNameFromAlign?.(H.value));
|
|
155
|
+
});
|
|
156
|
+
ye({
|
|
157
|
+
nativeElement: I,
|
|
158
|
+
popupElement: G,
|
|
159
|
+
forceAlign: P
|
|
160
|
+
});
|
|
161
|
+
const ie = u(0), re = u(0), se = () => {
|
|
162
|
+
if (t.stretch && a.value) {
|
|
163
|
+
const e = a.value.getBoundingClientRect();
|
|
164
|
+
ie.value = e.width, re.value = e.height;
|
|
165
|
+
}
|
|
166
|
+
}, Fe = () => {
|
|
167
|
+
se(), P();
|
|
168
|
+
}, Be = (e) => {
|
|
169
|
+
g.value = !1, X(), t?.afterOpenChange?.(e), t?.afterPopupVisibleChange?.(e);
|
|
170
|
+
}, je = () => new Promise((e) => {
|
|
171
|
+
se(), M.value = e;
|
|
172
|
+
});
|
|
173
|
+
q([M], () => {
|
|
174
|
+
M.value && (X(), M.value(), M.value = void 0);
|
|
175
|
+
});
|
|
176
|
+
function b(e, n, i, v, y, r) {
|
|
177
|
+
e[n] = (c, ...f) => {
|
|
178
|
+
(!r || !r()) && (y?.(c), s(i, v)), h.value[n]?.(c, ...f);
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const ce = o(() => k.value?.has("touch")), Y = o(() => C.value?.has("touch")), U = u(!1);
|
|
182
|
+
B(() => {
|
|
183
|
+
const e = {};
|
|
184
|
+
(ce.value || Y.value) && (e.onTouchStart = (...n) => {
|
|
185
|
+
U.value = !0, m.value && Y.value ? s(!1) : !m.value && ce.value && s(!0), h.value.onTouchStart?.(...n);
|
|
186
|
+
}), (ae.value || E.value) && (e.onClick = (n, ...i) => {
|
|
187
|
+
m.value && E.value ? s(!1) : !m.value && ae.value && (L(n), s(!0)), h.value?.onClick?.(n, ...i), U.value = !1;
|
|
188
|
+
}), Z.value = e;
|
|
189
|
+
});
|
|
190
|
+
const ze = dt(l, o(() => E.value || Y.value), a, p, o(() => t.mask), o(() => t.maskClosable), Ae, s), Ie = o(() => k.value?.has("hover")), Le = o(() => C.value?.has("hover"));
|
|
191
|
+
let R, W;
|
|
192
|
+
const O = () => U.value;
|
|
193
|
+
B(() => {
|
|
194
|
+
const {
|
|
195
|
+
mouseEnterDelay: e,
|
|
196
|
+
mouseLeaveDelay: n,
|
|
197
|
+
alignPoint: i,
|
|
198
|
+
focusDelay: v,
|
|
199
|
+
blurDelay: y
|
|
200
|
+
} = t, r = {};
|
|
201
|
+
if (Ie.value) {
|
|
202
|
+
const c = (f) => {
|
|
203
|
+
L(f);
|
|
204
|
+
};
|
|
205
|
+
b(r, "onMouseenter", !0, e, c, O), b(r, "onPointerenter", !0, e, c, O), R = (f) => {
|
|
206
|
+
(l.value || g.value) && p?.value?.contains(f.target) && s(!0, e);
|
|
207
|
+
}, i && (r.onMouseMove = (f) => {
|
|
208
|
+
h.value.onMouseMove?.(f);
|
|
209
|
+
});
|
|
210
|
+
} else
|
|
211
|
+
R = void 0;
|
|
212
|
+
Le.value ? (b(r, "onMouseleave", !1, n, void 0, O), b(r, "onPointerleave", !1, n, void 0, O), W = () => {
|
|
213
|
+
s(!1, n);
|
|
214
|
+
}) : W = void 0, k.value.has("focus") && b(r, "onFocus", !0, v), C.value.has("focus") && b(r, "onBlur", !1, y), k.value.has("contextmenu") && (r.onContextmenu = (c, ...f) => {
|
|
215
|
+
m.value && C.value.has("contextmenu") ? s(!1) : (L(c), s(!0)), c.preventDefault(), h.value.onContextMenu?.(c, ...f);
|
|
216
|
+
}), ee.value = r;
|
|
217
|
+
});
|
|
218
|
+
const fe = u(!1);
|
|
219
|
+
return B(() => {
|
|
220
|
+
fe.value ||= t.forceRender || l.value || g.value;
|
|
221
|
+
}), () => {
|
|
222
|
+
const e = {
|
|
223
|
+
...h.value,
|
|
224
|
+
...we.value
|
|
225
|
+
}, n = {};
|
|
226
|
+
["onContextmenu", "onClick", "onMousedown", "onTouchstart", "onMouseenter", "onMouseleave", "onFocus", "onBlur"].forEach((V) => {
|
|
227
|
+
$[V] && (n[V] = (...pe) => {
|
|
228
|
+
e[V]?.(...pe), $[V](...pe);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
const v = {
|
|
232
|
+
x: Te.value,
|
|
233
|
+
y: Ee.value
|
|
234
|
+
}, y = S(Q.value, {
|
|
235
|
+
...e,
|
|
236
|
+
...n,
|
|
237
|
+
ref: qe
|
|
238
|
+
}), {
|
|
239
|
+
unique: r,
|
|
240
|
+
prefixCls: c,
|
|
241
|
+
popup: f,
|
|
242
|
+
popupClassName: He,
|
|
243
|
+
popupStyle: Xe,
|
|
244
|
+
zIndex: Ye,
|
|
245
|
+
fresh: Ue,
|
|
246
|
+
onPopupClick: We,
|
|
247
|
+
mask: $e,
|
|
248
|
+
popupMotion: Je,
|
|
249
|
+
maskMotion: _e,
|
|
250
|
+
forceRender: Ge,
|
|
251
|
+
getPopupContainer: Ke,
|
|
252
|
+
stretch: Qe,
|
|
253
|
+
mobile: Ze
|
|
254
|
+
} = t;
|
|
255
|
+
return console.log(g.value), S(nt, null, [S(ut, {
|
|
256
|
+
disabled: !l.value,
|
|
257
|
+
onResize: Fe
|
|
258
|
+
}, yt(y) ? y : {
|
|
259
|
+
default: () => [y]
|
|
260
|
+
}), fe.value && a.value && (!d || !r) && S(st, Pe.value, {
|
|
261
|
+
default: () => [S(mt, {
|
|
262
|
+
portal: w,
|
|
263
|
+
ref: be,
|
|
264
|
+
prefixCls: c,
|
|
265
|
+
popup: f,
|
|
266
|
+
className: de(He, !J.value && Ve.value),
|
|
267
|
+
style: Xe,
|
|
268
|
+
target: a.value,
|
|
269
|
+
onMouseEnter: R,
|
|
270
|
+
onMouseLeave: W,
|
|
271
|
+
onPointerEnter: R,
|
|
272
|
+
zIndex: Ye,
|
|
273
|
+
open: l.value,
|
|
274
|
+
keepDom: g.value,
|
|
275
|
+
fresh: Ue,
|
|
276
|
+
onClick: We,
|
|
277
|
+
onPointerDownCapture: ze,
|
|
278
|
+
mask: $e,
|
|
279
|
+
motion: Je,
|
|
280
|
+
maskMotion: _e,
|
|
281
|
+
onVisibleChanged: Be,
|
|
282
|
+
onPrepare: je,
|
|
283
|
+
forceRender: Ge,
|
|
284
|
+
autoDestroy: Ce.value,
|
|
285
|
+
getPopupContainer: Ke,
|
|
286
|
+
align: H.value,
|
|
287
|
+
arrow: te.value,
|
|
288
|
+
arrowPos: v,
|
|
289
|
+
ready: ke.value,
|
|
290
|
+
offsetX: Se.value,
|
|
291
|
+
offsetY: xe.value,
|
|
292
|
+
offsetR: De.value,
|
|
293
|
+
offsetB: Ne.value,
|
|
294
|
+
onAlign: P,
|
|
295
|
+
stretch: Qe,
|
|
296
|
+
targetWidth: ie.value / Re.value,
|
|
297
|
+
targetHeight: re.value / Oe.value,
|
|
298
|
+
mobile: Ze
|
|
299
|
+
}, null)]
|
|
300
|
+
})]);
|
|
301
|
+
};
|
|
302
|
+
}, {
|
|
303
|
+
props: /* @__PURE__ */ ot({
|
|
304
|
+
action: {
|
|
305
|
+
type: [String, Array],
|
|
306
|
+
required: !1
|
|
307
|
+
},
|
|
308
|
+
showAction: {
|
|
309
|
+
type: Array,
|
|
310
|
+
required: !1
|
|
311
|
+
},
|
|
312
|
+
hideAction: {
|
|
313
|
+
type: Array,
|
|
314
|
+
required: !1
|
|
315
|
+
},
|
|
316
|
+
prefixCls: {
|
|
317
|
+
type: String,
|
|
318
|
+
required: !1
|
|
319
|
+
},
|
|
320
|
+
zIndex: {
|
|
321
|
+
type: Number,
|
|
322
|
+
required: !1
|
|
323
|
+
},
|
|
324
|
+
onPopupAlign: {
|
|
325
|
+
type: Function,
|
|
326
|
+
required: !1
|
|
327
|
+
},
|
|
328
|
+
stretch: {
|
|
329
|
+
type: String,
|
|
330
|
+
required: !1
|
|
331
|
+
},
|
|
332
|
+
popupVisible: {
|
|
333
|
+
type: Boolean,
|
|
334
|
+
required: !1
|
|
335
|
+
},
|
|
336
|
+
defaultPopupVisible: {
|
|
337
|
+
type: Boolean,
|
|
338
|
+
required: !1
|
|
339
|
+
},
|
|
340
|
+
onOpenChange: {
|
|
341
|
+
type: Function,
|
|
342
|
+
required: !1
|
|
343
|
+
},
|
|
344
|
+
afterOpenChange: {
|
|
345
|
+
type: Function,
|
|
346
|
+
required: !1
|
|
347
|
+
},
|
|
348
|
+
onPopupVisibleChange: {
|
|
349
|
+
type: Function,
|
|
350
|
+
required: !1
|
|
351
|
+
},
|
|
352
|
+
afterPopupVisibleChange: {
|
|
353
|
+
type: Function,
|
|
354
|
+
required: !1
|
|
355
|
+
},
|
|
356
|
+
getPopupContainer: {
|
|
357
|
+
type: Function,
|
|
358
|
+
required: !1
|
|
359
|
+
},
|
|
360
|
+
forceRender: {
|
|
361
|
+
type: Boolean,
|
|
362
|
+
required: !1
|
|
363
|
+
},
|
|
364
|
+
autoDestroy: {
|
|
365
|
+
type: Boolean,
|
|
366
|
+
required: !1
|
|
367
|
+
},
|
|
368
|
+
mask: {
|
|
369
|
+
type: Boolean,
|
|
370
|
+
required: !1
|
|
371
|
+
},
|
|
372
|
+
maskClosable: {
|
|
373
|
+
type: Boolean,
|
|
374
|
+
required: !1
|
|
375
|
+
},
|
|
376
|
+
popupMotion: {
|
|
377
|
+
type: Object,
|
|
378
|
+
required: !1
|
|
379
|
+
},
|
|
380
|
+
maskMotion: {
|
|
381
|
+
type: Object,
|
|
382
|
+
required: !1
|
|
383
|
+
},
|
|
384
|
+
mouseEnterDelay: {
|
|
385
|
+
type: Number,
|
|
386
|
+
required: !1
|
|
387
|
+
},
|
|
388
|
+
mouseLeaveDelay: {
|
|
389
|
+
type: Number,
|
|
390
|
+
required: !1
|
|
391
|
+
},
|
|
392
|
+
focusDelay: {
|
|
393
|
+
type: Number,
|
|
394
|
+
required: !1
|
|
395
|
+
},
|
|
396
|
+
blurDelay: {
|
|
397
|
+
type: Number,
|
|
398
|
+
required: !1
|
|
399
|
+
},
|
|
400
|
+
popup: {
|
|
401
|
+
type: [String, Number, null, Array, Function],
|
|
402
|
+
required: !0,
|
|
403
|
+
skipCheck: !0
|
|
404
|
+
},
|
|
405
|
+
popupPlacement: {
|
|
406
|
+
type: String,
|
|
407
|
+
required: !1
|
|
408
|
+
},
|
|
409
|
+
builtinPlacements: {
|
|
410
|
+
type: Object,
|
|
411
|
+
required: !1
|
|
412
|
+
},
|
|
413
|
+
popupAlign: {
|
|
414
|
+
type: Object,
|
|
415
|
+
required: !1
|
|
416
|
+
},
|
|
417
|
+
popupClassName: {
|
|
418
|
+
type: String,
|
|
419
|
+
required: !1
|
|
420
|
+
},
|
|
421
|
+
uniqueContainerClassName: {
|
|
422
|
+
type: String,
|
|
423
|
+
required: !1
|
|
424
|
+
},
|
|
425
|
+
uniqueContainerStyle: {
|
|
426
|
+
type: null,
|
|
427
|
+
required: !1
|
|
428
|
+
},
|
|
429
|
+
popupStyle: {
|
|
430
|
+
type: null,
|
|
431
|
+
required: !1
|
|
432
|
+
},
|
|
433
|
+
getPopupClassNameFromAlign: {
|
|
434
|
+
type: Function,
|
|
435
|
+
required: !1
|
|
436
|
+
},
|
|
437
|
+
onPopupClick: {
|
|
438
|
+
type: Function,
|
|
439
|
+
required: !1
|
|
440
|
+
},
|
|
441
|
+
alignPoint: {
|
|
442
|
+
type: Boolean,
|
|
443
|
+
required: !1
|
|
444
|
+
},
|
|
445
|
+
fresh: {
|
|
446
|
+
type: Boolean,
|
|
447
|
+
required: !1
|
|
448
|
+
},
|
|
449
|
+
unique: {
|
|
450
|
+
type: Boolean,
|
|
451
|
+
required: !1
|
|
452
|
+
},
|
|
453
|
+
arrow: {
|
|
454
|
+
type: [Boolean, Object],
|
|
455
|
+
required: !1
|
|
456
|
+
},
|
|
457
|
+
mobile: {
|
|
458
|
+
type: Object,
|
|
459
|
+
required: !1
|
|
460
|
+
}
|
|
461
|
+
}, ht)
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
const Bt = Ct(ge);
|
|
465
|
+
export {
|
|
466
|
+
Bt as Trigger,
|
|
467
|
+
It as UniqueProvider,
|
|
468
|
+
Bt as default,
|
|
469
|
+
Ct as generateTrigger
|
|
470
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { VueNode } from '../../util/src/type';
|
|
2
|
+
import { CSSProperties } from 'vue';
|
|
3
|
+
export type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
4
|
+
export type AlignPointTopBottom = 't' | 'b' | 'c';
|
|
5
|
+
export type AlignPointLeftRight = 'l' | 'r' | 'c';
|
|
6
|
+
/** Two char of 't' 'b' 'c' 'l' 'r'. Example: 'lt' */
|
|
7
|
+
export type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
|
|
8
|
+
export type OffsetType = number | `${number}%`;
|
|
9
|
+
export interface AlignType {
|
|
10
|
+
/**
|
|
11
|
+
* move point of source node to align with point of target node.
|
|
12
|
+
* Such as ['tr','cc'], align top right point of source node with center point of target node.
|
|
13
|
+
* Point can be 't'(top), 'b'(bottom), 'c'(center), 'l'(left), 'r'(right)
|
|
14
|
+
*/
|
|
15
|
+
points?: (string | AlignPoint)[];
|
|
16
|
+
/**
|
|
17
|
+
* @private Do not use in your production code
|
|
18
|
+
*/
|
|
19
|
+
_experimental?: Record<string, any>;
|
|
20
|
+
/**
|
|
21
|
+
* offset source node by offset[0] in x and offset[1] in y.
|
|
22
|
+
* If offset contains percentage string value, it is relative to sourceNode region.
|
|
23
|
+
*/
|
|
24
|
+
offset?: OffsetType[];
|
|
25
|
+
/**
|
|
26
|
+
* offset target node by offset[0] in x and offset[1] in y.
|
|
27
|
+
* If targetOffset contains percentage string value, it is relative to targetNode region.
|
|
28
|
+
*/
|
|
29
|
+
targetOffset?: OffsetType[];
|
|
30
|
+
/**
|
|
31
|
+
* If adjustX field is true, will adjust source node in x direction if source node is invisible.
|
|
32
|
+
* If adjustY field is true, will adjust source node in y direction if source node is invisible.
|
|
33
|
+
*/
|
|
34
|
+
overflow?: {
|
|
35
|
+
adjustX?: boolean | number;
|
|
36
|
+
adjustY?: boolean | number;
|
|
37
|
+
shiftX?: boolean | number;
|
|
38
|
+
shiftY?: boolean | number;
|
|
39
|
+
};
|
|
40
|
+
/** Auto adjust arrow position */
|
|
41
|
+
autoArrow?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Config visible region check of html node. Default `visible`:
|
|
44
|
+
* - `visible`:
|
|
45
|
+
* The visible region of user browser window.
|
|
46
|
+
* Use `clientHeight` for check.
|
|
47
|
+
* If `visible` region not satisfy, fallback to `scroll`.
|
|
48
|
+
* - `scroll`:
|
|
49
|
+
* The whole region of the html scroll area.
|
|
50
|
+
* Use `scrollHeight` for check.
|
|
51
|
+
* - `visibleFirst`:
|
|
52
|
+
* Similar to `visible`, but if `visible` region not satisfy, fallback to `scroll`.
|
|
53
|
+
*/
|
|
54
|
+
htmlRegion?: 'visible' | 'scroll' | 'visibleFirst';
|
|
55
|
+
/**
|
|
56
|
+
* Auto chose position with `top` or `bottom` by the align result
|
|
57
|
+
*/
|
|
58
|
+
dynamicInset?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether use css right instead of left to position
|
|
61
|
+
*/
|
|
62
|
+
useCssRight?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether use css bottom instead of top to position
|
|
65
|
+
*/
|
|
66
|
+
useCssBottom?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether use css transform instead of left/top/right/bottom to position if browser supports.
|
|
69
|
+
* Defaults to false.
|
|
70
|
+
*/
|
|
71
|
+
useCssTransform?: boolean;
|
|
72
|
+
ignoreShake?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface ArrowTypeOuter {
|
|
75
|
+
style?: CSSProperties;
|
|
76
|
+
className?: string;
|
|
77
|
+
content?: VueNode;
|
|
78
|
+
}
|
|
79
|
+
export interface ArrowPos {
|
|
80
|
+
x?: number;
|
|
81
|
+
y?: number;
|
|
82
|
+
}
|
|
83
|
+
export type BuildInPlacements = Record<string, AlignType>;
|
|
84
|
+
export type StretchType = string;
|
|
85
|
+
export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
|
|
86
|
+
export type AnimationType = string;
|
|
87
|
+
export type TransitionNameType = string;
|
|
88
|
+
export interface Point {
|
|
89
|
+
pageX: number;
|
|
90
|
+
pageY: number;
|
|
91
|
+
}
|
|
92
|
+
export interface CommonEventHandler {
|
|
93
|
+
remove: () => void;
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),e=Symbol("QueueContextKey");function u(n){const t=n;return o.provide(e,t),t}function r(){return o.inject(e,void 0)}exports.QueueContextKey=e;exports.useContextProvider=u;exports.useContextState=r;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { provide as n, inject as r } from "vue";
|
|
2
|
+
const t = Symbol("QueueContextKey");
|
|
3
|
+
function i(o) {
|
|
4
|
+
const e = o;
|
|
5
|
+
return n(t, e), e;
|
|
6
|
+
}
|
|
7
|
+
function s() {
|
|
8
|
+
return r(t, void 0);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
t as QueueContextKey,
|
|
12
|
+
i as useContextProvider,
|
|
13
|
+
s as useContextState
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),p=require("../../util/dist/warning.cjs"),l=require("../../util/dist/Dom/canUseDom.cjs"),v=require("../../util/dist/props-util/index.cjs"),y=require("./Context.cjs"),g=require("./useDom.cjs"),m=require("./useScrollLocker.cjs");function q(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}function a(e){return e===!1?!1:!l.default()||!e?null:typeof e=="string"?document.querySelector(e):typeof e=="function"?e():e}const C={autoDestroy:!0,getContainer:void 0},S=t.defineComponent((e,{slots:d})=>{const s=t.shallowRef(e.open),i=t.computed(()=>s.value||e.open);process.env.NODE_ENV!=="production"&&p.default(l.default()||!open,"Portal only work in client side. Please call 'useEffect' to show Portal instead default render in SSR."),t.watch([()=>e.open,()=>e.autoDestroy],()=>{(e.autoDestroy||e.open)&&(s.value=e.open)});const o=t.shallowRef(a(e.getContainer));t.onMounted(()=>{const n=a(e.getContainer);o.value=n??null}),t.watch(()=>e.getContainer,()=>{const n=a(e.getContainer);o.value=n??null});const[c,f]=g.default(t.computed(()=>!!(i.value&&!o.value)),e.debug);y.useContextProvider(f);const u=t.computed(()=>o.value??c);return m.default(t.computed(()=>!!(e.autoLock&&e.open&&l.default()&&(u.value===c||u.value===document.body)))),()=>{if(!i.value||!l.default()||o.value===void 0)return null;const n=u.value===!1,r=v.filterEmpty(d.default?.()??[]);return n?r:t.createVNode(t.Teleport,{to:u.value},q(r)?r:{default:()=>[r]})}},{props:t.mergeDefaults({getContainer:{type:[String,Function,Boolean],required:!1,skipCheck:!0},open:{type:Boolean,required:!1},autoDestroy:{type:Boolean,required:!1},autoLock:{type:Boolean,required:!1},debug:{type:String,required:!1}},C),name:"Portal",inheritAttrs:!1});exports.default=S;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defineComponent as y, shallowRef as p, computed as a, watch as c, onMounted as v, createVNode as g, Teleport as C, mergeDefaults as b, isVNode as q } from "vue";
|
|
2
|
+
import D from "../../util/dist/warning.js";
|
|
3
|
+
import u from "../../util/dist/Dom/canUseDom.js";
|
|
4
|
+
import { filterEmpty as S } from "../../util/dist/props-util/index.js";
|
|
5
|
+
import { useContextProvider as h } from "./Context.js";
|
|
6
|
+
import k from "./useDom.js";
|
|
7
|
+
import w from "./useScrollLocker.js";
|
|
8
|
+
function B(e) {
|
|
9
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !q(e);
|
|
10
|
+
}
|
|
11
|
+
function l(e) {
|
|
12
|
+
return e === !1 ? !1 : !u() || !e ? null : typeof e == "string" ? document.querySelector(e) : typeof e == "function" ? e() : e;
|
|
13
|
+
}
|
|
14
|
+
const P = {
|
|
15
|
+
autoDestroy: !0,
|
|
16
|
+
getContainer: void 0
|
|
17
|
+
}, R = /* @__PURE__ */ y((e, {
|
|
18
|
+
slots: d
|
|
19
|
+
}) => {
|
|
20
|
+
const i = p(e.open), s = a(() => i.value || e.open);
|
|
21
|
+
process.env.NODE_ENV !== "production" && D(u() || !open, "Portal only work in client side. Please call 'useEffect' to show Portal instead default render in SSR."), c([() => e.open, () => e.autoDestroy], () => {
|
|
22
|
+
(e.autoDestroy || e.open) && (i.value = e.open);
|
|
23
|
+
});
|
|
24
|
+
const o = p(l(e.getContainer));
|
|
25
|
+
v(() => {
|
|
26
|
+
const t = l(e.getContainer);
|
|
27
|
+
o.value = t ?? null;
|
|
28
|
+
}), c(() => e.getContainer, () => {
|
|
29
|
+
const t = l(e.getContainer);
|
|
30
|
+
o.value = t ?? null;
|
|
31
|
+
});
|
|
32
|
+
const [f, m] = k(a(() => !!(s.value && !o.value)), e.debug);
|
|
33
|
+
h(m);
|
|
34
|
+
const n = a(() => o.value ?? f);
|
|
35
|
+
return w(a(() => !!(e.autoLock && e.open && u() && (n.value === f || n.value === document.body)))), () => {
|
|
36
|
+
if (!s.value || !u() || o.value === void 0) return null;
|
|
37
|
+
const t = n.value === !1, r = S(d.default?.() ?? []);
|
|
38
|
+
return t ? r : g(C, {
|
|
39
|
+
to: n.value
|
|
40
|
+
}, B(r) ? r : {
|
|
41
|
+
default: () => [r]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}, {
|
|
45
|
+
props: /* @__PURE__ */ b({
|
|
46
|
+
getContainer: {
|
|
47
|
+
type: [String, Function, Boolean],
|
|
48
|
+
required: !1,
|
|
49
|
+
skipCheck: !0
|
|
50
|
+
},
|
|
51
|
+
open: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
required: !1
|
|
54
|
+
},
|
|
55
|
+
autoDestroy: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
required: !1
|
|
58
|
+
},
|
|
59
|
+
autoLock: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
required: !1
|
|
62
|
+
},
|
|
63
|
+
debug: {
|
|
64
|
+
type: String,
|
|
65
|
+
required: !1
|
|
66
|
+
}
|
|
67
|
+
}, P),
|
|
68
|
+
name: "Portal",
|
|
69
|
+
inheritAttrs: !1
|
|
70
|
+
});
|
|
71
|
+
export {
|
|
72
|
+
R as default
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../../util/dist/Dom/canUseDom.cjs"),t=require("vue"),v=require("./Context.cjs"),m=[];function f(o,r){const e=(()=>{if(!s.default())return null;const n=document.createElement("div");return process.env.NODE_ENV!=="production"&&r&&n.setAttribute("data-debug",r),n})(),l=t.shallowRef(!1),a=v.useContextState(),u=t.shallowRef([]),c=t.computed(()=>a?.value||(l.value?void 0:n=>{u.value=[n,...u.value]}));function d(){e?.parentElement||document.body.appendChild(e),l.value=!0}function i(){e?.parentElement?e?.parentElement?.removeChild(e):e&&l.value&&document.body?.removeChild?.(e),l.value=!1}return t.watch(o,()=>{o.value?a?.value?a.value(d):d():t.nextTick(()=>{i()})},{immediate:!0}),t.onUnmounted(i),t.watch(u,()=>{u.value.length&&(u.value.forEach(n=>n()),u.value=[...m])},{flush:"post",immediate:!0}),[e,c]}exports.default=f;
|