@tensor_1/react 2.58.0 → 2.61.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.
Files changed (42) hide show
  1. package/README.md +4 -4
  2. package/component-inventory.json +4 -0
  3. package/dist/components/Button.d.ts +15 -0
  4. package/dist/components/Button.js +11 -6
  5. package/dist/components/Checkbox.js +1 -1
  6. package/dist/components/Drawer.js +104 -1
  7. package/dist/components/FileKindIcon.d.ts +5 -1
  8. package/dist/components/FileKindIcon.js +5 -1
  9. package/dist/components/Menu.js +10 -1
  10. package/dist/components/Popover.js +4 -1
  11. package/dist/components/Select.js +85 -11
  12. package/dist/components/Sidebar.js +29 -2
  13. package/dist/components/Tooltip.js +103 -16
  14. package/dist/emoji.cjs +263 -70
  15. package/dist/file-model.d.ts +14 -7
  16. package/dist/file-model.js +18 -6
  17. package/dist/hooks/useArrivalBlur.d.ts +14 -0
  18. package/dist/hooks/useArrivalBlur.js +47 -0
  19. package/dist/hooks/useHoverGlide.d.ts +28 -0
  20. package/dist/hooks/useHoverGlide.js +137 -0
  21. package/dist/icons/Icon.d.ts +4 -2
  22. package/dist/icons/Icon.js +6 -2
  23. package/dist/icons/NamedIcon.js +1 -1
  24. package/dist/icons/components.d.ts +2 -1
  25. package/dist/icons/components.js +2 -0
  26. package/dist/icons/glyphs.d.ts +3 -1
  27. package/dist/icons/glyphs.js +3 -0
  28. package/dist/icons/types.d.ts +11 -0
  29. package/dist/icons.cjs +12 -3
  30. package/dist/icons.d.cts +5 -3
  31. package/dist/icons.d.ts +1 -1
  32. package/dist/index.cjs +2956 -2333
  33. package/dist/index.d.cts +61 -11
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.js +3 -0
  36. package/dist/motion.d.ts +25 -1
  37. package/dist/motion.js +100 -0
  38. package/dist/rich-text.cjs +4 -1
  39. package/dist/{types-B593xJNf.d.cts → types-B7OIndwg.d.cts} +11 -0
  40. package/dist/usage-roles.d.ts +28 -0
  41. package/dist/usage-roles.js +28 -0
  42. package/package.json +1 -1
package/README.md CHANGED
@@ -520,7 +520,7 @@ toast.dismiss(id); // or toast.dismiss() for all
520
520
  - **Modal feedback (HAR-2754):** keep one `Toaster` in the shell. It moves its stable host into the most recently opened UIx modal (`Modal`, `Drawer`, `Peek`, `ConfirmDialog`) and promotes the region to a manual popover. Both are necessary: a page z-index cannot cover a modal, and a top-layer popover outside the modal remains inert. Closing a nested dialog returns the same queue to its parent; closing the last dialog returns it to its original shell location. No caller z-index or extra toaster is needed. The live [German modal-feedback specimen](../../tests/toast-top-layer/harness.html) exercises error, pending, success, retry and dismissal in a drawer and a nested modal; bundle it with `node tests/toast-top-layer/build.mjs` when serving the repository. Browser regression: `tests/a11y/toast-top-layer.spec.mjs` hit-tests toast pixels and operates its controls at desktop and 320 px in both themes.
521
521
  ### Icons (`@tensor_1/react/icons`)
522
522
 
523
- The UIx icon set (HAR-996): 233 glyphs drawn in `currentColor` at the `--uix-icon-*` sizes. Icons come only from UIx
523
+ The UIx icon set (HAR-996): 237 glyphs drawn in `currentColor` at the `--uix-icon-*` sizes. Icons come only from UIx
524
524
  (workspace ADR-0038); no product adds an icon library. The glyphs are Lucide's (ISC); the licence travels in
525
525
  `THIRD_PARTY_NOTICES.md`. Import the CSS once: `@tensor_1/tokens/components/icon` (also in the bundle).
526
526
 
@@ -931,7 +931,7 @@ A full-screen media viewer (HAR-1367; TENSOR's capture viewer, MOTUS's programme
931
931
  - **Attachment:** the name is the link (`href`, `download`, `renderLink`). It has a quieter `meta` line, a `state` slot (e.g. a "Scanning" `StatusPill`), `actions`, `onRemove`, and `status` `loading` | `error` | `forbidden` (no link, and the reason shown). It's server-renderable.
932
932
  - Pure helpers: `formatFileSize`, `fileMatchesAccept`, `partitionFiles`, `fileKind`.
933
933
 
934
- ### File kit: kinds, the file row and the slim drop row (2.57.0)
934
+ ### File kit: kinds, the file row and the slim drop row (2.57.0; office kinds 2.59.0)
935
935
 
936
936
  Attachments that show what they are before you read the name, and an upload you can watch (variation H of the 2026-11-05 attachments study; TENSOR's Anhänge panel). Each kind of file has a hue (`--uix-file-<kind>`) and a Lucide glyph; a row's left edge carries the kind's tint, and that tint becomes the upload fill.
937
937
 
@@ -949,8 +949,8 @@ Attachments that show what they are before you read the name, and an upload you
949
949
  </section>
950
950
  ```
951
951
 
952
- - **Kinds:** `fileKind(name, mime)` gives one of `img` Bild, `doc` Dokument, `sheet` Tabelle, `mail` E-Mail, `code` Code & Konfiguration, `log` Protokoll, `archive` Archiv, `other` Datei. A known extension wins over the MIME type (a `.log` arrives as `text/plain`); pass `''` as the name when only the type is known, as in a drag event. The lists are `FILE_KIND_EXTENSIONS`. None of the hues is red (red stays for broken) and none is the brand blue (blue stays for actions); in light five of them are the calm chart slots.
953
- - **`FileKindIcon`:** the glyph in the kind's colour with the extension (`fileTypeLabel`: at most four capitals) as a solid label on the corner, ringed in the surface colour. `size` `sm` 30 px (a compact row), `md` 34 px, `lg` 52 px. Decorative unless you pass `label`. It is server-renderable. (`FileIcon` in `./icons` is the plain `file` glyph, hence the name.)
952
+ - **Kinds:** `fileKind(name, mime)` gives one of `img` Bild, `doc` Dokument (Word and other word-processor files), `sheet` Tabelle, `slides` Präsentation, `pdf` PDF, `mail` E-Mail, `code` Code & Konfiguration, `log` Protokoll, `archive` Archiv, `text` Text (`.txt`, `.md`), `other` Datei. `.key` stays `other`: in a ticket it is far more often a private key than a Keynote file. A known extension wins over the MIME type (a `.log` arrives as `text/plain`); pass `''` as the name when only the type is known, as in a drag event. The lists are `FILE_KIND_EXTENSIONS`. The office kinds take the colour people know from the program: Word blue (`doc`), Excel green (`sheet`), PowerPoint orange (`slides`), PDF red (`pdf`), each tuned so it never reads as the danger red (red stays for broken), the attention orange or the brand blue (blue stays for actions); `file-kinds.test.mjs` holds them there. `text` is the grey of `other`. In light four kinds are the calm chart slots. Before 2.59 Word, PowerPoint, PDF and text files were one rose `doc` kind.
953
+ - **`FileKindIcon`:** the glyph in the kind's colour (`slides` draws the presentation board, which is new in the icon set; `doc`, `pdf` and `text` share the page glyph) with the extension (`fileTypeLabel`: at most four capitals) as a solid label on the corner, ringed in the surface colour. `size` `sm` 30 px (a compact row), `md` 34 px, `lg` 52 px. Decorative unless you pass `label`. It is server-renderable. (`FileIcon` in `./icons` is the plain `file` glyph, hence the name.)
954
954
  - **`FileRow` states:** `idle` (files that were already there), `uploading` (the fill scales to `progress`, 0 to 1, or `loaded / size`, with a thin leading edge; "Wird hochgeladen · 62 % · 1,5 von 2,4 MB" and Abbrechen with `onCancel`), `done` (just finished: a check draws on the icon and the fill fades over 1.2 s; render `idle` afterwards), `scanning` ("Wird auf Schadsoftware geprüft", no motion), `blocked` (amber, Details with `onDetails`) and `failed` (red, Erneut versuchen with `onRetry`). `message` replaces the words of the last two. The outcome of an upload is announced once, never the progress.
955
955
  - **Actions:** `href` makes the download a link (`download` sets the saved name), or pass `onDownload`; `onMoreActions` adds "Weitere Aktionen" for your `Menu`; `actions` replaces both. With a fine pointer they appear on hover and focus; on touch they are always there.
956
956
  - **`FileDrop`:** one dashed line, "Dateien ablegen oder auswählen", backed by a real file input. The choose button is the one tab stop and opens the chooser; a click anywhere on the row does too. While files are dragged over it (or over `targetRef`, such as the whole panel), it reads their MIME types and names them ("2 Dateien: Bild, Protokoll") and tints itself from the pointer outwards, one colour per kind. A drop hands the files that match `accept` to `onFiles` and the rest to `onReject`.
@@ -1653,6 +1653,10 @@
1653
1653
  "name": "PlusIcon",
1654
1654
  "subpath": "./icons"
1655
1655
  },
1656
+ {
1657
+ "name": "PresentationIcon",
1658
+ "subpath": "./icons"
1659
+ },
1656
1660
  {
1657
1661
  "name": "PrinterIcon",
1658
1662
  "subpath": "./icons"
@@ -48,6 +48,21 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
48
48
  * the product binds the key.
49
49
  */
50
50
  shortcut?: KeyShortcut;
51
+ /**
52
+ * Why the button is unavailable (HAR-2816), e.g. "Nur Administratoren können Lizenzen
53
+ * löschen". Use it with `disabled`: the button then stays focusable and hoverable as
54
+ * `aria-disabled="true"`, takes no press, shows the reason in a `Tooltip` and is described by
55
+ * it, so a keyboard or screen-reader user learns why as well. A disabled button looks the same
56
+ * with or without a reason (muted text, no fill, a hairline); the reason is what tells a person
57
+ * what to do instead. While the button is enabled the reason is silent. Pass the prop for as
58
+ * long as the button can become unavailable (`undefined` only when it never can): the button
59
+ * then sits in the Tooltip's inline wrapper the whole time, so turning `disabled` on or off
60
+ * never remounts it and focus stays on it. Give a full-width button's wrapper its width with
61
+ * `disabledReasonClassName`.
62
+ */
63
+ disabledReason?: string;
64
+ /** Class for the Tooltip wrapper `disabledReason` adds, e.g. to make it full width. */
65
+ disabledReasonClassName?: string;
51
66
  children?: ReactNode;
52
67
  }
53
68
  declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
@@ -5,6 +5,7 @@ import { renderUixLink } from "../link.js";
5
5
  import { ShortcutHint } from "./ShortcutHint.js";
6
6
  import { ButtonFeedback } from "./ButtonFeedback.js";
7
7
  import { PENDING_DELAY_MS } from "../motion-timing.js";
8
+ import { Tooltip } from "./Tooltip.js";
8
9
  const buttonClasses = (variant, size, icon, wrap, className) => cx(
9
10
  "uix-btn",
10
11
  `uix-btn--${variant}`,
@@ -15,22 +16,25 @@ const buttonClasses = (variant, size, icon, wrap, className) => cx(
15
16
  );
16
17
  let warnedIconButton = false;
17
18
  const Button = forwardRef(
18
- ({ variant = "secondary", size = "md", icon = false, loading, loadingDelay = PENDING_DELAY_MS, result, resultLabels, wrap = false, shortcut, className, children, disabled, onClick, ...props }, ref) => {
19
+ ({ variant = "secondary", size = "md", icon = false, loading, loadingDelay = PENDING_DELAY_MS, result, resultLabels, wrap = false, shortcut, disabledReason, disabledReasonClassName, className, children, disabled, onClick, ...props }, ref) => {
19
20
  if (!warnedIconButton && icon && children == null && !props["aria-label"] && !props["aria-labelledby"] && typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
20
21
  warnedIconButton = true;
21
22
  console.warn("uix: icon-only <Button> has no accessible name \u2014 pass aria-label or aria-labelledby.");
22
23
  }
23
- return /* @__PURE__ */ jsxs(
24
+ const explained = !!disabled && !!disabledReason;
25
+ const blocked = loading || explained;
26
+ const button = /* @__PURE__ */ jsxs(
24
27
  "button",
25
28
  {
26
29
  ref,
27
30
  className: buttonClasses(variant, size, icon, wrap, className),
28
- disabled,
29
- "aria-disabled": loading || void 0,
31
+ disabled: explained ? void 0 : disabled,
32
+ "aria-disabled": blocked || void 0,
30
33
  "aria-busy": loading || void 0,
31
34
  "data-pending": loading || void 0,
32
- onClick: loading || onClick ? (e) => {
33
- if (loading) {
35
+ "data-disabled-reason": explained || void 0,
36
+ onClick: blocked || onClick ? (e) => {
37
+ if (blocked) {
34
38
  e.preventDefault();
35
39
  return;
36
40
  }
@@ -43,6 +47,7 @@ const Button = forwardRef(
43
47
  ]
44
48
  }
45
49
  );
50
+ return disabledReason !== void 0 ? /* @__PURE__ */ jsx(Tooltip, { label: explained ? disabledReason : void 0, className: disabledReasonClassName, children: button }) : button;
46
51
  }
47
52
  );
48
53
  Button.displayName = "Button";
@@ -2,7 +2,7 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { forwardRef, useEffect, useId, useRef } from "react";
4
4
  import { cx } from "../cx.js";
5
- const CheckIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("polyline", { points: "1.5,6 4.5,9 10.5,3" }) });
5
+ const CheckIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("polyline", { points: "1.5,6 4.5,9 10.5,3", pathLength: 1 }) });
6
6
  const IndeterminateIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx("rect", { x: "2", y: "5", width: "8", height: "2", rx: "1", fill: "currentColor" }) });
7
7
  const Checkbox = forwardRef(
8
8
  ({ label, indeterminate, className, ...props }, forwardedRef) => {
@@ -1,10 +1,85 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { useId, useRef } from "react";
3
+ import { useEffect, useId, useRef } from "react";
4
4
  import { cx } from "../cx.js";
5
5
  import { useUixLabels } from "../labels-context.js";
6
6
  import { isBackdropClick } from "../hooks/backdropDismiss.js";
7
7
  import { useGuardedDialog } from "./DiscardPrompt.js";
8
+ import { prefersReducedMotion } from "../hooks/useReducedMotion.js";
9
+ const SWIPE_VELOCITY = 0.11;
10
+ const SWIPE_SLOP = 6;
11
+ const SWIPE_WINDOW = 100;
12
+ const NOT_A_HANDLE = 'button, a, input, textarea, select, label, [role="button"], [role="slider"], [contenteditable=""], [contenteditable="true"]';
13
+ function useDrawerSwipe(side, canClose, dismiss) {
14
+ const drag = useRef(null);
15
+ const vertical = side === "bottom";
16
+ const sign = side === "start" ? -1 : 1;
17
+ const along = (e, d) => (vertical ? e.clientY - d.y0 : e.clientX - d.x0) * sign;
18
+ const across = (e, d) => vertical ? e.clientX - d.x0 : e.clientY - d.y0;
19
+ const place = (el, d) => {
20
+ el.style.translate = vertical ? `0 ${d}px` : `${d * sign}px 0`;
21
+ const size = vertical ? el.offsetHeight : el.offsetWidth;
22
+ el.style.setProperty("--uix-drawer-swipe", String(Math.min(1, d / Math.max(1, size))));
23
+ };
24
+ const settle = (el) => {
25
+ el.removeAttribute("data-swiping");
26
+ el.style.translate = "";
27
+ el.style.removeProperty("--uix-drawer-swipe");
28
+ };
29
+ const end = (e) => {
30
+ const d = drag.current;
31
+ drag.current = null;
32
+ if (!d?.active) return;
33
+ const el = e.currentTarget;
34
+ const recent = d.samples.filter((s) => e.timeStamp - s.t <= SWIPE_WINDOW);
35
+ const v = recent.length ? (along(e, d) - recent[0].p) / Math.max(1, e.timeStamp - recent[0].t) : 0;
36
+ const size = vertical ? el.offsetHeight : el.offsetWidth;
37
+ if (e.type === "pointerup" && (v > SWIPE_VELOCITY || d.d > size / 3) && dismiss(e)) {
38
+ el.removeAttribute("data-swiping");
39
+ if (!prefersReducedMotion()) place(el, size + 32);
40
+ return;
41
+ }
42
+ settle(el);
43
+ };
44
+ return {
45
+ settle,
46
+ handlers: {
47
+ onPointerDown: (e) => {
48
+ if (!canClose || e.pointerType === "mouse" || !e.isPrimary || e.target === e.currentTarget) return;
49
+ const target = e.target;
50
+ if (target.closest(NOT_A_HANDLE)) return;
51
+ if (vertical) {
52
+ const body = e.currentTarget.querySelector(".uix-drawer__body");
53
+ if (!target.closest(".uix-drawer__header") && body && body.contains(target) && body.scrollTop > 0) return;
54
+ }
55
+ drag.current = { id: e.pointerId, x0: e.clientX, y0: e.clientY, d: 0, samples: [{ p: 0, t: e.timeStamp }], active: false };
56
+ },
57
+ onPointerMove: (e) => {
58
+ const d = drag.current;
59
+ if (!d || d.id !== e.pointerId) return;
60
+ const a = along(e, d);
61
+ if (!d.active) {
62
+ if (Math.abs(a) < SWIPE_SLOP) return;
63
+ if (Math.abs(across(e, d)) > Math.abs(a) || a < 0) {
64
+ drag.current = null;
65
+ return;
66
+ }
67
+ d.active = true;
68
+ try {
69
+ e.currentTarget.setPointerCapture?.(e.pointerId);
70
+ } catch {
71
+ }
72
+ e.currentTarget.setAttribute("data-swiping", "");
73
+ }
74
+ d.samples = [...d.samples.filter((s) => e.timeStamp - s.t <= SWIPE_WINDOW), { p: a, t: e.timeStamp }];
75
+ d.d = Math.max(0, a);
76
+ place(e.currentTarget, d.d);
77
+ },
78
+ onPointerUp: end,
79
+ onPointerCancel: end
80
+ }
81
+ };
82
+ }
8
83
  const CloseIcon = () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M4 4l8 8M12 4l-8 8" }) });
9
84
  function Drawer({
10
85
  open,
@@ -28,6 +103,18 @@ function Drawer({
28
103
  const closeRef = useRef(null);
29
104
  const guard = useGuardedDialog({ open, onClose, dirty, pending, labels: discardLabels, closeRef });
30
105
  const titleId = useId();
106
+ const swipe = useDrawerSwipe(side, !!onClose && !pending, (event) => {
107
+ if (dirty) {
108
+ guard.requestClose(null, event);
109
+ return false;
110
+ }
111
+ guard.requestClose(null, event);
112
+ return true;
113
+ });
114
+ useEffect(() => {
115
+ const el = guard.ref.current;
116
+ if (open && el) swipe.settle(el);
117
+ }, [open]);
31
118
  return /* @__PURE__ */ jsxs(
32
119
  "dialog",
33
120
  {
@@ -43,6 +130,22 @@ function Drawer({
43
130
  onKeyDown?.(event);
44
131
  guard.onKeyDown(event);
45
132
  },
133
+ onPointerDown: (event) => {
134
+ rest.onPointerDown?.(event);
135
+ swipe.handlers.onPointerDown(event);
136
+ },
137
+ onPointerMove: (event) => {
138
+ rest.onPointerMove?.(event);
139
+ swipe.handlers.onPointerMove(event);
140
+ },
141
+ onPointerUp: (event) => {
142
+ rest.onPointerUp?.(event);
143
+ swipe.handlers.onPointerUp(event);
144
+ },
145
+ onPointerCancel: (event) => {
146
+ rest.onPointerCancel?.(event);
147
+ swipe.handlers.onPointerCancel(event);
148
+ },
46
149
  children: [
47
150
  guard.provide(
48
151
  /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -3,7 +3,11 @@ import { HTMLAttributes } from 'react';
3
3
  import { FileKind } from '../file-model.js';
4
4
  import { UixIcon } from '../icons/types.js';
5
5
 
6
- /** The Lucide glyph of each kind. E-Mail keeps the envelope: Lucide has no file-shaped mail icon. */
6
+ /**
7
+ * The Lucide glyph of each kind. E-Mail keeps the envelope and Präsentation the presentation
8
+ * board: Lucide has no file-shaped icon for either. Dokument, PDF and Text share the page with
9
+ * lines; their colour and the type label on the corner tell them apart.
10
+ */
7
11
  declare const FILE_KIND_GLYPHS: Readonly<Record<FileKind, UixIcon>>;
8
12
  /** `md` 34 px (a list row), `sm` 30 px (a compact panel row), `lg` 52 px. */
9
13
  type FileKindIconSize = 'sm' | 'md' | 'lg';
@@ -9,16 +9,20 @@ import {
9
9
  FileSpreadsheetIcon,
10
10
  FileTerminalIcon,
11
11
  FileTextIcon,
12
- MailIcon
12
+ MailIcon,
13
+ PresentationIcon
13
14
  } from "../icons/components.js";
14
15
  const FILE_KIND_GLYPHS = {
15
16
  img: FileImageIcon,
16
17
  doc: FileTextIcon,
17
18
  sheet: FileSpreadsheetIcon,
19
+ slides: PresentationIcon,
20
+ pdf: FileTextIcon,
18
21
  mail: MailIcon,
19
22
  code: FileCodeIcon,
20
23
  log: FileTerminalIcon,
21
24
  archive: FileArchiveIcon,
25
+ text: FileTextIcon,
22
26
  other: FileIcon
23
27
  };
24
28
  const STROKE = { sm: 1.5, md: 1.5, lg: 1.4 };
@@ -6,6 +6,8 @@ import { Popover } from "./Popover.js";
6
6
  import { CheckIcon } from "../icons/components.js";
7
7
  import { renderUixLink } from "../link.js";
8
8
  import { KbdCombo, ariaKeyShortcuts, isKeyShortcut, useKbdPlatform } from "./Kbd.js";
9
+ import { useHoverGlide } from "../hooks/useHoverGlide.js";
10
+ import { useArrivalBlur } from "../hooks/useArrivalBlur.js";
9
11
  function useRowShortcut(shortcut) {
10
12
  const platform = useKbdPlatform();
11
13
  if (shortcut == null) return { node: null, aria: {} };
@@ -32,6 +34,8 @@ function Menu({ trigger, children, open: controlledOpen, defaultOpen = false, on
32
34
  const open = controlledOpen ?? internalOpen;
33
35
  const focusOnOpen = useRef("first");
34
36
  const typeahead = useRef({ text: "", at: 0 });
37
+ const glideRef = useRef(null);
38
+ useHoverGlide(glideRef, ".uix-menu__item", open);
35
39
  const setOpen = (next) => {
36
40
  if (controlledOpen === void 0) setInternalOpen(next);
37
41
  onOpenChange?.(next);
@@ -78,6 +82,7 @@ function Menu({ trigger, children, open: controlledOpen, defaultOpen = false, on
78
82
  document.addEventListener("pointerdown", onPointer, true);
79
83
  return () => document.removeEventListener("pointerdown", onPointer, true);
80
84
  }, [open, menuId]);
85
+ useArrivalBlur(menu, ':scope > :is(.uix-menu__item, .uix-menu__label, .uix-menu__sep, [role="group"])', open);
81
86
  const onMenuKeyDown = (event) => {
82
87
  const list = items();
83
88
  const index = list.indexOf(document.activeElement);
@@ -143,6 +148,7 @@ function Menu({ trigger, children, open: controlledOpen, defaultOpen = false, on
143
148
  {
144
149
  id: menuId,
145
150
  popover: "manual",
151
+ "data-uix-animate-keys": "",
146
152
  anchor: triggerRef,
147
153
  placement,
148
154
  capHeight: true,
@@ -151,7 +157,10 @@ function Menu({ trigger, children, open: controlledOpen, defaultOpen = false, on
151
157
  "aria-labelledby": label ? void 0 : triggerProps.id ?? triggerId,
152
158
  className: cx("uix-menu", className),
153
159
  onKeyDown: onMenuKeyDown,
154
- children: open ? children : null
160
+ children: open ? /* @__PURE__ */ jsxs(Fragment, { children: [
161
+ /* @__PURE__ */ jsx("span", { ref: glideRef, className: "uix-glide", "aria-hidden": "true" }),
162
+ children
163
+ ] }) : null
155
164
  }
156
165
  )
157
166
  ] });
@@ -59,7 +59,10 @@ function Popover({
59
59
  watchInputModality();
60
60
  const el = ref.current;
61
61
  if (!el) return;
62
- const mark = () => markKeyOpened(el);
62
+ const mark = () => {
63
+ if (el.hasAttribute("data-uix-animate-keys")) el.removeAttribute("data-uix-key-opened");
64
+ else markKeyOpened(el);
65
+ };
63
66
  el.addEventListener("beforetoggle", mark);
64
67
  return () => el.removeEventListener("beforetoggle", mark);
65
68
  }, []);
@@ -4,7 +4,10 @@ import { Children, Fragment as Fragment2, forwardRef, isValidElement, useCallbac
4
4
  import { cx } from "../cx.js";
5
5
  import { useUixLabels } from "../labels-context.js";
6
6
  import { useAnchoredPosition, zoomOf } from "../hooks/useAnchoredPosition.js";
7
- import { markKeyOpened, watchInputModality } from "../motion.js";
7
+ import { blurIn, keyboardInitiated, tokenEase, tokenMs, tokenPx, watchInputModality } from "../motion.js";
8
+ import { prefersReducedMotion } from "../hooks/useReducedMotion.js";
9
+ import { useHoverGlide } from "../hooks/useHoverGlide.js";
10
+ import { useArrivalBlur } from "../hooks/useArrivalBlur.js";
8
11
  import { Drawer } from "./Drawer.js";
9
12
  import {
10
13
  buildSelectModel,
@@ -134,7 +137,7 @@ function labelText(trigger, own, ariaLabel, labelledBy) {
134
137
  const labels = trigger.labels;
135
138
  return labels ? Array.from(labels).map(read).join(" ").trim() : "";
136
139
  }
137
- const CheckIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) });
140
+ const CheckIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5", pathLength: 1 }) });
138
141
  const Select = forwardRef(function Select2(props, forwardedRef) {
139
142
  const {
140
143
  size = "md",
@@ -181,6 +184,7 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
181
184
  const proxyRef = useRef(null);
182
185
  const popupRef = useRef(null);
183
186
  const listRef = useRef(null);
187
+ const glideRef = useRef(null);
184
188
  const searchRef = useRef(null);
185
189
  const staticItems = useMemo(() => options ? [...options] : parseChildren(children), [options, children]);
186
190
  const formModel = useMemo(() => buildSelectModel(staticItems), [staticItems]);
@@ -202,6 +206,30 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
202
206
  controlledRef.current = controlled;
203
207
  const [initialDefault] = useState(() => multiple ? values : current);
204
208
  const [open, setOpen] = useState(false);
209
+ const [justChosen, setJustChosen] = useState(null);
210
+ useEffect(() => {
211
+ if (justChosen == null) return void 0;
212
+ const t = setTimeout(() => setJustChosen(null), 600);
213
+ return () => clearTimeout(t);
214
+ }, [justChosen]);
215
+ const holdTimer = useRef(null);
216
+ const onHoldKey = () => clearHold();
217
+ const clearHold = () => {
218
+ document.removeEventListener("keydown", onHoldKey, true);
219
+ if (holdTimer.current != null) {
220
+ clearTimeout(holdTimer.current);
221
+ holdTimer.current = null;
222
+ }
223
+ };
224
+ useEffect(() => clearHold, []);
225
+ const valueKey = values.join("|");
226
+ const lastValueKey = useRef(valueKey);
227
+ const valueChanged = useRef(false);
228
+ if (lastValueKey.current !== valueKey) {
229
+ lastValueKey.current = valueKey;
230
+ valueChanged.current = true;
231
+ }
232
+ useHoverGlide(glideRef, ".uix-listbox__option", open);
205
233
  const [mode, setMode] = useState("popover");
206
234
  const [active, setActive] = useState(-1);
207
235
  const [query, setQuery] = useState("");
@@ -369,6 +397,7 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
369
397
  setOpen(true);
370
398
  };
371
399
  const close = (opts = {}) => {
400
+ clearHold();
372
401
  if (opts.revert && multiple) {
373
402
  const was = snapshot.current;
374
403
  const now = valuesRef.current;
@@ -382,6 +411,7 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
382
411
  };
383
412
  const choose = (entry, closeAfter = !multiple) => {
384
413
  if (!entry || entry.disabled) return;
414
+ setJustChosen(entry.option.value);
385
415
  if (multiple) {
386
416
  commit(toggleValue(valuesRef.current, entry.option.value), entry.option);
387
417
  setActive(entry.index);
@@ -389,6 +419,17 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
389
419
  return;
390
420
  }
391
421
  if (entry.option.value !== current) commit([entry.option.value], entry.option);
422
+ const pointer = !keyboardInitiated() && !!window.matchMedia?.("(hover: hover)").matches;
423
+ const hold = mode === "popover" && pointer && !prefersReducedMotion() ? tokenMs("--uix-hold-pick", 250) : 0;
424
+ if (hold > 0) {
425
+ clearHold();
426
+ holdTimer.current = setTimeout(() => {
427
+ clearHold();
428
+ close({ focus: true });
429
+ }, hold);
430
+ document.addEventListener("keydown", onHoldKey, true);
431
+ return;
432
+ }
392
433
  close({ focus: true });
393
434
  };
394
435
  const clearAll = () => {
@@ -541,16 +582,14 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
541
582
  const zoom = zoomOf(trigger);
542
583
  const r = trigger.getBoundingClientRect();
543
584
  const room = Math.max(r.top, window.innerHeight - r.bottom) / zoom - OFFSET - EDGE;
544
- popup.style.minWidth = `${Math.round(r.width / zoom)}px`;
585
+ popup.style.minWidth = `${Math.round(trigger.offsetWidth || r.width / zoom)}px`;
545
586
  popup.style.maxHeight = `${Math.max(96, Math.min(MAX_HEIGHT, Math.floor(room)))}px`;
546
- if (!isOpen()) markKeyOpened(popup);
547
587
  try {
548
588
  if (!isOpen()) popup.showPopover();
549
589
  } catch {
550
590
  }
551
591
  if (isSearchable) searchRef.current?.focus({ preventScroll: true });
552
592
  } else {
553
- if (isOpen()) markKeyOpened(popup);
554
593
  try {
555
594
  if (isOpen()) popup.hidePopover();
556
595
  } catch {
@@ -561,6 +600,7 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
561
600
  watchInputModality();
562
601
  }, []);
563
602
  useAnchoredPosition(triggerRef, popupRef, { open: showing, placement, offset: OFFSET, padding: EDGE });
603
+ useArrivalBlur(() => popupRef.current, ".uix-listbox > :is(.uix-listbox__option, .uix-listbox__group)", showing);
564
604
  useEffect(() => {
565
605
  if (open && mode === "sheet") (isSearchable ? searchRef.current : listRef.current)?.focus({ preventScroll: true });
566
606
  }, [open, mode, isSearchable]);
@@ -601,6 +641,36 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
601
641
  firstSelected?.icon != null && /* @__PURE__ */ jsx("span", { className: "uix-select__icon", "aria-hidden": "true", children: firstSelected.icon }),
602
642
  /* @__PURE__ */ jsx("span", { className: "uix-select__text", children: firstSelected?.label })
603
643
  ] });
644
+ const valueRef = useRef(null);
645
+ const shownText = useRef(null);
646
+ useIsomorphicLayoutEffect(() => {
647
+ const trigger = triggerRef.current;
648
+ const was = shownText.current;
649
+ shownText.current = valueRef.current?.textContent ?? "";
650
+ if (!trigger || was == null || was === shownText.current || prefersReducedMotion()) return void 0;
651
+ trigger.setAttribute("data-leaving", was);
652
+ trigger.removeAttribute("data-swap");
653
+ void trigger.offsetWidth;
654
+ trigger.setAttribute("data-swap", "");
655
+ const blur = tokenPx("--uix-arrive-blur", 4);
656
+ const duration = tokenMs("--uix-dur-overlay", 400);
657
+ const ease = tokenEase("--uix-ease-soft");
658
+ const stops = [
659
+ valueRef.current ? blurIn([valueRef.current], { from: blur, duration, ease }) : () => {
660
+ },
661
+ blurIn([trigger], { from: blur, duration, ease, leave: true, property: "--uix-leaving-blur" })
662
+ ];
663
+ const t = setTimeout(() => {
664
+ trigger.removeAttribute("data-leaving");
665
+ trigger.removeAttribute("data-swap");
666
+ }, duration);
667
+ return () => {
668
+ clearTimeout(t);
669
+ stops.forEach((stop) => stop());
670
+ trigger.removeAttribute("data-leaving");
671
+ trigger.removeAttribute("data-swap");
672
+ };
673
+ }, [valueKey]);
604
674
  const more = multiple && values.length > 1 ? values.length - 1 : 0;
605
675
  const isInvalid = !!invalid || formInvalid || ariaInvalid != null && ariaInvalid !== false && ariaInvalid !== "false";
606
676
  const popoverAttr = { popover: "manual" };
@@ -641,6 +711,7 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
641
711
  "aria-selected": selected,
642
712
  "aria-disabled": entry.disabled || void 0,
643
713
  "data-active": open && isActive || void 0,
714
+ "data-just-chosen": selected && justChosen === o.value || void 0,
644
715
  onMouseDown: (e) => e.preventDefault(),
645
716
  onPointerMove: () => {
646
717
  if (!isActive && !entry.disabled) setActive(entry.index);
@@ -665,7 +736,7 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
665
736
  };
666
737
  const empty = entries.length === 0;
667
738
  const status = hasLoader ? asyncState.status : "ready";
668
- const listbox = /* @__PURE__ */ jsx(
739
+ const listbox = /* @__PURE__ */ jsxs(
669
740
  "div",
670
741
  {
671
742
  ref: listRef,
@@ -679,10 +750,13 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
679
750
  tabIndex: mode === "sheet" ? 0 : -1,
680
751
  hidden: entries.length === 0 || void 0,
681
752
  onKeyDown: mode === "sheet" && !isSearchable ? (e) => onOpenKey(e, false) : void 0,
682
- children: listModel.sections.map((section, i) => section.label != null ? /* @__PURE__ */ jsxs("div", { role: "group", className: "uix-listbox__group", "aria-labelledby": `${uid}-group-${i}`, "aria-disabled": section.disabled || void 0, children: [
683
- /* @__PURE__ */ jsx("div", { id: `${uid}-group-${i}`, role: "presentation", className: "uix-listbox__group-label", children: section.label }),
684
- section.entries.map(renderEntry)
685
- ] }, `g${i}`) : /* @__PURE__ */ jsx(Fragment2, { children: section.entries.map(renderEntry) }, `s${i}`))
753
+ children: [
754
+ /* @__PURE__ */ jsx("span", { ref: glideRef, className: "uix-glide", "aria-hidden": "true" }),
755
+ listModel.sections.map((section, i) => section.label != null ? /* @__PURE__ */ jsxs("div", { role: "group", className: "uix-listbox__group", "aria-labelledby": `${uid}-group-${i}`, "aria-disabled": section.disabled || void 0, children: [
756
+ /* @__PURE__ */ jsx("div", { id: `${uid}-group-${i}`, role: "presentation", className: "uix-listbox__group-label", children: section.label }),
757
+ section.entries.map(renderEntry)
758
+ ] }, `g${i}`) : /* @__PURE__ */ jsx(Fragment2, { children: section.entries.map(renderEntry) }, `s${i}`))
759
+ ]
686
760
  }
687
761
  );
688
762
  const stateRow = status === "loading" && empty ? /* @__PURE__ */ jsxs("div", { className: "uix-select__state", role: "status", children: [
@@ -738,7 +812,7 @@ const Select = forwardRef(function Select2(props, forwardedRef) {
738
812
  onFocus: handleFocus,
739
813
  onBlur: handleBlur,
740
814
  children: [
741
- /* @__PURE__ */ jsx("span", { className: "uix-select__value", children: display }),
815
+ /* @__PURE__ */ jsx("span", { ref: valueRef, className: "uix-select__value", "data-changed": valueChanged.current || void 0, children: display }, valueKey),
742
816
  more > 0 && /* @__PURE__ */ jsxs("span", { className: "uix-select__more", children: [
743
817
  /* @__PURE__ */ jsxs("span", { "aria-hidden": "true", children: [
744
818
  "+",
@@ -6,6 +6,10 @@ import { useUixLabels } from "../labels-context.js";
6
6
  import { SearchIcon } from "../icons/components.js";
7
7
  import { useInShellDrawer } from "../shell-context.js";
8
8
  import { KbdCombo, ariaKeyShortcuts, useKbdPlatform } from "./Kbd.js";
9
+ import { useHoverGlide } from "../hooks/useHoverGlide.js";
10
+ import { useSlidingIndicator } from "../hooks/useSlidingIndicator.js";
11
+ import { useArrivalBlur } from "../hooks/useArrivalBlur.js";
12
+ import { watchInputModality } from "../motion.js";
9
13
  const ChevronIcon = () => /* @__PURE__ */ jsx("svg", { className: "uix-navgroup__chevron", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2 4l4 4 4-4" }) });
10
14
  function Sidebar({ collapsed, nav, onToggle, brand, toggleIcon, actions, search, footer, children, expandLabel: expandLabelProp, collapseLabel: collapseLabelProp, className, ...props }) {
11
15
  const uixLabels = useUixLabels();
@@ -14,7 +18,26 @@ function Sidebar({ collapsed, nav, onToggle, brand, toggleIcon, actions, search,
14
18
  const inDrawer = useInShellDrawer();
15
19
  const isCollapsed = !inDrawer && (collapsed ?? nav === "rail");
16
20
  const platform = useKbdPlatform();
17
- return /* @__PURE__ */ jsxs("nav", { className: cx("uix-sidebar", className), "data-collapsed": isCollapsed || void 0, "data-nav": inDrawer ? void 0 : nav, ...props, children: [
21
+ const navRef = useRef(null);
22
+ const glideRef = useRef(null);
23
+ const markRef = useRef(null);
24
+ useHoverGlide(glideRef, ".uix-navitem");
25
+ useSlidingIndicator(navRef, markRef, '.uix-navitem[aria-current="page"]');
26
+ const lastCollapsed = useRef(isCollapsed);
27
+ useEffect(() => {
28
+ const el = navRef.current;
29
+ if (!el || lastCollapsed.current === isCollapsed) return void 0;
30
+ lastCollapsed.current = isCollapsed;
31
+ el.setAttribute("data-uix-toggled", "");
32
+ const t = setTimeout(() => el.removeAttribute("data-uix-toggled"), 600);
33
+ return () => {
34
+ clearTimeout(t);
35
+ el.removeAttribute("data-uix-toggled");
36
+ };
37
+ }, [isCollapsed]);
38
+ return /* @__PURE__ */ jsxs("nav", { ref: navRef, className: cx("uix-sidebar", className), "data-collapsed": isCollapsed || void 0, "data-nav": inDrawer ? void 0 : nav, ...props, children: [
39
+ /* @__PURE__ */ jsx("span", { ref: glideRef, className: "uix-glide", "aria-hidden": "true" }),
40
+ /* @__PURE__ */ jsx("span", { ref: markRef, className: "uix-sidebar__mark", "aria-hidden": "true", hidden: true }),
18
41
  (brand != null || onToggle || actions != null) && /* @__PURE__ */ jsxs("div", { className: "uix-sidebar__head", children: [
19
42
  brand && /* @__PURE__ */ jsx("div", { className: "uix-sidebar__brand", children: brand }),
20
43
  actions != null && /* @__PURE__ */ jsx("div", { className: "uix-sidebar__actions", children: actions }),
@@ -96,6 +119,10 @@ function NavGroup({ icon, label, children, defaultExpanded = true, expanded: con
96
119
  const panelId = useId();
97
120
  const triggerRef = useRef(null);
98
121
  const panelRef = useRef(null);
122
+ useEffect(() => {
123
+ watchInputModality();
124
+ }, []);
125
+ useArrivalBlur(() => panelRef.current, ":scope > div > .uix-subitem", expanded, true);
99
126
  useEffect(() => {
100
127
  panelRef.current?.toggleAttribute("inert", !expanded);
101
128
  if (!expanded && panelRef.current?.contains(document.activeElement)) triggerRef.current?.focus();
@@ -105,7 +132,7 @@ function NavGroup({ icon, label, children, defaultExpanded = true, expanded: con
105
132
  if (controlledExpanded == null) setInternalExpanded(next);
106
133
  onExpandedChange?.(next);
107
134
  };
108
- return /* @__PURE__ */ jsxs("div", { className: "uix-navgroup", children: [
135
+ return /* @__PURE__ */ jsxs("div", { className: "uix-navgroup", "data-plain": icon ? void 0 : "", children: [
109
136
  /* @__PURE__ */ jsxs(
110
137
  "button",
111
138
  {