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