@surfaces-ui/components 0.7.0 → 0.8.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/record/record.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,kBAAkB,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,SAAS,EAA4C,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAkB/C;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAsB;IACjD,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE;QACzD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACtN,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAE,CAAC,CAAC;QAC1E,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC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,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,MAAM,CAAC,OAAO,CAAC,GAAG,oGAAoG,CAAC;IACrK,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC1G,CAAC","sourcesContent":["import type { JsonObject, JsonValue } from \"@bufbuild/protobuf\";\nimport { type DataSource, checkOperationArgs, collect, filtersFromSpec } from \"@surfaces-ui/data\";\nimport { FieldType, type FormField, type OperationDefinition } from \"@surfaces-ui/proto\";\nimport { plainValue } from \"../data/format.js\";\nimport type { FormFieldSpec } from \"../form/Form.js\";\n\n/** One record as plain values by column: numbers as numbers, dates and times as ISO text, a missing value as null. */\nexport type RecordRow = Record<string, string | number | boolean | null>;\n\n/** What a record form reads of the operation that saves it: its arguments are the form's fields. */\nexport type RecordOperation = Pick<OperationDefinition, \"args\"> & Partial<Pick<OperationDefinition, \"id\" | \"title\">>;\n\n/** One record to read: a read-only query and the key that picks the row. */\nexport interface RecordRequest {\n sourceId: string;\n sql: string;\n key: { column: string; value: string | number | boolean };\n notBefore?: string;\n signal?: AbortSignal;\n}\n\n/**\n * Reads the rows a key picks, over any `DataSource`: the base SQL with the key as a filter the engine binds as a\n * parameter, never spliced into the text, and two rows at most (one is the record, two means the key is not one).\n * It is what `RecordForm` reads with, and what an app shell is given to read a page's `record`.\n */\nexport function recordReader(dataSource: DataSource): (request: RecordRequest) => Promise<RecordRow[]> {\n return async ({ sourceId, sql, key, notBefore, signal }) => {\n const result = await collect(dataSource.execute({ sourceId, notBefore, query: { baseSql: sql, filters: filtersFromSpec([{ column: key.column, op: \"eq\", values: [key.value] }]), page: { limit: 2 } } }, { signal }));\n const fields = result.table.schema.fields;\n const columns = fields.map((_, index) => result.table.getChildAt(index)!);\n return Array.from({ length: result.table.numRows }, (_, row) => Object.fromEntries(fields.map((field, column) => [field.name, plainValue(columns[column]!.get(row), field.type)])) as RecordRow);\n };\n}\n\nconst KINDS: Partial<Record<FieldType, FormFieldSpec[\"type\"]>> = {\n [FieldType.TEXT]: \"text\",\n [FieldType.NUMBER]: \"number\",\n [FieldType.INTEGER]: \"integer\",\n [FieldType.BOOLEAN]: \"boolean\",\n [FieldType.DATE]: \"date\",\n [FieldType.DATETIME]: \"datetime\",\n [FieldType.CHOICE]: \"choice\",\n};\n\n/** Text longer than this is given a box of several lines: the contract has one text type and says only how long. */\nexport const LONG_TEXT = 120;\n\n/** A field as the backend defines it (`FormField`), as the spec `FieldInput` draws. */\nexport function fieldSpec(field: FormField): FormFieldSpec {\n const kind = KINDS[field.type] ?? \"text\";\n return {\n name: field.name,\n label: field.label || field.name,\n type: kind === \"text\" && (field.maxLength ?? 0) > LONG_TEXT ? \"longtext\" : kind,\n ...(field.required ? { required: true } : {}),\n ...(field.options.length ? { options: [...field.options] } : {}),\n ...(field.min !== undefined ? { min: field.min } : {}),\n ...(field.max !== undefined ? { max: field.max } : {}),\n ...(field.maxLength !== undefined ? { maxLength: field.maxLength } : {}),\n ...(field.pattern ? { pattern: field.pattern } : {}),\n ...(field.help ? { help: field.help } : {}),\n };\n}\n\nconst empty = (value: unknown) => value === null || value === undefined || value === \"\";\n\n/** Whether what a person entered is what the record already holds, so a field set back is no longer a change. */\nexport function sameValue(entered: unknown, held: unknown, type: FieldType): boolean {\n if (type === FieldType.BOOLEAN) return (entered === true) === (held === true);\n if (empty(entered) || empty(held)) return empty(entered) && empty(held);\n if (type === FieldType.NUMBER || type === FieldType.INTEGER) return Number(entered) === Number(held);\n if (type === FieldType.DATETIME) {\n const [a, b] = [Date.parse(String(entered)), Date.parse(String(held))];\n return Number.isNaN(a) || Number.isNaN(b) ? String(entered) === String(held) : a === b;\n }\n if (type === FieldType.DATE) return String(entered).slice(0, 10) === String(held).slice(0, 10);\n return String(entered) === String(held);\n}\n\n/** The draft with one field changed: a value the record already holds is taken out, so the draft is only what changed. */\nexport function draftWith(draft: JsonObject, record: RecordRow | undefined, field: Pick<FormField, \"name\" | \"type\">, value: JsonValue): JsonObject {\n const { [field.name]: _gone, ...rest } = draft;\n return sameValue(value, record?.[field.name], field.type) ? rest : { ...rest, [field.name]: value };\n}\n\n/** A column's name as a label, for a column the operation does not describe: \"opened_at\" is \"Opened at\". */\nconst columnLabel = (name: string) => {\n const words = name.replace(/_+/g, \" \").trim();\n return words ? words[0]!.toUpperCase() + words.slice(1) : name;\n};\n\nexport interface RecordPlan {\n /** The operation's arguments a person may change here: every one but the key and the version. */\n editable: FormField[];\n /** What the form shows, in order: an argument to edit, or a column of the record to read. */\n shown: ({ kind: \"field\"; field: FormField } | { kind: \"column\"; name: string; label: string })[];\n}\n\n/**\n * Which fields a record form shows. `fields` chooses and orders them; left out, it is every argument a person may\n * change. A name the operation takes is a field to edit; one it does not take (and the key and the version, which\n * a person never edits) is a column of the record, shown to read. A new record has no columns to show.\n */\nexport function recordPlan(definition: RecordOperation, options: { fields?: readonly string[]; key?: string; version?: string; record?: RecordRow }): RecordPlan {\n const fixed = new Set([options.key, options.version].filter((name): name is string => typeof name === \"string\"));\n const editable = definition.args.filter((field) => !fixed.has(field.name));\n const names = options.fields ?? editable.map((field) => field.name);\n const shown: RecordPlan[\"shown\"] = [];\n for (const name of new Set(names)) {\n const field = editable.find((candidate) => candidate.name === name);\n if (field) shown.push({ kind: \"field\", field });\n else if (options.record && Object.hasOwn(options.record, name)) shown.push({ kind: \"column\", name, label: definition.args.find((candidate) => candidate.name === name)?.label || columnLabel(name) });\n }\n return { editable, shown };\n}\n\nexport interface RecordSave {\n /** What to run the operation with. Nothing when there is something to correct first. */\n args?: JsonObject;\n /** What is wrong, by argument: the check every backend runs (`checkOperationArgs`), run here first. */\n errors: Record<string, string>;\n /** The fields a person changed, by name. */\n changed: string[];\n}\n\n/**\n * What saving sends: the record whole, as the operation takes it. Every argument goes, with what the person changed\n * laid over what the record held, the key, and the version (so the server can refuse a stale edit). It is the whole\n * record and not only the changes because every backend checks a call whole and hands the operation `null` for an\n * argument that was not sent (`checkSubmission`), so an operation cannot tell \"not sent\" from \"emptied\". For the same\n * reason an argument the record's query did not read is refused here: saving would empty it. The values are checked\n * first, as the server will check them (`checkOperationArgs`). A new record sends everything entered.\n */\nexport function recordSave(definition: RecordOperation, options: { record?: RecordRow; draft: JsonObject; key?: { column: string; value: string | number | boolean }; version?: string }): RecordSave {\n const { record, draft, key, version } = options;\n const takes = new Map(definition.args.map((field) => [field.name, field]));\n const changed = Object.keys(draft).filter((name) => takes.has(name) && name !== key?.column && name !== version);\n const whole: JsonObject = {};\n const unread: string[] = [];\n for (const field of definition.args) {\n if (record && !Object.hasOwn(record, field.name) && field.name !== key?.column) unread.push(field.name);\n const held = record?.[field.name];\n if (held !== undefined && held !== null) whole[field.name] = held;\n }\n for (const name of changed) whole[name] = draft[name]!;\n if (key && takes.has(key.column)) whole[key.column] = key.value;\n const checked = checkOperationArgs(definition, whole);\n const errors = Object.fromEntries(checked.errors.map((error) => [error.field, error.message]));\n for (const name of unread) errors[name] = \"The record's query does not read this, and the operation that saves it takes it, so saving would empty it. Nothing was sent.\";\n if (key && !takes.has(key.column)) errors[key.column] = \"The operation that saves this takes no such argument, so it cannot be told which record to change.\";\n if (version && record && !takes.has(version)) errors[version] = \"The operation that saves this takes no such argument, so it cannot be told which version was read.\";\n return Object.keys(errors).length > 0 ? { errors, changed } : { args: checked.values, errors, changed };\n}\n"]}
@@ -1,4 +1,5 @@
1
- export type ReceiptOutcome = "done" | "partial" | "failed";
1
+ /** `none`: it ran and changed nothing (every row it was given was left alone). */
2
+ export type ReceiptOutcome = "done" | "partial" | "none" | "failed";
2
3
  export interface ReceiptDecision {
3
4
  /** Who decided. */
4
5
  by: string;
@@ -5,6 +5,7 @@ import { CodeBlock } from "../text/Markdown.js";
5
5
  const OUTCOME = {
6
6
  done: { mark: "✓", text: "receipt.done" },
7
7
  partial: { mark: "◐", text: "receipt.partial" },
8
+ none: { mark: "○", text: "receipt.none" },
8
9
  failed: { mark: "✕", text: "receipt.failed" },
9
10
  };
10
11
  const when = (iso) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ActionReceipt.js","sourceRoot":"","sources":["../../src/review/ActionReceipt.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAiB,UAAU,EAAE,KAAK,IAAI,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAmDhD,MAAM,OAAO,GAA6D;IACxE,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACzC,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE;IAC/C,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE;CAC9C,CAAC;AAEF,MAAM,IAAI,GAAG,CAAC,GAAuB,EAAE,EAAE;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACnH,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,E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AAI,EAAE,GAAG,EAAE,QAAQ,EAAC,KAAK,EAAC,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAI,EAC9E,CAAC,IAAI,CAAC,CAAC,CAAC,CACP,YAAG,SAAS,EAAC,sBAAsB,YAAE,IAAI,CAAC,oBAAoB,CAAC,GAAK,CACrE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CACX,YAAG,SAAS,EAAC,sBAAsB,YAAE,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAK,CACjG,CAAC,CAAC,CAAC,CACF,eAAK,SAAS,EAAC,iBAAiB,aAC7B,IAAI,CAAC,WAAW,IAAI,YAAG,SAAS,EAAC,sBAAsB,YAAE,IAAI,CAAC,WAAW,GAAK,EAC9E,IAAI,CAAC,KAAK,IAAI,YAAG,SAAS,EAAC,sBAAsB,YAAE,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAK,EAC7G,KAAK,CAAC,CAAC,CAAC,CACP,YAAG,SAAS,EAAC,sBAAsB,EAAC,IAAI,EAAC,QAAQ,YAC9C,IAAI,CAAC,uBAAuB,CAAC,GAC5B,CACL,CAAC,CAAC,CAAC,CACF,MAAM,IAAI,CACR,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,WAAW,EACrB,OAAO,EAAE,GAAG,EAAE;4BACZ,QAAQ,CAAC,IAAI,CAAC,CAAC;4BACf,MAAM,EAAE,CAAC;wBACX,CAAC,YAEA,IAAI,CAAC,KAAK,GACJ,CACV,CACF,IACG,CACP,IACO,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { type LabelKey, dateFormat, label as text } from \"../locale/locale.js\";\nimport { CodeBlock } from \"../text/Markdown.js\";\n\nexport type ReceiptOutcome = \"done\" | \"partial\" | \"failed\";\n\nexport interface ReceiptDecision {\n /** Who decided. */\n by: string;\n /** ISO time. */\n at?: string;\n reason?: string;\n}\n\nexport interface ReceiptChange {\n /** What changed, such as \"Rows in orders_clean\". */\n label: string;\n before?: string;\n after: string;\n}\n\nexport interface ReceiptUndo {\n /** The button text, such as \"Restore version 41\". */\n label: string;\n /** What undoing does and what it cannot bring back. */\n description?: string;\n /** ISO time after which it can no longer be undone. */\n until?: string;\n}\n\nexport interface ActionReceiptProps {\n /** What was done, such as \"Rebuilt orders_clean\". */\n title: string;\n outcome: ReceiptOutcome;\n summary?: string;\n /** When it ran, ISO time. */\n ranAt?: string;\n /** What ran it: an agent, a pipeline, a service. */\n ranBy?: string;\n /** Who approved it, with when and why. */\n approvedBy?: ReceiptDecision[];\n /** What ran, for the record. Never run from here. */\n sql?: string;\n changes?: ReceiptChange[];\n /** How to undo it, when it can be. Leave out when it cannot; the receipt then says so. */\n undo?: ReceiptUndo;\n /** The person asked to undo it. Undoing is the host's or agent's job; this only reports the request. */\n onUndo?(): void;\n /** The time to check `undo.until` against; for tests. */\n now?: () => number;\n className?: string;\n}\n\nconst OUTCOME: Record<ReceiptOutcome, { mark: string; text: LabelKey }> = {\n done: { mark: \"✓\", text: \"receipt.done\" },\n partial: { mark: \"◐\", text: \"receipt.partial\" },\n failed: { mark: \"✕\", text: \"receipt.failed\" },\n};\n\nconst when = (iso: string | undefined) => {\n if (!iso) return \"\";\n const time = Date.parse(iso);\n return Number.isNaN(time) ? iso : dateFormat({ dateStyle: \"medium\", timeStyle: \"short\" }).format(new Date(time));\n};\n\n/**\n * What an agent or pipeline did after a person approved it: the outcome,\n * who approved it and why, what ran, what changed, and whether it can be\n * undone. The last step of every approval, so a decision is never left\n * without a record of what followed. Display only: pressing Undo reports a\n * request; whatever undoes it is the host or the agent, after asking again.\n */\nexport function ActionReceipt({ title, outcome, summary, ranAt, ranBy, approvedBy = [], sql, changes = [], undo, onUndo, now = Date.now, className }: ActionReceiptProps) {\n const [asked, setAsked] = useState(false);\n const closed = undo?.until ? Date.parse(undo.until) <= now() : false;\n const status = OUTCOME[outcome];\n return (\n <section className={[\"sf-receipt\", className].filter(Boolean).join(\" \")} aria-label={title} data-outcome={outcome}>\n <p className=\"sf-receipt-head\">\n <span className=\"sf-receipt-mark\" aria-hidden=\"true\">\n {status.mark}\n </span>\n <span className=\"sf-receipt-title\">{title}</span>\n <span className=\"sf-receipt-status\">{text(status.text)}</span>\n </p>\n {summary && <p className=\"sf-receipt-summary\">{summary}</p>}\n <dl className=\"sf-receipt-facts\">\n {(ranAt || ranBy) && (\n <>\n <dt>{text(\"receipt.ran\")}</dt>\n <dd>{[when(ranAt), ranBy ? text(\"receipt.by\", { who: ranBy }) : \"\"].filter(Boolean).join(\" \")}</dd>\n </>\n )}\n <dt>{text(\"receipt.approved\")}</dt>\n <dd>\n {approvedBy.length === 0 ? (\n text(\"receipt.noApproval\")\n ) : (\n <ul>\n {approvedBy.map((d, i) => (\n <li key={`${d.by}-${i}`}>\n {d.by}\n {d.at ? `, ${when(d.at)}` : \"\"}\n {d.reason ? `: “${d.reason}”` : \"\"}\n </li>\n ))}\n </ul>\n )}\n </dd>\n </dl>\n {changes.length > 0 && (\n <table className=\"sf-receipt-changes\">\n <caption className=\"sf-a2-visually-hidden\">{text(\"receipt.whatChanged\")}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{text(\"receipt.what\")}</th>\n <th scope=\"col\">{text(\"receipt.before\")}</th>\n <th scope=\"col\">{text(\"receipt.after\")}</th>\n </tr>\n </thead>\n <tbody>\n {changes.map((c) => (\n <tr key={c.label}>\n <th scope=\"row\">{c.label}</th>\n <td>{c.before ?? \"–\"}</td>\n <td>{c.after}</td>\n </tr>\n ))}\n </tbody>\n </table>\n )}\n {sql && <CodeBlock code={sql} language=\"sql\" label={text(\"receipt.whatRan\")} />}\n {!undo ? (\n <p className=\"sf-receipt-undo-note\">{text(\"receipt.cannotUndo\")}</p>\n ) : closed ? (\n <p className=\"sf-receipt-undo-note\">{text(\"receipt.undoClosed\", { time: when(undo.until) })}</p>\n ) : (\n <div className=\"sf-receipt-undo\">\n {undo.description && <p className=\"sf-receipt-undo-note\">{undo.description}</p>}\n {undo.until && <p className=\"sf-receipt-undo-note\">{text(\"receipt.undoUntil\", { time: when(undo.until) })}</p>}\n {asked ? (\n <p className=\"sf-receipt-undo-note\" role=\"status\">\n {text(\"receipt.undoRequested\")}\n </p>\n ) : (\n onUndo && (\n <button\n type=\"button\"\n className=\"sf-button\"\n onClick={() => {\n setAsked(true);\n onUndo();\n }}\n >\n {undo.label}\n </button>\n )\n )}\n </div>\n )}\n </section>\n );\n}\n"]}
1
+ {"version":3,"file":"ActionReceipt.js","sourceRoot":"","sources":["../../src/review/ActionReceipt.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAiB,UAAU,EAAE,KAAK,IAAI,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAoDhD,MAAM,OAAO,GAA6D;IACxE,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACzC,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE;IAC/C,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE;IACzC,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE;CAC9C,CAAC;AAEF,MAAM,IAAI,GAAG,CAAC,GAAuB,EAAE,EAAE;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAA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,EACrB,OAAO,EAAE,GAAG,EAAE;4BACZ,QAAQ,CAAC,IAAI,CAAC,CAAC;4BACf,MAAM,EAAE,CAAC;wBACX,CAAC,YAEA,IAAI,CAAC,KAAK,GACJ,CACV,CACF,IACG,CACP,IACO,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { type LabelKey, dateFormat, label as text } from \"../locale/locale.js\";\nimport { CodeBlock } from \"../text/Markdown.js\";\n\n/** `none`: it ran and changed nothing (every row it was given was left alone). */\nexport type ReceiptOutcome = \"done\" | \"partial\" | \"none\" | \"failed\";\n\nexport interface ReceiptDecision {\n /** Who decided. */\n by: string;\n /** ISO time. */\n at?: string;\n reason?: string;\n}\n\nexport interface ReceiptChange {\n /** What changed, such as \"Rows in orders_clean\". */\n label: string;\n before?: string;\n after: string;\n}\n\nexport interface ReceiptUndo {\n /** The button text, such as \"Restore version 41\". */\n label: string;\n /** What undoing does and what it cannot bring back. */\n description?: string;\n /** ISO time after which it can no longer be undone. */\n until?: string;\n}\n\nexport interface ActionReceiptProps {\n /** What was done, such as \"Rebuilt orders_clean\". */\n title: string;\n outcome: ReceiptOutcome;\n summary?: string;\n /** When it ran, ISO time. */\n ranAt?: string;\n /** What ran it: an agent, a pipeline, a service. */\n ranBy?: string;\n /** Who approved it, with when and why. */\n approvedBy?: ReceiptDecision[];\n /** What ran, for the record. Never run from here. */\n sql?: string;\n changes?: ReceiptChange[];\n /** How to undo it, when it can be. Leave out when it cannot; the receipt then says so. */\n undo?: ReceiptUndo;\n /** The person asked to undo it. Undoing is the host's or agent's job; this only reports the request. */\n onUndo?(): void;\n /** The time to check `undo.until` against; for tests. */\n now?: () => number;\n className?: string;\n}\n\nconst OUTCOME: Record<ReceiptOutcome, { mark: string; text: LabelKey }> = {\n done: { mark: \"✓\", text: \"receipt.done\" },\n partial: { mark: \"◐\", text: \"receipt.partial\" },\n none: { mark: \"○\", text: \"receipt.none\" },\n failed: { mark: \"✕\", text: \"receipt.failed\" },\n};\n\nconst when = (iso: string | undefined) => {\n if (!iso) return \"\";\n const time = Date.parse(iso);\n return Number.isNaN(time) ? iso : dateFormat({ dateStyle: \"medium\", timeStyle: \"short\" }).format(new Date(time));\n};\n\n/**\n * What an agent or pipeline did after a person approved it: the outcome,\n * who approved it and why, what ran, what changed, and whether it can be\n * undone. The last step of every approval, so a decision is never left\n * without a record of what followed. Display only: pressing Undo reports a\n * request; whatever undoes it is the host or the agent, after asking again.\n */\nexport function ActionReceipt({ title, outcome, summary, ranAt, ranBy, approvedBy = [], sql, changes = [], undo, onUndo, now = Date.now, className }: ActionReceiptProps) {\n const [asked, setAsked] = useState(false);\n const closed = undo?.until ? Date.parse(undo.until) <= now() : false;\n const status = OUTCOME[outcome];\n return (\n <section className={[\"sf-receipt\", className].filter(Boolean).join(\" \")} aria-label={title} data-outcome={outcome}>\n <p className=\"sf-receipt-head\">\n <span className=\"sf-receipt-mark\" aria-hidden=\"true\">\n {status.mark}\n </span>\n <span className=\"sf-receipt-title\">{title}</span>\n <span className=\"sf-receipt-status\">{text(status.text)}</span>\n </p>\n {summary && <p className=\"sf-receipt-summary\">{summary}</p>}\n <dl className=\"sf-receipt-facts\">\n {(ranAt || ranBy) && (\n <>\n <dt>{text(\"receipt.ran\")}</dt>\n <dd>{[when(ranAt), ranBy ? text(\"receipt.by\", { who: ranBy }) : \"\"].filter(Boolean).join(\" \")}</dd>\n </>\n )}\n <dt>{text(\"receipt.approved\")}</dt>\n <dd>\n {approvedBy.length === 0 ? (\n text(\"receipt.noApproval\")\n ) : (\n <ul>\n {approvedBy.map((d, i) => (\n <li key={`${d.by}-${i}`}>\n {d.by}\n {d.at ? `, ${when(d.at)}` : \"\"}\n {d.reason ? `: “${d.reason}”` : \"\"}\n </li>\n ))}\n </ul>\n )}\n </dd>\n </dl>\n {changes.length > 0 && (\n <table className=\"sf-receipt-changes\">\n <caption className=\"sf-a2-visually-hidden\">{text(\"receipt.whatChanged\")}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{text(\"receipt.what\")}</th>\n <th scope=\"col\">{text(\"receipt.before\")}</th>\n <th scope=\"col\">{text(\"receipt.after\")}</th>\n </tr>\n </thead>\n <tbody>\n {changes.map((c) => (\n <tr key={c.label}>\n <th scope=\"row\">{c.label}</th>\n <td>{c.before ?? \"–\"}</td>\n <td>{c.after}</td>\n </tr>\n ))}\n </tbody>\n </table>\n )}\n {sql && <CodeBlock code={sql} language=\"sql\" label={text(\"receipt.whatRan\")} />}\n {!undo ? (\n <p className=\"sf-receipt-undo-note\">{text(\"receipt.cannotUndo\")}</p>\n ) : closed ? (\n <p className=\"sf-receipt-undo-note\">{text(\"receipt.undoClosed\", { time: when(undo.until) })}</p>\n ) : (\n <div className=\"sf-receipt-undo\">\n {undo.description && <p className=\"sf-receipt-undo-note\">{undo.description}</p>}\n {undo.until && <p className=\"sf-receipt-undo-note\">{text(\"receipt.undoUntil\", { time: when(undo.until) })}</p>}\n {asked ? (\n <p className=\"sf-receipt-undo-note\" role=\"status\">\n {text(\"receipt.undoRequested\")}\n </p>\n ) : (\n onUndo && (\n <button\n type=\"button\"\n className=\"sf-button\"\n onClick={() => {\n setAsked(true);\n onUndo();\n }}\n >\n {undo.label}\n </button>\n )\n )}\n </div>\n )}\n </section>\n );\n}\n"]}
@@ -78,16 +78,21 @@ export interface PromptRevealProps {
78
78
  prompt: string;
79
79
  /** The answer, shown once the prompt is typed. */
80
80
  children: ReactNode;
81
- /** Starts again after a pause. Defaults to true. */
81
+ /**
82
+ * Starts again after a pause, with a Pause button. Defaults to false: it plays once and stops on the answer,
83
+ * with a Replay button.
84
+ */
82
85
  loop?: boolean;
83
86
  /** What is shown, for the status line. */
84
87
  label?: string;
85
88
  className?: string;
86
89
  }
87
90
  /**
88
- * A prompt typed out and its answer shown, then again. Under reduced motion, once paused, or once a person reaches
89
- * into the answer, it shows the finished answer and stands still. It has a Pause button, since it moves for longer
90
- * than five seconds. Assistive technology reads the whole prompt at once, never letter by letter.
91
+ * A prompt typed out and its answer shown. It plays once and stops on the finished answer, with a Replay button to
92
+ * play it again. With `loop` it starts again after a pause and has a Pause button instead, since it then moves for
93
+ * longer than five seconds; once paused, or once a person reaches into the answer, it shows the finished answer and
94
+ * stands still. Under reduced motion it shows the finished answer and has no button. Assistive technology reads the
95
+ * whole prompt at once, never letter by letter.
91
96
  */
92
97
  export declare function PromptReveal({ prompt, children, loop, label, className }: PromptRevealProps): import("react").JSX.Element;
93
98
  export interface ShowcaseItem {
package/dist/site/Site.js CHANGED
@@ -44,16 +44,21 @@ function useReducedMotion() {
44
44
  /** How fast the prompt types, how long the answer holds before it starts again, in milliseconds. */
45
45
  export const PROMPT_REVEAL_TIMING = { type: 28, start: 400, hold: 9000, restart: 600 };
46
46
  /**
47
- * A prompt typed out and its answer shown, then again. Under reduced motion, once paused, or once a person reaches
48
- * into the answer, it shows the finished answer and stands still. It has a Pause button, since it moves for longer
49
- * than five seconds. Assistive technology reads the whole prompt at once, never letter by letter.
47
+ * A prompt typed out and its answer shown. It plays once and stops on the finished answer, with a Replay button to
48
+ * play it again. With `loop` it starts again after a pause and has a Pause button instead, since it then moves for
49
+ * longer than five seconds; once paused, or once a person reaches into the answer, it shows the finished answer and
50
+ * stands still. Under reduced motion it shows the finished answer and has no button. Assistive technology reads the
51
+ * whole prompt at once, never letter by letter.
50
52
  */
51
- export function PromptReveal({ prompt, children, loop = true, label, className }) {
53
+ export function PromptReveal({ prompt, children, loop = false, label, className }) {
52
54
  const reduce = useReducedMotion();
53
55
  const [paused, setPaused] = useState(false);
54
- const still = reduce || paused;
56
+ const still = reduce || (loop && paused);
55
57
  const [typed, setTyped] = useState(0);
56
58
  const [round, setRound] = useState(0);
59
+ // Each replay plays it from the start again.
60
+ const [play, setPlay] = useState(0);
61
+ // biome-ignore lint/correctness/useExhaustiveDependencies: `play` is how Replay starts it again
57
62
  useEffect(() => {
58
63
  if (still)
59
64
  return;
@@ -77,15 +82,16 @@ export function PromptReveal({ prompt, children, loop = true, label, className }
77
82
  setTyped(0);
78
83
  timer = setTimeout(step, PROMPT_REVEAL_TIMING.start);
79
84
  return () => clearTimeout(timer);
80
- }, [still, prompt, loop]);
85
+ }, [still, prompt, loop, play]);
81
86
  const shown = still ? prompt.length : typed;
82
87
  const done = shown >= prompt.length;
83
- const status = reduce ? "Shown finished, since your system asks for less motion." : paused ? "Paused." : done ? "Answered." : "Typing.";
88
+ const status = reduce ? "Shown finished, since your system asks for less motion." : loop && paused ? "Paused." : done ? "Answered." : "Typing.";
84
89
  return (_jsxs("div", { className: ["sf-site-prompt-reveal", className].filter(Boolean).join(" "), children: [_jsx("p", { className: "sf-visually-hidden", children: prompt }), _jsxs("p", { className: "sf-site-prompt", "aria-hidden": "true", children: [_jsx("span", { children: prompt.slice(0, shown) || " " }), !done && _jsx("span", { className: "sf-site-caret" })] }), _jsx("div", { className: "sf-site-answer", "data-shown": done || undefined, ref: (element) => {
85
90
  // Set here, not as a prop: React 18 does not know `inert`.
86
91
  if (element)
87
92
  element.inert = !done;
88
- }, "aria-hidden": done ? undefined : true, onPointerDown: () => setPaused(true), onFocus: () => setPaused(true), children: children }, done ? `shown-${round}` : "waiting"), _jsxs("div", { className: "sf-site-reveal-foot", children: [_jsxs("p", { className: "sf-site-reveal-status", role: "status", children: [label ? `${label}. ` : "", status] }), !reduce && (_jsx("button", { type: "button", className: "sf-button", "aria-pressed": paused, onClick: () => setPaused((p) => !p), children: paused ? "Play" : "Pause" }))] })] }));
93
+ }, "aria-hidden": done ? undefined : true, onPointerDown: loop ? () => setPaused(true) : undefined, onFocus: loop ? () => setPaused(true) : undefined, children: children }, done ? `shown-${round}` : "waiting"), _jsxs("div", { className: "sf-site-reveal-foot", children: [_jsxs("p", { className: "sf-site-reveal-status", role: "status", children: [label ? `${label}. ` : "", status] }), !reduce &&
94
+ (loop ? (_jsx("button", { type: "button", className: "sf-button", "aria-pressed": paused, onClick: () => setPaused((p) => !p), children: paused ? "Play" : "Pause" })) : (_jsx("button", { type: "button", className: "sf-button", onClick: () => setPlay((p) => p + 1), children: "Replay" })))] })] }));
89
95
  }
90
96
  /** A picker of named examples above a stage that shows the chosen one. The picker wraps rather than run past the edge. */
91
97
  export function Showcase({ items, label, value, defaultValue, onChange, className }) {
@@ -1 +1 @@
1
- {"version":3,"file":"Site.js","sourceRoot":"","sources":["../../src/site/Site.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAStG,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,KAA8B,EAAE,QAAmB,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAkBrI,sGAAsG;AACtG,MAAM,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,EAAa;IAC9G,OAAO,CACL,mBAAS,SAAS,EAAE,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAc,KAAK,aACzF,OAAO,IAAI,IAAI,IAAI,YAAG,SAAS,EAAC,iBAAiB,YAAE,OAAO,GAAK,EAC/D,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAE,EAAE,KAAK,CAAC,EAC1D,IAAI,IAAI,IAAI,IAAI,YAAG,SAAS,EAAC,cAAc,YAAE,IAAI,GAAK,EACtD,OAAO,IAAI,IAAI,IAAI,cAAK,SAAS,EAAC,iBAAiB,YAAE,OAAO,GAAO,EACnE,KAAK,IAAI,IAAI,IAAI,cAAK,SAAS,EAAC,oBAAoB,YAAE,KAAK,GAAO,IAC3D,CACX,CAAC;AACJ,CAAC;AAYD,kHAAkH;AAClH,MAAM,UAAU,OAAO,CAAC,EAAE,OAAO,EAA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AC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,uBAAe,GAAG,IAAT,GAAG,CAAY,CACzB,CAAC,GACC,CACN,IACO,CACX,CAAC;AACJ,CAAC;AASD,kDAAkD;AAClD,MAAM,UAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAiB;IACzE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,YAAG,SAAS,EAAC,eAAe,kCAAsB,CAAC;IAClF,OAAO,CACL,aAAI,SAAS,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAc,KAAK,YACrF,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,uBACE,KAAC,QAAQ,OAAK,IAAI,EAAE,MAAM,EAAE,MAAM,GAAI,IAD/B,IAAI,CAAC,EAAE,CAEX,CACN,CAAC,GACC,CACN,CAAC;AACJ,CAAC","sourcesContent":["import { type CSSProperties, type ReactNode, createElement, useEffect, useId, useState } from \"react\";\n\n/**\n * Components for sites: a landing page, a docs page, a blog. Each is plain React, styled by `--sf-*` tokens only,\n * and responds to its container. Links are taken as given: an app passes its own addresses, and the catalog's\n * renderers check an agent's with `safeUrl` before they reach here.\n */\n\ntype Heading = 1 | 2 | 3 | 4;\nconst heading = (level: Heading, props: Record<string, unknown>, children: ReactNode) => createElement(`h${level}`, props, children);\n\nexport interface HeroProps {\n title: ReactNode;\n /** One or two sentences under the title, at most 40rem wide. */\n lead?: ReactNode;\n /** A short line above the title. */\n eyebrow?: ReactNode;\n /** Buttons or links: the first is the primary action. */\n actions?: ReactNode;\n /** An image, a device frame or a live surface beneath the words. */\n media?: ReactNode;\n align?: \"center\" | \"start\";\n /** The title's heading level. Defaults to 1. */\n level?: Heading;\n className?: string;\n}\n\n/** The opening of a page: a large title that scales with its container, a lead, actions and media. */\nexport function Hero({ title, lead, eyebrow, actions, media, align = \"center\", level = 1, className }: HeroProps) {\n return (\n <section className={[\"sf-site-hero\", className].filter(Boolean).join(\" \")} data-align={align}>\n {eyebrow != null && <p className=\"sf-site-eyebrow\">{eyebrow}</p>}\n {heading(level, { className: \"sf-site-hero-title\" }, title)}\n {lead != null && <p className=\"sf-site-lead\">{lead}</p>}\n {actions != null && <div className=\"sf-site-actions\">{actions}</div>}\n {media != null && <div className=\"sf-site-hero-media\">{media}</div>}\n </section>\n );\n}\n\nexport interface SectionProps {\n heading: ReactNode;\n eyebrow?: ReactNode;\n lead?: ReactNode;\n children?: ReactNode;\n /** The heading's level. Defaults to 2. */\n level?: Heading;\n className?: string;\n}\n\n/** A part of a page under its own heading, with room around it. Named by its heading for assistive technology. */\nexport function Section({ heading: title, eyebrow, lead, children, level = 2, className }: SectionProps) {\n const id = useId();\n return (\n <section className={[\"sf-site-section\", className].filter(Boolean).join(\" \")} aria-labelledby={id}>\n <div className=\"sf-site-section-head\">\n {eyebrow != null && <p className=\"sf-site-eyebrow\">{eyebrow}</p>}\n {heading(level, { id, className: \"sf-site-section-title\" }, title)}\n {lead != null && <p className=\"sf-site-section-lead\">{lead}</p>}\n </div>\n {children}\n </section>\n );\n}\n\nexport interface FeatureItem {\n id: string;\n title: string;\n line?: string;\n /** A link. Without one the item is a button that calls `onSelect`. */\n href?: string;\n}\n\nexport interface FeatureGridProps {\n items: FeatureItem[];\n /** What the list is, for assistive technology. */\n label?: string;\n onSelect?(id: string): void;\n className?: string;\n}\n\n/** Cards of a title and a line each, as many to a row as the container fits. Each is a link or a button. */\nexport function FeatureGrid({ items, label, onSelect, className }: FeatureGridProps) {\n return (\n <ul className={[\"sf-site-features\", className].filter(Boolean).join(\" \")} aria-label={label}>\n {items.map((item) => {\n const body = (\n <>\n <span className=\"sf-site-feature-title\">{item.title}</span>\n {item.line && <span className=\"sf-site-feature-line\">{item.line}</span>}\n </>\n );\n return (\n <li key={item.id}>\n {item.href ? (\n <a className=\"sf-site-feature\" href={item.href}>\n {body}\n </a>\n ) : (\n <button type=\"button\" className=\"sf-site-feature\" onClick={() => onSelect?.(item.id)} disabled={!onSelect}>\n {body}\n </button>\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport type Device = \"desktop\" | \"phone\";\n\nexport interface DeviceFrameProps {\n /** Draws `children` in each, side by side. Defaults to a desktop and a phone. Under 40rem of room only the last stands. */\n devices?: Device[];\n /** The desktop window's title. */\n title?: string;\n /** What the screen shows, for assistive technology; each screen is named after its device and this. */\n label?: string;\n /** Draws the content for one device. Called once per device. */\n children: ReactNode | ((device: Device) => ReactNode);\n className?: string;\n}\n\nconst DEVICE_NAME: Record<Device, string> = { desktop: \"Desktop\", phone: \"Phone\" };\n\n/**\n * A desktop window and a phone around the same content, for showing a product. The screens scroll on their own and\n * can be focused to scroll by keyboard. The frames are drawing only: they are hidden from assistive technology.\n */\nexport function DeviceFrame({ devices = [\"desktop\", \"phone\"], title, label, children, className }: DeviceFrameProps) {\n const shown = devices.length ? [...new Set(devices)] : ([\"desktop\", \"phone\"] as Device[]);\n const content = (device: Device) => (typeof children === \"function\" ? children(device) : children);\n const screen = (device: Device) => (\n // biome-ignore lint/a11y/noNoninteractiveTabindex: a scrolling region is focused to scroll it by keyboard\n <section className=\"sf-site-screen sf-container\" aria-label={label ? `${DEVICE_NAME[device]}: ${label}` : DEVICE_NAME[device]} tabIndex={0}>\n {content(device)}\n </section>\n );\n return (\n <div className={[\"sf-site-devices\", className].filter(Boolean).join(\" \")}>\n <div className=\"sf-site-devices-row\" data-count={shown.length}>\n {shown.map((device) =>\n device === \"desktop\" ? (\n <figure key={device} className=\"sf-site-desktop\">\n <div className=\"sf-site-desktop-bar\" aria-hidden=\"true\">\n <span />\n <span />\n <span />\n <p>{title ?? \"\"}</p>\n </div>\n <div className=\"sf-site-desktop-body\">{screen(device)}</div>\n <figcaption>{DEVICE_NAME.desktop}</figcaption>\n </figure>\n ) : (\n <figure key={device} className=\"sf-site-phone\">\n <div className=\"sf-site-phone-frame\">\n <div className=\"sf-site-phone-island\" aria-hidden=\"true\" />\n <div className=\"sf-site-phone-body\">{screen(device)}</div>\n </div>\n <figcaption>{DEVICE_NAME.phone}</figcaption>\n </figure>\n ),\n )}\n </div>\n </div>\n );\n}\n\nfunction useReducedMotion(): boolean {\n const query = \"(prefers-reduced-motion: reduce)\";\n const [reduce, setReduce] = useState(() => (typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" ? window.matchMedia(query).matches : false));\n useEffect(() => {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return;\n const media = window.matchMedia(query);\n const change = () => setReduce(media.matches);\n media.addEventListener(\"change\", change);\n return () => media.removeEventListener(\"change\", change);\n }, []);\n return reduce;\n}\n\n/** How fast the prompt types, how long the answer holds before it starts again, in milliseconds. */\nexport const PROMPT_REVEAL_TIMING = { type: 28, start: 400, hold: 9000, restart: 600 } as const;\n\nexport interface PromptRevealProps {\n /** What a person asks, typed out first. */\n prompt: string;\n /** The answer, shown once the prompt is typed. */\n children: ReactNode;\n /** Starts again after a pause. Defaults to true. */\n loop?: boolean;\n /** What is shown, for the status line. */\n label?: string;\n className?: string;\n}\n\n/**\n * A prompt typed out and its answer shown, then again. Under reduced motion, once paused, or once a person reaches\n * into the answer, it shows the finished answer and stands still. It has a Pause button, since it moves for longer\n * than five seconds. Assistive technology reads the whole prompt at once, never letter by letter.\n */\nexport function PromptReveal({ prompt, children, loop = true, label, className }: PromptRevealProps) {\n const reduce = useReducedMotion();\n const [paused, setPaused] = useState(false);\n const still = reduce || paused;\n const [typed, setTyped] = useState(0);\n const [round, setRound] = useState(0);\n useEffect(() => {\n if (still) return;\n let count = 0;\n let timer: ReturnType<typeof setTimeout>;\n const step = () => {\n if (count < prompt.length) {\n count += 1;\n setTyped(count);\n timer = setTimeout(step, PROMPT_REVEAL_TIMING.type);\n } else if (loop) {\n timer = setTimeout(() => {\n count = 0;\n setTyped(0);\n setRound((r) => r + 1);\n timer = setTimeout(step, PROMPT_REVEAL_TIMING.restart);\n }, PROMPT_REVEAL_TIMING.hold);\n }\n };\n setTyped(0);\n timer = setTimeout(step, PROMPT_REVEAL_TIMING.start);\n return () => clearTimeout(timer);\n }, [still, prompt, loop]);\n const shown = still ? prompt.length : typed;\n const done = shown >= prompt.length;\n const status = reduce ? \"Shown finished, since your system asks for less motion.\" : paused ? \"Paused.\" : done ? \"Answered.\" : \"Typing.\";\n return (\n <div className={[\"sf-site-prompt-reveal\", className].filter(Boolean).join(\" \")}>\n <p className=\"sf-visually-hidden\">{prompt}</p>\n <p className=\"sf-site-prompt\" aria-hidden=\"true\">\n <span>{prompt.slice(0, shown) || \" \"}</span>\n {!done && <span className=\"sf-site-caret\" />}\n </p>\n {/* biome-ignore lint/a11y/noStaticElementInteractions: it only watches for a person reaching into the answer, to stop it moving */}\n {/* The answer keeps its place while the prompt types, hidden and out of reach, so the page does not jump; it is\n drawn afresh each time it is shown, so whatever rises in as it is drawn rises in again. */}\n <div\n key={done ? `shown-${round}` : \"waiting\"}\n className=\"sf-site-answer\"\n data-shown={done || undefined}\n ref={(element) => {\n // Set here, not as a prop: React 18 does not know `inert`.\n if (element) element.inert = !done;\n }}\n aria-hidden={done ? undefined : true}\n onPointerDown={() => setPaused(true)}\n onFocus={() => setPaused(true)}\n >\n {children}\n </div>\n <div className=\"sf-site-reveal-foot\">\n <p className=\"sf-site-reveal-status\" role=\"status\">\n {label ? `${label}. ` : \"\"}\n {status}\n </p>\n {!reduce && (\n <button type=\"button\" className=\"sf-button\" aria-pressed={paused} onClick={() => setPaused((p) => !p)}>\n {paused ? \"Play\" : \"Pause\"}\n </button>\n )}\n </div>\n </div>\n );\n}\n\nexport interface ShowcaseItem {\n id: string;\n name: string;\n line?: string;\n content: ReactNode;\n}\n\nexport interface ShowcaseProps {\n items: ShowcaseItem[];\n /** What the picker chooses between, for assistive technology. */\n label: string;\n value?: string;\n defaultValue?: string;\n onChange?(id: string): void;\n className?: string;\n}\n\n/** A picker of named examples above a stage that shows the chosen one. The picker wraps rather than run past the edge. */\nexport function Showcase({ items, label, value, defaultValue, onChange, className }: ShowcaseProps) {\n const name = useId();\n const [own, setOwn] = useState(defaultValue ?? items[0]?.id);\n const current = items.find((item) => item.id === (value ?? own)) ?? items[0];\n const choose = (id: string) => {\n setOwn(id);\n onChange?.(id);\n };\n return (\n <div className={[\"sf-site-showcase\", className].filter(Boolean).join(\" \")}>\n <div className=\"sf-segmented sf-site-showcase-picker\" role=\"radiogroup\" aria-label={label} data-thumb=\"off\">\n {items.map((item) => (\n <label key={item.id} className=\"sf-segment\" data-checked={item.id === current?.id || undefined}>\n <input type=\"radio\" name={name} value={item.id} checked={item.id === current?.id} onChange={() => choose(item.id)} />\n {item.name}\n </label>\n ))}\n </div>\n {current && (\n <div key={current.id} className=\"sf-site-showcase-stage\">\n <p className=\"sf-site-showcase-name\">{current.name}</p>\n {current.line && <p className=\"sf-site-showcase-line\">{current.line}</p>}\n {current.content}\n </div>\n )}\n </div>\n );\n}\n\nexport interface FooterLink {\n id: string;\n label: string;\n href?: string;\n}\n\nexport interface FooterProps {\n groups: { label?: string; items: FooterLink[] }[];\n /** A line at the very end: a copyright, a licence. */\n note?: ReactNode;\n onSelect?(id: string): void;\n label?: string;\n className?: string;\n}\n\n/** The end of a site's page: columns of links that wrap to the container, and a note. */\nexport function Footer({ groups, note, onSelect, label = \"Site\", className }: FooterProps) {\n return (\n <footer className={[\"sf-site-footer\", className].filter(Boolean).join(\" \")}>\n <nav className=\"sf-site-footer-groups\" aria-label={label}>\n {groups.map((group, index) => (\n <div key={group.label ?? index} className=\"sf-site-footer-group\">\n {group.label && <p className=\"sf-site-footer-label\">{group.label}</p>}\n <ul>\n {group.items.map((item) => (\n <li key={item.id}>\n {item.href ? (\n <a href={item.href}>{item.label}</a>\n ) : (\n <button type=\"button\" className=\"sf-site-link\" onClick={() => onSelect?.(item.id)} disabled={!onSelect}>\n {item.label}\n </button>\n )}\n </li>\n ))}\n </ul>\n </div>\n ))}\n </nav>\n {note != null && <p className=\"sf-site-footer-note\">{note}</p>}\n </footer>\n );\n}\n\nexport type MediaRatio = \"16:9\" | \"4:3\" | \"3:2\" | \"1:1\" | \"21:9\";\n\nexport interface MediaProps {\n /** The address. Without one, the description stands in its place. */\n src?: string;\n /** What it shows, for anyone who cannot see it. An empty string marks it as decoration. */\n alt: string;\n kind?: \"image\" | \"video\";\n ratio?: MediaRatio;\n caption?: ReactNode;\n className?: string;\n}\n\n/**\n * An image or a video at a fixed ratio, so nothing moves as it loads, and loaded only near the screen. A video has\n * controls and never plays on its own. With no address, its description is shown in the space it would take.\n */\nexport function Media({ src, alt, kind = \"image\", ratio = \"16:9\", caption, className }: MediaProps) {\n const style = { \"--sf-site-ratio\": ratio.replace(\":\", \" / \") } as CSSProperties;\n const body = !src ? (\n <div className=\"sf-site-media-missing\" role={alt ? \"img\" : undefined} aria-label={alt || undefined}>\n <span aria-hidden=\"true\">{alt || \"Image\"}</span>\n </div>\n ) : kind === \"video\" ? (\n // biome-ignore lint/a11y/useMediaCaption: captions are the host's to add to the file\n <video className=\"sf-site-media-body\" src={src} controls preload=\"none\" aria-label={alt || undefined} />\n ) : (\n <img className=\"sf-site-media-body\" src={src} alt={alt} loading=\"lazy\" decoding=\"async\" />\n );\n return (\n <figure className={[\"sf-site-media\", className].filter(Boolean).join(\" \")} style={style}>\n {body}\n {caption != null && <figcaption>{caption}</figcaption>}\n </figure>\n );\n}\n\nexport interface QuoteProps {\n children: ReactNode;\n /** Who said it. */\n cite?: ReactNode;\n /** Where it was said. */\n href?: string;\n className?: string;\n}\n\n/** A pull quote, with who said it. */\nexport function Quote({ children, cite, href, className }: QuoteProps) {\n return (\n <figure className={[\"sf-site-quote\", className].filter(Boolean).join(\" \")}>\n <blockquote cite={href}>{children}</blockquote>\n {cite != null && <figcaption>{href ? <a href={href}>{cite}</a> : cite}</figcaption>}\n </figure>\n );\n}\n\nexport type CalloutTone = \"note\" | \"tip\" | \"warning\";\nconst TONE_NAME: Record<CalloutTone, string> = { note: \"Note\", tip: \"Tip\", warning: \"Warning\" };\n\nexport interface CalloutProps {\n tone?: CalloutTone;\n /** Its heading. Without one, the tone's name (\"Note\") is the heading, so the kind is never told by colour alone. */\n title?: ReactNode;\n children: ReactNode;\n className?: string;\n}\n\n/** A note set apart from the text around it: a note, a tip or a warning. */\nexport function Callout({ tone = \"note\", title, children, className }: CalloutProps) {\n return (\n <aside className={[\"sf-site-callout\", className].filter(Boolean).join(\" \")} data-tone={tone} aria-label={typeof title === \"string\" ? title : TONE_NAME[tone]}>\n <p className=\"sf-site-callout-title\">{title ?? TONE_NAME[tone]}</p>\n <div className=\"sf-site-callout-body\">{children}</div>\n </aside>\n );\n}\n\nexport interface Post {\n id: string;\n title: string;\n /** An ISO date, shown in the reader's own words for it. */\n date?: string;\n excerpt?: string;\n tags?: string[];\n href?: string;\n}\n\nexport interface PostCardProps extends Post {\n onOpen?(id: string): void;\n /** The title's heading level. Defaults to 3. */\n level?: Heading;\n className?: string;\n}\n\n/** A UTC date read as words, or the text as given when it is not a date. */\nexport function postDate(date: string, locale?: string): string {\n const time = Date.parse(date);\n return Number.isNaN(time) ? date : new Intl.DateTimeFormat(locale, { dateStyle: \"long\", timeZone: \"UTC\" }).format(time);\n}\n\n/** A post in a list: its title as a link or a button, the date, a line of it and its tags. */\nexport function PostCard({ id, title, date, excerpt, tags, href, onOpen, level = 3, className }: PostCardProps) {\n return (\n <article className={[\"sf-site-post\", className].filter(Boolean).join(\" \")}>\n {heading(\n level,\n { className: \"sf-site-post-title\" },\n href ? (\n <a href={href}>{title}</a>\n ) : onOpen ? (\n <button type=\"button\" className=\"sf-site-link\" onClick={() => onOpen(id)}>\n {title}\n </button>\n ) : (\n title\n ),\n )}\n {date && (\n <p className=\"sf-site-post-date\">\n <time dateTime={date}>{postDate(date)}</time>\n </p>\n )}\n {excerpt && <p className=\"sf-site-post-excerpt\">{excerpt}</p>}\n {tags && tags.length > 0 && (\n <ul className=\"sf-site-post-tags\" aria-label=\"Tags\">\n {tags.map((tag) => (\n <li key={tag}>{tag}</li>\n ))}\n </ul>\n )}\n </article>\n );\n}\n\nexport interface PostListProps {\n posts: Post[];\n label?: string;\n onOpen?(id: string): void;\n className?: string;\n}\n\n/** Posts newest first as given, one card each. */\nexport function PostList({ posts, label, onOpen, className }: PostListProps) {\n if (posts.length === 0) return <p className=\"sf-site-empty\">Nothing here yet.</p>;\n return (\n <ul className={[\"sf-site-posts\", className].filter(Boolean).join(\" \")} aria-label={label}>\n {posts.map((post) => (\n <li key={post.id}>\n <PostCard {...post} onOpen={onOpen} />\n </li>\n ))}\n </ul>\n );\n}\n"]}
1
+ {"version":3,"file":"Site.js","sourceRoot":"","sources":["../../src/site/Site.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAStG,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,KAA8B,EAAE,QAAmB,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAkBrI,sGAAsG;AACtG,MAAM,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,EAAa;IAC9G,OAAO,CACL,mBAAS,SAAS,EAAE,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAc,KAAK,aACzF,OAAO,IAAI,IAAI,IAAI,YAAG,SAAS,EAAC,iBAAiB,YAAE,OAAO,GAAK,EAC/D,OAAO,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAE,EAAE,KAAK,CAAC,EAC1D,IAAI,IAAI,IAAI,IAAI,YAAG,SAAS,EAAC,cAAc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AC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,uBACE,KAAC,QAAQ,OAAK,IAAI,EAAE,MAAM,EAAE,MAAM,GAAI,IAD/B,IAAI,CAAC,EAAE,CAEX,CACN,CAAC,GACC,CACN,CAAC;AACJ,CAAC","sourcesContent":["import { type CSSProperties, type ReactNode, createElement, useEffect, useId, useState } from \"react\";\n\n/**\n * Components for sites: a landing page, a docs page, a blog. Each is plain React, styled by `--sf-*` tokens only,\n * and responds to its container. Links are taken as given: an app passes its own addresses, and the catalog's\n * renderers check an agent's with `safeUrl` before they reach here.\n */\n\ntype Heading = 1 | 2 | 3 | 4;\nconst heading = (level: Heading, props: Record<string, unknown>, children: ReactNode) => createElement(`h${level}`, props, children);\n\nexport interface HeroProps {\n title: ReactNode;\n /** One or two sentences under the title, at most 40rem wide. */\n lead?: ReactNode;\n /** A short line above the title. */\n eyebrow?: ReactNode;\n /** Buttons or links: the first is the primary action. */\n actions?: ReactNode;\n /** An image, a device frame or a live surface beneath the words. */\n media?: ReactNode;\n align?: \"center\" | \"start\";\n /** The title's heading level. Defaults to 1. */\n level?: Heading;\n className?: string;\n}\n\n/** The opening of a page: a large title that scales with its container, a lead, actions and media. */\nexport function Hero({ title, lead, eyebrow, actions, media, align = \"center\", level = 1, className }: HeroProps) {\n return (\n <section className={[\"sf-site-hero\", className].filter(Boolean).join(\" \")} data-align={align}>\n {eyebrow != null && <p className=\"sf-site-eyebrow\">{eyebrow}</p>}\n {heading(level, { className: \"sf-site-hero-title\" }, title)}\n {lead != null && <p className=\"sf-site-lead\">{lead}</p>}\n {actions != null && <div className=\"sf-site-actions\">{actions}</div>}\n {media != null && <div className=\"sf-site-hero-media\">{media}</div>}\n </section>\n );\n}\n\nexport interface SectionProps {\n heading: ReactNode;\n eyebrow?: ReactNode;\n lead?: ReactNode;\n children?: ReactNode;\n /** The heading's level. Defaults to 2. */\n level?: Heading;\n className?: string;\n}\n\n/** A part of a page under its own heading, with room around it. Named by its heading for assistive technology. */\nexport function Section({ heading: title, eyebrow, lead, children, level = 2, className }: SectionProps) {\n const id = useId();\n return (\n <section className={[\"sf-site-section\", className].filter(Boolean).join(\" \")} aria-labelledby={id}>\n <div className=\"sf-site-section-head\">\n {eyebrow != null && <p className=\"sf-site-eyebrow\">{eyebrow}</p>}\n {heading(level, { id, className: \"sf-site-section-title\" }, title)}\n {lead != null && <p className=\"sf-site-section-lead\">{lead}</p>}\n </div>\n {children}\n </section>\n );\n}\n\nexport interface FeatureItem {\n id: string;\n title: string;\n line?: string;\n /** A link. Without one the item is a button that calls `onSelect`. */\n href?: string;\n}\n\nexport interface FeatureGridProps {\n items: FeatureItem[];\n /** What the list is, for assistive technology. */\n label?: string;\n onSelect?(id: string): void;\n className?: string;\n}\n\n/** Cards of a title and a line each, as many to a row as the container fits. Each is a link or a button. */\nexport function FeatureGrid({ items, label, onSelect, className }: FeatureGridProps) {\n return (\n <ul className={[\"sf-site-features\", className].filter(Boolean).join(\" \")} aria-label={label}>\n {items.map((item) => {\n const body = (\n <>\n <span className=\"sf-site-feature-title\">{item.title}</span>\n {item.line && <span className=\"sf-site-feature-line\">{item.line}</span>}\n </>\n );\n return (\n <li key={item.id}>\n {item.href ? (\n <a className=\"sf-site-feature\" href={item.href}>\n {body}\n </a>\n ) : (\n <button type=\"button\" className=\"sf-site-feature\" onClick={() => onSelect?.(item.id)} disabled={!onSelect}>\n {body}\n </button>\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport type Device = \"desktop\" | \"phone\";\n\nexport interface DeviceFrameProps {\n /** Draws `children` in each, side by side. Defaults to a desktop and a phone. Under 40rem of room only the last stands. */\n devices?: Device[];\n /** The desktop window's title. */\n title?: string;\n /** What the screen shows, for assistive technology; each screen is named after its device and this. */\n label?: string;\n /** Draws the content for one device. Called once per device. */\n children: ReactNode | ((device: Device) => ReactNode);\n className?: string;\n}\n\nconst DEVICE_NAME: Record<Device, string> = { desktop: \"Desktop\", phone: \"Phone\" };\n\n/**\n * A desktop window and a phone around the same content, for showing a product. The screens scroll on their own and\n * can be focused to scroll by keyboard. The frames are drawing only: they are hidden from assistive technology.\n */\nexport function DeviceFrame({ devices = [\"desktop\", \"phone\"], title, label, children, className }: DeviceFrameProps) {\n const shown = devices.length ? [...new Set(devices)] : ([\"desktop\", \"phone\"] as Device[]);\n const content = (device: Device) => (typeof children === \"function\" ? children(device) : children);\n const screen = (device: Device) => (\n // biome-ignore lint/a11y/noNoninteractiveTabindex: a scrolling region is focused to scroll it by keyboard\n <section className=\"sf-site-screen sf-container\" aria-label={label ? `${DEVICE_NAME[device]}: ${label}` : DEVICE_NAME[device]} tabIndex={0}>\n {content(device)}\n </section>\n );\n return (\n <div className={[\"sf-site-devices\", className].filter(Boolean).join(\" \")}>\n <div className=\"sf-site-devices-row\" data-count={shown.length}>\n {shown.map((device) =>\n device === \"desktop\" ? (\n <figure key={device} className=\"sf-site-desktop\">\n <div className=\"sf-site-desktop-bar\" aria-hidden=\"true\">\n <span />\n <span />\n <span />\n <p>{title ?? \"\"}</p>\n </div>\n <div className=\"sf-site-desktop-body\">{screen(device)}</div>\n <figcaption>{DEVICE_NAME.desktop}</figcaption>\n </figure>\n ) : (\n <figure key={device} className=\"sf-site-phone\">\n <div className=\"sf-site-phone-frame\">\n <div className=\"sf-site-phone-island\" aria-hidden=\"true\" />\n <div className=\"sf-site-phone-body\">{screen(device)}</div>\n </div>\n <figcaption>{DEVICE_NAME.phone}</figcaption>\n </figure>\n ),\n )}\n </div>\n </div>\n );\n}\n\nfunction useReducedMotion(): boolean {\n const query = \"(prefers-reduced-motion: reduce)\";\n const [reduce, setReduce] = useState(() => (typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" ? window.matchMedia(query).matches : false));\n useEffect(() => {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return;\n const media = window.matchMedia(query);\n const change = () => setReduce(media.matches);\n media.addEventListener(\"change\", change);\n return () => media.removeEventListener(\"change\", change);\n }, []);\n return reduce;\n}\n\n/** How fast the prompt types, how long the answer holds before it starts again, in milliseconds. */\nexport const PROMPT_REVEAL_TIMING = { type: 28, start: 400, hold: 9000, restart: 600 } as const;\n\nexport interface PromptRevealProps {\n /** What a person asks, typed out first. */\n prompt: string;\n /** The answer, shown once the prompt is typed. */\n children: ReactNode;\n /**\n * Starts again after a pause, with a Pause button. Defaults to false: it plays once and stops on the answer,\n * with a Replay button.\n */\n loop?: boolean;\n /** What is shown, for the status line. */\n label?: string;\n className?: string;\n}\n\n/**\n * A prompt typed out and its answer shown. It plays once and stops on the finished answer, with a Replay button to\n * play it again. With `loop` it starts again after a pause and has a Pause button instead, since it then moves for\n * longer than five seconds; once paused, or once a person reaches into the answer, it shows the finished answer and\n * stands still. Under reduced motion it shows the finished answer and has no button. Assistive technology reads the\n * whole prompt at once, never letter by letter.\n */\nexport function PromptReveal({ prompt, children, loop = false, label, className }: PromptRevealProps) {\n const reduce = useReducedMotion();\n const [paused, setPaused] = useState(false);\n const still = reduce || (loop && paused);\n const [typed, setTyped] = useState(0);\n const [round, setRound] = useState(0);\n // Each replay plays it from the start again.\n const [play, setPlay] = useState(0);\n // biome-ignore lint/correctness/useExhaustiveDependencies: `play` is how Replay starts it again\n useEffect(() => {\n if (still) return;\n let count = 0;\n let timer: ReturnType<typeof setTimeout>;\n const step = () => {\n if (count < prompt.length) {\n count += 1;\n setTyped(count);\n timer = setTimeout(step, PROMPT_REVEAL_TIMING.type);\n } else if (loop) {\n timer = setTimeout(() => {\n count = 0;\n setTyped(0);\n setRound((r) => r + 1);\n timer = setTimeout(step, PROMPT_REVEAL_TIMING.restart);\n }, PROMPT_REVEAL_TIMING.hold);\n }\n };\n setTyped(0);\n timer = setTimeout(step, PROMPT_REVEAL_TIMING.start);\n return () => clearTimeout(timer);\n }, [still, prompt, loop, play]);\n const shown = still ? prompt.length : typed;\n const done = shown >= prompt.length;\n const status = reduce ? \"Shown finished, since your system asks for less motion.\" : loop && paused ? \"Paused.\" : done ? \"Answered.\" : \"Typing.\";\n return (\n <div className={[\"sf-site-prompt-reveal\", className].filter(Boolean).join(\" \")}>\n <p className=\"sf-visually-hidden\">{prompt}</p>\n <p className=\"sf-site-prompt\" aria-hidden=\"true\">\n <span>{prompt.slice(0, shown) || \" \"}</span>\n {!done && <span className=\"sf-site-caret\" />}\n </p>\n {/* biome-ignore lint/a11y/noStaticElementInteractions: it only watches for a person reaching into the answer, to stop it moving */}\n {/* The answer keeps its place while the prompt types, hidden and out of reach, so the page does not jump; it is\n drawn afresh each time it is shown, so whatever rises in as it is drawn rises in again. */}\n <div\n key={done ? `shown-${round}` : \"waiting\"}\n className=\"sf-site-answer\"\n data-shown={done || undefined}\n ref={(element) => {\n // Set here, not as a prop: React 18 does not know `inert`.\n if (element) element.inert = !done;\n }}\n aria-hidden={done ? undefined : true}\n onPointerDown={loop ? () => setPaused(true) : undefined}\n onFocus={loop ? () => setPaused(true) : undefined}\n >\n {children}\n </div>\n <div className=\"sf-site-reveal-foot\">\n <p className=\"sf-site-reveal-status\" role=\"status\">\n {label ? `${label}. ` : \"\"}\n {status}\n </p>\n {!reduce &&\n (loop ? (\n <button type=\"button\" className=\"sf-button\" aria-pressed={paused} onClick={() => setPaused((p) => !p)}>\n {paused ? \"Play\" : \"Pause\"}\n </button>\n ) : (\n <button type=\"button\" className=\"sf-button\" onClick={() => setPlay((p) => p + 1)}>\n Replay\n </button>\n ))}\n </div>\n </div>\n );\n}\n\nexport interface ShowcaseItem {\n id: string;\n name: string;\n line?: string;\n content: ReactNode;\n}\n\nexport interface ShowcaseProps {\n items: ShowcaseItem[];\n /** What the picker chooses between, for assistive technology. */\n label: string;\n value?: string;\n defaultValue?: string;\n onChange?(id: string): void;\n className?: string;\n}\n\n/** A picker of named examples above a stage that shows the chosen one. The picker wraps rather than run past the edge. */\nexport function Showcase({ items, label, value, defaultValue, onChange, className }: ShowcaseProps) {\n const name = useId();\n const [own, setOwn] = useState(defaultValue ?? items[0]?.id);\n const current = items.find((item) => item.id === (value ?? own)) ?? items[0];\n const choose = (id: string) => {\n setOwn(id);\n onChange?.(id);\n };\n return (\n <div className={[\"sf-site-showcase\", className].filter(Boolean).join(\" \")}>\n <div className=\"sf-segmented sf-site-showcase-picker\" role=\"radiogroup\" aria-label={label} data-thumb=\"off\">\n {items.map((item) => (\n <label key={item.id} className=\"sf-segment\" data-checked={item.id === current?.id || undefined}>\n <input type=\"radio\" name={name} value={item.id} checked={item.id === current?.id} onChange={() => choose(item.id)} />\n {item.name}\n </label>\n ))}\n </div>\n {current && (\n <div key={current.id} className=\"sf-site-showcase-stage\">\n <p className=\"sf-site-showcase-name\">{current.name}</p>\n {current.line && <p className=\"sf-site-showcase-line\">{current.line}</p>}\n {current.content}\n </div>\n )}\n </div>\n );\n}\n\nexport interface FooterLink {\n id: string;\n label: string;\n href?: string;\n}\n\nexport interface FooterProps {\n groups: { label?: string; items: FooterLink[] }[];\n /** A line at the very end: a copyright, a licence. */\n note?: ReactNode;\n onSelect?(id: string): void;\n label?: string;\n className?: string;\n}\n\n/** The end of a site's page: columns of links that wrap to the container, and a note. */\nexport function Footer({ groups, note, onSelect, label = \"Site\", className }: FooterProps) {\n return (\n <footer className={[\"sf-site-footer\", className].filter(Boolean).join(\" \")}>\n <nav className=\"sf-site-footer-groups\" aria-label={label}>\n {groups.map((group, index) => (\n <div key={group.label ?? index} className=\"sf-site-footer-group\">\n {group.label && <p className=\"sf-site-footer-label\">{group.label}</p>}\n <ul>\n {group.items.map((item) => (\n <li key={item.id}>\n {item.href ? (\n <a href={item.href}>{item.label}</a>\n ) : (\n <button type=\"button\" className=\"sf-site-link\" onClick={() => onSelect?.(item.id)} disabled={!onSelect}>\n {item.label}\n </button>\n )}\n </li>\n ))}\n </ul>\n </div>\n ))}\n </nav>\n {note != null && <p className=\"sf-site-footer-note\">{note}</p>}\n </footer>\n );\n}\n\nexport type MediaRatio = \"16:9\" | \"4:3\" | \"3:2\" | \"1:1\" | \"21:9\";\n\nexport interface MediaProps {\n /** The address. Without one, the description stands in its place. */\n src?: string;\n /** What it shows, for anyone who cannot see it. An empty string marks it as decoration. */\n alt: string;\n kind?: \"image\" | \"video\";\n ratio?: MediaRatio;\n caption?: ReactNode;\n className?: string;\n}\n\n/**\n * An image or a video at a fixed ratio, so nothing moves as it loads, and loaded only near the screen. A video has\n * controls and never plays on its own. With no address, its description is shown in the space it would take.\n */\nexport function Media({ src, alt, kind = \"image\", ratio = \"16:9\", caption, className }: MediaProps) {\n const style = { \"--sf-site-ratio\": ratio.replace(\":\", \" / \") } as CSSProperties;\n const body = !src ? (\n <div className=\"sf-site-media-missing\" role={alt ? \"img\" : undefined} aria-label={alt || undefined}>\n <span aria-hidden=\"true\">{alt || \"Image\"}</span>\n </div>\n ) : kind === \"video\" ? (\n // biome-ignore lint/a11y/useMediaCaption: captions are the host's to add to the file\n <video className=\"sf-site-media-body\" src={src} controls preload=\"none\" aria-label={alt || undefined} />\n ) : (\n <img className=\"sf-site-media-body\" src={src} alt={alt} loading=\"lazy\" decoding=\"async\" />\n );\n return (\n <figure className={[\"sf-site-media\", className].filter(Boolean).join(\" \")} style={style}>\n {body}\n {caption != null && <figcaption>{caption}</figcaption>}\n </figure>\n );\n}\n\nexport interface QuoteProps {\n children: ReactNode;\n /** Who said it. */\n cite?: ReactNode;\n /** Where it was said. */\n href?: string;\n className?: string;\n}\n\n/** A pull quote, with who said it. */\nexport function Quote({ children, cite, href, className }: QuoteProps) {\n return (\n <figure className={[\"sf-site-quote\", className].filter(Boolean).join(\" \")}>\n <blockquote cite={href}>{children}</blockquote>\n {cite != null && <figcaption>{href ? <a href={href}>{cite}</a> : cite}</figcaption>}\n </figure>\n );\n}\n\nexport type CalloutTone = \"note\" | \"tip\" | \"warning\";\nconst TONE_NAME: Record<CalloutTone, string> = { note: \"Note\", tip: \"Tip\", warning: \"Warning\" };\n\nexport interface CalloutProps {\n tone?: CalloutTone;\n /** Its heading. Without one, the tone's name (\"Note\") is the heading, so the kind is never told by colour alone. */\n title?: ReactNode;\n children: ReactNode;\n className?: string;\n}\n\n/** A note set apart from the text around it: a note, a tip or a warning. */\nexport function Callout({ tone = \"note\", title, children, className }: CalloutProps) {\n return (\n <aside className={[\"sf-site-callout\", className].filter(Boolean).join(\" \")} data-tone={tone} aria-label={typeof title === \"string\" ? title : TONE_NAME[tone]}>\n <p className=\"sf-site-callout-title\">{title ?? TONE_NAME[tone]}</p>\n <div className=\"sf-site-callout-body\">{children}</div>\n </aside>\n );\n}\n\nexport interface Post {\n id: string;\n title: string;\n /** An ISO date, shown in the reader's own words for it. */\n date?: string;\n excerpt?: string;\n tags?: string[];\n href?: string;\n}\n\nexport interface PostCardProps extends Post {\n onOpen?(id: string): void;\n /** The title's heading level. Defaults to 3. */\n level?: Heading;\n className?: string;\n}\n\n/** A UTC date read as words, or the text as given when it is not a date. */\nexport function postDate(date: string, locale?: string): string {\n const time = Date.parse(date);\n return Number.isNaN(time) ? date : new Intl.DateTimeFormat(locale, { dateStyle: \"long\", timeZone: \"UTC\" }).format(time);\n}\n\n/** A post in a list: its title as a link or a button, the date, a line of it and its tags. */\nexport function PostCard({ id, title, date, excerpt, tags, href, onOpen, level = 3, className }: PostCardProps) {\n return (\n <article className={[\"sf-site-post\", className].filter(Boolean).join(\" \")}>\n {heading(\n level,\n { className: \"sf-site-post-title\" },\n href ? (\n <a href={href}>{title}</a>\n ) : onOpen ? (\n <button type=\"button\" className=\"sf-site-link\" onClick={() => onOpen(id)}>\n {title}\n </button>\n ) : (\n title\n ),\n )}\n {date && (\n <p className=\"sf-site-post-date\">\n <time dateTime={date}>{postDate(date)}</time>\n </p>\n )}\n {excerpt && <p className=\"sf-site-post-excerpt\">{excerpt}</p>}\n {tags && tags.length > 0 && (\n <ul className=\"sf-site-post-tags\" aria-label=\"Tags\">\n {tags.map((tag) => (\n <li key={tag}>{tag}</li>\n ))}\n </ul>\n )}\n </article>\n );\n}\n\nexport interface PostListProps {\n posts: Post[];\n label?: string;\n onOpen?(id: string): void;\n className?: string;\n}\n\n/** Posts newest first as given, one card each. */\nexport function PostList({ posts, label, onOpen, className }: PostListProps) {\n if (posts.length === 0) return <p className=\"sf-site-empty\">Nothing here yet.</p>;\n return (\n <ul className={[\"sf-site-posts\", className].filter(Boolean).join(\" \")} aria-label={label}>\n {posts.map((post) => (\n <li key={post.id}>\n <PostCard {...post} onOpen={onOpen} />\n </li>\n ))}\n </ul>\n );\n}\n"]}