@vanduo-oss/framework 1.4.6 → 1.5.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,4 +1,4 @@
1
- /*! Vanduo v1.4.6 | Built: 2026-06-13T10:32:26.875Z | git:82019ff | development */
1
+ /*! Vanduo v1.5.0 | Built: 2026-06-18T19:13:58.613Z | git:8f0e1b5 | development */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -201,7 +201,7 @@ module.exports = __toCommonJS(index_exports);
201
201
  // js/vanduo.js
202
202
  (function() {
203
203
  "use strict";
204
- const VANDUO_VERSION = true ? "1.4.6" : "0.0.0-dev";
204
+ const VANDUO_VERSION = true ? "1.5.0" : "0.0.0-dev";
205
205
  const hasOwn = Object.prototype.hasOwnProperty;
206
206
  const Vanduo2 = {
207
207
  version: VANDUO_VERSION,
@@ -10441,6 +10441,7 @@ module.exports = __toCommonJS(index_exports);
10441
10441
  _cleanup: [],
10442
10442
  _boundTriggers: /* @__PURE__ */ new WeakMap(),
10443
10443
  _triggerElement: null,
10444
+ _currentTarget: null,
10444
10445
  init: function(root) {
10445
10446
  const triggers = window.Vanduo.queryAll(root, "[data-vd-spotlight]");
10446
10447
  triggers.forEach((trigger) => {
@@ -10509,8 +10510,29 @@ module.exports = __toCommonJS(index_exports);
10509
10510
  document.addEventListener("keydown", escHandler);
10510
10511
  this._cleanup.push(() => document.removeEventListener("keydown", escHandler));
10511
10512
  overlay.addEventListener("click", () => this.stop());
10513
+ const reposition = () => {
10514
+ if (this._active && this._currentTarget) this._positionTooltip(this._currentTarget);
10515
+ };
10516
+ window.addEventListener("scroll", reposition, { passive: true });
10517
+ window.addEventListener("resize", reposition);
10518
+ this._cleanup.push(() => window.removeEventListener("scroll", reposition));
10519
+ this._cleanup.push(() => window.removeEventListener("resize", reposition));
10512
10520
  this._showStep(this._currentStep);
10513
10521
  },
10522
+ _positionTooltip: function(target) {
10523
+ const tooltip = this._elements.tooltip;
10524
+ if (!tooltip || !target || !target.isConnected) return;
10525
+ const rect = target.getBoundingClientRect();
10526
+ const tRect = tooltip.getBoundingClientRect();
10527
+ let top = rect.bottom + 12 + window.scrollY;
10528
+ let left = rect.left + (rect.width - tRect.width) / 2 + window.scrollX;
10529
+ left = Math.max(8, Math.min(left, window.innerWidth - tRect.width - 8));
10530
+ if (top + tRect.height > window.innerHeight + window.scrollY) {
10531
+ top = rect.top - tRect.height - 12 + window.scrollY;
10532
+ }
10533
+ tooltip.style.top = top + "px";
10534
+ tooltip.style.left = left + "px";
10535
+ },
10514
10536
  _showStep: function(index) {
10515
10537
  const step = this._steps[index];
10516
10538
  if (!step) return;
@@ -10583,19 +10605,15 @@ module.exports = __toCommonJS(index_exports);
10583
10605
  footer.appendChild(counter);
10584
10606
  footer.appendChild(actions);
10585
10607
  tooltip.appendChild(footer);
10608
+ this._currentTarget = target || null;
10586
10609
  if (target) {
10587
- requestAnimationFrame(() => {
10588
- const rect = target.getBoundingClientRect();
10589
- const tRect = tooltip.getBoundingClientRect();
10590
- let top = rect.bottom + 12 + window.scrollY;
10591
- let left = rect.left + (rect.width - tRect.width) / 2 + window.scrollX;
10592
- left = Math.max(8, Math.min(left, window.innerWidth - tRect.width - 8));
10593
- if (top + tRect.height > window.innerHeight + window.scrollY) {
10594
- top = rect.top - tRect.height - 12 + window.scrollY;
10595
- }
10596
- tooltip.style.top = top + "px";
10597
- tooltip.style.left = left + "px";
10598
- });
10610
+ let frames = 0;
10611
+ const settle = () => {
10612
+ if (!this._active || this._currentTarget !== target) return;
10613
+ this._positionTooltip(target);
10614
+ if (frames++ < 30) requestAnimationFrame(settle);
10615
+ };
10616
+ requestAnimationFrame(settle);
10599
10617
  }
10600
10618
  document.dispatchEvent(new CustomEvent("spotlight:step", {
10601
10619
  detail: { index, step: index, total, data: step }
@@ -10636,6 +10654,7 @@ module.exports = __toCommonJS(index_exports);
10636
10654
  this._elements = {};
10637
10655
  this._steps = [];
10638
10656
  this._currentStep = 0;
10657
+ this._currentTarget = null;
10639
10658
  if (this._triggerElement && this._triggerElement.isConnected && typeof this._triggerElement.focus === "function") {
10640
10659
  this._triggerElement.focus();
10641
10660
  }