@retoo/borda 0.1.0 → 0.1.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.
@@ -3655,9 +3655,8 @@
3655
3655
  return e = n(), po.has(e) ? e : so.BOTTOM_START;
3656
3656
  var e;
3657
3657
  }), m = Ce(o), _ = Ce(i), b = Ce(r), y = Ce(s), T = Ce(a);
3658
- return Lt(() => {
3658
+ function w() {
3659
3659
  if (!En(h) || !En(v)) return;
3660
- p.x, p.y;
3661
3660
  const e = Si({
3662
3661
  target: En(h),
3663
3662
  tooltip: En(v),
@@ -3673,6 +3672,13 @@
3673
3672
  }
3674
3673
  });
3675
3674
  ot(l, e.position.top, !0), ot(u, e.position.left, !0), ot(c, e.placement, !0), ot(f, e.arrowOffset, !0);
3675
+ }
3676
+ return Lt(() => {
3677
+ if (!En(v)) return;
3678
+ const e = new ResizeObserver(w);
3679
+ return e.observe(En(v)), () => e.disconnect();
3680
+ }), Lt(() => {
3681
+ p.x, p.y, w();
3676
3682
  }), {
3677
3683
  get top() {
3678
3684
  return En(l);
@@ -4275,13 +4281,20 @@
4275
4281
  getDuration: () => t.animation.overlay.transitionDuration
4276
4282
  });
4277
4283
  to({ getContainer: () => En(n)?.getElements()?.root ?? null });
4278
- const a = Ce(() => t.config.size), l = Ce(() => t.config.shape), u = Ce(() => ["rb"]), c = Ce(() => ({
4284
+ const a = Ce(() => ["rb"]), l = Ce(() => ({
4279
4285
  ...t.config.container,
4280
4286
  customClasses: {
4281
4287
  ...t.config.container?.customClasses,
4282
4288
  root: [t.config.container?.customClasses?.root, i.classes]
4283
4289
  }
4284
- })), f = Ce(() => t.config.tourOverlay), d = Ce(() => t.config.tourTooltip), p = Ce(() => t.config.tourImage), h = Ce(() => t.config.tourButtons), v = Ce(() => t.config.tourProgress), g = Ce(() => t.config.tourSkip), m = Ce(() => t.config.closeButton), _ = Ce(() => !!t.animation.isEnabled && t.animation.tooltip), b = Ce(() => t.animation.isEnabled), y = Ce(() => t.animation.tooltip.transition === Oo.GLIDE), T = Ce(() => t.animation.tooltip.appearance === So.DURING_SCROLL), w = Ce(() => t.scroll.isScrolling || s.isActive), E = Ce(() => !En(y) && En(b) && En(w) && !En(T)), S = Ce(() => t.controller.step), O = Ce(() => {
4290
+ })), u = Ce(() => !!t.animation.isEnabled && t.animation.tooltip), c = Ce(() => t.animation.isEnabled), f = Ce(() => t.animation.tooltip.transition === Oo.GLIDE), d = Ce(() => t.animation.tooltip.appearance === So.DURING_SCROLL), p = Ce(() => t.scroll.isScrolling || s.isActive), h = Ce(() => !En(f) && En(c) && En(p) && !En(d));
4291
+ let v = nt(ut({
4292
+ step: Cn(() => t.controller.step),
4293
+ target: Cn(() => t.controller.currentTarget),
4294
+ currentStep: Cn(() => t.controller.currentStep),
4295
+ config: Cn(() => t.config)
4296
+ }));
4297
+ const g = Ce(() => En(v).config.size), m = Ce(() => En(v).config.shape), _ = Ce(() => En(v).config.tourOverlay), b = Ce(() => En(v).config.tourTooltip), y = Ce(() => En(v).config.tourImage), T = Ce(() => En(v).config.tourButtons), w = Ce(() => En(v).config.tourProgress), E = Ce(() => En(v).config.tourSkip), S = Ce(() => En(v).config.closeButton), O = Ce(() => {
4285
4298
  const e = En(o)?.getComponents();
4286
4299
  return {
4287
4300
  tourTooltip: e?.tourTooltip ?? null,
@@ -4308,6 +4321,22 @@
4308
4321
  var N;
4309
4322
  Lt(() => {
4310
4323
  t.config.visibility?.isHidden || t.scroll.scrollTo(t.controller.currentTarget);
4324
+ }), Lt(() => {
4325
+ if (!En(h)) return void ot(v, {
4326
+ step: t.controller.step,
4327
+ target: t.controller.currentTarget,
4328
+ currentStep: t.controller.currentStep,
4329
+ config: t.config
4330
+ }, !0);
4331
+ const e = setTimeout(() => {
4332
+ ot(v, {
4333
+ step: t.controller.step,
4334
+ target: t.controller.currentTarget,
4335
+ currentStep: t.controller.currentStep,
4336
+ config: t.config
4337
+ }, !0);
4338
+ }, t.animation.tooltip.exitDuration);
4339
+ return () => clearTimeout(e);
4311
4340
  }), sr(() => {
4312
4341
  t.mount();
4313
4342
  }), N = () => {
@@ -4329,9 +4358,9 @@
4329
4358
  }), X(s), zr(s, (e) => ot(n, e), () => En(n)), Bt(() => {
4330
4359
  Ir(s, "id", t.id), Tr(s, 1, mr(En(r))), Er(s, En(o));
4331
4360
  }), zn(e, s), oe(i);
4332
- }(yt(A), qr(() => En(c), {
4361
+ }(yt(A), qr(() => En(l), {
4333
4362
  children: (e, n) => {
4334
- var i = Fn(), s = Tt(i), u = (e) => {
4363
+ var i = Fn(), s = Tt(i), a = (e) => {
4335
4364
  var n = xi(), i = Tt(n), s = (e) => {
4336
4365
  zr(function(e, t) {
4337
4366
  re(t, !0);
@@ -4373,26 +4402,26 @@
4373
4402
  }), zn(e, y), oe(b);
4374
4403
  }(e, qr({
4375
4404
  get targetElement() {
4376
- return t.controller.currentTarget;
4405
+ return En(v).target;
4377
4406
  },
4378
4407
  get isAnimated() {
4379
- return En(b);
4408
+ return En(c);
4380
4409
  }
4381
- }, () => En(f))), (e) => ot(r, e, !0), () => En(r));
4410
+ }, () => En(_))), (e) => ot(r, e, !0), () => En(r));
4382
4411
  };
4383
4412
  ar(i, (e) => {
4384
- !1 !== En(f) && e(s);
4413
+ !1 !== En(_) && e(s);
4385
4414
  });
4386
- var u = wt(i, 2), c = (e) => {
4415
+ var a = wt(i, 2), l = (e) => {
4387
4416
  zr(Pi(e, {
4388
4417
  get step() {
4389
- return En(S);
4418
+ return En(v).step;
4390
4419
  },
4391
4420
  get currentTarget() {
4392
- return t.controller.currentTarget;
4421
+ return En(v).target;
4393
4422
  },
4394
4423
  get currentStep() {
4395
- return t.controller.currentStep;
4424
+ return En(v).currentStep;
4396
4425
  },
4397
4426
  get totalSteps() {
4398
4427
  return t.controller.totalSteps;
@@ -4401,37 +4430,37 @@
4401
4430
  return t.skip.isSkipped;
4402
4431
  },
4403
4432
  get isHidden() {
4404
- return En(E);
4433
+ return En(h);
4405
4434
  },
4406
4435
  get hasGlide() {
4407
- return En(y);
4436
+ return En(f);
4408
4437
  },
4409
4438
  get tourTooltipAnimation() {
4410
- return En(_);
4439
+ return En(u);
4411
4440
  },
4412
4441
  get size() {
4413
- return En(a);
4442
+ return En(g);
4414
4443
  },
4415
4444
  get shape() {
4416
- return En(l);
4445
+ return En(m);
4417
4446
  },
4418
4447
  get tourTooltipProps() {
4419
- return En(d);
4448
+ return En(b);
4420
4449
  },
4421
4450
  get tourImageProps() {
4422
- return En(p);
4451
+ return En(y);
4423
4452
  },
4424
4453
  get tourButtonsProps() {
4425
- return En(h);
4454
+ return En(T);
4426
4455
  },
4427
4456
  get tourProgressProps() {
4428
- return En(v);
4457
+ return En(w);
4429
4458
  },
4430
4459
  get closeButtonProps() {
4431
- return En(m);
4460
+ return En(S);
4432
4461
  },
4433
4462
  get tourSkipProps() {
4434
- return En(g);
4463
+ return En(E);
4435
4464
  },
4436
4465
  get onNext() {
4437
4466
  return t.controller.next;
@@ -4450,16 +4479,16 @@
4450
4479
  }
4451
4480
  }), (e) => ot(o, e, !0), () => En(o));
4452
4481
  };
4453
- ar(u, (e) => {
4454
- !1 !== En(d) && e(c);
4482
+ ar(a, (e) => {
4483
+ !1 !== En(b) && e(l);
4455
4484
  }), zn(e, n);
4456
4485
  };
4457
4486
  ar(s, (e) => {
4458
- t.controller.currentTarget && En(S) && e(u);
4487
+ t.controller.currentTarget && t.controller.step && e(a);
4459
4488
  }), zn(e, i);
4460
4489
  },
4461
4490
  $$slots: { default: !0 }
4462
- })), (e) => ot(n, e, !0), () => En(n)), X(A), Bt(() => Tr(A, 1, mr(En(u)))), zn(e, A), oe(k);
4491
+ })), (e) => ot(n, e, !0), () => En(n)), X(A), Bt(() => Tr(A, 1, mr(En(a)))), zn(e, A), oe(k);
4463
4492
  }
4464
4493
  function Ri() {
4465
4494
  const e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakSet();
@@ -4552,7 +4581,7 @@
4552
4581
  }
4553
4582
  return {
4554
4583
  NAME: "@retoo/borda",
4555
- VERSION: "0.1.0",
4584
+ VERSION: "0.1.1",
4556
4585
  mount: n,
4557
4586
  unmount: r,
4558
4587
  highlight: Do(n).highlight
package/dist/borda.umd.js CHANGED
@@ -8445,11 +8445,9 @@ createHTML: (html) => {
8445
8445
  const padding = /* @__PURE__ */ user_derived(getPadding);
8446
8446
  const autoPlacement = /* @__PURE__ */ user_derived(getAutoPlacement);
8447
8447
  const arrowSide = /* @__PURE__ */ user_derived(getArrowSide);
8448
- user_effect(() => {
8448
+ /** Reads the live target/tooltip rects and writes the resolved position into state. */
8449
+ function recompute() {
8449
8450
  if (!get(target) || !get(tooltip)) return;
8450
- /** Re-run on scroll so auto-flip/shift recompute against the live viewport. */
8451
- scroll.x;
8452
- scroll.y;
8453
8451
  const layout = useTooltipLayout({
8454
8452
  target: get(target),
8455
8453
  tooltip: get(tooltip),
@@ -8468,6 +8466,19 @@ createHTML: (html) => {
8468
8466
  set(left, layout.position.left, true);
8469
8467
  set(effectivePlacement, layout.placement, true);
8470
8468
  set(arrowOffset, layout.arrowOffset, true);
8469
+ }
8470
+ user_effect(() => {
8471
+ if (!get(tooltip)) return;
8472
+ /** Re-run when the tooltip's own size changes (e.g. an image finishes loading). */
8473
+ const observer = new ResizeObserver(recompute);
8474
+ observer.observe(get(tooltip));
8475
+ return () => observer.disconnect();
8476
+ });
8477
+ user_effect(() => {
8478
+ /** Re-run on scroll so auto-flip/shift recompute against the live viewport. */
8479
+ scroll.x;
8480
+ scroll.y;
8481
+ recompute();
8471
8482
  });
8472
8483
  return {
8473
8484
  get top() {
@@ -8952,9 +8963,8 @@ createHTML: (html) => {
8952
8963
  getDuration: () => $$props.animation.overlay.transitionDuration
8953
8964
  });
8954
8965
  useFocusTrap({ getContainer: () => get(bordaContainer)?.getElements()?.root ?? null });
8955
- const size = /* @__PURE__ */ user_derived(() => $$props.config.size);
8956
- const shape = /* @__PURE__ */ user_derived(() => $$props.config.shape);
8957
8966
  const rootClasses = /* @__PURE__ */ user_derived(() => ["rb"]);
8967
+ /** Container chrome isn't per-step content, so it always tracks the live config. */
8958
8968
  const containerProps = /* @__PURE__ */ user_derived(() => ({
8959
8969
  ...$$props.config.container,
8960
8970
  customClasses: {
@@ -8962,13 +8972,6 @@ createHTML: (html) => {
8962
8972
  root: [$$props.config.container?.customClasses?.root, containerAnimator.classes]
8963
8973
  }
8964
8974
  }));
8965
- const tourOverlayProps = /* @__PURE__ */ user_derived(() => $$props.config.tourOverlay);
8966
- const tourTooltipProps = /* @__PURE__ */ user_derived(() => $$props.config.tourTooltip);
8967
- const tourImageProps = /* @__PURE__ */ user_derived(() => $$props.config.tourImage);
8968
- const tourButtonsProps = /* @__PURE__ */ user_derived(() => $$props.config.tourButtons);
8969
- const tourProgressProps = /* @__PURE__ */ user_derived(() => $$props.config.tourProgress);
8970
- const tourSkipProps = /* @__PURE__ */ user_derived(() => $$props.config.tourSkip);
8971
- const closeButtonProps = /* @__PURE__ */ user_derived(() => $$props.config.closeButton);
8972
8975
  const tourTooltipAnimation = /* @__PURE__ */ user_derived(() => $$props.animation.isEnabled ? $$props.animation.tooltip : false);
8973
8976
  const isAnimated = /* @__PURE__ */ user_derived(() => $$props.animation.isEnabled);
8974
8977
  const hasGlide = /* @__PURE__ */ user_derived(() => $$props.animation.tooltip.transition === BordaTooltipTransition.GLIDE);
@@ -8976,7 +8979,22 @@ createHTML: (html) => {
8976
8979
  const isStepSettling = /* @__PURE__ */ user_derived(() => $$props.scroll.isScrolling || overlayTransition.isActive);
8977
8980
  /** In fade mode, hide the tooltip while the step settles, then fade it in at the new position. */
8978
8981
  const isHidden = /* @__PURE__ */ user_derived(() => !get(hasGlide) && get(isAnimated) && get(isStepSettling) && !get(isShownOnScroll));
8979
- const step = /* @__PURE__ */ user_derived(() => $$props.controller.step);
8982
+ /** Seeded once from the initial step so the first render has content; kept in sync by the effect below. */
8983
+ let displayed = /* @__PURE__ */ state(proxy({
8984
+ step: untrack(() => $$props.controller.step),
8985
+ target: untrack(() => $$props.controller.currentTarget),
8986
+ currentStep: untrack(() => $$props.controller.currentStep),
8987
+ config: untrack(() => $$props.config)
8988
+ }));
8989
+ const size = /* @__PURE__ */ user_derived(() => get(displayed).config.size);
8990
+ const shape = /* @__PURE__ */ user_derived(() => get(displayed).config.shape);
8991
+ const tourOverlayProps = /* @__PURE__ */ user_derived(() => get(displayed).config.tourOverlay);
8992
+ const tourTooltipProps = /* @__PURE__ */ user_derived(() => get(displayed).config.tourTooltip);
8993
+ const tourImageProps = /* @__PURE__ */ user_derived(() => get(displayed).config.tourImage);
8994
+ const tourButtonsProps = /* @__PURE__ */ user_derived(() => get(displayed).config.tourButtons);
8995
+ const tourProgressProps = /* @__PURE__ */ user_derived(() => get(displayed).config.tourProgress);
8996
+ const tourSkipProps = /* @__PURE__ */ user_derived(() => get(displayed).config.tourSkip);
8997
+ const closeButtonProps = /* @__PURE__ */ user_derived(() => get(displayed).config.closeButton);
8980
8998
  const tourComponents = /* @__PURE__ */ user_derived(() => {
8981
8999
  const components = get(bordaTour)?.getComponents();
8982
9000
  return {
@@ -9008,6 +9026,34 @@ createHTML: (html) => {
9008
9026
  if ($$props.config.visibility?.isHidden) return;
9009
9027
  $$props.scroll.scrollTo($$props.controller.currentTarget);
9010
9028
  });
9029
+ user_effect(() => {
9030
+ if (!get(isHidden)) {
9031
+ set(displayed, {
9032
+ step: $$props.controller.step,
9033
+ target: $$props.controller.currentTarget,
9034
+ currentStep: $$props.controller.currentStep,
9035
+ config: $$props.config
9036
+ }, true);
9037
+ return;
9038
+ }
9039
+ /**
9040
+ * `step`/`currentTarget`/`currentStep`/`config` (incl. per-step overrides
9041
+ * like `tourProgress`) are live and swap the instant the step index
9042
+ * changes, so binding the tooltip/overlay to them directly would render
9043
+ * the new step's content immediately — visible for a frame before the
9044
+ * fade-out even starts. Keep showing the outgoing step's snapshot while
9045
+ * it fades out, and only swap once it's actually invisible.
9046
+ */
9047
+ const timeoutId = setTimeout(() => {
9048
+ set(displayed, {
9049
+ step: $$props.controller.step,
9050
+ target: $$props.controller.currentTarget,
9051
+ currentStep: $$props.controller.currentStep,
9052
+ config: $$props.config
9053
+ }, true);
9054
+ }, $$props.animation.tooltip.exitDuration);
9055
+ return () => clearTimeout(timeoutId);
9056
+ });
9011
9057
  onMount(() => {
9012
9058
  $$props.mount();
9013
9059
  });
@@ -9027,7 +9073,7 @@ createHTML: (html) => {
9027
9073
  var consequent = ($$anchor) => {
9028
9074
  bind_this(BordaTourOverlay($$anchor, spread_props({
9029
9075
  get targetElement() {
9030
- return $$props.controller.currentTarget;
9076
+ return get(displayed).target;
9031
9077
  },
9032
9078
  get isAnimated() {
9033
9079
  return get(isAnimated);
@@ -9041,13 +9087,13 @@ createHTML: (html) => {
9041
9087
  var consequent_1 = ($$anchor) => {
9042
9088
  bind_this(BordaTour($$anchor, {
9043
9089
  get step() {
9044
- return get(step);
9090
+ return get(displayed).step;
9045
9091
  },
9046
9092
  get currentTarget() {
9047
- return $$props.controller.currentTarget;
9093
+ return get(displayed).target;
9048
9094
  },
9049
9095
  get currentStep() {
9050
- return $$props.controller.currentStep;
9096
+ return get(displayed).currentStep;
9051
9097
  },
9052
9098
  get totalSteps() {
9053
9099
  return $$props.controller.totalSteps;
@@ -9111,7 +9157,7 @@ createHTML: (html) => {
9111
9157
  append($$anchor, fragment_1);
9112
9158
  };
9113
9159
  if_block(node_1, ($$render) => {
9114
- if ($$props.controller.currentTarget && get(step)) $$render(consequent_2);
9160
+ if ($$props.controller.currentTarget && $$props.controller.step) $$render(consequent_2);
9115
9161
  });
9116
9162
  append($$anchor, fragment);
9117
9163
  },
@@ -9289,7 +9335,7 @@ createHTML: (html) => {
9289
9335
  }
9290
9336
  return {
9291
9337
  NAME: "@retoo/borda",
9292
- VERSION: "0.1.0",
9338
+ VERSION: "0.1.1",
9293
9339
  mount: mount$1,
9294
9340
  unmount: unmount$1,
9295
9341
  highlight: useBordaHighlight(mount$1).highlight
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retoo/borda",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Embeddable onboarding widget for any website. Framework-agnostic, SSR-safe.",
5
5
  "keywords": [
6
6
  "embeddable",