@sdxc/kit 2026.11.26 → 2026.11.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.jsonl CHANGED
@@ -465,6 +465,7 @@
465
465
  {"release":"2026.10.2","package":"@sdxc/billing","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
466
466
  {"release":"2026.10.2","package":"@sdxc/blueprint","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
467
467
  {"release":"2026.10.2","package":"@sdxc/bracket-params","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
468
+ {"release":"2026.10.2","package":"@sdxc/bytes","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
468
469
  {"release":"2026.10.2","package":"@sdxc/cache","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
469
470
  {"release":"2026.10.2","package":"@sdxc/captcha","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
470
471
  {"release":"2026.10.2","package":"@sdxc/catch-response-middleware","type":"chore","breaking":false,"title":"Update Remix to 3.0.0","body":"Remix 3 is stable. Every workspace now pins `remix@3.0.0`, and\n`@remix-run/data-schema` moves to `^1.0.0`.\n\nThe component runtime moved from `remix/ui` to `remix/component`, along with\nits subpaths (`remix/component/server`, `remix/component/test`, the JSX\nruntimes), so every import and every `jsxImportSource` now points there.\n\nThe headless primitives (`anchor`, `combobox`, `listbox`, `tabs`) are no\nlonger part of `remix`. They ship in the standalone `@remix-run/ui` package,\npinned at 0.12.1, which `@sdxc/ui` and the sdxc app now depend on directly."}
@@ -2245,3 +2246,6 @@
2245
2246
  {"release":"2026.11.26","package":"@sdxc/novel","type":"feat","breaking":false,"title":"Add a full screen button to the title screen","body":"`NovelPlayer.Title`, and so `NovelPlayer.Default`'s title screen, shows a button in its bottom\ncorner that enters and leaves full screen, where the browser allows it. It fills the screen with\nthe box the title sits in; a player with a title screen now does the same from its quick menu,\nso starting a game or going back to the title stays in full screen.\n\nRestyle the button with `--novel-title-fullscreen-inset`, `-size`, `-border`, `-radius`,\n`-background` and `-color`, or through `[data-novel-title-fullscreen]`. No action is needed."}
2246
2247
  {"release":"2026.11.26","package":"@sdxc/novel","type":"fix","breaking":false,"title":"Start the settings preview's typing once it is on the page","body":"Before, the settings screen's text preview started its typing timer while rendering, so a\nserver render of a player (a docs page that embeds one, for example) left a timer running\nthat later tried to update a component that never mounted, logging \"Cannot call\nhandle.update() before TextPreview's initial render commits\".\n\nNow the preview starts typing after it mounts in the browser, and a server render draws the\nline at rest with no timer. No action is needed."}
2247
2248
  {"release":"2026.11.26","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Center the slider thumb on its rail in Chrome and Safari","body":"Before, a `Slider` whose pointer target (`--ui-target-size`, 1.5rem by default) was taller than\nits thumb drew the thumb high in Chrome and Safari: WebKit placed it at the top of the grown\nnative input, about 2px above the rail at the default sizes and more for larger targets.\n\nNow the thumb sits on the rail's centre line in every browser, at any thumb and target size. No\naction is needed."}
2249
+ {"release":"2026.11.27","package":"@sdxc/bytes","type":"feat","breaking":false,"title":"Add typed byte size strings converted to bytes","body":"New package @sdxc/bytes. Write a size limit as \"10 MiB\" instead of\n10 * 1024 * 1024, with the unit checked at compile time:\n\n import { toBytes, toBytesBigInt, parse } from \"@sdxc/bytes\";\n\n const MAX_UPLOAD_BYTES = toBytes(\"10 MiB\"); // 10485760\n toBytes(\"10 MB\"); // 10000000\n toBytes(\"10 klobyes\"); // type error\n toBytesBigInt(\"2 EiB\"); // 2305843009213693952n\n\n let result = parse(env.MAX_UPLOAD_SIZE ?? \"\"); // Result<number, InvalidByteSizeError>\n\nMB, GB and the other plain symbols count in powers of 1000, and MiB, GiB\nand the other \"i\" symbols in powers of 1024. KB is rejected because it\nmeans either, so write kB or KiB. Symbols take an optional space (\"10MB\",\n\"10 MB\"), unit names need one (\"10 megabytes\"), and amounts are whole.\n\ntoBytes() and parse() cover B through PB/PiB and fail past\nNumber.MAX_SAFE_INTEGER. toBytesBigInt() and parseBigInt() are exact at\nany size and add EB, ZB, YB, EiB, ZiB and YiB. Declare ByteSizeInput or\nBigByteSizeInput in your own APIs to accept either a string or a raw count."}
2250
+ {"release":"2026.11.27","package":"@sdxc/novel","type":"fix","breaking":false,"title":"Draw the dialogs' close button in the dialog's text color","body":"Before, the close button of every player dialog (settings, saves, backlog and the library\nscreens) drew its X in the default neutral ink, so on a dark `--novel-dialog-background` the\nglyph stayed invisible until the pointer hovered it. Now the X takes `--novel-dialog-color`, and\nits hover and press tints mix from that color, so the button reads on light and dark themes\nalike. No action is needed: a theme that already sets `--novel-dialog-color` gets a visible\nclose button on upgrade."}
2251
+ {"release":"2026.11.27","package":"@sdxc/ui","type":"fix","breaking":false,"title":"Keep Lightbox's counter on its own line on a narrow viewer","body":"Before, on a viewer narrower than 48rem a slide's counter and caption shared\none wrapping row: a short caption sat beside the counter and a long one\ndropped below it, so the footer changed from one line to two between slides\nand the photo above resized as the reader stepped through. Now a narrow\nviewer always sets the counter above the caption, and a wider one keeps them\nside by side. No action needed."}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdxc/kit",
3
- "version": "2026.11.26",
3
+ "version": "2026.11.27",
4
4
  "description": "The sdxc command line: start a Remix v3 app, generate its files, copy UI components into it and upgrade it",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  "peerDependencies": {
34
34
  "remix": "3.2.0"
35
35
  },
36
- "gitHead": "a6d84fa08849d9318c95ac92e15cc77973a91561",
36
+ "gitHead": "a02e72f0baabdf2cda53d1a3f32ef2449a59650d",
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lightbox",
3
- "changedIn": "2026.11.22",
3
+ "changedIn": "2026.11.27",
4
4
  "dependencies": [],
5
5
  "exports": [
6
6
  "Lightbox",
@@ -8,10 +8,10 @@
8
8
  ],
9
9
  "source": {
10
10
  "path": "lightbox.tsx",
11
- "content": "/**\n * A full-screen photo viewer for a gallery, as a native `<dialog>` a trigger opens through\n * Invoker Commands. Every photo sits in a scroll-snap track with its own address, so swiping\n * and the step links work without script; a small island adds arrow keys and opening at a photo.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { EntryComponent, Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { ChevronLeftIcon, ChevronRightIcon, XIcon } from \"@sdxc/icons\";\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { outline } from \"@sdxc/u/color\";\nimport { raw, mergeMix } from \"@sdxc/u/general\";\nimport { container } from \"@sdxc/u/layout\";\nimport { at, motionReduce, motionSafe, startingStyle } from \"@sdxc/u/responsive\";\nimport { when } from \"@sdxc/u/state\";\nimport { tabularNums } from \"@sdxc/u/typography\";\nimport { clientEntry } from \"remix/component\";\n\nimport { lightboxControls } from \"@sdxc/ui/mixins\";\n\n/** Container the viewer names, so its step buttons move beside the photo once there is room. */\nconst CONTAINER_NAME = \"ui-lightbox\";\n\n/** Width from which the step buttons sit in their own gutters instead of over the photo. */\nconst GUTTER_WIDTH = \"48rem\";\n\n/** Words the controls are named by when `labels` leaves them out. */\nconst DEFAULT_LABELS: Lightbox.Labels = {\n\tclose: \"Close\",\n\tprevious: \"Previous photo\",\n\tnext: \"Next photo\",\n};\n\n/** The round, 44px control shared by the close button and the step links. */\nconst CONTROL_STYLES = raw({\n\tdisplay: \"inline-grid\",\n\tplaceItems: \"center\",\n\tinlineSize: \"2.75rem\",\n\tblockSize: \"2.75rem\",\n\tpadding: 0,\n\tborder: 0,\n\tborderRadius: \"999px\",\n\tbackground: \"rgb(0 0 0 / 0.55)\",\n\tcolor: \"white\",\n\tcursor: \"pointer\",\n\ttextDecoration: \"none\",\n\tzIndex: 1,\n});\n\n/**\n * Prop types for {@link Lightbox} and its compound parts.\n */\nexport namespace Lightbox {\n\t/** One photo in the gallery. */\n\texport interface Photo {\n\t\t/** The image's address; leave it out to draw the photo with `art` instead. */\n\t\tsrc?: string;\n\t\t/** Candidate sources, as the native `srcset`. */\n\t\tsrcset?: string;\n\t\t/** What the photo shows, for a reader who cannot see it. */\n\t\talt: string;\n\t\t/** A line under the photo, such as the room it shows. */\n\t\tcaption?: RemixNode;\n\t\t/**\n\t\t * Drawn content standing in for `src`, such as an inline SVG with a `viewBox`; it is\n\t\t * scaled to fit the viewer as an image would be.\n\t\t */\n\t\tart?: RemixNode;\n\t}\n\n\t/** The words each control is named by. */\n\texport interface Labels {\n\t\t/** @default \"Close\" */\n\t\tclose: string;\n\t\t/** @default \"Previous photo\" */\n\t\tprevious: string;\n\t\t/** @default \"Next photo\" */\n\t\tnext: string;\n\t}\n\n\t/** Every native `<dialog>` attribute, plus the gallery. */\n\texport interface Props extends Omit<TagProps<\"dialog\">, \"children\" | \"open\"> {\n\t\t/** Targeted by each trigger's `commandfor`, and the prefix of every photo's own id. */\n\t\tid: string;\n\t\t/** The gallery's name, such as \"Photos of Fern Cabin\", read when the viewer opens. */\n\t\tlabel: string;\n\t\tphotos: Photo[];\n\t\t/**\n\t\t * Renders the viewer already open at this zero-based photo, for a page whose address\n\t\t * names one (`?photo=3`). Without script it is a non-modal dialog covering the page;\n\t\t * the island reopens it as a modal.\n\t\t */\n\t\tinitial?: number;\n\t\tlabels?: Partial<Labels>;\n\t}\n\n\t/** Every native `<button>` attribute, plus the viewer and photo it opens. */\n\texport interface TriggerProps extends Omit<TagProps<\"button\">, \"commandfor\" | \"command\"> {\n\t\t/** `id` of the {@link Lightbox} this opens. */\n\t\tlightbox: string;\n\t\t/**\n\t\t * Zero-based photo the viewer opens at once the island has loaded.\n\t\t *\n\t\t * @default 0\n\t\t */\n\t\tindex?: number;\n\t}\n}\n\n/** The id of photo `index`, one-based so it reads like the counter (`photos-photo-3`). */\nfunction slideId(id: string, index: number): string {\n\treturn `${id}-photo-${index + 1}`;\n}\n\n/**\n * Loads the viewer's script: the hidden host whose mixin wires the arrow keys, the\n * index-aware triggers and the live region. It loads from `@sdxc/ui/lightbox`, which the\n * app's browser entry maps; {@link Lightbox} renders it, so a page never places it itself.\n */\nexport const LightboxControls: EntryComponent<Record<never, never>> = clientEntry(\n\t\"@sdxc/ui/lightbox#LightboxControls\",\n\tfunction LightboxControls() {\n\t\treturn () => <span hidden mix={[lightboxControls()]} />;\n\t},\n);\n\n/**\n * Renders the viewer: a full-screen dark `<dialog>` with a close button, one slide per photo\n * (contained, with \"n / N\" and its caption) and step links between neighbours. Opened from a\n * {@link Lightbox.Trigger}; Escape and the close button dismiss it.\n *\n * @param handle Runtime handle carrying the dialog's props.\n * @returns The render function producing the viewer's markup.\n * @example\n * <Lightbox.Trigger lightbox=\"cabin-photos\" index={2}><img src={thumb} alt=\"\" /></Lightbox.Trigger>\n * <Lightbox id=\"cabin-photos\" label=\"Photos of Fern Cabin\" photos={photos} />\n * @example\n * <Lightbox id=\"cabin-photos\" label=\"Photos\" photos={photos} initial={Number(url.searchParams.get(\"photo\")) - 1} />\n */\nexport function Lightbox(handle: Handle<Lightbox.Props>) {\n\treturn () => {\n\t\tlet { id, label, photos, initial, labels, mix, ...rest } = handle.props;\n\t\tlet words = { ...DEFAULT_LABELS, ...labels };\n\t\tlet total = photos.length;\n\t\tlet start = initial === undefined ? undefined : Math.max(0, Math.min(total - 1, initial));\n\n\t\treturn (\n\t\t\t<dialog\n\t\t\t\t{...rest}\n\t\t\t\tid={id}\n\t\t\t\taria-label={label}\n\t\t\t\topen={start !== undefined}\n\t\t\t\tdata-lightbox-initial={start === undefined ? undefined : String(start)}\n\t\t\t\tdata-slot=\"lightbox\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tposition: \"fixed\",\n\t\t\t\t\t\t\tinset: 0,\n\t\t\t\t\t\t\tinlineSize: \"auto\",\n\t\t\t\t\t\t\tblockSize: \"auto\",\n\t\t\t\t\t\t\tmaxInlineSize: \"none\",\n\t\t\t\t\t\t\tmaxBlockSize: \"none\",\n\t\t\t\t\t\t\tmargin: 0,\n\t\t\t\t\t\t\tpadding: 0,\n\t\t\t\t\t\t\tborder: 0,\n\t\t\t\t\t\t\toverflow: \"hidden\",\n\t\t\t\t\t\t\tbackground: \"rgb(12 12 14)\",\n\t\t\t\t\t\t\tcolor: \"white\",\n\t\t\t\t\t\t\tcolorScheme: \"dark\",\n\t\t\t\t\t\t\tzIndex: 50,\n\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tcontainer(CONTAINER_NAME, \"inline-size\"),\n\t\t\t\t\t\twhen(\"&[open]\", raw({ display: \"block\" })),\n\t\t\t\t\t\twhen(\"&::backdrop\", raw({ background: \"rgb(0 0 0 / 0.9)\" })),\n\t\t\t\t\t\tmotionSafe([\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\ttransition:\n\t\t\t\t\t\t\t\t\t\"opacity 160ms ease-out, display 160ms allow-discrete, overlay 160ms allow-discrete\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tstartingStyle(when(\"&[open]\", raw({ opacity: 0 }))),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<LightboxControls />\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tcommandfor={id}\n\t\t\t\t\tcommand=\"close\"\n\t\t\t\t\taria-label={words.close}\n\t\t\t\t\tdata-slot=\"lightbox-close\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tCONTROL_STYLES,\n\t\t\t\t\t\traw({ position: \"absolute\", insetBlockStart: \"0.75rem\", insetInlineEnd: \"0.75rem\" }),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"white\", offset: 2, width: 2 })),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<XIcon size={20} />\n\t\t\t\t</button>\n\t\t\t\t<p role=\"status\" data-lightbox-status=\"\" mix={[visuallyHidden()]} />\n\t\t\t\t<div\n\t\t\t\t\tdata-lightbox-track=\"\"\n\t\t\t\t\tdata-slot=\"lightbox-track\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tblockSize: \"100%\",\n\t\t\t\t\t\t\toverflowX: \"auto\",\n\t\t\t\t\t\t\toverflowY: \"hidden\",\n\t\t\t\t\t\t\tscrollSnapType: \"x mandatory\",\n\t\t\t\t\t\t\toverscrollBehaviorX: \"contain\",\n\t\t\t\t\t\t\tscrollbarWidth: \"none\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&::-webkit-scrollbar\", raw({ display: \"none\" })),\n\t\t\t\t\t\tmotionSafe(raw({ scrollBehavior: \"smooth\" })),\n\t\t\t\t\t\tmotionReduce(raw({ scrollBehavior: \"auto\" })),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{photos.map((photo, index) => (\n\t\t\t\t\t\t<LightboxSlide\n\t\t\t\t\t\t\tviewer={id}\n\t\t\t\t\t\t\tphoto={photo}\n\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\ttotal={total}\n\t\t\t\t\t\t\tinitial={index === start}\n\t\t\t\t\t\t\tlabels={words}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t</dialog>\n\t\t);\n\t};\n}\n\n/** Props {@link LightboxSlide} reads. */\ninterface LightboxSlideProps {\n\tviewer: string;\n\tphoto: Lightbox.Photo;\n\tindex: number;\n\ttotal: number;\n\t/** Whether the server opened the viewer here, which snaps the track to it on first paint. */\n\tinitial: boolean;\n\tlabels: Lightbox.Labels;\n}\n\n/**\n * One photo filling the track: the picture contained in the space above its counter and\n * caption, with a link to each neighbour that addresses it by id, so the track scrolls there\n * with or without script. The first photo has no previous link and the last no next.\n *\n * @param handle Runtime handle carrying the slide's photo and position.\n * @returns The render function producing the slide's markup.\n */\nfunction LightboxSlide(handle: Handle<LightboxSlideProps>) {\n\treturn () => {\n\t\tlet { viewer, photo, index, total, initial, labels } = handle.props;\n\t\tlet hasPrevious = index > 0;\n\t\tlet hasNext = index < total - 1;\n\n\t\treturn (\n\t\t\t<figure\n\t\t\t\tid={slideId(viewer, index)}\n\t\t\t\tdata-lightbox-slide=\"\"\n\t\t\t\tdata-slot=\"lightbox-slide\"\n\t\t\t\tmix={[\n\t\t\t\t\traw({\n\t\t\t\t\t\tposition: \"relative\",\n\t\t\t\t\t\tflex: \"0 0 100%\",\n\t\t\t\t\t\tdisplay: \"grid\",\n\t\t\t\t\t\tgridTemplateRows: \"minmax(0, 1fr) auto\",\n\t\t\t\t\t\tgap: \"0.75rem\",\n\t\t\t\t\t\tmargin: 0,\n\t\t\t\t\t\tpaddingBlock: \"4rem 1rem\",\n\t\t\t\t\t\tscrollSnapAlign: \"center\",\n\t\t\t\t\t\tminInlineSize: 0,\n\t\t\t\t\t}),\n\t\t\t\t\tinitial ? raw({ scrollInitialTarget: \"nearest\" } as never) : undefined,\n\t\t\t\t\tat(GUTTER_WIDTH, CONTAINER_NAME, raw({ paddingInline: \"4.5rem\" })),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{photo.art === undefined ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={photo.src}\n\t\t\t\t\t\tsrcset={photo.srcset}\n\t\t\t\t\t\talt={photo.alt}\n\t\t\t\t\t\tloading={initial ? \"eager\" : \"lazy\"}\n\t\t\t\t\t\tdecoding=\"async\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tdisplay: \"block\",\n\t\t\t\t\t\t\t\tinlineSize: \"100%\",\n\t\t\t\t\t\t\t\tblockSize: \"100%\",\n\t\t\t\t\t\t\t\tminBlockSize: 0,\n\t\t\t\t\t\t\t\tobjectFit: \"contain\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t]}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<div\n\t\t\t\t\t\trole=\"img\"\n\t\t\t\t\t\taria-label={photo.alt}\n\t\t\t\t\t\tdata-slot=\"lightbox-art\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tdisplay: \"grid\",\n\t\t\t\t\t\t\t\tplaceItems: \"center\",\n\t\t\t\t\t\t\t\tminBlockSize: 0,\n\t\t\t\t\t\t\t\toverflow: \"hidden\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\twhen(\"& > svg\", raw({ inlineSize: \"100%\", blockSize: \"100%\" })),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{photo.art}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<figcaption\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tgap: \"0.75rem\",\n\t\t\t\t\t\t\talignItems: \"baseline\",\n\t\t\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\t\t\tflexWrap: \"wrap\",\n\t\t\t\t\t\t\tpaddingInline: \"1rem\",\n\t\t\t\t\t\t\tfontSize: \"0.875rem\",\n\t\t\t\t\t\t\tlineHeight: 1.4,\n\t\t\t\t\t\t\ttextAlign: \"center\",\n\t\t\t\t\t\t\tcolor: \"rgb(255 255 255 / 0.86)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tdata-lightbox-announce=\"\"\n\t\t\t\t\t\tdata-slot=\"lightbox-counter\"\n\t\t\t\t\t\tmix={[tabularNums(), raw({ color: \"rgb(255 255 255 / 0.6)\" })]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{`${index + 1} / ${total}`}\n\t\t\t\t\t</span>\n\t\t\t\t\t{photo.caption === undefined ? null : (\n\t\t\t\t\t\t<span data-lightbox-announce=\"\" data-slot=\"lightbox-caption\">\n\t\t\t\t\t\t\t{photo.caption}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</figcaption>\n\t\t\t\t{hasPrevious ? (\n\t\t\t\t\t<LightboxStep\n\t\t\t\t\t\thref={`#${slideId(viewer, index - 1)}`}\n\t\t\t\t\t\tto={index - 1}\n\t\t\t\t\t\tlabel={labels.previous}\n\t\t\t\t\t\tside=\"start\"\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t\t{hasNext ? (\n\t\t\t\t\t<LightboxStep\n\t\t\t\t\t\thref={`#${slideId(viewer, index + 1)}`}\n\t\t\t\t\t\tto={index + 1}\n\t\t\t\t\t\tlabel={labels.next}\n\t\t\t\t\t\tside=\"end\"\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</figure>\n\t\t);\n\t};\n}\n\n/** Props {@link LightboxStep} reads. */\ninterface LightboxStepProps {\n\thref: string;\n\tto: number;\n\tlabel: string;\n\tside: \"start\" | \"end\";\n}\n\n/**\n * A round link to a neighbouring photo, centred on the slide's edge: over the photo on a\n * phone, in the slide's own gutter once the viewer is wide. The chevron mirrors under RTL.\n *\n * @param handle Runtime handle carrying the link's target and side.\n * @returns The render function producing the link's markup.\n */\nfunction LightboxStep(handle: Handle<LightboxStepProps>) {\n\treturn () => {\n\t\tlet { href, to, label, side } = handle.props;\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\thref={href}\n\t\t\t\taria-label={label}\n\t\t\t\tdata-lightbox-to={String(to)}\n\t\t\t\tdata-slot={side === \"start\" ? \"lightbox-previous\" : \"lightbox-next\"}\n\t\t\t\tmix={[\n\t\t\t\t\tCONTROL_STYLES,\n\t\t\t\t\traw({\n\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\tinsetBlockStart: \"50%\",\n\t\t\t\t\t\ttranslate: \"0 -50%\",\n\t\t\t\t\t\t[side === \"start\" ? \"insetInlineStart\" : \"insetInlineEnd\"]: \"0.5rem\",\n\t\t\t\t\t}),\n\t\t\t\t\twhen(\":dir(rtl) > &\", raw({ scale: \"-1 1\" })),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"white\", offset: 2, width: 2 })),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{side === \"start\" ? <ChevronLeftIcon size={22} /> : <ChevronRightIcon size={22} />}\n\t\t\t</a>\n\t\t);\n\t};\n}\n\n/**\n * Renders a button that opens the viewer named by `lightbox` as a modal, at photo `index`\n * once the island has loaded. It is unstyled apart from a focus ring, so a thumbnail or a\n * \"Show all photos\" label inside it sets its look.\n *\n * @param handle Runtime handle carrying the button's props.\n * @returns The render function producing the trigger's markup.\n * @example\n * <Lightbox.Trigger lightbox=\"cabin-photos\" index={3} aria-label=\"Open photo 4\"><img src={thumb} alt=\"\" /></Lightbox.Trigger>\n */\nLightbox.Trigger = function LightboxTrigger(handle: Handle<Lightbox.TriggerProps>) {\n\treturn () => {\n\t\tlet { lightbox, index, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tcommandfor={lightbox}\n\t\t\t\tcommand=\"show-modal\"\n\t\t\t\tdata-lightbox-index={String(index ?? 0)}\n\t\t\t\tdata-slot=\"lightbox-trigger\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"block\",\n\t\t\t\t\t\t\tpadding: 0,\n\t\t\t\t\t\t\tborder: 0,\n\t\t\t\t\t\t\tbackground: \"none\",\n\t\t\t\t\t\t\tcolor: \"inherit\",\n\t\t\t\t\t\t\tfont: \"inherit\",\n\t\t\t\t\t\t\ttextAlign: \"inherit\",\n\t\t\t\t\t\t\tcursor: \"zoom-in\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2, width: 2 })),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
11
+ "content": "/**\n * A full-screen photo viewer for a gallery, as a native `<dialog>` a trigger opens through\n * Invoker Commands. Every photo sits in a scroll-snap track with its own address, so swiping\n * and the step links work without script; a small island adds arrow keys and opening at a photo.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { EntryComponent, Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { ChevronLeftIcon, ChevronRightIcon, XIcon } from \"@sdxc/icons\";\nimport { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { outline } from \"@sdxc/u/color\";\nimport { raw, mergeMix } from \"@sdxc/u/general\";\nimport { container } from \"@sdxc/u/layout\";\nimport { at, motionReduce, motionSafe, startingStyle } from \"@sdxc/u/responsive\";\nimport { when } from \"@sdxc/u/state\";\nimport { tabularNums } from \"@sdxc/u/typography\";\nimport { clientEntry } from \"remix/component\";\n\nimport { lightboxControls } from \"@sdxc/ui/mixins\";\n\n/** Container the viewer names, so its step buttons move beside the photo once there is room. */\nconst CONTAINER_NAME = \"ui-lightbox\";\n\n/** Width from which the step buttons sit in their own gutters instead of over the photo. */\nconst GUTTER_WIDTH = \"48rem\";\n\n/** Words the controls are named by when `labels` leaves them out. */\nconst DEFAULT_LABELS: Lightbox.Labels = {\n\tclose: \"Close\",\n\tprevious: \"Previous photo\",\n\tnext: \"Next photo\",\n};\n\n/** The round, 44px control shared by the close button and the step links. */\nconst CONTROL_STYLES = raw({\n\tdisplay: \"inline-grid\",\n\tplaceItems: \"center\",\n\tinlineSize: \"2.75rem\",\n\tblockSize: \"2.75rem\",\n\tpadding: 0,\n\tborder: 0,\n\tborderRadius: \"999px\",\n\tbackground: \"rgb(0 0 0 / 0.55)\",\n\tcolor: \"white\",\n\tcursor: \"pointer\",\n\ttextDecoration: \"none\",\n\tzIndex: 1,\n});\n\n/**\n * Prop types for {@link Lightbox} and its compound parts.\n */\nexport namespace Lightbox {\n\t/** One photo in the gallery. */\n\texport interface Photo {\n\t\t/** The image's address; leave it out to draw the photo with `art` instead. */\n\t\tsrc?: string;\n\t\t/** Candidate sources, as the native `srcset`. */\n\t\tsrcset?: string;\n\t\t/** What the photo shows, for a reader who cannot see it. */\n\t\talt: string;\n\t\t/** A line under the photo, such as the room it shows. */\n\t\tcaption?: RemixNode;\n\t\t/**\n\t\t * Drawn content standing in for `src`, such as an inline SVG with a `viewBox`; it is\n\t\t * scaled to fit the viewer as an image would be.\n\t\t */\n\t\tart?: RemixNode;\n\t}\n\n\t/** The words each control is named by. */\n\texport interface Labels {\n\t\t/** @default \"Close\" */\n\t\tclose: string;\n\t\t/** @default \"Previous photo\" */\n\t\tprevious: string;\n\t\t/** @default \"Next photo\" */\n\t\tnext: string;\n\t}\n\n\t/** Every native `<dialog>` attribute, plus the gallery. */\n\texport interface Props extends Omit<TagProps<\"dialog\">, \"children\" | \"open\"> {\n\t\t/** Targeted by each trigger's `commandfor`, and the prefix of every photo's own id. */\n\t\tid: string;\n\t\t/** The gallery's name, such as \"Photos of Fern Cabin\", read when the viewer opens. */\n\t\tlabel: string;\n\t\tphotos: Photo[];\n\t\t/**\n\t\t * Renders the viewer already open at this zero-based photo, for a page whose address\n\t\t * names one (`?photo=3`). Without script it is a non-modal dialog covering the page;\n\t\t * the island reopens it as a modal.\n\t\t */\n\t\tinitial?: number;\n\t\tlabels?: Partial<Labels>;\n\t}\n\n\t/** Every native `<button>` attribute, plus the viewer and photo it opens. */\n\texport interface TriggerProps extends Omit<TagProps<\"button\">, \"commandfor\" | \"command\"> {\n\t\t/** `id` of the {@link Lightbox} this opens. */\n\t\tlightbox: string;\n\t\t/**\n\t\t * Zero-based photo the viewer opens at once the island has loaded.\n\t\t *\n\t\t * @default 0\n\t\t */\n\t\tindex?: number;\n\t}\n}\n\n/** The id of photo `index`, one-based so it reads like the counter (`photos-photo-3`). */\nfunction slideId(id: string, index: number): string {\n\treturn `${id}-photo-${index + 1}`;\n}\n\n/**\n * Loads the viewer's script: the hidden host whose mixin wires the arrow keys, the\n * index-aware triggers and the live region. It loads from `@sdxc/ui/lightbox`, which the\n * app's browser entry maps; {@link Lightbox} renders it, so a page never places it itself.\n */\nexport const LightboxControls: EntryComponent<Record<never, never>> = clientEntry(\n\t\"@sdxc/ui/lightbox#LightboxControls\",\n\tfunction LightboxControls() {\n\t\treturn () => <span hidden mix={[lightboxControls()]} />;\n\t},\n);\n\n/**\n * Renders the viewer: a full-screen dark `<dialog>` with a close button, one slide per photo\n * (contained, with \"n / N\" and its caption) and step links between neighbours. Opened from a\n * {@link Lightbox.Trigger}; Escape and the close button dismiss it.\n *\n * @param handle Runtime handle carrying the dialog's props.\n * @returns The render function producing the viewer's markup.\n * @example\n * <Lightbox.Trigger lightbox=\"cabin-photos\" index={2}><img src={thumb} alt=\"\" /></Lightbox.Trigger>\n * <Lightbox id=\"cabin-photos\" label=\"Photos of Fern Cabin\" photos={photos} />\n * @example\n * <Lightbox id=\"cabin-photos\" label=\"Photos\" photos={photos} initial={Number(url.searchParams.get(\"photo\")) - 1} />\n */\nexport function Lightbox(handle: Handle<Lightbox.Props>) {\n\treturn () => {\n\t\tlet { id, label, photos, initial, labels, mix, ...rest } = handle.props;\n\t\tlet words = { ...DEFAULT_LABELS, ...labels };\n\t\tlet total = photos.length;\n\t\tlet start = initial === undefined ? undefined : Math.max(0, Math.min(total - 1, initial));\n\n\t\treturn (\n\t\t\t<dialog\n\t\t\t\t{...rest}\n\t\t\t\tid={id}\n\t\t\t\taria-label={label}\n\t\t\t\topen={start !== undefined}\n\t\t\t\tdata-lightbox-initial={start === undefined ? undefined : String(start)}\n\t\t\t\tdata-slot=\"lightbox\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tposition: \"fixed\",\n\t\t\t\t\t\t\tinset: 0,\n\t\t\t\t\t\t\tinlineSize: \"auto\",\n\t\t\t\t\t\t\tblockSize: \"auto\",\n\t\t\t\t\t\t\tmaxInlineSize: \"none\",\n\t\t\t\t\t\t\tmaxBlockSize: \"none\",\n\t\t\t\t\t\t\tmargin: 0,\n\t\t\t\t\t\t\tpadding: 0,\n\t\t\t\t\t\t\tborder: 0,\n\t\t\t\t\t\t\toverflow: \"hidden\",\n\t\t\t\t\t\t\tbackground: \"rgb(12 12 14)\",\n\t\t\t\t\t\t\tcolor: \"white\",\n\t\t\t\t\t\t\tcolorScheme: \"dark\",\n\t\t\t\t\t\t\tzIndex: 50,\n\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tcontainer(CONTAINER_NAME, \"inline-size\"),\n\t\t\t\t\t\twhen(\"&[open]\", raw({ display: \"block\" })),\n\t\t\t\t\t\twhen(\"&::backdrop\", raw({ background: \"rgb(0 0 0 / 0.9)\" })),\n\t\t\t\t\t\tmotionSafe([\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\ttransition:\n\t\t\t\t\t\t\t\t\t\"opacity 160ms ease-out, display 160ms allow-discrete, overlay 160ms allow-discrete\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tstartingStyle(when(\"&[open]\", raw({ opacity: 0 }))),\n\t\t\t\t\t\t]),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<LightboxControls />\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tcommandfor={id}\n\t\t\t\t\tcommand=\"close\"\n\t\t\t\t\taria-label={words.close}\n\t\t\t\t\tdata-slot=\"lightbox-close\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\tCONTROL_STYLES,\n\t\t\t\t\t\traw({ position: \"absolute\", insetBlockStart: \"0.75rem\", insetInlineEnd: \"0.75rem\" }),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"white\", offset: 2, width: 2 })),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<XIcon size={20} />\n\t\t\t\t</button>\n\t\t\t\t<p role=\"status\" data-lightbox-status=\"\" mix={[visuallyHidden()]} />\n\t\t\t\t<div\n\t\t\t\t\tdata-lightbox-track=\"\"\n\t\t\t\t\tdata-slot=\"lightbox-track\"\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tblockSize: \"100%\",\n\t\t\t\t\t\t\toverflowX: \"auto\",\n\t\t\t\t\t\t\toverflowY: \"hidden\",\n\t\t\t\t\t\t\tscrollSnapType: \"x mandatory\",\n\t\t\t\t\t\t\toverscrollBehaviorX: \"contain\",\n\t\t\t\t\t\t\tscrollbarWidth: \"none\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&::-webkit-scrollbar\", raw({ display: \"none\" })),\n\t\t\t\t\t\tmotionSafe(raw({ scrollBehavior: \"smooth\" })),\n\t\t\t\t\t\tmotionReduce(raw({ scrollBehavior: \"auto\" })),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t{photos.map((photo, index) => (\n\t\t\t\t\t\t<LightboxSlide\n\t\t\t\t\t\t\tviewer={id}\n\t\t\t\t\t\t\tphoto={photo}\n\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\ttotal={total}\n\t\t\t\t\t\t\tinitial={index === start}\n\t\t\t\t\t\t\tlabels={words}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t</dialog>\n\t\t);\n\t};\n}\n\n/** Props {@link LightboxSlide} reads. */\ninterface LightboxSlideProps {\n\tviewer: string;\n\tphoto: Lightbox.Photo;\n\tindex: number;\n\ttotal: number;\n\t/** Whether the server opened the viewer here, which snaps the track to it on first paint. */\n\tinitial: boolean;\n\tlabels: Lightbox.Labels;\n}\n\n/**\n * One photo filling the track: the picture contained in the space above its counter and\n * caption, with a link to each neighbour that addresses it by id. On a narrow viewer the\n * counter keeps its own line, so the photo's space stays the same from slide to slide.\n *\n * @param handle Runtime handle carrying the slide's photo and position.\n * @returns The render function producing the slide's markup.\n */\nfunction LightboxSlide(handle: Handle<LightboxSlideProps>) {\n\treturn () => {\n\t\tlet { viewer, photo, index, total, initial, labels } = handle.props;\n\t\tlet hasPrevious = index > 0;\n\t\tlet hasNext = index < total - 1;\n\n\t\treturn (\n\t\t\t<figure\n\t\t\t\tid={slideId(viewer, index)}\n\t\t\t\tdata-lightbox-slide=\"\"\n\t\t\t\tdata-slot=\"lightbox-slide\"\n\t\t\t\tmix={[\n\t\t\t\t\traw({\n\t\t\t\t\t\tposition: \"relative\",\n\t\t\t\t\t\tflex: \"0 0 100%\",\n\t\t\t\t\t\tdisplay: \"grid\",\n\t\t\t\t\t\tgridTemplateRows: \"minmax(0, 1fr) auto\",\n\t\t\t\t\t\tgap: \"0.75rem\",\n\t\t\t\t\t\tmargin: 0,\n\t\t\t\t\t\tpaddingBlock: \"4rem 1rem\",\n\t\t\t\t\t\tscrollSnapAlign: \"center\",\n\t\t\t\t\t\tminInlineSize: 0,\n\t\t\t\t\t}),\n\t\t\t\t\tinitial ? raw({ scrollInitialTarget: \"nearest\" } as never) : undefined,\n\t\t\t\t\tat(GUTTER_WIDTH, CONTAINER_NAME, raw({ paddingInline: \"4.5rem\" })),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{photo.art === undefined ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={photo.src}\n\t\t\t\t\t\tsrcset={photo.srcset}\n\t\t\t\t\t\talt={photo.alt}\n\t\t\t\t\t\tloading={initial ? \"eager\" : \"lazy\"}\n\t\t\t\t\t\tdecoding=\"async\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tdisplay: \"block\",\n\t\t\t\t\t\t\t\tinlineSize: \"100%\",\n\t\t\t\t\t\t\t\tblockSize: \"100%\",\n\t\t\t\t\t\t\t\tminBlockSize: 0,\n\t\t\t\t\t\t\t\tobjectFit: \"contain\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t]}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<div\n\t\t\t\t\t\trole=\"img\"\n\t\t\t\t\t\taria-label={photo.alt}\n\t\t\t\t\t\tdata-slot=\"lightbox-art\"\n\t\t\t\t\t\tmix={[\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tdisplay: \"grid\",\n\t\t\t\t\t\t\t\tplaceItems: \"center\",\n\t\t\t\t\t\t\t\tminBlockSize: 0,\n\t\t\t\t\t\t\t\toverflow: \"hidden\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\twhen(\"& > svg\", raw({ inlineSize: \"100%\", blockSize: \"100%\" })),\n\t\t\t\t\t\t]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{photo.art}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<figcaption\n\t\t\t\t\tmix={[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\t\tflexDirection: \"column\",\n\t\t\t\t\t\t\tgap: \"0.25rem\",\n\t\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\t\tpaddingInline: \"1rem\",\n\t\t\t\t\t\t\tfontSize: \"0.875rem\",\n\t\t\t\t\t\t\tlineHeight: 1.4,\n\t\t\t\t\t\t\ttextAlign: \"center\",\n\t\t\t\t\t\t\tcolor: \"rgb(255 255 255 / 0.86)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tat(\n\t\t\t\t\t\t\tGUTTER_WIDTH,\n\t\t\t\t\t\t\tCONTAINER_NAME,\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tflexDirection: \"row\",\n\t\t\t\t\t\t\t\tflexWrap: \"wrap\",\n\t\t\t\t\t\t\t\tgap: \"0.75rem\",\n\t\t\t\t\t\t\t\talignItems: \"baseline\",\n\t\t\t\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t]}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tdata-lightbox-announce=\"\"\n\t\t\t\t\t\tdata-slot=\"lightbox-counter\"\n\t\t\t\t\t\tmix={[tabularNums(), raw({ color: \"rgb(255 255 255 / 0.6)\" })]}\n\t\t\t\t\t>\n\t\t\t\t\t\t{`${index + 1} / ${total}`}\n\t\t\t\t\t</span>\n\t\t\t\t\t{photo.caption === undefined ? null : (\n\t\t\t\t\t\t<span data-lightbox-announce=\"\" data-slot=\"lightbox-caption\">\n\t\t\t\t\t\t\t{photo.caption}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</figcaption>\n\t\t\t\t{hasPrevious ? (\n\t\t\t\t\t<LightboxStep\n\t\t\t\t\t\thref={`#${slideId(viewer, index - 1)}`}\n\t\t\t\t\t\tto={index - 1}\n\t\t\t\t\t\tlabel={labels.previous}\n\t\t\t\t\t\tside=\"start\"\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t\t{hasNext ? (\n\t\t\t\t\t<LightboxStep\n\t\t\t\t\t\thref={`#${slideId(viewer, index + 1)}`}\n\t\t\t\t\t\tto={index + 1}\n\t\t\t\t\t\tlabel={labels.next}\n\t\t\t\t\t\tside=\"end\"\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t</figure>\n\t\t);\n\t};\n}\n\n/** Props {@link LightboxStep} reads. */\ninterface LightboxStepProps {\n\thref: string;\n\tto: number;\n\tlabel: string;\n\tside: \"start\" | \"end\";\n}\n\n/**\n * A round link to a neighbouring photo, centred on the slide's edge: over the photo on a\n * phone, in the slide's own gutter once the viewer is wide. The chevron mirrors under RTL.\n *\n * @param handle Runtime handle carrying the link's target and side.\n * @returns The render function producing the link's markup.\n */\nfunction LightboxStep(handle: Handle<LightboxStepProps>) {\n\treturn () => {\n\t\tlet { href, to, label, side } = handle.props;\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\thref={href}\n\t\t\t\taria-label={label}\n\t\t\t\tdata-lightbox-to={String(to)}\n\t\t\t\tdata-slot={side === \"start\" ? \"lightbox-previous\" : \"lightbox-next\"}\n\t\t\t\tmix={[\n\t\t\t\t\tCONTROL_STYLES,\n\t\t\t\t\traw({\n\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\tinsetBlockStart: \"50%\",\n\t\t\t\t\t\ttranslate: \"0 -50%\",\n\t\t\t\t\t\t[side === \"start\" ? \"insetInlineStart\" : \"insetInlineEnd\"]: \"0.5rem\",\n\t\t\t\t\t}),\n\t\t\t\t\twhen(\":dir(rtl) > &\", raw({ scale: \"-1 1\" })),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"white\", offset: 2, width: 2 })),\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{side === \"start\" ? <ChevronLeftIcon size={22} /> : <ChevronRightIcon size={22} />}\n\t\t\t</a>\n\t\t);\n\t};\n}\n\n/**\n * Renders a button that opens the viewer named by `lightbox` as a modal, at photo `index`\n * once the island has loaded. It is unstyled apart from a focus ring, so a thumbnail or a\n * \"Show all photos\" label inside it sets its look.\n *\n * @param handle Runtime handle carrying the button's props.\n * @returns The render function producing the trigger's markup.\n * @example\n * <Lightbox.Trigger lightbox=\"cabin-photos\" index={3} aria-label=\"Open photo 4\"><img src={thumb} alt=\"\" /></Lightbox.Trigger>\n */\nLightbox.Trigger = function LightboxTrigger(handle: Handle<Lightbox.TriggerProps>) {\n\treturn () => {\n\t\tlet { lightbox, index, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\t{...rest}\n\t\t\t\tcommandfor={lightbox}\n\t\t\t\tcommand=\"show-modal\"\n\t\t\t\tdata-lightbox-index={String(index ?? 0)}\n\t\t\t\tdata-slot=\"lightbox-trigger\"\n\t\t\t\tmix={mergeMix(\n\t\t\t\t\t[\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tdisplay: \"block\",\n\t\t\t\t\t\t\tpadding: 0,\n\t\t\t\t\t\t\tborder: 0,\n\t\t\t\t\t\t\tbackground: \"none\",\n\t\t\t\t\t\t\tcolor: \"inherit\",\n\t\t\t\t\t\t\tfont: \"inherit\",\n\t\t\t\t\t\t\ttextAlign: \"inherit\",\n\t\t\t\t\t\t\tcursor: \"zoom-in\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2, width: 2 })),\n\t\t\t\t\t],\n\t\t\t\t\tmix,\n\t\t\t\t)}\n\t\t\t/>\n\t\t);\n\t};\n};\n"
12
12
  },
13
13
  "test": {
14
14
  "path": "lightbox.browser.test.tsx",
15
- "content": "/**\n * Opens `Lightbox` in a real browser: a trigger opens it as a true modal at the photo it\n * names, arrow keys step through the photos and the announced counter follows, the step\n * links address each neighbour by id, the close button dismisses it, and nothing overflows.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\nimport type { RenderResult } from \"remix/component/test\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { page } from \"vitest/browser\";\n\nimport { Lightbox } from \"@sdxc/ui/lightbox\";\n\nimport \"@sdxc/ui/reset.css\";\nimport \"@sdxc/u/theme.css\";\nimport \"@sdxc/ui/theme.css\";\n\n/** Three drawn photos of a cabin stay. */\nconst PHOTOS: Lightbox.Photo[] = [\n\t{ alt: \"The cabin at dusk\", caption: \"Outside\", art: <svg viewBox=\"0 0 4 3\" /> },\n\t{ alt: \"The wood stove\", caption: \"Living room\", art: <svg viewBox=\"0 0 4 3\" /> },\n\t{ alt: \"A loft bed\", art: <svg viewBox=\"0 0 4 3\" /> },\n];\n\nlet mounted: RenderResult | undefined;\n\nafterEach(() => {\n\tmounted?.cleanup();\n\tmounted = undefined;\n\tdocument.body.replaceChildren();\n});\n\n/** Mounts two triggers and the viewer, waits for the island, and returns the parts. */\nasync function mount(initial?: number) {\n\tmounted = render(\n\t\t<div>\n\t\t\t<Lightbox.Trigger lightbox=\"photos\">Show all photos</Lightbox.Trigger>\n\t\t\t<Lightbox.Trigger lightbox=\"photos\" index={2}>\n\t\t\t\tLoft\n\t\t\t</Lightbox.Trigger>\n\t\t\t<Lightbox id=\"photos\" label=\"Photos of Fern Cabin\" photos={PHOTOS} initial={initial} />\n\t\t</div>,\n\t);\n\tawait new Promise((resolve) => requestAnimationFrame(resolve));\n\tawait new Promise((resolve) => setTimeout(resolve, 0));\n\tlet root = mounted.container;\n\tlet triggers = [...root.querySelectorAll<HTMLButtonElement>(\"[data-slot=lightbox-trigger]\")];\n\treturn {\n\t\tdialog: root.querySelector<HTMLDialogElement>(\"dialog\")!,\n\t\ttriggers,\n\t\ttrack: root.querySelector<HTMLElement>(\"[data-lightbox-track]\")!,\n\t\tstatus: root.querySelector<HTMLElement>(\"[data-lightbox-status]\")!,\n\t};\n}\n\n/** The counter of the slide the script marks as in view. */\nfunction currentCounter(dialog: HTMLDialogElement): string | null | undefined {\n\treturn dialog.querySelector(\"[data-current] [data-slot=lightbox-counter]\")?.textContent;\n}\n\ndescribe(\"Lightbox\", () => {\n\ttest(\"a trigger opens it as a modal at the photo it names, instantly\", async () => {\n\t\tlet { dialog, triggers, track, status } = await mount();\n\t\texpect(dialog.open).toBe(false);\n\t\texpect(dialog.getAttribute(\"aria-label\")).toBe(\"Photos of Fern Cabin\");\n\n\t\ttriggers[1]!.click();\n\t\texpect(dialog.matches(\":modal\")).toBe(true);\n\t\texpect(Math.round(track.scrollLeft)).toBe(track.clientWidth * 2);\n\t\texpect(currentCounter(dialog)).toBe(\"3 / 3\");\n\t\texpect(status.textContent).toBe(\"3 / 3\");\n\t});\n\n\ttest(\"arrow keys step through the photos and the counter follows\", async () => {\n\t\tlet { dialog, triggers, status } = await mount();\n\t\ttriggers[0]!.click();\n\t\texpect(currentCounter(dialog)).toBe(\"1 / 3\");\n\t\texpect(status.textContent).toBe(\"1 / 3. Outside\");\n\n\t\tdialog.dispatchEvent(new KeyboardEvent(\"keydown\", { key: \"ArrowRight\", bubbles: true }));\n\t\tawait expect.poll(() => currentCounter(dialog)).toBe(\"2 / 3\");\n\t\texpect(status.textContent).toBe(\"2 / 3. Living room\");\n\n\t\tdialog.dispatchEvent(new KeyboardEvent(\"keydown\", { key: \"ArrowLeft\", bubbles: true }));\n\t\tawait expect.poll(() => currentCounter(dialog)).toBe(\"1 / 3\");\n\t});\n\n\ttest(\"step links address each neighbour by id, and the ends have none\", async () => {\n\t\tlet { dialog } = await mount();\n\t\tlet slides = [...dialog.querySelectorAll<HTMLElement>(\"[data-lightbox-slide]\")];\n\t\texpect(slides.map((slide) => slide.id)).toEqual([\n\t\t\t\"photos-photo-1\",\n\t\t\t\"photos-photo-2\",\n\t\t\t\"photos-photo-3\",\n\t\t]);\n\t\tlet hrefs = slides.map((slide) =>\n\t\t\t[...slide.querySelectorAll(\"a\")].map((link) => link.getAttribute(\"href\")),\n\t\t);\n\t\texpect(hrefs).toEqual([\n\t\t\t[\"#photos-photo-2\"],\n\t\t\t[\"#photos-photo-1\", \"#photos-photo-3\"],\n\t\t\t[\"#photos-photo-2\"],\n\t\t]);\n\t\texpect(slides[1]!.querySelector(\"a\")!.getAttribute(\"aria-label\")).toBe(\"Previous photo\");\n\t});\n\n\ttest(\"a step link scrolls in place without changing the address\", async () => {\n\t\tlet { dialog, triggers } = await mount();\n\t\ttriggers[0]!.click();\n\t\tlet before = location.hash;\n\t\tdialog.querySelector<HTMLAnchorElement>(\"#photos-photo-1 a\")!.click();\n\t\tawait expect.poll(() => currentCounter(dialog)).toBe(\"2 / 3\");\n\t\texpect(location.hash).toBe(before);\n\t});\n\n\ttest(\"the close button closes it\", async () => {\n\t\tlet { dialog, triggers } = await mount();\n\t\ttriggers[0]!.click();\n\t\tdialog.querySelector<HTMLButtonElement>(\"[data-slot=lightbox-close]\")!.click();\n\t\texpect(dialog.open).toBe(false);\n\t});\n\n\ttest(\"a server-opened viewer is upgraded to a modal at its initial photo\", async () => {\n\t\tlet { dialog } = await mount(1);\n\t\texpect(dialog.matches(\":modal\")).toBe(true);\n\t\texpect(currentCounter(dialog)).toBe(\"2 / 3\");\n\t});\n\n\ttest(\"fills a 320px screen without overflowing, with 44px controls\", async () => {\n\t\tawait page.viewport(320, 640);\n\t\tlet { dialog, triggers } = await mount();\n\t\ttriggers[0]!.click();\n\t\tlet box = dialog.getBoundingClientRect();\n\t\texpect(box.left).toBe(0);\n\t\texpect(box.width).toBe(320);\n\t\texpect(document.documentElement.scrollWidth).toBeLessThanOrEqual(320);\n\t\tfor (let control of dialog.querySelectorAll(\"[data-slot=lightbox-close], a\")) {\n\t\t\tlet rect = control.getBoundingClientRect();\n\t\t\texpect(rect.width).toBe(44);\n\t\t\texpect(rect.height).toBe(44);\n\t\t}\n\t});\n});\n"
15
+ "content": "/**\n * Opens `Lightbox` in a real browser: a trigger opens it as a true modal at the photo it\n * names, arrow keys step through the photos and the announced counter follows, the step\n * links address each neighbour by id, the close button dismisses it, nothing overflows, and\n * a phone keeps the counter on its own line.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {} from \"@vitest/browser-playwright\";\nimport type { RenderResult } from \"remix/component/test\";\n\nimport { render } from \"remix/component/test\";\nimport { afterEach, describe, expect, test } from \"vitest\";\nimport { page } from \"vitest/browser\";\n\nimport { Lightbox } from \"@sdxc/ui/lightbox\";\n\nimport \"@sdxc/ui/reset.css\";\nimport \"@sdxc/u/theme.css\";\nimport \"@sdxc/ui/theme.css\";\n\n/** Three drawn photos of a cabin stay. */\nconst PHOTOS: Lightbox.Photo[] = [\n\t{ alt: \"The cabin at dusk\", caption: \"Outside\", art: <svg viewBox=\"0 0 4 3\" /> },\n\t{ alt: \"The wood stove\", caption: \"Living room\", art: <svg viewBox=\"0 0 4 3\" /> },\n\t{ alt: \"A loft bed\", art: <svg viewBox=\"0 0 4 3\" /> },\n];\n\nlet mounted: RenderResult | undefined;\n\nafterEach(() => {\n\tmounted?.cleanup();\n\tmounted = undefined;\n\tdocument.body.replaceChildren();\n});\n\n/** Mounts two triggers and the viewer, waits for the island, and returns the parts. */\nasync function mount(initial?: number) {\n\tmounted = render(\n\t\t<div>\n\t\t\t<Lightbox.Trigger lightbox=\"photos\">Show all photos</Lightbox.Trigger>\n\t\t\t<Lightbox.Trigger lightbox=\"photos\" index={2}>\n\t\t\t\tLoft\n\t\t\t</Lightbox.Trigger>\n\t\t\t<Lightbox id=\"photos\" label=\"Photos of Fern Cabin\" photos={PHOTOS} initial={initial} />\n\t\t</div>,\n\t);\n\tawait new Promise((resolve) => requestAnimationFrame(resolve));\n\tawait new Promise((resolve) => setTimeout(resolve, 0));\n\tlet root = mounted.container;\n\tlet triggers = [...root.querySelectorAll<HTMLButtonElement>(\"[data-slot=lightbox-trigger]\")];\n\treturn {\n\t\tdialog: root.querySelector<HTMLDialogElement>(\"dialog\")!,\n\t\ttriggers,\n\t\ttrack: root.querySelector<HTMLElement>(\"[data-lightbox-track]\")!,\n\t\tstatus: root.querySelector<HTMLElement>(\"[data-lightbox-status]\")!,\n\t};\n}\n\n/** The counter of the slide the script marks as in view. */\nfunction currentCounter(dialog: HTMLDialogElement): string | null | undefined {\n\treturn dialog.querySelector(\"[data-current] [data-slot=lightbox-counter]\")?.textContent;\n}\n\ndescribe(\"Lightbox\", () => {\n\ttest(\"a trigger opens it as a modal at the photo it names, instantly\", async () => {\n\t\tlet { dialog, triggers, track, status } = await mount();\n\t\texpect(dialog.open).toBe(false);\n\t\texpect(dialog.getAttribute(\"aria-label\")).toBe(\"Photos of Fern Cabin\");\n\n\t\ttriggers[1]!.click();\n\t\texpect(dialog.matches(\":modal\")).toBe(true);\n\t\texpect(Math.round(track.scrollLeft)).toBe(track.clientWidth * 2);\n\t\texpect(currentCounter(dialog)).toBe(\"3 / 3\");\n\t\texpect(status.textContent).toBe(\"3 / 3\");\n\t});\n\n\ttest(\"arrow keys step through the photos and the counter follows\", async () => {\n\t\tlet { dialog, triggers, status } = await mount();\n\t\ttriggers[0]!.click();\n\t\texpect(currentCounter(dialog)).toBe(\"1 / 3\");\n\t\texpect(status.textContent).toBe(\"1 / 3. Outside\");\n\n\t\tdialog.dispatchEvent(new KeyboardEvent(\"keydown\", { key: \"ArrowRight\", bubbles: true }));\n\t\tawait expect.poll(() => currentCounter(dialog)).toBe(\"2 / 3\");\n\t\texpect(status.textContent).toBe(\"2 / 3. Living room\");\n\n\t\tdialog.dispatchEvent(new KeyboardEvent(\"keydown\", { key: \"ArrowLeft\", bubbles: true }));\n\t\tawait expect.poll(() => currentCounter(dialog)).toBe(\"1 / 3\");\n\t});\n\n\ttest(\"step links address each neighbour by id, and the ends have none\", async () => {\n\t\tlet { dialog } = await mount();\n\t\tlet slides = [...dialog.querySelectorAll<HTMLElement>(\"[data-lightbox-slide]\")];\n\t\texpect(slides.map((slide) => slide.id)).toEqual([\n\t\t\t\"photos-photo-1\",\n\t\t\t\"photos-photo-2\",\n\t\t\t\"photos-photo-3\",\n\t\t]);\n\t\tlet hrefs = slides.map((slide) =>\n\t\t\t[...slide.querySelectorAll(\"a\")].map((link) => link.getAttribute(\"href\")),\n\t\t);\n\t\texpect(hrefs).toEqual([\n\t\t\t[\"#photos-photo-2\"],\n\t\t\t[\"#photos-photo-1\", \"#photos-photo-3\"],\n\t\t\t[\"#photos-photo-2\"],\n\t\t]);\n\t\texpect(slides[1]!.querySelector(\"a\")!.getAttribute(\"aria-label\")).toBe(\"Previous photo\");\n\t});\n\n\ttest(\"a step link scrolls in place without changing the address\", async () => {\n\t\tlet { dialog, triggers } = await mount();\n\t\ttriggers[0]!.click();\n\t\tlet before = location.hash;\n\t\tdialog.querySelector<HTMLAnchorElement>(\"#photos-photo-1 a\")!.click();\n\t\tawait expect.poll(() => currentCounter(dialog)).toBe(\"2 / 3\");\n\t\texpect(location.hash).toBe(before);\n\t});\n\n\ttest(\"the close button closes it\", async () => {\n\t\tlet { dialog, triggers } = await mount();\n\t\ttriggers[0]!.click();\n\t\tdialog.querySelector<HTMLButtonElement>(\"[data-slot=lightbox-close]\")!.click();\n\t\texpect(dialog.open).toBe(false);\n\t});\n\n\ttest(\"a server-opened viewer is upgraded to a modal at its initial photo\", async () => {\n\t\tlet { dialog } = await mount(1);\n\t\texpect(dialog.matches(\":modal\")).toBe(true);\n\t\texpect(currentCounter(dialog)).toBe(\"2 / 3\");\n\t});\n\n\ttest(\"fills a 320px screen without overflowing, with 44px controls\", async () => {\n\t\tawait page.viewport(320, 640);\n\t\tlet { dialog, triggers } = await mount();\n\t\ttriggers[0]!.click();\n\t\tlet box = dialog.getBoundingClientRect();\n\t\texpect(box.left).toBe(0);\n\t\texpect(box.width).toBe(320);\n\t\texpect(document.documentElement.scrollWidth).toBeLessThanOrEqual(320);\n\t\tfor (let control of dialog.querySelectorAll(\"[data-slot=lightbox-close], a\")) {\n\t\t\tlet rect = control.getBoundingClientRect();\n\t\t\texpect(rect.width).toBe(44);\n\t\t\texpect(rect.height).toBe(44);\n\t\t}\n\t});\n\n\ttest(\"keeps the counter on its own line on a phone, whatever the caption's length\", async () => {\n\t\tawait page.viewport(390, 640);\n\t\tlet { dialog, triggers } = await mount();\n\t\ttriggers[0]!.click();\n\t\tfor (let slide of dialog.querySelectorAll(\"[data-slot=lightbox-slide]\")) {\n\t\t\tlet counter = slide.querySelector(\"[data-slot=lightbox-counter]\")!.getBoundingClientRect();\n\t\t\tlet caption = slide.querySelector(\"[data-slot=lightbox-caption]\")?.getBoundingClientRect();\n\t\t\tif (caption) expect(caption.top).toBeGreaterThanOrEqual(counter.bottom);\n\t\t}\n\t});\n});\n"
16
16
  }
17
17
  }