@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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Popup/Arrow.cjs +1 -0
  3. package/dist/Popup/Arrow.d.ts +8 -0
  4. package/dist/Popup/Arrow.js +66 -0
  5. package/dist/Popup/Mask.cjs +1 -0
  6. package/dist/Popup/Mask.d.ts +11 -0
  7. package/dist/Popup/Mask.js +57 -0
  8. package/dist/Popup/PopupContent.cjs +1 -0
  9. package/dist/Popup/PopupContent.d.ts +5 -0
  10. package/dist/Popup/PopupContent.js +21 -0
  11. package/dist/Popup/index.cjs +1 -0
  12. package/dist/Popup/index.d.ts +54 -0
  13. package/dist/Popup/index.js +295 -0
  14. package/dist/UniqueProvider/UniqueContainer.cjs +1 -0
  15. package/dist/UniqueProvider/UniqueContainer.d.ts +24 -0
  16. package/dist/UniqueProvider/UniqueContainer.js +125 -0
  17. package/dist/UniqueProvider/index.cjs +1 -0
  18. package/dist/UniqueProvider/index.d.ts +7 -0
  19. package/dist/UniqueProvider/index.js +167 -0
  20. package/dist/UniqueProvider/useTargetState.cjs +1 -0
  21. package/dist/UniqueProvider/useTargetState.d.ts +11 -0
  22. package/dist/UniqueProvider/useTargetState.js +13 -0
  23. package/dist/context.cjs +1 -0
  24. package/dist/context.d.ts +48 -0
  25. package/dist/context.js +27 -0
  26. package/dist/hooks/useAction.cjs +1 -0
  27. package/dist/hooks/useAction.d.ts +6 -0
  28. package/dist/hooks/useAction.js +17 -0
  29. package/dist/hooks/useAlign.cjs +1 -0
  30. package/dist/hooks/useAlign.d.ts +4 -0
  31. package/dist/hooks/useAlign.js +257 -0
  32. package/dist/hooks/useDelay.cjs +1 -0
  33. package/dist/hooks/useDelay.d.ts +1 -0
  34. package/dist/hooks/useDelay.js +16 -0
  35. package/dist/hooks/useOffsetStyle.cjs +1 -0
  36. package/dist/hooks/useOffsetStyle.d.ts +3 -0
  37. package/dist/hooks/useOffsetStyle.js +20 -0
  38. package/dist/hooks/useWatch.cjs +1 -0
  39. package/dist/hooks/useWatch.d.ts +2 -0
  40. package/dist/hooks/useWatch.js +26 -0
  41. package/dist/hooks/useWinClick.cjs +1 -0
  42. package/dist/hooks/useWinClick.d.ts +6 -0
  43. package/dist/hooks/useWinClick.js +50 -0
  44. package/dist/index.cjs +1 -0
  45. package/dist/index.d.ts +78 -0
  46. package/dist/index.js +470 -0
  47. package/dist/interface.cjs +1 -0
  48. package/dist/interface.d.ts +94 -0
  49. package/dist/interface.js +1 -0
  50. package/dist/portal/dist/Context.cjs +1 -0
  51. package/dist/portal/dist/Context.js +14 -0
  52. package/dist/portal/dist/Portal.cjs +1 -0
  53. package/dist/portal/dist/Portal.js +73 -0
  54. package/dist/portal/dist/useDom.cjs +1 -0
  55. package/dist/portal/dist/useDom.js +34 -0
  56. package/dist/portal/dist/useScrollLocker.cjs +5 -0
  57. package/dist/portal/dist/useScrollLocker.js +28 -0
  58. package/dist/portal/dist/util.cjs +1 -0
  59. package/dist/portal/dist/util.js +6 -0
  60. package/dist/resize-observer/dist/Collection.cjs +1 -0
  61. package/dist/resize-observer/dist/Collection.js +32 -0
  62. package/dist/resize-observer/dist/SingleObserver/DomWrapper.cjs +1 -0
  63. package/dist/resize-observer/dist/SingleObserver/DomWrapper.js +11 -0
  64. package/dist/resize-observer/dist/SingleObserver/index.cjs +1 -0
  65. package/dist/resize-observer/dist/SingleObserver/index.js +81 -0
  66. package/dist/resize-observer/dist/index.cjs +1 -0
  67. package/dist/resize-observer/dist/index.js +44 -0
  68. package/dist/resize-observer/dist/utils/observerUtil.cjs +1 -0
  69. package/dist/resize-observer/dist/utils/observerUtil.js +21 -0
  70. package/dist/util/dist/Children/isFragment.cjs +1 -0
  71. package/dist/util/dist/Children/isFragment.js +7 -0
  72. package/dist/util/dist/Children/toArray.cjs +1 -0
  73. package/dist/util/dist/Children/toArray.js +11 -0
  74. package/dist/util/dist/Dom/canUseDom.cjs +1 -0
  75. package/dist/util/dist/Dom/canUseDom.js +6 -0
  76. package/dist/util/dist/Dom/contains.cjs +1 -0
  77. package/dist/util/dist/Dom/contains.js +16 -0
  78. package/dist/util/dist/Dom/dynamicCSS.cjs +1 -0
  79. package/dist/util/dist/Dom/dynamicCSS.js +73 -0
  80. package/dist/util/dist/Dom/findDOMNode.cjs +1 -0
  81. package/dist/util/dist/Dom/findDOMNode.js +12 -0
  82. package/dist/util/dist/Dom/isVisible.cjs +1 -0
  83. package/dist/util/dist/Dom/isVisible.js +22 -0
  84. package/dist/util/dist/Dom/shadow.cjs +1 -0
  85. package/dist/util/dist/Dom/shadow.js +13 -0
  86. package/dist/util/dist/classnames.cjs +1 -0
  87. package/dist/util/dist/classnames.js +30 -0
  88. package/dist/util/dist/getScrollBarSize.cjs +1 -0
  89. package/dist/util/dist/getScrollBarSize.js +37 -0
  90. package/dist/util/dist/props-util/index.cjs +1 -0
  91. package/dist/util/dist/props-util/index.js +21 -0
  92. package/dist/util/dist/raf.cjs +1 -0
  93. package/dist/util/dist/raf.js +37 -0
  94. package/dist/util/dist/utils/transition.cjs +1 -0
  95. package/dist/util/dist/utils/transition.js +21 -0
  96. package/dist/util/dist/warning.cjs +1 -0
  97. package/dist/util/dist/warning.js +48 -0
  98. package/dist/util.cjs +1 -0
  99. package/dist/util.d.ts +44 -0
  100. package/dist/util.js +69 -0
  101. package/package.json +41 -0
@@ -0,0 +1,257 @@
1
+ import { isDOM as Ce } from "../util/dist/Dom/findDOMNode.js";
2
+ import Le from "../util/dist/Dom/isVisible.js";
3
+ import { rafDebounce as Ie } from "../util/dist/raf.js";
4
+ import { reactive as Te, shallowRef as Fe, computed as Se, ref as je, watch as Ne, nextTick as Xt, watchEffect as We, toRefs as $e } from "vue";
5
+ import { collectScroller as Ee, getWin as He, getVisibleArea as Yt, toNum as Pt } from "../util.js";
6
+ function Bt(o, c = 0) {
7
+ const f = `${c}`, a = f.match(/^(.*)\%$/);
8
+ return a ? o * (parseFloat(a[1]) / 100) : parseFloat(f);
9
+ }
10
+ function Mt(o, c) {
11
+ const [f, a] = c || [];
12
+ return [
13
+ Bt(o.width, f),
14
+ Bt(o.height, a)
15
+ ];
16
+ }
17
+ function Ot(o = "") {
18
+ return [o[0], o[1]];
19
+ }
20
+ function O(o, c) {
21
+ const f = c[0], a = c[1];
22
+ let y, R;
23
+ return f === "t" ? R = o.y : f === "b" ? R = o.y + o.height : R = o.y + o.height / 2, a === "l" ? y = o.x : a === "r" ? y = o.x + o.width : y = o.x + o.width / 2, { x: y, y: R };
24
+ }
25
+ function b(o, c) {
26
+ const f = {
27
+ t: "b",
28
+ b: "t",
29
+ l: "r",
30
+ r: "l"
31
+ };
32
+ return o.map((a, y) => y === c ? f[a] || "c" : a).join("");
33
+ }
34
+ function Ke(o, c, f, a, y, R, Vt, G) {
35
+ const D = Te({
36
+ ready: !1,
37
+ offsetX: 0,
38
+ offsetY: 0,
39
+ offsetR: 0,
40
+ offsetB: 0,
41
+ arrowX: 0,
42
+ arrowY: 0,
43
+ scaleX: 1,
44
+ scaleY: 1,
45
+ align: y.value[a.value] || {}
46
+ }), _ = Fe(0), J = Se(() => !c.value || G?.value ? [] : Ee(c.value)), u = je({}), Ct = () => {
47
+ u.value = {};
48
+ }, Lt = Ie(() => {
49
+ if (c.value && f.value && o.value && !G?.value) {
50
+ let h = function(t, p, g = it) {
51
+ const At = n.x + t, Rt = n.y + p, Ye = At + Y, Pe = Rt + X, Be = Math.max(At, g.left), Me = Math.max(Rt, g.top), Oe = Math.min(Ye, g.right), Ve = Math.min(Pe, g.bottom);
52
+ return Math.max(0, (Oe - Be) * (Ve - Me));
53
+ }, Q = function() {
54
+ F = n.y + r, E = F + X, S = n.x + l, H = S + Y;
55
+ };
56
+ const e = c.value, Z = e.ownerDocument, tt = He(e), { position: _t } = tt.getComputedStyle(e), kt = e.style.left, Ut = e.style.top, qt = e.style.right, zt = e.style.bottom, Gt = e.style.overflow, V = {
57
+ ...y.value[a.value],
58
+ ...R?.value
59
+ }, w = Z.createElement("div");
60
+ e.parentElement?.appendChild(w), w.style.left = `${e.offsetLeft}px`, w.style.top = `${e.offsetTop}px`, w.style.position = _t, w.style.height = `${e.offsetHeight}px`, w.style.width = `${e.offsetWidth}px`, e.style.left = "0", e.style.top = "0", e.style.right = "auto", e.style.bottom = "auto", e.style.overflow = "hidden";
61
+ let i;
62
+ if (Array.isArray(f.value))
63
+ i = {
64
+ x: f.value[0],
65
+ y: f.value[1],
66
+ width: 0,
67
+ height: 0
68
+ };
69
+ else {
70
+ const t = f.value.getBoundingClientRect();
71
+ t.x = t.x ?? t.left, t.y = t.y ?? t.top, i = {
72
+ x: t.x,
73
+ y: t.y,
74
+ width: t.width,
75
+ height: t.height
76
+ };
77
+ }
78
+ const n = e.getBoundingClientRect(), { height: Jt, width: Kt } = tt.getComputedStyle(e);
79
+ n.x = n.x ?? n.left, n.y = n.y ?? n.top;
80
+ const {
81
+ clientWidth: Qt,
82
+ clientHeight: Zt,
83
+ scrollWidth: te,
84
+ scrollHeight: ee,
85
+ scrollTop: et,
86
+ scrollLeft: ot
87
+ } = Z.documentElement, X = n.height, Y = n.width, C = i.height, L = i.width, oe = {
88
+ left: 0,
89
+ top: 0,
90
+ right: Qt,
91
+ bottom: Zt
92
+ }, se = {
93
+ left: -ot,
94
+ top: -et,
95
+ right: te - ot,
96
+ bottom: ee - et
97
+ };
98
+ let { htmlRegion: I } = V;
99
+ const st = "visible", nt = "visibleFirst";
100
+ I !== "scroll" && I !== nt && (I = st);
101
+ const T = I === nt, ne = Yt(se, J.value), s = Yt(oe, J.value), it = I === st ? s : ne, W = T ? s : it;
102
+ e.style.left = "auto", e.style.top = "auto", e.style.right = "0", e.style.bottom = "0";
103
+ const lt = e.getBoundingClientRect();
104
+ e.style.left = kt, e.style.top = Ut, e.style.right = qt, e.style.bottom = zt, e.style.overflow = Gt, e.parentElement?.removeChild(w);
105
+ const P = Pt(
106
+ Math.round(Y / parseFloat(Kt) * 1e3) / 1e3
107
+ ), B = Pt(
108
+ Math.round(X / parseFloat(Jt) * 1e3) / 1e3
109
+ );
110
+ if (P === 0 || B === 0 || Ce(f) && !Le(f))
111
+ return;
112
+ const { offset: ie, targetOffset: le } = V;
113
+ let [d, v] = Mt(n, ie);
114
+ const [re, fe] = Mt(
115
+ i,
116
+ le
117
+ );
118
+ i.x -= re, i.y -= fe;
119
+ const [ce, ae] = V.points || [], A = Ot(ae), m = Ot(ce), rt = O(i, A), ft = O(n, m), M = {
120
+ ...V
121
+ };
122
+ let l = rt.x - ft.x + d, r = rt.y - ft.y + v;
123
+ const x = h(
124
+ l,
125
+ r
126
+ ), $ = h(
127
+ l,
128
+ r,
129
+ s
130
+ ), ct = O(i, ["t", "l"]), at = O(n, ["t", "l"]), ut = O(i, ["b", "r"]), pt = O(n, ["b", "r"]), ue = V.overflow || {}, { adjustX: pe, adjustY: he, shiftX: ht, shiftY: gt } = ue, mt = (t) => typeof t == "boolean" ? t : t >= 0;
131
+ let F, E, S, H;
132
+ Q();
133
+ const yt = mt(he), dt = m[0] === A[0];
134
+ if (yt && m[0] === "t" && (E > W.bottom || u.value.bt)) {
135
+ let t = r;
136
+ dt ? t -= X - C : t = ct.y - pt.y - v;
137
+ const p = h(
138
+ l,
139
+ t
140
+ ), g = h(
141
+ l,
142
+ t,
143
+ s
144
+ );
145
+ // Of course use larger one
146
+ p > x || p === x && (!T || g >= $) ? (u.value.bt = !0, r = t, v = -v, M.points = [
147
+ b(m, 0),
148
+ b(A, 0)
149
+ ]) : u.value.bt = !1;
150
+ }
151
+ if (yt && m[0] === "b" && (F < W.top || u.value.tb)) {
152
+ let t = r;
153
+ dt ? t += X - C : t = ut.y - at.y - v;
154
+ const p = h(
155
+ l,
156
+ t
157
+ ), g = h(
158
+ l,
159
+ t,
160
+ s
161
+ );
162
+ // Of course use larger one
163
+ p > x || p === x && (!T || g >= $) ? (u.value.tb = !0, r = t, v = -v, M.points = [
164
+ b(m, 0),
165
+ b(A, 0)
166
+ ]) : u.value.tb = !1;
167
+ }
168
+ const vt = mt(pe), xt = m[1] === A[1];
169
+ if (vt && m[1] === "l" && (H > W.right || u.value.rl)) {
170
+ let t = l;
171
+ xt ? t -= Y - L : t = ct.x - pt.x - d;
172
+ const p = h(
173
+ t,
174
+ r
175
+ ), g = h(
176
+ t,
177
+ r,
178
+ s
179
+ );
180
+ // Of course use larger one
181
+ p > x || p === x && (!T || g >= $) ? (u.value.rl = !0, l = t, d = -d, M.points = [
182
+ b(m, 1),
183
+ b(A, 1)
184
+ ]) : u.value.rl = !1;
185
+ }
186
+ if (vt && m[1] === "r" && (S < W.left || u.value.lr)) {
187
+ let t = l;
188
+ xt ? t += Y - L : t = ut.x - at.x - d;
189
+ const p = h(
190
+ t,
191
+ r
192
+ ), g = h(
193
+ t,
194
+ r,
195
+ s
196
+ );
197
+ // Of course use larger one
198
+ p > x || p === x && (!T || g >= $) ? (u.value.lr = !0, l = t, d = -d, M.points = [
199
+ b(m, 1),
200
+ b(A, 1)
201
+ ]) : u.value.lr = !1;
202
+ }
203
+ Q();
204
+ const j = ht === !0 ? 0 : ht;
205
+ typeof j == "number" && (S < s.left && (l -= S - s.left - d, i.x + L < s.left + j && (l += i.x - s.left + L - j)), H > s.right && (l -= H - s.right - d, i.x > s.right - j && (l += i.x - s.right + j)));
206
+ const N = gt === !0 ? 0 : gt;
207
+ typeof N == "number" && (F < s.top && (r -= F - s.top - v, i.y + C < s.top + N && (r += i.y - s.top + C - N)), E > s.bottom && (r -= E - s.bottom - v, i.y > s.bottom - N && (r += i.y - s.bottom + N)));
208
+ const k = n.x + l, ge = k + Y, U = n.y + r, me = U + X, bt = i.x, ye = bt + L, wt = i.y, de = wt + C, ve = Math.max(k, bt), xe = Math.min(ge, ye), be = (ve + xe) / 2 - k, we = Math.max(U, wt), Ae = Math.min(me, de), Re = (we + Ae) / 2 - U;
209
+ Vt?.(c.value, M);
210
+ let q = lt.right - n.x - (l + n.width), z = lt.bottom - n.y - (r + n.height);
211
+ P === 1 && (l = Math.round(l), q = Math.round(q)), B === 1 && (r = Math.round(r), z = Math.round(z));
212
+ const Xe = {
213
+ ready: !0,
214
+ offsetX: l / P,
215
+ offsetY: r / B,
216
+ offsetR: q / P,
217
+ offsetB: z / B,
218
+ arrowX: be / P,
219
+ arrowY: Re / B,
220
+ scaleX: P,
221
+ scaleY: B,
222
+ align: M
223
+ };
224
+ Object.assign(D, Xe);
225
+ }
226
+ }), It = () => {
227
+ _.value += 1;
228
+ const h = _.value;
229
+ Promise.resolve().then(() => {
230
+ _.value === h && Lt();
231
+ });
232
+ }, K = () => {
233
+ D.ready = !1;
234
+ };
235
+ Ne(a, async () => {
236
+ await Xt(), K();
237
+ }), We(async () => {
238
+ await Xt(), o.value || (Ct(), K());
239
+ });
240
+ const { ready: Tt, offsetX: Ft, offsetR: St, offsetY: jt, offsetB: Nt, align: Wt, arrowY: $t, arrowX: Et, scaleY: Ht, scaleX: Dt } = $e(D);
241
+ return [
242
+ Tt,
243
+ Ft,
244
+ jt,
245
+ St,
246
+ Nt,
247
+ Et,
248
+ $t,
249
+ Dt,
250
+ Ht,
251
+ Wt,
252
+ It
253
+ ];
254
+ }
255
+ export {
256
+ Ke as default
257
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue");function r(){const e=o.ref(null),u=()=>{e.value&&(clearTimeout(e.value),e.value=null)},n=(l,t)=>{u(),t===0?l():e.value=setTimeout(()=>{l()},t*1e3)};return o.onBeforeUnmount(()=>{u()}),n}exports.default=r;
@@ -0,0 +1 @@
1
+ export default function useDelay(): (callback: VoidFunction, delay: number) => void;
@@ -0,0 +1,16 @@
1
+ import { ref as t, onBeforeUnmount as a } from "vue";
2
+ function f() {
3
+ const e = t(null), l = () => {
4
+ e.value && (clearTimeout(e.value), e.value = null);
5
+ }, n = (o, u) => {
6
+ l(), u === 0 ? o() : e.value = setTimeout(() => {
7
+ o();
8
+ }, u * 1e3);
9
+ };
10
+ return a(() => {
11
+ l();
12
+ }), n;
13
+ }
14
+ export {
15
+ f as default
16
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("vue");function d(u,a,s,o,i,r,v,c){const t="auto";return m.computed(()=>{const e=u.value?{}:{left:"-1000vw",top:"-1000vh",right:t,bottom:t};if(!u.value&&(a.value||!s.value)){const{points:l}=o.value??{},n=o.value?.dynamicInset||o.value?._experimental?.dynamicInset,f=n&&l?.[0]?.[1]==="r",p=n&&l?.[0]?.[0]==="b";f?(e.right=`${i.value}px`,e.left=t):(e.left=`${v.value}px`,e.right=t),p?(e.bottom=`${r.value}px`,e.top=t):(e.top=`${c.value}px`,e.bottom=t)}return e})}exports.default=d;
@@ -0,0 +1,3 @@
1
+ import { CSSProperties, Ref } from 'vue';
2
+ import { AlignType } from '../interface.ts';
3
+ export default function useOffsetStyle(isMobile: Ref<boolean>, ready: Ref<boolean>, open: Ref<boolean>, align: Ref<AlignType | undefined>, offsetR: Ref<number>, offsetB: Ref<number>, offsetX: Ref<number>, offsetY: Ref<number>): import('vue').ComputedRef<CSSProperties>;
@@ -0,0 +1,20 @@
1
+ import { computed as m } from "vue";
2
+ function d(l, u, s, o, f, v, i, p) {
3
+ const e = "auto";
4
+ return m(() => {
5
+ const t = l.value ? {} : {
6
+ left: "-1000vw",
7
+ top: "-1000vh",
8
+ right: e,
9
+ bottom: e
10
+ };
11
+ if (!l.value && (u.value || !s.value)) {
12
+ const { points: a } = o.value ?? {}, n = o.value?.dynamicInset || o.value?._experimental?.dynamicInset, r = n && a?.[0]?.[1] === "r", c = n && a?.[0]?.[0] === "b";
13
+ r ? (t.right = `${f.value}px`, t.left = e) : (t.left = `${i.value}px`, t.right = e), c ? (t.bottom = `${v.value}px`, t.top = e) : (t.top = `${p.value}px`, t.bottom = e);
14
+ }
15
+ return t;
16
+ });
17
+ }
18
+ export {
19
+ d as default
20
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),s=require("../util.cjs");function L(n,t,l,o,v){a.watch([n,t,l],async(m,h,d)=>{if(await a.nextTick(),n.value&&t.value&&l.value){let e=function(){o(),v()};const f=t.value,i=l.value,E=s.collectScroller(f),S=s.collectScroller(i),r=s.getWin(i),u=new Set([r,...E,...S]);u.forEach(c=>{c.addEventListener("scroll",e,{passive:!0})}),r.addEventListener("resize",e,{passive:!0}),o(),d(()=>{u.forEach(c=>{c.removeEventListener("scroll",e),r.removeEventListener("resize",e)})})}})}exports.default=L;
@@ -0,0 +1,2 @@
1
+ import { Ref } from 'vue';
2
+ export default function useWatch(open: Ref<boolean>, target: Ref<HTMLElement>, popup: Ref<HTMLElement>, onAlign: VoidFunction, onScroll: VoidFunction): void;
@@ -0,0 +1,26 @@
1
+ import { watch as L, nextTick as d } from "vue";
2
+ import { collectScroller as a, getWin as S } from "../util.js";
3
+ function y(s, t, r, c, v) {
4
+ L([s, t, r], async (h, p, u) => {
5
+ if (await d(), s.value && t.value && r.value) {
6
+ let e = function() {
7
+ c(), v();
8
+ };
9
+ const f = t.value, l = r.value, m = a(f), E = a(l), n = S(l), i = /* @__PURE__ */ new Set([
10
+ n,
11
+ ...m,
12
+ ...E
13
+ ]);
14
+ i.forEach((o) => {
15
+ o.addEventListener("scroll", e, { passive: !0 });
16
+ }), n.addEventListener("resize", e, { passive: !0 }), c(), u(() => {
17
+ i.forEach((o) => {
18
+ o.removeEventListener("scroll", e), n.removeEventListener("resize", e);
19
+ });
20
+ });
21
+ }
22
+ });
23
+ }
24
+ export {
25
+ y as default
26
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("../util/dist/warning.cjs"),D=require("../util/dist/Dom/shadow.cjs"),r=require("vue"),N=require("../util.cjs");function S(a,v,l,f,w,m,g,p){const d=r.shallowRef(a.value);r.watchEffect(()=>{d.value=a.value});const u=r.shallowRef(!1);r.watch([v,l,f,w,m],([L,s,i,R,E],_,P)=>{if(L&&i&&(!R||E)){const c=()=>{u.value=!1},e=n=>{d.value&&!g(n.composedPath?.()?.[0]||n.target)&&!u.value&&p(!1)},t=N.getWin(i);t.addEventListener("pointerdown",c,!0),t.addEventListener("mousedown",e,!0),t.addEventListener("contextmenu",e,!0);const o=D.getShadowRoot(s);if(o&&(o.addEventListener("mousedown",e,!0),o.addEventListener("contextmenu",e,!0)),process.env.NODE_ENV!=="production"&&s){const n=s.getRootNode?.(),q=i.getRootNode?.();x.default(n===q,"trigger element and popup element should in same shadow root.")}P(()=>{t.removeEventListener("pointerdown",c,!0),t.removeEventListener("mousedown",e,!0),t.removeEventListener("contextmenu",e,!0),o&&(o.removeEventListener("mousedown",e,!0),o.removeEventListener("contextmenu",e,!0))})}});function h(){u.value=!0}return h}exports.default=S;
@@ -0,0 +1,6 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * Close if click on the window.
4
+ * Return the function that click on the Popup element.
5
+ */
6
+ export default function useWinClick(open: Ref<boolean>, clickToHide: Ref<boolean>, targetEle: Ref<HTMLElement>, popupEle: Ref<HTMLElement>, mask: Ref<boolean>, maskClosable: Ref<boolean>, inPopupOrChild: (target: EventTarget) => boolean, triggerOpen: (open: boolean) => void): () => void;
@@ -0,0 +1,50 @@
1
+ import D from "../util/dist/warning.js";
2
+ import { getShadowRoot as N } from "../util/dist/Dom/shadow.js";
3
+ import { shallowRef as m, watchEffect as C, watch as S } from "vue";
4
+ import { getWin as W } from "../util.js";
5
+ function b(i, v, c, f, w, p, l, L) {
6
+ const a = m(i.value);
7
+ C(() => {
8
+ a.value = i.value;
9
+ });
10
+ const r = m(!1);
11
+ S(
12
+ [v, c, f, w, p],
13
+ ([E, s, u, R, h], _, x) => {
14
+ if (E && u && (!R || h)) {
15
+ const d = () => {
16
+ r.value = !1;
17
+ }, e = (n) => {
18
+ a.value && !l(n.composedPath?.()?.[0] || n.target) && !r.value && L(!1);
19
+ }, t = W(u);
20
+ t.addEventListener("pointerdown", d, !0), t.addEventListener("mousedown", e, !0), t.addEventListener("contextmenu", e, !0);
21
+ const o = N(s);
22
+ if (o && (o.addEventListener("mousedown", e, !0), o.addEventListener("contextmenu", e, !0)), process.env.NODE_ENV !== "production" && s) {
23
+ const n = s.getRootNode?.(), P = u.getRootNode?.();
24
+ D(
25
+ n === P,
26
+ "trigger element and popup element should in same shadow root."
27
+ );
28
+ }
29
+ x(() => {
30
+ t.removeEventListener("pointerdown", d, !0), t.removeEventListener("mousedown", e, !0), t.removeEventListener("contextmenu", e, !0), o && (o.removeEventListener(
31
+ "mousedown",
32
+ e,
33
+ !0
34
+ ), o.removeEventListener(
35
+ "contextmenu",
36
+ e,
37
+ !0
38
+ ));
39
+ });
40
+ }
41
+ }
42
+ );
43
+ function g() {
44
+ r.value = !0;
45
+ }
46
+ return g;
47
+ }
48
+ export {
49
+ b as default
50
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),fe=require("./portal/dist/Portal.cjs"),Qe=require("./resize-observer/dist/index.cjs");require("./util/dist/warning.cjs");const re=require("./util/dist/classnames.cjs"),k=require("./util/dist/Dom/findDOMNode.cjs"),ce=require("./util/dist/Dom/shadow.cjs"),Ze=require("./util/dist/props-util/index.cjs"),H=require("./context.cjs"),et=require("./hooks/useAction.cjs"),tt=require("./hooks/useAlign.cjs"),ut=require("./hooks/useDelay.cjs"),nt=require("./hooks/useWatch.cjs"),ot=require("./hooks/useWinClick.cjs"),lt=require("./Popup/index.cjs"),at=require("./util.cjs"),it=require("./UniqueProvider/index.cjs");function st(C){return typeof C=="function"||Object.prototype.toString.call(C)==="[object Object]"&&!t.isVNode(C)}const rt={prefixCls:"vc-trigger-popup",action:"hover",mouseLeaveDelay:.1,maskClosable:!0,builtinPlacements:{},popupVisible:void 0,defaultPopupVisible:void 0};function de(C=fe.default){return t.defineComponent((u,{expose:ve,slots:ge,attrs:$})=>{const me=t.computed(()=>u.autoDestroy??!1),O=t.computed(()=>u.popupVisible===void 0),X=t.computed(()=>!!u.mobile),E=t.ref({}),R=H.useTriggerContext(),he=t.computed(()=>({registerSubPopup(e,n){n?E.value[e]=n:delete E.value[e],R?.value.registerSubPopup(e,n)}})),p=H.useUniqueContext(),Y=t.useId(),f=t.shallowRef(null),U=t.shallowRef(null),W=e=>{if(!e)return null;if(k.isDOM(e))return e;const n=e;if(k.isDOM(n?.$el))return n.$el;const a=n?.nativeElement;if(k.isDOM(a?.value))return a.value;if(k.isDOM(a))return a;if(typeof n?.getElement=="function"){const d=n.getElement();if(k.isDOM(d))return d}return null},ye=e=>{const n=W(e);U.value=n,f.value!==n&&(f.value=n),R?.value?.registerSubPopup(Y,n??null)},l=t.shallowRef(null),V=t.shallowRef(null),Pe=e=>{const n=W(e);n&&l.value!==n?(l.value=n,V.value=n):n||(l.value=null,V.value=null)},_=t.computed(()=>Ze.filterEmpty(ge?.default?.()??[])?.[0]),h=t.computed(()=>_?.value?.props||{}),J=t.shallowRef({}),G=t.shallowRef({}),qe=t.computed(()=>({...J.value,...G.value})),Ce=e=>{const n=l.value;return n?.contains(e)||n&&ce.getShadowRoot(n)?.host===e||e===n||f.value?.contains(e)||f.value&&ce.getShadowRoot(f.value)?.host===e||e===f.value||Object.values(E.value).some(a=>a?.contains(e)||e===a)},K=t.computed(()=>u.arrow?{...u?.arrow!==!0?u?.arrow:{}}:null),A=t.shallowRef(u?.defaultPopupVisible??!1);u.popupVisible!==void 0&&(A.value=u.popupVisible);const o=t.computed(()=>u?.popupVisible??A.value),we=e=>{O.value&&(A.value=e)},Q=()=>o.value;t.watch(()=>u.popupVisible,async e=>{e!==void 0&&(await t.nextTick(),A.value=e)});const Z=(e=0)=>({popup:u.popup,target:l.value,delay:e,prefixCls:u.prefixCls,popupClassName:u.popupClassName,uniqueContainerClassName:u.uniqueContainerClassName,uniqueContainerStyle:u.uniqueContainerStyle,popupStyle:u.popupStyle,popupPlacement:u.popupPlacement,builtinPlacements:u.builtinPlacements,popupAlign:u.popupAlign,zIndex:u.zIndex,mask:u.mask,maskClosable:u.maskClosable,popupMotion:u.popupMotion,maskMotion:u.maskMotion,arrow:K.value,getPopupContainer:u.getPopupContainer,getPopupClassNameFromAlign:u.getPopupClassNameFromAlign,id:Y});t.watch([o,l],()=>{if(p&&u.unique&&l.value&&!O.value&&!R?.value)if(o.value){const e=u.mouseEnterDelay??0;p?.show(Z(e),Q)}else p?.hide(u.mouseLeaveDelay||0)});const v=t.shallowRef(o.value),w=t.shallowRef([]);w.value=[],t.watchEffect(()=>{v.value=o.value,o.value||(w.value=[])});const ee=e=>{we(e),(w.value[w.value.length-1]??o.value)!==e&&(w.value.push(e),u?.onOpenChange?.(e),u?.onPopupVisibleChange?.(e))},te=ut.default(),s=(e,n=0)=>{if(u.popupVisible!==void 0){te(()=>{ee(e)},n);return}if(p&&u.unique&&O.value&&!R?.value){e?p?.show(Z(n),Q):p.hide(n);return}te(()=>{ee(e)},n)},g=t.shallowRef(!1);console.log("inMotion"),t.watch(o,async()=>{await t.nextTick(),o.value&&(console.log("inMotion opened"),g.value=!0)});const b=t.shallowRef(),x=t.ref(null),F=e=>{x.value=[e.clientX,e.clientY]},[be,Me,ke,Re,Ae,xe,Se,De,Te,B,j]=tt.default(o,f,t.computed(()=>u?.alignPoint&&x.value!==null?x.value:l.value),t.computed(()=>u?.popupPlacement),t.computed(()=>u?.builtinPlacements),t.computed(()=>u?.popupAlign),u?.onPopupAlign,X),[M,y]=et.default(t.computed(()=>u.action),t.computed(()=>u.showAction),t.computed(()=>u.hideAction)),ue=t.computed(()=>M.value?.has("click")),S=t.computed(()=>y.value?.has("click")||y.value?.has("contextmenu")),P=()=>{g.value||j()},Ne=()=>{v.value&&u?.alignPoint&&S.value&&s(!1)};nt.default(o,l,f,P,Ne),t.watch([x,()=>u.popupPlacement],async()=>{await t.nextTick(),P()}),t.watch(()=>JSON.stringify(u.popupAlign),async()=>{await t.nextTick();const{builtinPlacements:e,popupPlacement:n}=u;o.value&&!e?.[n]&&P()});const Oe=t.computed(()=>{const e=at.getAlignPopupClassName(u.builtinPlacements,u.prefixCls,B.value,u.alignPoint);return re.default(e,u?.getPopupClassNameFromAlign?.(B.value))});ve({nativeElement:V,popupElement:U,forceAlign:P});const ne=t.shallowRef(0),oe=t.shallowRef(0),le=()=>{if(u.stretch&&l.value){const e=l.value.getBoundingClientRect();ne.value=e.width,oe.value=e.height}},Ee=()=>{le(),P()},Ve=e=>{g.value=!1,j(),u?.afterOpenChange?.(e),u?.afterPopupVisibleChange?.(e)},Fe=()=>new Promise(e=>{le(),b.value=e});t.watch([b],()=>{b.value&&(j(),b.value(),b.value=void 0)});function q(e,n,a,d,m,i){e[n]=(r,...c)=>{(!i||!i())&&(m?.(r),s(a,d)),h.value[n]?.(r,...c)}}const ae=t.computed(()=>M.value?.has("touch")),z=t.computed(()=>y.value?.has("touch")),I=t.shallowRef(!1);t.watchEffect(()=>{const e={};(ae.value||z.value)&&(e.onTouchStart=(...n)=>{I.value=!0,v.value&&z.value?s(!1):!v.value&&ae.value&&s(!0),h.value.onTouchStart?.(...n)}),(ue.value||S.value)&&(e.onClick=(n,...a)=>{v.value&&S.value?s(!1):!v.value&&ue.value&&(F(n),s(!0)),h.value?.onClick?.(n,...a),I.value=!1}),J.value=e});const Be=ot.default(o,t.computed(()=>S.value||z.value),l,f,t.computed(()=>u.mask),t.computed(()=>u.maskClosable),Ce,s),je=t.computed(()=>M.value?.has("hover")),ze=t.computed(()=>y.value?.has("hover"));let D,L;const T=()=>I.value;t.watchEffect(()=>{const{mouseEnterDelay:e,mouseLeaveDelay:n,alignPoint:a,focusDelay:d,blurDelay:m}=u,i={};if(je.value){const r=c=>{F(c)};q(i,"onMouseenter",!0,e,r,T),q(i,"onPointerenter",!0,e,r,T),D=c=>{(o.value||g.value)&&f?.value?.contains(c.target)&&s(!0,e)},a&&(i.onMouseMove=c=>{h.value.onMouseMove?.(c)})}else D=void 0;ze.value?(q(i,"onMouseleave",!1,n,void 0,T),q(i,"onPointerleave",!1,n,void 0,T),L=()=>{s(!1,n)}):L=void 0,M.value.has("focus")&&q(i,"onFocus",!0,d),y.value.has("focus")&&q(i,"onBlur",!1,m),M.value.has("contextmenu")&&(i.onContextmenu=(r,...c)=>{v.value&&y.value.has("contextmenu")?s(!1):(F(r),s(!0)),r.preventDefault(),h.value.onContextMenu?.(r,...c)}),G.value=i});const ie=t.shallowRef(!1);return t.watchEffect(()=>{ie.value||=u.forceRender||o.value||g.value}),()=>{const e={...h.value,...qe.value},n={};["onContextmenu","onClick","onMousedown","onTouchstart","onMouseenter","onMouseleave","onFocus","onBlur"].forEach(N=>{$[N]&&(n[N]=(...se)=>{e[N]?.(...se),$[N](...se)})});const d={x:xe.value,y:Se.value},m=t.createVNode(_.value,{...e,...n,ref:Pe}),{unique:i,prefixCls:r,popup:c,popupClassName:Ie,popupStyle:Le,zIndex:He,fresh:$e,onPopupClick:Xe,mask:Ye,popupMotion:Ue,maskMotion:We,forceRender:_e,getPopupContainer:Je,stretch:Ge,mobile:Ke}=u;return console.log(g.value),t.createVNode(t.Fragment,null,[t.createVNode(Qe.default,{disabled:!o.value,onResize:Ee},st(m)?m:{default:()=>[m]}),ie.value&&l.value&&(!p||!i)&&t.createVNode(H.TriggerContextProvider,he.value,{default:()=>[t.createVNode(lt.default,{portal:C,ref:ye,prefixCls:r,popup:c,className:re.default(Ie,!X.value&&Oe.value),style:Le,target:l.value,onMouseEnter:D,onMouseLeave:L,onPointerEnter:D,zIndex:He,open:o.value,keepDom:g.value,fresh:$e,onClick:Xe,onPointerDownCapture:Be,mask:Ye,motion:Ue,maskMotion:We,onVisibleChanged:Ve,onPrepare:Fe,forceRender:_e,autoDestroy:me.value,getPopupContainer:Je,align:B.value,arrow:K.value,arrowPos:d,ready:be.value,offsetX:Me.value,offsetY:ke.value,offsetR:Re.value,offsetB:Ae.value,onAlign:P,stretch:Ge,targetWidth:ne.value/De.value,targetHeight:oe.value/Te.value,mobile:Ke},null)]})])}},{props:t.mergeDefaults({action:{type:[String,Array],required:!1},showAction:{type:Array,required:!1},hideAction:{type:Array,required:!1},prefixCls:{type:String,required:!1},zIndex:{type:Number,required:!1},onPopupAlign:{type:Function,required:!1},stretch:{type:String,required:!1},popupVisible:{type:Boolean,required:!1},defaultPopupVisible:{type:Boolean,required:!1},onOpenChange:{type:Function,required:!1},afterOpenChange:{type:Function,required:!1},onPopupVisibleChange:{type:Function,required:!1},afterPopupVisibleChange:{type:Function,required:!1},getPopupContainer:{type:Function,required:!1},forceRender:{type:Boolean,required:!1},autoDestroy:{type:Boolean,required:!1},mask:{type:Boolean,required:!1},maskClosable:{type:Boolean,required:!1},popupMotion:{type:Object,required:!1},maskMotion:{type:Object,required:!1},mouseEnterDelay:{type:Number,required:!1},mouseLeaveDelay:{type:Number,required:!1},focusDelay:{type:Number,required:!1},blurDelay:{type:Number,required:!1},popup:{type:[String,Number,null,Array,Function],required:!0,skipCheck:!0},popupPlacement:{type:String,required:!1},builtinPlacements:{type:Object,required:!1},popupAlign:{type:Object,required:!1},popupClassName:{type:String,required:!1},uniqueContainerClassName:{type:String,required:!1},uniqueContainerStyle:{type:null,required:!1},popupStyle:{type:null,required:!1},getPopupClassNameFromAlign:{type:Function,required:!1},onPopupClick:{type:Function,required:!1},alignPoint:{type:Boolean,required:!1},fresh:{type:Boolean,required:!1},unique:{type:Boolean,required:!1},arrow:{type:[Boolean,Object],required:!1},mobile:{type:Object,required:!1}},rt)})}const pe=de(fe.default);exports.UniqueProvider=it.default;exports.Trigger=pe;exports.default=pe;exports.generateTrigger=de;
@@ -0,0 +1,78 @@
1
+ import { VueNode } from '../../util/src/type';
2
+ import { CSSMotionProps } from '../../util/src/utils/transition';
3
+ import { CSSProperties } from 'vue';
4
+ import { ActionType, AlignType, ArrowTypeOuter, BuildInPlacements } from './interface';
5
+ import { MobileConfig } from './Popup';
6
+ export type { ActionType, AlignType, ArrowTypeOuter as ArrowType, BuildInPlacements, };
7
+ export interface TriggerRef {
8
+ nativeElement: HTMLElement;
9
+ popupElement: HTMLDivElement;
10
+ forceAlign: VoidFunction;
11
+ }
12
+ export interface TriggerProps {
13
+ action?: ActionType | ActionType[];
14
+ showAction?: ActionType[];
15
+ hideAction?: ActionType[];
16
+ prefixCls?: string;
17
+ zIndex?: number;
18
+ onPopupAlign?: (element: HTMLElement, align: AlignType) => void;
19
+ stretch?: string;
20
+ popupVisible?: boolean;
21
+ defaultPopupVisible?: boolean;
22
+ onOpenChange?: (visible: boolean) => void;
23
+ afterOpenChange?: (visible: boolean) => void;
24
+ /** @deprecated Use `onOpenChange` instead */
25
+ onPopupVisibleChange?: (visible: boolean) => void;
26
+ /** @deprecated Use `afterOpenChange` instead */
27
+ afterPopupVisibleChange?: (visible: boolean) => void;
28
+ getPopupContainer?: (node: HTMLElement) => HTMLElement;
29
+ forceRender?: boolean;
30
+ autoDestroy?: boolean;
31
+ mask?: boolean;
32
+ maskClosable?: boolean;
33
+ /** Set popup motion. You can ref `rc-motion` for more info. */
34
+ popupMotion?: CSSMotionProps;
35
+ /** Set mask motion. You can ref `rc-motion` for more info. */
36
+ maskMotion?: CSSMotionProps;
37
+ mouseEnterDelay?: number;
38
+ mouseLeaveDelay?: number;
39
+ focusDelay?: number;
40
+ blurDelay?: number;
41
+ popup: VueNode | (() => VueNode);
42
+ popupPlacement?: string;
43
+ builtinPlacements?: BuildInPlacements;
44
+ popupAlign?: AlignType;
45
+ popupClassName?: string;
46
+ /** Pass to `UniqueProvider` UniqueContainer */
47
+ uniqueContainerClassName?: string;
48
+ /** Pass to `UniqueProvider` UniqueContainer */
49
+ uniqueContainerStyle?: CSSProperties;
50
+ popupStyle?: CSSProperties;
51
+ getPopupClassNameFromAlign?: (align: AlignType) => string;
52
+ onPopupClick?: (e: MouseEvent) => void;
53
+ alignPoint?: boolean;
54
+ /**
55
+ * Trigger will memo content when close.
56
+ * This may affect the case if want to keep content update.
57
+ * Set `fresh` to `false` will always keep update.
58
+ */
59
+ fresh?: boolean;
60
+ /**
61
+ * Config with UniqueProvider to shared the floating popup.
62
+ */
63
+ unique?: boolean;
64
+ arrow?: boolean | ArrowTypeOuter;
65
+ /**
66
+ * @private Bump fixed position at bottom in mobile.
67
+ * Will replace the config of root props.
68
+ * This will directly trade as mobile view which will not check what real is.
69
+ * This is internal usage currently, do not use in your prod.
70
+ */
71
+ mobile?: MobileConfig;
72
+ }
73
+ export declare function generateTrigger(PortalComponent?: any): import('vue').DefineSetupFnComponent<TriggerProps, {}, {}, TriggerProps & {}, import('vue').PublicProps>;
74
+ declare const Trigger: import('vue').DefineSetupFnComponent<TriggerProps, {}, {}, TriggerProps & {}, import('vue').PublicProps>;
75
+ export { Trigger };
76
+ export default Trigger;
77
+ export { default as UniqueProvider } from './UniqueProvider';
78
+ export type { UniqueProviderProps } from './UniqueProvider';