@repere/core 0.0.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/constants/animations.d.ts +8 -0
- package/dist/constants/animations.d.ts.map +1 -0
- package/dist/constants/beacon.d.ts +3 -0
- package/dist/constants/beacon.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +352 -0
- package/dist/store/memory-store.d.ts +10 -0
- package/dist/store/memory-store.d.ts.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/types/animations.d.ts +40 -0
- package/dist/types/animations.d.ts.map +1 -0
- package/dist/types/base.d.ts +33 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/types/beacon.d.ts +36 -0
- package/dist/types/beacon.d.ts.map +1 -0
- package/dist/types/config.d.ts +19 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/position.d.ts +11 -0
- package/dist/types/position.d.ts.map +1 -0
- package/dist/types/store.d.ts +12 -0
- package/dist/types/store.d.ts.map +1 -0
- package/dist/utils/BeaconManager.d.ts +30 -0
- package/dist/utils/BeaconManager.d.ts.map +1 -0
- package/dist/utils/PositionTracker.d.ts +32 -0
- package/dist/utils/PositionTracker.d.ts.map +1 -0
- package/dist/utils/animations.d.ts +37 -0
- package/dist/utils/animations.d.ts.map +1 -0
- package/dist/utils/path-matching.d.ts +6 -0
- package/dist/utils/path-matching.d.ts.map +1 -0
- package/dist/utils/positioning.d.ts +15 -0
- package/dist/utils/positioning.d.ts.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Animation } from '../types/animations';
|
|
2
|
+
export type AnimationProps = {
|
|
3
|
+
initial: Record<string, number | string>;
|
|
4
|
+
animate: Record<string, number | string>;
|
|
5
|
+
exit: Record<string, number | string>;
|
|
6
|
+
};
|
|
7
|
+
export declare const ANIMATION_VARIANTS: Record<Animation, AnimationProps>;
|
|
8
|
+
//# sourceMappingURL=animations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../src/constants/animations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,SAAS,EAAE,cAAc,CA8ChE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beacon.d.ts","sourceRoot":"","sources":["../../src/constants/beacon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,eAAO,MAAM,gBAAgB,EAAE,QAA4B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { DEFAULT_POSITION } from './constants/beacon';
|
|
2
|
+
export { MemoryStore } from './store/memory-store';
|
|
3
|
+
export { Animation, type ResolvedAnimationConfig } from './types/animations';
|
|
4
|
+
export type { BasePopoverProps, BaseTriggerProps } from './types/base';
|
|
5
|
+
export type { Beacon, CalculatedBeaconPosition, Offset, PopoverConfig, TriggerConfig, } from './types/beacon';
|
|
6
|
+
export type { Page, RepereConfig } from './types/config';
|
|
7
|
+
export { Position } from './types/position';
|
|
8
|
+
export type { BeaconStore } from './types/store';
|
|
9
|
+
export { calculateDismissDuration, combineTranslateWithAnimation, getAnimationConfig, getPopoverAnimationStyles, mergeAnimationConfigs, waitForAnimations, } from './utils/animations';
|
|
10
|
+
export { BeaconManager } from './utils/BeaconManager';
|
|
11
|
+
export { PositionTracker } from './utils/PositionTracker';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEvE,YAAY,EACV,MAAM,EACN,wBAAwB,EACxB,MAAM,EACN,aAAa,EACb,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var p = (e, i, t) => i in e ? h(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
|
|
3
|
+
var c = (e, i, t) => p(e, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
+
var d = /* @__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))(d || {});
|
|
5
|
+
const x = d.TopRight;
|
|
6
|
+
class m {
|
|
7
|
+
constructor() {
|
|
8
|
+
c(this, "state", /* @__PURE__ */ new Map());
|
|
9
|
+
}
|
|
10
|
+
isDismissed(i) {
|
|
11
|
+
const t = this.state.get(i);
|
|
12
|
+
return (t == null ? void 0 : t.isDismissed) ?? !1;
|
|
13
|
+
}
|
|
14
|
+
dismiss(i) {
|
|
15
|
+
this.state.set(i, {
|
|
16
|
+
id: i,
|
|
17
|
+
isDismissed: !0
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
reset(i) {
|
|
21
|
+
this.state.delete(i);
|
|
22
|
+
}
|
|
23
|
+
resetAll() {
|
|
24
|
+
this.state.clear();
|
|
25
|
+
}
|
|
26
|
+
getAll() {
|
|
27
|
+
return Array.from(this.state.values());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
var u = /* @__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))(u || {});
|
|
31
|
+
const g = {
|
|
32
|
+
[u.SlideDown]: {
|
|
33
|
+
initial: { y: -20, opacity: 0 },
|
|
34
|
+
animate: { y: 0, opacity: 1 },
|
|
35
|
+
exit: { y: -20, opacity: 0 }
|
|
36
|
+
},
|
|
37
|
+
[u.SlideUp]: {
|
|
38
|
+
initial: { y: 20, opacity: 0 },
|
|
39
|
+
animate: { y: 0, opacity: 1 },
|
|
40
|
+
exit: { y: 20, opacity: 0 }
|
|
41
|
+
},
|
|
42
|
+
[u.SlideLeft]: {
|
|
43
|
+
initial: { x: 20, opacity: 0 },
|
|
44
|
+
animate: { x: 0, opacity: 1 },
|
|
45
|
+
exit: { x: 20, opacity: 0 }
|
|
46
|
+
},
|
|
47
|
+
[u.SlideRight]: {
|
|
48
|
+
initial: { x: -20, opacity: 0 },
|
|
49
|
+
animate: { x: 0, opacity: 1 },
|
|
50
|
+
exit: { x: -20, opacity: 0 }
|
|
51
|
+
},
|
|
52
|
+
[u.Fade]: {
|
|
53
|
+
initial: { opacity: 0 },
|
|
54
|
+
animate: { opacity: 1 },
|
|
55
|
+
exit: { opacity: 0 }
|
|
56
|
+
},
|
|
57
|
+
[u.Shrink]: {
|
|
58
|
+
initial: { scale: 1.1, opacity: 0 },
|
|
59
|
+
animate: { scale: 1, opacity: 1 },
|
|
60
|
+
exit: { scale: 0.9, opacity: 0 }
|
|
61
|
+
},
|
|
62
|
+
[u.Grow]: {
|
|
63
|
+
initial: { scale: 0.9, opacity: 0 },
|
|
64
|
+
animate: { scale: 1, opacity: 1 },
|
|
65
|
+
exit: { scale: 1.1, opacity: 0 }
|
|
66
|
+
},
|
|
67
|
+
[u.Scale]: {
|
|
68
|
+
initial: { scale: 0, opacity: 0 },
|
|
69
|
+
animate: { scale: 1, opacity: 1 },
|
|
70
|
+
exit: { scale: 0, opacity: 0 }
|
|
71
|
+
},
|
|
72
|
+
[u.None]: {
|
|
73
|
+
initial: {},
|
|
74
|
+
animate: {},
|
|
75
|
+
exit: {}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
function f(e) {
|
|
79
|
+
return e ? typeof e == "string" ? { variant: e } : e : null;
|
|
80
|
+
}
|
|
81
|
+
function v(e, i) {
|
|
82
|
+
const t = f(e), s = f(i);
|
|
83
|
+
return !t && !s ? null : t ? s ? {
|
|
84
|
+
variant: s.variant ?? t.variant,
|
|
85
|
+
duration: s.duration ?? t.duration,
|
|
86
|
+
delay: s.delay ?? t.delay,
|
|
87
|
+
ease: s.ease ?? t.ease
|
|
88
|
+
} : t : s;
|
|
89
|
+
}
|
|
90
|
+
function k(e) {
|
|
91
|
+
const i = f(e);
|
|
92
|
+
if (!i) return null;
|
|
93
|
+
const t = g[i.variant];
|
|
94
|
+
return t ? {
|
|
95
|
+
variants: t,
|
|
96
|
+
transition: {
|
|
97
|
+
duration: (i.duration || 300) / 1e3,
|
|
98
|
+
// Convert ms to seconds
|
|
99
|
+
delay: (i.delay || 0) / 1e3,
|
|
100
|
+
ease: i.ease || [0.4, 0, 0.2, 1]
|
|
101
|
+
// cubic-bezier
|
|
102
|
+
}
|
|
103
|
+
} : (console.warn(`[Repere] Unknown animation variant: ${i.variant}`), null);
|
|
104
|
+
}
|
|
105
|
+
function L(e, i) {
|
|
106
|
+
const t = (o) => {
|
|
107
|
+
const a = o.match(/(-?\d+)%/);
|
|
108
|
+
return a ? parseFloat(a[1]) : 0;
|
|
109
|
+
}, s = t(e.x), r = t(e.y), n = (o = 0) => r === 0 && o === 0 ? `translate(${s}%, 0)` : o === 0 ? `translate(${s}%, ${r}%)` : `translate(${s}%, calc(${r}% + ${o}px))`;
|
|
110
|
+
return {
|
|
111
|
+
initial: {
|
|
112
|
+
...i.initial,
|
|
113
|
+
transform: n(i.initial.y || 0)
|
|
114
|
+
},
|
|
115
|
+
animate: {
|
|
116
|
+
...i.animate,
|
|
117
|
+
transform: n(i.animate.y || 0)
|
|
118
|
+
},
|
|
119
|
+
exit: {
|
|
120
|
+
...i.exit,
|
|
121
|
+
transform: n(i.exit.y || 0)
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function z(e, i) {
|
|
126
|
+
if (!e && !i) return {};
|
|
127
|
+
const t = e == null ? void 0 : e.variants, s = e == null ? void 0 : e.transition, r = i == null ? void 0 : i.variants, n = i == null ? void 0 : i.transition, o = (n == null ? void 0 : n.ease) ?? (s == null ? void 0 : s.ease) ?? [0.4, 0, 0.2, 1], a = Array.isArray(o) ? `cubic-bezier(${o.join(", ")})` : o;
|
|
128
|
+
return {
|
|
129
|
+
// Initial state (when opening starts) - from onOpen animation
|
|
130
|
+
"--repere-initial-opacity": (t == null ? void 0 : t.initial.opacity) ?? 0,
|
|
131
|
+
"--repere-initial-x": `${(t == null ? void 0 : t.initial.x) ?? 0}px`,
|
|
132
|
+
"--repere-initial-y": `${(t == null ? void 0 : t.initial.y) ?? 0}px`,
|
|
133
|
+
"--repere-initial-scale": (t == null ? void 0 : t.initial.scale) ?? 1,
|
|
134
|
+
// Animate state (fully open) - from onOpen animation
|
|
135
|
+
"--repere-animate-opacity": (t == null ? void 0 : t.animate.opacity) ?? 1,
|
|
136
|
+
"--repere-animate-x": `${(t == null ? void 0 : t.animate.x) ?? 0}px`,
|
|
137
|
+
"--repere-animate-y": `${(t == null ? void 0 : t.animate.y) ?? 0}px`,
|
|
138
|
+
"--repere-animate-scale": (t == null ? void 0 : t.animate.scale) ?? 1,
|
|
139
|
+
// Exit state (when closing) - from onClose animation
|
|
140
|
+
"--repere-exit-opacity": (r == null ? void 0 : r.exit.opacity) ?? 0,
|
|
141
|
+
"--repere-exit-x": `${(r == null ? void 0 : r.exit.x) ?? 0}px`,
|
|
142
|
+
"--repere-exit-y": `${(r == null ? void 0 : r.exit.y) ?? 0}px`,
|
|
143
|
+
"--repere-exit-scale": (r == null ? void 0 : r.exit.scale) ?? 1,
|
|
144
|
+
// Transition timing
|
|
145
|
+
"--repere-transition-duration": `${(n == null ? void 0 : n.duration) ?? (s == null ? void 0 : s.duration) ?? 0.3}s`,
|
|
146
|
+
"--repere-transition-timing": a
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function $(e, i) {
|
|
150
|
+
const t = (e == null ? void 0 : e.transition.duration) ?? 0, s = (i == null ? void 0 : i.transition.duration) ?? 0;
|
|
151
|
+
return Math.max(t, s) * 1e3;
|
|
152
|
+
}
|
|
153
|
+
function B(e) {
|
|
154
|
+
return new Promise((i) => setTimeout(i, e));
|
|
155
|
+
}
|
|
156
|
+
function y(e, i) {
|
|
157
|
+
if (i instanceof RegExp)
|
|
158
|
+
return i.test(e);
|
|
159
|
+
if (i === e)
|
|
160
|
+
return !0;
|
|
161
|
+
if (i.includes("*")) {
|
|
162
|
+
const t = i.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
163
|
+
return new RegExp(`^${t}$`).test(e);
|
|
164
|
+
}
|
|
165
|
+
return !1;
|
|
166
|
+
}
|
|
167
|
+
class S {
|
|
168
|
+
constructor(i, t = {}) {
|
|
169
|
+
c(this, "store");
|
|
170
|
+
c(this, "debug");
|
|
171
|
+
this.store = i, this.debug = t.debug ?? !1;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Find all pages that match the current path
|
|
175
|
+
* This supports wildcards - e.g., path="*" will match all pages
|
|
176
|
+
*/
|
|
177
|
+
findMatchingPages(i, t) {
|
|
178
|
+
const s = i.filter((r) => typeof r.path == "function" ? r.path(t) : y(t, r.path));
|
|
179
|
+
return this.debug && console.log(
|
|
180
|
+
"[BeaconManager] Path:",
|
|
181
|
+
t,
|
|
182
|
+
"Matched pages:",
|
|
183
|
+
s.map((r) => r.id).join(", ") || "none"
|
|
184
|
+
), s;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get all active (non-dismissed) beacons for the current path
|
|
188
|
+
* Includes beacons from all matching pages (supports wildcards)
|
|
189
|
+
*/
|
|
190
|
+
async getActiveBeacons(i, t) {
|
|
191
|
+
const s = this.findMatchingPages(i, t);
|
|
192
|
+
if (s.length === 0)
|
|
193
|
+
return this.debug && console.log("[BeaconManager] No matching pages found"), [];
|
|
194
|
+
this.debug && console.log(
|
|
195
|
+
"[BeaconManager] Found",
|
|
196
|
+
s.length,
|
|
197
|
+
"matching page(s):",
|
|
198
|
+
s.map((a) => a.id).join(", ")
|
|
199
|
+
);
|
|
200
|
+
const r = [], n = /* @__PURE__ */ new Set();
|
|
201
|
+
for (const a of s)
|
|
202
|
+
for (const l of a.beacons) {
|
|
203
|
+
if (n.has(l.id)) {
|
|
204
|
+
this.debug && console.warn(
|
|
205
|
+
`[BeaconManager] Duplicate beacon ID "${l.id}" in page "${a.id}", skipping`
|
|
206
|
+
);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
n.add(l.id), r.push(l);
|
|
210
|
+
}
|
|
211
|
+
const o = [];
|
|
212
|
+
for (const a of r)
|
|
213
|
+
await Promise.resolve(
|
|
214
|
+
this.store.isDismissed(a.id)
|
|
215
|
+
) ? this.debug && console.log("[BeaconManager] Beacon", a.id, "is dismissed") : o.push(a);
|
|
216
|
+
return this.debug && console.log("[BeaconManager] Active beacons:", o.length), o;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get the store instance
|
|
220
|
+
*/
|
|
221
|
+
getStore() {
|
|
222
|
+
return this.store;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function w(e, i = d.TopRight, t = { x: 0, y: 0 }) {
|
|
226
|
+
const { x: s = 0, y: r = 0 } = t;
|
|
227
|
+
let n = 0, o = 0, a = "0", l = "0";
|
|
228
|
+
switch (i) {
|
|
229
|
+
case d.TopLeft:
|
|
230
|
+
n = e.top + window.scrollY, o = e.left + window.scrollX, a = "-50%", l = "-100%";
|
|
231
|
+
break;
|
|
232
|
+
case d.TopCenter:
|
|
233
|
+
n = e.top + window.scrollY, o = e.left + window.scrollX + e.width / 2, a = "-50%", l = "-100%";
|
|
234
|
+
break;
|
|
235
|
+
case d.TopRight:
|
|
236
|
+
n = e.top + window.scrollY, o = e.right + window.scrollX, a = "-50%", l = "-100%";
|
|
237
|
+
break;
|
|
238
|
+
case d.RightCenter:
|
|
239
|
+
n = e.top + window.scrollY + e.height / 2, o = e.right + window.scrollX, a = "0", l = "-50%";
|
|
240
|
+
break;
|
|
241
|
+
case d.BottomLeft:
|
|
242
|
+
n = e.bottom + window.scrollY, o = e.left + window.scrollX, a = "-50%", l = "0";
|
|
243
|
+
break;
|
|
244
|
+
case d.BottomCenter:
|
|
245
|
+
n = e.bottom + window.scrollY, o = e.left + window.scrollX + e.width / 2, a = "-50%", l = "0";
|
|
246
|
+
break;
|
|
247
|
+
case d.BottomRight:
|
|
248
|
+
n = e.bottom + window.scrollY, o = e.right + window.scrollX, a = "-50%", l = "0";
|
|
249
|
+
break;
|
|
250
|
+
case d.LeftCenter:
|
|
251
|
+
n = e.top + window.scrollY + e.height / 2, o = e.left + window.scrollX, a = "-100%", l = "-50%";
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
return n += r, o += s, {
|
|
255
|
+
top: n,
|
|
256
|
+
left: o,
|
|
257
|
+
translate: { x: a, y: l }
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
class M {
|
|
261
|
+
constructor(i = !1) {
|
|
262
|
+
c(this, "tracked", /* @__PURE__ */ new Map());
|
|
263
|
+
c(this, "scrollListener", null);
|
|
264
|
+
c(this, "resizeListener", null);
|
|
265
|
+
c(this, "resizeObserver", null);
|
|
266
|
+
c(this, "mutationObserver", null);
|
|
267
|
+
c(this, "debug", !1);
|
|
268
|
+
c(this, "updateAllPositions", () => {
|
|
269
|
+
for (const [i] of this.tracked)
|
|
270
|
+
this.updatePosition(i);
|
|
271
|
+
});
|
|
272
|
+
this.debug = i;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Subscribe to position updates for an element
|
|
276
|
+
*/
|
|
277
|
+
subscribe(i, t, s, r = {}) {
|
|
278
|
+
const n = i;
|
|
279
|
+
this.tracked.has(n) || this.tracked.set(n, {
|
|
280
|
+
selector: i,
|
|
281
|
+
position: t,
|
|
282
|
+
offset: r.offset,
|
|
283
|
+
zIndex: r.zIndex ?? 9999,
|
|
284
|
+
callbacks: /* @__PURE__ */ new Set(),
|
|
285
|
+
element: null
|
|
286
|
+
});
|
|
287
|
+
const o = this.tracked.get(n);
|
|
288
|
+
return o == null || o.callbacks.add(s), this.tracked.size === 1 && this.startListening(), this.updatePosition(n), () => {
|
|
289
|
+
const a = this.tracked.get(n);
|
|
290
|
+
a && (a.callbacks.delete(s), a.callbacks.size === 0 && (this.tracked.delete(n), this.tracked.size === 0 && this.stopListening()));
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
updatePosition(i) {
|
|
294
|
+
const t = this.tracked.get(i);
|
|
295
|
+
if (!t) return;
|
|
296
|
+
const s = document.querySelector(t.selector);
|
|
297
|
+
if (!s) {
|
|
298
|
+
this.debug && console.log(`[PositionTracker] Element not found: ${t.selector}`), t.element = null;
|
|
299
|
+
for (const a of t.callbacks)
|
|
300
|
+
a(null);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
t.element = s;
|
|
304
|
+
const r = s.getBoundingClientRect(), o = {
|
|
305
|
+
...w(
|
|
306
|
+
r,
|
|
307
|
+
t.position,
|
|
308
|
+
t.offset
|
|
309
|
+
),
|
|
310
|
+
position: "fixed",
|
|
311
|
+
zIndex: t.zIndex
|
|
312
|
+
};
|
|
313
|
+
this.debug && console.log(
|
|
314
|
+
`[PositionTracker] Updated position for ${t.selector}:`,
|
|
315
|
+
o
|
|
316
|
+
);
|
|
317
|
+
for (const a of t.callbacks)
|
|
318
|
+
a(o);
|
|
319
|
+
}
|
|
320
|
+
startListening() {
|
|
321
|
+
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(() => {
|
|
322
|
+
this.updateAllPositions();
|
|
323
|
+
}), this.mutationObserver.observe(document.body, {
|
|
324
|
+
childList: !0,
|
|
325
|
+
subtree: !0
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
stopListening() {
|
|
329
|
+
var i, t;
|
|
330
|
+
this.scrollListener && (window.removeEventListener("scroll", this.scrollListener, !0), this.scrollListener = null), this.resizeListener && (window.removeEventListener("resize", this.resizeListener), this.resizeListener = null), (i = this.resizeObserver) == null || i.disconnect(), this.resizeObserver = null, (t = this.mutationObserver) == null || t.disconnect(), this.mutationObserver = null;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Clean up all listeners and subscriptions
|
|
334
|
+
*/
|
|
335
|
+
destroy() {
|
|
336
|
+
this.stopListening(), this.tracked.clear();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
export {
|
|
340
|
+
u as Animation,
|
|
341
|
+
S as BeaconManager,
|
|
342
|
+
x as DEFAULT_POSITION,
|
|
343
|
+
m as MemoryStore,
|
|
344
|
+
d as Position,
|
|
345
|
+
M as PositionTracker,
|
|
346
|
+
$ as calculateDismissDuration,
|
|
347
|
+
L as combineTranslateWithAnimation,
|
|
348
|
+
k as getAnimationConfig,
|
|
349
|
+
z as getPopoverAnimationStyles,
|
|
350
|
+
v as mergeAnimationConfigs,
|
|
351
|
+
B as waitForAnimations
|
|
352
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BeaconState, BeaconStore } from '../types/store';
|
|
2
|
+
export declare class MemoryStore implements BeaconStore {
|
|
3
|
+
private state;
|
|
4
|
+
isDismissed(beaconId: string): boolean;
|
|
5
|
+
dismiss(beaconId: string): void;
|
|
6
|
+
reset(beaconId: string): void;
|
|
7
|
+
resetAll(): void;
|
|
8
|
+
getAll(): BeaconState[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=memory-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../src/store/memory-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/D,qBAAa,WAAY,YAAW,WAAW;IAC7C,OAAO,CAAC,KAAK,CAAuC;IAEpD,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKtC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAO/B,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI7B,QAAQ,IAAI,IAAI;IAIhB,MAAM,IAAI,WAAW,EAAE;CAGxB"}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[data-repere-popover]{position:absolute;position-anchor:var(--repere-anchor);inset:unset;margin:0;opacity:var(--repere-exit-opacity, 0);transform:translate(var(--repere-exit-x, 0)) translateY(var(--repere-exit-y, -20px)) scale(var(--repere-exit-scale, 1));transition-property:opacity,transform,overlay,display;transition-duration:var(--repere-transition-duration, .3s);transition-timing-function:var( --repere-transition-timing, cubic-bezier(.4, 0, .2, 1) );transition-behavior:allow-discrete}[data-repere-popover]:popover-open{opacity:var(--repere-animate-opacity, 1);transform:translate(var(--repere-animate-x, 0)) translateY(var(--repere-animate-y, 0)) scale(var(--repere-animate-scale, 1))}@starting-style{[data-repere-popover]:popover-open{opacity:var(--repere-initial-opacity, 0);transform:translate(var(--repere-initial-x, 0)) translateY(var(--repere-initial-y, -20px)) scale(var(--repere-initial-scale, 1))}}[data-repere-popover][data-position=bottom-left]{top:anchor(bottom);left:anchor(left);position-try-fallbacks:--bottom-right,--top-left,--top-right}[data-repere-popover][data-position=bottom-center]{top:anchor(bottom);left:anchor(center);translate:-50% 0;position-try-fallbacks:--bottom-left,--bottom-right,--top-center}[data-repere-popover][data-position=bottom-right]{top:anchor(bottom);right:anchor(right);position-try-fallbacks:--bottom-left,--top-right,--top-left}[data-repere-popover][data-position=top-left]{bottom:anchor(top);left:anchor(left);position-try-fallbacks:--top-right,--bottom-left,--bottom-right}[data-repere-popover][data-position=top-center]{bottom:anchor(top);left:anchor(center);translate:-50% 0;position-try-fallbacks:--top-left,--top-right,--bottom-center}[data-repere-popover][data-position=top-right]{bottom:anchor(top);right:anchor(right);position-try-fallbacks:--top-left,--bottom-right,--bottom-left}[data-repere-popover][data-position=left-center]:popover-open{top:anchor(center);right:anchor(left);translate:0 -50%;position-try-fallbacks:--right-center,--bottom-center,--top-center}[data-repere-popover][data-position=right-center]:popover-open{top:anchor(center);left:anchor(right);translate:0 -50%;position-try-fallbacks:--left-center,--bottom-center,--top-center}[data-repere-trigger]{anchor-name:var(--repere-anchor)}@position-try --bottom-left{top:anchor(bottom);left:anchor(left);right:auto;bottom:auto;translate:0 0}@position-try --bottom-right{top:anchor(bottom);right:anchor(right);left:auto;bottom:auto;translate:0 0}@position-try --bottom-center{top:anchor(bottom);left:anchor(center);right:auto;bottom:auto;translate:-50% 0}@position-try --top-left{bottom:anchor(top);left:anchor(left);right:auto;top:auto;translate:0 0}@position-try --top-right{bottom:anchor(top);right:anchor(right);left:auto;top:auto;translate:0 0}@position-try --top-center{bottom:anchor(top);left:anchor(center);right:auto;top:auto;translate:-50% 0}@position-try --left-center{top:anchor(center);right:anchor(left);left:auto;bottom:auto;translate:0 -50%}@position-try --right-center{top:anchor(center);left:anchor(right);right:auto;bottom:auto;translate:0 -50%}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare enum Animation {
|
|
2
|
+
Fade = "fade",
|
|
3
|
+
Scale = "scale",
|
|
4
|
+
Grow = "grow",
|
|
5
|
+
Shrink = "shrink",
|
|
6
|
+
SlideUp = "slide-up",
|
|
7
|
+
SlideDown = "slide-down",
|
|
8
|
+
SlideLeft = "slide-left",
|
|
9
|
+
SlideRight = "slide-right",
|
|
10
|
+
None = "none"
|
|
11
|
+
}
|
|
12
|
+
export interface AnimationConfig {
|
|
13
|
+
variant: Animation;
|
|
14
|
+
duration?: number;
|
|
15
|
+
delay?: number;
|
|
16
|
+
ease?: string | number[];
|
|
17
|
+
}
|
|
18
|
+
export interface AnimationVariants {
|
|
19
|
+
initial: Record<string, number | string>;
|
|
20
|
+
animate: Record<string, number | string>;
|
|
21
|
+
exit: Record<string, number | string>;
|
|
22
|
+
}
|
|
23
|
+
export interface AnimationTransition {
|
|
24
|
+
duration: number;
|
|
25
|
+
delay: number;
|
|
26
|
+
ease: string | number[];
|
|
27
|
+
}
|
|
28
|
+
export interface ResolvedAnimationConfig {
|
|
29
|
+
variants: AnimationVariants;
|
|
30
|
+
transition: AnimationTransition;
|
|
31
|
+
}
|
|
32
|
+
export interface TriggerAnimations {
|
|
33
|
+
onRender?: Animation | AnimationConfig;
|
|
34
|
+
onDismiss?: Animation | AnimationConfig;
|
|
35
|
+
}
|
|
36
|
+
export interface PopoverAnimations {
|
|
37
|
+
onOpen?: Animation | AnimationConfig;
|
|
38
|
+
onClose?: Animation | AnimationConfig;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=animations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../src/types/animations.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,aAAa;IACpB,SAAS,eAAe;IACxB,SAAS,eAAe;IACxB,UAAU,gBAAgB;IAC1B,IAAI,SAAS;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,UAAU,EAAE,mBAAmB,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,SAAS,GAAG,eAAe,CAAC;IACvC,SAAS,CAAC,EAAE,SAAS,GAAG,eAAe,CAAC;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,SAAS,GAAG,eAAe,CAAC;IACrC,OAAO,CAAC,EAAE,SAAS,GAAG,eAAe,CAAC;CACvC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CalculatedBeaconPosition } from './beacon';
|
|
2
|
+
import { Position } from './position';
|
|
3
|
+
/**
|
|
4
|
+
* Base props that trigger components receive (framework-agnostic)
|
|
5
|
+
*/
|
|
6
|
+
export interface BaseTriggerProps {
|
|
7
|
+
beaconId: string;
|
|
8
|
+
position: Position;
|
|
9
|
+
calculatedPosition: CalculatedBeaconPosition;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
isDismissing: boolean;
|
|
12
|
+
popoverId?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Base props that popover components receive (framework-agnostic)
|
|
16
|
+
*/
|
|
17
|
+
export interface BasePopoverProps {
|
|
18
|
+
beaconId: string;
|
|
19
|
+
position: Position;
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
isDismissing?: boolean;
|
|
22
|
+
popoverId?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Actions available to components
|
|
26
|
+
*/
|
|
27
|
+
export interface BeaconActions {
|
|
28
|
+
toggle: () => void;
|
|
29
|
+
open: () => void;
|
|
30
|
+
close: () => void;
|
|
31
|
+
dismiss: () => void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/types/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,kBAAkB,EAAE,wBAAwB,CAAC;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PopoverAnimations, TriggerAnimations } from './animations';
|
|
2
|
+
import { Position } from './position';
|
|
3
|
+
export interface Offset {
|
|
4
|
+
x?: number;
|
|
5
|
+
y?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TriggerConfig<TNode = unknown> {
|
|
8
|
+
position?: Position;
|
|
9
|
+
offset?: Offset;
|
|
10
|
+
zIndex?: number;
|
|
11
|
+
animations?: TriggerAnimations;
|
|
12
|
+
component?: TNode;
|
|
13
|
+
}
|
|
14
|
+
export interface PopoverConfig<TNode = unknown> {
|
|
15
|
+
position?: Position;
|
|
16
|
+
offset?: Offset;
|
|
17
|
+
animations?: PopoverAnimations;
|
|
18
|
+
component?: TNode;
|
|
19
|
+
}
|
|
20
|
+
export interface Beacon<TNode = unknown> {
|
|
21
|
+
id: string;
|
|
22
|
+
selector: string;
|
|
23
|
+
trigger?: TriggerConfig<TNode>;
|
|
24
|
+
popover: PopoverConfig<TNode>;
|
|
25
|
+
}
|
|
26
|
+
export interface CalculatedBeaconPosition {
|
|
27
|
+
top: number;
|
|
28
|
+
left: number;
|
|
29
|
+
translate: {
|
|
30
|
+
x: string;
|
|
31
|
+
y: string;
|
|
32
|
+
};
|
|
33
|
+
position: "fixed";
|
|
34
|
+
zIndex: number;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=beacon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beacon.d.ts","sourceRoot":"","sources":["../../src/types/beacon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,MAAM;IACrB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,GAAG,OAAO;IAC5C,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,GAAG,OAAO;IAC5C,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB;AAED,MAAM,WAAW,MAAM,CAAC,KAAK,GAAG,OAAO;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE;QACT,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Beacon, PopoverConfig, TriggerConfig } from './beacon';
|
|
2
|
+
import { BeaconStore } from './store';
|
|
3
|
+
export interface Page<TNode = unknown> {
|
|
4
|
+
id: string;
|
|
5
|
+
path: string | ((pathname: string) => boolean);
|
|
6
|
+
beacons: Beacon<TNode>[];
|
|
7
|
+
}
|
|
8
|
+
export interface ErrorHandling {
|
|
9
|
+
onRenderError?: (beaconId: string, error: Error) => void;
|
|
10
|
+
onPositionError?: (beaconId: string, error: Error) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface RepereConfig<TNode = unknown> {
|
|
13
|
+
pages: Page<TNode>[];
|
|
14
|
+
store?: BeaconStore;
|
|
15
|
+
trigger?: TriggerConfig<TNode>;
|
|
16
|
+
popover?: PopoverConfig<TNode>;
|
|
17
|
+
errorHandling?: ErrorHandling;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,WAAW,IAAI,CAAC,KAAK,GAAG,OAAO;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACzD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC5D;AAED,MAAM,WAAW,YAAY,CAAC,KAAK,GAAG,OAAO;IAC3C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum Position {
|
|
2
|
+
TopLeft = "top-left",
|
|
3
|
+
TopCenter = "top-center",
|
|
4
|
+
TopRight = "top-right",
|
|
5
|
+
RightCenter = "right-center",
|
|
6
|
+
BottomRight = "bottom-right",
|
|
7
|
+
BottomCenter = "bottom-center",
|
|
8
|
+
BottomLeft = "bottom-left",
|
|
9
|
+
LeftCenter = "left-center"
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../src/types/position.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,OAAO,aAAa;IACpB,SAAS,eAAe;IACxB,QAAQ,cAAc;IACtB,WAAW,iBAAiB;IAC5B,WAAW,iBAAiB;IAC5B,YAAY,kBAAkB;IAC9B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;CAC3B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface BeaconState {
|
|
2
|
+
id: string;
|
|
3
|
+
isDismissed: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface BeaconStore {
|
|
6
|
+
isDismissed(beaconId: BeaconState["id"]): Promise<boolean> | boolean;
|
|
7
|
+
dismiss(beaconId: BeaconState["id"]): Promise<void> | void;
|
|
8
|
+
reset(beaconId: BeaconState["id"]): Promise<void> | void;
|
|
9
|
+
resetAll(): Promise<void> | void;
|
|
10
|
+
getAll(): Promise<BeaconState[]> | BeaconState[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/types/store.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAE1B,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAGrE,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAG3D,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAGzD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAGjC,MAAM,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC;CAClD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Beacon } from '../types/beacon';
|
|
2
|
+
import { Page } from '../types/config';
|
|
3
|
+
import { BeaconStore } from '../types/store';
|
|
4
|
+
export interface BeaconManagerOptions {
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Framework-agnostic beacon lifecycle manager
|
|
9
|
+
* Handles page matching and beacon filtering
|
|
10
|
+
*/
|
|
11
|
+
export declare class BeaconManager<TComponent = unknown> {
|
|
12
|
+
private readonly store;
|
|
13
|
+
private readonly debug;
|
|
14
|
+
constructor(store: BeaconStore, options?: BeaconManagerOptions);
|
|
15
|
+
/**
|
|
16
|
+
* Find all pages that match the current path
|
|
17
|
+
* This supports wildcards - e.g., path="*" will match all pages
|
|
18
|
+
*/
|
|
19
|
+
findMatchingPages(pages: Page<TComponent>[], currentPath: string): Page<TComponent>[];
|
|
20
|
+
/**
|
|
21
|
+
* Get all active (non-dismissed) beacons for the current path
|
|
22
|
+
* Includes beacons from all matching pages (supports wildcards)
|
|
23
|
+
*/
|
|
24
|
+
getActiveBeacons(pages: Page<TComponent>[], currentPath: string): Promise<Beacon<TComponent>[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the store instance
|
|
27
|
+
*/
|
|
28
|
+
getStore(): BeaconStore;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=BeaconManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeaconManager.d.ts","sourceRoot":"","sources":["../../src/utils/BeaconManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,aAAa,CAAC,UAAU,GAAG,OAAO;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,KAAK,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB;IAKlE;;;OAGG;IACH,iBAAiB,CACf,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,EACzB,WAAW,EAAE,MAAM,GAClB,IAAI,CAAC,UAAU,CAAC,EAAE;IAoBrB;;;OAGG;IACG,gBAAgB,CACpB,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,EACzB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;IA+DhC;;OAEG;IACH,QAAQ,IAAI,WAAW;CAGxB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CalculatedBeaconPosition, Offset } from '../types/beacon';
|
|
2
|
+
import { Position } from '../types/position';
|
|
3
|
+
export type PositionCallback = (position: CalculatedBeaconPosition | null) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Framework-agnostic position tracker for beacon elements
|
|
6
|
+
* Tracks element positions and notifies subscribers of changes
|
|
7
|
+
*/
|
|
8
|
+
export declare class PositionTracker {
|
|
9
|
+
private tracked;
|
|
10
|
+
private scrollListener;
|
|
11
|
+
private resizeListener;
|
|
12
|
+
private resizeObserver;
|
|
13
|
+
private mutationObserver;
|
|
14
|
+
private debug;
|
|
15
|
+
constructor(debug?: boolean);
|
|
16
|
+
/**
|
|
17
|
+
* Subscribe to position updates for an element
|
|
18
|
+
*/
|
|
19
|
+
subscribe(selector: string, position: Position, callback: PositionCallback, options?: {
|
|
20
|
+
offset?: Offset;
|
|
21
|
+
zIndex?: number;
|
|
22
|
+
}): () => void;
|
|
23
|
+
private updatePosition;
|
|
24
|
+
private updateAllPositions;
|
|
25
|
+
private startListening;
|
|
26
|
+
private stopListening;
|
|
27
|
+
/**
|
|
28
|
+
* Clean up all listeners and subscriptions
|
|
29
|
+
*/
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=PositionTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PositionTracker.d.ts","sourceRoot":"","sources":["../../src/utils/PositionTracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,MAAM,gBAAgB,GAAG,CAC7B,QAAQ,EAAE,wBAAwB,GAAG,IAAI,KACtC,IAAI,CAAC;AAWV;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,KAAK,CAAS;gBAEV,KAAK,UAAQ;IAIzB;;OAEG;IACH,SAAS,CACP,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ,GACL,MAAM,IAAI;IA4Cb,OAAO,CAAC,cAAc;IA2CtB,OAAO,CAAC,kBAAkB,CAIxB;IAEF,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,OAAO;CAIR"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Animation, AnimationConfig, AnimationVariants, ResolvedAnimationConfig } from '../types/animations';
|
|
2
|
+
/**
|
|
3
|
+
* Normalize animation input to full config
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeAnimationConfig(input?: Animation | AnimationConfig | null): AnimationConfig | null;
|
|
6
|
+
/**
|
|
7
|
+
* Merge two animation configs, with override taking precedence
|
|
8
|
+
*/
|
|
9
|
+
export declare function mergeAnimationConfigs(base?: Animation | AnimationConfig, override?: Animation | AnimationConfig): AnimationConfig | null;
|
|
10
|
+
/**
|
|
11
|
+
* Get animation config ready for motion library (Framer Motion, etc.)
|
|
12
|
+
*/
|
|
13
|
+
export declare function getAnimationConfig(input?: Animation | AnimationConfig | null): ResolvedAnimationConfig | null;
|
|
14
|
+
/**
|
|
15
|
+
* Combine positioning translate with animation variants
|
|
16
|
+
* This merges the static positioning offset (e.g., "-50%, 0") with
|
|
17
|
+
* animation offsets (e.g., y: -20px for slide-down)
|
|
18
|
+
*/
|
|
19
|
+
export declare function combineTranslateWithAnimation(translate: {
|
|
20
|
+
x: string;
|
|
21
|
+
y: string;
|
|
22
|
+
}, animationVariants: AnimationVariants): AnimationVariants;
|
|
23
|
+
/**
|
|
24
|
+
* Generate CSS custom properties for popover animations
|
|
25
|
+
* These are used with transition-behavior: allow-discrete in CSS
|
|
26
|
+
*/
|
|
27
|
+
export declare function getPopoverAnimationStyles(openAnimation?: ResolvedAnimationConfig | null, closeAnimation?: ResolvedAnimationConfig | null): Record<string, string | number>;
|
|
28
|
+
/**
|
|
29
|
+
* Calculate the total duration needed for dismiss animations
|
|
30
|
+
* Returns the maximum of trigger and popover animation durations
|
|
31
|
+
*/
|
|
32
|
+
export declare function calculateDismissDuration(triggerDismissAnimation?: ResolvedAnimationConfig | null, popoverCloseAnimation?: ResolvedAnimationConfig | null): number;
|
|
33
|
+
/**
|
|
34
|
+
* Create a promise that resolves after the given animation duration
|
|
35
|
+
*/
|
|
36
|
+
export declare function waitForAnimations(durationMs: number): Promise<void>;
|
|
37
|
+
//# sourceMappingURL=animations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../src/utils/animations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,CAAC,EAAE,SAAS,GAAG,eAAe,GAAG,IAAI,GACzC,eAAe,GAAG,IAAI,CAQxB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,CAAC,EAAE,SAAS,GAAG,eAAe,EAClC,QAAQ,CAAC,EAAE,SAAS,GAAG,eAAe,GACrC,eAAe,GAAG,IAAI,CAcxB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,EAAE,SAAS,GAAG,eAAe,GAAG,IAAI,GACzC,uBAAuB,GAAG,IAAI,CAoBhC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACnC,iBAAiB,EAAE,iBAAiB,GACnC,iBAAiB,CAqCnB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,CAAC,EAAE,uBAAuB,GAAG,IAAI,EAC9C,cAAc,CAAC,EAAE,uBAAuB,GAAG,IAAI,GAC9C,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAkCjC;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,uBAAuB,CAAC,EAAE,uBAAuB,GAAG,IAAI,EACxD,qBAAqB,CAAC,EAAE,uBAAuB,GAAG,IAAI,GACrD,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-matching.d.ts","sourceRoot":"","sources":["../../src/utils/path-matching.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,SAAS,CACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,OAAO,CAkBT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Offset } from '../types/beacon';
|
|
2
|
+
import { Position } from '../types/position';
|
|
3
|
+
export interface PositionCoordinates {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
translate: {
|
|
7
|
+
x: string;
|
|
8
|
+
y: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Calculate beacon position relative to target element
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateBeaconPosition(targetRect: DOMRect, position?: Position, offset?: Offset): PositionCoordinates;
|
|
15
|
+
//# sourceMappingURL=positioning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"positioning.d.ts","sourceRoot":"","sources":["../../src/utils/positioning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE;QACT,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,OAAO,EACnB,QAAQ,GAAE,QAA4B,EACtC,MAAM,GAAE,MAAuB,GAC9B,mBAAmB,CA0ErB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@repere/core",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./styles.css": "./dist/styles.css"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"tour",
|
|
18
|
+
"onboarding",
|
|
19
|
+
"beacon",
|
|
20
|
+
"popover",
|
|
21
|
+
"guide",
|
|
22
|
+
"tutorial"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/repere-ui/repere",
|
|
27
|
+
"directory": "packages/core"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "vite build --watch",
|
|
34
|
+
"build": "vite build",
|
|
35
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
36
|
+
"check": "pnpm exec biome check --write"
|
|
37
|
+
}
|
|
38
|
+
}
|