@zonsh/ui 0.4.1 → 0.5.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 (67) hide show
  1. package/dist/components/accordion.js +1 -1
  2. package/dist/components/ascii-field.js +2 -1
  3. package/dist/components/bottom-nav.js +4 -4
  4. package/dist/components/button.js +1 -1
  5. package/dist/components/chart.d.ts +11 -0
  6. package/dist/components/chart.js +12 -0
  7. package/dist/components/collapsible.js +1 -1
  8. package/dist/components/command.js +3 -3
  9. package/dist/components/conversation.js +10 -3
  10. package/dist/components/copy-button.js +7 -5
  11. package/dist/components/graph.js +24 -7
  12. package/dist/components/illustration.js +50 -3
  13. package/dist/components/input-group.d.ts +2 -2
  14. package/dist/components/input-group.js +6 -4
  15. package/dist/components/input.d.ts +1 -1
  16. package/dist/components/input.js +1 -1
  17. package/dist/components/layout.d.ts +2 -1
  18. package/dist/components/layout.js +55 -11
  19. package/dist/components/lightbox.js +22 -4
  20. package/dist/components/menubar.js +60 -13
  21. package/dist/components/message.js +3 -2
  22. package/dist/components/navigation-menu.js +4 -2
  23. package/dist/components/number-field.js +26 -12
  24. package/dist/components/pagination.js +1 -1
  25. package/dist/components/prompt-input.js +14 -6
  26. package/dist/components/radio-group.js +7 -2
  27. package/dist/components/reasoning.js +1 -1
  28. package/dist/components/response.d.ts +3 -2
  29. package/dist/components/response.js +22 -10
  30. package/dist/components/sidebar.js +37 -18
  31. package/dist/components/site-header.js +6 -1
  32. package/dist/components/skeleton.d.ts +1 -1
  33. package/dist/components/skeleton.js +1 -1
  34. package/dist/components/sortable.js +61 -37
  35. package/dist/components/table.d.ts +1 -1
  36. package/dist/components/table.js +55 -2
  37. package/dist/components/tabs.js +8 -4
  38. package/dist/components/tags-input.js +1 -1
  39. package/dist/components/theme.d.ts +1 -1
  40. package/dist/components/theme.js +21 -3
  41. package/dist/components/time-field.d.ts +2 -1
  42. package/dist/components/time-field.js +13 -3
  43. package/dist/components/toggle-group.js +1 -0
  44. package/dist/components/tool-call.js +6 -1
  45. package/dist/components/toolbar.d.ts +1 -1
  46. package/dist/components/toolbar.js +5 -2
  47. package/dist/components/tooltip.d.ts +4 -2
  48. package/dist/components/tooltip.js +10 -4
  49. package/dist/components/tour.js +35 -10
  50. package/dist/components/tree.js +29 -6
  51. package/dist/components/video-player.js +61 -5
  52. package/dist/lib/glide.d.ts +5 -4
  53. package/dist/lib/glide.js +5 -4
  54. package/dist/lib/table-fit.d.ts +3 -2
  55. package/dist/lib/table-fit.js +29 -19
  56. package/dist/styles/expressive.css +40 -21
  57. package/dist/styles/index.css +8 -0
  58. package/dist/styles/material.css +40 -20
  59. package/dist/styles/parts/ai.css +2 -1
  60. package/dist/styles/parts/controls.css +24 -20
  61. package/dist/styles/parts/data.css +33 -5
  62. package/dist/styles/parts/feedback.css +43 -13
  63. package/dist/styles/parts/navigation.css +42 -9
  64. package/dist/styles/parts/overlays.css +93 -6
  65. package/dist/styles/parts/pdf.css +13 -7
  66. package/dist/styles/tokens.css +16 -1
  67. package/package.json +1 -1
@@ -35,5 +35,5 @@ export function AccordionTrigger({ index, headerProps, className, children, ...p
35
35
  }
36
36
  /** The disclosed content. Height animates from `--accordion-panel-height`. */
37
37
  export function AccordionPanel({ inset = false, className, children, ...props }) {
38
- return (_jsx(BaseAccordion.Panel, { "data-slot": "accordion-panel", className: sx("h-(--accordion-panel-height) overflow-hidden transition-[height] duration-(--duration) ease-(--ease) data-ending-style:h-0 data-starting-style:h-0", className), ...props, children: _jsx("div", { className: cn("max-w-[68ch] pe-10 pb-6 text-body text-foreground-soft", inset && "ps-11 sm:ps-14"), children: children }) }));
38
+ return (_jsx(BaseAccordion.Panel, { "data-slot": "accordion-panel", className: sx("h-(--accordion-panel-height) overflow-hidden transition-[height] duration-(--duration-glide) ease-(--ease-glide) data-ending-style:h-0 data-starting-style:h-0", className), ...props, children: _jsx("div", { className: cn("max-w-[68ch] pe-10 pb-6 text-body text-foreground-soft", inset && "ps-11 sm:ps-14"), children: children }) }));
39
39
  }
@@ -347,7 +347,8 @@ export function AsciiField({ density = 1, intensity = 1, mask = "brackets", spre
347
347
  draw(0, false);
348
348
  }
349
349
  function onPointerMove(e) {
350
- if (isStill() || e.pointerType === "touch")
350
+ // Off screen (or stopped) nothing is drawn: skip the layout read every move would cost.
351
+ if (!onScreen || !raf || e.pointerType === "touch" || isStill())
351
352
  return;
352
353
  const rect = root.getBoundingClientRect();
353
354
  const x = e.clientX - rect.left;
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useRender } from "@base-ui/react/use-render";
4
4
  import * as React from "react";
5
5
  import { cn } from "../lib/cn.js";
6
- import { glideStyle, useGlide, useMergedRef } from "../lib/glide.js";
6
+ import { glideMotion, glideStyle, useGlide, useMergedRef } from "../lib/glide.js";
7
7
  import { Badge, BadgeAnchor } from "./badge.js";
8
8
  import { useMessages } from "./locale.js";
9
9
  const defaultMessages = {
@@ -121,9 +121,9 @@ export function BottomNav({ value: valueProp, defaultValue, onValueChange, posit
121
121
  // Clear of the home indicator, and of the notch on a phone on its side (viewport-fit=cover).
122
122
  "pr-[env(safe-area-inset-right,0px)] pb-[env(safe-area-inset-bottom,0px)] pl-[env(safe-area-inset-left,0px)]",
123
123
  // Leaving eases in, coming back eases out: 300ms either way, instant under reduced motion.
124
- "transition-[translate] duration-[calc(var(--duration)*2)] ease-[cubic-bezier(0.33,1,0.68,1)]", "data-hidden:translate-y-full data-hidden:ease-[cubic-bezier(0.32,0,0.67,0)]", breakpoint && hiddenFrom[breakpoint], className), ...props, children: [_jsx("span", { "aria-hidden": true, "data-slot": "bottom-nav-ground" }), _jsxs("div", { ref: rowRef, "data-slot": "bottom-nav-list", className: "relative mx-auto flex h-(--bottom-nav-bar) w-full max-w-lg items-stretch px-1", children: [_jsx("span", { "aria-hidden": true, "data-slot": "bottom-nav-indicator", "data-visible": glide.visible ? "" : undefined, "data-instant": glide.instant ? "" : undefined, className: cn("pointer-events-none absolute top-0 left-0 opacity-0 data-visible:opacity-100",
125
- // The glide crosses the bar: 300ms on an ease-out that does not rush its first frames.
126
- "transition-[translate,width,height,opacity] duration-[calc(var(--duration)*2)] ease-[cubic-bezier(0.33,1,0.68,1)] data-instant:transition-none", "rounded-button border border-transparent bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised"), style: glideStyle(glide) }), children] })] }) }));
124
+ "transition-[translate] duration-[calc(var(--duration)*2)] ease-(--ease-glide)", "data-hidden:translate-y-full data-hidden:ease-[cubic-bezier(0.32,0,0.67,0)]", breakpoint && hiddenFrom[breakpoint], className), ...props, children: [_jsx("span", { "aria-hidden": true, "data-slot": "bottom-nav-ground" }), _jsxs("div", { ref: rowRef, "data-slot": "bottom-nav-list", className: "relative mx-auto flex h-(--bottom-nav-bar) w-full max-w-lg items-stretch px-1", children: [_jsx("span", { "aria-hidden": true, "data-slot": "bottom-nav-indicator", "data-visible": glide.visible ? "" : undefined, "data-instant": glide.instant ? "" : undefined, className: cn(
125
+ // The glide crosses the bar at the one speed of every gliding indicator.
126
+ glideMotion, "rounded-button border border-transparent bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised"), style: glideStyle(glide) }), children] })] }) }));
127
127
  }
128
128
  /**
129
129
  * BottomNavItem — one destination: an icon over a label, at least 44px to touch (the whole cell
@@ -122,7 +122,7 @@ export function Button({ variant = "primary", size = "default", collapsible = fa
122
122
  folds && [
123
123
  "gap-0 data-collapse-instant:transition-none!",
124
124
  // The fold's padding and corners; an expandable button waits out its hover intent first.
125
- "[--material-motion:padding_calc(var(--duration)*2)_var(--ease)_var(--expand-delay,0s),border-radius_calc(var(--duration)*2)_var(--ease)_var(--expand-delay,0s)]",
125
+ "[--material-motion:padding_var(--expand-time,calc(var(--duration)*2))_var(--ease)_var(--expand-delay,0s),border-radius_var(--expand-time,calc(var(--duration)*2))_var(--ease)_var(--expand-delay,0s)]",
126
126
  collapsibleGaps[size],
127
127
  ],
128
128
  variants[variant],
@@ -1,6 +1,17 @@
1
1
  import * as React from "react";
2
2
  import * as RechartsPrimitive from "recharts";
3
3
  import type { LegendPayload } from "recharts";
4
+ /**
5
+ * The zon timing for a series that changes: spread it on `Line`, `Area`, `Bar`, `Pie`, `Radar`
6
+ * or `Scatter` (`<Area {...chartAnimation} … />`). Recharts' own defaults morph lines, areas and
7
+ * pies for 1.5s on a plain `ease`, so every new set of data drags; this ends in 300ms on the
8
+ * `--ease` curve (a strong ease-out). Recharts' `isAnimationActive="auto"` default still turns it
9
+ * off under `prefers-reduced-motion`.
10
+ */
11
+ export declare const chartAnimation: {
12
+ readonly animationDuration: 300;
13
+ readonly animationEasing: "cubic-bezier(0.16,1,0.3,1)";
14
+ };
4
15
  /** How one series is named and drawn. Keys are the `dataKey`s (or `nameKey` values) of the chart. */
5
16
  export interface ChartSeriesConfig {
6
17
  /** The series name shown in tooltips and legends. */
@@ -4,6 +4,18 @@ import * as React from "react";
4
4
  import * as RechartsPrimitive from "recharts";
5
5
  import { cn } from "../lib/cn.js";
6
6
  import { useLocale } from "./locale.js";
7
+ /* ── Motion ────────────────────────────────────────────────────────────────── */
8
+ /**
9
+ * The zon timing for a series that changes: spread it on `Line`, `Area`, `Bar`, `Pie`, `Radar`
10
+ * or `Scatter` (`<Area {...chartAnimation} … />`). Recharts' own defaults morph lines, areas and
11
+ * pies for 1.5s on a plain `ease`, so every new set of data drags; this ends in 300ms on the
12
+ * `--ease` curve (a strong ease-out). Recharts' `isAnimationActive="auto"` default still turns it
13
+ * off under `prefers-reduced-motion`.
14
+ */
15
+ export const chartAnimation = {
16
+ animationDuration: 300,
17
+ animationEasing: "cubic-bezier(0.16,1,0.3,1)",
18
+ };
7
19
  const ChartContext = React.createContext(null);
8
20
  /** The config of the nearest `ChartContainer`. For custom tooltip or legend content. */
9
21
  export function useChart() {
@@ -28,5 +28,5 @@ export function CollapsibleTrigger({ showIcon = true, className, children, ...pr
28
28
  }
29
29
  /** The hidden content. Height animates from `--collapsible-panel-height`. */
30
30
  export function CollapsiblePanel({ className, ...props }) {
31
- return (_jsx(BaseCollapsible.Panel, { "data-slot": "collapsible-panel", className: sx("h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-(--duration) ease-(--ease) data-ending-style:h-0 data-starting-style:h-0", className), ...props }));
31
+ return (_jsx(BaseCollapsible.Panel, { "data-slot": "collapsible-panel", className: sx("h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-(--duration-glide) ease-(--ease-glide) data-ending-style:h-0 data-starting-style:h-0", className), ...props }));
32
32
  }
@@ -171,7 +171,7 @@ export function CommandDialog({ items, filter, label, placeholder, emptyMessage,
171
171
  if (!open)
172
172
  setQuery("");
173
173
  onOpenChangeComplete?.(open);
174
- }, ...rootProps, children: [trigger && _jsx(BaseDialog.Trigger, { render: trigger }), _jsxs(BaseDialog.Portal, { children: [_jsx(BaseDialog.Backdrop, { "data-slot": "command-backdrop", className: overlayBackdrop }), _jsx(BaseDialog.Viewport, { "data-slot": "command-viewport", className: "fixed inset-0 z-50 flex items-start justify-center px-4 pt-[12dvh] pb-4 sm:pt-[16dvh]", children: _jsx(BaseDialog.Popup, { "data-slot": "command-dialog", "aria-label": label ?? text.label, dir: popupDir, className: cn("relative flex max-h-[min(34rem,calc(84dvh-1rem))] w-full max-w-[40rem] flex-col overflow-hidden rounded-card font-body outline-none", overlayCard, "popup-motion", className), children: _jsx(CommandContext.Provider, { value: context, children: _jsx(BaseAutocomplete.Root, { open: true, inline: true, items: groups, filteredItems: results, value: query, onValueChange: setQuery, itemToStringValue: (item) => item.label, autoHighlight: "always", keepHighlight: true, children: children ?? (_jsxs(_Fragment, { children: [_jsx(CommandInput, { placeholder: placeholder ?? text.placeholder }), _jsx(CommandEmpty, { children: emptyMessage === undefined ? text.empty : emptyMessage }), _jsx(CommandList, { children: (group) => (_jsx(CommandGroup, { items: group.items, label: group.value, children: (entry) => _jsx(CommandItem, { value: entry }, entry.value) }, group.value)) }), _jsx(CommandFooter, {})] })) }) }) }) })] })] }));
174
+ }, ...rootProps, children: [trigger && _jsx(BaseDialog.Trigger, { render: trigger }), _jsxs(BaseDialog.Portal, { children: [_jsx(BaseDialog.Backdrop, { "data-slot": "command-backdrop", className: cn(overlayBackdrop, "transition-none") }), _jsx(BaseDialog.Viewport, { "data-slot": "command-viewport", className: "fixed inset-0 z-50 flex items-start justify-center px-4 pt-[12dvh] pb-4 sm:pt-[16dvh]", children: _jsx(BaseDialog.Popup, { "data-slot": "command-dialog", "aria-label": label ?? text.label, dir: popupDir, className: cn("relative flex max-h-[min(34rem,calc(84dvh-1rem))] w-full max-w-[40rem] flex-col overflow-hidden rounded-card font-body outline-none", overlayCard, className), children: _jsx(CommandContext.Provider, { value: context, children: _jsx(BaseAutocomplete.Root, { open: true, inline: true, items: groups, filteredItems: results, value: query, onValueChange: setQuery, itemToStringValue: (item) => item.label, autoHighlight: "always", keepHighlight: true, children: children ?? (_jsxs(_Fragment, { children: [_jsx(CommandInput, { placeholder: placeholder ?? text.placeholder }), _jsx(CommandEmpty, { children: emptyMessage === undefined ? text.empty : emptyMessage }), _jsx(CommandList, { children: (group) => (_jsx(CommandGroup, { items: group.items, label: group.value, children: (entry) => _jsx(CommandItem, { value: entry }, entry.value) }, group.value)) }), _jsx(CommandFooter, {})] })) }) }) }) })] })] }));
175
175
  }
176
176
  /**
177
177
  * The search field: borderless, 46px, a search icon before it and an `Esc` hint after it.
@@ -216,8 +216,8 @@ export function CommandItem({ value, onItemSelect, closeOnSelect = true, classNa
216
216
  }, className: sx([
217
217
  "flex min-h-(--control-h) cursor-pointer scroll-my-2 items-center gap-3 rounded-item border border-transparent px-2.5 text-sm text-foreground-soft outline-none select-none",
218
218
  // The raised treatment, on the highlight only: the pointer moves the highlight, so a CSS
219
- // :hover lift (as in material-row) would show two raised rows while typing.
220
- "transition-[background-color,color,box-shadow] duration-(--duration) ease-brand",
219
+ // :hover lift (as in material-row) would show two raised rows while typing. No transition:
220
+ // the highlight follows the arrow keys at once, as in a menu or a select.
221
221
  "data-highlighted:bg-control-hover data-highlighted:bg-[linear-gradient(180deg,var(--control-inner-edge),transparent)] data-highlighted:text-foreground data-highlighted:shadow-raised",
222
222
  "data-disabled:pointer-events-none data-disabled:opacity-50",
223
223
  "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&>svg]:text-muted-foreground data-highlighted:[&>svg]:text-foreground",
@@ -92,8 +92,13 @@ export function Conversation({ className, style, children, ref, onScroll, ...pro
92
92
  return;
93
93
  setStuck(true);
94
94
  setAtBottom(true);
95
- el.scrollTo({ top: el.scrollHeight, behavior: reducedMotion() ? "auto" : behavior });
96
- }, [setStuck]);
95
+ // Smooth is the same glide that follows a reply (follow jumps under reduced motion), so the
96
+ // jump back lands like the stream does, and keeps landing if the reply grows on the way.
97
+ if (behavior === "smooth")
98
+ follow();
99
+ else
100
+ el.scrollTo({ top: el.scrollHeight, behavior });
101
+ }, [setStuck, follow]);
97
102
  const focusLog = React.useCallback(() => scroller.current?.focus({ preventScroll: true }), []);
98
103
  React.useEffect(() => () => {
99
104
  const g = glide.current;
@@ -297,7 +302,9 @@ export function ConversationScrollButton({ label, className, onClick, ...props }
297
302
  context.focusLog();
298
303
  context.scrollToBottom();
299
304
  }, className: sx([
300
- "absolute bottom-4 left-1/2 -translate-x-1/2 transition-[opacity,translate] duration-(--duration) ease-(--ease)",
305
+ // The fade and the rise ride the material's own transition list (--material-motion): a
306
+ // transition utility would replace it, and the hover and the press would snap.
307
+ "absolute bottom-4 left-1/2 -translate-x-1/2 [--material-motion:opacity_var(--duration-fade)_var(--ease),translate_var(--duration)_var(--ease)]",
301
308
  visible ? "opacity-100" : "pointer-events-none translate-y-2 opacity-0",
302
309
  ], className), ...props, children: _jsx(ArrowDownIcon, { "aria-hidden": true }) }));
303
310
  }
@@ -41,11 +41,13 @@ async function writeClipboard(text) {
41
41
  throw error;
42
42
  }
43
43
  }
44
- /* Two faces stacked in one grid cell: the one at rest and the one that answers. They cross-fade
45
- and swap scale on --duration (0 under reduced motion), so the button never changes size. */
46
- const face = "col-start-1 row-start-1 place-self-center transition-[opacity,scale] duration-(--duration) ease-(--ease)";
47
- const shown = "scale-100 opacity-100";
48
- const hidden = "scale-50 opacity-0";
44
+ /* Two faces stacked in one grid cell: the one at rest and the one that answers, so the button
45
+ never changes size. They cross-fade on --duration-fade and swap from 85% with a 2px blur on
46
+ --duration — never from nothing, and the blur hides the moment both are half there. Reduced
47
+ motion keeps the fade only. */
48
+ const face = "col-start-1 row-start-1 place-self-center transition-[opacity,scale,filter] [transition-duration:var(--duration-fade),var(--duration),var(--duration)] ease-(--ease)";
49
+ const shown = "scale-100 opacity-100 blur-none";
50
+ const hidden = "scale-[0.85] opacity-0 blur-[2px]";
49
51
  /**
50
52
  * CopyButton — copies a value to the clipboard and says so: the copy icon turns into a check for
51
53
  * a moment and a polite live region announces "Copied". If the clipboard refuses, it shows a
@@ -13,6 +13,8 @@ import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator } from "./toolba
13
13
  import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
14
14
  /** Networks of up to this many nodes settle live around a dragged node. */
15
15
  const LIVE_DRAG_MAX = 300;
16
+ /** One d3-force tick: the simulation is tuned for one per frame at 60Hz. */
17
+ const TICK_MS = 1000 / 60;
16
18
  const newNodes = {
17
19
  task: "New step",
18
20
  start: "Start",
@@ -609,9 +611,10 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
609
611
  const value = toValue(from.nodes, from.edges);
610
612
  const next = build({ nodes: value.nodes.map(({ position: _p, size: _s, ...n }) => n), edges: value.edges }, layout, direction);
611
613
  const el = frame.current;
612
- const duration = el ? cssDuration(el) * 3 : 0;
614
+ // Twice --duration: a move the interface makes on its own, ended within 300ms.
615
+ const duration = el ? cssDuration(el) * 2 : 0;
613
616
  // Without motion (reduced motion) the camera jumps too.
614
- const fit = () => requestAnimationFrame(() => void flow.fitView({ padding: 0.18, maxZoom: 1.15, duration: duration ? 280 : 0 }));
617
+ const fit = () => requestAnimationFrame(() => void flow.fitView({ padding: 0.18, maxZoom: 1.15, duration }));
615
618
  if (!el || !duration) {
616
619
  setState(next);
617
620
  emit(next);
@@ -625,7 +628,8 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
625
628
  const camera1 = pane
626
629
  ? getViewportForBounds(boxAround(next.nodes.filter((n) => !n.parentId)), pane.clientWidth, pane.clientHeight, 0.2, 1.15, 0.18)
627
630
  : null;
628
- const ease = getComputedStyle(el).getPropertyValue("--ease").trim() || "ease-out";
631
+ // The interface moves the nodes from A to B on its own: ease in and out.
632
+ const ease = getComputedStyle(el).getPropertyValue("--ease-move").trim() || "ease-in-out";
629
633
  // No keyframes: the animation only keeps the clock; its progress places the nodes.
630
634
  const clock = el.animate([], { duration, easing: ease });
631
635
  let raf = 0;
@@ -699,8 +703,21 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
699
703
  const sizes = new Map(s.nodes.map((n) => [n.id, { w: n.width ?? 0, h: n.height ?? 0 }]));
700
704
  const byId = new Map(sim.map((d) => [d.id, d]));
701
705
  const held = new Set([node.id]);
702
- const step = () => {
703
- simulation.tick();
706
+ // d3-force is tuned for one tick per 60Hz frame: tick by the time that has passed, so a
707
+ // 120Hz screen does not settle twice as fast and a dropped frame does not stall it.
708
+ let last = 0;
709
+ let owed = 0;
710
+ const step = (now) => {
711
+ owed += last ? Math.min(now - last, 50) / TICK_MS : 1;
712
+ last = now;
713
+ // One to three ticks a frame; time beyond that (a long stall) is dropped, not caught up.
714
+ const ticks = Math.min(3, Math.floor(owed));
715
+ owed = ticks === 3 ? 0 : owed - ticks;
716
+ if (!ticks) {
717
+ frame = requestAnimationFrame(step);
718
+ return;
719
+ }
720
+ simulation.tick(ticks);
704
721
  setState((prev) => {
705
722
  const next = {
706
723
  ...prev,
@@ -814,12 +831,12 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
814
831
  return;
815
832
  event.preventDefault();
816
833
  setEditing({ kind: "node", id: node.dataset.id });
817
- }, ...props, children: [_jsx("svg", { "aria-hidden": true, className: "absolute size-0", children: _jsx("defs", { children: ["rest", "lit"].map((tone) => (_jsx("marker", { id: `${markers}-${tone}`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: _jsx("path", { d: "M1 1.5 L9 5 L1 8.5 Z", "data-tone": tone, className: "zon-graph-arrow" }) }, tone))) }) }), editable ? (_jsxs(ContextMenu, { children: [_jsx(ContextMenuTrigger, { className: "absolute inset-0", onContextMenuCapture: pick, children: canvas }), _jsxs(ContextMenuContent, { children: [target?.type === "pane" && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuGroup, { children: [_jsx(ContextMenuGroupLabel, { children: text.addHere }), addable[layout].map((kind) => (_jsxs(ContextMenuItem, { onClick: () => addNode(target.at, kind), children: [_jsx(PlusIcon, {}), text.kind(kind)] }, kind)))] }), _jsx(ContextMenuSeparator, {}), layout !== "none" && (_jsxs(ContextMenuItem, { onClick: tidy, children: [_jsx(WandSparklesIcon, {}), text.tidy] })), _jsxs(ContextMenuItem, { onClick: () => void flow.fitView({ padding: 0.18, maxZoom: 1.15, duration: 280 }), children: [_jsx(MaximizeIcon, {}), text.fit] })] })), (target?.type === "node" || target?.type === "group") && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuItem, { onClick: () => setEditing({ kind: "node", id: target.id }), children: [_jsx(PencilIcon, {}), text.rename, _jsx(ContextMenuShortcut, { children: text.enterKey })] }), target.type === "node" && (_jsxs(_Fragment, { children: [_jsx(ContextMenuSeparator, {}), _jsxs(ContextMenuItem, { variant: "destructive", onClick: () => removeNode(target.id), children: [_jsx(Trash2Icon, {}), text.delete, _jsx(ContextMenuShortcut, { children: text.deleteKey })] })] }))] })), target?.type === "edge" && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuItem, { onClick: () => setEditing({ kind: "edge", id: target.id }), children: [_jsx(PencilIcon, {}), targetEdge?.data?.edge.label ? text.renameLabel : text.addLabel] }), targetEdge && isDirected(targetEdge.data.edge, layout) && (_jsxs(ContextMenuItem, { onClick: () => reverse(target.id), children: [_jsx(ArrowLeftRightIcon, {}), text.reverse] })), _jsx(ContextMenuSeparator, {}), _jsxs(ContextMenuItem, { variant: "destructive", onClick: () => removeEdge(target.id), children: [_jsx(Trash2Icon, {}), text.removeConnection, _jsx(ContextMenuShortcut, { children: text.deleteKey })] })] }))] })] })) : (canvas), _jsx("ul", { id: describedBy, className: "sr-only", children: state.edges.map((e) => (_jsxs("li", { children: [text.connection(nodeLabels.get(e.source) ?? e.source, nodeLabels.get(e.target) ?? e.target, isDirected(e.data.edge, layout)), e.data.edge.label ? `: ${e.data.edge.label}` : ""] }, e.id))) })] }) }));
834
+ }, ...props, children: [_jsx("svg", { "aria-hidden": true, className: "absolute size-0", children: _jsx("defs", { children: ["rest", "lit"].map((tone) => (_jsx("marker", { id: `${markers}-${tone}`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: _jsx("path", { d: "M1 1.5 L9 5 L1 8.5 Z", "data-tone": tone, className: "zon-graph-arrow" }) }, tone))) }) }), editable ? (_jsxs(ContextMenu, { children: [_jsx(ContextMenuTrigger, { className: "absolute inset-0", onContextMenuCapture: pick, children: canvas }), _jsxs(ContextMenuContent, { children: [target?.type === "pane" && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuGroup, { children: [_jsx(ContextMenuGroupLabel, { children: text.addHere }), addable[layout].map((kind) => (_jsxs(ContextMenuItem, { onClick: () => addNode(target.at, kind), children: [_jsx(PlusIcon, {}), text.kind(kind)] }, kind)))] }), _jsx(ContextMenuSeparator, {}), layout !== "none" && (_jsxs(ContextMenuItem, { onClick: tidy, children: [_jsx(WandSparklesIcon, {}), text.tidy] })), _jsxs(ContextMenuItem, { onClick: () => void flow.fitView({ padding: 0.18, maxZoom: 1.15, duration: cssDuration() * 2 }), children: [_jsx(MaximizeIcon, {}), text.fit] })] })), (target?.type === "node" || target?.type === "group") && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuItem, { onClick: () => setEditing({ kind: "node", id: target.id }), children: [_jsx(PencilIcon, {}), text.rename, _jsx(ContextMenuShortcut, { children: text.enterKey })] }), target.type === "node" && (_jsxs(_Fragment, { children: [_jsx(ContextMenuSeparator, {}), _jsxs(ContextMenuItem, { variant: "destructive", onClick: () => removeNode(target.id), children: [_jsx(Trash2Icon, {}), text.delete, _jsx(ContextMenuShortcut, { children: text.deleteKey })] })] }))] })), target?.type === "edge" && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuItem, { onClick: () => setEditing({ kind: "edge", id: target.id }), children: [_jsx(PencilIcon, {}), targetEdge?.data?.edge.label ? text.renameLabel : text.addLabel] }), targetEdge && isDirected(targetEdge.data.edge, layout) && (_jsxs(ContextMenuItem, { onClick: () => reverse(target.id), children: [_jsx(ArrowLeftRightIcon, {}), text.reverse] })), _jsx(ContextMenuSeparator, {}), _jsxs(ContextMenuItem, { variant: "destructive", onClick: () => removeEdge(target.id), children: [_jsx(Trash2Icon, {}), text.removeConnection, _jsx(ContextMenuShortcut, { children: text.deleteKey })] })] }))] })] })) : (canvas), _jsx("ul", { id: describedBy, className: "sr-only", children: state.edges.map((e) => (_jsxs("li", { children: [text.connection(nodeLabels.get(e.source) ?? e.source, nodeLabels.get(e.target) ?? e.target, isDirected(e.data.edge, layout)), e.data.edge.label ? `: ${e.data.edge.label}` : ""] }, e.id))) })] }) }));
818
835
  }
819
836
  function ControlButton({ label, onClick, children, }) {
820
837
  return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(ToolbarButton, { "aria-label": label, onClick: onClick }), children: children }), _jsx(TooltipContent, { side: "top", children: label })] }));
821
838
  }
822
839
  function GraphControls({ text, editable, tidy, add, }) {
823
840
  const flow = useReactFlow();
824
- return (_jsxs(Toolbar, { "aria-label": text.controls, "data-slot": "graph-controls", children: [_jsxs(ToolbarGroup, { children: [_jsx(ControlButton, { label: text.zoomIn, onClick: () => void flow.zoomIn({ duration: 200 }), children: _jsx(PlusIcon, {}) }), _jsx(ControlButton, { label: text.zoomOut, onClick: () => void flow.zoomOut({ duration: 200 }), children: _jsx(MinusIcon, {}) }), _jsx(ControlButton, { label: text.fit, onClick: () => void flow.fitView({ padding: 0.18, maxZoom: 1.15, duration: 280 }), children: _jsx(MaximizeIcon, {}) })] }), (editable || tidy) && _jsx(ToolbarSeparator, {}), _jsxs(ToolbarGroup, { children: [editable && (_jsx(ControlButton, { label: text.addNode, onClick: add, children: _jsx(CircleDotIcon, {}) })), tidy && (_jsx(ControlButton, { label: text.tidy, onClick: tidy, children: _jsx(WandSparklesIcon, {}) }))] })] }));
841
+ return (_jsxs(Toolbar, { "aria-label": text.controls, "data-slot": "graph-controls", children: [_jsxs(ToolbarGroup, { children: [_jsx(ControlButton, { label: text.zoomIn, onClick: () => void flow.zoomIn({ duration: cssDuration() * 2 }), children: _jsx(PlusIcon, {}) }), _jsx(ControlButton, { label: text.zoomOut, onClick: () => void flow.zoomOut({ duration: cssDuration() * 2 }), children: _jsx(MinusIcon, {}) }), _jsx(ControlButton, { label: text.fit, onClick: () => void flow.fitView({ padding: 0.18, maxZoom: 1.15, duration: cssDuration() * 2 }), children: _jsx(MaximizeIcon, {}) })] }), (editable || tidy) && _jsx(ToolbarSeparator, {}), _jsxs(ToolbarGroup, { children: [editable && (_jsx(ControlButton, { label: text.addNode, onClick: add, children: _jsx(CircleDotIcon, {}) })), tidy && (_jsx(ControlButton, { label: text.tidy, onClick: tidy, children: _jsx(WandSparklesIcon, {}) }))] })] }));
825
842
  }
@@ -114,20 +114,67 @@ function EditorialImage({ entry, priority, title, className, style, }) {
114
114
  function CornerMark({ className }) {
115
115
  return (_jsx("svg", { "aria-hidden": true, focusable: "false", viewBox: "0 0 13 13", className: cn("pointer-events-none absolute z-3 size-[13px] text-(--sheet-mark)", className), children: _jsx("path", { d: "M6.5 0v13M0 6.5h13", stroke: "currentColor", strokeWidth: "1", shapeRendering: "crispEdges" }) }));
116
116
  }
117
+ const sheetLights = new WeakMap();
118
+ /**
119
+ * One frame of a sheet's light: read the pointer against the sheet once, however many moves came
120
+ * in, and close most of the way to it by the time since the last frame — the same at any refresh
121
+ * rate. It eases after the pointer like a light, rather than sticking to it like a cursor, and
122
+ * stops once it is there.
123
+ */
124
+ function stepLight(el, now) {
125
+ const l = sheetLights.get(el);
126
+ if (!l)
127
+ return;
128
+ const rect = el.getBoundingClientRect();
129
+ const tx = rect.width ? ((l.cx - rect.left) / rect.width) * 100 : 0;
130
+ const ty = rect.height ? ((l.cy - rect.top) / rect.height) * 100 : 0;
131
+ if (!l.placed) {
132
+ l.placed = true;
133
+ l.x = tx;
134
+ l.y = ty;
135
+ }
136
+ const dt = l.last ? Math.min(64, now - l.last) : 16;
137
+ l.last = now;
138
+ const k = 1 - Math.exp(-dt / 70);
139
+ l.x += (tx - l.x) * k;
140
+ l.y += (ty - l.y) * k;
141
+ const done = Math.abs(tx - l.x) < 0.05 && Math.abs(ty - l.y) < 0.05;
142
+ if (done) {
143
+ l.x = tx;
144
+ l.y = ty;
145
+ }
146
+ el.style.setProperty("--lx", `${l.x.toFixed(2)}%`);
147
+ el.style.setProperty("--ly", `${l.y.toFixed(2)}%`);
148
+ if (done) {
149
+ l.frame = 0;
150
+ l.last = 0;
151
+ }
152
+ else
153
+ l.frame = requestAnimationFrame((t) => stepLight(el, t));
154
+ }
117
155
  function setLight(event, lit) {
118
156
  const el = event.currentTarget;
119
157
  if (event.pointerType !== "mouse" && event.pointerType !== "pen")
120
158
  return;
121
159
  if (window.matchMedia("(prefers-reduced-motion: reduce)").matches)
122
160
  return;
161
+ let l = sheetLights.get(el);
162
+ if (!l)
163
+ sheetLights.set(el, (l = { x: 0, y: 0, cx: 0, cy: 0, last: 0, frame: 0, placed: false }));
123
164
  if (!lit) {
165
+ // The light fades out where it is; the next entry places it afresh.
166
+ cancelAnimationFrame(l.frame);
167
+ l.frame = 0;
168
+ l.last = 0;
169
+ l.placed = false;
124
170
  el.dataset.lit = "false";
125
171
  return;
126
172
  }
127
- const rect = el.getBoundingClientRect();
128
- el.style.setProperty("--lx", `${(((event.clientX - rect.left) / rect.width) * 100).toFixed(2)}%`);
129
- el.style.setProperty("--ly", `${(((event.clientY - rect.top) / rect.height) * 100).toFixed(2)}%`);
173
+ l.cx = event.clientX;
174
+ l.cy = event.clientY;
130
175
  el.dataset.lit = "true";
176
+ if (!l.frame)
177
+ l.frame = requestAnimationFrame((t) => stepLight(el, t));
131
178
  }
132
179
  /**
133
180
  * SpecSheet — the frame of the `sheet/…` entries, for your own sheets and walls: a square-cornered
@@ -14,7 +14,7 @@ declare module "./locale" {
14
14
  }
15
15
  }
16
16
  declare const groupSizes: {
17
- readonly sm: "min-h-(--control-h-sm) text-[13px]";
17
+ readonly sm: "min-h-(--control-h-sm) text-[13px] pointer-coarse:text-base";
18
18
  readonly default: "min-h-(--control-h) text-base sm:text-[15px]";
19
19
  };
20
20
  export interface InputGroupProps extends React.ComponentProps<"div"> {
@@ -132,7 +132,7 @@ export interface InputGroupClearButtonProps extends Omit<InputGroupButtonProps,
132
132
  * InputGroupClearButton — empties the field it sits in, smoothly: the text is erased right to
133
133
  * left behind a soft edge, as if typed away, then the value clears and focus returns to the
134
134
  * field. The button fades out while the field is empty and back in when there is text, instead of
135
- * popping in and out. Reduced motion clears at once.
135
+ * popping in and out. The keyboard (Enter, Space) and reduced motion clear at once.
136
136
  */
137
137
  export declare function InputGroupClearButton({ onClear, label, ref, className, ...props }: InputGroupClearButtonProps): React.JSX.Element;
138
138
  export {};
@@ -11,7 +11,7 @@ import { cssDuration } from "../lib/motion.js";
11
11
  import { useMessages } from "./locale.js";
12
12
  const defaultMessages = { showPassword: "Show password", clear: "Clear" };
13
13
  const groupSizes = {
14
- sm: "min-h-(--control-h-sm) text-[13px]",
14
+ sm: "min-h-(--control-h-sm) text-[13px] pointer-coarse:text-base",
15
15
  default: "min-h-(--control-h) text-base sm:text-[15px]",
16
16
  };
17
17
  /**
@@ -232,7 +232,7 @@ function EyeSlashIcon({ slashed }) {
232
232
  * InputGroupClearButton — empties the field it sits in, smoothly: the text is erased right to
233
233
  * left behind a soft edge, as if typed away, then the value clears and focus returns to the
234
234
  * field. The button fades out while the field is empty and back in when there is text, instead of
235
- * popping in and out. Reduced motion clears at once.
235
+ * popping in and out. The keyboard (Enter, Space) and reduced motion clear at once.
236
236
  */
237
237
  export function InputGroupClearButton({ onClear, label, ref, className, ...props }) {
238
238
  const text = useMessages("inputGroup", defaultMessages);
@@ -267,7 +267,7 @@ export function InputGroupClearButton({ onClear, label, ref, className, ...props
267
267
  input.form?.removeEventListener("reset", reset);
268
268
  };
269
269
  }, []);
270
- const clear = () => {
270
+ const clear = (event) => {
271
271
  const input = groupInput(own.current);
272
272
  if (!input || clearing.current)
273
273
  return;
@@ -281,7 +281,9 @@ export function InputGroupClearButton({ onClear, label, ref, className, ...props
281
281
  }
282
282
  input.focus();
283
283
  };
284
- const duration = cssDuration(input) * 1.6;
284
+ // One --duration, and none for Enter or Space (a click with no pointer, detail 0): a keyboard
285
+ // action never waits for an animation.
286
+ const duration = event.detail === 0 ? 0 : cssDuration(input);
285
287
  if (!duration || input.value === "") {
286
288
  done();
287
289
  return;
@@ -1,6 +1,6 @@
1
1
  import { Input as BaseInput } from "@base-ui/react/input";
2
2
  declare const sizes: {
3
- readonly sm: "min-h-(--control-h-sm) px-2.5 text-[13px] [&[type=file]]:p-0.5 [&[type=file]]:leading-none file:h-(--control-inset-sm)";
3
+ readonly sm: "min-h-(--control-h-sm) px-2.5 text-[13px] pointer-coarse:text-base [&[type=file]]:p-0.5 [&[type=file]]:leading-none file:h-(--control-inset-sm)";
4
4
  readonly default: "min-h-(--control-h) px-3.5 text-base sm:text-[15px] [&[type=file]]:p-[3px] [&[type=file]]:leading-none file:h-(--control-inset)";
5
5
  };
6
6
  export interface InputProps extends Omit<BaseInput.Props, "size"> {
@@ -3,7 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Input as BaseInput } from "@base-ui/react/input";
4
4
  import { sx } from "../lib/cn.js";
5
5
  const sizes = {
6
- sm: "min-h-(--control-h-sm) px-2.5 text-[13px] [&[type=file]]:p-0.5 [&[type=file]]:leading-none file:h-(--control-inset-sm)",
6
+ sm: "min-h-(--control-h-sm) px-2.5 text-[13px] pointer-coarse:text-base [&[type=file]]:p-0.5 [&[type=file]]:leading-none file:h-(--control-inset-sm)",
7
7
  default: "min-h-(--control-h) px-3.5 text-base sm:text-[15px] [&[type=file]]:p-[3px] [&[type=file]]:leading-none file:h-(--control-inset)",
8
8
  };
9
9
  /**
@@ -116,7 +116,8 @@ export interface GrainProps extends HTMLAttributes<HTMLDivElement> {
116
116
  }
117
117
  /**
118
118
  * Grain — an animated film-grain overlay that fills its positioned parent. It is
119
- * `aria-hidden`, ignores the pointer and holds still under reduced motion.
119
+ * `aria-hidden`, ignores the pointer and holds still under reduced motion, and on a phone or
120
+ * a touch screen: it moves only on a desktop.
120
121
  *
121
122
  * Use it on dark or large expressive regions to take the digital edge off a flat ground.
122
123
  * The rule people break: putting it over small text, where it costs contrast.
@@ -89,6 +89,8 @@ export function Blueprint({ cell, interactive = true, className, style, children
89
89
  const ref = useRef(null);
90
90
  const enabled = useRef(false);
91
91
  const frame = useRef(0);
92
+ /** Where the light is drawn, and where the pointer is: the light eases after it, frame by frame. */
93
+ const light = useRef({ x: 0, y: 0, cx: 0, cy: 0, last: 0, placed: false });
92
94
  useEffect(() => {
93
95
  if (!interactive || typeof window === "undefined" || !window.matchMedia)
94
96
  return;
@@ -103,25 +105,66 @@ export function Blueprint({ cell, interactive = true, className, style, children
103
105
  return () => {
104
106
  mq.removeEventListener("change", sync);
105
107
  cancelAnimationFrame(frame.current);
108
+ frame.current = 0;
106
109
  };
107
110
  }, [interactive]);
111
+ /**
112
+ * One frame of the light: it closes most of the way to the pointer (by the time since the last
113
+ * frame, so the same at any refresh rate) and keeps going until it is there. Tied to the pointer
114
+ * directly it moved like a cursor; easing after it, it moves like a light.
115
+ */
116
+ const step = useCallback((now) => {
117
+ const el = ref.current;
118
+ const l = light.current;
119
+ if (!el) {
120
+ frame.current = 0;
121
+ return;
122
+ }
123
+ // The pointer in the grid's box, read once a frame however many moves there were.
124
+ const r = el.getBoundingClientRect();
125
+ const tx = l.cx - r.left;
126
+ const ty = l.cy - r.top;
127
+ // Coming in, the light starts under the pointer (it fades in there), and eases after it.
128
+ if (!l.placed) {
129
+ l.placed = true;
130
+ l.x = tx;
131
+ l.y = ty;
132
+ }
133
+ const dt = l.last ? Math.min(64, now - l.last) : 16;
134
+ l.last = now;
135
+ const k = 1 - Math.exp(-dt / 70);
136
+ l.x += (tx - l.x) * k;
137
+ l.y += (ty - l.y) * k;
138
+ const done = Math.abs(tx - l.x) < 0.5 && Math.abs(ty - l.y) < 0.5;
139
+ if (done) {
140
+ l.x = tx;
141
+ l.y = ty;
142
+ }
143
+ el.style.setProperty("--mx", `${l.x.toFixed(1)}px`);
144
+ el.style.setProperty("--my", `${l.y.toFixed(1)}px`);
145
+ if (done) {
146
+ frame.current = 0;
147
+ l.last = 0;
148
+ }
149
+ else
150
+ frame.current = requestAnimationFrame(step);
151
+ }, []);
108
152
  const handleMove = useCallback((e) => {
109
153
  onPointerMove?.(e);
110
154
  const el = ref.current;
111
155
  if (!interactive || !enabled.current || !el || e.pointerType !== "mouse")
112
156
  return;
113
- const { clientX, clientY } = e;
114
- cancelAnimationFrame(frame.current);
115
- frame.current = requestAnimationFrame(() => {
116
- const r = el.getBoundingClientRect();
117
- el.style.setProperty("--mx", `${clientX - r.left}px`);
118
- el.style.setProperty("--my", `${clientY - r.top}px`);
119
- el.dataset.lit = "true";
120
- });
121
- }, [interactive, onPointerMove]);
157
+ const l = light.current;
158
+ l.cx = e.clientX;
159
+ l.cy = e.clientY;
160
+ el.dataset.lit = "true";
161
+ if (!frame.current)
162
+ frame.current = requestAnimationFrame(step);
163
+ }, [interactive, onPointerMove, step]);
122
164
  const handleLeave = useCallback((e) => {
123
165
  onPointerLeave?.(e);
124
- cancelAnimationFrame(frame.current);
166
+ // The light fades out where it is; the next entry places it afresh.
167
+ light.current.placed = false;
125
168
  if (ref.current)
126
169
  ref.current.dataset.lit = "false";
127
170
  }, [onPointerLeave]);
@@ -140,7 +183,8 @@ export function DotField({ className, children, ...props }) {
140
183
  }
141
184
  /**
142
185
  * Grain — an animated film-grain overlay that fills its positioned parent. It is
143
- * `aria-hidden`, ignores the pointer and holds still under reduced motion.
186
+ * `aria-hidden`, ignores the pointer and holds still under reduced motion, and on a phone or
187
+ * a touch screen: it moves only on a desktop.
144
188
  *
145
189
  * Use it on dark or large expressive regions to take the digital edge off a flat ground.
146
190
  * The rule people break: putting it over small text, where it costs contrast.
@@ -127,9 +127,11 @@ export function LightboxGrid({ columns = 4, className, ...props }) {
127
127
  /** The furthest zoom, and the one a double click goes to when the image is no larger than its place. */
128
128
  const MAX_ZOOM = 4;
129
129
  const STEP_ZOOM = 2;
130
- /** A swipe that goes further than this, or flicks faster, turns the page. */
130
+ /** A swipe that goes further than this, or flicks faster (px/ms, over at least 20px), turns the page. */
131
131
  const SWIPE = 60;
132
- const FLICK = 0.5;
132
+ const FLICK = 0.11;
133
+ /** A wheel or trackpad pinch counts as one gesture until this long (ms) after its last event. */
134
+ const WHEEL_SETTLE = 120;
133
135
  /** Two taps this close in time and place are a double tap. */
134
136
  const DOUBLE_TAP = 300;
135
137
  const REST = { scale: 1, x: 0, y: 0 };
@@ -151,6 +153,10 @@ function LightboxViewer() {
151
153
  };
152
154
  const [swipe, setSwipe] = React.useState(0);
153
155
  const [gesturing, setGesturing] = React.useState(false);
156
+ // While the wheel or a trackpad pinch is moving, the image follows each event at once: a
157
+ // transition retargeted on every event would trail behind the fingers.
158
+ const [wheeling, setWheeling] = React.useState(false);
159
+ const wheelTimer = React.useRef(undefined);
154
160
  const [loaded, setLoaded] = React.useState(false);
155
161
  const canPrev = loop ? count > 1 : index > 0;
156
162
  const canNext = loop ? count > 1 : index < count - 1;
@@ -374,11 +380,23 @@ function LightboxViewer() {
374
380
  return;
375
381
  const onWheel = (event) => {
376
382
  event.preventDefault();
383
+ if (wheelTimer.current === undefined)
384
+ setWheeling(true);
385
+ clearTimeout(wheelTimer.current);
386
+ wheelTimer.current = setTimeout(() => {
387
+ wheelTimer.current = undefined;
388
+ setWheeling(false);
389
+ }, WHEEL_SETTLE);
377
390
  const factor = Math.exp(-event.deltaY * (event.ctrlKey ? 0.01 : 0.002));
378
391
  zoomTo(viewRef.current.scale * factor, { x: event.clientX, y: event.clientY });
379
392
  };
380
393
  frame.addEventListener("wheel", onWheel, { passive: false });
381
- return () => frame.removeEventListener("wheel", onWheel);
394
+ return () => {
395
+ frame.removeEventListener("wheel", onWheel);
396
+ clearTimeout(wheelTimer.current);
397
+ wheelTimer.current = undefined;
398
+ setWheeling(false);
399
+ };
382
400
  // eslint-disable-next-line react-hooks/exhaustive-deps
383
401
  }, [open, index]);
384
402
  const onKeyDown = (event) => {
@@ -435,5 +453,5 @@ function LightboxViewer() {
435
453
  }, onDoubleClick: (event) => {
436
454
  if (lastPointerType.current !== "touch")
437
455
  toggleZoom({ x: event.clientX, y: event.clientY });
438
- }, className: cn("relative flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden px-4 py-3 select-none sm:px-20", zoomed && (gesturing ? "cursor-grabbing" : "cursor-grab")), children: [!loaded && (_jsx(Spinner, { label: text.loading, className: "absolute top-1/2 left-1/2 -translate-1/2 text-muted-foreground" })), _jsx("img", { ref: imgRef, "data-slot": "lightbox-image", src: image.src, srcSet: image.srcSet, sizes: image.sizes, alt: image.alt, draggable: false, onLoad: () => setLoaded(true), onError: () => setLoaded(true), style: { transform: `translate(${view.x + swipe}px, ${view.y}px) scale(${view.scale})` }, className: cn("max-h-full max-w-full object-contain", !zoomed && "cursor-zoom-in", "transition-[opacity,transform] duration-(--duration) ease-(--ease) will-change-transform", gesturing && "transition-none", loaded ? "opacity-100" : "opacity-0", context.imageClassName) }, index), count > 1 && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "secondary", size: "icon", "data-slot": "lightbox-previous", "aria-label": text.previous, disabled: !canPrev, focusableWhenDisabled: true, onClick: () => go(-1), className: "absolute start-3 top-1/2 z-10 -translate-y-1/2 sm:start-5", children: _jsx(ChevronLeftIcon, { className: "rtl:-scale-x-100" }) }), _jsx(Button, { variant: "secondary", size: "icon", "data-slot": "lightbox-next", "aria-label": text.next, disabled: !canNext, focusableWhenDisabled: true, onClick: () => go(1), className: "absolute end-3 top-1/2 z-10 -translate-y-1/2 sm:end-5", children: _jsx(ChevronRightIcon, { className: "rtl:-scale-x-100" }) })] }))] }), _jsx("div", { "data-slot": "lightbox-caption", className: "relative z-10 mx-auto min-h-14 w-full max-w-2xl shrink-0 px-6 pt-2 pb-5 text-center text-[15px] leading-relaxed text-pretty text-foreground-soft", children: image.caption }), _jsx("div", { "data-slot": "lightbox-status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: open ? `${text.position(index + 1, count)}${image.alt ? `: ${image.alt}` : ""}` : "" })] })] }));
456
+ }, className: cn("relative flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden px-4 py-3 select-none sm:px-20", zoomed && (gesturing ? "cursor-grabbing" : "cursor-grab")), children: [!loaded && (_jsx(Spinner, { label: text.loading, className: "absolute top-1/2 left-1/2 -translate-1/2 text-muted-foreground" })), _jsx("img", { ref: imgRef, "data-slot": "lightbox-image", src: image.src, srcSet: image.srcSet, sizes: image.sizes, alt: image.alt, draggable: false, onLoad: () => setLoaded(true), onError: () => setLoaded(true), style: { transform: `translate(${view.x + swipe}px, ${view.y}px) scale(${view.scale})` }, className: cn("max-h-full max-w-full object-contain", !zoomed && "cursor-zoom-in", "transition-[opacity,transform] duration-(--duration) ease-(--ease) will-change-transform", (gesturing || wheeling) && "transition-none", loaded ? "opacity-100" : "opacity-0", context.imageClassName) }, index), count > 1 && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "secondary", size: "icon", "data-slot": "lightbox-previous", "aria-label": text.previous, disabled: !canPrev, focusableWhenDisabled: true, onClick: () => go(-1), className: "absolute start-3 top-1/2 z-10 -translate-y-1/2 sm:start-5", children: _jsx(ChevronLeftIcon, { className: "rtl:-scale-x-100" }) }), _jsx(Button, { variant: "secondary", size: "icon", "data-slot": "lightbox-next", "aria-label": text.next, disabled: !canNext, focusableWhenDisabled: true, onClick: () => go(1), className: "absolute end-3 top-1/2 z-10 -translate-y-1/2 sm:end-5", children: _jsx(ChevronRightIcon, { className: "rtl:-scale-x-100" }) })] }))] }), _jsx("div", { "data-slot": "lightbox-caption", className: "relative z-10 mx-auto min-h-14 w-full max-w-2xl shrink-0 px-6 pt-2 pb-5 text-center text-[15px] leading-relaxed text-pretty text-foreground-soft", children: image.caption }), _jsx("div", { "data-slot": "lightbox-status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: open ? `${text.position(index + 1, count)}${image.alt ? `: ${image.alt}` : ""}` : "" })] })] }));
439
457
  }