@tristan2828/ui-foundation 4.128.0 → 4.129.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -118,13 +118,19 @@ Follow `docs/foundation/reminders.md`. Never ask for notification
118
118
  permission on page load: only from the click on "Allow Reminders".
119
119
 
120
120
  ## Scope and Stopping
121
- - Do the task you were given and nothing beyond it. A task is done when
122
- `npm run verify` passes — not when it feels complete.
123
- - If verify cannot pass without breaking a Hard Rule, an instruction
121
+ - Do the task you were given. Its tests, its docs and anything it breaks
122
+ are part of it; a refactor or a feature nobody asked for is not. Ideas
123
+ beyond the task go in the app's backlog, not in code.
124
+ - A task is done when the app's gate passes, not when it feels complete:
125
+ `npm run verify`, unless the app's own section below names its gate. Do
126
+ not report a task complete on a failing gate. The developer reviews
127
+ results (the running app, a screenshot, an options page), not every
128
+ line, so the gates are the safety net.
129
+ - If the gate cannot pass without breaking a Hard Rule, an instruction
124
130
  conflicts with current library docs, or the change would exceed the
125
- task's scope: write `docs/BLOCKERS.md` (what, why, what you tried) and
126
- stop. Do not guess, do not widen scope.
127
- - Ideas that are out of scope go in the app's backlog, not in code.
131
+ task's scope: stop. In a chat with the developer, ask them; working
132
+ alone, write `docs/BLOCKERS.md` (what, why, what you tried). Do not
133
+ guess past it, and do not widen the task to get around it.
128
134
 
129
135
  ## Correct Patterns
130
136
  ```tsx
@@ -153,12 +159,6 @@ before guessing props — component APIs move between releases and training
153
159
  data lags them. The package's own props are in its type declarations
154
160
  (`node_modules/@tristan2828/ui-foundation/dist/**/*.d.ts`).
155
161
 
156
- ## Before You Finish
157
- Run `npm run verify`. It must pass. Do not report a task complete on a
158
- failing gate. The developer reviews results — the running app, a
159
- screenshot, an options page — not every line, so the gates are the safety
160
- net.
161
-
162
162
  ## Adding an Entity
163
163
  Follow `docs/foundation/add-an-entity.md` (in Claude Code, `/new-entity
164
164
  <Name>` is a shortcut to it). It builds from the entity's plan,
@@ -2,6 +2,7 @@
2
2
  name: spec-tester
3
3
  description: Writes gateway translation tests from openapi.yaml and contracts.ts only. Used in Phase 2 and by the new-entity playbook — never invoked to test code it can read.
4
4
  tools: Read, Write, Bash(vitest *)
5
+ model: sonnet
5
6
  hooks:
6
7
  PreToolUse:
7
8
  - matcher: "Read"
@@ -3,41 +3,42 @@
3
3
  <!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
4
4
  ## Index
5
5
 
6
- - [Palettes](#palettes) · lines 50–159
7
- - [Glow](#glow) · lines 161–180
8
- - [Semantic tones](#semantic-tones) · lines 182–210
9
- - [The three badge styles](#the-three-badge-styles) · lines 212–229
10
- - [Status marks](#status-marks) · lines 231–276
11
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 278–307
12
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 309–322
13
- - [Logos and brand marks](#logos-and-brand-marks) · lines 324–368
14
- - [Categorical colour](#categorical-colour) · lines 370–440
15
- - [Heat scale](#heat-scale) · lines 442–503
16
- - [Depth ramps](#depth-ramps) · lines 505–590
17
- - [A stored colour](#a-stored-colour) · lines 592–649
18
- - [Shapes and sizes](#shapes-and-sizes) · lines 651–672
19
- - [Typography](#typography) · lines 674–845
20
- - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 708–741
21
- - [Written text (notes)](#written-text-notes) · lines 743–845
22
- - [Density](#density) · lines 847–940
23
- - [Rows on this device](#rows-on-this-device) · lines 913–940
24
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 942–1056
25
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1058–1135
26
- - [Notices](#notices) · lines 1137–1165
27
- - [A value over time](#a-value-over-time) · lines 1167–1253
28
- - [Several values over time](#several-values-over-time) · lines 1216–1253
29
- - [A list as a board](#a-list-as-a-board) · lines 1255–1306
30
- - [A list as cards](#a-list-as-cards) · lines 1308–1354
31
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1356–1392
32
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1394–1464
33
- - [A few equal things](#a-few-equal-things) · lines 1466–1586
34
- - [An overview page](#an-overview-page) · lines 1588–1659
35
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1660–1726
36
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1728–1865
37
- - [Picking at random](#picking-at-random) · lines 1867–1898
38
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1900–1967
39
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1969–1994
40
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1996–2092
6
+ - [Palettes](#palettes) · lines 51–160
7
+ - [Glow](#glow) · lines 162–181
8
+ - [Semantic tones](#semantic-tones) · lines 183–211
9
+ - [The three badge styles](#the-three-badge-styles) · lines 213–230
10
+ - [Status marks](#status-marks) · lines 232–277
11
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 279–308
12
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 310–323
13
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 325–369
14
+ - [Categorical colour](#categorical-colour) · lines 371–441
15
+ - [Heat scale](#heat-scale) · lines 443–504
16
+ - [Depth ramps](#depth-ramps) · lines 506–591
17
+ - [A stored colour](#a-stored-colour) · lines 593–650
18
+ - [Shapes and sizes](#shapes-and-sizes) · lines 652–673
19
+ - [Typography](#typography) · lines 675–846
20
+ - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 709–742
21
+ - [Written text (notes)](#written-text-notes) · lines 744–846
22
+ - [Density](#density) · lines 848–941
23
+ - [Rows on this device](#rows-on-this-device) · lines 914–941
24
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 943–1057
25
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1059–1136
26
+ - [Notices](#notices) · lines 1138–1166
27
+ - [A value over time](#a-value-over-time) · lines 1168–1254
28
+ - [Several values over time](#several-values-over-time) · lines 1217–1254
29
+ - [A list as a board](#a-list-as-a-board) · lines 1256–1307
30
+ - [A list as cards](#a-list-as-cards) · lines 1309–1355
31
+ - [Images full screen](#images-full-screen) · lines 1357–1403
32
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1405–1441
33
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1443–1513
34
+ - [A few equal things](#a-few-equal-things) · lines 1515–1635
35
+ - [An overview page](#an-overview-page) · lines 1637–1708
36
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1709–1775
37
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1777–1914
38
+ - [Picking at random](#picking-at-random) · lines 1916–1947
39
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1949–2016
40
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2018–2043
41
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2045–2141
41
42
 
42
43
  <!-- /index -->
43
44
 
@@ -1353,6 +1354,54 @@ const { layout, setLayout } = useTableLayout({
1353
1354
  - `totals` and `highlightRow` are the table's alone. Sorting is the
1354
1355
  toolbar's in a card layout (there is no header to click).
1355
1356
 
1357
+ ## Images full screen
1358
+
1359
+ `ImageViewer` (4.129) shows one of an ordered list of images large, over
1360
+ the whole viewport: a cover clicked in a grid, a record's photos, the
1361
+ pages kept from a set. It's the package's modal dialog, so focus stays in
1362
+ it while it's open and goes back to the cover that opened it.
1363
+
1364
+ ```tsx
1365
+ const [shown, setShown] = useState<number | null>(null)
1366
+
1367
+ <button aria-label={`Open ${book.title}`} onClick={() => setShown(i)}>
1368
+ <Artwork src={book.coverUrl} aspect="2:3" />
1369
+ </button>
1370
+
1371
+ <ImageViewer
1372
+ title="Covers"
1373
+ images={books.map((book) => ({ src: book.coverUrl, alt: `${book.title}, cover`, caption: book.title }))}
1374
+ index={shown}
1375
+ onIndexChange={setShown}
1376
+ actions={(image, i) => <Button onClick={() => readFrom(books[i])}>Read From Here</Button>}
1377
+ />
1378
+ ```
1379
+
1380
+ - **One value runs it:** `index` is the image shown, `null` while closed.
1381
+ The viewer calls `onIndexChange` with the next index on a step and with
1382
+ `null` on Esc and Close. An action that leaves (opens a page, starts a
1383
+ reading) sets it to `null` itself.
1384
+ - **The dark stage, always**, whatever the app's theme: the frame is the
1385
+ dark theme's tokens, so a picture's own colours never fight a light
1386
+ page. The image fits the frame whole (`object-contain`), any shape.
1387
+ - **Moving:** the round buttons at the frame's sides, ←/→ (Home and End
1388
+ for the ends), one image per wheel gesture, and a sideways swipe on a
1389
+ touch screen. The list doesn't wrap: at an end the button stays in the
1390
+ tab order, dimmed and `aria-disabled`, so focus is never dropped. The
1391
+ images either side are fetched ahead.
1392
+ - **Told to a screen reader:** the dialog is named by `title`, and each
1393
+ step announces "3 of 14: <alt>". So `alt` says what the image shows
1394
+ ("Issue 3, cover"), not "image". The visible counter ("3 of 14") shows
1395
+ with more than one image; with one there are no steps either.
1396
+ - **Below the image:** `caption` (a node: the name in semibold, the rest
1397
+ muted) and, beside it, the app's own `actions(image, index)`, one or
1398
+ two Buttons. On a phone they stack under the caption at full width.
1399
+ - **States in the frame:** a spinner while the image loads (the last one
1400
+ is never left showing), and "This image couldn't be loaded." with its
1401
+ `alt` and Try Again when it fails. The rest of the viewer still works.
1402
+ - Arrow keys typed into a control that uses them (a text box, a slider, a
1403
+ menu an action opened) stay that control's.
1404
+
1356
1405
  ## Key numbers on a record
1357
1406
 
1358
1407
  `KeyStats` (4.46), in `EntityView`'s `strip`: the few figures a record's
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ export type ImageViewerImage = {
3
+ src: string;
4
+ /** What the image shows, for a screen reader (and the frame's message if it fails). */
5
+ alt: string;
6
+ /** Shown under the image: a title, a date, a line about it. */
7
+ caption?: React.ReactNode;
8
+ };
9
+ export type ImageViewerProps<T extends ImageViewerImage = ImageViewerImage> = {
10
+ /** The images in order. */
11
+ images: readonly T[];
12
+ /** The image shown (an index into `images`); null while the viewer is closed. */
13
+ index: number | null;
14
+ /** Called with the new index on a step, and with null on Esc and Close. */
15
+ onIndexChange: (index: number | null) => void;
16
+ /** Names the viewer for screen readers, and heads it on screen. */
17
+ title: React.ReactNode;
18
+ /** An app's own controls beside the caption, for the image shown (a Button or two). */
19
+ actions?: (image: T, index: number) => React.ReactNode;
20
+ className?: string;
21
+ };
22
+ export declare function ImageViewer<T extends ImageViewerImage>({ images, index, onIndexChange, title, actions, className, }: ImageViewerProps<T>): React.JSX.Element;
@@ -0,0 +1,159 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // A full-screen image viewer (a lightbox): one of an ordered list of
3
+ // images, large, over the whole viewport, on the dark stage whatever the
4
+ // app's theme (photos and covers read best on dark, and the stage never
5
+ // fights the picture's own colours). Previous and next by the arrow
6
+ // buttons, the arrow keys (Home and End for the first and last), the mouse
7
+ // wheel and a swipe on a phone; Esc and Close leave. A counter ("3 of 14"),
8
+ // the image's caption, and an app's own actions beside it ("Read from
9
+ // here").
10
+ //
11
+ // It's the package's modal Dialog (Base UI) with its own popup, as
12
+ // SessionView is: focus stays inside while it's open and goes back to what
13
+ // opened it, and it's named by its title. Each image shows a spinner until
14
+ // it has loaded, and a message in the frame if it can't be, with Try
15
+ // Again. The neighbours are fetched ahead, so a step is usually instant.
16
+ //
17
+ // Controlled by one value: `index` is the image shown, null while closed.
18
+ // An app keeps `useState<number | null>(null)`, sets it from a click on a
19
+ // cover, and passes the setter as `onIndexChange`.
20
+ import * as React from 'react';
21
+ import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
22
+ import { ChevronLeftIcon, ChevronRightIcon, ImageOffIcon, XIcon } from 'lucide-react';
23
+ import { cn } from 'cn';
24
+ import { Button } from '../ui/button.js';
25
+ import { Dialog, DialogClose, DialogPortal, DialogTitle } from '../ui/dialog.js';
26
+ import { Spinner } from '../ui/spinner.js';
27
+ // A wheel gesture moves one image: a trackpad's flick sends dozens of
28
+ // events, so once a step is taken the rest of the gesture is ignored.
29
+ const WHEEL_THRESHOLD = 40;
30
+ const WHEEL_REST_MS = 350;
31
+ // A swipe is a mostly sideways touch drag at least this long.
32
+ const SWIPE_MIN_PX = 50;
33
+ export function ImageViewer({ images, index, onIndexChange, title, actions, className, }) {
34
+ const count = images.length;
35
+ const open = index !== null && count > 0;
36
+ // The last image shown, so the content stays while the viewer fades out.
37
+ // (React's "adjust state while rendering": the stored value follows `index`.)
38
+ const [lastShown, setLastShown] = React.useState(0);
39
+ const at = open ? clamp(index, count) : Math.min(lastShown, Math.max(count - 1, 0));
40
+ if (open && at !== lastShown)
41
+ setLastShown(at);
42
+ const image = images[at];
43
+ const canBack = at > 0;
44
+ const canForward = at < count - 1;
45
+ const go = React.useCallback((next) => {
46
+ if (!open || next < 0 || next >= count || next === at)
47
+ return;
48
+ onIndexChange(next);
49
+ }, [open, count, at, onIndexChange]);
50
+ // The keys, heard on the document in the capture phase: Base UI's focus
51
+ // handling stops arrow keys bubbling, and a click on the image can leave
52
+ // focus on the body. A key meant for a control that uses arrows itself
53
+ // (a text box, a slider, a menu an action opened) is left alone.
54
+ const popup = React.useRef(null);
55
+ React.useEffect(() => {
56
+ if (!open)
57
+ return;
58
+ const onKey = (event) => {
59
+ if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
60
+ return;
61
+ const target = event.target instanceof Node ? event.target : null;
62
+ const inViewer = target === document.body || (target !== null && !!popup.current?.contains(target));
63
+ if (!inViewer || usesArrows(event.target))
64
+ return;
65
+ const step = event.key === 'ArrowLeft' ? at - 1 : event.key === 'ArrowRight' ? at + 1 : event.key === 'Home' ? 0 : event.key === 'End' ? count - 1 : null;
66
+ if (step === null)
67
+ return;
68
+ event.preventDefault();
69
+ go(step);
70
+ };
71
+ document.addEventListener('keydown', onKey, true);
72
+ return () => document.removeEventListener('keydown', onKey, true);
73
+ }, [open, at, count, go]);
74
+ usePreload(open ? images : undefined, at);
75
+ const wheel = React.useRef({ total: 0, stepped: 0 });
76
+ const onWheel = (event) => {
77
+ const now = performance.now();
78
+ if (now - wheel.current.stepped < WHEEL_REST_MS)
79
+ return;
80
+ const delta = Math.abs(event.deltaX) > Math.abs(event.deltaY) ? event.deltaX : event.deltaY;
81
+ wheel.current.total += delta;
82
+ if (Math.abs(wheel.current.total) < WHEEL_THRESHOLD)
83
+ return;
84
+ go(wheel.current.total > 0 ? at + 1 : at - 1);
85
+ wheel.current = { total: 0, stepped: now };
86
+ };
87
+ const swipe = React.useRef(null);
88
+ const onPointerDown = (event) => {
89
+ if (event.pointerType !== 'touch')
90
+ return;
91
+ swipe.current = { id: event.pointerId, x: event.clientX, y: event.clientY };
92
+ };
93
+ const onPointerUp = (event) => {
94
+ const start = swipe.current;
95
+ swipe.current = null;
96
+ if (!start || start.id !== event.pointerId)
97
+ return;
98
+ const dx = event.clientX - start.x;
99
+ const dy = event.clientY - start.y;
100
+ if (Math.abs(dx) < SWIPE_MIN_PX || Math.abs(dx) < Math.abs(dy) * 1.5)
101
+ return;
102
+ go(dx < 0 ? at + 1 : at - 1);
103
+ };
104
+ const position = `${at + 1} of ${count}`;
105
+ const caption = image?.caption;
106
+ const ownActions = image && actions ? actions(image, at) : null;
107
+ return (_jsx(Dialog, { open: open, onOpenChange: (next) => !next && onIndexChange(null), children: _jsx(DialogPortal, { children: _jsxs(DialogPrimitive.Popup, { ref: popup, "data-slot": "image-viewer", className: cn(
108
+ // The dark stage: theme.css's .dark block remaps the tokens for this subtree only.
109
+ 'dark scheme-dark fixed inset-0 z-50 flex flex-col bg-background text-foreground outline-none', 'pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)]', 'duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0', className), children: [_jsxs("header", { className: "flex items-center gap-3 px-4 py-2", children: [_jsx(DialogTitle, { className: "min-w-0 flex-1 truncate type-section-title", children: title }), count > 1 && (_jsx("span", { "data-slot": "image-viewer-counter", "aria-hidden": true, className: "shrink-0 type-label text-muted-foreground tabular-nums", children: position })), _jsx(DialogClose, { render: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Close" }), children: _jsx(XIcon, {}) })] }), _jsx("p", { "aria-live": "polite", "aria-atomic": true, className: "sr-only", children: image ? (count > 1 ? `${position}: ${image.alt}` : image.alt) : '' }), _jsxs("div", { "data-slot": "image-viewer-frame", className: "relative min-h-0 flex-1 touch-pan-y touch-pinch-zoom select-none", onWheel: onWheel, onPointerDown: onPointerDown, onPointerUp: onPointerUp, onPointerCancel: () => (swipe.current = null), children: [image && _jsx(ViewerImage, { image: image }, image.src), count > 1 && (_jsxs(_Fragment, { children: [_jsx(StepButton, { side: "start", label: "Previous Image", available: canBack, onClick: () => go(at - 1) }), _jsx(StepButton, { side: "end", label: "Next Image", available: canForward, onClick: () => go(at + 1) })] }))] }), (caption || ownActions) && (_jsxs("footer", { "data-slot": "image-viewer-footer", className: "flex flex-col gap-3 px-4 pt-3 pb-4 md:flex-row md:items-center md:gap-6 md:px-6", children: [_jsx("div", { "data-slot": "image-viewer-caption", className: "min-w-0 flex-1 type-body text-foreground", children: caption }), ownActions && (_jsx("div", { "data-slot": "image-viewer-actions", className: "flex shrink-0 flex-wrap gap-2 max-md:[&>*]:flex-1", children: ownActions }))] }))] }) }) }));
110
+ }
111
+ // One image in the frame, keyed by its src, so each new one starts loading
112
+ // from scratch: the spinner over an empty frame, never the last picture.
113
+ function ViewerImage({ image }) {
114
+ const [state, setState] = React.useState('loading');
115
+ const [attempt, setAttempt] = React.useState(0);
116
+ // A cached image may have finished before React heard its load event.
117
+ const seeIfDone = React.useCallback((element) => {
118
+ if (element?.complete)
119
+ setState(element.naturalWidth > 0 ? 'loaded' : 'failed');
120
+ }, []);
121
+ return (_jsxs("div", { className: "absolute inset-x-4 inset-y-2 md:inset-x-20 md:inset-y-4", "data-state": state, children: [state !== 'failed' && (_jsx("img", { ref: seeIfDone, src: image.src, alt: image.alt, decoding: "async", draggable: false, onLoad: () => setState('loaded'), onError: () => setState('failed'), className: cn('size-full object-contain transition-opacity duration-150', state === 'loading' && 'opacity-0') }, attempt)), state === 'loading' && (_jsx("div", { "data-slot": "image-viewer-loading", className: "absolute inset-0 flex items-center justify-center", children: _jsx(Spinner, { className: "size-8 text-muted-foreground", "aria-label": "Loading image" }) })), state === 'failed' && (_jsxs("div", { "data-slot": "image-viewer-error", role: "alert", className: "absolute inset-0 flex flex-col items-center justify-center gap-3 p-4 text-center", children: [_jsx(ImageOffIcon, { "aria-hidden": true, className: "size-10 text-muted-foreground" }), _jsx("p", { className: "type-body text-foreground", children: "This image couldn\u2019t be loaded." }), _jsx("p", { className: "max-w-prose type-caption text-muted-foreground", children: image.alt }), _jsx(Button, { variant: "outline", onClick: () => {
122
+ setAttempt((n) => n + 1);
123
+ setState('loading');
124
+ }, children: "Try Again" })] }))] }));
125
+ }
126
+ // A step button at the frame's side. At an end it stays in the tab order,
127
+ // marked unavailable, so focus isn't dropped out of the viewer.
128
+ function StepButton({ side, label, available, onClick, }) {
129
+ const Icon = side === 'start' ? ChevronLeftIcon : ChevronRightIcon;
130
+ return (_jsx(Button, { variant: "secondary", size: "icon-lg", "aria-label": label, "aria-disabled": !available || undefined, "data-slot": side === 'start' ? 'image-viewer-previous' : 'image-viewer-next', onClick: () => available && onClick(), className: cn('absolute top-1/2 z-10 -translate-y-1/2 rounded-full shadow-sm', side === 'start' ? 'left-2 md:left-4' : 'right-2 md:right-4', 'aria-disabled:cursor-default aria-disabled:opacity-40 aria-disabled:hover:bg-secondary'), children: _jsx(Icon, {}) }));
131
+ }
132
+ // The images either side of the one shown, fetched ahead so a step shows
133
+ // one already in the browser's cache.
134
+ function usePreload(images, at) {
135
+ const before = images?.[at - 1]?.src;
136
+ const after = images?.[at + 1]?.src;
137
+ React.useEffect(() => {
138
+ for (const src of [after, before]) {
139
+ if (!src)
140
+ continue;
141
+ const preload = new Image();
142
+ preload.decoding = 'async';
143
+ preload.src = src;
144
+ }
145
+ }, [before, after]);
146
+ }
147
+ function clamp(index, count) {
148
+ return Math.min(Math.max(Math.trunc(index), 0), count - 1);
149
+ }
150
+ const ARROW_ROLES = '[role=slider],[role=menu],[role=menubar],[role=listbox],[role=radiogroup],[role=tablist],[role=grid],[role=tree],[role=combobox],[role=spinbutton]';
151
+ function usesArrows(target) {
152
+ if (!(target instanceof HTMLElement))
153
+ return false;
154
+ if (target.isContentEditable || target.closest(ARROW_ROLES))
155
+ return true;
156
+ if (target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement)
157
+ return true;
158
+ return target instanceof HTMLInputElement && !['button', 'checkbox', 'radio', 'submit', 'reset'].includes(target.type);
159
+ }
package/dist/index.d.ts CHANGED
@@ -103,6 +103,7 @@ export { DateField, type DateFieldProps } from './components/app/date-field.js';
103
103
  export { EmojiField, type EmojiFieldProps } from './components/app/emoji-field.js';
104
104
  export { MonthDayField, type MonthDayFieldProps } from './components/app/month-day-field.js';
105
105
  export { ImageField, type ImageFieldProps } from './components/app/image-field.js';
106
+ export { ImageViewer, type ImageViewerImage, type ImageViewerProps } from './components/app/image-viewer.js';
106
107
  export { DEFAULT_IMAGE_TYPES, type ImageUpload, type ImageUploadResult } from './lib/image-file.js';
107
108
  export { formatPlainDate, parsePlainDate, plainDateExamples, unreadableDateMessage, type ParsePlainDateOptions, type PlainDate, } from './lib/plain-date.js';
108
109
  export { formatMonthDay, isMonthDay, monthDayProblem, type MonthDay } from './lib/month-day.js';
package/dist/index.js CHANGED
@@ -114,6 +114,7 @@ export { DateField } from './components/app/date-field.js';
114
114
  export { EmojiField } from './components/app/emoji-field.js';
115
115
  export { MonthDayField } from './components/app/month-day-field.js';
116
116
  export { ImageField } from './components/app/image-field.js';
117
+ export { ImageViewer } from './components/app/image-viewer.js';
117
118
  export { DEFAULT_IMAGE_TYPES } from './lib/image-file.js';
118
119
  export { formatPlainDate, parsePlainDate, plainDateExamples, unreadableDateMessage, } from './lib/plain-date.js';
119
120
  export { formatMonthDay, isMonthDay, monthDayProblem } from './lib/month-day.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.128.0",
3
+ "version": "4.129.1",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {