@1337exp/taoui 1.10.3 → 1.10.4

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/index.d.ts CHANGED
@@ -1545,7 +1545,7 @@ peek?: number;
1545
1545
  /** How many slides fit in the viewport. 5 = product strip. 1 = one card. */
1546
1546
  perView?: number;
1547
1547
  controls?: boolean;
1548
- /** Interval in ms. 0 — off. Pauses on hover, focus, drag, and reduced motion. */
1548
+ /** Interval in ms. 0 — off. Pauses on hover, keyboard focus, drag, and reduced motion. */
1549
1549
  autoplay?: number;
1550
1550
  loop?: boolean;
1551
1551
  /** Pips under the track: one per snap. Inactive are dots, the current one stretches into a pill. */
@@ -1578,7 +1578,7 @@ peek?: number;
1578
1578
  /** How many slides fit in the viewport. 5 = product strip. 1 = one card. */
1579
1579
  perView?: number;
1580
1580
  controls?: boolean;
1581
- /** Interval in ms. 0 — off. Pauses on hover, focus, drag, and reduced motion. */
1581
+ /** Interval in ms. 0 — off. Pauses on hover, keyboard focus, drag, and reduced motion. */
1582
1582
  autoplay?: number;
1583
1583
  loop?: boolean;
1584
1584
  /** Pips under the track: one per snap. Inactive are dots, the current one stretches into a pill. */
package/dist/index.mjs CHANGED
@@ -7256,6 +7256,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
7256
7256
  let dragMoved = 0;
7257
7257
  let dragPointer = -1;
7258
7258
  let scrollFrame = 0;
7259
+ let focusFrame = 0;
7259
7260
  let autoplayTimer = 0;
7260
7261
  const step = computed(() => Math.max(1, Math.round(props.perView)));
7261
7262
  const lastIndex = computed(() => Math.max(count.value - step.value, 0));
@@ -7364,18 +7365,32 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
7364
7365
  hoverPaused.value = false;
7365
7366
  syncAutoplay();
7366
7367
  }
7367
- function onFocusIn() {
7368
- focusPaused.value = true;
7369
- stopAutoplay();
7368
+ function hasKeyboardFocus(root) {
7369
+ const active = document.activeElement;
7370
+ if (!(active instanceof HTMLElement) || !root.contains(active)) {
7371
+ return false;
7372
+ }
7373
+ try {
7374
+ return active.matches(":focus-visible");
7375
+ } catch {
7376
+ return true;
7377
+ }
7370
7378
  }
7371
- function onFocusOut(event) {
7379
+ function scheduleFocusPause(event) {
7372
7380
  const root = event.currentTarget;
7373
- const next = event.relatedTarget;
7374
- if (next && root.contains(next)) {
7375
- return;
7376
- }
7377
- focusPaused.value = false;
7378
- syncAutoplay();
7381
+ cancelAnimationFrame(focusFrame);
7382
+ focusFrame = requestAnimationFrame(() => {
7383
+ if (!track.value) {
7384
+ return;
7385
+ }
7386
+ const next = hasKeyboardFocus(root);
7387
+ focusPaused.value = next;
7388
+ if (next) {
7389
+ stopAutoplay();
7390
+ return;
7391
+ }
7392
+ syncAutoplay();
7393
+ });
7379
7394
  }
7380
7395
  function onScroll() {
7381
7396
  if (dragging.value) {
@@ -7512,6 +7527,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
7512
7527
  onBeforeUnmount(() => {
7513
7528
  endDrag();
7514
7529
  cancelAnimationFrame(scrollFrame);
7530
+ cancelAnimationFrame(focusFrame);
7515
7531
  stopAutoplay();
7516
7532
  document.removeEventListener("visibilitychange", onVisibilityChange);
7517
7533
  window.removeEventListener("blur", onWindowBlur);
@@ -7523,8 +7539,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
7523
7539
  style: normalizeStyle(trackStyle.value),
7524
7540
  onMouseenter: onMouseEnter,
7525
7541
  onMouseleave: onMouseLeave,
7526
- onFocusin: onFocusIn,
7527
- onFocusout: onFocusOut
7542
+ onFocusin: scheduleFocusPause,
7543
+ onFocusout: scheduleFocusPause
7528
7544
  }, [
7529
7545
  createElementVNode("div", _hoisted_1$4, [
7530
7546
  renderSlot(_ctx.$slots, "prev", {
@@ -7647,7 +7663,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
7647
7663
  };
7648
7664
  }
7649
7665
  });
7650
- const TaoCarousel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-bc396e5d"]]);
7666
+ const TaoCarousel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-b4139b57"]]);
7651
7667
  const _hoisted_1$3 = ["aria-label"];
7652
7668
  const _hoisted_2$2 = ["aria-label"];
7653
7669
  const _hoisted_3$2 = {