@repere/react 0.1.0 → 0.2.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.
@@ -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,kDAkHrB"}
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.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export type * from '@repere/core';
2
+ export { Animation, Position } from '@repere/core';
1
3
  export { Beacons, type BeaconsProps } from './components/Beacons';
2
4
  export { ReperePopover } from './components/Popover';
3
5
  export { RepereTrigger } from './components/RepereTrigger';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,cAAc,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { jsx as g, jsxs as J } from "react/jsx-runtime";
2
- import { createContext as K, useContext as Q, useMemo as y, useState as C, useEffect as $, useCallback as A, isValidElement as N, cloneElement as W, useId as Z, forwardRef as b } from "react";
3
- import { createPortal as ee } from "react-dom";
1
+ import { jsx as g, jsxs as K } from "react/jsx-runtime";
2
+ import { createContext as Q, useContext as W, useMemo as w, useState as C, useEffect as L, useCallback as A, isValidElement as N, cloneElement as Z, useId as ee, forwardRef as b } from "react";
3
+ import { createPortal as te } 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 te = m.TopRight;
7
- class oe {
6
+ const oe = m.TopRight;
7
+ class ne {
8
8
  state = /* @__PURE__ */ new Map();
9
9
  isDismissed(t) {
10
10
  return this.state.get(t)?.isDismissed ?? !1;
@@ -26,7 +26,7 @@ class oe {
26
26
  }
27
27
  }
28
28
  var v = /* @__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))(v || {});
29
- const ne = {
29
+ const ie = {
30
30
  [v.SlideDown]: {
31
31
  initial: { y: -20, opacity: 0 },
32
32
  animate: { y: 0, opacity: 1 },
@@ -73,11 +73,11 @@ const ne = {
73
73
  exit: {}
74
74
  }
75
75
  };
76
- function z(e) {
76
+ function B(e) {
77
77
  return e ? typeof e == "string" ? { variant: e } : e : null;
78
78
  }
79
- function L(e, t) {
80
- const o = z(e), i = z(t);
79
+ function T(e, t) {
80
+ const o = B(e), i = B(t);
81
81
  return !o && !i ? null : o ? i ? {
82
82
  variant: i.variant ?? o.variant,
83
83
  duration: i.duration ?? o.duration,
@@ -85,10 +85,10 @@ function L(e, t) {
85
85
  ease: i.ease ?? o.ease
86
86
  } : o : i;
87
87
  }
88
- function B(e) {
89
- const t = z(e);
88
+ function $(e) {
89
+ const t = B(e);
90
90
  if (!t) return null;
91
- const o = ne[t.variant];
91
+ const o = ie[t.variant];
92
92
  return o ? {
93
93
  variants: o,
94
94
  transition: {
@@ -100,7 +100,7 @@ function B(e) {
100
100
  }
101
101
  } : (console.warn(`[Repere] Unknown animation variant: ${t.variant}`), null);
102
102
  }
103
- function ie(e, t) {
103
+ function se(e, t) {
104
104
  const o = (n) => {
105
105
  const a = n.match(/(-?\d+)%/);
106
106
  return a ? parseFloat(a[1]) : 0;
@@ -120,7 +120,7 @@ function ie(e, t) {
120
120
  }
121
121
  };
122
122
  }
123
- function se(e, t) {
123
+ function re(e, t) {
124
124
  if (!e && !t) return {};
125
125
  const o = e?.variants, i = e?.transition, r = t?.variants, s = t?.transition, n = s?.ease ?? i?.ease ?? [0.4, 0, 0.2, 1], a = Array.isArray(n) ? `cubic-bezier(${n.join(", ")})` : n;
126
126
  return {
@@ -144,14 +144,14 @@ function se(e, t) {
144
144
  "--repere-transition-timing": a
145
145
  };
146
146
  }
147
- function re(e, t) {
147
+ function ae(e, t) {
148
148
  const o = e?.transition.duration ?? 0, i = t?.transition.duration ?? 0;
149
149
  return Math.max(o, i) * 1e3;
150
150
  }
151
- function ae(e) {
151
+ function le(e) {
152
152
  return new Promise((t) => setTimeout(t, e));
153
153
  }
154
- function le(e, t) {
154
+ function ce(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 ce {
165
+ class pe {
166
166
  store;
167
167
  debug;
168
168
  constructor(t, o = {}) {
@@ -173,7 +173,7 @@ class ce {
173
173
  * This supports wildcards - e.g., path="*" will match all pages
174
174
  */
175
175
  findMatchingPages(t, o) {
176
- const i = t.filter((r) => typeof r.path == "function" ? r.path(o) : le(o, r.path));
176
+ const i = t.filter((r) => typeof r.path == "function" ? r.path(o) : ce(o, r.path));
177
177
  return this.debug && console.log(
178
178
  "[BeaconManager] Path:",
179
179
  o,
@@ -220,7 +220,7 @@ class ce {
220
220
  return this.store;
221
221
  }
222
222
  }
223
- function pe(e, t = m.TopRight, o = { x: 0, y: 0 }) {
223
+ function de(e, t = m.TopRight, o = { x: 0, y: 0 }) {
224
224
  const { x: i = 0, y: r = 0 } = o;
225
225
  let s = 0, n = 0, a = "0", l = "0";
226
226
  switch (t) {
@@ -259,7 +259,7 @@ function pe(e, t = m.TopRight, o = { x: 0, y: 0 }) {
259
259
  translate: { x: a, y: l }
260
260
  };
261
261
  }
262
- class de {
262
+ class ue {
263
263
  tracked = /* @__PURE__ */ new Map();
264
264
  scrollListener = null;
265
265
  resizeListener = null;
@@ -279,13 +279,25 @@ class de {
279
279
  position: o,
280
280
  offset: r.offset,
281
281
  zIndex: r.zIndex ?? 9999,
282
+ delay: r.delay,
282
283
  callbacks: /* @__PURE__ */ new Set(),
283
- element: null
284
- }), this.tracked.get(s)?.callbacks.add(i), this.tracked.size === 1 && this.startListening(), this.updatePosition(s), () => {
284
+ element: null,
285
+ hasInitialUpdate: !1
286
+ }), this.tracked.get(s)?.callbacks.add(i), this.tracked.size === 1 && this.startListening(), this.scheduleInitialUpdate(s), () => {
285
287
  const n = this.tracked.get(s);
286
- n && (n.callbacks.delete(i), n.callbacks.size === 0 && (this.tracked.delete(s), this.tracked.size === 0 && this.stopListening()));
288
+ n && (n.callbacks.delete(i), n.callbacks.size === 0 && (n.delayTimeoutId !== void 0 && (clearTimeout(n.delayTimeoutId), n.delayTimeoutId = void 0), this.tracked.delete(s), this.tracked.size === 0 && this.stopListening()));
287
289
  };
288
290
  }
291
+ scheduleInitialUpdate(t) {
292
+ const o = this.tracked.get(t);
293
+ o && (!o.hasInitialUpdate && o.delay && o.delay > 0 ? (o.hasInitialUpdate = !0, this.debug && console.log(
294
+ `[PositionTracker] Delaying initial position calculation for ${t} by ${o.delay}ms`
295
+ ), o.delayTimeoutId = setTimeout(() => {
296
+ this.debug && console.log(
297
+ `[PositionTracker] Calculating position for ${t} after delay`
298
+ ), o.delayTimeoutId !== void 0 && (o.delayTimeoutId = void 0), this.updatePosition(t);
299
+ }, o.delay)) : (o.hasInitialUpdate || (o.hasInitialUpdate = !0), this.updatePosition(t)));
300
+ }
289
301
  updatePosition(t) {
290
302
  const o = this.tracked.get(t);
291
303
  if (!o) return;
@@ -298,7 +310,7 @@ class de {
298
310
  }
299
311
  o.element = i;
300
312
  const r = i.getBoundingClientRect(), s = {
301
- ...pe(
313
+ ...de(
302
314
  r,
303
315
  o.position,
304
316
  o.offset
@@ -332,32 +344,34 @@ class de {
332
344
  * Clean up all listeners and subscriptions
333
345
  */
334
346
  destroy() {
347
+ for (const [, t] of this.tracked)
348
+ t.delayTimeoutId !== void 0 && (clearTimeout(t.delayTimeoutId), t.delayTimeoutId = void 0);
335
349
  this.stopListening(), this.tracked.clear();
336
350
  }
337
351
  }
338
- const j = K(null);
339
- function k() {
340
- const e = Q(j);
352
+ const U = Q(null);
353
+ function I() {
354
+ const e = W(U);
341
355
  if (!e)
342
356
  throw new Error("useRepereContext must be used within a Repere provider.");
343
357
  return e;
344
358
  }
345
- function ue(e, t) {
346
- const o = y(() => {
359
+ function me(e, t) {
360
+ const o = w(() => {
347
361
  const n = t.trigger?.animations?.onRender, a = e.trigger?.animations?.onRender;
348
- return B(L(n, a));
349
- }, [t.trigger?.animations, e.trigger?.animations]), i = y(() => {
362
+ return $(T(n, a));
363
+ }, [t.trigger?.animations, e.trigger?.animations]), i = w(() => {
350
364
  const n = t.trigger?.animations?.onDismiss, a = e.trigger?.animations?.onDismiss;
351
- return B(L(n, a));
365
+ return $(T(n, a));
352
366
  }, [
353
367
  t.trigger?.animations?.onDismiss,
354
368
  e.trigger?.animations?.onDismiss
355
- ]), r = y(() => {
369
+ ]), r = w(() => {
356
370
  const n = t.popover?.animations?.onOpen, a = e.popover?.animations?.onOpen;
357
- return B(L(n, a));
358
- }, [t.popover?.animations?.onOpen, e.popover?.animations?.onOpen]), s = y(() => {
371
+ return $(T(n, a));
372
+ }, [t.popover?.animations?.onOpen, e.popover?.animations?.onOpen]), s = w(() => {
359
373
  const n = t.popover?.animations?.onClose, a = e.popover?.animations?.onClose;
360
- return B(L(n, a));
374
+ return $(T(n, a));
361
375
  }, [
362
376
  t.popover?.animations?.onClose,
363
377
  e.popover?.animations?.onClose
@@ -369,32 +383,33 @@ function ue(e, t) {
369
383
  popoverCloseAnimation: s
370
384
  };
371
385
  }
372
- function me({
386
+ function ge({
373
387
  targetSelector: e,
374
388
  position: t,
375
389
  offset: o,
376
390
  zIndex: i = 9999,
377
- enabled: r = !0,
378
- debug: s = !1
391
+ delay: r,
392
+ enabled: s = !0,
393
+ debug: n = !1
379
394
  }) {
380
- const [n, a] = C(null), l = y(() => new de(s), [s]);
381
- return $(() => {
382
- if (!r) {
383
- a(null);
395
+ const [a, l] = C(null), c = w(() => new ue(n), [n]);
396
+ return L(() => {
397
+ if (!s) {
398
+ l(null);
384
399
  return;
385
400
  }
386
- return l.subscribe(
401
+ return c.subscribe(
387
402
  e,
388
403
  t,
389
- a,
390
- { offset: o, zIndex: i }
404
+ l,
405
+ { offset: o, zIndex: i, delay: r }
391
406
  );
392
- }, [l, e, t, o, i, r]), $(() => () => l.destroy(), [l]), {
393
- calculatedPosition: n,
394
- targetElement: n ? document.querySelector(e) : null
407
+ }, [c, e, t, o, i, r, s]), L(() => () => c.destroy(), [c]), {
408
+ calculatedPosition: a,
409
+ targetElement: a ? document.querySelector(e) : null
395
410
  };
396
411
  }
397
- function ge() {
412
+ function ve() {
398
413
  const [e, t] = C(!1), [o, i] = C(
399
414
  null
400
415
  ), r = A((l) => {
@@ -409,7 +424,7 @@ function ge() {
409
424
  () => o?.hidePopover(),
410
425
  [o]
411
426
  );
412
- return $(() => {
427
+ return L(() => {
413
428
  if (!o) return;
414
429
  const l = (c) => {
415
430
  t(c.newState === "open");
@@ -424,7 +439,7 @@ function ge() {
424
439
  hidePopover: a
425
440
  };
426
441
  }
427
- function ve(e, t) {
442
+ function he(e, t) {
428
443
  return e ? N(e) ? e : /* @__PURE__ */ g(
429
444
  e,
430
445
  {
@@ -436,7 +451,7 @@ function ve(e, t) {
436
451
  }
437
452
  ) : null;
438
453
  }
439
- function he(e, t) {
454
+ function fe(e, t) {
440
455
  let o;
441
456
  return N(e) ? o = e : o = /* @__PURE__ */ g(
442
457
  e,
@@ -446,21 +461,22 @@ function he(e, t) {
446
461
  onDismiss: t.handleDismiss,
447
462
  onClose: t.hidePopover
448
463
  }
449
- ), W(o, {
464
+ ), Z(o, {
450
465
  // @ts-expect-error - cloneElement ref typing doesn't handle callback refs properly
451
466
  ref: t.handlePopoverRef,
452
467
  id: t.popoverId,
453
468
  popover: "auto"
454
469
  });
455
470
  }
456
- function fe(e, t) {
457
- const o = e.trigger?.position || t.trigger?.position || te, i = e.trigger?.zIndex || t.trigger?.zIndex || 9999, r = e.trigger?.offset, s = e.popover?.position || t.popover?.position || o, n = e.popover?.offset || t.popover?.offset || { x: 0, y: 0 };
471
+ function ye(e, t) {
472
+ const o = e.trigger?.position || t.trigger?.position || oe, i = e.trigger?.zIndex || t.trigger?.zIndex || 9999, r = e.trigger?.offset, s = e.trigger?.delay ?? t.trigger?.delay, n = e.popover?.position || t.popover?.position || o, a = e.popover?.offset || t.popover?.offset || { x: 0, y: 0 };
458
473
  return {
459
474
  position: o,
460
475
  zIndex: i,
461
476
  offset: r,
462
- popoverPosition: s,
463
- popoverOffset: n
477
+ delay: s,
478
+ popoverPosition: n,
479
+ popoverOffset: a
464
480
  };
465
481
  }
466
482
  function we({
@@ -470,66 +486,67 @@ function we({
470
486
  onDismiss: i,
471
487
  debug: r
472
488
  }) {
473
- const s = Z(), [n, a] = C(!1), { position: l, zIndex: c, offset: d, popoverPosition: w, popoverOffset: p } = fe(e, t), { calculatedPosition: u, targetElement: h } = me({
489
+ const s = ee(), [n, a] = C(!1), { position: l, zIndex: c, offset: d, delay: f, popoverPosition: p, popoverOffset: h } = ye(e, t), { calculatedPosition: u, targetElement: x } = ge({
474
490
  targetSelector: e.selector,
475
491
  position: l,
476
492
  offset: d,
477
493
  zIndex: c,
494
+ delay: f,
478
495
  enabled: !0,
479
496
  debug: r
480
497
  }), {
481
- isOpen: x,
482
- popoverElement: R,
483
- handlePopoverRef: P,
484
- togglePopover: f,
485
- showPopover: O,
486
- hidePopover: I
487
- } = ge(), {
488
- triggerAnimation: _,
489
- triggerDismissAnimation: D,
490
- popoverOpenAnimation: G,
491
- popoverCloseAnimation: T
492
- } = ue(e, t), E = async () => {
493
- a(!0), R?.hidePopover();
494
- const H = re(
495
- D,
496
- T
498
+ isOpen: k,
499
+ popoverElement: P,
500
+ handlePopoverRef: y,
501
+ togglePopover: R,
502
+ showPopover: _,
503
+ hidePopover: O
504
+ } = ve(), {
505
+ triggerAnimation: G,
506
+ triggerDismissAnimation: z,
507
+ popoverOpenAnimation: V,
508
+ popoverCloseAnimation: D
509
+ } = me(e, t), E = async () => {
510
+ a(!0), P?.hidePopover();
511
+ const J = ae(
512
+ z,
513
+ D
497
514
  );
498
- await ae(H), await Promise.resolve(o.dismiss(e.id)), i();
499
- }, V = {
515
+ await le(J), await Promise.resolve(o.dismiss(e.id)), i();
516
+ }, q = {
500
517
  beaconId: e.id,
501
518
  position: l,
502
- popoverPosition: w,
503
- popoverOffset: p,
519
+ popoverPosition: p,
520
+ popoverOffset: h,
504
521
  calculatedPosition: u,
505
- isOpen: x,
522
+ isOpen: k,
506
523
  isDismissing: n,
507
- toggle: f,
508
- open: O,
509
- close: I,
524
+ toggle: R,
525
+ open: _,
526
+ close: O,
510
527
  dismiss: E,
511
- triggerAnimation: _,
512
- triggerDismissAnimation: D,
513
- popoverOpenAnimation: G,
514
- popoverCloseAnimation: T,
528
+ triggerAnimation: G,
529
+ triggerDismissAnimation: z,
530
+ popoverOpenAnimation: V,
531
+ popoverCloseAnimation: D,
515
532
  popoverId: s
516
- }, q = e.trigger?.component || t.trigger?.component, S = e.popover.component || t.popover?.component;
517
- return !u || !h ? (r && console.warn(
518
- `[Repere] ${e.id} waiting for target element: position=${!!u}, element=${!!h}`
519
- ), null) : S ? /* @__PURE__ */ J(j.Provider, { value: V, children: [
520
- ve(q, {
533
+ }, H = e.trigger?.component || t.trigger?.component, S = e.popover.component || t.popover?.component;
534
+ return !u || !x ? (r && console.warn(
535
+ `[Repere] ${e.id} waiting for target element: position=${!!u}, element=${!!x}`
536
+ ), null) : S ? /* @__PURE__ */ K(U.Provider, { value: q, children: [
537
+ he(H, {
521
538
  beacon: e,
522
539
  calculatedPosition: u,
523
540
  position: l,
524
- isOpen: x,
525
- togglePopover: f
541
+ isOpen: k,
542
+ togglePopover: R
526
543
  }),
527
- he(S, {
544
+ fe(S, {
528
545
  beacon: e,
529
546
  position: l,
530
547
  handleDismiss: E,
531
- hidePopover: I,
532
- handlePopoverRef: P,
548
+ hidePopover: O,
549
+ handlePopoverRef: y,
533
550
  popoverId: s
534
551
  })
535
552
  ] }) : (r && console.warn(
@@ -537,41 +554,41 @@ function we({
537
554
  e.id
538
555
  ), null);
539
556
  }
540
- function Be({
557
+ function $e({
541
558
  config: e,
542
559
  currentPath: t,
543
560
  enabled: o = !0,
544
561
  debug: i = !1
545
562
  }) {
546
- const r = y(
547
- () => e.store || new oe(),
563
+ const r = w(
564
+ () => e.store || new ne(),
548
565
  [e.store]
549
- ), s = y(
550
- () => new ce(r, { debug: i }),
566
+ ), s = w(
567
+ () => new pe(r, { debug: i }),
551
568
  [r, i]
552
569
  ), [n, a] = C([]), [l, c] = C(
553
570
  /* @__PURE__ */ new Set()
554
571
  );
555
- $(() => {
572
+ L(() => {
556
573
  if (!o) {
557
574
  a([]), c(/* @__PURE__ */ new Set());
558
575
  return;
559
576
  }
560
577
  (async () => {
561
- const u = await s.getActiveBeacons(
578
+ const h = await s.getActiveBeacons(
562
579
  e.pages,
563
580
  t
564
581
  );
565
- a(u);
582
+ a(h);
566
583
  })();
567
584
  }, [s, e.pages, t, o]);
568
585
  const d = (p) => {
569
- c((u) => /* @__PURE__ */ new Set([...u, p]));
570
- }, w = n.filter(
586
+ c((h) => /* @__PURE__ */ new Set([...h, p]));
587
+ }, f = n.filter(
571
588
  (p) => !l.has(p.id)
572
589
  );
573
- return w.length === 0 ? null : ee(
574
- w.map((p) => /* @__PURE__ */ g(
590
+ return f.length === 0 ? null : te(
591
+ f.map((p) => /* @__PURE__ */ g(
575
592
  we,
576
593
  {
577
594
  beacon: p,
@@ -585,7 +602,7 @@ function Be({
585
602
  document.body
586
603
  );
587
604
  }
588
- const X = b(
605
+ const j = b(
589
606
  ({
590
607
  children: e,
591
608
  style: t,
@@ -600,22 +617,22 @@ const X = b(
600
617
  }, c) => {
601
618
  const {
602
619
  beaconId: d,
603
- popoverOpenAnimation: w,
620
+ popoverOpenAnimation: f,
604
621
  popoverCloseAnimation: p,
605
- popoverPosition: u,
606
- popoverOffset: h
607
- } = k(), x = A(
608
- (f) => {
609
- typeof c == "function" ? c(f) : c && (c.current = f);
622
+ popoverPosition: h,
623
+ popoverOffset: u
624
+ } = I(), x = A(
625
+ (y) => {
626
+ typeof c == "function" ? c(y) : c && (c.current = y);
610
627
  },
611
628
  [c]
612
629
  ), P = {
613
630
  positionAnchor: d ? `--repere-trigger-${d}` : void 0,
614
- ...h && {
615
- marginLeft: h.x || 0,
616
- marginTop: h.y || 0
631
+ ...u && {
632
+ marginLeft: u.x || 0,
633
+ marginTop: u.y || 0
617
634
  },
618
- ...se(w, p),
635
+ ...re(f, p),
619
636
  ...t
620
637
  };
621
638
  return /* @__PURE__ */ g(
@@ -625,7 +642,7 @@ const X = b(
625
642
  role: "dialog",
626
643
  "aria-labelledby": `repere-popover-${d}`,
627
644
  "data-repere-popover": "",
628
- "data-position": u,
645
+ "data-position": h,
629
646
  popover: o,
630
647
  ...l,
631
648
  style: P,
@@ -634,15 +651,15 @@ const X = b(
634
651
  );
635
652
  }
636
653
  );
637
- X.displayName = "ReperePopover";
638
- const ye = b(
654
+ j.displayName = "ReperePopover";
655
+ const xe = b(
639
656
  ({
640
657
  children: e = "Got it",
641
658
  onClick: t,
642
659
  as: o,
643
660
  ...i
644
661
  }, r) => {
645
- const s = k(), n = s?.dismiss || (() => {
662
+ const s = I(), n = s?.dismiss || (() => {
646
663
  }), a = s?.popoverId;
647
664
  return /* @__PURE__ */ g(
648
665
  o || "button",
@@ -658,10 +675,10 @@ const ye = b(
658
675
  }
659
676
  );
660
677
  }
661
- ), xe = Object.assign(ye, {
678
+ ), be = Object.assign(xe, {
662
679
  displayName: "ReperePopover.AcknowledgeButton"
663
- }), Y = b(({ children: e = "×", ...t }, o) => {
664
- const r = k()?.popoverId;
680
+ }), X = b(({ children: e = "×", ...t }, o) => {
681
+ const r = I()?.popoverId;
665
682
  return /* @__PURE__ */ g(
666
683
  "button",
667
684
  {
@@ -674,29 +691,29 @@ const ye = b(
674
691
  }
675
692
  );
676
693
  });
677
- Y.displayName = "ReperePopover.CloseButton";
678
- const F = b(
694
+ X.displayName = "ReperePopover.CloseButton";
695
+ const Y = b(
679
696
  ({ children: e, ...t }, o) => /* @__PURE__ */ g("div", { ref: o, ...t, children: e })
680
697
  );
681
- F.displayName = "ReperePopover.Content";
682
- const U = b(
698
+ Y.displayName = "ReperePopover.Content";
699
+ const F = b(
683
700
  ({ children: e, ...t }, o) => /* @__PURE__ */ g("div", { ref: o, ...t, children: e })
684
701
  );
685
- U.displayName = "ReperePopover.Footer";
686
- const be = b(
702
+ F.displayName = "ReperePopover.Footer";
703
+ const Pe = b(
687
704
  ({ children: e, as: t, ...o }, i) => {
688
- const s = k()?.beaconId || "unknown";
705
+ const s = I()?.beaconId || "unknown";
689
706
  return /* @__PURE__ */ g(t || "h3", { ref: i, id: `repere-popover-${s}`, ...o, children: e });
690
707
  }
691
- ), Pe = Object.assign(be, {
708
+ ), Ce = Object.assign(Pe, {
692
709
  displayName: "ReperePopover.Title"
693
- }), $e = Object.assign(X, {
694
- Title: Pe,
695
- Content: F,
696
- Footer: U,
697
- AcknowledgeButton: xe,
698
- CloseButton: Y
699
- }), Ce = b(
710
+ }), Le = Object.assign(j, {
711
+ Title: Ce,
712
+ Content: Y,
713
+ Footer: F,
714
+ AcknowledgeButton: be,
715
+ CloseButton: X
716
+ }), ke = b(
700
717
  ({
701
718
  children: e,
702
719
  as: t,
@@ -710,10 +727,10 @@ const be = b(
710
727
  triggerAnimation: l,
711
728
  triggerDismissAnimation: c,
712
729
  isDismissing: d,
713
- popoverId: w
714
- } = k(), p = t || "button", u = y(() => !t || t === "button" ? M.button : M.create(p), [t, p]);
730
+ popoverId: f
731
+ } = I(), p = t || "button", h = w(() => !t || t === "button" ? M.button : M.create(p), [t, p]);
715
732
  if (!n) return null;
716
- const h = {
733
+ const u = {
717
734
  position: n.position,
718
735
  top: n.top,
719
736
  left: n.left,
@@ -721,27 +738,27 @@ const be = b(
721
738
  pointerEvents: "auto",
722
739
  cursor: "pointer",
723
740
  anchorName: `--repere-trigger-${a}`
724
- }, x = o ? { ...h, ...o } : h, R = !i && (l || c), P = {
741
+ }, x = o ? { ...u, ...o } : u, k = !i && (l || c), P = {
725
742
  ref: s,
726
- popovertarget: w,
743
+ popovertarget: f,
727
744
  "aria-label": `Beacon trigger for ${a}`,
728
745
  "data-repere-trigger": "",
729
746
  ...r
730
747
  };
731
- if (R) {
732
- const f = d && c ? c : l;
733
- if (!f) return null;
734
- const O = ie(
748
+ if (k) {
749
+ const y = d && c ? c : l;
750
+ if (!y) return null;
751
+ const R = se(
735
752
  n.translate,
736
- f.variants
753
+ y.variants
737
754
  );
738
755
  return /* @__PURE__ */ g(
739
- u,
756
+ h,
740
757
  {
741
758
  initial: "initial",
742
759
  animate: d ? "exit" : "animate",
743
- variants: O,
744
- transition: f.transition,
760
+ variants: R,
761
+ transition: y.transition,
745
762
  ...P,
746
763
  style: x,
747
764
  children: e
@@ -760,11 +777,13 @@ const be = b(
760
777
  }
761
778
  );
762
779
  }
763
- ), Oe = Object.assign(Ce, {
780
+ ), Be = Object.assign(ke, {
764
781
  displayName: "RepereTrigger"
765
782
  });
766
783
  export {
767
- Be as Beacons,
768
- $e as ReperePopover,
769
- Oe as RepereTrigger
784
+ v as Animation,
785
+ $e as Beacons,
786
+ m as Position,
787
+ Le as ReperePopover,
788
+ Be as RepereTrigger
770
789
  };
@@ -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%}
@@ -4,6 +4,7 @@ export declare function resolveBeaconConfig(beacon: Beacon, config: RepereReactC
4
4
  position: Position;
5
5
  zIndex: number;
6
6
  offset: Offset | undefined;
7
+ delay: number | undefined;
7
8
  popoverPosition: Position;
8
9
  popoverOffset: Offset;
9
10
  };
@@ -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;;;;;;EAqB5E"}
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,26 +1,25 @@
1
1
  {
2
2
  "name": "@repere/react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",
9
9
  "import": "./dist/index.js"
10
- }
10
+ },
11
+ "./styles.css": "./dist/styles.css"
11
12
  },
12
13
  "files": [
13
14
  "dist"
14
15
  ],
15
- "dependencies": {
16
- "@repere/core": "0.0.3"
17
- },
18
16
  "peerDependencies": {
19
17
  "motion": "^12.0.0",
20
18
  "react": "^18.0.0 || ^19.0.0",
21
19
  "react-dom": "^18.0.0 || ^19.0.0"
22
20
  },
23
21
  "devDependencies": {
22
+ "@types/node": "^25.0.3",
24
23
  "@types/react": "^19.2.7",
25
24
  "@types/react-dom": "^19.2.3",
26
25
  "@vitejs/plugin-react": "^5.1.2",
@@ -28,7 +27,8 @@
28
27
  "react": "^19.2.3",
29
28
  "react-dom": "^19.2.3",
30
29
  "vite": "^7.3.0",
31
- "vite-plugin-dts": "^4.5.4"
30
+ "vite-plugin-dts": "^4.5.4",
31
+ "@repere/core": "0.1.0"
32
32
  },
33
33
  "keywords": [
34
34
  "react",