@weasel-js/ui 1.7.2 → 1.7.3

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 (22) hide show
  1. package/dist/chunks/{LayerList-Bxj1N6bj.js → LayerList-BqeWFuGc.js} +3 -3
  2. package/dist/chunks/{LayerList-Bxj1N6bj.js.map → LayerList-BqeWFuGc.js.map} +1 -1
  3. package/dist/chunks/{Prefs-C4MZ28SX.js → Prefs-BnVEyfWO.js} +2 -2
  4. package/dist/chunks/{Prefs-C4MZ28SX.js.map → Prefs-BnVEyfWO.js.map} +1 -1
  5. package/dist/chunks/{Properties-DseN56WI.js → Properties-BoG2MMHR.js} +2 -2
  6. package/dist/chunks/{Properties-DseN56WI.js.map → Properties-BoG2MMHR.js.map} +1 -1
  7. package/dist/chunks/{PropertyField-BbNqK8xr.js → PropertyField-PMrqBA0n.js} +61 -61
  8. package/dist/chunks/{PropertyField-BbNqK8xr.js.map → PropertyField-PMrqBA0n.js.map} +1 -1
  9. package/dist/chunks/{SelectionPanel-C3WzyaZV.js → SelectionPanel-COZ6z9_P.js} +2 -2
  10. package/dist/chunks/{SelectionPanel-C3WzyaZV.js.map → SelectionPanel-COZ6z9_P.js.map} +1 -1
  11. package/dist/chunks/{ToolOptionsBar-CZTYPoC2.js → ToolOptionsBar-BJKwnemU.js} +2 -2
  12. package/dist/chunks/{ToolOptionsBar-CZTYPoC2.js.map → ToolOptionsBar-BJKwnemU.js.map} +1 -1
  13. package/dist/chunks/{model-qsAFK7_0.js → model-B6zuQg6b.js} +2 -2
  14. package/dist/chunks/{model-qsAFK7_0.js.map → model-B6zuQg6b.js.map} +1 -1
  15. package/dist/components/LayerList/index.js +1 -1
  16. package/dist/components/Prefs/index.js +1 -1
  17. package/dist/components/Properties/index.js +2 -2
  18. package/dist/components/SelectionPanel/index.js +2 -2
  19. package/dist/components/ToolOptionsBar/index.js +1 -1
  20. package/dist/index.js +7 -7
  21. package/dist/style.css +1 -1
  22. package/package.json +9 -9
@@ -6,8 +6,8 @@ import { t as i } from "./Disclosure-Ch2KxYuB.js";
6
6
  import { t as a } from "./DragGhost-BeYDJyLZ.js";
7
7
  import { t as o } from "./DragGrip-AoIZXfZb.js";
8
8
  import { t as s } from "./ItemList.module-BSpCSxan.js";
9
- import { n as c } from "./Properties-DseN56WI.js";
10
- import { a as l } from "./PropertyField-BbNqK8xr.js";
9
+ import { n as c } from "./Properties-BoG2MMHR.js";
10
+ import { a as l } from "./PropertyField-PMrqBA0n.js";
11
11
  import { asNodeId as u, createMoveToIndexOp as d, dispatchApplyBatch as f, useLatest as p } from "@weasel-js/core";
12
12
  import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
13
13
  import { useId as _, useLayoutEffect as v, useRef as y, useState as b } from "react";
@@ -418,4 +418,4 @@ function F(e) {
418
418
  //#endregion
419
419
  export { D as n, S as r, F as t };
420
420
 
421
- //# sourceMappingURL=LayerList-Bxj1N6bj.js.map
421
+ //# sourceMappingURL=LayerList-BqeWFuGc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LayerList-Bxj1N6bj.js","names":["stop","s","rows","_Fragment","dlog","LockIcon","CloseButton","useReorderDragList","Disclosure","DragGhost","DragGrip","ItemList_module_default","PropertyGroup","PropertyList","LayerList_module_default","moveLayers","move","reorder","items","item","moving","ids","kept","siblings","it","moved","at","index","collectCollapsed","isCollapsed","into","anyNested","hasBody","body","LayerList","props","toggled","setToggled","useState","collapsed","collapsedIds","toggle","next","id","prev","onCollapsedChange","live","useLatest","press","onSelect","mods","locked","lockedIds","selectedIds","bodies","collectBodies","list","visible","walk","level","rowEls","useRef","focusId","setFocusId","pendingFocus","anchor","nudgers","el","tabStop","v","focusRow","selectRange","from","to","a","b","range","keys","e","go","branch","open","delta","parentId","shared","useId","palette","onAdd","addKinds","cls","className","title","kind","empty","Level","out","selected","drag","target","setEl","bind","node","cards","entry","i","kids","childId","path","onPointerDown","ghosted","isSelected","draggedIds","targetIndex","controls","Controls","head","Handle","stop","Grip","Remove","Fragment","ghost","onNudge","onVisibilityChange","onRemove","useSceneLayerList","args","build","scene","itemFor","selection","asNodeId","back","adapter","createMoveToIndexOp","label"],"sources":["../../src/components/LayerList/LayerList.module.css","../../src/components/LayerList/LayerList.tsx","../../src/components/LayerList/useSceneLayerList.ts"],"sourcesContent":["/* Row box, hover and selection are `ItemList`'s, so a layer list and the\n history list stacked under it agree. What is here is only what a layer has. */\n.root,\n.root * {\n box-sizing: border-box;\n}\n\n.root {\n display: grid;\n gap: var(--wzl-space-4);\n}\n\n.head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--wzl-space-4);\n}\n\n.title {\n margin: 0;\n font-family: var(--wzl-font-display);\n font-weight: var(--wzl-font-weight-light);\n font-size: var(--wzl-font-size-lg);\n color: var(--wzl-fg);\n}\n\n.palette {\n display: flex;\n gap: var(--wzl-space-2);\n}\n\n.add {\n font: inherit;\n height: var(--wzl-control-h);\n background: transparent;\n border: 1px dashed var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n padding: var(--wzl-space-1) var(--wzl-space-4);\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n cursor: pointer;\n}\n\n.add:hover {\n background: var(--wzl-surface-raised);\n color: var(--wzl-fg);\n}\n\n.level {\n display: flex;\n flex-direction: column;\n gap: 1px;\n position: relative;\n width: 100%;\n}\n\n/* A level of cards is a `PropertyList`, so the controls in each body take the\n panel's density; its rows are spaced like cards rather than lines. */\n.level.cards {\n display: grid;\n row-gap: var(--wzl-space-3);\n}\n\n.entry {\n min-width: 0;\n}\n\n.row {\n user-select: none;\n}\n\n.row:focus-visible {\n outline: 2px solid var(--wzl-focus-ring);\n outline-offset: -2px;\n}\n\n/* A child's twisty sits under its parent's grip. */\n.children {\n padding-left: calc(var(--wzl-disclosure-target, var(--wzl-control-h-sm)) + var(--wzl-space-4));\n}\n\n/* The layer the drag picked up holds its place, faded, while its ghost follows the pointer. */\n.dragging {\n opacity: 0.5;\n}\n\n/* Where the drop would land: a line on the edge of the layer it would land against. */\n.dropBefore {\n box-shadow: 0 -2px 0 var(--wzl-accent);\n}\n\n.dropAfter {\n box-shadow: 0 2px 0 var(--wzl-accent);\n}\n\n/* One width for the grip and the lock, so a locked row's label lines up. */\n.grip,\n.lock {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n min-width: 13px;\n color: var(--wzl-fg-muted);\n}\n\n.row:not([data-locked]) {\n cursor: grab;\n}\n\n.row:not([data-locked]):active {\n cursor: grabbing;\n}\n\n.stop {\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n}\n\n/* Holds the twisty column open on rows with nothing to expand, so labels line up down a level. */\n.twistyGap {\n flex: 0 0 auto;\n width: var(--wzl-disclosure-target, var(--wzl-control-h-sm));\n}\n\n/* Sized, so the empty column a locked row keeps is the checkbox's width. */\n.check {\n flex: 0 0 auto;\n width: 13px;\n height: 13px;\n margin: 0;\n accent-color: var(--wzl-accent);\n}\n\n.handle {\n font: inherit;\n background: transparent;\n border: 0;\n color: var(--wzl-fg-subtle);\n padding: var(--wzl-space-1) var(--wzl-space-2);\n cursor: grab;\n touch-action: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: var(--wzl-icon-button-size);\n height: var(--wzl-icon-button-size);\n border-radius: var(--wzl-radius-sm);\n font-weight: var(--wzl-font-weight-bold);\n font-size: var(--wzl-font-size);\n}\n\n.card[data-tone] .handle {\n background: var(--wzl-tone);\n color: var(--wzl-fg-on-accent);\n}\n\n.handle:active {\n cursor: grabbing;\n}\n\n.entry[data-selected] > .card {\n outline: 2px solid var(--wzl-accent);\n outline-offset: -1px;\n}\n","import {\n type KeyboardEvent,\n type ReactNode,\n type RefCallback,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { useLatest } from '@weasel-js/core';\nimport { dlog } from '../../dlog';\nimport { LockIcon } from '../../icons';\nimport { type PressModifiers, useReorderDragList } from '../../useReorderDragList';\nimport { CloseButton } from '../CloseButton';\nimport { Disclosure } from '../Disclosure';\nimport { DragGhost } from '../DragGhost';\nimport { DragGrip } from '../DragGrip';\nimport rows from '../ItemList/ItemList.module.css';\nimport { PropertyGroup, PropertyList } from '../Properties';\nimport type { StanceProps } from '../stance';\nimport s from './LayerList.module.css';\n\n/** One layer. With a body (see `renderBody`) it draws as a card that folds its\n * body away; without one, as a one-line row. Either can hold child layers. */\nexport interface LayerListItem {\n id: string;\n /** The layer's name. Also what its controls are labeled by. */\n label: string;\n /** Shown in the header in place of `label` — a select that switches the\n * layer's kind, say. */\n title?: ReactNode;\n /** Fixed-size content before the label: a color swatch, a kind icon. */\n leading?: ReactNode;\n /** Drawn in the drag handle in place of the grip — an ordinal. */\n badge?: ReactNode;\n /** Which of its list this layer is: an index into the theme's tone list, or\n * a color. A card draws its edge and handle in it and recolors its controls. */\n tone?: StanceProps['tone'];\n /** Cannot be dragged, hidden or removed, walls off drops on either side, and\n * selects alone rather than joining a multi-selection. */\n locked?: boolean;\n /** Shown or not, when the list has `onVisibilityChange`. Default true. */\n visible?: boolean;\n children?: LayerListItem[];\n /** Folds the body and children away until the user opens them.\n * `collapsedIds` overrides it. */\n defaultCollapsed?: boolean;\n}\n\n/**\n * A reorder: `ids`, siblings under `parentId` (`null` at the top level), now\n * sit as one block in list order starting at `index` of the parent's children.\n * A drag never moves a layer to another parent.\n */\nexport interface LayerMove {\n ids: string[];\n parentId: string | null;\n index: number;\n}\n\n/** Props for `<LayerList>`. */\nexport interface LayerListProps {\n items: LayerListItem[];\n /** Omit for a list the user cannot reorder. */\n onReorder?: (move: LayerMove) => void;\n /** Giving both makes rows selectable: a click selects one, shift-click adds\n * or removes one, and dragging a selected row drags its selected siblings. */\n selectedIds?: readonly string[];\n onSelect?: (ids: string[]) => void;\n /** Adds a visibility checkbox to every unlocked layer. */\n onVisibilityChange?: (id: string, visible: boolean) => void;\n /** Adds a remove button to every unlocked layer. */\n onRemove?: (id: string) => void;\n /** A layer's controls. Returning `null` leaves that layer a one-line row. */\n renderBody?: (item: LayerListItem) => ReactNode;\n /** Ids whose body and children are folded away. Giving it makes folding\n * controlled; `onCollapsedChange` fires either way. */\n collapsedIds?: readonly string[];\n onCollapsedChange?: (ids: string[]) => void;\n /** Heading above the list. */\n title?: string;\n /** Names the list for assistive tech when it has no `title`. */\n label?: string;\n /** Kinds the user can add, as buttons beside the title. Shown only with `onAdd`. */\n addKinds?: string[];\n onAdd?: (kind: string) => void;\n /** Shown in place of the list when `items` is empty. */\n empty?: ReactNode;\n /** Appended to the root's class list — the module's own names are hashed. */\n className?: string;\n}\n\n/** Returns `items` with `move` applied, for a consumer that holds the tree as state. */\nexport function moveLayers(items: LayerListItem[], move: LayerMove): LayerListItem[] {\n if (move.parentId === null) return reorder(items, move);\n return items.map((item) => {\n if (item.id === move.parentId) return { ...item, children: reorder(item.children ?? [], move) };\n return item.children ? { ...item, children: moveLayers(item.children, move) } : item;\n });\n}\n\nfunction reorder(siblings: LayerListItem[], { ids, index }: LayerMove): LayerListItem[] {\n const moving = new Set(ids);\n const kept = siblings.filter((it) => !moving.has(it.id));\n const moved = siblings.filter((it) => moving.has(it.id));\n const at = Math.max(0, Math.min(kept.length, index));\n return [...kept.slice(0, at), ...moved, ...kept.slice(at)];\n}\n\nfunction collectCollapsed(\n items: LayerListItem[],\n isCollapsed: (item: LayerListItem) => boolean,\n into = new Set<string>(),\n): Set<string> {\n for (const item of items) {\n if (isCollapsed(item)) into.add(item.id);\n if (item.children) collectCollapsed(item.children, isCollapsed, into);\n }\n return into;\n}\n\nfunction anyNested(items: LayerListItem[]): boolean {\n return items.some((it) => (it.children?.length ?? 0) > 0);\n}\n\n/** What every level of the tree reads from the list. */\ninterface Shared {\n props: LayerListProps;\n collapsed: ReadonlySet<string>;\n toggle: (id: string) => void;\n press: (item: LayerListItem, mods: PressModifiers) => void;\n uid: string;\n /** Some layer has children, so every row keeps a twisty column. */\n nested: boolean;\n /** Each layer's body, rendered once; a row where it is empty. */\n bodies: ReadonlyMap<string, ReactNode>;\n /** Per sibling group, keyed by parent: move a row one place, as its drag would. */\n nudgers: Map<string | null, (id: string, delta: -1 | 1) => boolean>;\n keys: RowKeys;\n}\n\n/** The roving focus over the rows: one row is in the tab order at a time. */\ninterface RowKeys {\n tabStop: string | undefined;\n register: (id: string) => (el: HTMLElement | null) => void;\n onKeyDown: (item: LayerListItem, parentId: string | null) => (e: KeyboardEvent<HTMLElement>) => void;\n onFocus: (id: string) => void;\n}\n\ninterface VisibleRow {\n item: LayerListItem;\n parentId: string | null;\n level: number;\n}\n\nfunction hasBody(body: ReactNode): boolean {\n return body !== null && body !== undefined && body !== false;\n}\n\n/**\n * An ordered, drag-reorderable list of layers — a document's objects, a lab's\n * canvases, a fill's effects. Each layer is a one-line row or, with a body, a\n * card whose controls fold away; either can nest child layers. Selection,\n * visibility, removal and an add palette are each on when their handler is given.\n */\nexport function LayerList(props: LayerListProps) {\n const { items, collapsedIds, onCollapsedChange, title, addKinds, onAdd, empty, className } = props;\n // Only the user's own toggles are state; everything else reads the layer's\n // `defaultCollapsed`, so a layer added later starts the way it asks to.\n const [toggled, setToggled] = useState<ReadonlyMap<string, boolean>>(new Map());\n const collapsed = collapsedIds\n ? new Set(collapsedIds)\n : collectCollapsed(items, (item) => toggled.get(item.id) ?? item.defaultCollapsed === true);\n const toggle = (id: string) => {\n const next = new Set(collapsed);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (!collapsedIds) setToggled((prev) => new Map(prev).set(id, next.has(id)));\n onCollapsedChange?.([...next]);\n };\n\n // The press arrives after the drag session ends, which can be after a render\n // the closure did not see, so it reads the selection from here.\n const live = useLatest(props);\n const press = (item: LayerListItem, mods: PressModifiers) => {\n const { selectedIds = [], onSelect } = live.current;\n if (!onSelect) return;\n anchor.current = item.id;\n if (item.locked || !mods.shiftKey) {\n onSelect([item.id]);\n return;\n }\n // A leftover locked selection does not carry into a multi-selection.\n const locked = new Set(lockedIds(live.current.items));\n const kept = selectedIds.filter((id) => !locked.has(id));\n onSelect(kept.includes(item.id) ? kept.filter((id) => id !== item.id) : [...kept, item.id]);\n };\n\n const bodies = new Map<string, ReactNode>();\n const collectBodies = (list: LayerListItem[]) => {\n for (const it of list) {\n bodies.set(it.id, props.renderBody ? props.renderBody(it) : null);\n if (it.children) collectBodies(it.children);\n }\n };\n collectBodies(items);\n\n // The rows the arrow keys walk: open branches only, and not cards, whose\n // heads are their own controls.\n const visible: VisibleRow[] = [];\n const walk = (list: LayerListItem[], parentId: string | null, level: number) => {\n for (const item of list) {\n if (!hasBody(bodies.get(item.id))) visible.push({ item, parentId, level });\n if (item.children?.length && !collapsed.has(item.id)) walk(item.children, item.id, level + 1);\n }\n };\n walk(items, null, 1);\n\n const rowEls = useRef(new Map<string, HTMLElement>());\n const [focusId, setFocusId] = useState<string | null>(null);\n const pendingFocus = useRef<string | null>(null);\n const anchor = useRef<string | null>(null);\n const nudgers = useRef(new Map<string | null, (id: string, delta: -1 | 1) => boolean>()).current;\n useLayoutEffect(() => {\n const id = pendingFocus.current;\n if (id === null) return;\n pendingFocus.current = null;\n const el = rowEls.current.get(id);\n if (el && document.activeElement !== el) el.focus();\n });\n\n const selectedIds = props.selectedIds ?? [];\n const tabStop = visible.some((v) => v.item.id === focusId)\n ? (focusId ?? undefined)\n : (visible.find((v) => selectedIds.includes(v.item.id)) ?? visible[0])?.item.id;\n\n const focusRow = (id: string) => {\n pendingFocus.current = id;\n setFocusId(id);\n };\n // Locked rows never join a multi-selection, so a range passes over them.\n const selectRange = (to: string) => {\n const from = anchor.current ?? to;\n const a = visible.findIndex((v) => v.item.id === from);\n const b = visible.findIndex((v) => v.item.id === to);\n if (a < 0 || b < 0) return;\n const range = visible\n .slice(Math.min(a, b), Math.max(a, b) + 1)\n .filter((v) => !v.item.locked)\n .map((v) => v.item.id);\n if (range.length > 0) live.current.onSelect?.(range);\n };\n\n const keys: RowKeys = {\n tabStop,\n register: (id) => (el) => {\n if (el) rowEls.current.set(id, el);\n else rowEls.current.delete(id);\n },\n onFocus: (id) => {\n setFocusId(id);\n anchor.current ??= id;\n },\n onKeyDown: (item, parentId) => (e) => {\n // Keys on a control inside the row are the control's.\n if (e.target !== e.currentTarget) return;\n const at = visible.findIndex((v) => v.item.id === item.id);\n const go = (index: number) => {\n const next = visible[Math.max(0, Math.min(visible.length - 1, index))];\n if (!next) return;\n focusRow(next.item.id);\n if (e.shiftKey && props.onSelect) selectRange(next.item.id);\n else anchor.current = next.item.id;\n };\n const branch = (item.children?.length ?? 0) > 0;\n const open = branch && !collapsed.has(item.id);\n switch (e.key) {\n case 'ArrowDown':\n case 'ArrowUp': {\n const delta = e.key === 'ArrowDown' ? 1 : -1;\n if (e.altKey) {\n if (nudgers.get(parentId)?.(item.id, delta)) pendingFocus.current = item.id;\n } else {\n go(at + delta);\n }\n break;\n }\n case 'Home':\n go(0);\n break;\n case 'End':\n go(visible.length - 1);\n break;\n case 'ArrowRight':\n if (branch && !open) toggle(item.id);\n else if (open) go(at + 1);\n else return;\n break;\n case 'ArrowLeft':\n if (open) toggle(item.id);\n else if (parentId !== null) go(visible.findIndex((v) => v.item.id === parentId));\n else return;\n break;\n case 'Enter':\n case ' ':\n press(item, { shiftKey: e.shiftKey, ctrlKey: e.ctrlKey, metaKey: e.metaKey, altKey: e.altKey });\n break;\n default:\n return;\n }\n e.preventDefault();\n },\n };\n\n const uid = useId();\n const shared: Shared = { props, collapsed, toggle, press, uid, nested: anyNested(items), bodies, nudgers, keys };\n const palette = onAdd ? (addKinds ?? []) : [];\n const cls = className ? `${s.root} ${className}` : s.root;\n\n return (\n <div className={cls}>\n {(title !== undefined || palette.length > 0) && (\n <div className={s.head}>\n {title !== undefined && <h2 className={s.title}>{title}</h2>}\n <div className={s.palette}>\n {palette.map((kind) => (\n <button\n key={kind}\n type=\"button\"\n className={s.add}\n aria-label={`Add ${kind}`}\n onClick={() => {\n dlog('layer-list', 'onAdd', { kind });\n onAdd?.(kind);\n }}\n >\n {kind}\n </button>\n ))}\n </div>\n </div>\n )}\n {items.length === 0 ? (\n <div className={rows.empty}>\n {empty ?? (palette.length > 0 ? 'No layers — add one above.' : 'No layers.')}\n </div>\n ) : (\n <Level items={items} parentId={null} shared={shared} path=\"\" level={1} />\n )}\n </div>\n );\n}\n\nfunction lockedIds(items: LayerListItem[]): string[] {\n const out: string[] = [];\n for (const it of items) {\n if (it.locked) out.push(it.id);\n if (it.children) out.push(...lockedIds(it.children));\n }\n return out;\n}\n\ninterface LevelProps {\n items: LayerListItem[];\n parentId: string | null;\n shared: Shared;\n path: string;\n level: number;\n}\n\n/** One sibling group. Each has its own drag, so a drag stays under one parent. */\nfunction Level({ items, parentId, shared, path, level }: LevelProps) {\n const { props } = shared;\n const selected = props.selectedIds ?? [];\n const drag = useReorderDragList({\n // With no `onReorder` every row is a locked one to the drag, so a press\n // still reaches `onPress` and nothing ever engages.\n items: items.map((it) => ({ id: it.id, label: it.label, locked: it.locked || !props.onReorder })),\n selectedIds: items.filter((it) => selected.includes(it.id)).map((it) => it.id),\n onReorder: (ids, target) => {\n const moving = new Set(ids);\n const inOrder = items.filter((it) => moving.has(it.id)).map((it) => it.id);\n // The hook's index counts the dragged rows; a move's index does not.\n const before = items.slice(0, target).filter((it) => moving.has(it.id)).length;\n const move = { ids: inOrder, parentId, index: target - before };\n dlog('layer-list', 'onReorder', move);\n props.onReorder?.(move);\n },\n onPress: (id, mods) => {\n const item = items.find((it) => it.id === id);\n if (item) shared.press(item, mods);\n },\n });\n shared.nudgers.set(parentId, (id, delta) =>\n drag.nudge(id, items.findIndex((it) => it.id === id), delta),\n );\n const [el, setEl] = useState<HTMLDivElement | null>(null);\n const bind = (node: HTMLDivElement | null) => {\n setEl(node);\n (drag.containerProps.ref as RefCallback<HTMLDivElement>)(node);\n };\n\n const bodies = items.map((it) => shared.bodies.get(it.id));\n const cards = bodies.some(hasBody);\n const { draggedIds, targetIndex, ghost } = drag.state;\n\n const entry = (item: LayerListItem, i: number, ghosted: boolean) => {\n const body = bodies[i];\n const kids = item.children ?? [];\n const open = !shared.collapsed.has(item.id);\n const childId = `${shared.uid}${path}-${i}`;\n const onPointerDown = ghosted ? undefined : drag.rowProps(item.id, i).onPointerDown;\n const isSelected = selected.includes(item.id);\n const cls = [s.entry];\n if (!ghosted) {\n if (draggedIds?.includes(item.id)) cls.push(s.dragging);\n if (targetIndex === i && !draggedIds?.includes(item.id)) cls.push(s.dropBefore);\n if (targetIndex === items.length && i === items.length - 1) cls.push(s.dropAfter);\n }\n const controls = <Controls item={item} shared={shared} />;\n const head =\n hasBody(body) ? (\n <PropertyGroup\n className={s.card}\n title={item.title ?? item.label}\n {...(item.tone === undefined ? {} : { tone: item.tone })}\n collapsed={ghosted || !open}\n onCollapsedChange={() => shared.toggle(item.id)}\n leading={\n <Handle\n item={item}\n reorder={props.onReorder !== undefined}\n onPointerDown={onPointerDown}\n onNudge={(delta) => shared.nudgers.get(parentId)?.(item.id, delta)}\n />\n }\n actions={ghosted ? undefined : controls}\n >\n {ghosted ? null : body}\n </PropertyGroup>\n ) : (\n <div\n className={[rows.row, s.row, isSelected ? rows.selected : ''].filter(Boolean).join(' ')}\n data-selected={isSelected ? 'true' : undefined}\n data-locked={item.locked ? 'true' : undefined}\n onPointerDown={onPointerDown}\n {...(ghosted\n ? {}\n : {\n role: 'row',\n 'aria-level': level,\n ...(kids.length > 0 ? { 'aria-expanded': open } : {}),\n ...(props.onSelect ? { 'aria-selected': isSelected } : {}),\n tabIndex: shared.keys.tabStop === item.id ? 0 : -1,\n ref: shared.keys.register(item.id),\n onKeyDown: shared.keys.onKeyDown(item, parentId),\n onFocus: () => shared.keys.onFocus(item.id),\n })}\n >\n {shared.nested &&\n (kids.length > 0 ? (\n <span className={s.stop} onPointerDown={stop}>\n <Disclosure\n open={open}\n onToggle={() => shared.toggle(item.id)}\n label={`${item.label} sublayers`}\n controls={childId}\n />\n </span>\n ) : (\n <span className={s.twistyGap} />\n ))}\n <Grip item={item} reorder={props.onReorder !== undefined} />\n {props.onVisibilityChange &&\n (item.locked ? (\n <span className={s.check} />\n ) : (\n <input\n className={s.check}\n type=\"checkbox\"\n checked={item.visible !== false}\n onPointerDown={stop}\n onChange={(e) => props.onVisibilityChange?.(item.id, e.target.checked)}\n aria-label={`Show ${item.label}`}\n />\n ))}\n {item.leading}\n <span className={rows.label}>{item.title ?? item.label}</span>\n {ghosted ? null : <Remove item={item} shared={shared} />}\n </div>\n );\n return (\n <div key={item.id} role=\"none\" className={cls.join(' ')} data-selected={isSelected ? 'true' : undefined}>\n {head}\n {!ghosted && kids.length > 0 && open && (\n <div id={childId} role=\"rowgroup\" className={s.children}>\n <Level items={kids} parentId={item.id} shared={shared} path={`${path}-${i}`} level={level + 1} />\n </div>\n )}\n </div>\n );\n };\n\n return (\n <>\n {cards ? (\n <PropertyList ref={bind} className={`${s.level} ${s.cards}`}>\n {items.map((it, i) => entry(it, i, false))}\n </PropertyList>\n ) : (\n <div\n ref={bind}\n className={s.level}\n {...(parentId === null\n ? {\n role: 'treegrid',\n 'aria-label': props.label ?? props.title ?? 'Layers',\n ...(props.onSelect ? { 'aria-multiselectable': true } : {}),\n }\n : { role: 'none' })}\n >\n {items.map((it, i) => entry(it, i, false))}\n </div>\n )}\n {ghost && el ? (\n <DragGhost at={ghost} from={el}>\n {items.map((it, i) => (ghost.ids.includes(it.id) ? entry(it, i, true) : null))}\n </DragGhost>\n ) : null}\n </>\n );\n}\n\n// Keeps a press on a control inside a row from also starting the row's press.\nconst stop = (e: { stopPropagation(): void }) => e.stopPropagation();\n\n/** A row's grip: decoration, since the whole row takes the drag. */\nfunction Grip({ item, reorder }: { item: LayerListItem; reorder: boolean }) {\n if (item.locked) {\n return (\n <span className={s.lock} role=\"img\" aria-label=\"Locked\">\n <LockIcon size={12} />\n </span>\n );\n }\n if (!reorder && item.badge === undefined) return null;\n return (\n <span className={s.grip} aria-hidden=\"true\">\n {item.badge ?? <DragGrip size={13} />}\n </span>\n );\n}\n\n/** A card's handle: the drag target, since the rest of its head folds it, and\n * Alt+Up/Down on it moves the card. */\nfunction Handle({\n item,\n reorder,\n onPointerDown,\n onNudge,\n}: {\n item: LayerListItem;\n reorder: boolean;\n onPointerDown: ((e: React.PointerEvent) => void) | undefined;\n onNudge: (delta: -1 | 1) => void;\n}) {\n if (item.locked) return <Grip item={item} reorder={reorder} />;\n if (!reorder && item.badge === undefined) return undefined;\n return (\n <button\n type=\"button\"\n className={s.handle}\n aria-label={`Drag to reorder ${item.label}`}\n aria-keyshortcuts=\"Alt+ArrowUp Alt+ArrowDown\"\n onPointerDown={onPointerDown}\n onKeyDown={(e) => {\n if (!e.altKey || (e.key !== 'ArrowUp' && e.key !== 'ArrowDown')) return;\n e.preventDefault();\n onNudge(e.key === 'ArrowUp' ? -1 : 1);\n }}\n >\n {item.badge ?? <DragGrip />}\n </button>\n );\n}\n\nfunction Controls({ item, shared }: { item: LayerListItem; shared: Shared }) {\n const { onVisibilityChange } = shared.props;\n return (\n <>\n {onVisibilityChange && !item.locked && (\n <input\n className={s.check}\n type=\"checkbox\"\n checked={item.visible !== false}\n onClick={stop}\n onChange={(e) => onVisibilityChange(item.id, e.target.checked)}\n aria-label={`Show ${item.label}`}\n />\n )}\n <Remove item={item} shared={shared} />\n </>\n );\n}\n\nfunction Remove({ item, shared }: { item: LayerListItem; shared: Shared }) {\n const { onRemove } = shared.props;\n if (!onRemove || item.locked) return null;\n return (\n <span className={s.stop} onPointerDown={stop}>\n <CloseButton ariaLabel={`Remove ${item.label}`} onClick={() => onRemove(item.id)} />\n </span>\n );\n}\n","import { asNodeId, createMoveToIndexOp, dispatchApplyBatch } from '@weasel-js/core';\nimport type { NodeId, Scene, SceneNode, SelectionApi } from '@weasel-js/core';\nimport type { LayerListItem, LayerListProps } from './LayerList';\n\n/** Arguments for {@link useSceneLayerList}. */\nexport interface UseSceneLayerListArgs<TData, TLayer extends string, TPose> {\n scene: Scene<TData, TLayer, TPose>;\n selection: SelectionApi;\n /** What the reorder op is dispatched against — the adapter `<SceneCanvas>` uses. */\n adapter: object;\n /** A row's content for a node: its label, a leading swatch or icon, whether it is locked. */\n itemFor: (node: SceneNode<TData, TLayer, TPose>) => Omit<LayerListItem, 'id' | 'children'>;\n /** Label of the reorder's history entry. Default `'Reorder'`. */\n label?: string;\n}\n\n/**\n * The props that put a scene in a `<LayerList>`: a row per node, a container's\n * children nested under it, the front-most at the top, selection read from and\n * written to `selection`, and a drag dispatched as a `MoveToIndexOp`.\n */\nexport function useSceneLayerList<TData, TLayer extends string, TPose>(\n args: UseSceneLayerListArgs<TData, TLayer, TPose>,\n): Required<Pick<LayerListProps, 'items' | 'selectedIds' | 'onSelect' | 'onReorder'>> {\n const { scene, selection, adapter, itemFor, label = 'Reorder' } = args;\n\n // A scene orders children back to front and the list front to back. Rebuilt\n // every render: the scene keeps its identity across a reorder, so a memo keyed\n // on it would serve the order from before.\n const build = (ids: readonly NodeId[]): LayerListItem[] =>\n [...ids].reverse().flatMap((id) => {\n const node = scene.get(id);\n if (!node) return [];\n const kids = scene.childrenOf(id);\n return [{ ...itemFor(node), id, ...(kids.length > 0 ? { children: build(kids) } : {}) }];\n });\n\n return {\n items: build(scene.roots),\n selectedIds: selection.current.map(String),\n onSelect: (ids) => selection.set(ids.map(asNodeId)),\n onReorder: ({ ids, parentId, index }) => {\n const siblings = parentId === null ? scene.roots : scene.childrenOf(asNodeId(parentId));\n // `index` counts from the front among the siblings the drag left behind.\n const back = siblings.length - ids.length - index;\n dispatchApplyBatch(adapter, [createMoveToIndexOp({ ids, parentId, index: Math.max(0, back) })], label);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6FA,SAAgBe,EAAW,GAAwB,GAAkC;CAEnF,OADIC,EAAK,aAAa,OAAaC,EAAQC,GAAOF,CAAI,IAC/CE,EAAM,KAAK,MACZC,EAAK,OAAOH,EAAK,WAAiB;EAAE,GAAGG;EAAM,UAAUF,EAAQE,EAAK,YAAY,CAAC,GAAGH,CAAI;CAAE,IACvFG,EAAK,W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AAI,MAAM;EACzC,WAAW,MAAQA,EAAU,IAAI7G,EAAI,IAAI8G,CAAQ,CAAC;EAClD,YAAY,EAAE,QAAK,aAAU,eAAY;GAGvC,IAAMC,KAFWjD,MAAa,OAAO6C,EAAM,QAAQA,EAAM,WAAWG,EAAShD,CAAQ,CAAC,EAAA,CAEhE,SAAS9D,EAAI,SAASM;GAC5C,EAAmB0G,GAAS,CAACC,EAAoB;IAAE;IAAK;IAAU,OAAO,KAAK,IAAI,GAAGF,CAAI;GAAE,CAAC,CAAC,GAAGG,CAAK;EACvG;CACF;AACF"}
1
+ {"version":3,"file":"LayerList-BqeWFuGc.js","names":["stop","s","rows","_Fragment","dlog","LockIcon","CloseButton","useReorderDragList","Disclosure","DragGhost","DragGrip","ItemList_module_default","PropertyGroup","PropertyList","LayerList_module_default","moveLayers","move","reorder","items","item","moving","ids","kept","siblings","it","moved","at","index","collectCollapsed","isCollapsed","into","anyNested","hasBody","body","LayerList","props","toggled","setToggled","useState","collapsed","collapsedIds","toggle","next","id","prev","onCollapsedChange","live","useLatest","press","onSelect","mods","locked","lockedIds","selectedIds","bodies","collectBodies","list","visible","walk","level","rowEls","useRef","focusId","setFocusId","pendingFocus","anchor","nudgers","el","tabStop","v","focusRow","selectRange","from","to","a","b","range","keys","e","go","branch","open","delta","parentId","shared","useId","palette","onAdd","addKinds","cls","className","title","kind","empty","Level","out","selected","drag","target","setEl","bind","node","cards","entry","i","kids","childId","path","onPointerDown","ghosted","isSelected","draggedIds","targetIndex","controls","Controls","head","Handle","stop","Grip","Remove","Fragment","ghost","onNudge","onVisibilityChange","onRemove","useSceneLayerList","args","build","scene","itemFor","selection","asNodeId","back","adapter","createMoveToIndexOp","label"],"sources":["../../src/components/LayerList/LayerList.module.css","../../src/components/LayerList/LayerList.tsx","../../src/components/LayerList/useSceneLayerList.ts"],"sourcesContent":["/* Row box, hover and selection are `ItemList`'s, so a layer list and the\n history list stacked under it agree. What is here is only what a layer has. */\n.root,\n.root * {\n box-sizing: border-box;\n}\n\n.root {\n display: grid;\n gap: var(--wzl-space-4);\n}\n\n.head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--wzl-space-4);\n}\n\n.title {\n margin: 0;\n font-family: var(--wzl-font-display);\n font-weight: var(--wzl-font-weight-light);\n font-size: var(--wzl-font-size-lg);\n color: var(--wzl-fg);\n}\n\n.palette {\n display: flex;\n gap: var(--wzl-space-2);\n}\n\n.add {\n font: inherit;\n height: var(--wzl-control-h);\n background: transparent;\n border: 1px dashed var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n padding: var(--wzl-space-1) var(--wzl-space-4);\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n cursor: pointer;\n}\n\n.add:hover {\n background: var(--wzl-surface-raised);\n color: var(--wzl-fg);\n}\n\n.level {\n display: flex;\n flex-direction: column;\n gap: 1px;\n position: relative;\n width: 100%;\n}\n\n/* A level of cards is a `PropertyList`, so the controls in each body take the\n panel's density; its rows are spaced like cards rather than lines. */\n.level.cards {\n display: grid;\n row-gap: var(--wzl-space-3);\n}\n\n.entry {\n min-width: 0;\n}\n\n.row {\n user-select: none;\n}\n\n.row:focus-visible {\n outline: 2px solid var(--wzl-focus-ring);\n outline-offset: -2px;\n}\n\n/* A child's twisty sits under its parent's grip. */\n.children {\n padding-left: calc(var(--wzl-disclosure-target, var(--wzl-control-h-sm)) + var(--wzl-space-4));\n}\n\n/* The layer the drag picked up holds its place, faded, while its ghost follows the pointer. */\n.dragging {\n opacity: 0.5;\n}\n\n/* Where the drop would land: a line on the edge of the layer it would land against. */\n.dropBefore {\n box-shadow: 0 -2px 0 var(--wzl-accent);\n}\n\n.dropAfter {\n box-shadow: 0 2px 0 var(--wzl-accent);\n}\n\n/* One width for the grip and the lock, so a locked row's label lines up. */\n.grip,\n.lock {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n min-width: 13px;\n color: var(--wzl-fg-muted);\n}\n\n.row:not([data-locked]) {\n cursor: grab;\n}\n\n.row:not([data-locked]):active {\n cursor: grabbing;\n}\n\n.stop {\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n}\n\n/* Holds the twisty column open on rows with nothing to expand, so labels line up down a level. */\n.twistyGap {\n flex: 0 0 auto;\n width: var(--wzl-disclosure-target, var(--wzl-control-h-sm));\n}\n\n/* Sized, so the empty column a locked row keeps is the checkbox's width. */\n.check {\n flex: 0 0 auto;\n width: 13px;\n height: 13px;\n margin: 0;\n accent-color: var(--wzl-accent);\n}\n\n.handle {\n font: inherit;\n background: transparent;\n border: 0;\n color: var(--wzl-fg-subtle);\n padding: var(--wzl-space-1) var(--wzl-space-2);\n cursor: grab;\n touch-action: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: var(--wzl-icon-button-size);\n height: var(--wzl-icon-button-size);\n border-radius: var(--wzl-radius-sm);\n font-weight: var(--wzl-font-weight-bold);\n font-size: var(--wzl-font-size);\n}\n\n.card[data-tone] .handle {\n background: var(--wzl-tone);\n color: var(--wzl-fg-on-accent);\n}\n\n.handle:active {\n cursor: grabbing;\n}\n\n.entry[data-selected] > .card {\n outline: 2px solid var(--wzl-accent);\n outline-offset: -1px;\n}\n","import {\n type KeyboardEvent,\n type ReactNode,\n type RefCallback,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { useLatest } from '@weasel-js/core';\nimport { dlog } from '../../dlog';\nimport { LockIcon } from '../../icons';\nimport { type PressModifiers, useReorderDragList } from '../../useReorderDragList';\nimport { CloseButton } from '../CloseButton';\nimport { Disclosure } from '../Disclosure';\nimport { DragGhost } from '../DragGhost';\nimport { DragGrip } from '../DragGrip';\nimport rows from '../ItemList/ItemList.module.css';\nimport { PropertyGroup, PropertyList } from '../Properties';\nimport type { StanceProps } from '../stance';\nimport s from './LayerList.module.css';\n\n/** One layer. With a body (see `renderBody`) it draws as a card that folds its\n * body away; without one, as a one-line row. Either can hold child layers. */\nexport interface LayerListItem {\n id: string;\n /** The layer's name. Also what its controls are labeled by. */\n label: string;\n /** Shown in the header in place of `label` — a select that switches the\n * layer's kind, say. */\n title?: ReactNode;\n /** Fixed-size content before the label: a color swatch, a kind icon. */\n leading?: ReactNode;\n /** Drawn in the drag handle in place of the grip — an ordinal. */\n badge?: ReactNode;\n /** Which of its list this layer is: an index into the theme's tone list, or\n * a color. A card draws its edge and handle in it and recolors its controls. */\n tone?: StanceProps['tone'];\n /** Cannot be dragged, hidden or removed, walls off drops on either side, and\n * selects alone rather than joining a multi-selection. */\n locked?: boolean;\n /** Shown or not, when the list has `onVisibilityChange`. Default true. */\n visible?: boolean;\n children?: LayerListItem[];\n /** Folds the body and children away until the user opens them.\n * `collapsedIds` overrides it. */\n defaultCollapsed?: boolean;\n}\n\n/**\n * A reorder: `ids`, siblings under `parentId` (`null` at the top level), now\n * sit as one block in list order starting at `index` of the parent's children.\n * A drag never moves a layer to another parent.\n */\nexport interface LayerMove {\n ids: string[];\n parentId: string | null;\n index: number;\n}\n\n/** Props for `<LayerList>`. */\nexport interface LayerListProps {\n items: LayerListItem[];\n /** Omit for a list the user cannot reorder. */\n onReorder?: (move: LayerMove) => void;\n /** Giving both makes rows selectable: a click selects one, shift-click adds\n * or removes one, and dragging a selected row drags its selected siblings. */\n selectedIds?: readonly string[];\n onSelect?: (ids: string[]) => void;\n /** Adds a visibility checkbox to every unlocked layer. */\n onVisibilityChange?: (id: string, visible: boolean) => void;\n /** Adds a remove button to every unlocked layer. */\n onRemove?: (id: string) => void;\n /** A layer's controls. Returning `null` leaves that layer a one-line row. */\n renderBody?: (item: LayerListItem) => ReactNode;\n /** Ids whose body and children are folded away. Giving it makes folding\n * controlled; `onCollapsedChange` fires either way. */\n collapsedIds?: readonly string[];\n onCollapsedChange?: (ids: string[]) => void;\n /** Heading above the list. */\n title?: string;\n /** Names the list for assistive tech when it has no `title`. */\n label?: string;\n /** Kinds the user can add, as buttons beside the title. Shown only with `onAdd`. */\n addKinds?: string[];\n onAdd?: (kind: string) => void;\n /** Shown in place of the list when `items` is empty. */\n empty?: ReactNode;\n /** Appended to the root's class list — the module's own names are hashed. */\n className?: string;\n}\n\n/** Returns `items` with `move` applied, for a consumer that holds the tree as state. */\nexport function moveLayers(items: LayerListItem[], move: LayerMove): LayerListItem[] {\n if (move.parentId === null) return reorder(items, move);\n return items.map((item) => {\n if (item.id === move.parentId) return { ...item, children: reorder(item.children ?? [], move) };\n return item.children ? { ...item, children: moveLayers(item.children, move) } : item;\n });\n}\n\nfunction reorder(siblings: LayerListItem[], { ids, index }: LayerMove): LayerListItem[] {\n const moving = new Set(ids);\n const kept = siblings.filter((it) => !moving.has(it.id));\n const moved = siblings.filter((it) => moving.has(it.id));\n const at = Math.max(0, Math.min(kept.length, index));\n return [...kept.slice(0, at), ...moved, ...kept.slice(at)];\n}\n\nfunction collectCollapsed(\n items: LayerListItem[],\n isCollapsed: (item: LayerListItem) => boolean,\n into = new Set<string>(),\n): Set<string> {\n for (const item of items) {\n if (isCollapsed(item)) into.add(item.id);\n if (item.children) collectCollapsed(item.children, isCollapsed, into);\n }\n return into;\n}\n\nfunction anyNested(items: LayerListItem[]): boolean {\n return items.some((it) => (it.children?.length ?? 0) > 0);\n}\n\n/** What every level of the tree reads from the list. */\ninterface Shared {\n props: LayerListProps;\n collapsed: ReadonlySet<string>;\n toggle: (id: string) => void;\n press: (item: LayerListItem, mods: PressModifiers) => void;\n uid: string;\n /** Some layer has children, so every row keeps a twisty column. */\n nested: boolean;\n /** Each layer's body, rendered once; a row where it is empty. */\n bodies: ReadonlyMap<string, ReactNode>;\n /** Per sibling group, keyed by parent: move a row one place, as its drag would. */\n nudgers: Map<string | null, (id: string, delta: -1 | 1) => boolean>;\n keys: RowKeys;\n}\n\n/** The roving focus over the rows: one row is in the tab order at a time. */\ninterface RowKeys {\n tabStop: string | undefined;\n register: (id: string) => (el: HTMLElement | null) => void;\n onKeyDown: (item: LayerListItem, parentId: string | null) => (e: KeyboardEvent<HTMLElement>) => void;\n onFocus: (id: string) => void;\n}\n\ninterface VisibleRow {\n item: LayerListItem;\n parentId: string | null;\n level: number;\n}\n\nfunction hasBody(body: ReactNode): boolean {\n return body !== null && body !== undefined && body !== false;\n}\n\n/**\n * An ordered, drag-reorderable list of layers — a document's objects, a lab's\n * canvases, a fill's effects. Each layer is a one-line row or, with a body, a\n * card whose controls fold away; either can nest child layers. Selection,\n * visibility, removal and an add palette are each on when their handler is given.\n */\nexport function LayerList(props: LayerListProps) {\n const { items, collapsedIds, onCollapsedChange, title, addKinds, onAdd, empty, className } = props;\n // Only the user's own toggles are state; everything else reads the layer's\n // `defaultCollapsed`, so a layer added later starts the way it asks to.\n const [toggled, setToggled] = useState<ReadonlyMap<string, boolean>>(new Map());\n const collapsed = collapsedIds\n ? new Set(collapsedIds)\n : collectCollapsed(items, (item) => toggled.get(item.id) ?? item.defaultCollapsed === true);\n const toggle = (id: string) => {\n const next = new Set(collapsed);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (!collapsedIds) setToggled((prev) => new Map(prev).set(id, next.has(id)));\n onCollapsedChange?.([...next]);\n };\n\n // The press arrives after the drag session ends, which can be after a render\n // the closure did not see, so it reads the selection from here.\n const live = useLatest(props);\n const press = (item: LayerListItem, mods: PressModifiers) => {\n const { selectedIds = [], onSelect } = live.current;\n if (!onSelect) return;\n anchor.current = item.id;\n if (item.locked || !mods.shiftKey) {\n onSelect([item.id]);\n return;\n }\n // A leftover locked selection does not carry into a multi-selection.\n const locked = new Set(lockedIds(live.current.items));\n const kept = selectedIds.filter((id) => !locked.has(id));\n onSelect(kept.includes(item.id) ? kept.filter((id) => id !== item.id) : [...kept, item.id]);\n };\n\n const bodies = new Map<string, ReactNode>();\n const collectBodies = (list: LayerListItem[]) => {\n for (const it of list) {\n bodies.set(it.id, props.renderBody ? props.renderBody(it) : null);\n if (it.children) collectBodies(it.children);\n }\n };\n collectBodies(items);\n\n // The rows the arrow keys walk: open branches only, and not cards, whose\n // heads are their own controls.\n const visible: VisibleRow[] = [];\n const walk = (list: LayerListItem[], parentId: string | null, level: number) => {\n for (const item of list) {\n if (!hasBody(bodies.get(item.id))) visible.push({ item, parentId, level });\n if (item.children?.length && !collapsed.has(item.id)) walk(item.children, item.id, level + 1);\n }\n };\n walk(items, null, 1);\n\n const rowEls = useRef(new Map<string, HTMLElement>());\n const [focusId, setFocusId] = useState<string | null>(null);\n const pendingFocus = useRef<string | null>(null);\n const anchor = useRef<string | null>(null);\n const nudgers = useRef(new Map<string | null, (id: string, delta: -1 | 1) => boolean>()).current;\n useLayoutEffect(() => {\n const id = pendingFocus.current;\n if (id === null) return;\n pendingFocus.current = null;\n const el = rowEls.current.get(id);\n if (el && document.activeElement !== el) el.focus();\n });\n\n const selectedIds = props.selectedIds ?? [];\n const tabStop = visible.some((v) => v.item.id === focusId)\n ? (focusId ?? undefined)\n : (visible.find((v) => selectedIds.includes(v.item.id)) ?? visible[0])?.item.id;\n\n const focusRow = (id: string) => {\n pendingFocus.current = id;\n setFocusId(id);\n };\n // Locked rows never join a multi-selection, so a range passes over them.\n const selectRange = (to: string) => {\n const from = anchor.current ?? to;\n const a = visible.findIndex((v) => v.item.id === from);\n const b = visible.findIndex((v) => v.item.id === to);\n if (a < 0 || b < 0) return;\n const range = visible\n .slice(Math.min(a, b), Math.max(a, b) + 1)\n .filter((v) => !v.item.locked)\n .map((v) => v.item.id);\n if (range.length > 0) live.current.onSelect?.(range);\n };\n\n const keys: RowKeys = {\n tabStop,\n register: (id) => (el) => {\n if (el) rowEls.current.set(id, el);\n else rowEls.current.delete(id);\n },\n onFocus: (id) => {\n setFocusId(id);\n anchor.current ??= id;\n },\n onKeyDown: (item, parentId) => (e) => {\n // Keys on a control inside the row are the control's.\n if (e.target !== e.currentTarget) return;\n const at = visible.findIndex((v) => v.item.id === item.id);\n const go = (index: number) => {\n const next = visible[Math.max(0, Math.min(visible.length - 1, index))];\n if (!next) return;\n focusRow(next.item.id);\n if (e.shiftKey && props.onSelect) selectRange(next.item.id);\n else anchor.current = next.item.id;\n };\n const branch = (item.children?.length ?? 0) > 0;\n const open = branch && !collapsed.has(item.id);\n switch (e.key) {\n case 'ArrowDown':\n case 'ArrowUp': {\n const delta = e.key === 'ArrowDown' ? 1 : -1;\n if (e.altKey) {\n if (nudgers.get(parentId)?.(item.id, delta)) pendingFocus.current = item.id;\n } else {\n go(at + delta);\n }\n break;\n }\n case 'Home':\n go(0);\n break;\n case 'End':\n go(visible.length - 1);\n break;\n case 'ArrowRight':\n if (branch && !open) toggle(item.id);\n else if (open) go(at + 1);\n else return;\n break;\n case 'ArrowLeft':\n if (open) toggle(item.id);\n else if (parentId !== null) go(visible.findIndex((v) => v.item.id === parentId));\n else return;\n break;\n case 'Enter':\n case ' ':\n press(item, { shiftKey: e.shiftKey, ctrlKey: e.ctrlKey, metaKey: e.metaKey, altKey: e.altKey });\n break;\n default:\n return;\n }\n e.preventDefault();\n },\n };\n\n const uid = useId();\n const shared: Shared = { props, collapsed, toggle, press, uid, nested: anyNested(items), bodies, nudgers, keys };\n const palette = onAdd ? (addKinds ?? []) : [];\n const cls = className ? `${s.root} ${className}` : s.root;\n\n return (\n <div className={cls}>\n {(title !== undefined || palette.length > 0) && (\n <div className={s.head}>\n {title !== undefined && <h2 className={s.title}>{title}</h2>}\n <div className={s.palette}>\n {palette.map((kind) => (\n <button\n key={kind}\n type=\"button\"\n className={s.add}\n aria-label={`Add ${kind}`}\n onClick={() => {\n dlog('layer-list', 'onAdd', { kind });\n onAdd?.(kind);\n }}\n >\n {kind}\n </button>\n ))}\n </div>\n </div>\n )}\n {items.length === 0 ? (\n <div className={rows.empty}>\n {empty ?? (palette.length > 0 ? 'No layers — add one above.' : 'No layers.')}\n </div>\n ) : (\n <Level items={items} parentId={null} shared={shared} path=\"\" level={1} />\n )}\n </div>\n );\n}\n\nfunction lockedIds(items: LayerListItem[]): string[] {\n const out: string[] = [];\n for (const it of items) {\n if (it.locked) out.push(it.id);\n if (it.children) out.push(...lockedIds(it.children));\n }\n return out;\n}\n\ninterface LevelProps {\n items: LayerListItem[];\n parentId: string | null;\n shared: Shared;\n path: string;\n level: number;\n}\n\n/** One sibling group. Each has its own drag, so a drag stays under one parent. */\nfunction Level({ items, parentId, shared, path, level }: LevelProps) {\n const { props } = shared;\n const selected = props.selectedIds ?? [];\n const drag = useReorderDragList({\n // With no `onReorder` every row is a locked one to the drag, so a press\n // still reaches `onPress` and nothing ever engages.\n items: items.map((it) => ({ id: it.id, label: it.label, locked: it.locked || !props.onReorder })),\n selectedIds: items.filter((it) => selected.includes(it.id)).map((it) => it.id),\n onReorder: (ids, target) => {\n const moving = new Set(ids);\n const inOrder = items.filter((it) => moving.has(it.id)).map((it) => it.id);\n // The hook's index counts the dragged rows; a move's index does not.\n const before = items.slice(0, target).filter((it) => moving.has(it.id)).length;\n const move = { ids: inOrder, parentId, index: target - before };\n dlog('layer-list', 'onReorder', move);\n props.onReorder?.(move);\n },\n onPress: (id, mods) => {\n const item = items.find((it) => it.id === id);\n if (item) shared.press(item, mods);\n },\n });\n shared.nudgers.set(parentId, (id, delta) =>\n drag.nudge(id, items.findIndex((it) => it.id === id), delta),\n );\n const [el, setEl] = useState<HTMLDivElement | null>(null);\n const bind = (node: HTMLDivElement | null) => {\n setEl(node);\n (drag.containerProps.ref as RefCallback<HTMLDivElement>)(node);\n };\n\n const bodies = items.map((it) => shared.bodies.get(it.id));\n const cards = bodies.some(hasBody);\n const { draggedIds, targetIndex, ghost } = drag.state;\n\n const entry = (item: LayerListItem, i: number, ghosted: boolean) => {\n const body = bodies[i];\n const kids = item.children ?? [];\n const open = !shared.collapsed.has(item.id);\n const childId = `${shared.uid}${path}-${i}`;\n const onPointerDown = ghosted ? undefined : drag.rowProps(item.id, i).onPointerDown;\n const isSelected = selected.includes(item.id);\n const cls = [s.entry];\n if (!ghosted) {\n if (draggedIds?.includes(item.id)) cls.push(s.dragging);\n if (targetIndex === i && !draggedIds?.includes(item.id)) cls.push(s.dropBefore);\n if (targetIndex === items.length && i === items.length - 1) cls.push(s.dropAfter);\n }\n const controls = <Controls item={item} shared={shared} />;\n const head =\n hasBody(body) ? (\n <PropertyGroup\n className={s.card}\n title={item.title ?? item.label}\n {...(item.tone === undefined ? {} : { tone: item.tone })}\n collapsed={ghosted || !open}\n onCollapsedChange={() => shared.toggle(item.id)}\n leading={\n <Handle\n item={item}\n reorder={props.onReorder !== undefined}\n onPointerDown={onPointerDown}\n onNudge={(delta) => shared.nudgers.get(parentId)?.(item.id, delta)}\n />\n }\n actions={ghosted ? undefined : controls}\n >\n {ghosted ? null : body}\n </PropertyGroup>\n ) : (\n <div\n className={[rows.row, s.row, isSelected ? rows.selected : ''].filter(Boolean).join(' ')}\n data-selected={isSelected ? 'true' : undefined}\n data-locked={item.locked ? 'true' : undefined}\n onPointerDown={onPointerDown}\n {...(ghosted\n ? {}\n : {\n role: 'row',\n 'aria-level': level,\n ...(kids.length > 0 ? { 'aria-expanded': open } : {}),\n ...(props.onSelect ? { 'aria-selected': isSelected } : {}),\n tabIndex: shared.keys.tabStop === item.id ? 0 : -1,\n ref: shared.keys.register(item.id),\n onKeyDown: shared.keys.onKeyDown(item, parentId),\n onFocus: () => shared.keys.onFocus(item.id),\n })}\n >\n {shared.nested &&\n (kids.length > 0 ? (\n <span className={s.stop} onPointerDown={stop}>\n <Disclosure\n open={open}\n onToggle={() => shared.toggle(item.id)}\n label={`${item.label} sublayers`}\n controls={childId}\n />\n </span>\n ) : (\n <span className={s.twistyGap} />\n ))}\n <Grip item={item} reorder={props.onReorder !== undefined} />\n {props.onVisibilityChange &&\n (item.locked ? (\n <span className={s.check} />\n ) : (\n <input\n className={s.check}\n type=\"checkbox\"\n checked={item.visible !== false}\n onPointerDown={stop}\n onChange={(e) => props.onVisibilityChange?.(item.id, e.target.checked)}\n aria-label={`Show ${item.label}`}\n />\n ))}\n {item.leading}\n <span className={rows.label}>{item.title ?? item.label}</span>\n {ghosted ? null : <Remove item={item} shared={shared} />}\n </div>\n );\n return (\n <div key={item.id} role=\"none\" className={cls.join(' ')} data-selected={isSelected ? 'true' : undefined}>\n {head}\n {!ghosted && kids.length > 0 && open && (\n <div id={childId} role=\"rowgroup\" className={s.children}>\n <Level items={kids} parentId={item.id} shared={shared} path={`${path}-${i}`} level={level + 1} />\n </div>\n )}\n </div>\n );\n };\n\n return (\n <>\n {cards ? (\n <PropertyList ref={bind} className={`${s.level} ${s.cards}`}>\n {items.map((it, i) => entry(it, i, false))}\n </PropertyList>\n ) : (\n <div\n ref={bind}\n className={s.level}\n {...(parentId === null\n ? {\n role: 'treegrid',\n 'aria-label': props.label ?? props.title ?? 'Layers',\n ...(props.onSelect ? { 'aria-multiselectable': true } : {}),\n }\n : { role: 'none' })}\n >\n {items.map((it, i) => entry(it, i, false))}\n </div>\n )}\n {ghost && el ? (\n <DragGhost at={ghost} from={el}>\n {items.map((it, i) => (ghost.ids.includes(it.id) ? entry(it, i, true) : null))}\n </DragGhost>\n ) : null}\n </>\n );\n}\n\n// Keeps a press on a control inside a row from also starting the row's press.\nconst stop = (e: { stopPropagation(): void }) => e.stopPropagation();\n\n/** A row's grip: decoration, since the whole row takes the drag. */\nfunction Grip({ item, reorder }: { item: LayerListItem; reorder: boolean }) {\n if (item.locked) {\n return (\n <span className={s.lock} role=\"img\" aria-label=\"Locked\">\n <LockIcon size={12} />\n </span>\n );\n }\n if (!reorder && item.badge === undefined) return null;\n return (\n <span className={s.grip} aria-hidden=\"true\">\n {item.badge ?? <DragGrip size={13} />}\n </span>\n );\n}\n\n/** A card's handle: the drag target, since the rest of its head folds it, and\n * Alt+Up/Down on it moves the card. */\nfunction Handle({\n item,\n reorder,\n onPointerDown,\n onNudge,\n}: {\n item: LayerListItem;\n reorder: boolean;\n onPointerDown: ((e: React.PointerEvent) => void) | undefined;\n onNudge: (delta: -1 | 1) => void;\n}) {\n if (item.locked) return <Grip item={item} reorder={reorder} />;\n if (!reorder && item.badge === undefined) return undefined;\n return (\n <button\n type=\"button\"\n className={s.handle}\n aria-label={`Drag to reorder ${item.label}`}\n aria-keyshortcuts=\"Alt+ArrowUp Alt+ArrowDown\"\n onPointerDown={onPointerDown}\n onKeyDown={(e) => {\n if (!e.altKey || (e.key !== 'ArrowUp' && e.key !== 'ArrowDown')) return;\n e.preventDefault();\n onNudge(e.key === 'ArrowUp' ? -1 : 1);\n }}\n >\n {item.badge ?? <DragGrip />}\n </button>\n );\n}\n\nfunction Controls({ item, shared }: { item: LayerListItem; shared: Shared }) {\n const { onVisibilityChange } = shared.props;\n return (\n <>\n {onVisibilityChange && !item.locked && (\n <input\n className={s.check}\n type=\"checkbox\"\n checked={item.visible !== false}\n onClick={stop}\n onChange={(e) => onVisibilityChange(item.id, e.target.checked)}\n aria-label={`Show ${item.label}`}\n />\n )}\n <Remove item={item} shared={shared} />\n </>\n );\n}\n\nfunction Remove({ item, shared }: { item: LayerListItem; shared: Shared }) {\n const { onRemove } = shared.props;\n if (!onRemove || item.locked) return null;\n return (\n <span className={s.stop} onPointerDown={stop}>\n <CloseButton ariaLabel={`Remove ${item.label}`} onClick={() => onRemove(item.id)} />\n </span>\n );\n}\n","import { asNodeId, createMoveToIndexOp, dispatchApplyBatch } from '@weasel-js/core';\nimport type { NodeId, Scene, SceneNode, SelectionApi } from '@weasel-js/core';\nimport type { LayerListItem, LayerListProps } from './LayerList';\n\n/** Arguments for {@link useSceneLayerList}. */\nexport interface UseSceneLayerListArgs<TData, TLayer extends string, TPose> {\n scene: Scene<TData, TLayer, TPose>;\n selection: SelectionApi;\n /** What the reorder op is dispatched against — the adapter `<SceneCanvas>` uses. */\n adapter: object;\n /** A row's content for a node: its label, a leading swatch or icon, whether it is locked. */\n itemFor: (node: SceneNode<TData, TLayer, TPose>) => Omit<LayerListItem, 'id' | 'children'>;\n /** Label of the reorder's history entry. Default `'Reorder'`. */\n label?: string;\n}\n\n/**\n * The props that put a scene in a `<LayerList>`: a row per node, a container's\n * children nested under it, the front-most at the top, selection read from and\n * written to `selection`, and a drag dispatched as a `MoveToIndexOp`.\n */\nexport function useSceneLayerList<TData, TLayer extends string, TPose>(\n args: UseSceneLayerListArgs<TData, TLayer, TPose>,\n): Required<Pick<LayerListProps, 'items' | 'selectedIds' | 'onSelect' | 'onReorder'>> {\n const { scene, selection, adapter, itemFor, label = 'Reorder' } = args;\n\n // A scene orders children back to front and the list front to back. Rebuilt\n // every render: the scene keeps its identity across a reorder, so a memo keyed\n // on it would serve the order from before.\n const build = (ids: readonly NodeId[]): LayerListItem[] =>\n [...ids].reverse().flatMap((id) => {\n const node = scene.get(id);\n if (!node) return [];\n const kids = scene.childrenOf(id);\n return [{ ...itemFor(node), id, ...(kids.length > 0 ? { children: build(kids) } : {}) }];\n });\n\n return {\n items: build(scene.roots),\n selectedIds: selection.current.map(String),\n onSelect: (ids) => selection.set(ids.map(asNodeId)),\n onReorder: ({ ids, parentId, index }) => {\n const siblings = parentId === null ? scene.roots : scene.childrenOf(asNodeId(parentId));\n // `index` counts from the front among the siblings the drag left behind.\n const back = siblings.length - ids.length - index;\n dispatchApplyBatch(adapter, [createMoveToIndexOp({ ids, parentId, index: Math.max(0, back) })], label);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6FA,SAAgBe,EAAW,GAAwB,GAAkC;CAEnF,OADIC,EAAK,aAAa,OAAaC,EAAQC,GAAOF,CAAI,IAC/CE,EAAM,KAAK,MACZC,EAAK,OAAOH,EAAK,WAAiB;EAAE,GAAGG;EAAM,UAAUF,EAAQE,EAAK,YAAY,CAAC,GAAGH,CAAI;CAAE,IACvFG,EAAK,WAAW;EAAE,GAAGA;EAAM,UAAUJ,EAAWI,EAAK,UAAUH,CAAI;CAAE,IAAIG,CACjF;AACH;AAEA,SAASF,EAAQ,GAA2B,EAAE,QAAK,YAAqC;CACtF,IAAMG,IAAS,IAAI,IAAIC,CAAG,GACpBC,IAAOC,EAAS,QAAQ,MAAO,CAACH,EAAO,IAAII,EAAG,EAAE,CAAC,GACjDC,IAAQF,EAAS,QAAQ,MAAOH,EAAO,IAAII,EAAG,EAAE,C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,GAAGF,CAAI;GAAE,CAAC,CAAC,GAAGG,CAAK;EACvG;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./Dialog-DKfsk5VN.js";
2
- import { c as t, t as n } from "./PropertyField-BbNqK8xr.js";
2
+ import { c as t, t as n } from "./PropertyField-PMrqBA0n.js";
3
3
  import { t as r } from "./Input-D7SDKbST.js";
4
4
  import { t as i } from "./useRovingTabIndex-D7u22Ia_.js";
5
5
  import { a, n as o, o as s, r as c, s as l, t as u } from "./prefField-BE_Ytr2H.js";
@@ -508,4 +508,4 @@ function R(t) {
508
508
  //#endregion
509
509
  export { y as a, O as i, j as n, x as o, A as r, R as t };
510
510
 
511
- //# sourceMappingURL=Prefs-C4MZ28SX.js.map
511
+ //# sourceMappingURL=Prefs-BnVEyfWO.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Prefs-C4MZ28SX.js","names":["_Fragment","s","s","s","s","s","Dialog","PropertyRow","PropertyControl","Input","useRovingTabIndex","filterPrefSubtree","prefValueAtPath","isPrefLeaf","visiblePrefSubtree","prefFieldProps","pickActiveSection","active","offsets","top","slack","id","SETTLE_MS","useScrollSpy","options","setActive","useState","heldRef","useRef","timerRef","releaseRef","key","ids","measure","useCallback","root","rootRef","rootTop","el","scrollTo","release","prefersReducedMotion","useEffect","Prefs_module_default","PrefRow","stored","ctx","path","inherited","toggles","onAutoChange","setAuto","next","renderCtx","pref","v","custom","control","renderBuiltin","Fragment","ObjectLeaf","field","settledOnly","held","value","objectRows","out","child","children","inner","base","PrefsPane","props","leaves","group","entry","groups","childPath","className","scrollRef","leaf","PaneSection","Heading","depth","p","PrefsRail","activate","item","items","index","onOpen","onScrollTo","roving","i","section","ariaLabel","header","open","inView","current","showCounts","PrefsForm","query","setQuery","useMemo","visible","schema","showHidden","filterable","layout","RailLayout","NoMatches","GroupBody","prefRailItems","uncontrolled","setUncontrolled","subPages","requested","hasLeaves","paneGroup","spy","setOpen","whole","opensTop","leavesOf","filterField","onClearFilter","rootName","node","cursor","seg","onClear","PrefsDialog","form","rail","title","dialogClassName","headerExtra"],"sources":["../../src/useScrollSpy.ts","../../src/components/Prefs/Prefs.module.css","../../src/components/Prefs/PrefsRow.tsx","../../src/components/Prefs/PrefsPane.tsx","../../src/components/Prefs/PrefsRail.tsx","../../src/components/Prefs/PrefsForm.tsx","../../src/components/Prefs/PrefsDialog.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, type RefObject } from 'react';\n\n/** One observed section: its id and its top edge, in the container's\n * coordinates (its `getBoundingClientRect().top` less the container's). */\nexport interface SectionOffset {\n id: string;\n top: number;\n}\n\n/**\n * The section a reader is looking at: the last one whose top edge has passed\n * the container's, within `slack` of it so a heading flush with the top counts\n * as arrived. Null until one has — the settings above the first section belong\n * to the group itself, and marking a section the reader has not reached yet\n * points them at the wrong place.\n *\n * Offsets arrive in document order and are not re-sorted — a caller reading\n * them off the DOM already has them that way, and sorting would hide a\n * measurement that came back wrong.\n */\nexport function pickActiveSection(\n offsets: readonly SectionOffset[],\n slack = 8,\n): string | null {\n let active: string | null = null;\n for (const { id, top } of offsets) {\n if (top - slack > 0) break;\n active = id;\n }\n return active;\n}\n\n/** Options for {@link useScrollSpy}. */\nexport interface UseScrollSpyOptions {\n /** The scrolling element holding the sections. */\n rootRef: RefObject<HTMLElement | null>;\n /** Section element ids, in document order. */\n ids: readonly string[];\n /** Pixels of tolerance at the container's top edge. */\n slack?: number;\n}\n\n/** What {@link useScrollSpy} returns. */\nexport interface ScrollSpy {\n /** Id of the section in view, or null before anything is measured. */\n active: string | null;\n /**\n * Scroll `id` to the container's top and hold that answer until the scroll\n * settles. Without the hold, the scroll the click causes is observed on its\n * way past every intervening section and the rail flickers through them.\n */\n scrollTo: (id: string) => void;\n}\n\n/** How long to keep a programmatic scroll's answer when `scrollend` never\n * arrives — Safari and Firefox have not shipped it. Comfortably longer than a\n * smooth scroll, short enough that a reader who then scrolls by hand is not\n * left looking at a stale highlight. */\nconst SETTLE_MS = 700;\n\n/**\n * Which of a scrolling container's sections is in view, for a navigation rail\n * that follows the reader. Positions are read on the container's own `scroll`\n * event — already throttled to the frame by the browser — rather than through\n * `IntersectionObserver`, so the decision stays a pure function of measured\n * offsets ({@link pickActiveSection}) and is testable apart from the DOM.\n */\nexport function useScrollSpy(options: UseScrollSpyOptions): ScrollSpy {\n const { rootRef, ids, slack } = options;\n const [active, setActive] = useState<string | null>(null);\n // Set while a programmatic scroll runs: what to report, instead of what the\n // moving container would say.\n const heldRef = useRef<string | null>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const releaseRef = useRef<(() => void) | null>(null);\n const key = ids.join('\\u0000');\n\n const measure = useCallback((): void => {\n const root = rootRef.current;\n if (!root) return;\n if (heldRef.current !== null) {\n setActive(heldRef.current);\n return;\n }\n const rootTop = root.getBoundingClientRect().top;\n const offsets: SectionOffset[] = [];\n for (const id of ids) {\n const el = root.querySelector<HTMLElement>(`[data-spy-section=\"${CSS.escape(id)}\"]`);\n if (el) offsets.push({ id, top: el.getBoundingClientRect().top - rootTop });\n }\n setActive(pickActiveSection(offsets, slack));\n // `ids` is compared by content through `key`: a caller deriving the array\n // each render would otherwise resubscribe on every one.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [rootRef, key, slack]);\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n measure();\n root.addEventListener('scroll', measure, { passive: true });\n return () => root.removeEventListener('scroll', measure);\n }, [rootRef, measure]);\n\n const scrollTo = useCallback((id: string): void => {\n const root = rootRef.current;\n if (!root) return;\n const el = root.querySelector<HTMLElement>(`[data-spy-section=\"${CSS.escape(id)}\"]`);\n heldRef.current = id;\n setActive(id);\n const release = (): void => {\n heldRef.current = null;\n root.removeEventListener('scrollend', release);\n measure();\n };\n // A scroll interrupted by the next one would otherwise leave its\n // `scrollend` listener behind to fire against a later scroll.\n releaseRef.current?.();\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n releaseRef.current = release;\n timerRef.current = setTimeout(release, SETTLE_MS);\n root.addEventListener('scrollend', release);\n if (!el) return;\n const top = el.getBoundingClientRect().top - root.getBoundingClientRect().top + root.scrollTop;\n root.scrollTo?.({ top, behavior: prefersReducedMotion() ? 'auto' : 'smooth' });\n }, [rootRef, measure]);\n\n useEffect(() => () => {\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n releaseRef.current?.();\n }, []);\n\n return { active, scrollTo };\n}\n\nfunction prefersReducedMotion(): boolean {\n return typeof matchMedia === 'function'\n && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n","/* Ported from WeaselDraw's wd-prefs-* rules (apps/draw/src/app.css),\n * generalized onto theme tokens. Column width is overridable via\n * --wzl-prefs-column-width at any ancestor scope. */\n\n.columns {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: var(--wzl-space-6);\n overflow-y: auto;\n padding-right: var(--wzl-space-2);\n}\n\n.column {\n flex: 0 0 var(--wzl-prefs-column-width, 300px);\n width: var(--wzl-prefs-column-width, 300px);\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n}\n\n.panel {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n padding: var(--wzl-space-5);\n background: var(--wzl-surface-sunken);\n border: 1px solid var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n --wzl-input-surface: var(--wzl-surface);\n}\n\n.subpanel {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n margin-top: var(--wzl-space-3);\n padding: var(--wzl-space-4) var(--wzl-space-4) var(--wzl-space-4) var(--wzl-space-5);\n background: var(--wzl-surface-sunken);\n border-left: 2px solid var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n --wzl-input-surface: var(--wzl-surface);\n}\n\n.groupHeader {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-1);\n padding-bottom: var(--wzl-space-2);\n border-bottom: 1px solid var(--wzl-border);\n}\n\n.subpanel .groupHeader {\n border-bottom: none;\n padding-bottom: var(--wzl-space-1);\n}\n\n.groupTitle {\n margin: 0;\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-font-weight-bold);\n color: var(--wzl-fg);\n letter-spacing: var(--wzl-params-label-tracking, var(--wzl-tracking-wider));\n text-transform: var(--wzl-params-label-case, uppercase);\n}\n\n.groupDesc {\n margin: 0;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n line-height: 1.35;\n}\n\n.rows {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n}\n\n/* A leaf's row is a PropertyRow, inline; this only sets the form's type. */\n.row {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg);\n cursor: default;\n}\n\n/* Control slot — fixed width so the label can take the rest of the row.\n * Kit form controls render as block-level flex columns that fill it. */\n.rowControl {\n flex: 0 0 110px;\n min-width: 0;\n display: flex;\n align-items: center;\n}\n\n.unrenderable {\n font-family: var(--wzl-font-mono);\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n}\n\n/* PrefsDialog header row: title text + optional headerExtra chrome. */\n.titleRow {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-6);\n flex: 1;\n min-width: 0;\n}\n\n.titleRow > span:first-child {\n flex: 1;\n min-width: 0;\n}\n\n/* An object leaf renders its fields as its own rows. */\n.objectLeaf {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n inline-size: 100%;\n}\n\n/* Outranks the PropertyRow it styles, which is a flex row. */\n.objectLeaf .objectRow {\n display: grid;\n grid-template-columns: 96px 1fr;\n gap: var(--wzl-space-4);\n align-items: center;\n}\n\n.objectGroup {\n margin: var(--wzl-space-2) 0 0;\n font-size: var(--wzl-font-size-xs);\n font-weight: var(--wzl-font-weight-bold);\n text-transform: var(--wzl-params-label-case, uppercase);\n letter-spacing: var(--wzl-params-label-tracking, var(--wzl-tracking-wide));\n opacity: 0.55;\n}\n\n/* ---------------------------------------------------------------------------\n * Rail layout. The rail is the only chrome: no panels, because the surface\n * the form sits on already has a border and a card inside it restates one.\n * Width is overridable via --wzl-prefs-rail-width at any ancestor scope.\n * ------------------------------------------------------------------------ */\n\n.columnsLayout {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n min-height: 0;\n}\n\n.railLayout {\n display: flex;\n flex-direction: row;\n align-items: stretch;\n min-height: 0;\n block-size: 100%;\n /* The pane scrolls, not the layout: a rail that scrolled away with the\n settings would be useless exactly when it is needed. */\n overflow: hidden;\n}\n\n/* What `PrefsDialog` hands `Dialog` for its body in rail layout: the pane\n inside does the scrolling and the rail meets the dialog's own edges. */\n.railBody {\n padding: 0;\n overflow: hidden;\n /* The modal sets only `max-height`, so the layout's `block-size: 100%`\n resolves against nothing and the pane grows to fit every row. As a flex\n item the layout takes the body's flexed height, which the cap does bound. */\n display: flex;\n flex-direction: column;\n /* A settled height: without one the dialog grows and shrinks as the reader\n moves between a two-row group and a twenty-row one, and the rail entry\n they are aiming at moves while they aim at it. */\n min-block-size: min(60vh, 420px);\n /* Same reason across: a filter that narrows the schema to two rows should\n not pull the dialog's edges in around them. */\n min-inline-size: min(760px, 90vw);\n}\n\n.railBody > .railLayout {\n flex: 1 1 auto;\n}\n\n.rail {\n /* Never more than two fifths of the box: at its full width in a narrow\n container the rail takes the space the settings need and leaves a pane\n too thin to hold a row. The clamp belongs on the flex basis — an\n `inline-size` here is simply ignored, which is what made a first attempt\n at this look right and do nothing. */\n flex: 0 1 min(var(--wzl-prefs-rail-width, 216px), 40%);\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-2);\n padding: var(--wzl-space-3) var(--wzl-space-2);\n background: var(--wzl-surface-sunken);\n border-right: 1px solid var(--wzl-border);\n overflow-y: auto;\n /* The rail is itself sunken, so a field taking the default surface would be\n the same color as the rail behind it. */\n --wzl-input-surface: var(--wzl-surface);\n}\n\n.railList {\n display: flex;\n flex-direction: column;\n gap: 1px;\n}\n\n.railItem {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-2);\n padding: var(--wzl-space-2) var(--wzl-space-3);\n border: none;\n border-radius: var(--wzl-radius-sm);\n background: none;\n color: var(--wzl-fg);\n font: inherit;\n font-size: var(--wzl-font-size-sm);\n text-align: start;\n cursor: default;\n}\n\n.railItem:hover {\n background: var(--wzl-surface-raised);\n}\n\n.railItem:focus-visible {\n outline: 2px solid var(--wzl-focus-ring);\n outline-offset: -2px;\n}\n\n.railSub {\n padding-left: var(--wzl-space-7);\n}\n\n.railOpen,\n.railOpen:hover {\n background: var(--wzl-accent);\n color: var(--wzl-fg-on-accent);\n}\n\n.railInView {\n box-shadow: inset 2px 0 0 var(--wzl-accent);\n}\n\n.railName {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Last in the row: a count that changes as the reader types would otherwise\n shove the name on every keystroke. */\n.railCount {\n composes: numeric from '@weasel-js/theme/numeric.module.css';\n margin-left: auto;\n font-size: var(--wzl-font-size-xs);\n opacity: 0.6;\n}\n\n.pane {\n flex: 1;\n min-width: 0;\n overflow-y: auto;\n padding: var(--wzl-space-5) var(--wzl-space-6);\n}\n\n.paneHead {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-1);\n margin-bottom: var(--wzl-space-5);\n}\n\n.paneTitle {\n margin: 0;\n font-size: var(--wzl-font-size-lg);\n font-weight: var(--wzl-font-weight-medium);\n color: var(--wzl-fg);\n}\n\n.paneDesc {\n margin: 0;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n line-height: 1.35;\n}\n\n.paneSection {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n margin-top: var(--wzl-space-6);\n}\n\n.paneSubsection {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-2);\n margin-top: var(--wzl-space-4);\n padding-left: var(--wzl-space-4);\n border-left: 2px solid var(--wzl-border);\n}\n\n.sectionTitle {\n position: sticky;\n /* Sticky offsets are measured from the scrollport's edge, not from inside\n the pane's padding, so this is 0 and the heading's own padding is what\n keeps the text off the edge. */\n top: 0;\n z-index: 1;\n margin: 0;\n padding: var(--wzl-space-3) 0 var(--wzl-space-2);\n background: var(--wzl-surface);\n border-bottom: 1px solid var(--wzl-border);\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-font-weight-bold);\n color: var(--wzl-fg-subtle);\n letter-spacing: var(--wzl-params-label-tracking, var(--wzl-tracking-wider));\n text-transform: var(--wzl-params-label-case, uppercase);\n}\n\n.subsectionTitle {\n margin: 0;\n font-size: var(--wzl-font-size-xs);\n font-weight: var(--wzl-font-weight-bold);\n color: var(--wzl-fg-subtle);\n letter-spacing: var(--wzl-params-label-tracking, var(--wzl-tracking-wide));\n text-transform: var(--wzl-params-label-case, uppercase);\n}\n\n/* In the rail layout a row is a grid, so the control track grows with the\n pane instead of holding at the columns layout's fixed slot. */\n.railLayout .row {\n display: grid;\n /* The control track is capped rather than taking the rest: a number field\n as wide as the pane reads as a text area, and every row's control starts\n at the same x either way. */\n grid-template-columns:\n minmax(140px, var(--wzl-params-label-width, 240px))\n minmax(180px, 260px);\n align-items: center;\n}\n\n.railLayout .rowControl {\n flex: 1 1 auto;\n}\n\n.filter {\n padding: 0 var(--wzl-space-1) var(--wzl-space-2);\n}\n\n.noMatches {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--wzl-space-3);\n padding: var(--wzl-space-6) 0;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n}\n\n.noMatches p {\n margin: 0;\n}\n\n.clearFilter {\n padding: var(--wzl-space-1) var(--wzl-space-3);\n border: 1px solid var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n background: var(--wzl-surface-raised);\n color: var(--wzl-fg);\n font: inherit;\n font-size: var(--wzl-font-size-sm);\n}\n","import { type ReactNode } from 'react';\nimport { PropertyControl } from '../Properties/PropertyField';\nimport { PropertyRow } from '../Properties/PropertyPanel';\nimport { prefFieldProps } from './prefField';\nimport {\n isPrefLeaf,\n prefValueAtPath,\n type PrefGroup,\n type PrefLeaf,\n type PrefObject,\n} from './schema';\nimport s from './Prefs.module.css';\n\n/** What a {@link PrefRenderer} is given for the leaf it is rendering. */\nexport interface PrefRenderContext {\n /** Dotted path of the leaf within the schema root. */\n path: string;\n /** The schema node. App renderers narrow this to their own kind shape. */\n pref: PrefLeaf;\n /** Current value — `values` at `path`, falling back to `pref.default`. */\n value: unknown;\n setValue: (value: unknown) => void;\n /** Whether this leaf is currently auto — not pinned, computed by the owner. */\n auto: boolean;\n /** Toggle this leaf's auto state. */\n setAuto: (next: boolean) => void;\n}\n\n/**\n * Renders the control cell for one preference leaf. Returning `null`\n * collapses the row.\n */\nexport type PrefRenderer = (ctx: PrefRenderContext) => ReactNode;\n\nexport interface WalkCtx {\n values: unknown;\n onChange: (path: string, value: unknown) => void;\n renderers?: Record<string, PrefRenderer>;\n auto?: ReadonlySet<string>;\n onAutoChange?: (path: string, next: boolean) => void;\n inheritHint?: (path: string) => string | undefined;\n canInherit?: (path: string) => boolean;\n}\n\nexport function PrefRow({ ctx, path, pref }: { ctx: WalkCtx; path: string; pref: PrefLeaf }) {\n const stored = prefValueAtPath(ctx.values, path);\n const inherited = ctx.auto?.has(path) ?? false;\n const { onAutoChange } = ctx;\n const toggles = onAutoChange !== undefined && (ctx.canInherit?.(path) ?? true);\n const setAuto = (next: boolean): void => {\n if (toggles) onAutoChange(path, next);\n };\n const renderCtx: PrefRenderContext = {\n path,\n pref,\n value: stored !== undefined ? stored : pref.default,\n setValue: (v) => ctx.onChange(path, v),\n auto: inherited,\n setAuto,\n };\n\n const custom = ctx.renderers?.[pref.kind];\n const control = custom ? custom(renderCtx) : renderBuiltin(renderCtx);\n if (custom && control === null) return null;\n\n // `block` leaves own their chrome (embedded editors with their own\n // header) — no label/tooltip row.\n if (pref.block) return <>{control}</>;\n\n return (\n <PropertyRow\n label={pref.name}\n description={pref.description}\n layout=\"inline\"\n className={s.row}\n // The owner passes an inherited leaf's value already resolved, so the\n // control keeps drawing it; editing it pins, through `onChange`.\n auto={inherited}\n autoControl=\"dimmed\"\n onAutoChange={toggles ? setAuto : undefined}\n hint={inherited ? ctx.inheritHint?.(path) : undefined}\n >\n <span className={s.rowControl}>{control}</span>\n </PropertyRow>\n );\n}\n\nfunction renderBuiltin(\n ctx: PrefRenderContext,\n // The object a nested leaf is a field of — what an enum `encoding` and a\n // font's weight and slant read against. Undefined for a top-level leaf.\n siblings?: Record<string, unknown>,\n): ReactNode {\n const { pref, value, setValue } = ctx;\n if (pref.kind === 'object') return <ObjectLeaf ctx={ctx} />;\n const field = prefFieldProps(pref, { value, siblings, setValue });\n if (field === null) {\n // App-defined kind with no `renderers` entry: labeled placeholder, not a\n // crash — a missing wiring should be visible and recoverable.\n return <span className={s.unrenderable}>({pref.kind}: no renderer)</span>;\n }\n switch (field.kind) {\n // A form stores what was settled on: a number once it is entered, a color\n // once its gesture ends.\n case 'number':\n return (\n <PropertyControl\n {...field}\n name={pref.name}\n onInput={settledOnly}\n steppers={field.accepts === undefined}\n />\n );\n case 'color':\n return <PropertyControl {...field} name={pref.name} onInput={settledOnly} />;\n default:\n return <PropertyControl {...field} name={pref.name} />;\n }\n}\n\nconst settledOnly = (): void => {};\n\n/** One value with its fields hanging off it: each field renders its own\n * control and commits the parent object whole. */\nfunction ObjectLeaf({ ctx }: { ctx: PrefRenderContext }) {\n const pref = ctx.pref as PrefObject;\n const { value, setValue } = ctx;\n const held = typeof value === 'object' && value !== null\n ? (value as Record<string, unknown>)\n : undefined;\n const objectRows = (children: Record<string, PrefLeaf | PrefGroup>): ReactNode[] => {\n const out: ReactNode[] = [];\n for (const [key, child] of Object.entries(children)) {\n if (!isPrefLeaf(child)) {\n const inner = objectRows(child.children);\n if (inner.length === 0) continue;\n out.push(<h4 key={`group:${key}`} className={s.objectGroup}>{child.name}</h4>, ...inner);\n continue;\n }\n out.push(\n <PropertyRow\n key={key}\n label={child.name}\n layout=\"inline\"\n className={s.objectRow}\n >\n <span className={s.rowControl}>\n {renderBuiltin({\n path: `${ctx.path}.${key}`,\n pref: child,\n value: held?.[key],\n setValue: (v) => {\n const base = held ?? pref.fromScalar?.(value) ?? {};\n setValue({ ...base, [key]: v });\n },\n // A field is not pinned on its own — it shares the state of\n // the object leaf it hangs off.\n auto: ctx.auto,\n setAuto: ctx.setAuto,\n }, held)}\n </span>\n </PropertyRow>,\n );\n }\n return out;\n };\n return <div className={s.objectLeaf}>{objectRows(pref.children)}</div>;\n}\n","import { type RefObject } from 'react';\nimport { isPrefLeaf, type PrefGroup, type PrefLeaf } from './schema';\nimport { PrefRow, type WalkCtx } from './PrefsRow';\nimport s from './Prefs.module.css';\n\n/** Props for {@link PrefsPane}. */\nexport interface PrefsPaneProps {\n ctx: WalkCtx;\n /** The open group, or a synthetic one holding the root's loose leaves. */\n group: PrefGroup;\n /** Dotted path of `group`. Empty for the loose-leaf pane. */\n path: string;\n /** The pane's scroll container, for the rail's scroll spy. */\n scrollRef: RefObject<HTMLDivElement | null>;\n className?: string;\n}\n\n/**\n * One rail section's settings: the group's own leaves, then one headed\n * section per nested group.\n *\n * Nothing here draws a panel. The rail is the layout's structure, and a card\n * inside a dialog that already has a border only restates it — the columns\n * layout's sunken panels are what this is the alternative to.\n */\nexport function PrefsPane(props: PrefsPaneProps) {\n const { ctx, group, path, scrollRef, className } = props;\n const leaves = Object.entries(group.children).filter(\n (entry): entry is [string, PrefLeaf] => isPrefLeaf(entry[1]),\n );\n const groups = Object.entries(group.children).filter(\n (entry): entry is [string, PrefGroup] => !isPrefLeaf(entry[1]),\n );\n const childPath = (key: string): string => (path === '' ? key : `${path}.${key}`);\n\n return (\n <div className={[s.pane, className].filter(Boolean).join(' ')} ref={scrollRef}>\n <div className={s.paneHead}>\n <h3 className={s.paneTitle}>{group.name}</h3>\n {group.description !== undefined && (\n <p className={s.paneDesc}>{group.description}</p>\n )}\n </div>\n {leaves.length > 0 && (\n <div className={s.rows}>\n {leaves.map(([key, leaf]) => (\n <PrefRow key={key} ctx={ctx} path={childPath(key)} pref={leaf} />\n ))}\n </div>\n )}\n {groups.map(([key, child]) => (\n <PaneSection\n key={key}\n ctx={ctx}\n group={child}\n path={childPath(key)}\n depth={0}\n />\n ))}\n </div>\n );\n}\n\n/**\n * A nested group inside a pane. Depth 0 sections are the ones the rail links\n * to and carry `data-spy-section`; deeper ones indent and are reached only by\n * scrolling, which is what keeps the rail two levels deep whatever the schema\n * does.\n */\nfunction PaneSection({ ctx, group, path, depth }: {\n ctx: WalkCtx;\n group: PrefGroup;\n path: string;\n depth: number;\n}) {\n const Heading = depth === 0 ? 'h4' : 'h5';\n return (\n <section\n className={depth === 0 ? s.paneSection : s.paneSubsection}\n data-spy-section={depth === 0 ? path : undefined}\n aria-label={group.name}\n >\n <Heading className={depth === 0 ? s.sectionTitle : s.subsectionTitle}>\n {group.name}\n </Heading>\n {group.description !== undefined && (\n <p className={s.paneDesc}>{group.description}</p>\n )}\n <div className={s.rows}>\n {Object.entries(group.children).map(([key, child]) => {\n const p = `${path}.${key}`;\n return isPrefLeaf(child) ? (\n <PrefRow key={key} ctx={ctx} path={p} pref={child} />\n ) : (\n <PaneSection key={key} ctx={ctx} group={child} path={p} depth={depth + 1} />\n );\n })}\n </div>\n </section>\n );\n}\n","import type { ReactNode } from 'react';\nimport { useRovingTabIndex } from '../../useRovingTabIndex';\nimport type { PrefRailItem } from './schema';\nimport s from './Prefs.module.css';\n\n/** Props for {@link PrefsRail}. */\nexport interface PrefsRailProps {\n items: readonly PrefRailItem[];\n /** Path of the open group: depth 0, or depth 1 under `subPages`. */\n section: string;\n /** Path of the depth-1 group in view, from the pane's scroll spy. */\n current: string | null;\n /** A depth-0 entry was chosen: open its pane. */\n onOpen: (path: string) => void;\n /** A depth-1 entry was chosen: scroll the open pane to it, or, under\n * `subPages`, open it. */\n onScrollTo: (path: string) => void;\n /** Accessible name for the rail's landmark. */\n ariaLabel: string;\n /** Rendered above the list — the filter field, when there is one. */\n header?: ReactNode;\n /** Show each entry's match count. Only meaningful while filtering. */\n showCounts?: boolean;\n}\n\n/**\n * The rail beside a `PrefsForm` pane: depth-0 groups, each followed by the\n * depth-1 groups that scroll within it.\n *\n * A list of buttons rather than a tablist, because only half of these entries\n * switch anything — the nested ones scroll the pane the selected entry already\n * opened, and a tab that does not own a panel has no honest role. The open\n * group is `aria-current=\"page\"`; the nested group in view is\n * `aria-current=\"location\"`.\n */\nexport function PrefsRail(props: PrefsRailProps) {\n const { items, section, current, onOpen, onScrollTo, ariaLabel, header, showCounts } = props;\n const activate = (index: number): void => {\n const item = items[index];\n if (!item) return;\n if (item.depth === 0) onOpen(item.path);\n else onScrollTo(item.path);\n };\n const roving = useRovingTabIndex<HTMLDivElement>({\n itemSelector: `.${s.railItem}`,\n tabStopIndex: Math.max(0, items.findIndex((i) => i.path === section)),\n });\n\n return (\n <nav className={s.rail} aria-label={ariaLabel}>\n {header}\n <div className={s.railList} ref={roving.rootRef} onKeyDown={roving.onKeyDown}>\n {items.map((item, index) => {\n const open = item.path === section;\n const inView = item.depth === 1 && item.path === current;\n return (\n <button\n key={item.path === '' ? '\\u0000root' : item.path}\n type=\"button\"\n className={[s.railItem, item.depth === 1 && s.railSub, open && s.railOpen, inView && s.railInView]\n .filter(Boolean)\n .join(' ')}\n aria-current={open ? 'page' : inView ? 'location' : undefined}\n onClick={() => activate(index)}\n >\n <span className={s.railName}>{item.name}</span>\n {showCounts ? <span className={s.railCount}>{item.matches}</span> : null}\n </button>\n );\n })}\n </div>\n </nav>\n );\n}\n","import { useMemo, useRef, useState, type ReactNode } from 'react';\nimport { Input } from '../Input';\nimport { useScrollSpy } from '../../useScrollSpy';\nimport {\n filterPrefSubtree,\n isPrefLeaf,\n prefRailItems,\n visiblePrefSubtree,\n type PrefGroup,\n} from './schema';\nimport { PrefRow, type PrefRenderer, type WalkCtx } from './PrefsRow';\nimport { PrefsPane } from './PrefsPane';\nimport { PrefsRail } from './PrefsRail';\nimport s from './Prefs.module.css';\n\nexport type { PrefRenderer, PrefRenderContext } from './PrefsRow';\n\n/** How a {@link PrefsForm} lays its groups out. */\nexport type PrefsLayout = 'columns' | 'rail';\n\n/** Props for {@link PrefsForm}. */\nexport interface PrefsFormProps {\n /** Root of the schema tree. Core `ToolPrefGroup`s assign structurally. */\n schema: PrefGroup;\n /** Nested value tree (shape mirrors the schema). Sparse is fine —\n * missing leaves fall back to their schema `default`. */\n values?: unknown;\n /** Change callback with the leaf's dotted path. Values apply live;\n * there is no dirty/commit state. */\n onChange: (path: string, value: unknown) => void;\n /**\n * Per-kind renderers for app-defined kinds. Entries also override the\n * built-in kinds when keys collide. A renderer owns the control cell\n * (the label/tooltip row chrome stays with the form, unless the leaf\n * sets `block`); returning `null` collapses the row entirely. Unknown\n * kinds with no renderer show a labeled placeholder instead of\n * crashing.\n */\n renderers?: Record<string, PrefRenderer>;\n /** Reveal `hidden` leaves (dev tooling). Default false. */\n showHidden?: boolean;\n /**\n * `'columns'` (the default) wraps each top-level group into its own panel\n * column. `'rail'` puts a two-level navigation rail beside one group's\n * settings at a time — what a dialog-sized surface wants, since columns\n * overflow sideways once there are more than two.\n */\n layout?: PrefsLayout;\n /** Show a filter field that narrows the form to matching leaves. */\n filterable?: boolean;\n /** Rail layout: path of the open top-level group. Controlled. */\n section?: string;\n /** Rail layout: path of the group open before the reader picks one.\n * Defaults to the first in the schema. */\n defaultSection?: string;\n onSectionChange?: (path: string) => void;\n /**\n * Rail layout: a nested entry opens a page of its own group instead of\n * scrolling the open one to it, and a top-level entry's page holds only its\n * own leaves (or opens its first nested entry when it has none). For a\n * top-level group whose subgroups are long enough that one page of all of\n * them reads as a wall. Default false.\n */\n subPages?: boolean;\n /** Dotted paths whose leaves currently inherit: each still draws its control,\n * dimmed, showing the value in `values` — pass it already resolved. Editing\n * it calls `onChange` as usual, which is the owner's cue to pin it. */\n auto?: ReadonlySet<string>;\n /** Given, a leaf's label toggles whether it inherits: `next` true unpins it,\n * false pins it at the value it shows. Leaves `canInherit` refuses keep a\n * plain label. */\n onAutoChange?: (path: string, next: boolean) => void;\n /** Which leaves can inherit, and so get a label toggle. Default: every leaf,\n * once `onAutoChange` is given. */\n canInherit?: (path: string) => boolean;\n /** Small text after an inherited leaf's label, e.g. `() => 'from Defaults'`.\n * Default: none. */\n inheritHint?: (path: string) => string | undefined;\n className?: string;\n}\n\n/**\n * Schema-driven preferences form. Leaves render as label + control rows;\n * how the groups around them are arranged is `layout`'s to say — columns of\n * panels, or a navigation rail beside one group at a time.\n *\n * Storage-agnostic: pair with `PrefsDialog` for the modal composition, and\n * persist however the app likes via `onChange`.\n */\nexport function PrefsForm(props: PrefsFormProps) {\n const {\n schema,\n values,\n onChange,\n renderers,\n showHidden = false,\n layout = 'columns',\n filterable = false,\n auto,\n onAutoChange,\n canInherit,\n inheritHint,\n className,\n } = props;\n const [query, setQuery] = useState('');\n const root = useMemo(() => {\n const visible = visiblePrefSubtree(schema, showHidden);\n return visible === null ? null : filterPrefSubtree(visible, query);\n }, [schema, showHidden, query]);\n\n const ctx: WalkCtx = { values, onChange, renderers, auto, onAutoChange, canInherit, inheritHint };\n const field = filterable ? (\n <div className={s.filter}>\n <Input\n value={query}\n onChange={setQuery}\n aria-label={`Filter ${schema.name}`}\n placeholder=\"Filter settings\"\n />\n </div>\n ) : null;\n\n if (layout === 'rail') {\n return (\n <RailLayout\n {...props}\n root={root}\n ctx={ctx}\n query={query}\n filterField={field}\n onClearFilter={() => setQuery('')}\n />\n );\n }\n\n return (\n <div className={[s.columnsLayout, className].filter(Boolean).join(' ')}>\n {field}\n {root === null ? (\n <NoMatches query={query} onClear={() => setQuery('')} />\n ) : (\n <div className={s.columns}>\n {Object.entries(root.children).map(([key, child]) => (\n <div key={key} className={s.column}>\n {isPrefLeaf(child) ? (\n // Top-level leaves are unusual but legal — give each its own\n // column for symmetry with grouped siblings.\n <PrefRow ctx={ctx} path={key} pref={child} />\n ) : (\n <GroupBody ctx={ctx} group={child} path={key} depth={0} />\n )}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n\n/** The rail layout's own state: which group is open, and where the pane is\n * scrolled to within it. Split out so the columns layout runs none of it. */\nfunction RailLayout(props: PrefsFormProps & {\n root: PrefGroup | null;\n ctx: WalkCtx;\n query: string;\n filterField: ReactNode;\n onClearFilter: () => void;\n}) {\n const { schema, root, ctx, query, filterField, onClearFilter, className } = props;\n const items = useMemo(() => (root === null ? [] : prefRailItems(root)), [root]);\n const [uncontrolled, setUncontrolled] = useState(\n () => props.defaultSection ?? '',\n );\n const subPages = props.subPages === true;\n const requested = props.section ?? uncontrolled;\n // A filter can take the open group out of the rail entirely, and a section\n // the schema never had can arrive from a consumer's stale state. Either way\n // the first surviving entry is what the reader should be looking at.\n let open = items.some((i) => i.path === requested && (i.depth === 0 || subPages))\n ? requested\n : (items.find((i) => i.depth === 0)?.path ?? '');\n if (subPages && root !== null && !hasLeaves(paneGroup(root, open, schema.name))) {\n open = items.find((i) => i.depth === 1 && i.section === open)?.path ?? open;\n }\n\n const scrollRef = useRef<HTMLDivElement | null>(null);\n const sectionIds = useMemo(\n () =>\n subPages\n ? []\n : items.filter((i) => i.depth === 1 && i.section === open).map((i) => i.path),\n [items, open, subPages],\n );\n const spy = useScrollSpy({ rootRef: scrollRef, ids: sectionIds });\n\n const setOpen = (path: string): void => {\n if (props.section === undefined) setUncontrolled(path);\n props.onSectionChange?.(path);\n // Optional-called: jsdom's elements have no `scrollTo`, and neither does\n // a pane that is not the scrolling box in some consumer's layout.\n scrollRef.current?.scrollTo?.({ top: 0 });\n };\n\n const whole = root === null ? null : paneGroup(root, open, schema.name);\n const opensTop = items.some((i) => i.path === open && i.depth === 0);\n const group = subPages && opensTop && whole !== null ? leavesOf(whole) : whole;\n\n return (\n <div className={[s.railLayout, className].filter(Boolean).join(' ')}>\n <PrefsRail\n items={items}\n section={open}\n current={subPages ? null : spy.active}\n onOpen={setOpen}\n onScrollTo={subPages ? setOpen : spy.scrollTo}\n ariaLabel={schema.name}\n header={filterField}\n showCounts={query.trim() !== ''}\n />\n {group === null ? (\n <div className={s.pane}>\n <NoMatches query={query} onClear={onClearFilter} />\n </div>\n ) : (\n <PrefsPane ctx={ctx} group={group} path={open} scrollRef={scrollRef} />\n )}\n </div>\n );\n}\n\n/**\n * The group a rail path opens. The empty path is the root's loose leaves,\n * which belong to no group of their own and are handed back as one named for\n * the schema — the rail lists them under the same name.\n */\nfunction paneGroup(root: PrefGroup, path: string, rootName: string): PrefGroup | null {\n if (path === '') {\n const children = Object.fromEntries(\n Object.entries(root.children).filter(([, child]) => isPrefLeaf(child)),\n );\n return Object.keys(children).length === 0\n ? null\n : { ...root, name: rootName, children };\n }\n let node: PrefGroup | undefined;\n let cursor = root;\n for (const seg of path.split('.')) {\n const next = cursor.children[seg];\n if (next === undefined || isPrefLeaf(next)) return null;\n node = next;\n cursor = next;\n }\n return node ?? null;\n}\n\n/** Whether a group holds any leaf directly, not counting its subgroups. */\nfunction hasLeaves(group: PrefGroup | null): boolean {\n return group !== null && Object.values(group.children).some(isPrefLeaf);\n}\n\n/** A group cut down to its direct leaves, for a page its subgroups each get their own of. */\nfunction leavesOf(group: PrefGroup): PrefGroup {\n return {\n ...group,\n children: Object.fromEntries(\n Object.entries(group.children).filter(([, child]) => isPrefLeaf(child)),\n ),\n };\n}\n\n/** What a filter matching nothing leaves behind. */\nfunction NoMatches({ query, onClear }: { query: string; onClear: () => void }) {\n return (\n <div className={s.noMatches}>\n <p>No settings match “{query.trim()}”.</p>\n <button type=\"button\" className={s.clearFilter} onClick={onClear}>\n Clear filter\n </button>\n </div>\n );\n}\n\nfunction GroupBody({ ctx, group, path, depth }: {\n ctx: WalkCtx;\n group: PrefGroup;\n path: string;\n depth: number;\n}) {\n return (\n <div className={depth === 0 ? s.panel : s.subpanel}>\n <div className={s.groupHeader}>\n <h3 className={s.groupTitle}>{group.name}</h3>\n {group.description !== undefined && (\n <p className={s.groupDesc}>{group.description}</p>\n )}\n </div>\n <div className={s.rows}>\n {Object.entries(group.children).map(([key, child]) => {\n const childPath = `${path}.${key}`;\n return isPrefLeaf(child) ? (\n <PrefRow key={key} ctx={ctx} path={childPath} pref={child} />\n ) : (\n <GroupBody key={key} ctx={ctx} group={child} path={childPath} depth={depth + 1} />\n );\n })}\n </div>\n </div>\n );\n}\n\n","import type { ReactNode } from 'react';\nimport { Dialog } from '../Dialog';\nimport { PrefsForm, type PrefsFormProps } from './PrefsForm';\nimport s from './Prefs.module.css';\n\n/**\n * Props for {@link PrefsDialog} — everything {@link PrefsForm} takes, plus\n * the dialog's own open state and chrome.\n */\nexport interface PrefsDialogProps extends PrefsFormProps {\n isOpen: boolean;\n onOpenChange: (open: boolean) => void;\n /** Dialog heading. Defaults to the schema root's `name`. */\n title?: ReactNode;\n /** Extra chrome rendered at the end of the title row (e.g. a dev-mode\n * \"Show hidden\" switch). An action the reader acts on when they are done\n * — resetting, importing — belongs in `footer` instead, where a dialog's\n * actions live. */\n headerExtra?: ReactNode;\n /** Footer slot, passed through to `Dialog` — typically a reset or done\n * action. */\n footer?: ReactNode;\n /** Class applied to the dialog's modal box. */\n dialogClassName?: string;\n}\n\n/**\n * The kit's preferences dialog: `Dialog` + `PrefsForm`. Changes apply\n * live through `onChange` — there is no OK/Cancel staging. For custom\n * placement (sidebar, popover, inline page), compose `PrefsForm`\n * directly; this wrapper is intentionally thin.\n *\n * `layout=\"rail\"` is what a dialog usually wants: the default columns wrap\n * sideways past two groups, and this box is 900px at its widest.\n */\nexport function PrefsDialog(props: PrefsDialogProps) {\n const { isOpen, onOpenChange, title, headerExtra, footer, dialogClassName, ...form } = props;\n const rail = form.layout === 'rail';\n return (\n <Dialog\n isOpen={isOpen}\n onOpenChange={onOpenChange}\n aria-label={typeof title === 'string' ? title : form.schema.name}\n className={dialogClassName}\n footer={footer}\n bodyClassName={rail ? s.railBody : undefined}\n title={\n headerExtra !== undefined ? (\n <span className={s.titleRow}>\n <span>{title ?? form.schema.name}</span>\n {headerExtra}\n </span>\n ) : (\n title ?? form.schema.name\n )\n }\n >\n <PrefsForm {...form} />\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;AAoBA,SA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,gBAAgB,KAAA,KACrB,kBAAC,KAAD;IAAG,WAAWtE,EAAE;IAAY,UAAAsE,EAAM;GAAe,CAAA,CAEhD;EACL,CAAA,GAAA,kBAAC,OAAD;GAAK,WAAWtE,EAAE;GACf,UAAA,OAAO,QAAQsE,EAAM,QAAQ,CAAC,CAAC,KAAK,CAAC3C,GAAKoC,OAAW;IACpD,IAAMU,IAAY,GAAG9B,EAAK,GAAGhB;IAC7B,OAAOlB,EAAWsD,CAAK,IACrB,kBAACvB,GAAD;KAAwB;KAAK,MAAMiC;KAAW,MAAMV;IAAQ,GAA9CpC,CAA8C,IAE5D,kBAACiF,GAAD;KAA0B;KAAK,OAAO7C;KAAO,MAAMU;KAAW,OAAOM,IAAQ;IAAI,GAAjEpD,CAAiE;GAErF,CAAC;EACE,CAAA,CACF;;AAET;;;ACjRA,SAAgBqG,EAAY,GAAyB;CACnD,IAAM,EAAE,WAAQ,iBAAc,UAAO,gBAAa,WAAQ,oBAAiB,GAAGC,MAAS7D,GACjF8D,IAAOD,EAAK,WAAW;CAC7B,OACE,kBAAC/H,GAAD;EACU;EACM;EACd,cAAY,OAAOiI,KAAU,WAAWA,IAAQF,EAAK,OAAO;EAC5D,WAAWG;EACH;EACR,eAAeF,IAAOjI,EAAE,WAAW,KAAA;EACnC,OACEoI,MAAgB,KAAA,IAMdF,KAASF,EAAK,OAAO,OALrB,kBAAC,QAAD;GAAM,WAAWhI,EAAE;GAAnB,UAAA,CACE,kBAAC,QAAD,EAAA,UAAOkI,KAASF,EAAK,OAAO,KAAW,CAAA,GACtCI,CACG;EAEN,CAAA;EAIJ,UAAA,kBAACpC,GAAD,EAAW,GAAIgC,EAAO,CAAA;CAChB,CAAA;AAEZ"}
1
+ {"version":3,"file":"Prefs-BnVEyfWO.js","names":["_Fragment","s","s","s","s","s","Dialog","PropertyRow","PropertyControl","Input","useRovingTabIndex","filterPrefSubtree","prefValueAtPath","isPrefLeaf","visiblePrefSubtree","prefFieldProps","pickActiveSection","active","offsets","top","slack","id","SETTLE_MS","useScrollSpy","options","setActive","useState","heldRef","useRef","timerRef","releaseRef","key","ids","measure","useCallback","root","rootRef","rootTop","el","scrollTo","release","prefersReducedMotion","useEffect","Prefs_module_default","PrefRow","stored","ctx","path","inherited","toggles","onAutoChange","setAuto","next","renderCtx","pref","v","custom","control","renderBuiltin","Fragment","ObjectLeaf","field","settledOnly","held","value","objectRows","out","child","children","inner","base","PrefsPane","props","leaves","group","entry","groups","childPath","className","scrollRef","leaf","PaneSection","Heading","depth","p","PrefsRail","activate","item","items","index","onOpen","onScrollTo","roving","i","section","ariaLabel","header","open","inView","current","showCounts","PrefsForm","query","setQuery","useMemo","visible","schema","showHidden","filterable","layout","RailLayout","NoMatches","GroupBody","prefRailItems","uncontrolled","setUncontrolled","subPages","requested","hasLeaves","paneGroup","spy","setOpen","whole","opensTop","leavesOf","filterField","onClearFilter","rootName","node","cursor","seg","onClear","PrefsDialog","form","rail","title","dialogClassName","headerExtra"],"sources":["../../src/useScrollSpy.ts","../../src/components/Prefs/Prefs.module.css","../../src/components/Prefs/PrefsRow.tsx","../../src/components/Prefs/PrefsPane.tsx","../../src/components/Prefs/PrefsRail.tsx","../../src/components/Prefs/PrefsForm.tsx","../../src/components/Prefs/PrefsDialog.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, type RefObject } from 'react';\n\n/** One observed section: its id and its top edge, in the container's\n * coordinates (its `getBoundingClientRect().top` less the container's). */\nexport interface SectionOffset {\n id: string;\n top: number;\n}\n\n/**\n * The section a reader is looking at: the last one whose top edge has passed\n * the container's, within `slack` of it so a heading flush with the top counts\n * as arrived. Null until one has — the settings above the first section belong\n * to the group itself, and marking a section the reader has not reached yet\n * points them at the wrong place.\n *\n * Offsets arrive in document order and are not re-sorted — a caller reading\n * them off the DOM already has them that way, and sorting would hide a\n * measurement that came back wrong.\n */\nexport function pickActiveSection(\n offsets: readonly SectionOffset[],\n slack = 8,\n): string | null {\n let active: string | null = null;\n for (const { id, top } of offsets) {\n if (top - slack > 0) break;\n active = id;\n }\n return active;\n}\n\n/** Options for {@link useScrollSpy}. */\nexport interface UseScrollSpyOptions {\n /** The scrolling element holding the sections. */\n rootRef: RefObject<HTMLElement | null>;\n /** Section element ids, in document order. */\n ids: readonly string[];\n /** Pixels of tolerance at the container's top edge. */\n slack?: number;\n}\n\n/** What {@link useScrollSpy} returns. */\nexport interface ScrollSpy {\n /** Id of the section in view, or null before anything is measured. */\n active: string | null;\n /**\n * Scroll `id` to the container's top and hold that answer until the scroll\n * settles. Without the hold, the scroll the click causes is observed on its\n * way past every intervening section and the rail flickers through them.\n */\n scrollTo: (id: string) => void;\n}\n\n/** How long to keep a programmatic scroll's answer when `scrollend` never\n * arrives — Safari and Firefox have not shipped it. Comfortably longer than a\n * smooth scroll, short enough that a reader who then scrolls by hand is not\n * left looking at a stale highlight. */\nconst SETTLE_MS = 700;\n\n/**\n * Which of a scrolling container's sections is in view, for a navigation rail\n * that follows the reader. Positions are read on the container's own `scroll`\n * event — already throttled to the frame by the browser — rather than through\n * `IntersectionObserver`, so the decision stays a pure function of measured\n * offsets ({@link pickActiveSection}) and is testable apart from the DOM.\n */\nexport function useScrollSpy(options: UseScrollSpyOptions): ScrollSpy {\n const { rootRef, ids, slack } = options;\n const [active, setActive] = useState<string | null>(null);\n // Set while a programmatic scroll runs: what to report, instead of what the\n // moving container would say.\n const heldRef = useRef<string | null>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const releaseRef = useRef<(() => void) | null>(null);\n const key = ids.join('\\u0000');\n\n const measure = useCallback((): void => {\n const root = rootRef.current;\n if (!root) return;\n if (heldRef.current !== null) {\n setActive(heldRef.current);\n return;\n }\n const rootTop = root.getBoundingClientRect().top;\n const offsets: SectionOffset[] = [];\n for (const id of ids) {\n const el = root.querySelector<HTMLElement>(`[data-spy-section=\"${CSS.escape(id)}\"]`);\n if (el) offsets.push({ id, top: el.getBoundingClientRect().top - rootTop });\n }\n setActive(pickActiveSection(offsets, slack));\n // `ids` is compared by content through `key`: a caller deriving the array\n // each render would otherwise resubscribe on every one.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [rootRef, key, slack]);\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n measure();\n root.addEventListener('scroll', measure, { passive: true });\n return () => root.removeEventListener('scroll', measure);\n }, [rootRef, measure]);\n\n const scrollTo = useCallback((id: string): void => {\n const root = rootRef.current;\n if (!root) return;\n const el = root.querySelector<HTMLElement>(`[data-spy-section=\"${CSS.escape(id)}\"]`);\n heldRef.current = id;\n setActive(id);\n const release = (): void => {\n heldRef.current = null;\n root.removeEventListener('scrollend', release);\n measure();\n };\n // A scroll interrupted by the next one would otherwise leave its\n // `scrollend` listener behind to fire against a later scroll.\n releaseRef.current?.();\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n releaseRef.current = release;\n timerRef.current = setTimeout(release, SETTLE_MS);\n root.addEventListener('scrollend', release);\n if (!el) return;\n const top = el.getBoundingClientRect().top - root.getBoundingClientRect().top + root.scrollTop;\n root.scrollTo?.({ top, behavior: prefersReducedMotion() ? 'auto' : 'smooth' });\n }, [rootRef, measure]);\n\n useEffect(() => () => {\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n releaseRef.current?.();\n }, []);\n\n return { active, scrollTo };\n}\n\nfunction prefersReducedMotion(): boolean {\n return typeof matchMedia === 'function'\n && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n","/* Ported from WeaselDraw's wd-prefs-* rules (apps/draw/src/app.css),\n * generalized onto theme tokens. Column width is overridable via\n * --wzl-prefs-column-width at any ancestor scope. */\n\n.columns {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: var(--wzl-space-6);\n overflow-y: auto;\n padding-right: var(--wzl-space-2);\n}\n\n.column {\n flex: 0 0 var(--wzl-prefs-column-width, 300px);\n width: var(--wzl-prefs-column-width, 300px);\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n}\n\n.panel {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n padding: var(--wzl-space-5);\n background: var(--wzl-surface-sunken);\n border: 1px solid var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n --wzl-input-surface: var(--wzl-surface);\n}\n\n.subpanel {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n margin-top: var(--wzl-space-3);\n padding: var(--wzl-space-4) var(--wzl-space-4) var(--wzl-space-4) var(--wzl-space-5);\n background: var(--wzl-surface-sunken);\n border-left: 2px solid var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n --wzl-input-surface: var(--wzl-surface);\n}\n\n.groupHeader {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-1);\n padding-bottom: var(--wzl-space-2);\n border-bottom: 1px solid var(--wzl-border);\n}\n\n.subpanel .groupHeader {\n border-bottom: none;\n padding-bottom: var(--wzl-space-1);\n}\n\n.groupTitle {\n margin: 0;\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-font-weight-bold);\n color: var(--wzl-fg);\n letter-spacing: var(--wzl-params-label-tracking, var(--wzl-tracking-wider));\n text-transform: var(--wzl-params-label-case, uppercase);\n}\n\n.groupDesc {\n margin: 0;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n line-height: 1.35;\n}\n\n.rows {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n}\n\n/* A leaf's row is a PropertyRow, inline; this only sets the form's type. */\n.row {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg);\n cursor: default;\n}\n\n/* Control slot — fixed width so the label can take the rest of the row.\n * Kit form controls render as block-level flex columns that fill it. */\n.rowControl {\n flex: 0 0 110px;\n min-width: 0;\n display: flex;\n align-items: center;\n}\n\n.unrenderable {\n font-family: var(--wzl-font-mono);\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n}\n\n/* PrefsDialog header row: title text + optional headerExtra chrome. */\n.titleRow {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-6);\n flex: 1;\n min-width: 0;\n}\n\n.titleRow > span:first-child {\n flex: 1;\n min-width: 0;\n}\n\n/* An object leaf renders its fields as its own rows. */\n.objectLeaf {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n inline-size: 100%;\n}\n\n/* Outranks the PropertyRow it styles, which is a flex row. */\n.objectLeaf .objectRow {\n display: grid;\n grid-template-columns: 96px 1fr;\n gap: var(--wzl-space-4);\n align-items: center;\n}\n\n.objectGroup {\n margin: var(--wzl-space-2) 0 0;\n font-size: var(--wzl-font-size-xs);\n font-weight: var(--wzl-font-weight-bold);\n text-transform: var(--wzl-params-label-case, uppercase);\n letter-spacing: var(--wzl-params-label-tracking, var(--wzl-tracking-wide));\n opacity: 0.55;\n}\n\n/* ---------------------------------------------------------------------------\n * Rail layout. The rail is the only chrome: no panels, because the surface\n * the form sits on already has a border and a card inside it restates one.\n * Width is overridable via --wzl-prefs-rail-width at any ancestor scope.\n * ------------------------------------------------------------------------ */\n\n.columnsLayout {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n min-height: 0;\n}\n\n.railLayout {\n display: flex;\n flex-direction: row;\n align-items: stretch;\n min-height: 0;\n block-size: 100%;\n /* The pane scrolls, not the layout: a rail that scrolled away with the\n settings would be useless exactly when it is needed. */\n overflow: hidden;\n}\n\n/* What `PrefsDialog` hands `Dialog` for its body in rail layout: the pane\n inside does the scrolling and the rail meets the dialog's own edges. */\n.railBody {\n padding: 0;\n overflow: hidden;\n /* The modal sets only `max-height`, so the layout's `block-size: 100%`\n resolves against nothing and the pane grows to fit every row. As a flex\n item the layout takes the body's flexed height, which the cap does bound. */\n display: flex;\n flex-direction: column;\n /* A settled height: without one the dialog grows and shrinks as the reader\n moves between a two-row group and a twenty-row one, and the rail entry\n they are aiming at moves while they aim at it. */\n min-block-size: min(60vh, 420px);\n /* Same reason across: a filter that narrows the schema to two rows should\n not pull the dialog's edges in around them. */\n min-inline-size: min(760px, 90vw);\n}\n\n.railBody > .railLayout {\n flex: 1 1 auto;\n}\n\n.rail {\n /* Never more than two fifths of the box: at its full width in a narrow\n container the rail takes the space the settings need and leaves a pane\n too thin to hold a row. The clamp belongs on the flex basis — an\n `inline-size` here is simply ignored, which is what made a first attempt\n at this look right and do nothing. */\n flex: 0 1 min(var(--wzl-prefs-rail-width, 216px), 40%);\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-2);\n padding: var(--wzl-space-3) var(--wzl-space-2);\n background: var(--wzl-surface-sunken);\n border-right: 1px solid var(--wzl-border);\n overflow-y: auto;\n /* The rail is itself sunken, so a field taking the default surface would be\n the same color as the rail behind it. */\n --wzl-input-surface: var(--wzl-surface);\n}\n\n.railList {\n display: flex;\n flex-direction: column;\n gap: 1px;\n}\n\n.railItem {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-2);\n padding: var(--wzl-space-2) var(--wzl-space-3);\n border: none;\n border-radius: var(--wzl-radius-sm);\n background: none;\n color: var(--wzl-fg);\n font: inherit;\n font-size: var(--wzl-font-size-sm);\n text-align: start;\n cursor: default;\n}\n\n.railItem:hover {\n background: var(--wzl-surface-raised);\n}\n\n.railItem:focus-visible {\n outline: 2px solid var(--wzl-focus-ring);\n outline-offset: -2px;\n}\n\n.railSub {\n padding-left: var(--wzl-space-7);\n}\n\n.railOpen,\n.railOpen:hover {\n background: var(--wzl-accent);\n color: var(--wzl-fg-on-accent);\n}\n\n.railInView {\n box-shadow: inset 2px 0 0 var(--wzl-accent);\n}\n\n.railName {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* Last in the row: a count that changes as the reader types would otherwise\n shove the name on every keystroke. */\n.railCount {\n composes: numeric from '@weasel-js/theme/numeric.module.css';\n margin-left: auto;\n font-size: var(--wzl-font-size-xs);\n opacity: 0.6;\n}\n\n.pane {\n flex: 1;\n min-width: 0;\n overflow-y: auto;\n padding: var(--wzl-space-5) var(--wzl-space-6);\n}\n\n.paneHead {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-1);\n margin-bottom: var(--wzl-space-5);\n}\n\n.paneTitle {\n margin: 0;\n font-size: var(--wzl-font-size-lg);\n font-weight: var(--wzl-font-weight-medium);\n color: var(--wzl-fg);\n}\n\n.paneDesc {\n margin: 0;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n line-height: 1.35;\n}\n\n.paneSection {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n margin-top: var(--wzl-space-6);\n}\n\n.paneSubsection {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-2);\n margin-top: var(--wzl-space-4);\n padding-left: var(--wzl-space-4);\n border-left: 2px solid var(--wzl-border);\n}\n\n.sectionTitle {\n position: sticky;\n /* Sticky offsets are measured from the scrollport's edge, not from inside\n the pane's padding, so this is 0 and the heading's own padding is what\n keeps the text off the edge. */\n top: 0;\n z-index: 1;\n margin: 0;\n padding: var(--wzl-space-3) 0 var(--wzl-space-2);\n background: var(--wzl-surface);\n border-bottom: 1px solid var(--wzl-border);\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-font-weight-bold);\n color: var(--wzl-fg-subtle);\n letter-spacing: var(--wzl-params-label-tracking, var(--wzl-tracking-wider));\n text-transform: var(--wzl-params-label-case, uppercase);\n}\n\n.subsectionTitle {\n margin: 0;\n font-size: var(--wzl-font-size-xs);\n font-weight: var(--wzl-font-weight-bold);\n color: var(--wzl-fg-subtle);\n letter-spacing: var(--wzl-params-label-tracking, var(--wzl-tracking-wide));\n text-transform: var(--wzl-params-label-case, uppercase);\n}\n\n/* In the rail layout a row is a grid, so the control track grows with the\n pane instead of holding at the columns layout's fixed slot. */\n.railLayout .row {\n display: grid;\n /* The control track is capped rather than taking the rest: a number field\n as wide as the pane reads as a text area, and every row's control starts\n at the same x either way. */\n grid-template-columns:\n minmax(140px, var(--wzl-params-label-width, 240px))\n minmax(180px, 260px);\n align-items: center;\n}\n\n.railLayout .rowControl {\n flex: 1 1 auto;\n}\n\n.filter {\n padding: 0 var(--wzl-space-1) var(--wzl-space-2);\n}\n\n.noMatches {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--wzl-space-3);\n padding: var(--wzl-space-6) 0;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n}\n\n.noMatches p {\n margin: 0;\n}\n\n.clearFilter {\n padding: var(--wzl-space-1) var(--wzl-space-3);\n border: 1px solid var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n background: var(--wzl-surface-raised);\n color: var(--wzl-fg);\n font: inherit;\n font-size: var(--wzl-font-size-sm);\n}\n","import { type ReactNode } from 'react';\nimport { PropertyControl } from '../Properties/PropertyField';\nimport { PropertyRow } from '../Properties/PropertyPanel';\nimport { prefFieldProps } from './prefField';\nimport {\n isPrefLeaf,\n prefValueAtPath,\n type PrefGroup,\n type PrefLeaf,\n type PrefObject,\n} from './schema';\nimport s from './Prefs.module.css';\n\n/** What a {@link PrefRenderer} is given for the leaf it is rendering. */\nexport interface PrefRenderContext {\n /** Dotted path of the leaf within the schema root. */\n path: string;\n /** The schema node. App renderers narrow this to their own kind shape. */\n pref: PrefLeaf;\n /** Current value — `values` at `path`, falling back to `pref.default`. */\n value: unknown;\n setValue: (value: unknown) => void;\n /** Whether this leaf is currently auto — not pinned, computed by the owner. */\n auto: boolean;\n /** Toggle this leaf's auto state. */\n setAuto: (next: boolean) => void;\n}\n\n/**\n * Renders the control cell for one preference leaf. Returning `null`\n * collapses the row.\n */\nexport type PrefRenderer = (ctx: PrefRenderContext) => ReactNode;\n\nexport interface WalkCtx {\n values: unknown;\n onChange: (path: string, value: unknown) => void;\n renderers?: Record<string, PrefRenderer>;\n auto?: ReadonlySet<string>;\n onAutoChange?: (path: string, next: boolean) => void;\n inheritHint?: (path: string) => string | undefined;\n canInherit?: (path: string) => boolean;\n}\n\nexport function PrefRow({ ctx, path, pref }: { ctx: WalkCtx; path: string; pref: PrefLeaf }) {\n const stored = prefValueAtPath(ctx.values, path);\n const inherited = ctx.auto?.has(path) ?? false;\n const { onAutoChange } = ctx;\n const toggles = onAutoChange !== undefined && (ctx.canInherit?.(path) ?? true);\n const setAuto = (next: boolean): void => {\n if (toggles) onAutoChange(path, next);\n };\n const renderCtx: PrefRenderContext = {\n path,\n pref,\n value: stored !== undefined ? stored : pref.default,\n setValue: (v) => ctx.onChange(path, v),\n auto: inherited,\n setAuto,\n };\n\n const custom = ctx.renderers?.[pref.kind];\n const control = custom ? custom(renderCtx) : renderBuiltin(renderCtx);\n if (custom && control === null) return null;\n\n // `block` leaves own their chrome (embedded editors with their own\n // header) — no label/tooltip row.\n if (pref.block) return <>{control}</>;\n\n return (\n <PropertyRow\n label={pref.name}\n description={pref.description}\n layout=\"inline\"\n className={s.row}\n // The owner passes an inherited leaf's value already resolved, so the\n // control keeps drawing it; editing it pins, through `onChange`.\n auto={inherited}\n autoControl=\"dimmed\"\n onAutoChange={toggles ? setAuto : undefined}\n hint={inherited ? ctx.inheritHint?.(path) : undefined}\n >\n <span className={s.rowControl}>{control}</span>\n </PropertyRow>\n );\n}\n\nfunction renderBuiltin(\n ctx: PrefRenderContext,\n // The object a nested leaf is a field of — what an enum `encoding` and a\n // font's weight and slant read against. Undefined for a top-level leaf.\n siblings?: Record<string, unknown>,\n): ReactNode {\n const { pref, value, setValue } = ctx;\n if (pref.kind === 'object') return <ObjectLeaf ctx={ctx} />;\n const field = prefFieldProps(pref, { value, siblings, setValue });\n if (field === null) {\n // App-defined kind with no `renderers` entry: labeled placeholder, not a\n // crash — a missing wiring should be visible and recoverable.\n return <span className={s.unrenderable}>({pref.kind}: no renderer)</span>;\n }\n switch (field.kind) {\n // A form stores what was settled on: a number once it is entered, a color\n // once its gesture ends.\n case 'number':\n return (\n <PropertyControl\n {...field}\n name={pref.name}\n onInput={settledOnly}\n steppers={field.accepts === undefined}\n />\n );\n case 'color':\n return <PropertyControl {...field} name={pref.name} onInput={settledOnly} />;\n default:\n return <PropertyControl {...field} name={pref.name} />;\n }\n}\n\nconst settledOnly = (): void => {};\n\n/** One value with its fields hanging off it: each field renders its own\n * control and commits the parent object whole. */\nfunction ObjectLeaf({ ctx }: { ctx: PrefRenderContext }) {\n const pref = ctx.pref as PrefObject;\n const { value, setValue } = ctx;\n const held = typeof value === 'object' && value !== null\n ? (value as Record<string, unknown>)\n : undefined;\n const objectRows = (children: Record<string, PrefLeaf | PrefGroup>): ReactNode[] => {\n const out: ReactNode[] = [];\n for (const [key, child] of Object.entries(children)) {\n if (!isPrefLeaf(child)) {\n const inner = objectRows(child.children);\n if (inner.length === 0) continue;\n out.push(<h4 key={`group:${key}`} className={s.objectGroup}>{child.name}</h4>, ...inner);\n continue;\n }\n out.push(\n <PropertyRow\n key={key}\n label={child.name}\n layout=\"inline\"\n className={s.objectRow}\n >\n <span className={s.rowControl}>\n {renderBuiltin({\n path: `${ctx.path}.${key}`,\n pref: child,\n value: held?.[key],\n setValue: (v) => {\n const base = held ?? pref.fromScalar?.(value) ?? {};\n setValue({ ...base, [key]: v });\n },\n // A field is not pinned on its own — it shares the state of\n // the object leaf it hangs off.\n auto: ctx.auto,\n setAuto: ctx.setAuto,\n }, held)}\n </span>\n </PropertyRow>,\n );\n }\n return out;\n };\n return <div className={s.objectLeaf}>{objectRows(pref.children)}</div>;\n}\n","import { type RefObject } from 'react';\nimport { isPrefLeaf, type PrefGroup, type PrefLeaf } from './schema';\nimport { PrefRow, type WalkCtx } from './PrefsRow';\nimport s from './Prefs.module.css';\n\n/** Props for {@link PrefsPane}. */\nexport interface PrefsPaneProps {\n ctx: WalkCtx;\n /** The open group, or a synthetic one holding the root's loose leaves. */\n group: PrefGroup;\n /** Dotted path of `group`. Empty for the loose-leaf pane. */\n path: string;\n /** The pane's scroll container, for the rail's scroll spy. */\n scrollRef: RefObject<HTMLDivElement | null>;\n className?: string;\n}\n\n/**\n * One rail section's settings: the group's own leaves, then one headed\n * section per nested group.\n *\n * Nothing here draws a panel. The rail is the layout's structure, and a card\n * inside a dialog that already has a border only restates it — the columns\n * layout's sunken panels are what this is the alternative to.\n */\nexport function PrefsPane(props: PrefsPaneProps) {\n const { ctx, group, path, scrollRef, className } = props;\n const leaves = Object.entries(group.children).filter(\n (entry): entry is [string, PrefLeaf] => isPrefLeaf(entry[1]),\n );\n const groups = Object.entries(group.children).filter(\n (entry): entry is [string, PrefGroup] => !isPrefLeaf(entry[1]),\n );\n const childPath = (key: string): string => (path === '' ? key : `${path}.${key}`);\n\n return (\n <div className={[s.pane, className].filter(Boolean).join(' ')} ref={scrollRef}>\n <div className={s.paneHead}>\n <h3 className={s.paneTitle}>{group.name}</h3>\n {group.description !== undefined && (\n <p className={s.paneDesc}>{group.description}</p>\n )}\n </div>\n {leaves.length > 0 && (\n <div className={s.rows}>\n {leaves.map(([key, leaf]) => (\n <PrefRow key={key} ctx={ctx} path={childPath(key)} pref={leaf} />\n ))}\n </div>\n )}\n {groups.map(([key, child]) => (\n <PaneSection\n key={key}\n ctx={ctx}\n group={child}\n path={childPath(key)}\n depth={0}\n />\n ))}\n </div>\n );\n}\n\n/**\n * A nested group inside a pane. Depth 0 sections are the ones the rail links\n * to and carry `data-spy-section`; deeper ones indent and are reached only by\n * scrolling, which is what keeps the rail two levels deep whatever the schema\n * does.\n */\nfunction PaneSection({ ctx, group, path, depth }: {\n ctx: WalkCtx;\n group: PrefGroup;\n path: string;\n depth: number;\n}) {\n const Heading = depth === 0 ? 'h4' : 'h5';\n return (\n <section\n className={depth === 0 ? s.paneSection : s.paneSubsection}\n data-spy-section={depth === 0 ? path : undefined}\n aria-label={group.name}\n >\n <Heading className={depth === 0 ? s.sectionTitle : s.subsectionTitle}>\n {group.name}\n </Heading>\n {group.description !== undefined && (\n <p className={s.paneDesc}>{group.description}</p>\n )}\n <div className={s.rows}>\n {Object.entries(group.children).map(([key, child]) => {\n const p = `${path}.${key}`;\n return isPrefLeaf(child) ? (\n <PrefRow key={key} ctx={ctx} path={p} pref={child} />\n ) : (\n <PaneSection key={key} ctx={ctx} group={child} path={p} depth={depth + 1} />\n );\n })}\n </div>\n </section>\n );\n}\n","import type { ReactNode } from 'react';\nimport { useRovingTabIndex } from '../../useRovingTabIndex';\nimport type { PrefRailItem } from './schema';\nimport s from './Prefs.module.css';\n\n/** Props for {@link PrefsRail}. */\nexport interface PrefsRailProps {\n items: readonly PrefRailItem[];\n /** Path of the open group: depth 0, or depth 1 under `subPages`. */\n section: string;\n /** Path of the depth-1 group in view, from the pane's scroll spy. */\n current: string | null;\n /** A depth-0 entry was chosen: open its pane. */\n onOpen: (path: string) => void;\n /** A depth-1 entry was chosen: scroll the open pane to it, or, under\n * `subPages`, open it. */\n onScrollTo: (path: string) => void;\n /** Accessible name for the rail's landmark. */\n ariaLabel: string;\n /** Rendered above the list — the filter field, when there is one. */\n header?: ReactNode;\n /** Show each entry's match count. Only meaningful while filtering. */\n showCounts?: boolean;\n}\n\n/**\n * The rail beside a `PrefsForm` pane: depth-0 groups, each followed by the\n * depth-1 groups that scroll within it.\n *\n * A list of buttons rather than a tablist, because only half of these entries\n * switch anything — the nested ones scroll the pane the selected entry already\n * opened, and a tab that does not own a panel has no honest role. The open\n * group is `aria-current=\"page\"`; the nested group in view is\n * `aria-current=\"location\"`.\n */\nexport function PrefsRail(props: PrefsRailProps) {\n const { items, section, current, onOpen, onScrollTo, ariaLabel, header, showCounts } = props;\n const activate = (index: number): void => {\n const item = items[index];\n if (!item) return;\n if (item.depth === 0) onOpen(item.path);\n else onScrollTo(item.path);\n };\n const roving = useRovingTabIndex<HTMLDivElement>({\n itemSelector: `.${s.railItem}`,\n tabStopIndex: Math.max(0, items.findIndex((i) => i.path === section)),\n });\n\n return (\n <nav className={s.rail} aria-label={ariaLabel}>\n {header}\n <div className={s.railList} ref={roving.rootRef} onKeyDown={roving.onKeyDown}>\n {items.map((item, index) => {\n const open = item.path === section;\n const inView = item.depth === 1 && item.path === current;\n return (\n <button\n key={item.path === '' ? '\\u0000root' : item.path}\n type=\"button\"\n className={[s.railItem, item.depth === 1 && s.railSub, open && s.railOpen, inView && s.railInView]\n .filter(Boolean)\n .join(' ')}\n aria-current={open ? 'page' : inView ? 'location' : undefined}\n onClick={() => activate(index)}\n >\n <span className={s.railName}>{item.name}</span>\n {showCounts ? <span className={s.railCount}>{item.matches}</span> : null}\n </button>\n );\n })}\n </div>\n </nav>\n );\n}\n","import { useMemo, useRef, useState, type ReactNode } from 'react';\nimport { Input } from '../Input';\nimport { useScrollSpy } from '../../useScrollSpy';\nimport {\n filterPrefSubtree,\n isPrefLeaf,\n prefRailItems,\n visiblePrefSubtree,\n type PrefGroup,\n} from './schema';\nimport { PrefRow, type PrefRenderer, type WalkCtx } from './PrefsRow';\nimport { PrefsPane } from './PrefsPane';\nimport { PrefsRail } from './PrefsRail';\nimport s from './Prefs.module.css';\n\nexport type { PrefRenderer, PrefRenderContext } from './PrefsRow';\n\n/** How a {@link PrefsForm} lays its groups out. */\nexport type PrefsLayout = 'columns' | 'rail';\n\n/** Props for {@link PrefsForm}. */\nexport interface PrefsFormProps {\n /** Root of the schema tree. Core `ToolPrefGroup`s assign structurally. */\n schema: PrefGroup;\n /** Nested value tree (shape mirrors the schema). Sparse is fine —\n * missing leaves fall back to their schema `default`. */\n values?: unknown;\n /** Change callback with the leaf's dotted path. Values apply live;\n * there is no dirty/commit state. */\n onChange: (path: string, value: unknown) => void;\n /**\n * Per-kind renderers for app-defined kinds. Entries also override the\n * built-in kinds when keys collide. A renderer owns the control cell\n * (the label/tooltip row chrome stays with the form, unless the leaf\n * sets `block`); returning `null` collapses the row entirely. Unknown\n * kinds with no renderer show a labeled placeholder instead of\n * crashing.\n */\n renderers?: Record<string, PrefRenderer>;\n /** Reveal `hidden` leaves (dev tooling). Default false. */\n showHidden?: boolean;\n /**\n * `'columns'` (the default) wraps each top-level group into its own panel\n * column. `'rail'` puts a two-level navigation rail beside one group's\n * settings at a time — what a dialog-sized surface wants, since columns\n * overflow sideways once there are more than two.\n */\n layout?: PrefsLayout;\n /** Show a filter field that narrows the form to matching leaves. */\n filterable?: boolean;\n /** Rail layout: path of the open top-level group. Controlled. */\n section?: string;\n /** Rail layout: path of the group open before the reader picks one.\n * Defaults to the first in the schema. */\n defaultSection?: string;\n onSectionChange?: (path: string) => void;\n /**\n * Rail layout: a nested entry opens a page of its own group instead of\n * scrolling the open one to it, and a top-level entry's page holds only its\n * own leaves (or opens its first nested entry when it has none). For a\n * top-level group whose subgroups are long enough that one page of all of\n * them reads as a wall. Default false.\n */\n subPages?: boolean;\n /** Dotted paths whose leaves currently inherit: each still draws its control,\n * dimmed, showing the value in `values` — pass it already resolved. Editing\n * it calls `onChange` as usual, which is the owner's cue to pin it. */\n auto?: ReadonlySet<string>;\n /** Given, a leaf's label toggles whether it inherits: `next` true unpins it,\n * false pins it at the value it shows. Leaves `canInherit` refuses keep a\n * plain label. */\n onAutoChange?: (path: string, next: boolean) => void;\n /** Which leaves can inherit, and so get a label toggle. Default: every leaf,\n * once `onAutoChange` is given. */\n canInherit?: (path: string) => boolean;\n /** Small text after an inherited leaf's label, e.g. `() => 'from Defaults'`.\n * Default: none. */\n inheritHint?: (path: string) => string | undefined;\n className?: string;\n}\n\n/**\n * Schema-driven preferences form. Leaves render as label + control rows;\n * how the groups around them are arranged is `layout`'s to say — columns of\n * panels, or a navigation rail beside one group at a time.\n *\n * Storage-agnostic: pair with `PrefsDialog` for the modal composition, and\n * persist however the app likes via `onChange`.\n */\nexport function PrefsForm(props: PrefsFormProps) {\n const {\n schema,\n values,\n onChange,\n renderers,\n showHidden = false,\n layout = 'columns',\n filterable = false,\n auto,\n onAutoChange,\n canInherit,\n inheritHint,\n className,\n } = props;\n const [query, setQuery] = useState('');\n const root = useMemo(() => {\n const visible = visiblePrefSubtree(schema, showHidden);\n return visible === null ? null : filterPrefSubtree(visible, query);\n }, [schema, showHidden, query]);\n\n const ctx: WalkCtx = { values, onChange, renderers, auto, onAutoChange, canInherit, inheritHint };\n const field = filterable ? (\n <div className={s.filter}>\n <Input\n value={query}\n onChange={setQuery}\n aria-label={`Filter ${schema.name}`}\n placeholder=\"Filter settings\"\n />\n </div>\n ) : null;\n\n if (layout === 'rail') {\n return (\n <RailLayout\n {...props}\n root={root}\n ctx={ctx}\n query={query}\n filterField={field}\n onClearFilter={() => setQuery('')}\n />\n );\n }\n\n return (\n <div className={[s.columnsLayout, className].filter(Boolean).join(' ')}>\n {field}\n {root === null ? (\n <NoMatches query={query} onClear={() => setQuery('')} />\n ) : (\n <div className={s.columns}>\n {Object.entries(root.children).map(([key, child]) => (\n <div key={key} className={s.column}>\n {isPrefLeaf(child) ? (\n // Top-level leaves are unusual but legal — give each its own\n // column for symmetry with grouped siblings.\n <PrefRow ctx={ctx} path={key} pref={child} />\n ) : (\n <GroupBody ctx={ctx} group={child} path={key} depth={0} />\n )}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n\n/** The rail layout's own state: which group is open, and where the pane is\n * scrolled to within it. Split out so the columns layout runs none of it. */\nfunction RailLayout(props: PrefsFormProps & {\n root: PrefGroup | null;\n ctx: WalkCtx;\n query: string;\n filterField: ReactNode;\n onClearFilter: () => void;\n}) {\n const { schema, root, ctx, query, filterField, onClearFilter, className } = props;\n const items = useMemo(() => (root === null ? [] : prefRailItems(root)), [root]);\n const [uncontrolled, setUncontrolled] = useState(\n () => props.defaultSection ?? '',\n );\n const subPages = props.subPages === true;\n const requested = props.section ?? uncontrolled;\n // A filter can take the open group out of the rail entirely, and a section\n // the schema never had can arrive from a consumer's stale state. Either way\n // the first surviving entry is what the reader should be looking at.\n let open = items.some((i) => i.path === requested && (i.depth === 0 || subPages))\n ? requested\n : (items.find((i) => i.depth === 0)?.path ?? '');\n if (subPages && root !== null && !hasLeaves(paneGroup(root, open, schema.name))) {\n open = items.find((i) => i.depth === 1 && i.section === open)?.path ?? open;\n }\n\n const scrollRef = useRef<HTMLDivElement | null>(null);\n const sectionIds = useMemo(\n () =>\n subPages\n ? []\n : items.filter((i) => i.depth === 1 && i.section === open).map((i) => i.path),\n [items, open, subPages],\n );\n const spy = useScrollSpy({ rootRef: scrollRef, ids: sectionIds });\n\n const setOpen = (path: string): void => {\n if (props.section === undefined) setUncontrolled(path);\n props.onSectionChange?.(path);\n // Optional-called: jsdom's elements have no `scrollTo`, and neither does\n // a pane that is not the scrolling box in some consumer's layout.\n scrollRef.current?.scrollTo?.({ top: 0 });\n };\n\n const whole = root === null ? null : paneGroup(root, open, schema.name);\n const opensTop = items.some((i) => i.path === open && i.depth === 0);\n const group = subPages && opensTop && whole !== null ? leavesOf(whole) : whole;\n\n return (\n <div className={[s.railLayout, className].filter(Boolean).join(' ')}>\n <PrefsRail\n items={items}\n section={open}\n current={subPages ? null : spy.active}\n onOpen={setOpen}\n onScrollTo={subPages ? setOpen : spy.scrollTo}\n ariaLabel={schema.name}\n header={filterField}\n showCounts={query.trim() !== ''}\n />\n {group === null ? (\n <div className={s.pane}>\n <NoMatches query={query} onClear={onClearFilter} />\n </div>\n ) : (\n <PrefsPane ctx={ctx} group={group} path={open} scrollRef={scrollRef} />\n )}\n </div>\n );\n}\n\n/**\n * The group a rail path opens. The empty path is the root's loose leaves,\n * which belong to no group of their own and are handed back as one named for\n * the schema — the rail lists them under the same name.\n */\nfunction paneGroup(root: PrefGroup, path: string, rootName: string): PrefGroup | null {\n if (path === '') {\n const children = Object.fromEntries(\n Object.entries(root.children).filter(([, child]) => isPrefLeaf(child)),\n );\n return Object.keys(children).length === 0\n ? null\n : { ...root, name: rootName, children };\n }\n let node: PrefGroup | undefined;\n let cursor = root;\n for (const seg of path.split('.')) {\n const next = cursor.children[seg];\n if (next === undefined || isPrefLeaf(next)) return null;\n node = next;\n cursor = next;\n }\n return node ?? null;\n}\n\n/** Whether a group holds any leaf directly, not counting its subgroups. */\nfunction hasLeaves(group: PrefGroup | null): boolean {\n return group !== null && Object.values(group.children).some(isPrefLeaf);\n}\n\n/** A group cut down to its direct leaves, for a page its subgroups each get their own of. */\nfunction leavesOf(group: PrefGroup): PrefGroup {\n return {\n ...group,\n children: Object.fromEntries(\n Object.entries(group.children).filter(([, child]) => isPrefLeaf(child)),\n ),\n };\n}\n\n/** What a filter matching nothing leaves behind. */\nfunction NoMatches({ query, onClear }: { query: string; onClear: () => void }) {\n return (\n <div className={s.noMatches}>\n <p>No settings match “{query.trim()}”.</p>\n <button type=\"button\" className={s.clearFilter} onClick={onClear}>\n Clear filter\n </button>\n </div>\n );\n}\n\nfunction GroupBody({ ctx, group, path, depth }: {\n ctx: WalkCtx;\n group: PrefGroup;\n path: string;\n depth: number;\n}) {\n return (\n <div className={depth === 0 ? s.panel : s.subpanel}>\n <div className={s.groupHeader}>\n <h3 className={s.groupTitle}>{group.name}</h3>\n {group.description !== undefined && (\n <p className={s.groupDesc}>{group.description}</p>\n )}\n </div>\n <div className={s.rows}>\n {Object.entries(group.children).map(([key, child]) => {\n const childPath = `${path}.${key}`;\n return isPrefLeaf(child) ? (\n <PrefRow key={key} ctx={ctx} path={childPath} pref={child} />\n ) : (\n <GroupBody key={key} ctx={ctx} group={child} path={childPath} depth={depth + 1} />\n );\n })}\n </div>\n </div>\n );\n}\n\n","import type { ReactNode } from 'react';\nimport { Dialog } from '../Dialog';\nimport { PrefsForm, type PrefsFormProps } from './PrefsForm';\nimport s from './Prefs.module.css';\n\n/**\n * Props for {@link PrefsDialog} — everything {@link PrefsForm} takes, plus\n * the dialog's own open state and chrome.\n */\nexport interface PrefsDialogProps extends PrefsFormProps {\n isOpen: boolean;\n onOpenChange: (open: boolean) => void;\n /** Dialog heading. Defaults to the schema root's `name`. */\n title?: ReactNode;\n /** Extra chrome rendered at the end of the title row (e.g. a dev-mode\n * \"Show hidden\" switch). An action the reader acts on when they are done\n * — resetting, importing — belongs in `footer` instead, where a dialog's\n * actions live. */\n headerExtra?: ReactNode;\n /** Footer slot, passed through to `Dialog` — typically a reset or done\n * action. */\n footer?: ReactNode;\n /** Class applied to the dialog's modal box. */\n dialogClassName?: string;\n}\n\n/**\n * The kit's preferences dialog: `Dialog` + `PrefsForm`. Changes apply\n * live through `onChange` — there is no OK/Cancel staging. For custom\n * placement (sidebar, popover, inline page), compose `PrefsForm`\n * directly; this wrapper is intentionally thin.\n *\n * `layout=\"rail\"` is what a dialog usually wants: the default columns wrap\n * sideways past two groups, and this box is 900px at its widest.\n */\nexport function PrefsDialog(props: PrefsDialogProps) {\n const { isOpen, onOpenChange, title, headerExtra, footer, dialogClassName, ...form } = props;\n const rail = form.layout === 'rail';\n return (\n <Dialog\n isOpen={isOpen}\n onOpenChange={onOpenChange}\n aria-label={typeof title === 'string' ? title : form.schema.name}\n className={dialogClassName}\n footer={footer}\n bodyClassName={rail ? s.railBody : undefined}\n title={\n headerExtra !== undefined ? (\n <span className={s.titleRow}>\n <span>{title ?? form.schema.name}</span>\n {headerExtra}\n </span>\n ) : (\n title ?? form.schema.name\n )\n }\n >\n <PrefsForm {...form} />\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgBgB,EACd,GACA,IAAQ,GACO;CACf,IAAIC,IAAwB;CAC5B,KAAK,IAAM,EAAE,OAAI,YAASC,GAAS;EACjC,IAAIC,IAAMC,IAAQ,GAAG;EACrB,IAASC;CACX;CACA,OAAOJ;AACT;AA4BA,IAAMK,IAAY;AASlB,SAAgBC,EAAa,GAAyC;CACpE,IAAM,EAAE,YAAS,QAAK,aAAUC,GAC1B,CAACP,GAAQQ,KAAaC,EAAwB,IAAI,GAGlDC,IAAUC,EAAsB,IAAI,GACpCC,IAAWD,EAA6C,IAAI,GAC5DE,IAAaF,EAA4B,IAAI,GAC7CG,IAAMC,EAAI,KAAK,IAAQ,GAEvBC,IAAUC,QAAwB;EACtC,IAAMC,IAAOC,EAAQ;EACrB,IAAI,CAACD,GAAM;EACX,IAAIR,EAAQ,YAAY,MAAM;GAC5B,EAAUA,EAAQ,OAAO;GACzB;EACF;EACA,IAAMU,IAAUF,EAAK,sBAAsB,CAAC,CAAC,KACvCjB,IAA2B,CAAC;EAClC,KAAK,IAAMG,KAAMW,GAAK;GACpB,IAAMM,IAAKH,EAAK,cAA2B,sB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,cAAY,OAAOiI,KAAU,WAAWA,IAAQF,EAAK,OAAO;EAC5D,WAAWG;EACH;EACR,eAAeF,IAAOjI,EAAE,WAAW,KAAA;EACnC,OACEoI,MAAgB,KAAA,IAMdF,KAASF,EAAK,OAAO,OALrB,kBAAC,QAAD;GAAM,WAAWhI,EAAE;GAAnB,UAAA,CACE,kBAAC,QAAD,EAAA,UAAOkI,KAASF,EAAK,OAAO,KAAW,CAAA,GACtCI,CACG;EAEN,CAAA;EAIJ,UAAA,kBAACpC,GAAD,EAAW,GAAIgC,EAAO,CAAA;CAChB,CAAA;AAEZ"}
@@ -4,7 +4,7 @@ import { t as n } from "./Button-XB-T75YL.js";
4
4
  import { t as r } from "./Disclosure-Ch2KxYuB.js";
5
5
  import { n as i } from "./CurveEditor-0EE00D6s.js";
6
6
  import { t as a } from "./Dialog-DKfsk5VN.js";
7
- import { c as o, d as s, o as c, u as l } from "./PropertyField-BbNqK8xr.js";
7
+ import { c as o, d as s, o as c, u as l } from "./PropertyField-PMrqBA0n.js";
8
8
  import { jsx as u, jsxs as d } from "react/jsx-runtime";
9
9
  import { useCallback as f, useId as p, useMemo as m, useState as h } from "react";
10
10
  var g = {
@@ -285,4 +285,4 @@ function x({ title: e, children: n, className: r, density: i, align: a, stance:
285
285
  //#endregion
286
286
  export { _ as i, b as n, v as r, x as t };
287
287
 
288
- //# sourceMappingURL=Properties-DseN56WI.js.map
288
+ //# sourceMappingURL=Properties-BoG2MMHR.js.map