@mcurcio/patchbay 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -2
- package/dist/base.css +22 -0
- package/dist/composites.js +0 -0
- package/dist/graph.js +0 -0
- package/dist/hooks.js +71 -0
- package/dist/hooks.js.map +1 -0
- package/dist/primitives.css +1 -0
- package/dist/primitives.js +643 -0
- package/dist/primitives.js.map +1 -0
- package/dist/shell.js +0 -0
- package/dist/tokens.css +221 -0
- package/dist/types/composites/index.d.ts +1 -0
- package/dist/types/graph/index.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/use-persistent-state/index.d.ts +2 -0
- package/dist/types/hooks/use-persistent-state/usePersistentState.d.ts +27 -0
- package/dist/types/hooks/use-theme/index.d.ts +2 -0
- package/dist/types/hooks/use-theme/useTheme.d.ts +31 -0
- package/dist/types/primitives/badge/Badge.d.ts +16 -0
- package/dist/types/primitives/badge/index.d.ts +2 -0
- package/dist/types/primitives/button/Button.d.ts +13 -0
- package/dist/types/primitives/button/index.d.ts +2 -0
- package/dist/types/primitives/checkbox/Checkbox.d.ts +9 -0
- package/dist/types/primitives/checkbox/index.d.ts +2 -0
- package/dist/types/primitives/dialog/CloseGlyph.d.ts +1 -0
- package/dist/types/primitives/dialog/Dialog.d.ts +18 -0
- package/dist/types/primitives/dialog/index.d.ts +2 -0
- package/dist/types/primitives/field/Field.d.ts +22 -0
- package/dist/types/primitives/field/index.d.ts +2 -0
- package/dist/types/primitives/icon-button/IconButton.d.ts +10 -0
- package/dist/types/primitives/icon-button/index.d.ts +2 -0
- package/dist/types/primitives/index.d.ts +19 -0
- package/dist/types/primitives/key-value/KeyValue.d.ts +24 -0
- package/dist/types/primitives/key-value/index.d.ts +2 -0
- package/dist/types/primitives/panel/Panel.d.ts +13 -0
- package/dist/types/primitives/panel/index.d.ts +2 -0
- package/dist/types/primitives/panel/scroll-focus.d.ts +5 -0
- package/dist/types/primitives/pill/Pill.d.ts +20 -0
- package/dist/types/primitives/pill/index.d.ts +2 -0
- package/dist/types/primitives/section-title/SectionTitle.d.ts +14 -0
- package/dist/types/primitives/section-title/index.d.ts +2 -0
- package/dist/types/primitives/select/Select.d.ts +8 -0
- package/dist/types/primitives/select/index.d.ts +2 -0
- package/dist/types/primitives/sheet/Sheet.d.ts +23 -0
- package/dist/types/primitives/sheet/index.d.ts +2 -0
- package/dist/types/primitives/spinner/Spinner.d.ts +7 -0
- package/dist/types/primitives/spinner/index.d.ts +2 -0
- package/dist/types/primitives/splitter/Splitter.d.ts +25 -0
- package/dist/types/primitives/splitter/index.d.ts +2 -0
- package/dist/types/primitives/splitter/splitter-math.d.ts +19 -0
- package/dist/types/primitives/text-input/TextInput.d.ts +8 -0
- package/dist/types/primitives/text-input/index.d.ts +2 -0
- package/dist/types/primitives/theme-switch/ThemeSwitch.d.ts +28 -0
- package/dist/types/primitives/theme-switch/index.d.ts +2 -0
- package/dist/types/primitives/tool-group/ToolGroup.d.ts +5 -0
- package/dist/types/primitives/tool-group/index.d.ts +2 -0
- package/dist/types/primitives/toolbar/Toolbar.d.ts +11 -0
- package/dist/types/primitives/toolbar/index.d.ts +2 -0
- package/dist/types/primitives/toolbar/roving.d.ts +14 -0
- package/dist/types/primitives/warn-mark/WarnMark.d.ts +11 -0
- package/dist/types/primitives/warn-mark/index.d.ts +2 -0
- package/dist/types/shell/index.d.ts +1 -0
- package/package.json +121 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","names":["_Fragment","Badge","className","tone","Spinner","rest","classes","label","Button","click","busy","event","onClick","size","assign","ref","value","Checkbox","own","useRef","setRef","useCallback","node","indeterminate","box","IconButton","title","CloseGlyph","focusable","tabbable","root","element","topmost","open","OpenDialog","boxRef","bodyRef","titleId","useId","onCloseRef","onClose","useEffect","before","body","keepFocus","controls","first","last","active","closeLabel","actions","Dialog","createPortal","present","Field","base","control","children","isValidElement","controlId","hintId","hint","errorId","error","describedBy","id","wired","cloneElement","layout","KeyValue","rows","row","index","overflows","useScrollFocus","settle","sizes","observeChildren","child","content","Panel","Heading","level","header","Pill","pulse","detail","SectionTitle","Select","font","OpenSheet","sheetRef","cameFrom","sheet","back","onFocus","from","onKeyDown","style","width","side","Sheet","clamp","max","bounds","dragged","start","sign","travel","growKey","orientation","edge","opposite","keyed","key","grow","step","Splitter","drag","along","down","onPointerDown","target","\"dragging\"","move","started","next","onChange","end","onPointerCancel","onPointerUp","min","TextInput","defaultThemeSwitchLabels","order","following","choice","themeSwitchTitle","labels","ThemeSwitch","words","itemSelector","items","toolbar","item","setTabStop","stop","current","all","moved","count","forth","rtl","editsText","Toolbar","watch","focus","ToolGroup","WarnMark","Fragment"],"sources":["../src/primitives/badge/Badge.tsx","../src/primitives/spinner/Spinner.tsx","../src/primitives/button/Button.tsx","../src/primitives/checkbox/Checkbox.tsx","../src/primitives/icon-button/IconButton.tsx","../src/primitives/dialog/CloseGlyph.tsx","../src/primitives/dialog/Dialog.tsx","../src/primitives/field/Field.tsx","../src/primitives/key-value/KeyValue.tsx","../src/primitives/panel/scroll-focus.ts","../src/primitives/panel/Panel.tsx","../src/primitives/pill/Pill.tsx","../src/primitives/section-title/SectionTitle.tsx","../src/primitives/select/Select.tsx","../src/primitives/sheet/Sheet.tsx","../src/primitives/splitter/splitter-math.ts","../src/primitives/splitter/Splitter.tsx","../src/primitives/text-input/TextInput.tsx","../src/primitives/theme-switch/ThemeSwitch.tsx","../src/primitives/toolbar/roving.ts","../src/primitives/toolbar/Toolbar.tsx","../src/primitives/tool-group/ToolGroup.tsx","../src/primitives/warn-mark/WarnMark.tsx"],"sourcesContent":["// A badge: a short word or count in a rounded chip, tinted by its tone (a count of retries, a \"not ready\"). A tone it\n// does not know is drawn neutrally.\nimport type { ReactNode } from \"react\";\nimport \"./Badge.css\";\n\n/** The tones a badge draws; any other string is drawn neutrally. */\nexport type BadgeTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\nexport type BadgeProps = {\n /** The badge's tone: its text and border colour, and for warn and err a soft surface. */\n tone: BadgeTone;\n /** What the badge says: a word, a count, a WarnMark beside them. */\n children: ReactNode;\n /** Shown on hover: what the badge means. */\n title?: string;\n /** A class added to the badge. */\n className?: string;\n};\n\n/** Draws a short word or count in a chip of its tone. */\nexport function Badge({ tone, children, title, className }: BadgeProps) {\n return (\n <span className={className === undefined ? \"pb-badge\" : `pb-badge ${className}`} data-tone={tone} title={title}>\n {children}\n </span>\n );\n}\n","// The busy mark: an open ring in the current text colour that turns once per --pb-motion-spin, and under reduced\n// motion stands still (the open ring is still the mark). Without a label it is decoration, hidden from screen\n// readers, as inside a busy Button, whose own words and aria-busy say what is happening. With a label it is a status\n// that screen readers announce.\nimport type { ComponentPropsWithRef } from \"react\";\nimport \"./Spinner.css\";\n\nexport type SpinnerProps = Omit<ComponentPropsWithRef<\"span\">, \"children\"> & {\n /** What is being waited for, read by screen readers; without it the spinner is hidden from them. */\n label?: string;\n};\n\nexport function Spinner({ label, className, ...rest }: SpinnerProps) {\n const classes = className === undefined ? \"pb-spinner\" : `pb-spinner ${className}`;\n if (label === undefined || label === \"\") {\n return <span {...rest} className={classes} aria-hidden=\"true\" />;\n }\n return (\n <span {...rest} className={`${classes} pb-spinner-labelled`} role=\"status\">\n <span className=\"pb-spinner-ring\" aria-hidden=\"true\" />\n <span className=\"pb-spinner-label\">{label}</span>\n </span>\n );\n}\n","// A push button in the library's look. Its tone (neutral, primary, danger, or any other word, drawn neutral) and size\n// are data attributes its stylesheet keys on. While busy it shows a Spinner over its words, which keep their place so\n// the button keeps its width, says aria-busy, and ignores presses (it stays focusable, unlike a disabled button, so\n// focus is not lost while a request is on its way).\nimport type { ComponentPropsWithRef, MouseEvent } from \"react\";\nimport { Spinner } from \"../spinner\";\nimport \"./Button.css\";\n\n/** What the button does, by colour: neutral (the default), primary (the one main action), danger; others draw neutral. */\nexport type ButtonTone = \"neutral\" | \"primary\" | \"danger\" | (string & {});\n\n/** md (the default) or sm, the compact one for dense rows; others draw as md. On touch both are at least 36 px tall. */\nexport type ButtonSize = \"md\" | \"sm\" | (string & {});\n\nexport type ButtonProps = ComponentPropsWithRef<\"button\"> & {\n tone?: ButtonTone;\n size?: ButtonSize;\n /** A request is on its way: a spinner over the words, aria-busy, and presses ignored. */\n busy?: boolean;\n};\n\nexport function Button({\n tone = \"neutral\",\n size = \"md\",\n busy = false,\n type = \"button\",\n className,\n children,\n onClick,\n ...rest\n}: ButtonProps) {\n function click(event: MouseEvent<HTMLButtonElement>) {\n if (busy) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n }\n return (\n <button\n {...rest}\n // A submit or reset button is asked for by name; a bare button inside a form never submits it.\n type={type}\n className={className === undefined ? \"pb-button\" : `pb-button ${className}`}\n data-tone={tone}\n data-size={size}\n aria-busy={busy || undefined}\n aria-disabled={busy || rest[\"aria-disabled\"] || undefined}\n onClick={click}\n >\n <span className=\"pb-button-content\">{children}</span>\n {busy && <Spinner className=\"pb-button-spinner\" />}\n </button>\n );\n}\n","// A tick box: a native checkbox (every native prop passes through, ref included, and id and aria props reach the\n// input, so Field can wire it), ticked in the accent. With a label it is wrapped in its own label, so a press on the\n// words ticks it too, and the row is a target a finger can find. Indeterminate (some of a group ticked) is a prop,\n// since HTML has it only as a DOM property.\nimport { useCallback, useLayoutEffect, useRef, type ComponentPropsWithRef, type ReactNode, type Ref } from \"react\";\nimport \"./Checkbox.css\";\n\nexport type CheckboxProps = Omit<ComponentPropsWithRef<\"input\">, \"type\"> & {\n /** The words beside the box, which tick it too; without them, name the box by a Field or aria-label. */\n label?: ReactNode;\n /** Neither ticked nor not: drawn as a dash and read as \"mixed\". */\n indeterminate?: boolean;\n};\n\nfunction assign<T>(ref: Ref<T> | undefined, value: T | null) {\n if (typeof ref === \"function\") ref(value);\n else if (ref !== null && ref !== undefined) ref.current = value;\n}\n\nexport function Checkbox({ label, indeterminate = false, className, ref, ...rest }: CheckboxProps) {\n const own = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n own.current = node;\n assign(ref, node);\n },\n [ref],\n );\n useLayoutEffect(() => {\n if (own.current !== null) own.current.indeterminate = indeterminate;\n }, [indeterminate]);\n\n const box = (\n <input\n {...rest}\n ref={setRef}\n type=\"checkbox\"\n className={label === undefined && className !== undefined ? `pb-checkbox ${className}` : \"pb-checkbox\"}\n />\n );\n if (label === undefined) return box;\n return (\n <label\n className={className === undefined ? \"pb-checkbox-row\" : `pb-checkbox-row ${className}`}\n data-disabled={rest.disabled === true || undefined}\n >\n {box}\n <span className=\"pb-checkbox-label\">{label}</span>\n </label>\n );\n}\n","// A square button that shows a glyph and is named by its label: the label is its accessible name and, unless a title\n// is given, its tooltip, and the glyph is hidden from screen readers. Tone, size and busy are Button's.\nimport type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"../button\";\nimport \"./IconButton.css\";\n\nexport type IconButtonProps = Omit<ButtonProps, \"children\" | \"aria-label\"> & {\n /** The button's name for screen readers, and its tooltip unless title says otherwise. */\n label: string;\n /** The glyph: an icon or a character, hidden from screen readers. */\n children: ReactNode;\n};\n\nexport function IconButton({ label, title, className, children, ...rest }: IconButtonProps) {\n return (\n <Button\n {...rest}\n className={className === undefined ? \"pb-icon-button\" : `pb-icon-button ${className}`}\n aria-label={label}\n title={title ?? label}\n >\n <span className=\"pb-icon-button-glyph\" aria-hidden=\"true\">\n {children}\n </span>\n </Button>\n );\n}\n","// The cross on Dialog's and Sheet's close buttons, in the current text colour. Internal: not exported by the layer.\nexport function CloseGlyph() {\n return (\n <svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" aria-hidden=\"true\">\n <path d=\"M3 3l10 10M13 3L3 13\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\" />\n </svg>\n );\n}\n","// A modal dialog: drawn over the page (in a portal on <body>) above a scrim, with a title, a close button, the app's\n// content and an optional row of actions. While it is open, Tab and Shift+Tab stay inside it and focus that wanders\n// out is brought back; Escape, the close button and a press on the scrim ask the app to close it (onClose), and the\n// app closes it by setting open to false. Opening focuses the content's first control (or one the content focused\n// itself, as with autoFocus), else the dialog; the body is a tab stop of its own, so a long one scrolls from the\n// keyboard; closing gives focus back to what had it before. Only the topmost of\n// several open dialogs keeps the focus.\nimport { type ReactNode, type KeyboardEvent, useEffect, useId, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { IconButton } from \"../icon-button\";\nimport { CloseGlyph } from \"./CloseGlyph\";\nimport \"./Dialog.css\";\n\nexport type DialogProps = {\n /** Whether the dialog is shown; the app holds it. */\n open: boolean;\n /** Asked for on Escape, the close button and a press on the scrim. */\n onClose: () => void;\n /** The dialog's title, which also names it for screen readers. */\n title: ReactNode;\n children: ReactNode;\n /** A row at the foot of the dialog, for its buttons. */\n actions?: ReactNode;\n /** The close button's name: \"Close\". */\n closeLabel?: string;\n /** A class added to the dialog's box. */\n className?: string;\n};\n\nconst focusable = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled]):not([type='hidden'])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"[tabindex]:not([tabindex='-1'])\",\n \"[contenteditable='true']\",\n].join(\",\");\n\n/** The controls inside `root` that Tab reaches, in order. */\nfunction tabbable(root: HTMLElement): HTMLElement[] {\n return [...root.querySelectorAll<HTMLElement>(focusable)].filter(\n (element) => element.closest(\"[hidden], [inert]\") === null && element.tabIndex >= 0,\n );\n}\n\n/** Whether `box` is the topmost open dialog: each opens in a portal appended to <body>, so the last one is on top. */\nfunction topmost(box: HTMLElement): boolean {\n const open = box.ownerDocument.querySelectorAll(\".pb-dialog\");\n return open[open.length - 1] === box;\n}\n\nfunction OpenDialog({ onClose, title, children, actions, closeLabel = \"Close\", className }: Omit<DialogProps, \"open\">) {\n const boxRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const titleId = useId();\n const onCloseRef = useRef(onClose);\n useEffect(() => {\n onCloseRef.current = onClose;\n }, [onClose]);\n\n useEffect(() => {\n const box = boxRef.current;\n if (box === null) return undefined;\n const before = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n if (!box.contains(document.activeElement)) {\n const body = bodyRef.current;\n (body === null ? undefined : tabbable(body)[0])?.focus();\n if (!box.contains(document.activeElement)) box.focus();\n }\n const keepFocus = (event: FocusEvent) => {\n if (!topmost(box)) return;\n if (event.target instanceof Node && box.contains(event.target)) return;\n (tabbable(box)[0] ?? box).focus();\n };\n document.addEventListener(\"focusin\", keepFocus);\n return () => {\n document.removeEventListener(\"focusin\", keepFocus);\n if (before?.isConnected === true) before.focus();\n };\n }, []);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.defaultPrevented) return;\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n onCloseRef.current();\n return;\n }\n if (event.key !== \"Tab\" || boxRef.current === null) return;\n const controls = tabbable(boxRef.current);\n const first = controls[0];\n const last = controls[controls.length - 1];\n if (first === undefined || last === undefined) {\n event.preventDefault();\n return;\n }\n const active = document.activeElement;\n if (event.shiftKey && (active === first || active === boxRef.current)) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n return (\n <div\n className=\"pb-dialog-scrim\"\n onMouseDown={(event) => {\n // Only a press that starts on the scrim itself: a drag out of a text field does not close.\n if (event.target === event.currentTarget) onCloseRef.current();\n }}\n >\n <div\n ref={boxRef}\n className={className === undefined ? \"pb-dialog\" : `pb-dialog ${className}`}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n tabIndex={-1}\n onKeyDown={onKeyDown}\n >\n <div className=\"pb-dialog-head\">\n <h2 className=\"pb-dialog-title\" id={titleId}>\n {title}\n </h2>\n <IconButton\n className=\"pb-dialog-close\"\n label={closeLabel}\n onClick={() => {\n onCloseRef.current();\n }}\n >\n <CloseGlyph />\n </IconButton>\n </div>\n {/* Focusable, so a body that scrolls can be scrolled from the keyboard. */}\n <div ref={bodyRef} className=\"pb-dialog-body\" tabIndex={0}>\n {children}\n </div>\n {actions === undefined ? null : <div className=\"pb-dialog-actions\">{actions}</div>}\n </div>\n </div>\n );\n}\n\nexport function Dialog({ open, ...rest }: DialogProps) {\n if (!open) return null;\n return createPortal(<OpenDialog {...rest} />, document.body);\n}\n","// A labelled form control: the label, the control (its one child), a hint under it and an error under that. It wires\n// the control to them itself: the control gets an id the label points at (its own id if it has one), aria-describedby\n// naming the hint and the error (after any ids it already has), and aria-invalid while there is an error. The control\n// is any element that passes those props on to its native element, as TextInput, Select and Checkbox do.\nimport {\n cloneElement,\n isValidElement,\n useId,\n type AriaAttributes,\n type ComponentPropsWithRef,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport \"./Field.css\";\n\n/** stacked (the default: the label above the control) or inline (the label in a column to its left); others stack. */\nexport type FieldLayout = \"stacked\" | \"inline\" | (string & {});\n\n/** The props Field sets on its control. */\nexport type FieldControlProps = {\n id?: string;\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: AriaAttributes[\"aria-invalid\"];\n};\n\nexport type FieldProps = Omit<ComponentPropsWithRef<\"div\">, \"children\"> & {\n /** What the control is, as its accessible name. */\n label: ReactNode;\n /** Why the value is refused; while there is one the control is marked invalid. Empty means none. */\n error?: ReactNode;\n /** A line of help under the control. */\n hint?: ReactNode;\n layout?: FieldLayout;\n /** The control: one element that passes id and aria props on to its native element. */\n children: ReactElement<FieldControlProps>;\n};\n\nfunction present(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n\nexport function Field({ label, error, hint, layout = \"stacked\", className, children, ...rest }: FieldProps) {\n const base = useId();\n const control: unknown = children;\n const own = isValidElement<FieldControlProps>(control) ? control.props : undefined;\n const controlId = own?.id ?? `${base}-control`;\n const hintId = present(hint) ? `${base}-hint` : undefined;\n const errorId = present(error) ? `${base}-error` : undefined;\n const describedBy = [own?.[\"aria-describedby\"], hintId, errorId].filter((id) => id !== undefined && id !== \"\");\n const wired =\n own === undefined\n ? children\n : cloneElement(children, {\n id: controlId,\n \"aria-describedby\": describedBy.length > 0 ? describedBy.join(\" \") : undefined,\n \"aria-invalid\": errorId !== undefined ? true : own[\"aria-invalid\"],\n });\n return (\n <div\n {...rest}\n className={className === undefined ? \"pb-field\" : `pb-field ${className}`}\n data-layout={layout}\n data-invalid={errorId !== undefined || undefined}\n >\n <label className=\"pb-field-label\" htmlFor={controlId}>\n {label}\n </label>\n <div className=\"pb-field-control\">\n {wired}\n {hintId !== undefined && (\n <div className=\"pb-field-hint\" id={hintId}>\n {hint}\n </div>\n )}\n {errorId !== undefined && (\n <div className=\"pb-field-error\" id={errorId}>\n {error}\n </div>\n )}\n </div>\n </div>\n );\n}\n","// Facts as a two-column list of keys and values (a status summary, an inspector's details), drawn as a <dl> so each key\n// names its value for screen readers. A row's tone colours its value; a tone it does not know leaves it plain.\nimport type { ReactNode } from \"react\";\nimport \"./KeyValue.css\";\n\n/** The tones a value draws in; any other string leaves it plain. */\nexport type KeyValueTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\nexport type KeyValueRow = {\n /** The fact's name. */\n key: string;\n /** Its value. */\n value: ReactNode;\n /** Colours the value: a fact that is wrong or worth a look. */\n tone?: KeyValueTone;\n /** Shown on hover over the key: what the fact means. */\n title?: string;\n};\n\nexport type KeyValueProps = {\n /** The facts, in order. */\n rows: readonly KeyValueRow[];\n /** Names the list for screen readers when no heading does. */\n label?: string;\n /** A class added to the list. */\n className?: string;\n};\n\n/** Draws facts as keys and their values, side by side. */\nexport function KeyValue({ rows, label, className }: KeyValueProps) {\n return (\n <dl className={className === undefined ? \"pb-key-value\" : `pb-key-value ${className}`} aria-label={label}>\n {rows.map((row, index) => (\n // Rows have no identity beyond their place; two may share a key.\n <div key={index} className=\"pb-key-value-row\" data-tone={row.tone}>\n <dt title={row.title}>{row.key}</dt>\n <dd>{row.value}</dd>\n </div>\n ))}\n </dl>\n );\n}\n","// Keeps a scrolling box reachable by keyboard: while its content overflows it is a tab stop (so the arrow keys and Page\n// Up and Down scroll it), and while everything fits it is not, so a short panel adds no empty stop to the tab order.\nimport { useEffect, type RefObject } from \"react\";\n\n/** Whether `box`'s content is taller or wider than the box. */\nexport function overflows(box: HTMLElement): boolean {\n return box.scrollHeight > box.clientHeight || box.scrollWidth > box.clientWidth;\n}\n\n/** Makes `ref`'s box focusable exactly while it overflows, watching its size and its content. */\nexport function useScrollFocus(ref: RefObject<HTMLElement | null>): void {\n useEffect(() => {\n const box = ref.current;\n if (box === null) return;\n const settle = () => {\n if (overflows(box)) box.tabIndex = 0;\n else box.removeAttribute(\"tabindex\");\n };\n settle();\n // jsdom has no ResizeObserver; the content watch still runs there.\n const sizes = typeof ResizeObserver === \"function\" ? new ResizeObserver(settle) : null;\n const observeChildren = () => {\n if (sizes === null) return;\n sizes.disconnect();\n sizes.observe(box);\n for (const child of box.children) sizes.observe(child);\n };\n observeChildren();\n const content = new MutationObserver(() => {\n observeChildren();\n settle();\n });\n content.observe(box, { childList: true, subtree: true, characterData: true });\n return () => {\n sizes?.disconnect();\n content.disconnect();\n };\n }, [ref]);\n}\n","// A panel: a region of the page with an optional header (its title, and actions at the far end) over a body that\n// scrolls on its own, as an inspector or a side panel. It draws no outer border: the layout that places it (a docked\n// side, a sheet, a card) draws its edges. Its title names the region for screen readers. While its body overflows, the\n// body is a tab stop, so the keyboard can scroll it.\nimport { useId, useRef, type ComponentPropsWithRef, type ReactNode } from \"react\";\nimport { useScrollFocus } from \"./scroll-focus\";\nimport \"./Panel.css\";\n\nexport type PanelProps = Omit<ComponentPropsWithRef<\"section\">, \"title\"> & {\n /** The panel's heading; it also names the region. Without one, name it with aria-label. */\n title?: ReactNode;\n /** Slot at the header's far end: buttons, a count, a close button. */\n actions?: ReactNode;\n /** The title's heading level, h1 to h6; h2 by default. */\n level?: 1 | 2 | 3 | 4 | 5 | 6;\n children?: ReactNode;\n};\n\n/** Draws a titled region with its actions and a body that scrolls. */\nexport function Panel({ title, actions, level = 2, className, children, ...rest }: PanelProps) {\n const titleId = useId();\n const body = useRef<HTMLDivElement>(null);\n useScrollFocus(body);\n const Heading = `h${String(level)}` as \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n const header = title !== undefined || actions !== undefined;\n return (\n <section\n {...rest}\n aria-labelledby={\n rest[\"aria-labelledby\"] ?? (title !== undefined && rest[\"aria-label\"] === undefined ? titleId : undefined)\n }\n className={className === undefined ? \"pb-panel\" : `pb-panel ${className}`}\n >\n {header && (\n <header className=\"pb-panel-header\">\n {title !== undefined && (\n <Heading id={titleId} className=\"pb-panel-title\">\n {title}\n </Heading>\n )}\n {actions !== undefined && <div className=\"pb-panel-actions\">{actions}</div>}\n </header>\n )}\n <div ref={body} className=\"pb-panel-body\">\n {children}\n </div>\n </section>\n );\n}\n","// A state pill: a dot in the state's tone and the word beside it, so the state never rests on colour alone. A tone it\n// does not know is drawn neutrally, by its own word.\nimport type { ReactNode } from \"react\";\nimport \"./Pill.css\";\n\n/** The tones a pill draws; any other string is drawn neutrally. */\nexport type PillTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\nexport type PillProps = {\n /** The state's tone: the dot's and the word's colour. */\n tone: PillTone;\n /** The state in words, always shown beside the dot. */\n label: string;\n /** Pulses the dot (never the word) while the state is on its way, such as \"starting\"; stops under reduced motion. */\n pulse?: boolean;\n /** Shown on hover: what the state means or why it is so. */\n title?: string;\n /** After the word, in code type: a failure's code, say. */\n detail?: ReactNode;\n /** A class added to the pill. */\n className?: string;\n};\n\n/** Draws a state as a dot and its word, in the state's tone. */\nexport function Pill({ tone, label, pulse = false, title, detail, className }: PillProps) {\n return (\n <span\n className={className === undefined ? \"pb-pill\" : `pb-pill ${className}`}\n data-tone={tone}\n data-pulse={pulse ? \"\" : undefined}\n title={title}\n >\n <span className=\"pb-pill-dot\" aria-hidden=\"true\" />\n {label}\n {detail !== undefined && <code className=\"pb-pill-detail\">{detail}</code>}\n </span>\n );\n}\n","// A section's title in a panel or inspector, a heading with its actions (buttons, a count) at the far end. The\n// heading's level fits the page it sits in.\nimport type { ReactNode } from \"react\";\nimport \"./SectionTitle.css\";\n\nexport type SectionTitleProps = {\n /** The title. */\n children: ReactNode;\n /** Slot at the title's far end: buttons, a count, a badge. */\n actions?: ReactNode;\n /** The heading's level, h2 to h6. */\n level?: 2 | 3 | 4 | 5 | 6;\n /** A class added to the title's row. */\n className?: string;\n};\n\n/** Draws a section's heading, with its actions at the far end. */\nexport function SectionTitle({ children, actions, level = 3, className }: SectionTitleProps) {\n const Heading = `h${level}` as const;\n return (\n <div className={className === undefined ? \"pb-section-title\" : `pb-section-title ${className}`}>\n <Heading className=\"pb-section-title-text\">{children}</Heading>\n {actions !== undefined && <div className=\"pb-section-title-actions\">{actions}</div>}\n </div>\n );\n}\n","// A drop-down choice in the library's look: a native select (every native prop passes through, ref included; its\n// options are its children), so the platform's own list opens, the keyboard works as the platform's does, and a phone\n// shows its picker. It shows aria-invalid in the error tone, as Field sets it. On a touch screen its text is 16 px, as\n// iOS Safari zooms the page when a smaller field takes the focus.\nimport type { ComponentPropsWithRef } from \"react\";\nimport \"./Select.css\";\n\n/** ui (the default) or code, the monospace face for values written as code; others draw as ui. */\nexport type SelectFont = \"ui\" | \"code\" | (string & {});\n\nexport type SelectProps = ComponentPropsWithRef<\"select\"> & {\n font?: SelectFont;\n};\n\nexport function Select({ font = \"ui\", className, children, ...rest }: SelectProps) {\n return (\n <select {...rest} className={className === undefined ? \"pb-select\" : `pb-select ${className}`} data-font={font}>\n {children}\n </select>\n );\n}\n","// A sheet: a panel drawn over its container's right edge or rising from its bottom, as an inspector is on a narrow\n// window or a phone. It is not modal: the page around it stays live, and opening it does not take the focus (a\n// selection on the canvas opens it while the person is still working there). Escape inside it and its close button\n// ask the app to close it; if the focus was inside when it closes, it goes back to where it came from. The sheet is\n// placed absolutely, so its container (the app's workspace) is positioned; the app holds open, and chooses the side\n// (the right edge below 760 px, the bottom below 600 px).\nimport {\n type FocusEvent,\n type KeyboardEvent,\n type ReactNode,\n type CSSProperties,\n useEffect,\n useId,\n useRef,\n} from \"react\";\nimport { CloseGlyph } from \"../dialog/CloseGlyph\";\nimport { IconButton } from \"../icon-button\";\nimport \"./Sheet.css\";\n\nexport type SheetSide = \"right\" | \"bottom\";\n\nexport type SheetProps = {\n /** Whether the sheet is shown; the app holds it. */\n open: boolean;\n /** Asked for on Escape inside the sheet and on its close button. */\n onClose: () => void;\n /** The edge it is drawn from: the right edge (the default) or the bottom. */\n side?: SheetSide;\n /** The sheet's title, which also names it for screen readers; without one, name it with `label`. */\n title?: ReactNode;\n /** The sheet's name for screen readers when it has no title. */\n label?: string;\n children: ReactNode;\n /** A right sheet's width in px, held to 280–560 px and to 48 px short of its container. */\n width?: number;\n /** The close button's name: \"Close\". */\n closeLabel?: string;\n /** A class added to the sheet. */\n className?: string;\n};\n\nfunction OpenSheet({\n onClose,\n side = \"right\",\n title,\n label,\n children,\n width,\n closeLabel = \"Close\",\n className,\n}: Omit<SheetProps, \"open\">) {\n const sheetRef = useRef<HTMLElement>(null);\n const titleId = useId();\n /** Where the focus came from when it entered the sheet: it goes back there if the sheet closes holding it. */\n const cameFrom = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n const sheet = sheetRef.current;\n return () => {\n const back = cameFrom.current;\n const active = document.activeElement;\n const held = active === null || active === document.body || (sheet?.contains(active) ?? false);\n if (held && back?.isConnected === true) back.focus();\n };\n }, []);\n\n const onFocus = (event: FocusEvent<HTMLElement>) => {\n const from = event.relatedTarget;\n if (from instanceof HTMLElement && !event.currentTarget.contains(from)) cameFrom.current = from;\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n if (event.defaultPrevented || event.key !== \"Escape\") return;\n event.preventDefault();\n event.stopPropagation();\n onClose();\n };\n\n const style = width === undefined ? undefined : ({ \"--pb-sheet-width\": `${width}px` } as CSSProperties);\n\n return (\n <section\n ref={sheetRef}\n className={className === undefined ? \"pb-sheet\" : `pb-sheet ${className}`}\n data-side={side}\n role=\"dialog\"\n aria-labelledby={title === undefined ? undefined : titleId}\n aria-label={title === undefined ? label : undefined}\n style={style}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n >\n <div className=\"pb-sheet-head\">\n {title === undefined ? (\n <span className=\"pb-sheet-title\" />\n ) : (\n <h2 className=\"pb-sheet-title\" id={titleId}>\n {title}\n </h2>\n )}\n <IconButton className=\"pb-sheet-close\" label={closeLabel} onClick={onClose}>\n <CloseGlyph />\n </IconButton>\n </div>\n {/* Focusable, so a body that scrolls can be scrolled from the keyboard. */}\n <div className=\"pb-sheet-body\" tabIndex={0}>\n {children}\n </div>\n </section>\n );\n}\n\nexport function Sheet({ open, ...rest }: SheetProps) {\n if (!open) return null;\n return <OpenSheet {...rest} />;\n}\n","// A splitter's maths, pure: a size kept within its bounds, a drag, and a key. Splitter.tsx draws and listens; this\n// file decides the size.\n\n/** The smallest and largest size, in px. */\nexport interface Bounds {\n min: number;\n max: number;\n}\n\n/** `value` within `bounds`, in whole px. A max below the min is read as the min. */\nexport function clamp(value: number, bounds: Bounds): number {\n const max = Math.max(bounds.min, bounds.max);\n return Math.round(Math.min(max, Math.max(bounds.min, value)));\n}\n\n/**\n * A drag: the size at the drag's start plus the pointer's travel times `sign`, clamped. The sign is -1 for a splitter on\n * the start edge (left or top) of what it resizes, where moving left or up grows it, and 1 on the end edge.\n */\nexport function dragged(start: number, travel: number, sign: 1 | -1, bounds: Bounds): number {\n return clamp(start + sign * travel, bounds);\n}\n\n/** Which arrow grows what the splitter resizes, from its orientation and the edge it sits on. */\nexport function growKey(orientation: \"vertical\" | \"horizontal\", edge: \"start\" | \"end\"): string {\n if (orientation === \"vertical\") return edge === \"start\" ? \"ArrowLeft\" : \"ArrowRight\";\n return edge === \"start\" ? \"ArrowUp\" : \"ArrowDown\";\n}\n\nconst opposite: Record<string, string> = {\n ArrowLeft: \"ArrowRight\",\n ArrowRight: \"ArrowLeft\",\n ArrowUp: \"ArrowDown\",\n ArrowDown: \"ArrowUp\",\n};\n\n/**\n * A key on a focused splitter: `grow` adds `step` and its opposite arrow takes it away, clamped; Home goes to the min\n * and End to the max; any other key gives undefined (the key is not the splitter's).\n */\nexport function keyed(value: number, key: string, grow: string, step: number, bounds: Bounds): number | undefined {\n if (key === grow) return clamp(value + step, bounds);\n if (key === opposite[grow]) return clamp(value - step, bounds);\n if (key === \"Home\") return clamp(bounds.min, bounds);\n if (key === \"End\") return clamp(bounds.max, bounds);\n return undefined;\n}\n","// A resize handle, as a WAI-ARIA separator: the edge of a pane, dragged with the pointer or moved by the arrow keys,\n// Home and End while focused. It keeps only the drag in progress; the size is the app's (value and onChange). It sits\n// absolutely on one edge of its positioned parent, the pane it resizes. splitter-math.ts holds the maths.\nimport { useRef, type ComponentPropsWithRef, type KeyboardEvent, type PointerEvent } from \"react\";\nimport { dragged, growKey, keyed } from \"./splitter-math\";\nimport \"./Splitter.css\";\n\n/** vertical: a vertical bar that resizes a width; horizontal: a horizontal bar that resizes a height. */\nexport type SplitterOrientation = \"vertical\" | \"horizontal\";\n\n/** The edge of the resized pane the splitter sits on: start is its left or top, end its right or bottom. */\nexport type SplitterEdge = \"start\" | \"end\";\n\nexport type SplitterProps = Omit<\n ComponentPropsWithRef<\"div\">,\n \"onChange\" | \"children\" | \"role\" | \"aria-orientation\" | \"aria-valuenow\" | \"aria-valuemin\" | \"aria-valuemax\"\n> & {\n orientation: SplitterOrientation;\n /** The pane's size in px. */\n value: number;\n /** The smallest size in px. */\n min: number;\n /** The largest size in px. */\n max: number;\n /** A new size, in whole px within min and max. */\n onChange: (px: number) => void;\n /** The separator's accessible name, such as \"Resize the inspector\". */\n label: string;\n /** Which edge of the pane it sits on; start (left or top) by default, where moving left or up grows the pane. */\n edge?: SplitterEdge;\n /** How far one arrow key moves it, in px; 16 by default. */\n step?: number;\n};\n\n/** Draws a pane's resize handle, dragged by pointer or moved by keys. */\nexport function Splitter({\n orientation,\n value,\n min,\n max,\n onChange,\n label,\n edge = \"start\",\n step = 16,\n className,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n onPointerCancel,\n onKeyDown,\n ...rest\n}: SplitterProps) {\n const drag = useRef<{ start: number; at: number } | null>(null);\n const bounds = { min, max };\n const along = (event: PointerEvent) => (orientation === \"vertical\" ? event.clientX : event.clientY);\n\n function down(event: PointerEvent<HTMLDivElement>) {\n onPointerDown?.(event);\n if (event.defaultPrevented || event.button !== 0) return;\n event.preventDefault();\n const target = event.currentTarget;\n // Captured, the drag follows the pointer past the bar's few px; jsdom has no capture.\n if (typeof target.setPointerCapture === \"function\") target.setPointerCapture(event.pointerId);\n target.focus();\n target.dataset[\"dragging\"] = \"\";\n drag.current = { start: value, at: along(event) };\n }\n function move(event: PointerEvent<HTMLDivElement>) {\n onPointerMove?.(event);\n const started = drag.current;\n if (started === null) return;\n const next = dragged(started.start, along(event) - started.at, edge === \"start\" ? -1 : 1, bounds);\n if (next !== value) onChange(next);\n }\n function end(event: PointerEvent<HTMLDivElement>) {\n if (event.type === \"pointercancel\") onPointerCancel?.(event);\n else onPointerUp?.(event);\n if (drag.current === null) return;\n drag.current = null;\n const target = event.currentTarget;\n delete target.dataset[\"dragging\"];\n if (typeof target.hasPointerCapture === \"function\" && target.hasPointerCapture(event.pointerId)) {\n target.releasePointerCapture(event.pointerId);\n }\n }\n function key(event: KeyboardEvent<HTMLDivElement>) {\n onKeyDown?.(event);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n const next = keyed(value, event.key, growKey(orientation, edge), step, bounds);\n if (next === undefined) return;\n event.preventDefault();\n if (next !== value) onChange(next);\n }\n\n return (\n <div\n {...rest}\n role=\"separator\"\n tabIndex={rest.tabIndex ?? 0}\n aria-orientation={orientation}\n aria-label={label}\n aria-valuenow={value}\n aria-valuemin={min}\n aria-valuemax={max}\n className={className === undefined ? \"pb-splitter\" : `pb-splitter ${className}`}\n data-orientation={orientation}\n data-edge={edge}\n onPointerDown={down}\n onPointerMove={move}\n onPointerUp={end}\n onPointerCancel={end}\n onKeyDown={key}\n />\n );\n}\n","// A one-line text field in the library's look: a native input (every native prop passes through, ref included), in\n// the UI face or the code face. It shows aria-invalid in the error tone, as Field sets it. On a touch screen its text is\n// 16 px, as iOS Safari zooms the page when a smaller field takes the focus.\nimport type { ComponentPropsWithRef } from \"react\";\nimport \"./TextInput.css\";\n\n/** ui (the default) or code, the monospace face for values written as code; others draw as ui. */\nexport type TextInputFont = \"ui\" | \"code\" | (string & {});\n\nexport type TextInputProps = ComponentPropsWithRef<\"input\"> & {\n font?: TextInputFont;\n};\n\nexport function TextInput({ font = \"ui\", type = \"text\", className, ...rest }: TextInputProps) {\n return (\n <input\n {...rest}\n type={type}\n className={className === undefined ? \"pb-text-input\" : `pb-text-input ${className}`}\n data-font={font}\n />\n );\n}\n","// The theme switch: one button that cycles system, light and dark. Its word is shown beside the icon, and its\n// accessible name always says the choice, so it is never just a glyph; the icon is SVG, since a font may lack a ◐\n// character. The choice is the app's (useTheme keeps it); the switch only says it and asks for the next. At phone\n// width the word gives way to the icon alone, and the name still says the choice.\nimport type { ComponentPropsWithRef } from \"react\";\nimport type { ThemeChoice } from \"../../hooks/use-theme/useTheme\";\nimport \"./ThemeSwitch.css\";\n\nexport type { ThemeChoice };\n\n/** The switch's words, each replaceable. */\nexport interface ThemeSwitchLabels {\n /** What the switch is: \"Theme\". */\n theme: string;\n system: string;\n light: string;\n dark: string;\n /** Said of system in the tooltip: \"follows the system's setting\". */\n systemHint: string;\n /** Before the next choice in the tooltip: \"click for\". */\n clickFor: string;\n}\n\nexport const defaultThemeSwitchLabels: ThemeSwitchLabels = {\n theme: \"Theme\",\n system: \"system\",\n light: \"light\",\n dark: \"dark\",\n systemHint: \"follows the system's setting\",\n clickFor: \"click for\",\n};\n\nconst order: readonly ThemeChoice[] = [\"system\", \"light\", \"dark\"];\n\n/** The choice a press moves to: system, light, dark and back. */\nfunction following(choice: ThemeChoice): ThemeChoice {\n return order[(order.indexOf(choice) + 1) % order.length] ?? \"system\";\n}\n\nexport type ThemeSwitchProps = Omit<ComponentPropsWithRef<\"button\">, \"children\" | \"onClick\" | \"type\" | \"title\"> & {\n /** The theme now. */\n choice: ThemeChoice;\n /** Called with the next choice in the cycle when the switch is pressed. */\n onChoose: (next: ThemeChoice) => void;\n /** Words to replace; the rest keep their defaults. */\n labels?: Partial<ThemeSwitchLabels>;\n};\n\n/** The switch's tooltip: what the theme is and what a press does. */\nexport function themeSwitchTitle(choice: ThemeChoice, labels: ThemeSwitchLabels = defaultThemeSwitchLabels): string {\n const hint = choice === \"system\" ? ` (${labels.systemHint})` : \"\";\n return `${labels.theme}: ${labels[choice]}${hint}; ${labels.clickFor} ${labels[following(choice)]}`;\n}\n\nexport function ThemeSwitch({ choice, onChoose, labels, className, ...rest }: ThemeSwitchProps) {\n const words = { ...defaultThemeSwitchLabels, ...labels };\n return (\n <button\n {...rest}\n type=\"button\"\n className={className === undefined ? \"pb-theme-switch\" : `pb-theme-switch ${className}`}\n title={themeSwitchTitle(choice, words)}\n aria-label={`${words.theme}: ${words[choice]}`}\n onClick={() => {\n onChoose(following(choice));\n }}\n >\n <svg className=\"pb-theme-switch-icon\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\">\n <circle cx=\"8\" cy=\"8\" r=\"6.25\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n <path d=\"M8 1.75a6.25 6.25 0 0 1 0 12.5z\" fill=\"currentColor\" />\n </svg>\n <span className=\"pb-theme-switch-word\">{words[choice]}</span>\n </button>\n );\n}\n","// Roving focus over a toolbar's items, pure DOM: which elements are items, which one holds the toolbar's one tab stop,\n// and where an arrow key, Home or End moves the focus. Toolbar.tsx wires it to React.\n\n/** What counts as an item: an enabled control, or anything that says it is a button, checkbox or radio. */\nexport const itemSelector = [\n \"button:not(:disabled)\",\n \"a[href]\",\n \"input:not(:disabled)\",\n \"select:not(:disabled)\",\n \"textarea:not(:disabled)\",\n '[role=\"button\"]',\n '[role=\"checkbox\"]',\n '[role=\"radio\"]',\n '[role=\"menuitem\"]',\n '[role=\"switch\"]',\n].join(\", \");\n\n/** The toolbar's items, in document order, leaving out those of a toolbar nested inside it. */\nexport function items(toolbar: HTMLElement): HTMLElement[] {\n return [...toolbar.querySelectorAll<HTMLElement>(itemSelector)].filter(\n (item) => item.closest('[role=\"toolbar\"]') === toolbar,\n );\n}\n\n/** Gives `current` the one tab stop (0) and every other item -1; with no current, the first item takes it. */\nexport function setTabStop(all: readonly HTMLElement[], current: HTMLElement | null): HTMLElement | null {\n const stop = current !== null && all.includes(current) ? current : (all[0] ?? null);\n for (const item of all) item.tabIndex = item === stop ? 0 : -1;\n return stop;\n}\n\n/**\n * The item a key moves the focus to from `index`, or undefined when the key is not the toolbar's. Horizontal toolbars\n * take the left and right arrows (swapped right to left), vertical ones up and down; both take Home and End. The ends\n * wrap around.\n */\nexport function moved(\n index: number,\n count: number,\n key: string,\n orientation: \"horizontal\" | \"vertical\",\n rtl: boolean,\n): number | undefined {\n if (count === 0) return undefined;\n if (key === \"Home\") return 0;\n if (key === \"End\") return count - 1;\n const [back, forth] =\n orientation === \"vertical\"\n ? [\"ArrowUp\", \"ArrowDown\"]\n : rtl\n ? [\"ArrowRight\", \"ArrowLeft\"]\n : [\"ArrowLeft\", \"ArrowRight\"];\n if (key === forth) return (index + 1) % count;\n if (key === back) return (index - 1 + count) % count;\n return undefined;\n}\n\n/** Whether a key pressed in `element` belongs to the text it edits (arrows, Home and End move its caret). */\nexport function editsText(element: Element): boolean {\n if (element instanceof HTMLTextAreaElement) return true;\n if (element instanceof HTMLInputElement) {\n return ![\"button\", \"checkbox\", \"radio\", \"reset\", \"submit\", \"image\", \"color\", \"file\", \"range\"].includes(\n element.type,\n );\n }\n return element instanceof HTMLElement && element.isContentEditable;\n}\n","// A WAI-ARIA toolbar: a row (or column) of controls that is one tab stop, the arrow keys, Home and End moving the focus\n// between its items (roving tabindex). The items are whatever controls its children render; the toolbar sets their\n// tabIndex itself, so an item's own tabIndex is overwritten. The item last focused keeps the tab stop, and a text field\n// inside keeps its own arrow keys. roving.ts holds the rules.\nimport { useEffect, useRef, type ComponentPropsWithRef, type FocusEvent, type KeyboardEvent } from \"react\";\nimport { editsText, items, moved, setTabStop } from \"./roving\";\nimport \"./Toolbar.css\";\n\nexport type ToolbarOrientation = \"horizontal\" | \"vertical\";\n\nexport type ToolbarProps = Omit<ComponentPropsWithRef<\"div\">, \"role\" | \"aria-orientation\"> & {\n /** The toolbar's accessible name, such as \"Canvas\". */\n label: string;\n /** horizontal (the default) moves with the left and right arrows; vertical with up and down. */\n orientation?: ToolbarOrientation;\n};\n\n/** Draws a group of controls as one tab stop, with the arrow keys moving between them. */\nexport function Toolbar({\n label,\n orientation = \"horizontal\",\n className,\n ref,\n onKeyDown,\n onFocus,\n children,\n ...rest\n}: ToolbarProps) {\n const own = useRef<HTMLDivElement | null>(null);\n const current = useRef<HTMLElement | null>(null);\n\n // After every render, and whenever an item comes, goes or is enabled or disabled, one item holds the tab stop.\n useEffect(() => {\n const toolbar = own.current;\n if (toolbar === null) return;\n const settle = () => {\n current.current = setTabStop(items(toolbar), current.current);\n };\n settle();\n const watch = new MutationObserver(settle);\n watch.observe(toolbar, { childList: true, subtree: true, attributes: true, attributeFilter: [\"disabled\", \"href\"] });\n return () => {\n watch.disconnect();\n };\n });\n\n function focus(event: FocusEvent<HTMLDivElement>) {\n onFocus?.(event);\n const toolbar = own.current;\n if (toolbar === null) return;\n const all = items(toolbar);\n if (event.target instanceof HTMLElement && all.includes(event.target)) {\n current.current = setTabStop(all, event.target);\n }\n }\n function key(event: KeyboardEvent<HTMLDivElement>) {\n onKeyDown?.(event);\n const toolbar = own.current;\n if (event.defaultPrevented || toolbar === null || event.altKey || event.ctrlKey || event.metaKey) return;\n if (editsText(event.target as Element)) return;\n const all = items(toolbar);\n const index = all.indexOf(event.target as HTMLElement);\n if (index === -1) return;\n const rtl = getComputedStyle(toolbar).direction === \"rtl\";\n const next = moved(index, all.length, event.key, orientation, rtl);\n if (next === undefined) return;\n event.preventDefault();\n all[next]?.focus();\n }\n\n return (\n <div\n {...rest}\n ref={(element) => {\n own.current = element;\n if (typeof ref === \"function\") return ref(element);\n if (ref) ref.current = element;\n return undefined;\n }}\n role=\"toolbar\"\n aria-label={label}\n aria-orientation={orientation}\n className={className === undefined ? \"pb-toolbar\" : `pb-toolbar ${className}`}\n onKeyDown={key}\n onFocus={focus}\n >\n {children}\n </div>\n );\n}\n","// A floating group of tools, such as a canvas's zoom, fit and minimap: a Toolbar drawn as one raised, framed group of\n// square buttons. Its tools are IconButtons (or plain <button>s named by aria-label with their\n// glyph hidden); a pressed one (aria-pressed) is drawn in the accent. 28 px buttons, 40 px on touch.\nimport { Toolbar, type ToolbarProps } from \"../toolbar\";\nimport \"./ToolGroup.css\";\n\nexport type ToolGroupProps = ToolbarProps;\n\n/** Draws a framed group of square tool buttons, one tab stop with roving focus. */\nexport function ToolGroup({ className, ...rest }: ToolGroupProps) {\n return <Toolbar {...rest} className={className === undefined ? \"pb-tool-group\" : `pb-tool-group ${className}`} />;\n}\n","// The warning mark: an \"!\" in a circle beside words, for something that rose lately (a badge's or a counter's). The\n// glyph is hidden from screen readers, which read its label instead.\nimport \"./WarnMark.css\";\n\nexport type WarnMarkProps = {\n /** What the mark means, read by screen readers in its place. */\n label: string;\n /** Shown on hover over the mark. */\n title?: string;\n /** A class added to the mark. */\n className?: string;\n};\n\n/** Draws a warning \"!\" for the eye and its words for screen readers. */\nexport function WarnMark({ label, title, className }: WarnMarkProps) {\n return (\n <>\n <span\n className={className === undefined ? \"pb-warn-mark\" : `pb-warn-mark ${className}`}\n aria-hidden=\"true\"\n title={title}\n >\n !\n </span>\n <span className=\"pb-warn-mark-text\">{label}</span>\n </>\n );\n}\n"],"mappings":";;;;AAoBA,SAAgBC,EAAM,EAAE,SAAM,aAAU,UAAO,gBAA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9J,GAAA,EAAA,UAAA,CACE,kBAAC,QAAD;EACE,WAAWE,MAAc,KAAA,IAAY,iBAAiB,gBAAgBA;EACtE,eAAY;EACL;EACR,UAAA;CAEK,CAAA,GACN,kBAAC,QAAD;EAAM,WAAU;EAAqB,UAAAK;CAAY,CAAA,CACjD,EAAA,CAAA;AAEN"}
|
package/dist/shell.js
ADDED
|
File without changes
|
package/dist/tokens.css
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/* patchbay's design tokens (@mcurcio/patchbay/tokens.css): every colour, radius, shadow, duration, space and type
|
|
2
|
+
size a component draws with, as --pb-* custom properties on :root, in a light and a dark theme (docs/tokens.md).
|
|
3
|
+
Component stylesheets use only these, and tokens.test.ts checks it.
|
|
4
|
+
|
|
5
|
+
The theme follows the system until data-theme on <html> chooses one: no attribute is the system's choice,
|
|
6
|
+
data-theme="light" or "dark" overrides it. The dark set is therefore written twice, once for a dark system with no
|
|
7
|
+
choice made and once for a chosen dark, and tokens.test.ts holds the two equal. CSS's light-dark() is not used
|
|
8
|
+
because a CSS minifier may rewrite it for older browsers. */
|
|
9
|
+
:root {
|
|
10
|
+
color-scheme: light;
|
|
11
|
+
|
|
12
|
+
/* Surfaces: the canvas, boxes and controls, tracks and read-only text. */
|
|
13
|
+
--pb-surface: #f6f7f9;
|
|
14
|
+
--pb-raised: #ffffff;
|
|
15
|
+
--pb-sunken: #eef0f3;
|
|
16
|
+
|
|
17
|
+
/* Lines: borders, the canvas's dot grid. */
|
|
18
|
+
--pb-line: #d9dde3;
|
|
19
|
+
--pb-line-strong: #aeb5bf;
|
|
20
|
+
|
|
21
|
+
/* Text: body, secondary, selection and focus, text on a filled chip. */
|
|
22
|
+
--pb-text: #16181d;
|
|
23
|
+
--pb-muted: #5b6270;
|
|
24
|
+
--pb-accent: #3b5bdb;
|
|
25
|
+
--pb-on-strong: #ffffff;
|
|
26
|
+
|
|
27
|
+
/* Tones: what a state is drawn in, and the soft surfaces under a warning or an error. */
|
|
28
|
+
--pb-ok: #26773a;
|
|
29
|
+
--pb-warn: #a35200;
|
|
30
|
+
--pb-err: #c92a2a;
|
|
31
|
+
--pb-quiet: #4058d6;
|
|
32
|
+
--pb-off: #646b78;
|
|
33
|
+
--pb-warn-soft: #fff4e6;
|
|
34
|
+
--pb-err-soft: #ffe3e3;
|
|
35
|
+
|
|
36
|
+
/* Changes: an edit not yet applied (added, removed, renamed). */
|
|
37
|
+
--pb-added: #157a3a;
|
|
38
|
+
--pb-removed: #c42020;
|
|
39
|
+
--pb-renamed: #7c3aed;
|
|
40
|
+
|
|
41
|
+
/* Meters: the bar's three zones and the peak tick. */
|
|
42
|
+
--pb-meter-low: #40c057;
|
|
43
|
+
--pb-meter-mid: #fab005;
|
|
44
|
+
--pb-meter-hot: #fa5252;
|
|
45
|
+
--pb-meter-peak: #2b8a3e;
|
|
46
|
+
|
|
47
|
+
/* Code: a code box and its highlighter's token colours. */
|
|
48
|
+
--pb-code-surface: var(--pb-raised);
|
|
49
|
+
--pb-code-surface-readonly: var(--pb-sunken);
|
|
50
|
+
--pb-code-border: var(--pb-line-strong);
|
|
51
|
+
--pb-code-text: var(--pb-text);
|
|
52
|
+
--pb-code-directive: #1864ab;
|
|
53
|
+
--pb-code-keyword: #a35200;
|
|
54
|
+
--pb-code-variable: #8a6100;
|
|
55
|
+
--pb-code-number: #2b7a3a;
|
|
56
|
+
--pb-code-string: #a61e1e;
|
|
57
|
+
--pb-code-comment: #666666;
|
|
58
|
+
--pb-code-punctuation: #495057;
|
|
59
|
+
--pb-code-error: #c92a2a;
|
|
60
|
+
--pb-code-error-surface: var(--pb-err-soft);
|
|
61
|
+
|
|
62
|
+
/* Shape. */
|
|
63
|
+
--pb-radius-box: 8px;
|
|
64
|
+
--pb-radius-control: 6px;
|
|
65
|
+
--pb-radius-pill: 999px;
|
|
66
|
+
--pb-shadow: 0 1px 2px rgb(16 24 40 / 0.08);
|
|
67
|
+
--pb-shadow-lifted: 0 4px 12px rgb(16 24 40 / 0.14);
|
|
68
|
+
|
|
69
|
+
/* Motion: hover and selection, what slides, a pulsing dot, a wire's flow, the busy spinner's turn. The last three
|
|
70
|
+
drive infinite animations, which a component stops under reduced motion rather than running at 0 s. */
|
|
71
|
+
--pb-motion-fast: 120ms;
|
|
72
|
+
--pb-motion-slow: 180ms;
|
|
73
|
+
--pb-motion-pulse: 2s;
|
|
74
|
+
--pb-motion-flow: 1s;
|
|
75
|
+
--pb-motion-spin: 0.8s;
|
|
76
|
+
|
|
77
|
+
/* Density: the spacing steps, a port row's height, the top bar's height. */
|
|
78
|
+
--pb-space-1: 2px;
|
|
79
|
+
--pb-space-2: 4px;
|
|
80
|
+
--pb-space-3: 8px;
|
|
81
|
+
--pb-space-4: 12px;
|
|
82
|
+
--pb-space-5: 16px;
|
|
83
|
+
--pb-row: 22px;
|
|
84
|
+
--pb-bar: 44px;
|
|
85
|
+
|
|
86
|
+
/* Type: the faces, the two text sizes, and the code boxes' size (shared by a textarea, its highlighted copy and a
|
|
87
|
+
gutter, so their glyphs line up). */
|
|
88
|
+
--pb-font-ui: system-ui, sans-serif;
|
|
89
|
+
--pb-font-code: ui-monospace, monospace;
|
|
90
|
+
--pb-text-sm: 12px;
|
|
91
|
+
--pb-text-md: 13px;
|
|
92
|
+
--pb-code-size: 12px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* The system's dark, while no theme is chosen. */
|
|
96
|
+
@media (prefers-color-scheme: dark) {
|
|
97
|
+
:root:not([data-theme]) {
|
|
98
|
+
color-scheme: dark;
|
|
99
|
+
--pb-surface: #0f1115;
|
|
100
|
+
--pb-raised: #181b21;
|
|
101
|
+
--pb-sunken: #12151a;
|
|
102
|
+
--pb-line: #2a2f38;
|
|
103
|
+
--pb-line-strong: #3d4450;
|
|
104
|
+
--pb-text: #e6e8ec;
|
|
105
|
+
--pb-muted: #9aa2b1;
|
|
106
|
+
--pb-accent: #7c94ff;
|
|
107
|
+
--pb-on-strong: #0f1115;
|
|
108
|
+
--pb-ok: #51cf66;
|
|
109
|
+
--pb-warn: #ffa94d;
|
|
110
|
+
--pb-err: #ff6b6b;
|
|
111
|
+
--pb-quiet: #91a7ff;
|
|
112
|
+
--pb-off: #808999;
|
|
113
|
+
--pb-warn-soft: #2e2414;
|
|
114
|
+
--pb-err-soft: #361b1d;
|
|
115
|
+
--pb-added: #4ade80;
|
|
116
|
+
--pb-removed: #f87171;
|
|
117
|
+
--pb-renamed: #c084fc;
|
|
118
|
+
--pb-meter-low: #51cf66;
|
|
119
|
+
--pb-meter-mid: #ffd43b;
|
|
120
|
+
--pb-meter-hot: #ff8787;
|
|
121
|
+
--pb-meter-peak: #b2f2bb;
|
|
122
|
+
--pb-shadow: 0 1px 2px rgb(0 0 0 / 0.5);
|
|
123
|
+
--pb-shadow-lifted: 0 4px 12px rgb(0 0 0 / 0.6);
|
|
124
|
+
--pb-code-directive: #74c0fc;
|
|
125
|
+
--pb-code-keyword: #ffa94d;
|
|
126
|
+
--pb-code-variable: #ffd43b;
|
|
127
|
+
--pb-code-number: #69db7c;
|
|
128
|
+
--pb-code-string: #ff8787;
|
|
129
|
+
--pb-code-comment: #8c929c;
|
|
130
|
+
--pb-code-punctuation: #adb5bd;
|
|
131
|
+
--pb-code-error: #ff6b6b;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* Dark chosen over any system: the same set, line for line. */
|
|
136
|
+
:root[data-theme="dark"] {
|
|
137
|
+
color-scheme: dark;
|
|
138
|
+
--pb-surface: #0f1115;
|
|
139
|
+
--pb-raised: #181b21;
|
|
140
|
+
--pb-sunken: #12151a;
|
|
141
|
+
--pb-line: #2a2f38;
|
|
142
|
+
--pb-line-strong: #3d4450;
|
|
143
|
+
--pb-text: #e6e8ec;
|
|
144
|
+
--pb-muted: #9aa2b1;
|
|
145
|
+
--pb-accent: #7c94ff;
|
|
146
|
+
--pb-on-strong: #0f1115;
|
|
147
|
+
--pb-ok: #51cf66;
|
|
148
|
+
--pb-warn: #ffa94d;
|
|
149
|
+
--pb-err: #ff6b6b;
|
|
150
|
+
--pb-quiet: #91a7ff;
|
|
151
|
+
--pb-off: #808999;
|
|
152
|
+
--pb-warn-soft: #2e2414;
|
|
153
|
+
--pb-err-soft: #361b1d;
|
|
154
|
+
--pb-added: #4ade80;
|
|
155
|
+
--pb-removed: #f87171;
|
|
156
|
+
--pb-renamed: #c084fc;
|
|
157
|
+
--pb-meter-low: #51cf66;
|
|
158
|
+
--pb-meter-mid: #ffd43b;
|
|
159
|
+
--pb-meter-hot: #ff8787;
|
|
160
|
+
--pb-meter-peak: #b2f2bb;
|
|
161
|
+
--pb-shadow: 0 1px 2px rgb(0 0 0 / 0.5);
|
|
162
|
+
--pb-shadow-lifted: 0 4px 12px rgb(0 0 0 / 0.6);
|
|
163
|
+
--pb-code-directive: #74c0fc;
|
|
164
|
+
--pb-code-keyword: #ffa94d;
|
|
165
|
+
--pb-code-variable: #ffd43b;
|
|
166
|
+
--pb-code-number: #69db7c;
|
|
167
|
+
--pb-code-string: #ff8787;
|
|
168
|
+
--pb-code-comment: #8c929c;
|
|
169
|
+
--pb-code-punctuation: #adb5bd;
|
|
170
|
+
--pb-code-error: #ff6b6b;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* A finger: every text field is 16 px, code boxes included, as iOS Safari zooms the page when a smaller field takes
|
|
174
|
+
the focus. */
|
|
175
|
+
@media (hover: none) and (pointer: coarse) {
|
|
176
|
+
:root {
|
|
177
|
+
--pb-code-size: 16px;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* No motion for those who ask for none. The pulse, the flow and the spin keep their durations: a component stops those
|
|
182
|
+
infinite animations instead, since one at 0 s would churn rather than stop. */
|
|
183
|
+
@media (prefers-reduced-motion: reduce) {
|
|
184
|
+
:root {
|
|
185
|
+
--pb-motion-fast: 0ms;
|
|
186
|
+
--pb-motion-slow: 0ms;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* Derived colours: mixed from the theme's tokens, so they follow the theme and a brand without a dark value of their
|
|
191
|
+
own (var() resolves on :root, after the theme and the brand). A brand may still override them. */
|
|
192
|
+
:root {
|
|
193
|
+
/* Behind a modal dialog: the canvas, mostly opaque. */
|
|
194
|
+
--pb-scrim: color-mix(in srgb, var(--pb-surface) 72%, transparent);
|
|
195
|
+
/* A filled accent control under the pointer: the accent pulled toward the text colour. */
|
|
196
|
+
--pb-accent-hover: color-mix(in srgb, var(--pb-accent) 85%, var(--pb-text));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* React Flow's own variables point at the tokens, so its canvas, dot grid, wires, handles and minimap follow the
|
|
200
|
+
theme and the brand. Its colorMode prop is not used: it would fight data-theme. Set on .react-flow, so each var()
|
|
201
|
+
resolves where React Flow reads it. */
|
|
202
|
+
.react-flow {
|
|
203
|
+
--xy-background-color: var(--pb-surface);
|
|
204
|
+
--xy-background-pattern-color: var(--pb-line);
|
|
205
|
+
--xy-node-color: var(--pb-text);
|
|
206
|
+
--xy-edge-stroke: var(--pb-muted);
|
|
207
|
+
--xy-edge-stroke-selected: var(--pb-accent);
|
|
208
|
+
--xy-connectionline-stroke: var(--pb-muted);
|
|
209
|
+
--xy-handle-background-color: var(--pb-text);
|
|
210
|
+
--xy-handle-border-color: var(--pb-raised);
|
|
211
|
+
--xy-selection-background-color: color-mix(in srgb, var(--pb-accent) 8%, transparent);
|
|
212
|
+
--xy-selection-border: 1px dotted var(--pb-accent);
|
|
213
|
+
--xy-attribution-background-color: color-mix(in srgb, var(--pb-raised) 60%, transparent);
|
|
214
|
+
--xy-controls-button-background-color: var(--pb-raised);
|
|
215
|
+
--xy-controls-button-color: var(--pb-text);
|
|
216
|
+
--xy-minimap-background-color: var(--pb-raised);
|
|
217
|
+
--xy-minimap-mask-background-color: color-mix(in srgb, var(--pb-surface) 65%, transparent);
|
|
218
|
+
--xy-minimap-mask-stroke-color: var(--pb-accent);
|
|
219
|
+
--xy-minimap-node-background-color: var(--pb-sunken);
|
|
220
|
+
--xy-minimap-node-stroke-color: var(--pb-line-strong);
|
|
221
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Dispatch, type SetStateAction } from "react";
|
|
2
|
+
/** What a kept value needs of window.localStorage. */
|
|
3
|
+
export interface StorageLike {
|
|
4
|
+
getItem(key: string): string | null;
|
|
5
|
+
setItem(key: string, value: string): void;
|
|
6
|
+
removeItem(key: string): void;
|
|
7
|
+
}
|
|
8
|
+
/** window.localStorage, or null without a window or where its accessor throws (blocked storage). */
|
|
9
|
+
export declare function browserStorage(): StorageLike | null;
|
|
10
|
+
/**
|
|
11
|
+
* Checks a value read back from storage: returns it (or a value made from it) when it is good, and undefined when it
|
|
12
|
+
* is not, so the initial value is used instead.
|
|
13
|
+
*/
|
|
14
|
+
export type KeptCheck<T> = (value: unknown) => T | undefined;
|
|
15
|
+
/** The value kept under `key`, checked; undefined when there is none, storage throws, or it is not good JSON. */
|
|
16
|
+
export declare function readKept<T>(storage: StorageLike | null, key: string, check: KeptCheck<T>): T | undefined;
|
|
17
|
+
/** Writes `value` as JSON under `key`; a full or blocked storage is ignored. */
|
|
18
|
+
export declare function writeKept(storage: StorageLike | null, key: string, value: unknown): void;
|
|
19
|
+
export interface PersistentStateOptions {
|
|
20
|
+
/** Where values are kept; the browser's localStorage by default. null keeps nothing. */
|
|
21
|
+
storage?: StorageLike | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* React state kept under `key` in localStorage: starts from the kept value when `check` accepts it, else `initial`,
|
|
25
|
+
* and writes every value the app sets. A new `key` reads that key's value afresh.
|
|
26
|
+
*/
|
|
27
|
+
export declare function usePersistentState<T>(key: string, initial: T, check: KeptCheck<T>, options?: PersistentStateOptions): [T, Dispatch<SetStateAction<T>>];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type PersistentStateOptions } from "../use-persistent-state/usePersistentState";
|
|
2
|
+
export type ThemeChoice = "system" | "light" | "dark";
|
|
3
|
+
/** The switch's cycle order. */
|
|
4
|
+
export declare const themeChoices: readonly ThemeChoice[];
|
|
5
|
+
/** The page follows the system until the person chooses. */
|
|
6
|
+
export declare const defaultTheme: ThemeChoice;
|
|
7
|
+
/** The key used when the app names none. */
|
|
8
|
+
export declare const defaultThemeKey = "patchbay/theme";
|
|
9
|
+
/** The choice after `choice` in the cycle system, light, dark. */
|
|
10
|
+
export declare function nextTheme(choice: ThemeChoice): ThemeChoice;
|
|
11
|
+
/** A kept value that is one of the three choices, else undefined. */
|
|
12
|
+
export declare function checkTheme(value: unknown): ThemeChoice | undefined;
|
|
13
|
+
/** Writes the choice onto the root it is given (the page's <html>): system removes data-theme. */
|
|
14
|
+
export declare function applyTheme(root: {
|
|
15
|
+
dataset: DOMStringMap;
|
|
16
|
+
}, choice: ThemeChoice): void;
|
|
17
|
+
/**
|
|
18
|
+
* The body of an inline <script> for the app's index.html, run before the page draws: it applies the choice kept
|
|
19
|
+
* under `key`, as useTheme keeps it, and does nothing when storage is blocked or the value is not light or dark.
|
|
20
|
+
*/
|
|
21
|
+
export declare function themeScript(key?: string): string;
|
|
22
|
+
export interface UseThemeOptions extends PersistentStateOptions {
|
|
23
|
+
/** The localStorage key the choice is kept under: the app's own, with its prefix. */
|
|
24
|
+
key?: string;
|
|
25
|
+
/** Where data-theme is written; the page's <html> by default. */
|
|
26
|
+
root?: {
|
|
27
|
+
dataset: DOMStringMap;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** The theme choice and its setter; the choice is kept, and written to data-theme on <html> before paint. */
|
|
31
|
+
export declare function useTheme(options?: UseThemeOptions): [ThemeChoice, (choice: ThemeChoice) => void];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import "./Badge.css";
|
|
3
|
+
/** The tones a badge draws; any other string is drawn neutrally. */
|
|
4
|
+
export type BadgeTone = "ok" | "warn" | "err" | "quiet" | "off" | (string & {});
|
|
5
|
+
export type BadgeProps = {
|
|
6
|
+
/** The badge's tone: its text and border colour, and for warn and err a soft surface. */
|
|
7
|
+
tone: BadgeTone;
|
|
8
|
+
/** What the badge says: a word, a count, a WarnMark beside them. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Shown on hover: what the badge means. */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** A class added to the badge. */
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Draws a short word or count in a chip of its tone. */
|
|
16
|
+
export declare function Badge({ tone, children, title, className }: BadgeProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
import "./Button.css";
|
|
3
|
+
/** What the button does, by colour: neutral (the default), primary (the one main action), danger; others draw neutral. */
|
|
4
|
+
export type ButtonTone = "neutral" | "primary" | "danger" | (string & {});
|
|
5
|
+
/** md (the default) or sm, the compact one for dense rows; others draw as md. On touch both are at least 36 px tall. */
|
|
6
|
+
export type ButtonSize = "md" | "sm" | (string & {});
|
|
7
|
+
export type ButtonProps = ComponentPropsWithRef<"button"> & {
|
|
8
|
+
tone?: ButtonTone;
|
|
9
|
+
size?: ButtonSize;
|
|
10
|
+
/** A request is on its way: a spinner over the words, aria-busy, and presses ignored. */
|
|
11
|
+
busy?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function Button({ tone, size, busy, type, className, children, onClick, ...rest }: ButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef, type ReactNode } from "react";
|
|
2
|
+
import "./Checkbox.css";
|
|
3
|
+
export type CheckboxProps = Omit<ComponentPropsWithRef<"input">, "type"> & {
|
|
4
|
+
/** The words beside the box, which tick it too; without them, name the box by a Field or aria-label. */
|
|
5
|
+
label?: ReactNode;
|
|
6
|
+
/** Neither ticked nor not: drawn as a dash and read as "mixed". */
|
|
7
|
+
indeterminate?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function Checkbox({ label, indeterminate, className, ref, ...rest }: CheckboxProps): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CloseGlyph(): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import "./Dialog.css";
|
|
3
|
+
export type DialogProps = {
|
|
4
|
+
/** Whether the dialog is shown; the app holds it. */
|
|
5
|
+
open: boolean;
|
|
6
|
+
/** Asked for on Escape, the close button and a press on the scrim. */
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
/** The dialog's title, which also names it for screen readers. */
|
|
9
|
+
title: ReactNode;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/** A row at the foot of the dialog, for its buttons. */
|
|
12
|
+
actions?: ReactNode;
|
|
13
|
+
/** The close button's name: "Close". */
|
|
14
|
+
closeLabel?: string;
|
|
15
|
+
/** A class added to the dialog's box. */
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function Dialog({ open, ...rest }: DialogProps): import("react").ReactPortal | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type AriaAttributes, type ComponentPropsWithRef, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import "./Field.css";
|
|
3
|
+
/** stacked (the default: the label above the control) or inline (the label in a column to its left); others stack. */
|
|
4
|
+
export type FieldLayout = "stacked" | "inline" | (string & {});
|
|
5
|
+
/** The props Field sets on its control. */
|
|
6
|
+
export type FieldControlProps = {
|
|
7
|
+
id?: string;
|
|
8
|
+
"aria-describedby"?: string;
|
|
9
|
+
"aria-invalid"?: AriaAttributes["aria-invalid"];
|
|
10
|
+
};
|
|
11
|
+
export type FieldProps = Omit<ComponentPropsWithRef<"div">, "children"> & {
|
|
12
|
+
/** What the control is, as its accessible name. */
|
|
13
|
+
label: ReactNode;
|
|
14
|
+
/** Why the value is refused; while there is one the control is marked invalid. Empty means none. */
|
|
15
|
+
error?: ReactNode;
|
|
16
|
+
/** A line of help under the control. */
|
|
17
|
+
hint?: ReactNode;
|
|
18
|
+
layout?: FieldLayout;
|
|
19
|
+
/** The control: one element that passes id and aria props on to its native element. */
|
|
20
|
+
children: ReactElement<FieldControlProps>;
|
|
21
|
+
};
|
|
22
|
+
export declare function Field({ label, error, hint, layout, className, children, ...rest }: FieldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type ButtonProps } from "../button";
|
|
3
|
+
import "./IconButton.css";
|
|
4
|
+
export type IconButtonProps = Omit<ButtonProps, "children" | "aria-label"> & {
|
|
5
|
+
/** The button's name for screen readers, and its tooltip unless title says otherwise. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** The glyph: an icon or a character, hidden from screen readers. */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
export declare function IconButton({ label, title, className, children, ...rest }: IconButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./badge";
|
|
2
|
+
export * from "./button";
|
|
3
|
+
export * from "./checkbox";
|
|
4
|
+
export * from "./dialog";
|
|
5
|
+
export * from "./field";
|
|
6
|
+
export * from "./icon-button";
|
|
7
|
+
export * from "./key-value";
|
|
8
|
+
export * from "./panel";
|
|
9
|
+
export * from "./pill";
|
|
10
|
+
export * from "./section-title";
|
|
11
|
+
export * from "./select";
|
|
12
|
+
export * from "./sheet";
|
|
13
|
+
export * from "./spinner";
|
|
14
|
+
export * from "./splitter";
|
|
15
|
+
export * from "./text-input";
|
|
16
|
+
export * from "./theme-switch";
|
|
17
|
+
export * from "./tool-group";
|
|
18
|
+
export * from "./toolbar";
|
|
19
|
+
export * from "./warn-mark";
|