@vanduo-oss/framework 1.4.6 → 1.5.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.
@@ -1,4 +1,4 @@
1
- /*! Vanduo v1.4.6 | Built: 2026-06-13T10:32:26.875Z | git:82019ff | development */
1
+ /*! Vanduo v1.5.1 | Built: 2026-06-20T15:00:18.257Z | git:baf8178 | 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.1" : "0.0.0-dev";
205
205
  const hasOwn = Object.prototype.hasOwnProperty;
206
206
  const Vanduo2 = {
207
207
  version: VANDUO_VERSION,
@@ -7788,7 +7788,7 @@ module.exports = __toCommonJS(index_exports);
7788
7788
  setActive(card);
7789
7789
  };
7790
7790
  const onKeydown = function(e) {
7791
- if (e.key !== "ArrowLeft" && e.key !== "ArrowRight" && e.key !== "Home" && e.key !== "End") {
7791
+ if (e.key !== "ArrowLeft" && e.key !== "ArrowRight" && e.key !== "ArrowUp" && e.key !== "ArrowDown" && e.key !== "Home" && e.key !== "End") {
7792
7792
  return;
7793
7793
  }
7794
7794
  const cards = getCards().filter(function(c) {
@@ -7803,10 +7803,14 @@ module.exports = __toCommonJS(index_exports);
7803
7803
  });
7804
7804
  }
7805
7805
  if (idx < 0) idx = 0;
7806
- if (e.key === "ArrowLeft") {
7806
+ const isVertical = window.getComputedStyle(container).flexDirection === "column";
7807
+ if (!isVertical && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
7808
+ return;
7809
+ }
7810
+ if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
7807
7811
  e.preventDefault();
7808
7812
  setActive(cards[Math.max(0, idx - 1)]);
7809
- } else if (e.key === "ArrowRight") {
7813
+ } else if (e.key === "ArrowRight" || e.key === "ArrowDown") {
7810
7814
  e.preventDefault();
7811
7815
  setActive(cards[Math.min(cards.length - 1, idx + 1)]);
7812
7816
  } else if (e.key === "Home") {
@@ -10441,6 +10445,7 @@ module.exports = __toCommonJS(index_exports);
10441
10445
  _cleanup: [],
10442
10446
  _boundTriggers: /* @__PURE__ */ new WeakMap(),
10443
10447
  _triggerElement: null,
10448
+ _currentTarget: null,
10444
10449
  init: function(root) {
10445
10450
  const triggers = window.Vanduo.queryAll(root, "[data-vd-spotlight]");
10446
10451
  triggers.forEach((trigger) => {
@@ -10509,8 +10514,29 @@ module.exports = __toCommonJS(index_exports);
10509
10514
  document.addEventListener("keydown", escHandler);
10510
10515
  this._cleanup.push(() => document.removeEventListener("keydown", escHandler));
10511
10516
  overlay.addEventListener("click", () => this.stop());
10517
+ const reposition = () => {
10518
+ if (this._active && this._currentTarget) this._positionTooltip(this._currentTarget);
10519
+ };
10520
+ window.addEventListener("scroll", reposition, { passive: true });
10521
+ window.addEventListener("resize", reposition);
10522
+ this._cleanup.push(() => window.removeEventListener("scroll", reposition));
10523
+ this._cleanup.push(() => window.removeEventListener("resize", reposition));
10512
10524
  this._showStep(this._currentStep);
10513
10525
  },
10526
+ _positionTooltip: function(target) {
10527
+ const tooltip = this._elements.tooltip;
10528
+ if (!tooltip || !target || !target.isConnected) return;
10529
+ const rect = target.getBoundingClientRect();
10530
+ const tRect = tooltip.getBoundingClientRect();
10531
+ let top = rect.bottom + 12 + window.scrollY;
10532
+ let left = rect.left + (rect.width - tRect.width) / 2 + window.scrollX;
10533
+ left = Math.max(8, Math.min(left, window.innerWidth - tRect.width - 8));
10534
+ if (top + tRect.height > window.innerHeight + window.scrollY) {
10535
+ top = rect.top - tRect.height - 12 + window.scrollY;
10536
+ }
10537
+ tooltip.style.top = top + "px";
10538
+ tooltip.style.left = left + "px";
10539
+ },
10514
10540
  _showStep: function(index) {
10515
10541
  const step = this._steps[index];
10516
10542
  if (!step) return;
@@ -10583,19 +10609,15 @@ module.exports = __toCommonJS(index_exports);
10583
10609
  footer.appendChild(counter);
10584
10610
  footer.appendChild(actions);
10585
10611
  tooltip.appendChild(footer);
10612
+ this._currentTarget = target || null;
10586
10613
  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
- });
10614
+ let frames = 0;
10615
+ const settle = () => {
10616
+ if (!this._active || this._currentTarget !== target) return;
10617
+ this._positionTooltip(target);
10618
+ if (frames++ < 30) requestAnimationFrame(settle);
10619
+ };
10620
+ requestAnimationFrame(settle);
10599
10621
  }
10600
10622
  document.dispatchEvent(new CustomEvent("spotlight:step", {
10601
10623
  detail: { index, step: index, total, data: step }
@@ -10636,6 +10658,7 @@ module.exports = __toCommonJS(index_exports);
10636
10658
  this._elements = {};
10637
10659
  this._steps = [];
10638
10660
  this._currentStep = 0;
10661
+ this._currentTarget = null;
10639
10662
  if (this._triggerElement && this._triggerElement.isConnected && typeof this._triggerElement.focus === "function") {
10640
10663
  this._triggerElement.focus();
10641
10664
  }