@tensor_1/react 2.59.0 → 2.62.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.
package/dist/emoji.cjs CHANGED
@@ -46,7 +46,7 @@ __export(emoji_exports, {
46
46
  module.exports = __toCommonJS(emoji_exports);
47
47
 
48
48
  // src/components/EmojiPicker.tsx
49
- var import_react4 = require("react");
49
+ var import_react5 = require("react");
50
50
 
51
51
  // src/cx.ts
52
52
  function cx(...args) {
@@ -54,7 +54,7 @@ function cx(...args) {
54
54
  }
55
55
 
56
56
  // src/components/Popover.tsx
57
- var import_react2 = require("react");
57
+ var import_react3 = require("react");
58
58
 
59
59
  // src/hooks/useAnchoredPosition.ts
60
60
  var import_react = require("react");
@@ -379,6 +379,14 @@ function useAnchoredPosition(anchor, floatingRef, { open, placement = "bottom-st
379
379
  return reposition;
380
380
  }
381
381
 
382
+ // src/hooks/useReducedMotion.ts
383
+ var import_react2 = require("react");
384
+ var QUERY = "(prefers-reduced-motion: reduce)";
385
+ function prefersReducedMotion() {
386
+ if (typeof document !== "undefined" && document.documentElement.getAttribute("data-motion") === "reduce") return true;
387
+ return typeof matchMedia !== "undefined" && matchMedia(QUERY).matches;
388
+ }
389
+
382
390
  // src/motion.ts
383
391
  var KEY_OPENED = "data-uix-key-opened";
384
392
  var keyboard = false;
@@ -405,10 +413,106 @@ function tokenMs(name, fallback, el) {
405
413
  if (!m) return fallback;
406
414
  return m[2] === "s" ? Number(m[1]) * 1e3 : Number(m[1]);
407
415
  }
416
+ function tokenPx(name, fallback) {
417
+ if (typeof window === "undefined" || typeof document === "undefined") return fallback;
418
+ const raw = window.getComputedStyle(document.documentElement).getPropertyValue(name).trim();
419
+ const m = /^(-?\d*\.?\d+)px$/.exec(raw);
420
+ return m ? Number(m[1]) : fallback;
421
+ }
422
+ function bezier(x1, y1, x2, y2) {
423
+ const at = (a, b, t) => 3 * a * t * (1 - t) ** 2 + 3 * b * t * t * (1 - t) + t ** 3;
424
+ const slope = (a, b, t) => 3 * a * (1 - t) ** 2 + 6 * (b - a) * t * (1 - t) + 3 * (1 - b) * t * t;
425
+ return (x) => {
426
+ if (x <= 0) return 0;
427
+ if (x >= 1) return 1;
428
+ let t = x;
429
+ for (let i = 0; i < 6; i++) {
430
+ const d = slope(x1, x2, t);
431
+ if (Math.abs(d) < 1e-6) break;
432
+ t -= (at(x1, x2, t) - x) / d;
433
+ }
434
+ if (t < 0 || t > 1 || Math.abs(at(x1, x2, t) - x) > 1e-4) {
435
+ let lo = 0;
436
+ let hi = 1;
437
+ t = x;
438
+ for (let i = 0; i < 30; i++) {
439
+ if (at(x1, x2, t) < x) lo = t;
440
+ else hi = t;
441
+ t = (lo + hi) / 2;
442
+ }
443
+ }
444
+ return at(y1, y2, t);
445
+ };
446
+ }
447
+ function tokenEase(name) {
448
+ const fallback = bezier(0.23, 1, 0.32, 1);
449
+ if (typeof window === "undefined" || typeof document === "undefined") return fallback;
450
+ const raw = window.getComputedStyle(document.documentElement).getPropertyValue(name).trim();
451
+ const cb = /^cubic-bezier\(([^)]+)\)$/.exec(raw);
452
+ if (cb) {
453
+ const [a, b, c, d] = cb[1].split(",").map(Number);
454
+ if ([a, b, c, d].every(Number.isFinite)) return bezier(a, b, c, d);
455
+ }
456
+ const lin = /^linear\(([^)]+)\)$/.exec(raw);
457
+ if (lin) {
458
+ const pts = lin[1].split(",").map(Number);
459
+ if (pts.length > 1 && pts.every(Number.isFinite)) {
460
+ return (x) => {
461
+ if (x <= 0) return pts[0];
462
+ if (x >= 1) return pts[pts.length - 1];
463
+ const at = x * (pts.length - 1);
464
+ const i = Math.floor(at);
465
+ return pts[i] + (pts[i + 1] - pts[i]) * (at - i);
466
+ };
467
+ }
468
+ }
469
+ return fallback;
470
+ }
471
+ function blurIn(elements, options) {
472
+ const els = elements.slice();
473
+ if (typeof window === "undefined" || els.length === 0 || options.from <= 0 || options.duration <= 0) return () => {
474
+ };
475
+ const { from, duration, ease, delay = () => 0, leave = false, property } = options;
476
+ const write = (el, r) => {
477
+ if (property) {
478
+ if (r > 0.05) el.style.setProperty(property, `${r.toFixed(2)}px`);
479
+ else el.style.removeProperty(property);
480
+ } else el.style.filter = r > 0.05 ? `blur(${r.toFixed(2)}px)` : "";
481
+ };
482
+ const paint = (el, p) => write(el, leave ? from * ease(p) : from * (1 - ease(p)));
483
+ els.forEach((el) => paint(el, 0));
484
+ const view = window;
485
+ const start = view.performance.now();
486
+ let frame = 0;
487
+ let stopped = false;
488
+ const tick = () => {
489
+ if (stopped) return;
490
+ if (prefersReducedMotion()) {
491
+ stopped = true;
492
+ els.forEach((el) => write(el, 0));
493
+ return;
494
+ }
495
+ const now = view.performance.now();
496
+ let busy = false;
497
+ els.forEach((el, i) => {
498
+ const p = Math.min(1, Math.max(0, (now - start - delay(i)) / duration));
499
+ if (p < 1) busy = true;
500
+ paint(el, p);
501
+ });
502
+ if (busy) frame = view.requestAnimationFrame(tick);
503
+ else if (leave) els.forEach((el) => write(el, 0));
504
+ };
505
+ frame = view.requestAnimationFrame(tick);
506
+ return () => {
507
+ stopped = true;
508
+ view.cancelAnimationFrame(frame);
509
+ els.forEach((el) => write(el, 0));
510
+ };
511
+ }
408
512
 
409
513
  // src/components/Popover.tsx
410
514
  var import_jsx_runtime = require("react/jsx-runtime");
411
- var useIsomorphicLayoutEffect2 = typeof document !== "undefined" ? import_react2.useLayoutEffect : import_react2.useEffect;
515
+ var useIsomorphicLayoutEffect2 = typeof document !== "undefined" ? import_react3.useLayoutEffect : import_react3.useEffect;
412
516
  var PLACING = "data-uix-placing";
413
517
  var isPopoverOpen = (el) => {
414
518
  try {
@@ -439,10 +543,10 @@ function Popover({
439
543
  const popover = popoverProp ?? (hover ? "manual" : "auto");
440
544
  const openDelay = typeof openOnHover === "object" ? openOnHover.openDelay ?? 300 : 300;
441
545
  const closeDelay = typeof openOnHover === "object" ? openOnHover.closeDelay ?? 150 : 150;
442
- const ref = (0, import_react2.useRef)(null);
443
- const [open, setOpen] = (0, import_react2.useState)(false);
444
- const openRef = (0, import_react2.useRef)(false);
445
- const onAnchorHiddenRef = (0, import_react2.useRef)(onAnchorHidden);
546
+ const ref = (0, import_react3.useRef)(null);
547
+ const [open, setOpen] = (0, import_react3.useState)(false);
548
+ const openRef = (0, import_react3.useRef)(false);
549
+ const onAnchorHiddenRef = (0, import_react3.useRef)(onAnchorHidden);
446
550
  onAnchorHiddenRef.current = onAnchorHidden;
447
551
  const popoverAttr = { popover };
448
552
  const reposition = useAnchoredPosition(anchor ?? null, ref, {
@@ -459,15 +563,18 @@ function Popover({
459
563
  el.hidePopover();
460
564
  } : void 0
461
565
  });
462
- (0, import_react2.useEffect)(() => {
566
+ (0, import_react3.useEffect)(() => {
463
567
  watchInputModality();
464
568
  const el = ref.current;
465
569
  if (!el) return;
466
- const mark = () => markKeyOpened(el);
570
+ const mark = () => {
571
+ if (el.hasAttribute("data-uix-animate-keys")) el.removeAttribute("data-uix-key-opened");
572
+ else markKeyOpened(el);
573
+ };
467
574
  el.addEventListener("beforetoggle", mark);
468
575
  return () => el.removeEventListener("beforetoggle", mark);
469
576
  }, []);
470
- (0, import_react2.useEffect)(() => {
577
+ (0, import_react3.useEffect)(() => {
471
578
  const el = ref.current;
472
579
  if (!el || !anchor) return;
473
580
  const hold = (event) => {
@@ -500,7 +607,7 @@ function Popover({
500
607
  el.removeAttribute(PLACING);
501
608
  };
502
609
  }, [anchor, reposition]);
503
- (0, import_react2.useEffect)(() => {
610
+ (0, import_react3.useEffect)(() => {
504
611
  const el = ref.current;
505
612
  const anchorEl = resolveAnchor(anchor);
506
613
  if (!hover || !el || !anchorEl) return;
@@ -687,7 +794,7 @@ function formatLabel(template, values) {
687
794
  }
688
795
 
689
796
  // src/components/EmojiGlyph.tsx
690
- var import_react3 = require("react");
797
+ var import_react4 = require("react");
691
798
 
692
799
  // src/emoji-image.ts
693
800
  var warned = /* @__PURE__ */ new Set();
@@ -755,12 +862,12 @@ function canRenderEmoji(emoji) {
755
862
  // src/components/EmojiGlyph.tsx
756
863
  var import_jsx_runtime2 = require("react/jsx-runtime");
757
864
  function useEmojiRenderer(emojiImageBaseUrl) {
758
- const base = (0, import_react3.useMemo)(() => normalizeEmojiImageBaseUrl(emojiImageBaseUrl), [emojiImageBaseUrl]);
759
- const [mounted, setMounted] = (0, import_react3.useState)(false);
760
- (0, import_react3.useEffect)(() => {
865
+ const base = (0, import_react4.useMemo)(() => normalizeEmojiImageBaseUrl(emojiImageBaseUrl), [emojiImageBaseUrl]);
866
+ const [mounted, setMounted] = (0, import_react4.useState)(false);
867
+ (0, import_react4.useEffect)(() => {
761
868
  if (base) setMounted(true);
762
869
  }, [base]);
763
- return (0, import_react3.useCallback)((emoji) => {
870
+ return (0, import_react4.useCallback)((emoji) => {
764
871
  if (!base || !mounted || canRenderEmoji(emoji)) return emoji;
765
872
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { className: "uix-emoji-img", src: emojiImageSrc(base, emoji), alt: emoji, draggable: false, decoding: "async" });
766
873
  }, [base, mounted]);
@@ -779,7 +886,7 @@ var DEFAULT_EMOJI_PICKER_LABELS = {
779
886
  loadFailed: "Emoji could not be loaded."
780
887
  };
781
888
  var EMOJI_GRID_COLUMNS = 8;
782
- var useIsomorphicLayoutEffect3 = typeof document !== "undefined" ? import_react4.useLayoutEffect : import_react4.useEffect;
889
+ var useIsomorphicLayoutEffect3 = typeof document !== "undefined" ? import_react5.useLayoutEffect : import_react5.useEffect;
783
890
  function revealInGrid(grid, cell) {
784
891
  const g = grid.getBoundingClientRect();
785
892
  const c = cell.getBoundingClientRect();
@@ -802,20 +909,20 @@ function EmojiPicker({
802
909
  }) {
803
910
  const renderEmoji = useEmojiRenderer(emojiImageBaseUrl);
804
911
  const labels = { ...DEFAULT_EMOJI_PICKER_LABELS, ...labelOverrides };
805
- const id = (0, import_react4.useId)();
912
+ const id = (0, import_react5.useId)();
806
913
  const popoverId = `${id}-picker`;
807
- const anchorRef = (0, import_react4.useRef)(null);
808
- const searchRef = (0, import_react4.useRef)(null);
809
- const gridRef = (0, import_react4.useRef)(null);
810
- const pointerWasOpen = (0, import_react4.useRef)(null);
811
- const closedByAnchor = (0, import_react4.useRef)(false);
812
- const pendingJump = (0, import_react4.useRef)(null);
813
- const [open, setOpen] = (0, import_react4.useState)(false);
814
- const [data, setData] = (0, import_react4.useState)(null);
815
- const [failed, setFailed] = (0, import_react4.useState)(false);
816
- const [query, setQuery] = (0, import_react4.useState)("");
817
- const [recent, setRecent] = (0, import_react4.useState)([]);
818
- const [active, setActive] = (0, import_react4.useState)(0);
914
+ const anchorRef = (0, import_react5.useRef)(null);
915
+ const searchRef = (0, import_react5.useRef)(null);
916
+ const gridRef = (0, import_react5.useRef)(null);
917
+ const pointerWasOpen = (0, import_react5.useRef)(null);
918
+ const closedByAnchor = (0, import_react5.useRef)(false);
919
+ const pendingJump = (0, import_react5.useRef)(null);
920
+ const [open, setOpen] = (0, import_react5.useState)(false);
921
+ const [data, setData] = (0, import_react5.useState)(null);
922
+ const [failed, setFailed] = (0, import_react5.useState)(false);
923
+ const [query, setQuery] = (0, import_react5.useState)("");
924
+ const [recent, setRecent] = (0, import_react5.useState)([]);
925
+ const [active, setActive] = (0, import_react5.useState)(0);
819
926
  const popoverEl = () => typeof document === "undefined" ? null : document.getElementById(popoverId);
820
927
  const isOpen = (el) => {
821
928
  try {
@@ -824,7 +931,7 @@ function EmojiPicker({
824
931
  return false;
825
932
  }
826
933
  };
827
- (0, import_react4.useEffect)(() => {
934
+ (0, import_react5.useEffect)(() => {
828
935
  const el = popoverEl();
829
936
  if (!el) return;
830
937
  const onToggle = (event) => {
@@ -848,7 +955,7 @@ function EmojiPicker({
848
955
  el.addEventListener("toggle", onToggle);
849
956
  return () => el.removeEventListener("toggle", onToggle);
850
957
  }, [popoverId, recentStorageKey, onOpenChange]);
851
- (0, import_react4.useEffect)(() => {
958
+ (0, import_react5.useEffect)(() => {
852
959
  if (!open || data?.locale === locale) return;
853
960
  let live = true;
854
961
  setFailed(false);
@@ -872,7 +979,7 @@ function EmojiPicker({
872
979
  const el = popoverEl();
873
980
  if (el && isOpen(el)) el.hidePopover();
874
981
  };
875
- const browseSections = (0, import_react4.useMemo)(() => {
982
+ const browseSections = (0, import_react5.useMemo)(() => {
876
983
  const list = [];
877
984
  if (quickPicks?.length) list.push({ key: "quick", title: labels.quickPicks, emojis: [...new Set(quickPicks)] });
878
985
  if (recent.length) list.push({ key: "recent", title: labels.recent, emojis: recent });
@@ -883,12 +990,12 @@ function EmojiPicker({
883
990
  }
884
991
  return list;
885
992
  }, [data, quickPicks, recent, labels.quickPicks, labels.recent]);
886
- const sections = (0, import_react4.useMemo)(() => {
993
+ const sections = (0, import_react5.useMemo)(() => {
887
994
  if (!query.trim()) return browseSections;
888
995
  return data ? [{ key: "results", title: labels.search, emojis: searchEmoji(data, query).map((e) => e.emoji) }] : [];
889
996
  }, [query, data, browseSections, labels.search]);
890
- const flat = (0, import_react4.useMemo)(() => sections.flatMap((s) => s.emojis), [sections]);
891
- const sectionStart = (0, import_react4.useMemo)(() => {
997
+ const flat = (0, import_react5.useMemo)(() => sections.flatMap((s) => s.emojis), [sections]);
998
+ const sectionStart = (0, import_react5.useMemo)(() => {
892
999
  const starts = /* @__PURE__ */ new Map();
893
1000
  let at = 0;
894
1001
  for (const section of sections) {
@@ -903,7 +1010,7 @@ function EmojiPicker({
903
1010
  onSelect(emoji);
904
1011
  hide();
905
1012
  };
906
- const focusCell = (0, import_react4.useCallback)((index, reveal = true) => {
1013
+ const focusCell = (0, import_react5.useCallback)((index, reveal = true) => {
907
1014
  setActive(index);
908
1015
  const find = () => gridRef.current?.querySelector(`[data-emoji-index="${index}"]`);
909
1016
  const move = (cell2) => {
@@ -975,8 +1082,8 @@ function EmojiPicker({
975
1082
  if (isOpen(el)) el.hidePopover();
976
1083
  else el.showPopover();
977
1084
  };
978
- const triggerProps = (0, import_react4.isValidElement)(trigger) ? trigger.props : {};
979
- const triggerEl = (0, import_react4.isValidElement)(trigger) ? (0, import_react4.cloneElement)(trigger, {
1085
+ const triggerProps = (0, import_react5.isValidElement)(trigger) ? trigger.props : {};
1086
+ const triggerEl = (0, import_react5.isValidElement)(trigger) ? (0, import_react5.cloneElement)(trigger, {
980
1087
  "aria-haspopup": "dialog",
981
1088
  "aria-expanded": open,
982
1089
  "aria-controls": popoverId,
@@ -1135,10 +1242,11 @@ function EditorIcon({ name, ...props }) {
1135
1242
  }
1136
1243
 
1137
1244
  // src/components/Tooltip.tsx
1138
- var import_react6 = require("react");
1245
+ var import_react7 = require("react");
1246
+ var import_react_dom = require("react-dom");
1139
1247
 
1140
1248
  // src/components/Kbd.tsx
1141
- var import_react5 = require("react");
1249
+ var import_react6 = require("react");
1142
1250
  var import_jsx_runtime5 = require("react/jsx-runtime");
1143
1251
  var KEYS = {
1144
1252
  Mod: { mac: ["\u2318", "Command"], other: ["Ctrl", "Control"] },
@@ -1168,7 +1276,7 @@ var noSubscription = () => () => {
1168
1276
  };
1169
1277
  var serverPlatform = () => "other";
1170
1278
  function useKbdPlatform(platform) {
1171
- const detected = (0, import_react5.useSyncExternalStore)(noSubscription, detectPlatform, serverPlatform);
1279
+ const detected = (0, import_react6.useSyncExternalStore)(noSubscription, detectPlatform, serverPlatform);
1172
1280
  return platform ?? detected;
1173
1281
  }
1174
1282
  var isKeyShortcut = (value) => Array.isArray(value) && value.length > 0 && value.every((key) => typeof key === "string");
@@ -1185,22 +1293,97 @@ function KbdCombo({ keys, platform, keyLabels, className, ...props }) {
1185
1293
 
1186
1294
  // src/components/Tooltip.tsx
1187
1295
  var import_jsx_runtime6 = require("react/jsx-runtime");
1188
- var group = { open: 0, lastClosed: -Infinity, current: null };
1189
- var useIsomorphicLayoutEffect4 = typeof document !== "undefined" ? import_react6.useLayoutEffect : import_react6.useEffect;
1296
+ var group = { open: 0, lastClosed: -Infinity, current: null, bubble: null };
1297
+ var MORPH_FALLBACK_MS = 1e3;
1298
+ var MORPH_MAX_TRAVEL_PX = 320;
1299
+ var useIsomorphicLayoutEffect4 = typeof document !== "undefined" ? import_react7.useLayoutEffect : import_react7.useEffect;
1190
1300
  function Tooltip({ label, content, placement = "top", shortcut, className, children, ...props }) {
1191
- const triggerRef = (0, import_react6.useRef)(null);
1192
- const bubbleRef = (0, import_react6.useRef)(null);
1193
- const closeTimer = (0, import_react6.useRef)(null);
1194
- const openTimer = (0, import_react6.useRef)(null);
1195
- const shown = (0, import_react6.useRef)(false);
1196
- const [open, setOpen] = (0, import_react6.useState)(false);
1197
- const id = (0, import_react6.useId)();
1301
+ const triggerRef = (0, import_react7.useRef)(null);
1302
+ const bubbleRef = (0, import_react7.useRef)(null);
1303
+ const closeTimer = (0, import_react7.useRef)(null);
1304
+ const openTimer = (0, import_react7.useRef)(null);
1305
+ const shown = (0, import_react7.useRef)(false);
1306
+ const morphFrom = (0, import_react7.useRef)(null);
1307
+ const [open, setOpen] = (0, import_react7.useState)(false);
1308
+ const id = (0, import_react7.useId)();
1198
1309
  const platform = useKbdPlatform();
1199
- const childShortcut = (0, import_react6.isValidElement)(children) ? children.props.shortcut : void 0;
1310
+ const childShortcut = (0, import_react7.isValidElement)(children) ? children.props.shortcut : void 0;
1200
1311
  const own = shortcut ?? (isKeyShortcut(childShortcut) ? childShortcut : void 0);
1201
1312
  const keys = own && own.length > 0 ? own : null;
1202
1313
  useAnchoredPosition(triggerRef, bubbleRef, { open, placement, offset: 6 });
1203
- (0, import_react6.useEffect)(() => {
1314
+ useIsomorphicLayoutEffect4(() => {
1315
+ const from = morphFrom.current;
1316
+ const b = bubbleRef.current;
1317
+ morphFrom.current = null;
1318
+ if (!open || !from || !b || prefersReducedMotion()) return void 0;
1319
+ const to = b.getBoundingClientRect();
1320
+ if (!to.width || !to.height) return void 0;
1321
+ const was = from.rect;
1322
+ const dx = was.left + was.width / 2 - (to.left + to.width / 2);
1323
+ const dy = was.top + was.height / 2 - (to.top + to.height / 2);
1324
+ if (Math.hypot(dx, dy) > MORPH_MAX_TRAVEL_PX) return void 0;
1325
+ const alongX = Math.abs(dx) >= Math.abs(dy);
1326
+ const way = Math.hypot(dx, dy) < 0.5 ? 0 : -Math.sign(alongX ? dx : dy);
1327
+ b.setAttribute("data-uix-instant", "");
1328
+ b.setAttribute("data-morph", "");
1329
+ b.style.setProperty("--uix-swap-x", String(alongX ? way : 0));
1330
+ b.style.setProperty("--uix-swap-y", String(alongX ? 0 : way));
1331
+ b.style.transform = `translate(${dx}px, ${dy}px)`;
1332
+ b.style.setProperty("--uix-morph-sx", String(was.width / to.width));
1333
+ b.style.setProperty("--uix-morph-sy", String(was.height / to.height));
1334
+ const content2 = b.querySelector(".uix-tooltip__content");
1335
+ const cs = window.getComputedStyle(b);
1336
+ const px = parseFloat(cs.paddingLeft) || 0;
1337
+ const py = parseFloat(cs.paddingTop) || 0;
1338
+ const insetY = (to.height - was.height) / 2;
1339
+ const insetX = (to.width - was.width) / 2;
1340
+ if (content2) content2.style.clipPath = `inset(${insetY - py}px ${insetX - px}px)`;
1341
+ let leaving = null;
1342
+ if (from.label) {
1343
+ leaving = document.createElement("span");
1344
+ leaving.className = "uix-tooltip__content uix-tooltip__content--leaving";
1345
+ leaving.setAttribute("aria-hidden", "true");
1346
+ const old = from.label.cloneNode(true);
1347
+ for (const el of [old, ...Array.from(old.querySelectorAll("[id]"))]) el.removeAttribute("id");
1348
+ leaving.appendChild(old);
1349
+ leaving.style.clipPath = `inset(${insetY}px ${insetX}px)`;
1350
+ b.appendChild(leaving);
1351
+ }
1352
+ void b.offsetWidth;
1353
+ b.removeAttribute("data-uix-instant");
1354
+ b.setAttribute("data-morphing", "");
1355
+ b.style.transform = "";
1356
+ b.style.removeProperty("--uix-morph-sx");
1357
+ b.style.removeProperty("--uix-morph-sy");
1358
+ if (content2) content2.style.clipPath = `inset(${-py}px ${-px}px)`;
1359
+ if (leaving) leaving.style.clipPath = "inset(0px)";
1360
+ const blur = tokenPx("--uix-swap-blur", 6);
1361
+ const label2 = content2?.querySelector(".uix-tooltip__label");
1362
+ const stopIn = label2 ? blurIn([label2], { from: blur, duration: tokenMs("--uix-dur-swap-in", 340), ease: tokenEase("--uix-ease-enter") }) : () => {
1363
+ };
1364
+ const oldLabel = leaving?.firstElementChild instanceof HTMLElement ? leaving.firstElementChild : null;
1365
+ const stopOut = oldLabel ? blurIn([oldLabel], { from: blur, duration: tokenMs("--uix-dur-swap-out", 130), ease: tokenEase("--uix-ease-leave"), leave: true }) : () => {
1366
+ };
1367
+ const end = () => {
1368
+ clearTimeout(timer);
1369
+ stopIn();
1370
+ stopOut();
1371
+ b.removeEventListener("transitionend", onEnd);
1372
+ b.removeAttribute("data-morph");
1373
+ b.removeAttribute("data-morphing");
1374
+ b.style.removeProperty("--uix-swap-x");
1375
+ b.style.removeProperty("--uix-swap-y");
1376
+ if (content2) content2.style.clipPath = "";
1377
+ leaving?.remove();
1378
+ };
1379
+ const onEnd = (event) => {
1380
+ if (event.target === b && !event.pseudoElement && event.propertyName === "transform") end();
1381
+ };
1382
+ b.addEventListener("transitionend", onEnd);
1383
+ const timer = setTimeout(end, MORPH_FALLBACK_MS);
1384
+ return end;
1385
+ }, [open]);
1386
+ (0, import_react7.useEffect)(() => {
1204
1387
  watchInputModality();
1205
1388
  }, []);
1206
1389
  const cancelClose = () => {
@@ -1215,13 +1398,17 @@ function Tooltip({ label, content, placement = "top", shortcut, className, child
1215
1398
  openTimer.current = null;
1216
1399
  }
1217
1400
  };
1218
- const reveal = (instant) => {
1401
+ const reveal = (handOver) => {
1219
1402
  cancelOpen();
1403
+ const neighbour = group.current && group.current !== self && group.bubble?.matches(":popover-open") ? group.bubble : null;
1404
+ const rect = neighbour?.getBoundingClientRect();
1405
+ morphFrom.current = handOver && neighbour && rect && rect.width > 0 ? { rect, label: neighbour.querySelector(".uix-tooltip__content:not(.uix-tooltip__content--leaving) > .uix-tooltip__label") } : null;
1220
1406
  if (group.current && group.current !== self) group.current.current(true);
1221
1407
  group.current = self;
1408
+ group.bubble = bubbleRef.current;
1222
1409
  const b = bubbleRef.current;
1223
1410
  if (b && !b.matches(":popover-open")) {
1224
- b.toggleAttribute("data-uix-instant", instant);
1411
+ b.toggleAttribute("data-uix-instant", handOver && !!neighbour);
1225
1412
  markKeyOpened(b);
1226
1413
  try {
1227
1414
  b.showPopover();
@@ -1232,14 +1419,14 @@ function Tooltip({ label, content, placement = "top", shortcut, className, child
1232
1419
  shown.current = true;
1233
1420
  group.open += 1;
1234
1421
  }
1235
- setOpen(true);
1422
+ (0, import_react_dom.flushSync)(() => setOpen(true));
1236
1423
  };
1237
1424
  const show = (via) => {
1238
1425
  cancelClose();
1239
- if (shown.current) return;
1426
+ if (shown.current || !hasText) return;
1240
1427
  const warm = group.open > 0 || performance.now() - group.lastClosed < tokenMs("--uix-delay-tooltip-skip", 300);
1241
1428
  if (via === "focus" || warm) {
1242
- reveal(via === "pointer");
1429
+ reveal(via === "pointer" && group.open > 0);
1243
1430
  return;
1244
1431
  }
1245
1432
  if (openTimer.current == null) openTimer.current = window.setTimeout(() => reveal(false), tokenMs("--uix-delay-tooltip", 400));
@@ -1260,10 +1447,15 @@ function Tooltip({ label, content, placement = "top", shortcut, className, child
1260
1447
  group.open -= 1;
1261
1448
  group.lastClosed = performance.now();
1262
1449
  }
1263
- if (group.current === self) group.current = null;
1450
+ if (group.current === self) {
1451
+ group.current = null;
1452
+ group.bubble = null;
1453
+ }
1454
+ morphFrom.current = null;
1455
+ b?.querySelector(".uix-tooltip__content--leaving")?.remove();
1264
1456
  setOpen(false);
1265
1457
  };
1266
- const self = (0, import_react6.useRef)(hide);
1458
+ const self = (0, import_react7.useRef)(hide);
1267
1459
  self.current = hide;
1268
1460
  const scheduleHide = () => {
1269
1461
  cancelClose();
@@ -1274,7 +1466,7 @@ function Tooltip({ label, content, placement = "top", shortcut, className, child
1274
1466
  } catch {
1275
1467
  }
1276
1468
  hide();
1277
- }, 100);
1469
+ }, tokenMs("--uix-delay-tooltip-skip", 300));
1278
1470
  };
1279
1471
  useIsomorphicLayoutEffect4(() => {
1280
1472
  if (!open) return void 0;
@@ -1282,12 +1474,12 @@ function Tooltip({ label, content, placement = "top", shortcut, className, child
1282
1474
  if (e.key !== "Escape") return;
1283
1475
  e.preventDefault();
1284
1476
  e.stopPropagation();
1285
- hide();
1477
+ hide(true);
1286
1478
  };
1287
1479
  document.addEventListener("keydown", onKey, true);
1288
1480
  return () => document.removeEventListener("keydown", onKey, true);
1289
1481
  }, [open]);
1290
- (0, import_react6.useEffect)(() => () => {
1482
+ (0, import_react7.useEffect)(() => () => {
1291
1483
  if (closeTimer.current != null) clearTimeout(closeTimer.current);
1292
1484
  if (openTimer.current != null) clearTimeout(openTimer.current);
1293
1485
  if (shown.current) {
@@ -1306,9 +1498,10 @@ function Tooltip({ label, content, placement = "top", shortcut, className, child
1306
1498
  }, []);
1307
1499
  const bubbleAttr = { popover: "manual" };
1308
1500
  const text = content ?? label;
1501
+ const hasText = keys != null || text != null && text !== "";
1309
1502
  const description = keys ? [text != null ? `${id}-text` : null, `${id}-keys`].filter(Boolean).join(" ") : id;
1310
- const single = (0, import_react6.isValidElement)(children);
1311
- const child = single ? (0, import_react6.cloneElement)(children, {
1503
+ const single = (0, import_react7.isValidElement)(children);
1504
+ const child = single && hasText ? (0, import_react7.cloneElement)(children, {
1312
1505
  "aria-describedby": [children.props["aria-describedby"], description].filter(Boolean).join(" ")
1313
1506
  }) : children;
1314
1507
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
@@ -1316,12 +1509,12 @@ function Tooltip({ label, content, placement = "top", shortcut, className, child
1316
1509
  {
1317
1510
  ref: triggerRef,
1318
1511
  className: cx("uix-tooltip", className),
1319
- "aria-describedby": single ? void 0 : description,
1320
- tabIndex: single ? void 0 : 0,
1512
+ "aria-describedby": single || !hasText ? void 0 : description,
1513
+ tabIndex: single || !hasText ? void 0 : 0,
1321
1514
  onMouseEnter: () => show("pointer"),
1322
1515
  onMouseLeave: scheduleHide,
1323
1516
  onFocus: () => show("focus"),
1324
- onBlur: () => hide(),
1517
+ onBlur: () => hide(true),
1325
1518
  ...props,
1326
1519
  children: [
1327
1520
  child,
@@ -1335,13 +1528,13 @@ function Tooltip({ label, content, placement = "top", shortcut, className, child
1335
1528
  onMouseEnter: cancelClose,
1336
1529
  onMouseLeave: scheduleHide,
1337
1530
  ...bubbleAttr,
1338
- children: keys ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1531
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uix-tooltip__content", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uix-tooltip__label", children: keys ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1339
1532
  text != null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { id: `${id}-text`, children: text }),
1340
1533
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "uix-tooltip__shortcut", children: [
1341
1534
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { id: `${id}-keys`, className: "uix-visually-hidden", children: spokenKeys(keys, platform) }),
1342
1535
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(KbdCombo, { keys: [...keys], platform, "aria-hidden": "true" })
1343
1536
  ] })
1344
- ] }) : text
1537
+ ] }) : text }) })
1345
1538
  }
1346
1539
  )
1347
1540
  ]
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The rows of a list that just opened clear from a short blur as they arrive (2.60, the
3
+ * animate-ui study): a Select's options, a Menu's items, a sidebar group's rows. The fade and the
4
+ * slide are CSS (`uix-row-in`, the sidebar's row transition); the blur runs per frame in script with
5
+ * the same timing (--uix-dur-row, --uix-ease-soft, --uix-stagger-rows; the first ten step), because
6
+ * Linux WebKit's renderer crashes on a CSS-animated `filter` (motion.ts `blurIn`).
7
+ *
8
+ * Pointer opens only: none when `host` carries [data-uix-key-opened] or [data-uix-instant], and none
9
+ * under reduced motion. `skipMount`: no blur for a list that is already open on the first render.
10
+ * @internal
11
+ */
12
+ declare function useArrivalBlur(host: () => HTMLElement | null, rows: string, open: boolean, skipMount?: boolean): void;
13
+
14
+ export { useArrivalBlur };
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { useEffect, useRef } from "react";
3
+ import { KEY_OPENED, blurIn, tokenEase, tokenMs, tokenPx } from "../motion.js";
4
+ import { prefersReducedMotion } from "./useReducedMotion.js";
5
+ function useArrivalBlur(host, rows, open, skipMount = false) {
6
+ const mounted = useRef(false);
7
+ useEffect(() => {
8
+ const first = !mounted.current;
9
+ mounted.current = true;
10
+ const el = host();
11
+ if (!open || !el || first && skipMount || prefersReducedMotion()) return void 0;
12
+ if (el.hasAttribute(KEY_OPENED) || el.closest("[data-uix-instant]")) return void 0;
13
+ const stagger = tokenMs("--uix-stagger-rows", 30);
14
+ let top = 0;
15
+ let bottom = window.innerHeight;
16
+ const clip = (r) => {
17
+ top = Math.max(top, r.top);
18
+ bottom = Math.min(bottom, r.bottom);
19
+ };
20
+ const box = el.getBoundingClientRect();
21
+ if (box.height >= 1) clip(box);
22
+ for (let a = el.parentElement; a && a !== document.body; a = a.parentElement) {
23
+ if (window.getComputedStyle(a).overflowY !== "visible") clip(a.getBoundingClientRect());
24
+ }
25
+ const shown = [];
26
+ for (const row of Array.from(el.querySelectorAll(rows))) {
27
+ const r = row.getBoundingClientRect();
28
+ if (r.bottom <= top || r.top >= bottom || r.height < 1) continue;
29
+ if (window.getComputedStyle(row).visibility === "hidden") continue;
30
+ shown.push(row);
31
+ if (shown.length === 12) break;
32
+ }
33
+ const order = shown.map((row, i) => {
34
+ const n = parseFloat(window.getComputedStyle(row).getPropertyValue("--uix-row-i"));
35
+ return Number.isFinite(n) ? n : Math.min(i, 9);
36
+ });
37
+ return blurIn(shown, {
38
+ from: tokenPx("--uix-arrive-blur", 4),
39
+ duration: tokenMs("--uix-dur-row", 300),
40
+ ease: tokenEase("--uix-ease-soft"),
41
+ delay: (i) => order[i] * stagger
42
+ });
43
+ }, [open]);
44
+ }
45
+ export {
46
+ useArrivalBlur
47
+ };
@@ -0,0 +1,28 @@
1
+ import { RefObject } from 'react';
2
+
3
+ /**
4
+ * One hover highlight that glides from row to row (the animate-ui study, 2.60): in a menu, a
5
+ * listbox or the sidebar the pointer's row is marked by a single layer (`layerRef`, an
6
+ * `aria-hidden` `.uix-glide` span whose parent is the list) instead of each row painting its own
7
+ * hover. The parent must be its containing block (positioned, or a fixed popover). Pass `enabled`
8
+ * as the list's open state when the layer mounts with it, so the hook binds once it exists. Moving the pointer down a list, the
9
+ * mark travels with it on `--uix-ease-glide`, so the eye follows one shape instead of a flicker of
10
+ * rows lighting up and going out.
11
+ *
12
+ * The layer travels on `transform` alone (the Tabs indicator's way): it takes the first row's size
13
+ * and reaches every other row by `translate` plus `scale` (animate-ui's highlight), so a taller row
14
+ * (a two-line nav item) is reached by growing, not by a jump. It never reads or changes the list's
15
+ * scroll size, so it cannot add overflow or a scrollbar under the pointer, and a new target retargets
16
+ * a running glide from where it is; nothing animates width, height or position.
17
+ *
18
+ * - Mouse and pen, and the keyboard too (operator, 2026-11-08, as animate-ui): a row reached with the
19
+ * arrow keys or Tab (focus, or a listbox's `[data-active]`) takes the highlight. Touch has no hover.
20
+ * - The first row fades in where it is; only row-to-row moves glide.
21
+ * - Reduced motion: the global policy drops transform from transitions, so the mark jumps and fades.
22
+ * - Forced colours: CSS hides the layer and the rows' own system-colour hover returns.
23
+ * - While the layer shows, the container carries `data-uix-glide`; the component's CSS uses it to
24
+ * take each row's own hover background away (`[data-uix-glide] > .row:hover { background: none }`).
25
+ */
26
+ declare function useHoverGlide(layerRef: RefObject<HTMLElement | null>, itemSelector: string, enabled?: boolean): void;
27
+
28
+ export { useHoverGlide };