@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.
package/dist/vanduo.js CHANGED
@@ -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
  (() => {
3
3
  // js/utils/lifecycle.js
4
4
  (function() {
@@ -176,7 +176,7 @@
176
176
  // js/vanduo.js
177
177
  (function() {
178
178
  "use strict";
179
- const VANDUO_VERSION = true ? "1.4.6" : "0.0.0-dev";
179
+ const VANDUO_VERSION = true ? "1.5.1" : "0.0.0-dev";
180
180
  const hasOwn = Object.prototype.hasOwnProperty;
181
181
  const Vanduo2 = {
182
182
  version: VANDUO_VERSION,
@@ -7763,7 +7763,7 @@
7763
7763
  setActive(card);
7764
7764
  };
7765
7765
  const onKeydown = function(e) {
7766
- if (e.key !== "ArrowLeft" && e.key !== "ArrowRight" && e.key !== "Home" && e.key !== "End") {
7766
+ if (e.key !== "ArrowLeft" && e.key !== "ArrowRight" && e.key !== "ArrowUp" && e.key !== "ArrowDown" && e.key !== "Home" && e.key !== "End") {
7767
7767
  return;
7768
7768
  }
7769
7769
  const cards = getCards().filter(function(c) {
@@ -7778,10 +7778,14 @@
7778
7778
  });
7779
7779
  }
7780
7780
  if (idx < 0) idx = 0;
7781
- if (e.key === "ArrowLeft") {
7781
+ const isVertical = window.getComputedStyle(container).flexDirection === "column";
7782
+ if (!isVertical && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
7783
+ return;
7784
+ }
7785
+ if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
7782
7786
  e.preventDefault();
7783
7787
  setActive(cards[Math.max(0, idx - 1)]);
7784
- } else if (e.key === "ArrowRight") {
7788
+ } else if (e.key === "ArrowRight" || e.key === "ArrowDown") {
7785
7789
  e.preventDefault();
7786
7790
  setActive(cards[Math.min(cards.length - 1, idx + 1)]);
7787
7791
  } else if (e.key === "Home") {
@@ -10416,6 +10420,7 @@
10416
10420
  _cleanup: [],
10417
10421
  _boundTriggers: /* @__PURE__ */ new WeakMap(),
10418
10422
  _triggerElement: null,
10423
+ _currentTarget: null,
10419
10424
  init: function(root) {
10420
10425
  const triggers = window.Vanduo.queryAll(root, "[data-vd-spotlight]");
10421
10426
  triggers.forEach((trigger) => {
@@ -10484,8 +10489,29 @@
10484
10489
  document.addEventListener("keydown", escHandler);
10485
10490
  this._cleanup.push(() => document.removeEventListener("keydown", escHandler));
10486
10491
  overlay.addEventListener("click", () => this.stop());
10492
+ const reposition = () => {
10493
+ if (this._active && this._currentTarget) this._positionTooltip(this._currentTarget);
10494
+ };
10495
+ window.addEventListener("scroll", reposition, { passive: true });
10496
+ window.addEventListener("resize", reposition);
10497
+ this._cleanup.push(() => window.removeEventListener("scroll", reposition));
10498
+ this._cleanup.push(() => window.removeEventListener("resize", reposition));
10487
10499
  this._showStep(this._currentStep);
10488
10500
  },
10501
+ _positionTooltip: function(target) {
10502
+ const tooltip = this._elements.tooltip;
10503
+ if (!tooltip || !target || !target.isConnected) return;
10504
+ const rect = target.getBoundingClientRect();
10505
+ const tRect = tooltip.getBoundingClientRect();
10506
+ let top = rect.bottom + 12 + window.scrollY;
10507
+ let left = rect.left + (rect.width - tRect.width) / 2 + window.scrollX;
10508
+ left = Math.max(8, Math.min(left, window.innerWidth - tRect.width - 8));
10509
+ if (top + tRect.height > window.innerHeight + window.scrollY) {
10510
+ top = rect.top - tRect.height - 12 + window.scrollY;
10511
+ }
10512
+ tooltip.style.top = top + "px";
10513
+ tooltip.style.left = left + "px";
10514
+ },
10489
10515
  _showStep: function(index) {
10490
10516
  const step = this._steps[index];
10491
10517
  if (!step) return;
@@ -10558,19 +10584,15 @@
10558
10584
  footer.appendChild(counter);
10559
10585
  footer.appendChild(actions);
10560
10586
  tooltip.appendChild(footer);
10587
+ this._currentTarget = target || null;
10561
10588
  if (target) {
10562
- requestAnimationFrame(() => {
10563
- const rect = target.getBoundingClientRect();
10564
- const tRect = tooltip.getBoundingClientRect();
10565
- let top = rect.bottom + 12 + window.scrollY;
10566
- let left = rect.left + (rect.width - tRect.width) / 2 + window.scrollX;
10567
- left = Math.max(8, Math.min(left, window.innerWidth - tRect.width - 8));
10568
- if (top + tRect.height > window.innerHeight + window.scrollY) {
10569
- top = rect.top - tRect.height - 12 + window.scrollY;
10570
- }
10571
- tooltip.style.top = top + "px";
10572
- tooltip.style.left = left + "px";
10573
- });
10589
+ let frames = 0;
10590
+ const settle = () => {
10591
+ if (!this._active || this._currentTarget !== target) return;
10592
+ this._positionTooltip(target);
10593
+ if (frames++ < 30) requestAnimationFrame(settle);
10594
+ };
10595
+ requestAnimationFrame(settle);
10574
10596
  }
10575
10597
  document.dispatchEvent(new CustomEvent("spotlight:step", {
10576
10598
  detail: { index, step: index, total, data: step }
@@ -10611,6 +10633,7 @@
10611
10633
  this._elements = {};
10612
10634
  this._steps = [];
10613
10635
  this._currentStep = 0;
10636
+ this._currentTarget = null;
10614
10637
  if (this._triggerElement && this._triggerElement.isConnected && typeof this._triggerElement.focus === "function") {
10615
10638
  this._triggerElement.focus();
10616
10639
  }