@repere/react 0.2.2 → 0.3.0
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/components/Popover/Popover.d.ts +3 -4
- package/dist/components/Popover/Popover.d.ts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/RepereProvider.d.ts.map +1 -1
- package/dist/context/RepereContext.d.ts +5 -5
- package/dist/context/RepereContext.d.ts.map +1 -1
- package/dist/hooks/useBeaconAnchor.d.ts +17 -0
- package/dist/hooks/useBeaconAnchor.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +516 -451
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/renderRepereComponents.d.ts +6 -6
- package/dist/utils/renderRepereComponents.d.ts.map +1 -1
- package/dist/utils/resolveBeaconConfig.d.ts +4 -3
- package/dist/utils/resolveBeaconConfig.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/hooks/useBeaconPosition.d.ts +0 -16
- package/dist/hooks/useBeaconPosition.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as g, jsxs as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as g, jsxs as W } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Z, useContext as ee, useMemo as b, useState as I, useEffect as D, useCallback as T, isValidElement as j, cloneElement as q, useId as te, forwardRef as A } from "react";
|
|
3
3
|
import { createPortal as oe } from "react-dom";
|
|
4
|
-
import { motion as
|
|
5
|
-
var
|
|
6
|
-
const ne =
|
|
4
|
+
import { motion as N } from "motion/react";
|
|
5
|
+
var h = /* @__PURE__ */ ((e) => (e.TopLeft = "top-left", e.TopCenter = "top-center", e.TopRight = "top-right", e.RightCenter = "right-center", e.BottomRight = "bottom-right", e.BottomCenter = "bottom-center", e.BottomLeft = "bottom-left", e.LeftCenter = "left-center", e))(h || {});
|
|
6
|
+
const ne = h.TopRight;
|
|
7
7
|
class ie {
|
|
8
8
|
state = /* @__PURE__ */ new Map();
|
|
9
9
|
isDismissed(t) {
|
|
@@ -25,59 +25,285 @@ class ie {
|
|
|
25
25
|
return Array.from(this.state.values());
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
var
|
|
28
|
+
var m = /* @__PURE__ */ ((e) => (e.Fade = "fade", e.Scale = "scale", e.Grow = "grow", e.Shrink = "shrink", e.SlideUp = "slide-up", e.SlideDown = "slide-down", e.SlideLeft = "slide-left", e.SlideRight = "slide-right", e.None = "none", e))(m || {}), P = /* @__PURE__ */ ((e) => (e.Fixed = "fixed", e.Absolute = "absolute", e))(P || {});
|
|
29
|
+
function L(e, t, o, n = P.Absolute) {
|
|
30
|
+
const s = o?.x ?? 0, a = o?.y ?? 0, i = n === P.Absolute ? window.scrollY : 0, r = n === P.Absolute ? window.scrollX : 0;
|
|
31
|
+
let c = 0, l = 0, d = "0%", p = "0%";
|
|
32
|
+
switch (t) {
|
|
33
|
+
case h.TopLeft:
|
|
34
|
+
c = e.top + i, l = e.left + r, d = "0%", p = "-100%";
|
|
35
|
+
break;
|
|
36
|
+
case h.TopCenter:
|
|
37
|
+
c = e.top + i, l = e.left + r + e.width / 2, d = "-50%", p = "-100%";
|
|
38
|
+
break;
|
|
39
|
+
case h.TopRight:
|
|
40
|
+
c = e.top + i, l = e.right + r, d = "-100%", p = "-100%";
|
|
41
|
+
break;
|
|
42
|
+
case h.RightCenter:
|
|
43
|
+
c = e.top + i + e.height / 2, l = e.right + r, d = "0%", p = "-50%";
|
|
44
|
+
break;
|
|
45
|
+
case h.BottomRight:
|
|
46
|
+
c = e.bottom + i, l = e.right + r, d = "-100%", p = "0%";
|
|
47
|
+
break;
|
|
48
|
+
case h.BottomCenter:
|
|
49
|
+
c = e.bottom + i, l = e.left + r + e.width / 2, d = "-50%", p = "0%";
|
|
50
|
+
break;
|
|
51
|
+
case h.BottomLeft:
|
|
52
|
+
c = e.bottom + i, l = e.left + r, d = "0%", p = "0%";
|
|
53
|
+
break;
|
|
54
|
+
case h.LeftCenter:
|
|
55
|
+
c = e.top + i + e.height / 2, l = e.left + r, d = "-100%", p = "-50%";
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
c = e.top + i, l = e.right + r, d = "-100%", p = "-100%";
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
return c += a, l += s, {
|
|
62
|
+
top: c,
|
|
63
|
+
left: l,
|
|
64
|
+
translate: { x: d, y: p }
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
class re {
|
|
68
|
+
tracked = /* @__PURE__ */ new Map();
|
|
69
|
+
scrollListener = null;
|
|
70
|
+
resizeListener = null;
|
|
71
|
+
resizeObserver = null;
|
|
72
|
+
mutationObserver = null;
|
|
73
|
+
updateScheduled = !1;
|
|
74
|
+
debug = !1;
|
|
75
|
+
constructor(t = !1) {
|
|
76
|
+
this.debug = t;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Subscribe to anchor point updates for an element
|
|
80
|
+
*/
|
|
81
|
+
subscribe(t, o, n, s = {}) {
|
|
82
|
+
return (s.positioningStrategy ?? P.Absolute) === P.Absolute ? this.subscribeAbsolute(t, o, n, s) : this.subscribeFixed(t, o, n, s);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Subscribe with absolute positioning strategy (no tracking)
|
|
86
|
+
*/
|
|
87
|
+
subscribeAbsolute(t, o, n, s) {
|
|
88
|
+
const { offset: a, zIndex: i = 9999, delay: r = 0 } = s, c = () => {
|
|
89
|
+
const l = document.querySelector(t);
|
|
90
|
+
if (!l) {
|
|
91
|
+
this.debug && console.log(
|
|
92
|
+
`[AnchorPointTracker:Absolute] Element not found: ${t}`
|
|
93
|
+
), n(null);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const d = l.getBoundingClientRect(), p = {
|
|
97
|
+
...L(d, o, a),
|
|
98
|
+
position: "absolute",
|
|
99
|
+
zIndex: i
|
|
100
|
+
};
|
|
101
|
+
this.debug && console.log(
|
|
102
|
+
`[AnchorPointTracker:Absolute] Calculated anchor point for ${t}:`,
|
|
103
|
+
p
|
|
104
|
+
), n(p);
|
|
105
|
+
};
|
|
106
|
+
if (r > 0) {
|
|
107
|
+
this.debug && console.log(
|
|
108
|
+
`[AnchorPointTracker:Absolute] Delaying calculation for ${t} by ${r}ms`
|
|
109
|
+
);
|
|
110
|
+
const l = setTimeout(c, r);
|
|
111
|
+
return () => clearTimeout(l);
|
|
112
|
+
} else
|
|
113
|
+
return c(), () => {
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Subscribe with fixed positioning strategy (with tracking)
|
|
118
|
+
*/
|
|
119
|
+
subscribeFixed(t, o, n, s) {
|
|
120
|
+
const a = t;
|
|
121
|
+
this.tracked.has(a) || this.tracked.set(a, {
|
|
122
|
+
selector: t,
|
|
123
|
+
anchorPoint: o,
|
|
124
|
+
offset: s.offset,
|
|
125
|
+
zIndex: s.zIndex ?? 9999,
|
|
126
|
+
delay: s.delay,
|
|
127
|
+
positioningStrategy: P.Fixed,
|
|
128
|
+
callbacks: /* @__PURE__ */ new Map(),
|
|
129
|
+
element: null,
|
|
130
|
+
delayTimeoutIds: /* @__PURE__ */ new Map()
|
|
131
|
+
});
|
|
132
|
+
const i = this.tracked.get(a);
|
|
133
|
+
return i ? (i.callbacks.set(n, {
|
|
134
|
+
callback: n,
|
|
135
|
+
needsInitialDelay: (s.delay ?? 0) > 0
|
|
136
|
+
}), this.tracked.size === 1 && this.startListening(), this.scheduleInitialUpdate(a, n), () => {
|
|
137
|
+
const r = this.tracked.get(a);
|
|
138
|
+
if (r) {
|
|
139
|
+
const c = r.delayTimeoutIds.get(n);
|
|
140
|
+
if (c !== void 0 && (clearTimeout(c), r.delayTimeoutIds.delete(n)), r.callbacks.delete(n), r.callbacks.size === 0) {
|
|
141
|
+
for (const [, l] of r.delayTimeoutIds)
|
|
142
|
+
clearTimeout(l);
|
|
143
|
+
r.delayTimeoutIds.clear(), this.tracked.delete(a), this.tracked.size === 0 && this.stopListening();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}) : () => {
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
scheduleInitialUpdate(t, o) {
|
|
150
|
+
const n = this.tracked.get(t);
|
|
151
|
+
if (!n) return;
|
|
152
|
+
const s = n.callbacks.get(o);
|
|
153
|
+
if (s)
|
|
154
|
+
if (s.needsInitialDelay && n.delay && n.delay > 0) {
|
|
155
|
+
this.debug && console.log(
|
|
156
|
+
`[AnchorPointTracker:Fixed] Delaying initial anchor point calculation for ${t} by ${n.delay}ms`
|
|
157
|
+
);
|
|
158
|
+
const a = setTimeout(() => {
|
|
159
|
+
this.debug && console.log(
|
|
160
|
+
`[AnchorPointTracker:Fixed] Calculating anchor point for ${t} after delay`
|
|
161
|
+
);
|
|
162
|
+
const i = n.callbacks.get(o);
|
|
163
|
+
i && (i.needsInitialDelay = !1), n.delayTimeoutIds.delete(o), this.updateAnchorPointForCallback(t, o);
|
|
164
|
+
}, n.delay);
|
|
165
|
+
n.delayTimeoutIds.set(o, a);
|
|
166
|
+
} else
|
|
167
|
+
this.updateAnchorPointForCallback(t, o);
|
|
168
|
+
}
|
|
169
|
+
updateAnchorPointForCallback(t, o) {
|
|
170
|
+
const n = this.tracked.get(t);
|
|
171
|
+
if (!n) return;
|
|
172
|
+
const s = document.querySelector(n.selector);
|
|
173
|
+
if (!s) {
|
|
174
|
+
this.debug && console.log(
|
|
175
|
+
`[AnchorPointTracker:Fixed] Element not found: ${n.selector}`
|
|
176
|
+
), n.element = null, o(null);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
n.element = s;
|
|
180
|
+
const a = s.getBoundingClientRect(), i = {
|
|
181
|
+
...L(
|
|
182
|
+
a,
|
|
183
|
+
n.anchorPoint,
|
|
184
|
+
n.offset
|
|
185
|
+
),
|
|
186
|
+
position: "fixed",
|
|
187
|
+
zIndex: n.zIndex
|
|
188
|
+
};
|
|
189
|
+
this.debug && console.log(
|
|
190
|
+
`[AnchorPointTracker:Fixed] Updated anchor point for ${n.selector}:`,
|
|
191
|
+
i
|
|
192
|
+
), o(i);
|
|
193
|
+
}
|
|
194
|
+
updateAnchorPoint(t) {
|
|
195
|
+
const o = this.tracked.get(t);
|
|
196
|
+
if (!o) return;
|
|
197
|
+
const n = document.querySelector(o.selector);
|
|
198
|
+
if (!n) {
|
|
199
|
+
this.debug && console.log(
|
|
200
|
+
`[AnchorPointTracker:Fixed] Element not found: ${o.selector}`
|
|
201
|
+
), o.element = null;
|
|
202
|
+
for (const [i, r] of o.callbacks)
|
|
203
|
+
r.needsInitialDelay || i(null);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
o.element = n;
|
|
207
|
+
const s = n.getBoundingClientRect(), a = {
|
|
208
|
+
...L(
|
|
209
|
+
s,
|
|
210
|
+
o.anchorPoint,
|
|
211
|
+
o.offset
|
|
212
|
+
),
|
|
213
|
+
position: "fixed",
|
|
214
|
+
zIndex: o.zIndex
|
|
215
|
+
};
|
|
216
|
+
this.debug && console.log(
|
|
217
|
+
`[AnchorPointTracker:Fixed] Updated anchor point for ${o.selector}:`,
|
|
218
|
+
a
|
|
219
|
+
);
|
|
220
|
+
for (const [i, r] of o.callbacks)
|
|
221
|
+
r.needsInitialDelay || i(a);
|
|
222
|
+
}
|
|
223
|
+
scheduleUpdate = () => {
|
|
224
|
+
this.updateScheduled || (this.updateScheduled = !0, requestAnimationFrame(() => {
|
|
225
|
+
this.updateAllAnchorPointsSync(), this.updateScheduled = !1;
|
|
226
|
+
}));
|
|
227
|
+
};
|
|
228
|
+
updateAllAnchorPointsSync = () => {
|
|
229
|
+
for (const [t] of this.tracked)
|
|
230
|
+
this.updateAnchorPoint(t);
|
|
231
|
+
};
|
|
232
|
+
startListening() {
|
|
233
|
+
this.scrollListener = this.scheduleUpdate, window.addEventListener("scroll", this.scrollListener, !0), this.resizeListener = this.scheduleUpdate, window.addEventListener("resize", this.resizeListener), "ResizeObserver" in window && (this.resizeObserver = new ResizeObserver(this.scheduleUpdate)), this.mutationObserver = new MutationObserver(() => {
|
|
234
|
+
this.scheduleUpdate();
|
|
235
|
+
}), this.mutationObserver.observe(document.body, {
|
|
236
|
+
childList: !0,
|
|
237
|
+
subtree: !0
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
stopListening() {
|
|
241
|
+
this.scrollListener && (window.removeEventListener("scroll", this.scrollListener, !0), this.scrollListener = null), this.resizeListener && (window.removeEventListener("resize", this.resizeListener), this.resizeListener = null), this.resizeObserver?.disconnect(), this.resizeObserver = null, this.mutationObserver?.disconnect(), this.mutationObserver = null;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Clean up all listeners and subscriptions
|
|
245
|
+
*/
|
|
246
|
+
destroy() {
|
|
247
|
+
for (const [, t] of this.tracked) {
|
|
248
|
+
for (const [, o] of t.delayTimeoutIds)
|
|
249
|
+
clearTimeout(o);
|
|
250
|
+
t.delayTimeoutIds.clear();
|
|
251
|
+
}
|
|
252
|
+
this.stopListening(), this.tracked.clear();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
29
255
|
const se = {
|
|
30
|
-
[
|
|
256
|
+
[m.SlideDown]: {
|
|
31
257
|
initial: { y: -20, opacity: 0 },
|
|
32
258
|
animate: { y: 0, opacity: 1 },
|
|
33
259
|
exit: { y: -20, opacity: 0 }
|
|
34
260
|
},
|
|
35
|
-
[
|
|
261
|
+
[m.SlideUp]: {
|
|
36
262
|
initial: { y: 20, opacity: 0 },
|
|
37
263
|
animate: { y: 0, opacity: 1 },
|
|
38
264
|
exit: { y: 20, opacity: 0 }
|
|
39
265
|
},
|
|
40
|
-
[
|
|
266
|
+
[m.SlideLeft]: {
|
|
41
267
|
initial: { x: 20, opacity: 0 },
|
|
42
268
|
animate: { x: 0, opacity: 1 },
|
|
43
269
|
exit: { x: 20, opacity: 0 }
|
|
44
270
|
},
|
|
45
|
-
[
|
|
271
|
+
[m.SlideRight]: {
|
|
46
272
|
initial: { x: -20, opacity: 0 },
|
|
47
273
|
animate: { x: 0, opacity: 1 },
|
|
48
274
|
exit: { x: -20, opacity: 0 }
|
|
49
275
|
},
|
|
50
|
-
[
|
|
276
|
+
[m.Fade]: {
|
|
51
277
|
initial: { opacity: 0 },
|
|
52
278
|
animate: { opacity: 1 },
|
|
53
279
|
exit: { opacity: 0 }
|
|
54
280
|
},
|
|
55
|
-
[
|
|
281
|
+
[m.Shrink]: {
|
|
56
282
|
initial: { scale: 1.1, opacity: 0 },
|
|
57
283
|
animate: { scale: 1, opacity: 1 },
|
|
58
284
|
exit: { scale: 0.9, opacity: 0 }
|
|
59
285
|
},
|
|
60
|
-
[
|
|
286
|
+
[m.Grow]: {
|
|
61
287
|
initial: { scale: 0.9, opacity: 0 },
|
|
62
288
|
animate: { scale: 1, opacity: 1 },
|
|
63
289
|
exit: { scale: 1.1, opacity: 0 }
|
|
64
290
|
},
|
|
65
|
-
[
|
|
291
|
+
[m.Scale]: {
|
|
66
292
|
initial: { scale: 0, opacity: 0 },
|
|
67
293
|
animate: { scale: 1, opacity: 1 },
|
|
68
294
|
exit: { scale: 0, opacity: 0 }
|
|
69
295
|
},
|
|
70
|
-
[
|
|
296
|
+
[m.None]: {
|
|
71
297
|
initial: {},
|
|
72
298
|
animate: {},
|
|
73
299
|
exit: {}
|
|
74
300
|
}
|
|
75
301
|
};
|
|
76
|
-
function
|
|
302
|
+
function z(e) {
|
|
77
303
|
return e ? typeof e == "string" ? { variant: e } : e : null;
|
|
78
304
|
}
|
|
79
|
-
function
|
|
80
|
-
const o =
|
|
305
|
+
function S(e, t) {
|
|
306
|
+
const o = z(e), n = z(t);
|
|
81
307
|
return !o && !n ? null : o ? n ? {
|
|
82
308
|
variant: n.variant ?? o.variant,
|
|
83
309
|
duration: n.duration ?? o.duration,
|
|
@@ -85,8 +311,8 @@ function T(e, t) {
|
|
|
85
311
|
ease: n.ease ?? o.ease
|
|
86
312
|
} : o : n;
|
|
87
313
|
}
|
|
88
|
-
function
|
|
89
|
-
const t =
|
|
314
|
+
function B(e) {
|
|
315
|
+
const t = z(e);
|
|
90
316
|
if (!t) return null;
|
|
91
317
|
const o = se[t.variant];
|
|
92
318
|
return o ? {
|
|
@@ -100,11 +326,11 @@ function $(e) {
|
|
|
100
326
|
}
|
|
101
327
|
} : (console.warn(`[Repere] Unknown animation variant: ${t.variant}`), null);
|
|
102
328
|
}
|
|
103
|
-
function
|
|
329
|
+
function ae(e, t) {
|
|
104
330
|
const o = (i) => {
|
|
105
|
-
const
|
|
106
|
-
return
|
|
107
|
-
}, n = o(e.x),
|
|
331
|
+
const r = i.match(/(-?\d+)%/);
|
|
332
|
+
return r ? parseFloat(r[1]) : 0;
|
|
333
|
+
}, n = o(e.x), s = o(e.y), a = (i = 0) => s === 0 && i === 0 ? `translate(${n}%, 0)` : i === 0 ? `translate(${n}%, ${s}%)` : `translate(${n}%, calc(${s}% + ${i}px))`;
|
|
108
334
|
return {
|
|
109
335
|
initial: {
|
|
110
336
|
...t.initial,
|
|
@@ -120,9 +346,9 @@ function re(e, t) {
|
|
|
120
346
|
}
|
|
121
347
|
};
|
|
122
348
|
}
|
|
123
|
-
function
|
|
349
|
+
function ce(e, t) {
|
|
124
350
|
if (!e && !t) return {};
|
|
125
|
-
const o = e?.variants, n = e?.transition,
|
|
351
|
+
const o = e?.variants, n = e?.transition, s = t?.variants, a = t?.transition, i = a?.ease ?? n?.ease ?? [0.4, 0, 0.2, 1], r = Array.isArray(i) ? `cubic-bezier(${i.join(", ")})` : i;
|
|
126
352
|
return {
|
|
127
353
|
// Initial state (when opening starts) - from onOpen animation
|
|
128
354
|
"--repere-initial-opacity": o?.initial.opacity ?? 0,
|
|
@@ -135,20 +361,20 @@ function ae(e, t) {
|
|
|
135
361
|
"--repere-animate-y": `${o?.animate.y ?? 0}px`,
|
|
136
362
|
"--repere-animate-scale": o?.animate.scale ?? 1,
|
|
137
363
|
// Exit state (when closing) - from onClose animation
|
|
138
|
-
"--repere-exit-opacity":
|
|
139
|
-
"--repere-exit-x": `${
|
|
140
|
-
"--repere-exit-y": `${
|
|
141
|
-
"--repere-exit-scale":
|
|
364
|
+
"--repere-exit-opacity": s?.exit.opacity ?? 0,
|
|
365
|
+
"--repere-exit-x": `${s?.exit.x ?? 0}px`,
|
|
366
|
+
"--repere-exit-y": `${s?.exit.y ?? 0}px`,
|
|
367
|
+
"--repere-exit-scale": s?.exit.scale ?? 1,
|
|
142
368
|
// Transition timing
|
|
143
369
|
"--repere-transition-duration": `${a?.duration ?? n?.duration ?? 0.3}s`,
|
|
144
|
-
"--repere-transition-timing":
|
|
370
|
+
"--repere-transition-timing": r
|
|
145
371
|
};
|
|
146
372
|
}
|
|
147
373
|
function le(e, t) {
|
|
148
374
|
const o = e?.transition.duration ?? 0, n = t?.transition.duration ?? 0;
|
|
149
375
|
return Math.max(o, n) * 1e3;
|
|
150
376
|
}
|
|
151
|
-
function
|
|
377
|
+
function de(e) {
|
|
152
378
|
return new Promise((t) => setTimeout(t, e));
|
|
153
379
|
}
|
|
154
380
|
function pe(e, t) {
|
|
@@ -162,7 +388,7 @@ function pe(e, t) {
|
|
|
162
388
|
}
|
|
163
389
|
return !1;
|
|
164
390
|
}
|
|
165
|
-
class
|
|
391
|
+
class ue {
|
|
166
392
|
store;
|
|
167
393
|
debug;
|
|
168
394
|
constructor(t, o = {}) {
|
|
@@ -173,12 +399,12 @@ class de {
|
|
|
173
399
|
* This supports wildcards - e.g., path="*" will match all pages
|
|
174
400
|
*/
|
|
175
401
|
findMatchingPages(t, o) {
|
|
176
|
-
const n = t.filter((
|
|
402
|
+
const n = t.filter((s) => typeof s.path == "function" ? s.path(o) : pe(o, s.path));
|
|
177
403
|
return this.debug && console.log(
|
|
178
404
|
"[BeaconManager] Path:",
|
|
179
405
|
o,
|
|
180
406
|
"Matched pages:",
|
|
181
|
-
n.map((
|
|
407
|
+
n.map((s) => s.id).join(", ") || "none"
|
|
182
408
|
), n;
|
|
183
409
|
}
|
|
184
410
|
/**
|
|
@@ -193,24 +419,24 @@ class de {
|
|
|
193
419
|
"[BeaconManager] Found",
|
|
194
420
|
n.length,
|
|
195
421
|
"matching page(s):",
|
|
196
|
-
n.map((
|
|
422
|
+
n.map((r) => r.id).join(", ")
|
|
197
423
|
);
|
|
198
|
-
const
|
|
199
|
-
for (const
|
|
200
|
-
for (const
|
|
201
|
-
if (a.has(
|
|
424
|
+
const s = [], a = /* @__PURE__ */ new Set();
|
|
425
|
+
for (const r of n)
|
|
426
|
+
for (const c of r.beacons) {
|
|
427
|
+
if (a.has(c.id)) {
|
|
202
428
|
this.debug && console.warn(
|
|
203
|
-
`[BeaconManager] Duplicate beacon ID "${
|
|
429
|
+
`[BeaconManager] Duplicate beacon ID "${c.id}" in page "${r.id}", skipping`
|
|
204
430
|
);
|
|
205
431
|
continue;
|
|
206
432
|
}
|
|
207
|
-
a.add(
|
|
433
|
+
a.add(c.id), s.push(c);
|
|
208
434
|
}
|
|
209
435
|
const i = [];
|
|
210
|
-
for (const
|
|
436
|
+
for (const r of s)
|
|
211
437
|
await Promise.resolve(
|
|
212
|
-
this.store.isDismissed(
|
|
213
|
-
) ? this.debug && console.log("[BeaconManager] Beacon",
|
|
438
|
+
this.store.isDismissed(r.id)
|
|
439
|
+
) ? this.debug && console.log("[BeaconManager] Beacon", r.id, "is dismissed") : i.push(r);
|
|
214
440
|
return this.debug && console.log("[BeaconManager] Active beacons:", i.length), i;
|
|
215
441
|
}
|
|
216
442
|
/**
|
|
@@ -220,207 +446,29 @@ class de {
|
|
|
220
446
|
return this.store;
|
|
221
447
|
}
|
|
222
448
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
switch (t) {
|
|
227
|
-
// Top positions
|
|
228
|
-
case m.TopLeft:
|
|
229
|
-
a = e.top + window.scrollY, i = e.left + window.scrollX, s = "-50%", l = "-100%";
|
|
230
|
-
break;
|
|
231
|
-
case m.TopCenter:
|
|
232
|
-
a = e.top + window.scrollY, i = e.left + window.scrollX + e.width / 2, s = "-50%", l = "-100%";
|
|
233
|
-
break;
|
|
234
|
-
case m.TopRight:
|
|
235
|
-
a = e.top + window.scrollY, i = e.right + window.scrollX, s = "-50%", l = "-100%";
|
|
236
|
-
break;
|
|
237
|
-
// Right positions
|
|
238
|
-
case m.RightCenter:
|
|
239
|
-
a = e.top + window.scrollY + e.height / 2, i = e.right + window.scrollX, s = "0", l = "-50%";
|
|
240
|
-
break;
|
|
241
|
-
// Bottom positions
|
|
242
|
-
case m.BottomLeft:
|
|
243
|
-
a = e.bottom + window.scrollY, i = e.left + window.scrollX, s = "-50%", l = "0";
|
|
244
|
-
break;
|
|
245
|
-
case m.BottomCenter:
|
|
246
|
-
a = e.bottom + window.scrollY, i = e.left + window.scrollX + e.width / 2, s = "-50%", l = "0";
|
|
247
|
-
break;
|
|
248
|
-
case m.BottomRight:
|
|
249
|
-
a = e.bottom + window.scrollY, i = e.right + window.scrollX, s = "-50%", l = "0";
|
|
250
|
-
break;
|
|
251
|
-
// Left positions
|
|
252
|
-
case m.LeftCenter:
|
|
253
|
-
a = e.top + window.scrollY + e.height / 2, i = e.left + window.scrollX, s = "-100%", l = "-50%";
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
return a += r, i += n, {
|
|
257
|
-
top: a,
|
|
258
|
-
left: i,
|
|
259
|
-
translate: { x: s, y: l }
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
class ue {
|
|
263
|
-
tracked = /* @__PURE__ */ new Map();
|
|
264
|
-
scrollListener = null;
|
|
265
|
-
resizeListener = null;
|
|
266
|
-
resizeObserver = null;
|
|
267
|
-
mutationObserver = null;
|
|
268
|
-
debug = !1;
|
|
269
|
-
constructor(t = !1) {
|
|
270
|
-
this.debug = t;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Subscribe to position updates for an element
|
|
274
|
-
*/
|
|
275
|
-
subscribe(t, o, n, r = {}) {
|
|
276
|
-
const a = t;
|
|
277
|
-
this.tracked.has(a) || this.tracked.set(a, {
|
|
278
|
-
selector: t,
|
|
279
|
-
position: o,
|
|
280
|
-
offset: r.offset,
|
|
281
|
-
zIndex: r.zIndex ?? 9999,
|
|
282
|
-
delay: r.delay,
|
|
283
|
-
callbacks: /* @__PURE__ */ new Map(),
|
|
284
|
-
element: null,
|
|
285
|
-
delayTimeoutIds: /* @__PURE__ */ new Map()
|
|
286
|
-
});
|
|
287
|
-
const i = this.tracked.get(a);
|
|
288
|
-
return i ? (i.callbacks.set(n, {
|
|
289
|
-
callback: n,
|
|
290
|
-
needsInitialDelay: (r.delay ?? 0) > 0
|
|
291
|
-
}), this.tracked.size === 1 && this.startListening(), this.scheduleInitialUpdate(a, n), () => {
|
|
292
|
-
const s = this.tracked.get(a);
|
|
293
|
-
if (s) {
|
|
294
|
-
const l = s.delayTimeoutIds.get(n);
|
|
295
|
-
if (l !== void 0 && (clearTimeout(l), s.delayTimeoutIds.delete(n)), s.callbacks.delete(n), s.callbacks.size === 0) {
|
|
296
|
-
for (const [, c] of s.delayTimeoutIds)
|
|
297
|
-
clearTimeout(c);
|
|
298
|
-
s.delayTimeoutIds.clear(), this.tracked.delete(a), this.tracked.size === 0 && this.stopListening();
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}) : () => {
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
scheduleInitialUpdate(t, o) {
|
|
305
|
-
const n = this.tracked.get(t);
|
|
306
|
-
if (!n) return;
|
|
307
|
-
const r = n.callbacks.get(o);
|
|
308
|
-
if (r)
|
|
309
|
-
if (r.needsInitialDelay && n.delay && n.delay > 0) {
|
|
310
|
-
this.debug && console.log(
|
|
311
|
-
`[PositionTracker] Delaying initial position calculation for ${t} by ${n.delay}ms`
|
|
312
|
-
);
|
|
313
|
-
const a = setTimeout(() => {
|
|
314
|
-
this.debug && console.log(
|
|
315
|
-
`[PositionTracker] Calculating position for ${t} after delay`
|
|
316
|
-
);
|
|
317
|
-
const i = n.callbacks.get(o);
|
|
318
|
-
i && (i.needsInitialDelay = !1), n.delayTimeoutIds.delete(o), this.updatePositionForCallback(t, o);
|
|
319
|
-
}, n.delay);
|
|
320
|
-
n.delayTimeoutIds.set(o, a);
|
|
321
|
-
} else
|
|
322
|
-
this.updatePositionForCallback(t, o);
|
|
323
|
-
}
|
|
324
|
-
updatePositionForCallback(t, o) {
|
|
325
|
-
const n = this.tracked.get(t);
|
|
326
|
-
if (!n) return;
|
|
327
|
-
const r = document.querySelector(n.selector);
|
|
328
|
-
if (!r) {
|
|
329
|
-
this.debug && console.log(`[PositionTracker] Element not found: ${n.selector}`), n.element = null, o(null);
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
n.element = r;
|
|
333
|
-
const a = r.getBoundingClientRect(), i = {
|
|
334
|
-
...N(
|
|
335
|
-
a,
|
|
336
|
-
n.position,
|
|
337
|
-
n.offset
|
|
338
|
-
),
|
|
339
|
-
position: "fixed",
|
|
340
|
-
zIndex: n.zIndex
|
|
341
|
-
};
|
|
342
|
-
this.debug && console.log(
|
|
343
|
-
`[PositionTracker] Updated position for ${n.selector}:`,
|
|
344
|
-
i
|
|
345
|
-
), o(i);
|
|
346
|
-
}
|
|
347
|
-
updatePosition(t) {
|
|
348
|
-
const o = this.tracked.get(t);
|
|
349
|
-
if (!o) return;
|
|
350
|
-
const n = document.querySelector(o.selector);
|
|
351
|
-
if (!n) {
|
|
352
|
-
this.debug && console.log(`[PositionTracker] Element not found: ${o.selector}`), o.element = null;
|
|
353
|
-
for (const [i, s] of o.callbacks)
|
|
354
|
-
s.needsInitialDelay || i(null);
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
o.element = n;
|
|
358
|
-
const r = n.getBoundingClientRect(), a = {
|
|
359
|
-
...N(
|
|
360
|
-
r,
|
|
361
|
-
o.position,
|
|
362
|
-
o.offset
|
|
363
|
-
),
|
|
364
|
-
position: "fixed",
|
|
365
|
-
zIndex: o.zIndex
|
|
366
|
-
};
|
|
367
|
-
this.debug && console.log(
|
|
368
|
-
`[PositionTracker] Updated position for ${o.selector}:`,
|
|
369
|
-
a
|
|
370
|
-
);
|
|
371
|
-
for (const [i, s] of o.callbacks)
|
|
372
|
-
s.needsInitialDelay || i(a);
|
|
373
|
-
}
|
|
374
|
-
updateAllPositions = () => {
|
|
375
|
-
for (const [t] of this.tracked)
|
|
376
|
-
this.updatePosition(t);
|
|
377
|
-
};
|
|
378
|
-
startListening() {
|
|
379
|
-
this.scrollListener = this.updateAllPositions, window.addEventListener("scroll", this.scrollListener, !0), this.resizeListener = this.updateAllPositions, window.addEventListener("resize", this.resizeListener), "ResizeObserver" in window && (this.resizeObserver = new ResizeObserver(this.updateAllPositions)), this.mutationObserver = new MutationObserver(() => {
|
|
380
|
-
this.updateAllPositions();
|
|
381
|
-
}), this.mutationObserver.observe(document.body, {
|
|
382
|
-
childList: !0,
|
|
383
|
-
subtree: !0
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
stopListening() {
|
|
387
|
-
this.scrollListener && (window.removeEventListener("scroll", this.scrollListener, !0), this.scrollListener = null), this.resizeListener && (window.removeEventListener("resize", this.resizeListener), this.resizeListener = null), this.resizeObserver?.disconnect(), this.resizeObserver = null, this.mutationObserver?.disconnect(), this.mutationObserver = null;
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Clean up all listeners and subscriptions
|
|
391
|
-
*/
|
|
392
|
-
destroy() {
|
|
393
|
-
for (const [, t] of this.tracked) {
|
|
394
|
-
for (const [, o] of t.delayTimeoutIds)
|
|
395
|
-
clearTimeout(o);
|
|
396
|
-
t.delayTimeoutIds.clear();
|
|
397
|
-
}
|
|
398
|
-
this.stopListening(), this.tracked.clear();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
const j = W(null);
|
|
402
|
-
function I() {
|
|
403
|
-
const e = Z(j);
|
|
449
|
+
const _ = Z(null);
|
|
450
|
+
function $() {
|
|
451
|
+
const e = ee(_);
|
|
404
452
|
if (!e)
|
|
405
|
-
throw new Error("useRepereContext must be used within
|
|
453
|
+
throw new Error("useRepereContext must be used within RepereProvider");
|
|
406
454
|
return e;
|
|
407
455
|
}
|
|
408
|
-
function
|
|
409
|
-
const o =
|
|
410
|
-
const i = t.trigger?.animations?.onRender,
|
|
411
|
-
return
|
|
412
|
-
}, [t.trigger?.animations, e.trigger?.animations]), n =
|
|
413
|
-
const i = t.trigger?.animations?.onDismiss,
|
|
414
|
-
return
|
|
456
|
+
function ge(e, t) {
|
|
457
|
+
const o = b(() => {
|
|
458
|
+
const i = t.trigger?.animations?.onRender, r = e.trigger?.animations?.onRender;
|
|
459
|
+
return B(S(i, r));
|
|
460
|
+
}, [t.trigger?.animations, e.trigger?.animations]), n = b(() => {
|
|
461
|
+
const i = t.trigger?.animations?.onDismiss, r = e.trigger?.animations?.onDismiss;
|
|
462
|
+
return B(S(i, r));
|
|
415
463
|
}, [
|
|
416
464
|
t.trigger?.animations?.onDismiss,
|
|
417
465
|
e.trigger?.animations?.onDismiss
|
|
418
|
-
]),
|
|
419
|
-
const i = t.popover?.animations?.onOpen,
|
|
420
|
-
return
|
|
421
|
-
}, [t.popover?.animations?.onOpen, e.popover?.animations?.onOpen]), a =
|
|
422
|
-
const i = t.popover?.animations?.onClose,
|
|
423
|
-
return
|
|
466
|
+
]), s = b(() => {
|
|
467
|
+
const i = t.popover?.animations?.onOpen, r = e.popover?.animations?.onOpen;
|
|
468
|
+
return B(S(i, r));
|
|
469
|
+
}, [t.popover?.animations?.onOpen, e.popover?.animations?.onOpen]), a = b(() => {
|
|
470
|
+
const i = t.popover?.animations?.onClose, r = e.popover?.animations?.onClose;
|
|
471
|
+
return B(S(i, r));
|
|
424
472
|
}, [
|
|
425
473
|
t.popover?.animations?.onClose,
|
|
426
474
|
e.popover?.animations?.onClose
|
|
@@ -428,311 +476,327 @@ function me(e, t) {
|
|
|
428
476
|
return {
|
|
429
477
|
triggerAnimation: o,
|
|
430
478
|
triggerDismissAnimation: n,
|
|
431
|
-
popoverOpenAnimation:
|
|
479
|
+
popoverOpenAnimation: s,
|
|
432
480
|
popoverCloseAnimation: a
|
|
433
481
|
};
|
|
434
482
|
}
|
|
435
|
-
function
|
|
483
|
+
function me({
|
|
436
484
|
targetSelector: e,
|
|
437
|
-
|
|
485
|
+
anchorPoint: t,
|
|
438
486
|
offset: o,
|
|
439
487
|
zIndex: n = 9999,
|
|
440
|
-
delay:
|
|
441
|
-
|
|
442
|
-
|
|
488
|
+
delay: s,
|
|
489
|
+
positioningStrategy: a,
|
|
490
|
+
enabled: i = !0,
|
|
491
|
+
debug: r = !1
|
|
443
492
|
}) {
|
|
444
|
-
const [
|
|
445
|
-
return
|
|
446
|
-
if (!
|
|
493
|
+
const [c, l] = I(null), d = b(() => new re(r), [r]);
|
|
494
|
+
return D(() => {
|
|
495
|
+
if (!i) {
|
|
447
496
|
l(null);
|
|
448
497
|
return;
|
|
449
498
|
}
|
|
450
|
-
return
|
|
499
|
+
return d.subscribe(
|
|
451
500
|
e,
|
|
452
501
|
t,
|
|
453
502
|
l,
|
|
454
|
-
{ offset: o, zIndex: n, delay:
|
|
503
|
+
{ offset: o, zIndex: n, delay: s, positioningStrategy: a }
|
|
455
504
|
);
|
|
456
|
-
}, [
|
|
457
|
-
|
|
458
|
-
|
|
505
|
+
}, [
|
|
506
|
+
d,
|
|
507
|
+
e,
|
|
508
|
+
t,
|
|
509
|
+
o,
|
|
510
|
+
n,
|
|
511
|
+
s,
|
|
512
|
+
a,
|
|
513
|
+
i
|
|
514
|
+
]), D(() => () => d.destroy(), [d]), {
|
|
515
|
+
calculatedAnchorPoint: c,
|
|
516
|
+
targetElement: c ? document.querySelector(e) : null
|
|
459
517
|
};
|
|
460
518
|
}
|
|
461
|
-
function
|
|
462
|
-
const [e, t] =
|
|
519
|
+
function he() {
|
|
520
|
+
const [e, t] = I(!1), [o, n] = I(
|
|
463
521
|
null
|
|
464
|
-
),
|
|
465
|
-
n(
|
|
466
|
-
}, []), a =
|
|
522
|
+
), s = T((c) => {
|
|
523
|
+
n(c);
|
|
524
|
+
}, []), a = T(
|
|
467
525
|
() => o?.togglePopover(),
|
|
468
526
|
[o]
|
|
469
|
-
), i =
|
|
527
|
+
), i = T(
|
|
470
528
|
() => o?.showPopover(),
|
|
471
529
|
[o]
|
|
472
|
-
),
|
|
530
|
+
), r = T(
|
|
473
531
|
() => o?.hidePopover(),
|
|
474
532
|
[o]
|
|
475
533
|
);
|
|
476
|
-
return
|
|
534
|
+
return D(() => {
|
|
477
535
|
if (!o) return;
|
|
478
|
-
const
|
|
479
|
-
t(
|
|
536
|
+
const c = (l) => {
|
|
537
|
+
t(l.newState === "open");
|
|
480
538
|
};
|
|
481
|
-
return o.addEventListener("toggle",
|
|
539
|
+
return o.addEventListener("toggle", c), () => o.removeEventListener("toggle", c);
|
|
482
540
|
}, [o]), {
|
|
483
541
|
isOpen: e,
|
|
484
542
|
popoverElement: o,
|
|
485
|
-
handlePopoverRef:
|
|
543
|
+
handlePopoverRef: s,
|
|
486
544
|
togglePopover: a,
|
|
487
545
|
showPopover: i,
|
|
488
|
-
hidePopover:
|
|
546
|
+
hidePopover: r
|
|
489
547
|
};
|
|
490
548
|
}
|
|
491
|
-
function
|
|
492
|
-
return e ?
|
|
549
|
+
function fe(e, t) {
|
|
550
|
+
return e ? j(e) ? q(e, t) : /* @__PURE__ */ g(
|
|
493
551
|
e,
|
|
494
552
|
{
|
|
495
553
|
beacon: t.beacon,
|
|
496
|
-
style: t.
|
|
497
|
-
|
|
554
|
+
style: t.calculatedAnchorPoint,
|
|
555
|
+
anchorPoint: t.anchorPoint,
|
|
498
556
|
isOpen: t.isOpen,
|
|
499
557
|
onClick: t.togglePopover
|
|
500
558
|
}
|
|
501
559
|
) : null;
|
|
502
560
|
}
|
|
503
|
-
function
|
|
504
|
-
|
|
505
|
-
|
|
561
|
+
function ve(e, t) {
|
|
562
|
+
return j(e) ? q(e, {
|
|
563
|
+
beacon: t.beacon,
|
|
564
|
+
anchorPoint: t.anchorPoint,
|
|
565
|
+
onDismiss: t.handleDismiss,
|
|
566
|
+
onClose: t.hidePopover
|
|
567
|
+
}) : /* @__PURE__ */ g(
|
|
506
568
|
e,
|
|
507
569
|
{
|
|
508
570
|
beacon: t.beacon,
|
|
509
|
-
|
|
571
|
+
anchorPoint: t.anchorPoint,
|
|
510
572
|
onDismiss: t.handleDismiss,
|
|
511
573
|
onClose: t.hidePopover
|
|
512
574
|
}
|
|
513
|
-
)
|
|
514
|
-
// @ts-expect-error - cloneElement ref typing doesn't handle callback refs properly
|
|
515
|
-
ref: t.handlePopoverRef,
|
|
516
|
-
id: t.popoverId,
|
|
517
|
-
popover: "auto"
|
|
518
|
-
});
|
|
575
|
+
);
|
|
519
576
|
}
|
|
520
577
|
function ye(e, t) {
|
|
521
|
-
const o = e.trigger?.
|
|
578
|
+
const o = e.trigger?.anchorPoint || t.trigger?.anchorPoint || ne, n = e.trigger?.zIndex || t.trigger?.zIndex || 9999, s = e.trigger?.offset, a = e.trigger?.delay ?? t.trigger?.delay, i = e.trigger?.positioningStrategy ?? t.trigger?.positioningStrategy, r = e.popover?.anchorPoint || t.popover?.anchorPoint || o, c = e.popover?.offset || t.popover?.offset || { x: 0, y: 0 };
|
|
522
579
|
return {
|
|
523
|
-
|
|
580
|
+
anchorPoint: o,
|
|
524
581
|
zIndex: n,
|
|
525
|
-
offset:
|
|
582
|
+
offset: s,
|
|
526
583
|
delay: a,
|
|
527
|
-
|
|
528
|
-
|
|
584
|
+
positioningStrategy: i,
|
|
585
|
+
popoverAnchorPoint: r,
|
|
586
|
+
popoverOffset: c
|
|
529
587
|
};
|
|
530
588
|
}
|
|
531
|
-
function
|
|
589
|
+
function be({
|
|
532
590
|
beacon: e,
|
|
533
591
|
config: t,
|
|
534
592
|
store: o,
|
|
535
593
|
onDismiss: n,
|
|
536
|
-
debug:
|
|
594
|
+
debug: s
|
|
537
595
|
}) {
|
|
538
|
-
const a = te(), [i,
|
|
596
|
+
const a = te(), [i, r] = I(!1), {
|
|
597
|
+
anchorPoint: c,
|
|
598
|
+
zIndex: l,
|
|
599
|
+
offset: d,
|
|
600
|
+
delay: p,
|
|
601
|
+
positioningStrategy: u,
|
|
602
|
+
popoverAnchorPoint: f,
|
|
603
|
+
popoverOffset: w
|
|
604
|
+
} = ye(e, t), { calculatedAnchorPoint: v, targetElement: y } = me({
|
|
539
605
|
targetSelector: e.selector,
|
|
540
|
-
|
|
606
|
+
anchorPoint: c,
|
|
541
607
|
offset: d,
|
|
542
|
-
zIndex:
|
|
543
|
-
delay:
|
|
608
|
+
zIndex: l,
|
|
609
|
+
delay: p,
|
|
610
|
+
positioningStrategy: u,
|
|
544
611
|
enabled: !0,
|
|
545
|
-
debug:
|
|
612
|
+
debug: s
|
|
546
613
|
}), {
|
|
547
|
-
isOpen:
|
|
548
|
-
popoverElement:
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
z
|
|
614
|
+
isOpen: x,
|
|
615
|
+
popoverElement: k,
|
|
616
|
+
togglePopover: C,
|
|
617
|
+
showPopover: R,
|
|
618
|
+
hidePopover: O
|
|
619
|
+
} = he(), {
|
|
620
|
+
triggerAnimation: Y,
|
|
621
|
+
triggerDismissAnimation: E,
|
|
622
|
+
popoverOpenAnimation: H,
|
|
623
|
+
popoverCloseAnimation: F
|
|
624
|
+
} = ge(e, t), M = async () => {
|
|
625
|
+
r(!0), k?.hidePopover();
|
|
626
|
+
const Q = le(
|
|
627
|
+
E,
|
|
628
|
+
F
|
|
563
629
|
);
|
|
564
|
-
await
|
|
565
|
-
},
|
|
630
|
+
await de(Q), await Promise.resolve(o.dismiss(e.id)), n();
|
|
631
|
+
}, J = {
|
|
566
632
|
beaconId: e.id,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
popoverOffset:
|
|
570
|
-
|
|
571
|
-
isOpen:
|
|
633
|
+
anchorPoint: c,
|
|
634
|
+
popoverAnchorPoint: f,
|
|
635
|
+
popoverOffset: w,
|
|
636
|
+
calculatedAnchorPoint: v,
|
|
637
|
+
isOpen: x,
|
|
572
638
|
isDismissing: i,
|
|
573
|
-
toggle:
|
|
574
|
-
open:
|
|
575
|
-
close:
|
|
576
|
-
dismiss:
|
|
577
|
-
triggerAnimation:
|
|
578
|
-
triggerDismissAnimation:
|
|
579
|
-
popoverOpenAnimation:
|
|
580
|
-
popoverCloseAnimation:
|
|
639
|
+
toggle: C,
|
|
640
|
+
open: R,
|
|
641
|
+
close: O,
|
|
642
|
+
dismiss: M,
|
|
643
|
+
triggerAnimation: Y,
|
|
644
|
+
triggerDismissAnimation: E,
|
|
645
|
+
popoverOpenAnimation: H,
|
|
646
|
+
popoverCloseAnimation: F,
|
|
581
647
|
popoverId: a
|
|
582
|
-
},
|
|
583
|
-
return !
|
|
584
|
-
`[Repere] ${e.id} waiting for target element:
|
|
585
|
-
), null) :
|
|
586
|
-
|
|
648
|
+
}, K = e.trigger?.component || t.trigger?.component, U = e.popover.component || t.popover?.component;
|
|
649
|
+
return !v || !y ? (s && console.warn(
|
|
650
|
+
`[Repere] ${e.id} waiting for target element: anchor=${!!v}, element=${!!y}`
|
|
651
|
+
), null) : U ? /* @__PURE__ */ W(_.Provider, { value: J, children: [
|
|
652
|
+
fe(K, {
|
|
587
653
|
beacon: e,
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
isOpen:
|
|
591
|
-
togglePopover:
|
|
654
|
+
calculatedAnchorPoint: v,
|
|
655
|
+
anchorPoint: c,
|
|
656
|
+
isOpen: x,
|
|
657
|
+
togglePopover: C
|
|
592
658
|
}),
|
|
593
|
-
|
|
659
|
+
ve(U, {
|
|
594
660
|
beacon: e,
|
|
595
|
-
|
|
596
|
-
handleDismiss:
|
|
597
|
-
hidePopover:
|
|
598
|
-
handlePopoverRef: y,
|
|
599
|
-
popoverId: a
|
|
661
|
+
anchorPoint: c,
|
|
662
|
+
handleDismiss: M,
|
|
663
|
+
hidePopover: O
|
|
600
664
|
})
|
|
601
|
-
] }) : (
|
|
665
|
+
] }) : (s && console.warn(
|
|
602
666
|
"[Repere] No popover component provided for beacon:",
|
|
603
667
|
e.id
|
|
604
668
|
), null);
|
|
605
669
|
}
|
|
606
|
-
function
|
|
670
|
+
function Se({
|
|
607
671
|
config: e,
|
|
608
672
|
currentPath: t,
|
|
609
673
|
enabled: o = !0,
|
|
610
674
|
debug: n = !1
|
|
611
675
|
}) {
|
|
612
|
-
const
|
|
676
|
+
const s = b(
|
|
613
677
|
() => e.store || new ie(),
|
|
614
678
|
[e.store]
|
|
615
|
-
), a =
|
|
616
|
-
() => new
|
|
617
|
-
[
|
|
618
|
-
), [i,
|
|
679
|
+
), a = b(
|
|
680
|
+
() => new ue(s, { debug: n }),
|
|
681
|
+
[s, n]
|
|
682
|
+
), [i, r] = I([]), [c, l] = I(
|
|
619
683
|
/* @__PURE__ */ new Set()
|
|
620
684
|
);
|
|
621
|
-
|
|
685
|
+
D(() => {
|
|
622
686
|
if (!o) {
|
|
623
|
-
|
|
687
|
+
r([]), l(/* @__PURE__ */ new Set());
|
|
624
688
|
return;
|
|
625
689
|
}
|
|
626
690
|
(async () => {
|
|
627
|
-
const
|
|
691
|
+
const f = await a.getActiveBeacons(
|
|
628
692
|
e.pages,
|
|
629
693
|
t
|
|
630
694
|
);
|
|
631
|
-
|
|
695
|
+
r(f);
|
|
632
696
|
})();
|
|
633
697
|
}, [a, e.pages, t, o]);
|
|
634
|
-
const d = (
|
|
635
|
-
|
|
636
|
-
},
|
|
637
|
-
(
|
|
698
|
+
const d = (u) => {
|
|
699
|
+
l((f) => /* @__PURE__ */ new Set([...f, u]));
|
|
700
|
+
}, p = i.filter(
|
|
701
|
+
(u) => !c.has(u.id)
|
|
638
702
|
);
|
|
639
|
-
return
|
|
640
|
-
|
|
641
|
-
|
|
703
|
+
return p.length === 0 ? null : oe(
|
|
704
|
+
p.map((u) => /* @__PURE__ */ g(
|
|
705
|
+
be,
|
|
642
706
|
{
|
|
643
|
-
beacon:
|
|
707
|
+
beacon: u,
|
|
644
708
|
config: e,
|
|
645
|
-
store:
|
|
709
|
+
store: s,
|
|
646
710
|
debug: n,
|
|
647
|
-
onDismiss: () => d(
|
|
711
|
+
onDismiss: () => d(u.id)
|
|
648
712
|
},
|
|
649
|
-
|
|
713
|
+
u.id
|
|
650
714
|
)),
|
|
651
715
|
document.body
|
|
652
716
|
);
|
|
653
717
|
}
|
|
654
|
-
const
|
|
655
|
-
({
|
|
656
|
-
children:
|
|
657
|
-
style:
|
|
658
|
-
popover:
|
|
659
|
-
disableAnimation:
|
|
718
|
+
const xe = A(
|
|
719
|
+
function({
|
|
720
|
+
children: t,
|
|
721
|
+
style: o,
|
|
722
|
+
popover: n = "auto",
|
|
723
|
+
disableAnimation: s,
|
|
660
724
|
// Destructure and discard internal props so they don't spread to DOM
|
|
661
|
-
beacon:
|
|
662
|
-
|
|
663
|
-
onDismiss:
|
|
664
|
-
onClose:
|
|
725
|
+
beacon: a,
|
|
726
|
+
anchorPoint: i,
|
|
727
|
+
onDismiss: r,
|
|
728
|
+
onClose: c,
|
|
665
729
|
...l
|
|
666
|
-
},
|
|
730
|
+
}, d) {
|
|
667
731
|
const {
|
|
668
|
-
beaconId:
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
732
|
+
beaconId: p,
|
|
733
|
+
popoverId: u,
|
|
734
|
+
popoverOpenAnimation: f,
|
|
735
|
+
popoverCloseAnimation: w,
|
|
736
|
+
popoverAnchorPoint: v,
|
|
737
|
+
popoverOffset: y
|
|
738
|
+
} = $(), x = T(
|
|
739
|
+
(R) => {
|
|
740
|
+
typeof d == "function" ? d(R) : d && (d.current = R);
|
|
676
741
|
},
|
|
677
|
-
[
|
|
678
|
-
),
|
|
679
|
-
positionAnchor:
|
|
680
|
-
...
|
|
681
|
-
marginLeft:
|
|
682
|
-
marginTop:
|
|
742
|
+
[d]
|
|
743
|
+
), C = {
|
|
744
|
+
positionAnchor: p ? `--repere-trigger-${p}` : void 0,
|
|
745
|
+
...y && {
|
|
746
|
+
marginLeft: y.x || 0,
|
|
747
|
+
marginTop: y.y || 0
|
|
683
748
|
},
|
|
684
|
-
...
|
|
685
|
-
...
|
|
749
|
+
...ce(f, w),
|
|
750
|
+
...o
|
|
686
751
|
};
|
|
687
752
|
return /* @__PURE__ */ g(
|
|
688
753
|
"div",
|
|
689
754
|
{
|
|
690
|
-
ref:
|
|
755
|
+
ref: x,
|
|
756
|
+
id: u,
|
|
691
757
|
role: "dialog",
|
|
692
|
-
"aria-labelledby": `repere-popover-${
|
|
758
|
+
"aria-labelledby": `repere-popover-${p}`,
|
|
693
759
|
"data-repere-popover": "",
|
|
694
|
-
"data-
|
|
695
|
-
popover:
|
|
760
|
+
"data-anchor-point": v,
|
|
761
|
+
popover: n,
|
|
696
762
|
...l,
|
|
697
|
-
style:
|
|
698
|
-
children:
|
|
763
|
+
style: C,
|
|
764
|
+
children: t
|
|
699
765
|
}
|
|
700
766
|
);
|
|
701
767
|
}
|
|
702
|
-
)
|
|
703
|
-
X.displayName = "ReperePopover";
|
|
704
|
-
const be = x(
|
|
768
|
+
), Pe = A(
|
|
705
769
|
({
|
|
706
770
|
children: e = "Got it",
|
|
707
771
|
onClick: t,
|
|
708
772
|
as: o,
|
|
709
773
|
...n
|
|
710
|
-
},
|
|
711
|
-
const a =
|
|
712
|
-
}),
|
|
774
|
+
}, s) => {
|
|
775
|
+
const a = $(), i = a?.dismiss || (() => {
|
|
776
|
+
}), r = a?.popoverId;
|
|
713
777
|
return /* @__PURE__ */ g(
|
|
714
778
|
o || "button",
|
|
715
779
|
{
|
|
716
|
-
ref:
|
|
780
|
+
ref: s,
|
|
717
781
|
onClick: (d) => {
|
|
718
782
|
i(), t?.(d);
|
|
719
783
|
},
|
|
720
|
-
popovertarget:
|
|
784
|
+
popovertarget: r,
|
|
721
785
|
popovertargetaction: "hide",
|
|
722
786
|
...n,
|
|
723
787
|
children: e
|
|
724
788
|
}
|
|
725
789
|
);
|
|
726
790
|
}
|
|
727
|
-
),
|
|
791
|
+
), Ae = Object.assign(Pe, {
|
|
728
792
|
displayName: "ReperePopover.AcknowledgeButton"
|
|
729
|
-
}),
|
|
730
|
-
const
|
|
793
|
+
}), G = A(({ children: e = "×", ...t }, o) => {
|
|
794
|
+
const s = $()?.popoverId;
|
|
731
795
|
return /* @__PURE__ */ g(
|
|
732
796
|
"button",
|
|
733
797
|
{
|
|
734
798
|
ref: o,
|
|
735
|
-
popovertarget:
|
|
799
|
+
popovertarget: s,
|
|
736
800
|
popovertargetaction: "hide",
|
|
737
801
|
"aria-label": "Close",
|
|
738
802
|
...t,
|
|
@@ -740,99 +804,100 @@ const be = x(
|
|
|
740
804
|
}
|
|
741
805
|
);
|
|
742
806
|
});
|
|
743
|
-
|
|
744
|
-
const
|
|
807
|
+
G.displayName = "ReperePopover.CloseButton";
|
|
808
|
+
const V = A(
|
|
745
809
|
({ children: e, ...t }, o) => /* @__PURE__ */ g("div", { ref: o, ...t, children: e })
|
|
746
810
|
);
|
|
747
|
-
|
|
748
|
-
const
|
|
811
|
+
V.displayName = "ReperePopover.Content";
|
|
812
|
+
const X = A(
|
|
749
813
|
({ children: e, ...t }, o) => /* @__PURE__ */ g("div", { ref: o, ...t, children: e })
|
|
750
814
|
);
|
|
751
|
-
|
|
752
|
-
const
|
|
815
|
+
X.displayName = "ReperePopover.Footer";
|
|
816
|
+
const we = A(
|
|
753
817
|
({ children: e, as: t, ...o }, n) => {
|
|
754
|
-
const a =
|
|
818
|
+
const a = $()?.beaconId || "unknown";
|
|
755
819
|
return /* @__PURE__ */ g(t || "h3", { ref: n, id: `repere-popover-${a}`, ...o, children: e });
|
|
756
820
|
}
|
|
757
|
-
), ke = Object.assign(
|
|
821
|
+
), ke = Object.assign(we, {
|
|
758
822
|
displayName: "ReperePopover.Title"
|
|
759
|
-
}), Be = Object.assign(
|
|
823
|
+
}), Be = Object.assign(xe, {
|
|
760
824
|
Title: ke,
|
|
761
|
-
Content:
|
|
762
|
-
Footer:
|
|
763
|
-
AcknowledgeButton:
|
|
764
|
-
CloseButton:
|
|
765
|
-
}), Ce =
|
|
825
|
+
Content: V,
|
|
826
|
+
Footer: X,
|
|
827
|
+
AcknowledgeButton: Ae,
|
|
828
|
+
CloseButton: G
|
|
829
|
+
}), Ce = A(
|
|
766
830
|
({
|
|
767
831
|
children: e,
|
|
768
832
|
as: t,
|
|
769
833
|
style: o,
|
|
770
834
|
disableAnimation: n,
|
|
771
|
-
...
|
|
835
|
+
...s
|
|
772
836
|
}, a) => {
|
|
773
837
|
const {
|
|
774
|
-
|
|
775
|
-
beaconId:
|
|
776
|
-
triggerAnimation:
|
|
777
|
-
triggerDismissAnimation:
|
|
838
|
+
calculatedAnchorPoint: i,
|
|
839
|
+
beaconId: r,
|
|
840
|
+
triggerAnimation: c,
|
|
841
|
+
triggerDismissAnimation: l,
|
|
778
842
|
isDismissing: d,
|
|
779
|
-
popoverId:
|
|
780
|
-
} =
|
|
843
|
+
popoverId: p
|
|
844
|
+
} = $(), u = t || "button", f = b(() => !t || t === "button" ? N.button : N.create(u), [t, u]);
|
|
781
845
|
if (!i) return null;
|
|
782
|
-
const
|
|
846
|
+
const w = {
|
|
783
847
|
position: i.position,
|
|
784
848
|
top: i.top,
|
|
785
849
|
left: i.left,
|
|
786
850
|
zIndex: i.zIndex,
|
|
787
851
|
pointerEvents: "auto",
|
|
788
852
|
cursor: "pointer",
|
|
789
|
-
anchorName: `--repere-trigger-${
|
|
790
|
-
},
|
|
853
|
+
anchorName: `--repere-trigger-${r}`
|
|
854
|
+
}, v = o ? { ...w, ...o } : w, y = !n && (c || l), x = {
|
|
791
855
|
ref: a,
|
|
792
|
-
popovertarget:
|
|
793
|
-
"aria-label": `Beacon trigger for ${
|
|
856
|
+
popovertarget: p,
|
|
857
|
+
"aria-label": `Beacon trigger for ${r}`,
|
|
794
858
|
"data-repere-trigger": "",
|
|
795
|
-
...
|
|
859
|
+
...s
|
|
796
860
|
};
|
|
797
|
-
if (
|
|
798
|
-
const
|
|
799
|
-
if (!
|
|
800
|
-
const
|
|
861
|
+
if (y) {
|
|
862
|
+
const k = d && l ? l : c;
|
|
863
|
+
if (!k) return null;
|
|
864
|
+
const C = ae(
|
|
801
865
|
i.translate,
|
|
802
|
-
|
|
866
|
+
k.variants
|
|
803
867
|
);
|
|
804
868
|
return /* @__PURE__ */ g(
|
|
805
|
-
|
|
869
|
+
f,
|
|
806
870
|
{
|
|
807
871
|
initial: "initial",
|
|
808
872
|
animate: d ? "exit" : "animate",
|
|
809
|
-
variants:
|
|
810
|
-
transition:
|
|
811
|
-
...
|
|
812
|
-
style:
|
|
873
|
+
variants: C,
|
|
874
|
+
transition: k.transition,
|
|
875
|
+
...x,
|
|
876
|
+
style: v,
|
|
813
877
|
children: e
|
|
814
878
|
}
|
|
815
879
|
);
|
|
816
880
|
}
|
|
817
881
|
return /* @__PURE__ */ g(
|
|
818
|
-
|
|
882
|
+
u,
|
|
819
883
|
{
|
|
820
|
-
...
|
|
884
|
+
...x,
|
|
821
885
|
style: {
|
|
822
|
-
...
|
|
886
|
+
...v,
|
|
823
887
|
translate: `${i.translate.x} ${i.translate.y}`
|
|
824
888
|
},
|
|
825
889
|
children: e
|
|
826
890
|
}
|
|
827
891
|
);
|
|
828
892
|
}
|
|
829
|
-
),
|
|
893
|
+
), De = Object.assign(Ce, {
|
|
830
894
|
displayName: "RepereTrigger"
|
|
831
895
|
});
|
|
832
896
|
export {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
897
|
+
h as AnchorPoint,
|
|
898
|
+
m as Animation,
|
|
899
|
+
Se as Beacons,
|
|
900
|
+
P as PositioningStrategy,
|
|
836
901
|
Be as ReperePopover,
|
|
837
|
-
|
|
902
|
+
De as RepereTrigger
|
|
838
903
|
};
|