@surfaces-ui/components 0.6.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.
- package/NOTICE +50 -0
- package/dist/appComponents.d.ts +9 -0
- package/dist/appComponents.js +105 -1
- package/dist/appComponents.js.map +1 -1
- package/dist/brand/MovingMark.d.ts +15 -0
- package/dist/brand/MovingMark.js +52 -0
- package/dist/brand/MovingMark.js.map +1 -0
- package/dist/brand/SurfacesMark.d.ts +9 -0
- package/dist/brand/SurfacesMark.js +12 -0
- package/dist/brand/SurfacesMark.js.map +1 -0
- package/dist/brand/index.d.ts +3 -0
- package/dist/brand/index.js +3 -0
- package/dist/brand/index.js.map +1 -0
- package/dist/brand/markMotion.d.ts +29 -0
- package/dist/brand/markMotion.js +89 -0
- package/dist/brand/markMotion.js.map +1 -0
- package/dist/chart/Chart.d.ts +8 -4
- package/dist/chart/Chart.js +19 -8
- package/dist/chart/Chart.js.map +1 -1
- package/dist/chart/advice.d.ts +4 -2
- package/dist/chart/advice.js +14 -1
- package/dist/chart/advice.js.map +1 -1
- package/dist/chart/option.d.ts +17 -2
- package/dist/chart/option.js +146 -3
- package/dist/chart/option.js.map +1 -1
- package/dist/controls/ConfirmDialog.d.ts +17 -2
- package/dist/controls/ConfirmDialog.js +37 -11
- package/dist/controls/ConfirmDialog.js.map +1 -1
- package/dist/controls/ItemControls.d.ts +6 -2
- package/dist/controls/ItemControls.js +8 -3
- package/dist/controls/ItemControls.js.map +1 -1
- package/dist/controls/OutlineIcon.d.ts +9 -0
- package/dist/controls/OutlineIcon.js +12 -0
- package/dist/controls/OutlineIcon.js.map +1 -0
- package/dist/data/DataSourceProvider.d.ts +2 -0
- package/dist/data/DataSourceProvider.js +5 -0
- package/dist/data/DataSourceProvider.js.map +1 -1
- package/dist/feedback/ErrorPage.d.ts +27 -0
- package/dist/feedback/ErrorPage.js +12 -0
- package/dist/feedback/ErrorPage.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/loading/ChartArt.d.ts +8 -0
- package/dist/loading/ChartArt.js +29 -0
- package/dist/loading/ChartArt.js.map +1 -0
- package/dist/loading/DraftCard.d.ts +10 -0
- package/dist/loading/DraftCard.js +38 -0
- package/dist/loading/DraftCard.js.map +1 -0
- package/dist/loading/Loading.d.ts +49 -0
- package/dist/loading/Loading.js +38 -0
- package/dist/loading/Loading.js.map +1 -0
- package/dist/locale/locale.d.ts +42 -0
- package/dist/locale/locale.js +43 -0
- package/dist/locale/locale.js.map +1 -1
- package/dist/record/RecordForm.d.ts +85 -0
- package/dist/record/RecordForm.js +221 -0
- package/dist/record/RecordForm.js.map +1 -0
- package/dist/record/record.d.ts +82 -0
- package/dist/record/record.js +125 -0
- package/dist/record/record.js.map +1 -0
- package/dist/result/QueryResult.js +2 -1
- package/dist/result/QueryResult.js.map +1 -1
- package/dist/review/ActionReceipt.d.ts +2 -1
- package/dist/review/ActionReceipt.js +1 -0
- package/dist/review/ActionReceipt.js.map +1 -1
- package/dist/schema/SchemaExplorer.d.ts +4 -0
- package/dist/schema/SchemaExplorer.js +46 -28
- package/dist/schema/SchemaExplorer.js.map +1 -1
- package/dist/site/Site.d.ts +9 -4
- package/dist/site/Site.js +14 -8
- package/dist/site/Site.js.map +1 -1
- package/dist/styles.css +1097 -100
- package/dist/styles.layer.css +1097 -100
- package/dist/text/Markdown.js +21 -8
- package/dist/text/Markdown.js.map +1 -1
- package/dist/workspace/icons.js +2 -1
- package/dist/workspace/icons.js.map +1 -1
- package/package.json +12 -7
|
@@ -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,E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AC,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 )}\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AC,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\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"]}
|
|
@@ -4,6 +4,10 @@ import { type ReactNode } from "react";
|
|
|
4
4
|
/** A table or column, as handed to callbacks and placed on the clipboard when dragged. */
|
|
5
5
|
export interface SchemaRef {
|
|
6
6
|
sourceId: string;
|
|
7
|
+
/** Given when the source says which catalog the table is in. */
|
|
8
|
+
catalog?: string;
|
|
9
|
+
/** The schema, or the database on an engine that has no catalog above it. Given when the source says. */
|
|
10
|
+
schema?: string;
|
|
7
11
|
table: string;
|
|
8
12
|
column?: string;
|
|
9
13
|
}
|
|
@@ -54,51 +54,69 @@ export function SchemaExplorer(props) {
|
|
|
54
54
|
clearTimeout(timer);
|
|
55
55
|
};
|
|
56
56
|
}, [dataSource, sourceId, search]);
|
|
57
|
-
|
|
57
|
+
// A table is known by its whole reference, never its name alone: a source with several
|
|
58
|
+
// databases lists the same name once for each, and rows that shared a name were drawn
|
|
59
|
+
// on top of one another.
|
|
60
|
+
const toggle = (id, table) => {
|
|
58
61
|
setExpanded((previous) => {
|
|
59
62
|
const next = new Set(previous);
|
|
60
|
-
if (next.has(
|
|
61
|
-
next.delete(
|
|
63
|
+
if (next.has(id))
|
|
64
|
+
next.delete(id);
|
|
62
65
|
else
|
|
63
|
-
next.add(
|
|
66
|
+
next.add(id);
|
|
64
67
|
return next;
|
|
65
68
|
});
|
|
66
|
-
if (details[
|
|
67
|
-
setDetails((previous) => ({ ...previous, [
|
|
69
|
+
if (details[id] === undefined) {
|
|
70
|
+
setDetails((previous) => ({ ...previous, [id]: "loading" }));
|
|
68
71
|
dataSource
|
|
69
|
-
.describeTable({ sourceId, ref: { table:
|
|
70
|
-
.then((response) => setDetails((previous) => ({ ...previous, [
|
|
71
|
-
.catch((error) => setDetails((previous) => ({ ...previous, [
|
|
72
|
+
.describeTable({ sourceId, ref: { catalog: table.ref?.catalog, schema: table.ref?.schema, table: table.ref?.table ?? "" }, includeStats: true })
|
|
73
|
+
.then((response) => setDetails((previous) => ({ ...previous, [id]: response.table ?? { error: "No details." } })))
|
|
74
|
+
.catch((error) => setDetails((previous) => ({ ...previous, [id]: { error: messageOf(error) } })));
|
|
72
75
|
}
|
|
73
76
|
};
|
|
77
|
+
// The schema is shown only when the tables listed are in more than one, and the catalog likewise.
|
|
78
|
+
const qualified = useMemo(() => {
|
|
79
|
+
const catalogs = new Set(tables.map((table) => table.ref?.catalog ?? ""));
|
|
80
|
+
const schemas = new Set(tables.map((table) => `${table.ref?.catalog ?? ""}\u0000${table.ref?.schema ?? ""}`));
|
|
81
|
+
return { catalog: catalogs.size > 1, schema: schemas.size > 1 };
|
|
82
|
+
}, [tables]);
|
|
74
83
|
const nodes = useMemo(() => {
|
|
75
84
|
const out = [];
|
|
85
|
+
const seen = new Map();
|
|
76
86
|
for (const table of tables) {
|
|
77
87
|
const name = table.ref?.table ?? "";
|
|
78
|
-
const
|
|
79
|
-
|
|
88
|
+
const base = [table.ref?.catalog ?? "", table.ref?.schema ?? "", name].join("\u0000");
|
|
89
|
+
// A source that lists one table twice still gets two rows that are told apart.
|
|
90
|
+
const repeat = seen.get(base) ?? 0;
|
|
91
|
+
seen.set(base, repeat + 1);
|
|
92
|
+
const id = repeat ? `${base}\u0000${repeat}` : base;
|
|
93
|
+
const open = expanded.has(id);
|
|
94
|
+
out.push({ kind: "table", key: `t:${id}`, id, table, name, expanded: open });
|
|
80
95
|
if (!open)
|
|
81
96
|
continue;
|
|
82
|
-
const detail = details[
|
|
97
|
+
const detail = details[id];
|
|
83
98
|
if (detail === undefined || detail === "loading")
|
|
84
|
-
out.push({ kind: "note", key: `n:${
|
|
99
|
+
out.push({ kind: "note", key: `n:${id}`, text: "Loading columns…" });
|
|
85
100
|
else if ("error" in detail)
|
|
86
|
-
out.push({ kind: "note", key: `n:${
|
|
101
|
+
out.push({ kind: "note", key: `n:${id}`, text: detail.error, error: true });
|
|
87
102
|
else
|
|
88
|
-
|
|
89
|
-
out.push({ kind: "column", key: `c:${name}.${column.name}`, table, tableName: name, column });
|
|
103
|
+
detail.columns.forEach((column, at) => out.push({ kind: "column", key: `c:${id}\u0000${at}`, id, table, column }));
|
|
90
104
|
}
|
|
91
105
|
return out;
|
|
92
106
|
}, [tables, expanded, details]);
|
|
93
107
|
const listHeight = Math.max(rowHeight, height - 44);
|
|
94
108
|
const first = Math.max(0, Math.floor(scrollTop / rowHeight) - 4);
|
|
95
109
|
const last = Math.min(nodes.length, first + Math.ceil(listHeight / rowHeight) + 8);
|
|
96
|
-
const refOf = (node) =>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
const refOf = (node) => {
|
|
111
|
+
if (node.kind === "note")
|
|
112
|
+
return undefined;
|
|
113
|
+
const { catalog, schema, table = "" } = node.table.ref ?? {};
|
|
114
|
+
return { sourceId, ...(catalog ? { catalog } : {}), ...(schema ? { schema } : {}), table, ...(node.kind === "column" ? { column: node.column.name } : {}) };
|
|
115
|
+
};
|
|
116
|
+
/** What a table is drawn under: its schema, when the list holds more than one, and its catalog likewise. */
|
|
117
|
+
const prefixOf = (ref) => [qualified.catalog && ref.catalog, qualified.schema && ref.schema].filter(Boolean).map((part) => `${part}.`).join("");
|
|
118
|
+
// The name put into an editor says which table it is when the name alone would not.
|
|
119
|
+
const nameOf = (ref) => ref.column ?? prefixOf(ref) + ref.table;
|
|
102
120
|
const focusRow = (index) => {
|
|
103
121
|
const clamped = Math.max(0, Math.min(nodes.length - 1, index));
|
|
104
122
|
setActive(clamped);
|
|
@@ -125,13 +143,13 @@ export function SchemaExplorer(props) {
|
|
|
125
143
|
return;
|
|
126
144
|
const ref = refOf(node);
|
|
127
145
|
if (event.key === "ArrowRight" && node.kind === "table" && !node.expanded)
|
|
128
|
-
return handled(), toggle(node.
|
|
146
|
+
return handled(), toggle(node.id, node.table);
|
|
129
147
|
if (event.key === "ArrowLeft") {
|
|
130
148
|
handled();
|
|
131
149
|
if (node.kind === "table" && node.expanded)
|
|
132
|
-
return toggle(node.
|
|
150
|
+
return toggle(node.id, node.table);
|
|
133
151
|
if (node.kind !== "table")
|
|
134
|
-
return focusRow(nodes.findIndex((n) => n.kind === "table" && n.
|
|
152
|
+
return focusRow(nodes.findIndex((n) => n.kind === "table" && n.id === (node.kind === "column" ? node.id : "")));
|
|
135
153
|
}
|
|
136
154
|
if (event.key === "Enter" && ref)
|
|
137
155
|
return handled(), props.onSelect?.(ref, node.table);
|
|
@@ -158,14 +176,14 @@ export function SchemaExplorer(props) {
|
|
|
158
176
|
rows.push(_jsx("div", { ...common, role: "treeitem", "aria-level": 2, "aria-selected": false, "data-error": node.error || undefined, children: node.text }, node.key));
|
|
159
177
|
continue;
|
|
160
178
|
}
|
|
161
|
-
const detail = node.kind === "table" ? details[node.
|
|
179
|
+
const detail = node.kind === "table" ? details[node.id] : undefined;
|
|
162
180
|
const rowCount = detail && typeof detail === "object" && "rowCount" in detail ? detail.rowCount : undefined;
|
|
163
181
|
rows.push(_jsx("div", { ...common, role: "treeitem", "aria-level": node.kind === "table" ? 1 : 2, "aria-expanded": node.kind === "table" ? node.expanded : undefined, "aria-selected": index === active, draggable: true, onDragStart: drag(ref), onClick: () => {
|
|
164
182
|
setActive(index);
|
|
165
183
|
if (node.kind === "table")
|
|
166
|
-
toggle(node.
|
|
184
|
+
toggle(node.id, node.table);
|
|
167
185
|
props.onSelect?.(ref, node.table);
|
|
168
|
-
}, onDoubleClick: () => props.onInsert?.(nameOf(ref), ref), children: node.kind === "table" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "sf-schema-caret", "aria-hidden": "true", "data-open": node.expanded || undefined, children: "\u25B8" }),
|
|
186
|
+
}, onDoubleClick: () => props.onInsert?.(nameOf(ref), ref), children: node.kind === "table" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "sf-schema-caret", "aria-hidden": "true", "data-open": node.expanded || undefined, children: "\u25B8" }), _jsxs("span", { className: "sf-schema-name", children: [prefixOf(ref) && _jsx("span", { className: "sf-schema-qualifier", children: prefixOf(ref) }), node.name] }), rowCount !== undefined && _jsxs("span", { className: "sf-schema-meta", children: [count.format(Number(rowCount)), " rows"] }), FORMAT_LABEL[node.table.format] && _jsx("span", { className: "sf-schema-tag", children: FORMAT_LABEL[node.table.format] }), props.renderActions && (_jsx("span", { className: "sf-schema-actions", onClick: (e) => e.stopPropagation(), onDoubleClick: (e) => e.stopPropagation(), children: props.renderActions(ref, node.table) }))] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "sf-schema-name", children: node.column.name }), _jsx("span", { className: "sf-schema-meta", children: node.column.nativeType.toLowerCase() })] })) }, node.key));
|
|
169
187
|
}
|
|
170
188
|
return (_jsxs("div", { className: ["sf-schema", props.className].filter(Boolean).join(" "), style: { height }, children: [_jsx("input", { className: "sf-input sf-schema-search", type: "search", placeholder: "Search tables", "aria-label": "Search tables", value: search, onChange: (event) => {
|
|
171
189
|
setSearch(event.target.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaExplorer.js","sourceRoot":"","sources":["../../src/schema/SchemaExplorer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAiC,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAsD,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,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,SAAS,CAAC,aAEhE,cAAK,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAG,IAAI,GAAO,EACnF,MAAM,CAAC,KAAK,IAAI,CACf,YAAG,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACxC,MAAM,CAAC,KAAK,GACX,CACL,EACA,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAC1D,YAAG,SAAS,EAAC,iBAAiB,YAAE,MAAM,CAAC,CAAC,CAAC,oBAAoB,MAAM,IAAI,CAAC,CAAC,CAAC,4BAA4B,GAAK,CAC5G,IACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { DataSource } from \"@surfaces-ui/data\";\nimport { type Column, type TableDetail, TableFormat, type TableSummary } from \"@surfaces-ui/proto\";\nimport { DENSITY_SCALE } from \"@surfaces-ui/tokens\";\nimport { type DragEvent, type KeyboardEvent, type ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useDataSource } from \"../data/DataSourceProvider.js\";\nimport { messageOf } from \"../data/useRowWindow.js\";\nimport { useOptionalTheme } from \"../theme/ThemeProvider.js\";\nimport { numberFormat } from \"../locale/locale.js\";\n\n/** A table or column, as handed to callbacks and placed on the clipboard when dragged. */\nexport interface SchemaRef {\n sourceId: string;\n table: string;\n column?: string;\n}\n\n/** MIME type carrying a SchemaRef as JSON during drag and drop. */\nexport const SCHEMA_REF_MIME = \"application/x-surfaces-ref+json\";\n\nexport interface SchemaExplorerProps {\n sourceId: string;\n /** Called when a table or column is activated (click or Enter). */\n onSelect?(ref: SchemaRef, table: TableSummary): void;\n /** Called on double-click or Insert, with the name to insert into an editor. */\n onInsert?(name: string, ref: SchemaRef): void;\n /** Extra controls at the end of each table row, e.g. \"add to context\". */\n renderActions?(ref: SchemaRef, table: TableSummary): ReactNode;\n /** Height in px. Defaults to 420. */\n height?: number;\n dataSource?: DataSource;\n /** Accessible name. Defaults to \"Tables\". */\n label?: string;\n className?: string;\n}\n\nconst FORMAT_LABEL: Partial<Record<TableFormat, string>> = {\n [TableFormat.PARQUET]: \"Parquet\",\n [TableFormat.CSV]: \"CSV\",\n [TableFormat.JSON]: \"JSON\",\n [TableFormat.ICEBERG]: \"Iceberg\",\n [TableFormat.DELTA]: \"Delta\",\n};\n\ntype Node =\n | { kind: \"table\"; key: string; table: TableSummary; name: string; expanded: boolean }\n | { kind: \"column\"; key: string; table: TableSummary; tableName: string; column: Column }\n | { kind: \"note\"; key: string; text: string; error?: boolean };\n\nconst count = { format: (n: number) => numberFormat({ notation: \"compact\", maximumFractionDigits: 1 }).format(n) };\n\n/**\n * A searchable tree of a source's tables and their columns. Columns load when\n * a table is opened; only visible rows are in the DOM, so catalogs with\n * thousands of tables stay fast. Items can be dragged into SqlEditor.\n */\nexport function SchemaExplorer(props: SchemaExplorerProps) {\n const { sourceId, height = 420 } = props;\n const dataSource = useDataSource(props.dataSource);\n const theme = useOptionalTheme();\n const rowHeight = DENSITY_SCALE[theme?.theme.density ?? \"comfortable\"].rowHeight - 4;\n\n const [search, setSearch] = useState(\"\");\n const [tables, setTables] = useState<TableSummary[]>([]);\n const [status, setStatus] = useState<{ loading: boolean; error?: string }>({ loading: true });\n const [expanded, setExpanded] = useState<Set<string>>(new Set());\n const [details, setDetails] = useState<Record<string, TableDetail | { error: string } | \"loading\">>({});\n const [active, setActive] = useState(0);\n const [scrollTop, setScrollTop] = useState(0);\n const list = useRef<HTMLDivElement>(null);\n\n // Search runs on the backend so it works over catalogs too large to list.\n useEffect(() => {\n let current = true;\n setStatus({ loading: true });\n const timer = setTimeout(() => {\n dataSource\n .listTables({ sourceId, search: search.trim() })\n .then((response) => {\n if (!current) return;\n setTables(response.tables);\n setStatus({ loading: false });\n })\n .catch((error: unknown) => current && setStatus({ loading: false, error: messageOf(error) }));\n }, search ? 180 : 0);\n return () => {\n current = false;\n clearTimeout(timer);\n };\n }, [dataSource, sourceId, search]);\n\n const toggle = (name: string) => {\n setExpanded((previous) => {\n const next = new Set(previous);\n if (next.has(name)) next.delete(name);\n else next.add(name);\n return next;\n });\n if (details[name] === undefined) {\n setDetails((previous) => ({ ...previous, [name]: \"loading\" }));\n dataSource\n .describeTable({ sourceId, ref: { table: name }, includeStats: true })\n .then((response) => setDetails((previous) => ({ ...previous, [name]: response.table ?? { error: \"No details.\" } })))\n .catch((error: unknown) => setDetails((previous) => ({ ...previous, [name]: { error: messageOf(error) } })));\n }\n };\n\n const nodes = useMemo<Node[]>(() => {\n const out: Node[] = [];\n for (const table of tables) {\n const name = table.ref?.table ?? \"\";\n const open = expanded.has(name);\n out.push({ kind: \"table\", key: `t:${name}`, table, name, expanded: open });\n if (!open) continue;\n const detail = details[name];\n if (detail === undefined || detail === \"loading\") out.push({ kind: \"note\", key: `n:${name}`, text: \"Loading columns…\" });\n else if (\"error\" in detail) out.push({ kind: \"note\", key: `n:${name}`, text: detail.error, error: true });\n else for (const column of detail.columns) out.push({ kind: \"column\", key: `c:${name}.${column.name}`, table, tableName: name, column });\n }\n return out;\n }, [tables, expanded, details]);\n\n const listHeight = Math.max(rowHeight, height - 44);\n const first = Math.max(0, Math.floor(scrollTop / rowHeight) - 4);\n const last = Math.min(nodes.length, first + Math.ceil(listHeight / rowHeight) + 8);\n\n const refOf = (node: Node): SchemaRef | undefined =>\n node.kind === \"table\"\n ? { sourceId, table: node.name }\n : node.kind === \"column\"\n ? { sourceId, table: node.tableName, column: node.column.name }\n : undefined;\n const nameOf = (ref: SchemaRef) => ref.column ?? ref.table;\n\n const focusRow = (index: number) => {\n const clamped = Math.max(0, Math.min(nodes.length - 1, index));\n setActive(clamped);\n const element = list.current;\n if (!element) return;\n if (clamped * rowHeight < element.scrollTop) element.scrollTop = clamped * rowHeight;\n else if ((clamped + 1) * rowHeight > element.scrollTop + listHeight) element.scrollTop = (clamped + 1) * rowHeight - listHeight;\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const node = nodes[active];\n const handled = () => event.preventDefault();\n if (event.key === \"ArrowDown\") return handled(), focusRow(active + 1);\n if (event.key === \"ArrowUp\") return handled(), focusRow(active - 1);\n if (event.key === \"Home\") return handled(), focusRow(0);\n if (event.key === \"End\") return handled(), focusRow(nodes.length - 1);\n if (!node) return;\n const ref = refOf(node);\n if (event.key === \"ArrowRight\" && node.kind === \"table\" && !node.expanded) return handled(), toggle(node.name);\n if (event.key === \"ArrowLeft\") {\n handled();\n if (node.kind === \"table\" && node.expanded) return toggle(node.name);\n if (node.kind !== \"table\") return focusRow(nodes.findIndex((n) => n.kind === \"table\" && n.name === (node.kind === \"column\" ? node.tableName : \"\")));\n }\n if (event.key === \"Enter\" && ref) return handled(), props.onSelect?.(ref, (node as { table: TableSummary }).table);\n if (event.key === \"Insert\" && ref) return handled(), props.onInsert?.(nameOf(ref), ref);\n };\n\n const drag = (ref: SchemaRef) => (event: DragEvent) => {\n event.dataTransfer.setData(\"text/plain\", nameOf(ref));\n event.dataTransfer.setData(SCHEMA_REF_MIME, JSON.stringify(ref));\n event.dataTransfer.effectAllowed = \"copy\";\n };\n\n const rows = [];\n for (let index = first; index < last; index++) {\n const node = nodes[index]!;\n const ref = refOf(node);\n const common = {\n id: `sf-schema-${index}`,\n className: \"sf-schema-row\",\n \"data-kind\": node.kind,\n \"data-active\": index === active || undefined,\n style: { top: index * rowHeight, height: rowHeight },\n };\n if (node.kind === \"note\") {\n rows.push(\n <div key={node.key} {...common} role=\"treeitem\" aria-level={2} aria-selected={false} data-error={node.error || undefined}>\n {node.text}\n </div>,\n );\n continue;\n }\n const detail = node.kind === \"table\" ? details[node.name] : undefined;\n const rowCount = detail && typeof detail === \"object\" && \"rowCount\" in detail ? detail.rowCount : undefined;\n rows.push(\n <div\n key={node.key}\n {...common}\n role=\"treeitem\"\n aria-level={node.kind === \"table\" ? 1 : 2}\n aria-expanded={node.kind === \"table\" ? node.expanded : undefined}\n aria-selected={index === active}\n draggable\n onDragStart={drag(ref!)}\n onClick={() => {\n setActive(index);\n if (node.kind === \"table\") toggle(node.name);\n props.onSelect?.(ref!, node.table);\n }}\n onDoubleClick={() => props.onInsert?.(nameOf(ref!), ref!)}\n >\n {node.kind === \"table\" ? (\n <>\n <span className=\"sf-schema-caret\" aria-hidden=\"true\" data-open={node.expanded || undefined}>\n ▸\n </span>\n <span className=\"sf-schema-name\">{node.name}</span>\n {rowCount !== undefined && <span className=\"sf-schema-meta\">{count.format(Number(rowCount))} rows</span>}\n {FORMAT_LABEL[node.table.format] && <span className=\"sf-schema-tag\">{FORMAT_LABEL[node.table.format]}</span>}\n {props.renderActions && (\n <span className=\"sf-schema-actions\" onClick={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>\n {props.renderActions(ref!, node.table)}\n </span>\n )}\n </>\n ) : (\n <>\n <span className=\"sf-schema-name\">{node.column.name}</span>\n <span className=\"sf-schema-meta\">{node.column.nativeType.toLowerCase()}</span>\n </>\n )}\n </div>,\n );\n }\n\n return (\n <div className={[\"sf-schema\", props.className].filter(Boolean).join(\" \")} style={{ height }}>\n <input\n className=\"sf-input sf-schema-search\"\n type=\"search\"\n placeholder=\"Search tables\"\n aria-label=\"Search tables\"\n value={search}\n onChange={(event) => {\n setSearch(event.target.value);\n setActive(0);\n }}\n />\n <div\n ref={list}\n className=\"sf-schema-list\"\n role=\"tree\"\n aria-label={props.label ?? \"Tables\"}\n aria-busy={status.loading}\n aria-activedescendant={nodes.length > 0 ? `sf-schema-${active}` : undefined}\n tabIndex={0}\n onKeyDown={onKeyDown}\n onScroll={(event) => setScrollTop(event.currentTarget.scrollTop)}\n >\n <div style={{ height: nodes.length * rowHeight, position: \"relative\" }}>{rows}</div>\n {status.error && (\n <p className=\"sf-schema-empty\" role=\"alert\">\n {status.error}\n </p>\n )}\n {!status.loading && !status.error && tables.length === 0 && (\n <p className=\"sf-schema-empty\">{search ? `No tables match “${search}”.` : \"This source has no tables.\"}</p>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaExplorer.js","sourceRoot":"","sources":["../../src/schema/SchemaExplorer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAiC,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAsD,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAanD,mEAAmE;AACnE,MAAM,CAAC,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAkBjE,MAAM,YAAY,GAAyC;IACzD,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,SAAS;IAChC,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,KAAK;IACxB,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM;IAC1B,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,SAAS;IAChC,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,OAAO;CAC7B,CAAC;AAOF,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AAEnH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC;IACzC,MAAM,UAAU,GAAG,aAAa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AC,aAEhE,cAAK,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAG,IAAI,GAAO,EACnF,MAAM,CAAC,KAAK,IAAI,CACf,YAAG,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACxC,MAAM,CAAC,KAAK,GACX,CACL,EACA,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAC1D,YAAG,SAAS,EAAC,iBAAiB,YAAE,MAAM,CAAC,CAAC,CAAC,oBAAoB,MAAM,IAAI,CAAC,CAAC,CAAC,4BAA4B,GAAK,CAC5G,IACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { DataSource } from \"@surfaces-ui/data\";\nimport { type Column, type TableDetail, TableFormat, type TableSummary } from \"@surfaces-ui/proto\";\nimport { DENSITY_SCALE } from \"@surfaces-ui/tokens\";\nimport { type DragEvent, type KeyboardEvent, type ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useDataSource } from \"../data/DataSourceProvider.js\";\nimport { messageOf } from \"../data/useRowWindow.js\";\nimport { useOptionalTheme } from \"../theme/ThemeProvider.js\";\nimport { numberFormat } from \"../locale/locale.js\";\n\n/** A table or column, as handed to callbacks and placed on the clipboard when dragged. */\nexport interface SchemaRef {\n sourceId: string;\n /** Given when the source says which catalog the table is in. */\n catalog?: string;\n /** The schema, or the database on an engine that has no catalog above it. Given when the source says. */\n schema?: string;\n table: string;\n column?: string;\n}\n\n/** MIME type carrying a SchemaRef as JSON during drag and drop. */\nexport const SCHEMA_REF_MIME = \"application/x-surfaces-ref+json\";\n\nexport interface SchemaExplorerProps {\n sourceId: string;\n /** Called when a table or column is activated (click or Enter). */\n onSelect?(ref: SchemaRef, table: TableSummary): void;\n /** Called on double-click or Insert, with the name to insert into an editor. */\n onInsert?(name: string, ref: SchemaRef): void;\n /** Extra controls at the end of each table row, e.g. \"add to context\". */\n renderActions?(ref: SchemaRef, table: TableSummary): ReactNode;\n /** Height in px. Defaults to 420. */\n height?: number;\n dataSource?: DataSource;\n /** Accessible name. Defaults to \"Tables\". */\n label?: string;\n className?: string;\n}\n\nconst FORMAT_LABEL: Partial<Record<TableFormat, string>> = {\n [TableFormat.PARQUET]: \"Parquet\",\n [TableFormat.CSV]: \"CSV\",\n [TableFormat.JSON]: \"JSON\",\n [TableFormat.ICEBERG]: \"Iceberg\",\n [TableFormat.DELTA]: \"Delta\",\n};\n\ntype Node =\n | { kind: \"table\"; key: string; id: string; table: TableSummary; name: string; expanded: boolean }\n | { kind: \"column\"; key: string; id: string; table: TableSummary; column: Column }\n | { kind: \"note\"; key: string; text: string; error?: boolean };\n\nconst count = { format: (n: number) => numberFormat({ notation: \"compact\", maximumFractionDigits: 1 }).format(n) };\n\n/**\n * A searchable tree of a source's tables and their columns. Columns load when\n * a table is opened; only visible rows are in the DOM, so catalogs with\n * thousands of tables stay fast. Items can be dragged into SqlEditor.\n */\nexport function SchemaExplorer(props: SchemaExplorerProps) {\n const { sourceId, height = 420 } = props;\n const dataSource = useDataSource(props.dataSource);\n const theme = useOptionalTheme();\n const rowHeight = DENSITY_SCALE[theme?.theme.density ?? \"comfortable\"].rowHeight - 4;\n\n const [search, setSearch] = useState(\"\");\n const [tables, setTables] = useState<TableSummary[]>([]);\n const [status, setStatus] = useState<{ loading: boolean; error?: string }>({ loading: true });\n const [expanded, setExpanded] = useState<Set<string>>(new Set());\n const [details, setDetails] = useState<Record<string, TableDetail | { error: string } | \"loading\">>({});\n const [active, setActive] = useState(0);\n const [scrollTop, setScrollTop] = useState(0);\n const list = useRef<HTMLDivElement>(null);\n\n // Search runs on the backend so it works over catalogs too large to list.\n useEffect(() => {\n let current = true;\n setStatus({ loading: true });\n const timer = setTimeout(() => {\n dataSource\n .listTables({ sourceId, search: search.trim() })\n .then((response) => {\n if (!current) return;\n setTables(response.tables);\n setStatus({ loading: false });\n })\n .catch((error: unknown) => current && setStatus({ loading: false, error: messageOf(error) }));\n }, search ? 180 : 0);\n return () => {\n current = false;\n clearTimeout(timer);\n };\n }, [dataSource, sourceId, search]);\n\n // A table is known by its whole reference, never its name alone: a source with several\n // databases lists the same name once for each, and rows that shared a name were drawn\n // on top of one another.\n const toggle = (id: string, table: TableSummary) => {\n setExpanded((previous) => {\n const next = new Set(previous);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n return next;\n });\n if (details[id] === undefined) {\n setDetails((previous) => ({ ...previous, [id]: \"loading\" }));\n dataSource\n .describeTable({ sourceId, ref: { catalog: table.ref?.catalog, schema: table.ref?.schema, table: table.ref?.table ?? \"\" }, includeStats: true })\n .then((response) => setDetails((previous) => ({ ...previous, [id]: response.table ?? { error: \"No details.\" } })))\n .catch((error: unknown) => setDetails((previous) => ({ ...previous, [id]: { error: messageOf(error) } })));\n }\n };\n\n // The schema is shown only when the tables listed are in more than one, and the catalog likewise.\n const qualified = useMemo(() => {\n const catalogs = new Set(tables.map((table) => table.ref?.catalog ?? \"\"));\n const schemas = new Set(tables.map((table) => `${table.ref?.catalog ?? \"\"}\\u0000${table.ref?.schema ?? \"\"}`));\n return { catalog: catalogs.size > 1, schema: schemas.size > 1 };\n }, [tables]);\n\n const nodes = useMemo<Node[]>(() => {\n const out: Node[] = [];\n const seen = new Map<string, number>();\n for (const table of tables) {\n const name = table.ref?.table ?? \"\";\n const base = [table.ref?.catalog ?? \"\", table.ref?.schema ?? \"\", name].join(\"\\u0000\");\n // A source that lists one table twice still gets two rows that are told apart.\n const repeat = seen.get(base) ?? 0;\n seen.set(base, repeat + 1);\n const id = repeat ? `${base}\\u0000${repeat}` : base;\n const open = expanded.has(id);\n out.push({ kind: \"table\", key: `t:${id}`, id, table, name, expanded: open });\n if (!open) continue;\n const detail = details[id];\n if (detail === undefined || detail === \"loading\") out.push({ kind: \"note\", key: `n:${id}`, text: \"Loading columns…\" });\n else if (\"error\" in detail) out.push({ kind: \"note\", key: `n:${id}`, text: detail.error, error: true });\n else detail.columns.forEach((column, at) => out.push({ kind: \"column\", key: `c:${id}\\u0000${at}`, id, table, column }));\n }\n return out;\n }, [tables, expanded, details]);\n\n const listHeight = Math.max(rowHeight, height - 44);\n const first = Math.max(0, Math.floor(scrollTop / rowHeight) - 4);\n const last = Math.min(nodes.length, first + Math.ceil(listHeight / rowHeight) + 8);\n\n const refOf = (node: Node): SchemaRef | undefined => {\n if (node.kind === \"note\") return undefined;\n const { catalog, schema, table = \"\" } = node.table.ref ?? {};\n return { sourceId, ...(catalog ? { catalog } : {}), ...(schema ? { schema } : {}), table, ...(node.kind === \"column\" ? { column: node.column.name } : {}) };\n };\n /** What a table is drawn under: its schema, when the list holds more than one, and its catalog likewise. */\n const prefixOf = (ref: SchemaRef) => [qualified.catalog && ref.catalog, qualified.schema && ref.schema].filter(Boolean).map((part) => `${part}.`).join(\"\");\n // The name put into an editor says which table it is when the name alone would not.\n const nameOf = (ref: SchemaRef) => ref.column ?? prefixOf(ref) + ref.table;\n\n const focusRow = (index: number) => {\n const clamped = Math.max(0, Math.min(nodes.length - 1, index));\n setActive(clamped);\n const element = list.current;\n if (!element) return;\n if (clamped * rowHeight < element.scrollTop) element.scrollTop = clamped * rowHeight;\n else if ((clamped + 1) * rowHeight > element.scrollTop + listHeight) element.scrollTop = (clamped + 1) * rowHeight - listHeight;\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const node = nodes[active];\n const handled = () => event.preventDefault();\n if (event.key === \"ArrowDown\") return handled(), focusRow(active + 1);\n if (event.key === \"ArrowUp\") return handled(), focusRow(active - 1);\n if (event.key === \"Home\") return handled(), focusRow(0);\n if (event.key === \"End\") return handled(), focusRow(nodes.length - 1);\n if (!node) return;\n const ref = refOf(node);\n if (event.key === \"ArrowRight\" && node.kind === \"table\" && !node.expanded) return handled(), toggle(node.id, node.table);\n if (event.key === \"ArrowLeft\") {\n handled();\n if (node.kind === \"table\" && node.expanded) return toggle(node.id, node.table);\n if (node.kind !== \"table\") return focusRow(nodes.findIndex((n) => n.kind === \"table\" && n.id === (node.kind === \"column\" ? node.id : \"\")));\n }\n if (event.key === \"Enter\" && ref) return handled(), props.onSelect?.(ref, (node as { table: TableSummary }).table);\n if (event.key === \"Insert\" && ref) return handled(), props.onInsert?.(nameOf(ref), ref);\n };\n\n const drag = (ref: SchemaRef) => (event: DragEvent) => {\n event.dataTransfer.setData(\"text/plain\", nameOf(ref));\n event.dataTransfer.setData(SCHEMA_REF_MIME, JSON.stringify(ref));\n event.dataTransfer.effectAllowed = \"copy\";\n };\n\n const rows = [];\n for (let index = first; index < last; index++) {\n const node = nodes[index]!;\n const ref = refOf(node);\n const common = {\n id: `sf-schema-${index}`,\n className: \"sf-schema-row\",\n \"data-kind\": node.kind,\n \"data-active\": index === active || undefined,\n style: { top: index * rowHeight, height: rowHeight },\n };\n if (node.kind === \"note\") {\n rows.push(\n <div key={node.key} {...common} role=\"treeitem\" aria-level={2} aria-selected={false} data-error={node.error || undefined}>\n {node.text}\n </div>,\n );\n continue;\n }\n const detail = node.kind === \"table\" ? details[node.id] : undefined;\n const rowCount = detail && typeof detail === \"object\" && \"rowCount\" in detail ? detail.rowCount : undefined;\n rows.push(\n <div\n key={node.key}\n {...common}\n role=\"treeitem\"\n aria-level={node.kind === \"table\" ? 1 : 2}\n aria-expanded={node.kind === \"table\" ? node.expanded : undefined}\n aria-selected={index === active}\n draggable\n onDragStart={drag(ref!)}\n onClick={() => {\n setActive(index);\n if (node.kind === \"table\") toggle(node.id, node.table);\n props.onSelect?.(ref!, node.table);\n }}\n onDoubleClick={() => props.onInsert?.(nameOf(ref!), ref!)}\n >\n {node.kind === \"table\" ? (\n <>\n <span className=\"sf-schema-caret\" aria-hidden=\"true\" data-open={node.expanded || undefined}>\n ▸\n </span>\n <span className=\"sf-schema-name\">\n {prefixOf(ref!) && <span className=\"sf-schema-qualifier\">{prefixOf(ref!)}</span>}\n {node.name}\n </span>\n {rowCount !== undefined && <span className=\"sf-schema-meta\">{count.format(Number(rowCount))} rows</span>}\n {FORMAT_LABEL[node.table.format] && <span className=\"sf-schema-tag\">{FORMAT_LABEL[node.table.format]}</span>}\n {props.renderActions && (\n <span className=\"sf-schema-actions\" onClick={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>\n {props.renderActions(ref!, node.table)}\n </span>\n )}\n </>\n ) : (\n <>\n <span className=\"sf-schema-name\">{node.column.name}</span>\n <span className=\"sf-schema-meta\">{node.column.nativeType.toLowerCase()}</span>\n </>\n )}\n </div>,\n );\n }\n\n return (\n <div className={[\"sf-schema\", props.className].filter(Boolean).join(\" \")} style={{ height }}>\n <input\n className=\"sf-input sf-schema-search\"\n type=\"search\"\n placeholder=\"Search tables\"\n aria-label=\"Search tables\"\n value={search}\n onChange={(event) => {\n setSearch(event.target.value);\n setActive(0);\n }}\n />\n <div\n ref={list}\n className=\"sf-schema-list\"\n role=\"tree\"\n aria-label={props.label ?? \"Tables\"}\n aria-busy={status.loading}\n aria-activedescendant={nodes.length > 0 ? `sf-schema-${active}` : undefined}\n tabIndex={0}\n onKeyDown={onKeyDown}\n onScroll={(event) => setScrollTop(event.currentTarget.scrollTop)}\n >\n <div style={{ height: nodes.length * rowHeight, position: \"relative\" }}>{rows}</div>\n {status.error && (\n <p className=\"sf-schema-empty\" role=\"alert\">\n {status.error}\n </p>\n )}\n {!status.loading && !status.error && tables.length === 0 && (\n <p className=\"sf-schema-empty\">{search ? `No tables match “${search}”.` : \"This source has no tables.\"}</p>\n )}\n </div>\n </div>\n );\n}\n"]}
|
package/dist/site/Site.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
|
89
|
-
*
|
|
90
|
-
* than five seconds
|
|
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
|
|
48
|
-
*
|
|
49
|
-
* than five seconds
|
|
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 =
|
|
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 &&
|
|
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 }) {
|
package/dist/site/Site.js.map
CHANGED
|
@@ -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,I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C,SAAS,EAAC,cAAc,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,YACrE,KAAK,GACC,CACV,CAAC,CAAC,CAAC,CACF,KAAK,CACN,CACF,EACA,IAAI,IAAI,CACP,YAAG,SAAS,EAAC,mBAAmB,YAC9B,eAAM,QAAQ,EAAE,IAAI,YAAG,QAAQ,CAAC,IAAI,CAAC,GAAQ,GAC3C,CACL,EACA,OAAO,IAAI,YAAG,SAAS,EAAC,sBAAsB,YAAE,OAAO,GAAK,EAC5D,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAC1B,aAAI,SAAS,EAAC,mBAAmB,gBAAY,MAAM,YAChD,IAAI,CAAC,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,IAA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,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 /**\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"]}
|