@surfaces-ui/components 0.4.0 → 0.5.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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/source/SourceList.js +6 -0
- package/dist/source/SourceList.js.map +1 -1
- package/dist/styles.css +114 -2
- package/dist/styles.layer.css +114 -2
- package/dist/text/Image.d.ts +50 -0
- package/dist/text/Image.js +65 -0
- package/dist/text/Image.js.map +1 -0
- package/dist/text/Markdown.d.ts +5 -1
- package/dist/text/Markdown.js +4 -2
- package/dist/text/Markdown.js.map +1 -1
- package/dist/workspace/SideNav.d.ts +14 -0
- package/dist/workspace/SideNav.js +31 -3
- package/dist/workspace/SideNav.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./graph/model.js";
|
|
|
26
26
|
export * from "./discovery/AskData.js";
|
|
27
27
|
export * from "./model/ModelDiagram.js";
|
|
28
28
|
export * from "./text/Markdown.js";
|
|
29
|
+
export * from "./text/Image.js";
|
|
29
30
|
export * from "./source/SourceList.js";
|
|
30
31
|
export * from "./source/ConnectionBuilder.js";
|
|
31
32
|
export * from "./metric/Metric.js";
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./graph/model.js";
|
|
|
26
26
|
export * from "./discovery/AskData.js";
|
|
27
27
|
export * from "./model/ModelDiagram.js";
|
|
28
28
|
export * from "./text/Markdown.js";
|
|
29
|
+
export * from "./text/Image.js";
|
|
29
30
|
export * from "./source/SourceList.js";
|
|
30
31
|
export * from "./source/ConnectionBuilder.js";
|
|
31
32
|
export * from "./metric/Metric.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,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AC","sourcesContent":["export * from \"./locale/locale.js\";\nexport * from \"./locale/SurfacesText.js\";\nexport * from \"./theme/ThemeProvider.js\";\nexport * from \"./theme/ThemePicker.js\";\nexport * from \"./data/DataSourceProvider.js\";\nexport * from \"./data/format.js\";\nexport * from \"./data/useRowWindow.js\";\nexport * from \"./data/messages.js\";\nexport * from \"./data/DataNotes.js\";\nexport * from \"./grid/DataGrid.js\";\nexport * from \"./chart/Chart.js\";\nexport * from \"./chart/option.js\";\nexport * from \"./editor/SqlEditor.js\";\nexport * from \"./schema/SchemaExplorer.js\";\nexport * from \"./schema/ObjectBrowser.js\";\nexport * from \"./filter/FilterBar.js\";\nexport * from \"./pivot/PivotTable.js\";\nexport * from \"./result/QueryResult.js\";\nexport * from \"./discovery/shared.js\";\nexport * from \"./discovery/DataSearch.js\";\nexport * from \"./discovery/ObjectDetail.js\";\nexport * from \"./discovery/ContextBuilder.js\";\nexport * from \"./discovery/RelationshipGraph.js\";\nexport * from \"./graph/NodeGraph.js\";\nexport * from \"./graph/model.js\";\nexport * from \"./discovery/AskData.js\";\nexport * from \"./model/ModelDiagram.js\";\nexport * from \"./text/Markdown.js\";\nexport * from \"./source/SourceList.js\";\nexport * from \"./source/ConnectionBuilder.js\";\nexport * from \"./metric/Metric.js\";\nexport * from \"./rows/RowList.js\";\nexport * from \"./pipeline/Pipeline.js\";\nexport * from \"./panzoom/usePanZoom.js\";\nexport * from \"./data/export.js\";\nexport * from \"./plan/QueryPlan.js\";\nexport * from \"./pipeline/PipelineView.js\";\nexport * from \"./pipeline/DatasetReview.js\";\nexport * from \"./pipeline/IngestWizard.js\";\nexport * from \"./chart/advice.js\";\nexport * from \"./chart/Sparkline.js\";\nexport * from \"./chart/BulletGraph.js\";\nexport * from \"./metric/useMeasure.js\";\nexport * from \"./review/PlanReview.js\";\nexport * from \"./review/PiiReview.js\";\nexport * from \"./review/pii.js\";\nexport * from \"./review/StepFlow.js\";\nexport * from \"./review/ActionReceipt.js\";\nexport * from \"./menu/ContextMenu.js\";\nexport * from \"./schema/ObjectInfo.js\";\n// The plain filter form lives in @surfaces-ui/data, below every package that uses it.\nexport { type FilterOp, type FilterSpec, type SortSpec, FILTER_OPS, chosenValues, filterWords, filtersExcept, filtersFromSpec, filtersToSpec, joinRelative, parseFilterSpecs, parseSortSpecs, sinceLabel, sinceStart, sortsFromSpec, sortsToSpec, selectValues, splitRelative, toggleValueFilter, valueFilter } from \"@surfaces-ui/data\";\nexport * from \"./form/Form.js\";\nexport * from \"./workspace/layout.js\";\nexport * from \"./workspace/icons.js\";\nexport * from \"./workspace/Workspace.js\";\nexport * from \"./workspace/SideNav.js\";\nexport * from \"./workspace/NavBar.js\";\nexport * from \"./site/Site.js\";\nexport * from \"./schema/refs.js\";\nexport * from \"./files/files.js\";\nexport * from \"./files/FileBrowser.js\";\nexport * from \"./filter/QueryFilters.js\";\nexport * from \"./explore/model.js\";\nexport * from \"./explore/Explorer.js\";\nexport * from \"./explore/report.js\";\nexport * from \"./explore/ReportBuilder.js\";\nexport * from \"./explore/semantic.js\";\nexport * from \"./explore/SemanticsProvider.js\";\nexport * from \"./explore/SemanticModelEditor.js\";\nexport * from \"./explore/SemanticRows.js\";\nexport * from \"./explore/ModelLineage.js\";\nexport * from \"./explore/semantic-proposal.js\";\nexport * from \"./controls/ItemControls.js\";\nexport * from \"./controls/context.js\";\nexport * from \"./controls/ResizeHandle.js\";\nexport * from \"./controls/SegmentedControl.js\";\nexport * from \"./controls/ConfirmDialog.js\";\nexport * from \"./controls/StatusBadge.js\";\nexport * from \"./controls/Combobox.js\";\nexport * from \"./controls/Popover.js\";\nexport * from \"./table/DataTable.js\";\nexport * from \"./table/SelectionBar.js\";\nexport * from \"./table/Pagination.js\";\nexport * from \"./controls/resize.js\";\nexport * from \"./appComponents.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC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ACrC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./locale/locale.js\";\nexport * from \"./locale/SurfacesText.js\";\nexport * from \"./theme/ThemeProvider.js\";\nexport * from \"./theme/ThemePicker.js\";\nexport * from \"./data/DataSourceProvider.js\";\nexport * from \"./data/format.js\";\nexport * from \"./data/useRowWindow.js\";\nexport * from \"./data/messages.js\";\nexport * from \"./data/DataNotes.js\";\nexport * from \"./grid/DataGrid.js\";\nexport * from \"./chart/Chart.js\";\nexport * from \"./chart/option.js\";\nexport * from \"./editor/SqlEditor.js\";\nexport * from \"./schema/SchemaExplorer.js\";\nexport * from \"./schema/ObjectBrowser.js\";\nexport * from \"./filter/FilterBar.js\";\nexport * from \"./pivot/PivotTable.js\";\nexport * from \"./result/QueryResult.js\";\nexport * from \"./discovery/shared.js\";\nexport * from \"./discovery/DataSearch.js\";\nexport * from \"./discovery/ObjectDetail.js\";\nexport * from \"./discovery/ContextBuilder.js\";\nexport * from \"./discovery/RelationshipGraph.js\";\nexport * from \"./graph/NodeGraph.js\";\nexport * from \"./graph/model.js\";\nexport * from \"./discovery/AskData.js\";\nexport * from \"./model/ModelDiagram.js\";\nexport * from \"./text/Markdown.js\";\nexport * from \"./text/Image.js\";\nexport * from \"./source/SourceList.js\";\nexport * from \"./source/ConnectionBuilder.js\";\nexport * from \"./metric/Metric.js\";\nexport * from \"./rows/RowList.js\";\nexport * from \"./pipeline/Pipeline.js\";\nexport * from \"./panzoom/usePanZoom.js\";\nexport * from \"./data/export.js\";\nexport * from \"./plan/QueryPlan.js\";\nexport * from \"./pipeline/PipelineView.js\";\nexport * from \"./pipeline/DatasetReview.js\";\nexport * from \"./pipeline/IngestWizard.js\";\nexport * from \"./chart/advice.js\";\nexport * from \"./chart/Sparkline.js\";\nexport * from \"./chart/BulletGraph.js\";\nexport * from \"./metric/useMeasure.js\";\nexport * from \"./review/PlanReview.js\";\nexport * from \"./review/PiiReview.js\";\nexport * from \"./review/pii.js\";\nexport * from \"./review/StepFlow.js\";\nexport * from \"./review/ActionReceipt.js\";\nexport * from \"./menu/ContextMenu.js\";\nexport * from \"./schema/ObjectInfo.js\";\n// The plain filter form lives in @surfaces-ui/data, below every package that uses it.\nexport { type FilterOp, type FilterSpec, type SortSpec, FILTER_OPS, chosenValues, filterWords, filtersExcept, filtersFromSpec, filtersToSpec, joinRelative, parseFilterSpecs, parseSortSpecs, sinceLabel, sinceStart, sortsFromSpec, sortsToSpec, selectValues, splitRelative, toggleValueFilter, valueFilter } from \"@surfaces-ui/data\";\nexport * from \"./form/Form.js\";\nexport * from \"./workspace/layout.js\";\nexport * from \"./workspace/icons.js\";\nexport * from \"./workspace/Workspace.js\";\nexport * from \"./workspace/SideNav.js\";\nexport * from \"./workspace/NavBar.js\";\nexport * from \"./site/Site.js\";\nexport * from \"./schema/refs.js\";\nexport * from \"./files/files.js\";\nexport * from \"./files/FileBrowser.js\";\nexport * from \"./filter/QueryFilters.js\";\nexport * from \"./explore/model.js\";\nexport * from \"./explore/Explorer.js\";\nexport * from \"./explore/report.js\";\nexport * from \"./explore/ReportBuilder.js\";\nexport * from \"./explore/semantic.js\";\nexport * from \"./explore/SemanticsProvider.js\";\nexport * from \"./explore/SemanticModelEditor.js\";\nexport * from \"./explore/SemanticRows.js\";\nexport * from \"./explore/ModelLineage.js\";\nexport * from \"./explore/semantic-proposal.js\";\nexport * from \"./controls/ItemControls.js\";\nexport * from \"./controls/context.js\";\nexport * from \"./controls/ResizeHandle.js\";\nexport * from \"./controls/SegmentedControl.js\";\nexport * from \"./controls/ConfirmDialog.js\";\nexport * from \"./controls/StatusBadge.js\";\nexport * from \"./controls/Combobox.js\";\nexport * from \"./controls/Popover.js\";\nexport * from \"./table/DataTable.js\";\nexport * from \"./table/SelectionBar.js\";\nexport * from \"./table/Pagination.js\";\nexport * from \"./controls/resize.js\";\nexport * from \"./appComponents.js\";\n"]}
|
|
@@ -8,6 +8,12 @@ const ENGINE_LABEL = {
|
|
|
8
8
|
[Engine.DATAFUSION]: "DataFusion",
|
|
9
9
|
[Engine.TERADATA]: "Teradata",
|
|
10
10
|
[Engine.POSTGRES]: "Postgres",
|
|
11
|
+
[Engine.MYSQL]: "MySQL",
|
|
12
|
+
[Engine.SQLSERVER]: "SQL Server",
|
|
13
|
+
[Engine.SNOWFLAKE]: "Snowflake",
|
|
14
|
+
[Engine.BIGQUERY]: "BigQuery",
|
|
15
|
+
[Engine.DATABRICKS]: "Databricks",
|
|
16
|
+
[Engine.ORACLE]: "Oracle",
|
|
11
17
|
};
|
|
12
18
|
export const CONNECTION_LABEL = {
|
|
13
19
|
[ConnectionKind.S3]: "Amazon S3",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceList.js","sourceRoot":"","sources":["../../src/source/SourceList.tsx"],"names":[],"mappings":";AACA,OAAO,EAAmB,cAAc,EAAE,MAAM,EAAwC,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AASpD,MAAM,YAAY,GAAoC;IACpD,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ;IACzB,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,YAAY;IACjC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC7B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAA4C;IACvE,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,WAAW;IAChC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,sBAAsB;IAC5C,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,eAAe;IACvC,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,aAAa;IACpC,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,sBA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,CAAC,CAAC,CAAC,GAAG,GAAQ,OAAE,IAAI,CAAC,OAAO,EAClE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,QAAQ,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,cAAK,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WACzH,EACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CACzB,aAAI,SAAS,EAAC,kBAAkB,YAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1B,yBAA8B,KAAK,CAAC,EAAE,IAAI,SAAS,aACjD,8BAAkB,MAAM,YAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAQ,EACtD,2BAAS,KAAK,CAAC,IAAI,GAAU,EAC7B,yBAAO,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAQ,KAH9C,KAAK,CAAC,IAAI,CAId,CACN,CAAC,GACC,CACN,IACA,CACJ,IACG,KA3EC,MAAM,CAAC,EAAE,CA4Eb,CACN,CAAC;QACJ,CAAC,CAAC,GACC,CACN,CAAC;AACJ,CAAC","sourcesContent":["import type { DataSource } from \"@surfaces-ui/data\";\nimport { type Connection, ConnectionKind, Engine, type Source, type TestSourceResponse } from \"@surfaces-ui/proto\";\nimport { useEffect, useState } from \"react\";\nimport { useDataSource } from \"../data/DataSourceProvider.js\";\nimport { messageOf } from \"../data/useRowWindow.js\";\n\nexport interface SourceListProps {\n /** Called when a source is chosen. */\n onSelect?(source: Source): void;\n dataSource?: DataSource;\n className?: string;\n}\n\nconst ENGINE_LABEL: Partial<Record<Engine, string>> = {\n [Engine.DUCKDB]: \"DuckDB\",\n [Engine.DATAFUSION]: \"DataFusion\",\n [Engine.TERADATA]: \"Teradata\",\n [Engine.POSTGRES]: \"Postgres\",\n};\n\nexport const CONNECTION_LABEL: Partial<Record<ConnectionKind, string>> = {\n [ConnectionKind.S3]: \"Amazon S3\",\n [ConnectionKind.GCS]: \"Google Cloud Storage\",\n [ConnectionKind.AZURE]: \"Azure Storage\",\n [ConnectionKind.HTTP]: \"Web (https)\",\n [ConnectionKind.ICEBERG_REST]: \"Iceberg REST catalog\",\n [ConnectionKind.DATABASE_FILE]: \"Database file\",\n [ConnectionKind.POSTGRES]: \"Postgres database\",\n};\n\n/** How a connection signs in, in words. Only the secret's name is ever known here. */\nexport function credentialText(connection: Connection): string {\n if (connection.ambientCredentials) return \"The server's own cloud credentials\";\n return connection.credentialsSecret ? `Secret ${connection.credentialsSecret}` : \"None (public)\";\n}\n\n/**\n * The data sources a backend offers: what runs their SQL, how they reach\n * storage and catalogs, and whether each table can be reached right now.\n * Credentials are shown by name only; their values never leave the server.\n */\nexport function SourceList(props: SourceListProps) {\n const dataSource = useDataSource(props.dataSource);\n const [sources, setSources] = useState<Source[] | undefined>();\n const [error, setError] = useState<string | undefined>();\n const [tests, setTests] = useState<Record<string, TestSourceResponse | \"running\" | { error: string }>>({});\n\n useEffect(() => {\n let current = true;\n dataSource\n .listSources({})\n .then((response) => current && setSources(response.sources))\n .catch((e: unknown) => current && setError(messageOf(e)));\n return () => {\n current = false;\n };\n }, [dataSource]);\n\n const test = (id: string) => {\n if (!dataSource.testSource) return;\n setTests((previous) => ({ ...previous, [id]: \"running\" }));\n dataSource\n .testSource({ target: { case: \"id\", value: id } })\n .then((response) => setTests((previous) => ({ ...previous, [id]: response })))\n .catch((e: unknown) => setTests((previous) => ({ ...previous, [id]: { error: messageOf(e) } })));\n };\n\n if (error) {\n return (\n <p className=\"sf-search-error\" role=\"alert\">\n {error}\n </p>\n );\n }\n if (!sources) return <p className=\"sf-object-muted\">Loading…</p>;\n if (sources.length === 0) return <p className=\"sf-object-muted\">No sources are configured.</p>;\n\n return (\n <ul className={[\"sf-sources\", props.className].filter(Boolean).join(\" \")}>\n {sources.map((source) => {\n const result = tests[source.id];\n const done = result && result !== \"running\" && !(\"error\" in result) ? result : undefined;\n return (\n <li key={source.id} className=\"sf-source\">\n <header className=\"sf-source-head\">\n <div>\n <h3 className=\"sf-object-title\">{source.displayName || source.id}</h3>\n <p className=\"sf-object-facts\">\n {[source.id, ENGINE_LABEL[source.engine], source.readOnly ? \"Read only\" : undefined, source.capabilities?.timeTravel ? \"Time travel\" : undefined, source.capabilities?.storedResults ? \"Keeps results\" : undefined]\n .filter(Boolean)\n .join(\" · \")}\n </p>\n </div>\n <div className=\"sf-object-buttons\">\n {props.onSelect && (\n <button type=\"button\" className=\"sf-button\" onClick={() => props.onSelect?.(source)}>\n Open\n </button>\n )}\n {dataSource.testSource && (\n <button type=\"button\" className=\"sf-button\" disabled={result === \"running\"} onClick={() => test(source.id)}>\n {result === \"running\" ? \"Testing…\" : \"Test connection\"}\n </button>\n )}\n </div>\n </header>\n\n {source.connections.length > 0 && (\n <div className=\"sf-object-table\" tabIndex={0} role=\"region\" aria-label={`Connections of ${source.displayName || source.id}`}>\n <table>\n <caption className=\"sf-a2-visually-hidden\">Connections of {source.displayName || source.id}</caption>\n <thead>\n <tr>\n <th scope=\"col\">Connection</th>\n <th scope=\"col\">Type</th>\n <th scope=\"col\">Covers</th>\n <th scope=\"col\">Signs in with</th>\n </tr>\n </thead>\n <tbody>\n {source.connections.map((connection) => (\n <tr key={connection.name}>\n <th scope=\"row\">{connection.name}</th>\n <td>{CONNECTION_LABEL[connection.kind] ?? \"Other\"}</td>\n <td className=\"sf-object-type\">{connection.scope}</td>\n <td>{credentialText(connection)}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n\n <div aria-live=\"polite\">\n {result && result !== \"running\" && \"error\" in result && (\n <p className=\"sf-search-error\" role=\"alert\">\n {result.error}\n </p>\n )}\n {done && (\n <>\n <p className=\"sf-source-result\" data-ok={done.ok || undefined}>\n <span aria-hidden=\"true\">{done.ok ? \"✓\" : \"!\"}</span> {done.message}\n {done.engineVersion ? ` · ${ENGINE_LABEL[source.engine] ?? \"Engine\"} ${done.engineVersion}` : \"\"} · {Number(done.elapsedMs)} ms\n </p>\n {done.checks.length > 0 && (\n <ul className=\"sf-source-checks\">\n {done.checks.map((check) => (\n <li key={check.name} data-ok={check.ok || undefined}>\n <span aria-hidden=\"true\">{check.ok ? \"✓\" : \"!\"}</span>\n <strong>{check.name}</strong>\n <span>{check.ok ? \"Reachable\" : check.message}</span>\n </li>\n ))}\n </ul>\n )}\n </>\n )}\n </div>\n </li>\n );\n })}\n </ul>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SourceList.js","sourceRoot":"","sources":["../../src/source/SourceList.tsx"],"names":[],"mappings":";AACA,OAAO,EAAmB,cAAc,EAAE,MAAM,EAAwC,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AASpD,MAAM,YAAY,GAAoC;IACpD,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ;IACzB,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,YAAY;IACjC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC7B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC7B,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO;IACvB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,YAAY;IAChC,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,WAAW;IAC/B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC7B,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,YAAY;IACjC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ;CA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,KAAK,SAAS,IAAI,OAAO,IAAI,MAAM,IAAI,CACtD,YAAG,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACxC,MAAM,CAAC,KAAK,GACX,CACL,EACA,IAAI,IAAI,CACP,8BACE,aAAG,SAAS,EAAC,kBAAkB,aAAU,IAAI,CAAC,EAAE,IAAI,SAAS,aAC3D,8BAAkB,MAAM,YAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAQ,OAAE,IAAI,CAAC,OAAO,EAClE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,QAAQ,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,cAAK,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WACzH,EACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CACzB,aAAI,SAAS,EAAC,kBAAkB,YAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1B,yBAA8B,KAAK,CAAC,EAAE,IAAI,SAAS,aACjD,8BAAkB,MAAM,YAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAQ,EACtD,2BAAS,KAAK,CAAC,IAAI,GAAU,EAC7B,yBAAO,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAQ,KAH9C,KAAK,CAAC,IAAI,CAId,CACN,CAAC,GACC,CACN,IACA,CACJ,IACG,KA3EC,MAAM,CAAC,EAAE,CA4Eb,CACN,CAAC;QACJ,CAAC,CAAC,GACC,CACN,CAAC;AACJ,CAAC","sourcesContent":["import type { DataSource } from \"@surfaces-ui/data\";\nimport { type Connection, ConnectionKind, Engine, type Source, type TestSourceResponse } from \"@surfaces-ui/proto\";\nimport { useEffect, useState } from \"react\";\nimport { useDataSource } from \"../data/DataSourceProvider.js\";\nimport { messageOf } from \"../data/useRowWindow.js\";\n\nexport interface SourceListProps {\n /** Called when a source is chosen. */\n onSelect?(source: Source): void;\n dataSource?: DataSource;\n className?: string;\n}\n\nconst ENGINE_LABEL: Partial<Record<Engine, string>> = {\n [Engine.DUCKDB]: \"DuckDB\",\n [Engine.DATAFUSION]: \"DataFusion\",\n [Engine.TERADATA]: \"Teradata\",\n [Engine.POSTGRES]: \"Postgres\",\n [Engine.MYSQL]: \"MySQL\",\n [Engine.SQLSERVER]: \"SQL Server\",\n [Engine.SNOWFLAKE]: \"Snowflake\",\n [Engine.BIGQUERY]: \"BigQuery\",\n [Engine.DATABRICKS]: \"Databricks\",\n [Engine.ORACLE]: \"Oracle\",\n};\n\nexport const CONNECTION_LABEL: Partial<Record<ConnectionKind, string>> = {\n [ConnectionKind.S3]: \"Amazon S3\",\n [ConnectionKind.GCS]: \"Google Cloud Storage\",\n [ConnectionKind.AZURE]: \"Azure Storage\",\n [ConnectionKind.HTTP]: \"Web (https)\",\n [ConnectionKind.ICEBERG_REST]: \"Iceberg REST catalog\",\n [ConnectionKind.DATABASE_FILE]: \"Database file\",\n [ConnectionKind.POSTGRES]: \"Postgres database\",\n};\n\n/** How a connection signs in, in words. Only the secret's name is ever known here. */\nexport function credentialText(connection: Connection): string {\n if (connection.ambientCredentials) return \"The server's own cloud credentials\";\n return connection.credentialsSecret ? `Secret ${connection.credentialsSecret}` : \"None (public)\";\n}\n\n/**\n * The data sources a backend offers: what runs their SQL, how they reach\n * storage and catalogs, and whether each table can be reached right now.\n * Credentials are shown by name only; their values never leave the server.\n */\nexport function SourceList(props: SourceListProps) {\n const dataSource = useDataSource(props.dataSource);\n const [sources, setSources] = useState<Source[] | undefined>();\n const [error, setError] = useState<string | undefined>();\n const [tests, setTests] = useState<Record<string, TestSourceResponse | \"running\" | { error: string }>>({});\n\n useEffect(() => {\n let current = true;\n dataSource\n .listSources({})\n .then((response) => current && setSources(response.sources))\n .catch((e: unknown) => current && setError(messageOf(e)));\n return () => {\n current = false;\n };\n }, [dataSource]);\n\n const test = (id: string) => {\n if (!dataSource.testSource) return;\n setTests((previous) => ({ ...previous, [id]: \"running\" }));\n dataSource\n .testSource({ target: { case: \"id\", value: id } })\n .then((response) => setTests((previous) => ({ ...previous, [id]: response })))\n .catch((e: unknown) => setTests((previous) => ({ ...previous, [id]: { error: messageOf(e) } })));\n };\n\n if (error) {\n return (\n <p className=\"sf-search-error\" role=\"alert\">\n {error}\n </p>\n );\n }\n if (!sources) return <p className=\"sf-object-muted\">Loading…</p>;\n if (sources.length === 0) return <p className=\"sf-object-muted\">No sources are configured.</p>;\n\n return (\n <ul className={[\"sf-sources\", props.className].filter(Boolean).join(\" \")}>\n {sources.map((source) => {\n const result = tests[source.id];\n const done = result && result !== \"running\" && !(\"error\" in result) ? result : undefined;\n return (\n <li key={source.id} className=\"sf-source\">\n <header className=\"sf-source-head\">\n <div>\n <h3 className=\"sf-object-title\">{source.displayName || source.id}</h3>\n <p className=\"sf-object-facts\">\n {[source.id, ENGINE_LABEL[source.engine], source.readOnly ? \"Read only\" : undefined, source.capabilities?.timeTravel ? \"Time travel\" : undefined, source.capabilities?.storedResults ? \"Keeps results\" : undefined]\n .filter(Boolean)\n .join(\" · \")}\n </p>\n </div>\n <div className=\"sf-object-buttons\">\n {props.onSelect && (\n <button type=\"button\" className=\"sf-button\" onClick={() => props.onSelect?.(source)}>\n Open\n </button>\n )}\n {dataSource.testSource && (\n <button type=\"button\" className=\"sf-button\" disabled={result === \"running\"} onClick={() => test(source.id)}>\n {result === \"running\" ? \"Testing…\" : \"Test connection\"}\n </button>\n )}\n </div>\n </header>\n\n {source.connections.length > 0 && (\n <div className=\"sf-object-table\" tabIndex={0} role=\"region\" aria-label={`Connections of ${source.displayName || source.id}`}>\n <table>\n <caption className=\"sf-a2-visually-hidden\">Connections of {source.displayName || source.id}</caption>\n <thead>\n <tr>\n <th scope=\"col\">Connection</th>\n <th scope=\"col\">Type</th>\n <th scope=\"col\">Covers</th>\n <th scope=\"col\">Signs in with</th>\n </tr>\n </thead>\n <tbody>\n {source.connections.map((connection) => (\n <tr key={connection.name}>\n <th scope=\"row\">{connection.name}</th>\n <td>{CONNECTION_LABEL[connection.kind] ?? \"Other\"}</td>\n <td className=\"sf-object-type\">{connection.scope}</td>\n <td>{credentialText(connection)}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n\n <div aria-live=\"polite\">\n {result && result !== \"running\" && \"error\" in result && (\n <p className=\"sf-search-error\" role=\"alert\">\n {result.error}\n </p>\n )}\n {done && (\n <>\n <p className=\"sf-source-result\" data-ok={done.ok || undefined}>\n <span aria-hidden=\"true\">{done.ok ? \"✓\" : \"!\"}</span> {done.message}\n {done.engineVersion ? ` · ${ENGINE_LABEL[source.engine] ?? \"Engine\"} ${done.engineVersion}` : \"\"} · {Number(done.elapsedMs)} ms\n </p>\n {done.checks.length > 0 && (\n <ul className=\"sf-source-checks\">\n {done.checks.map((check) => (\n <li key={check.name} data-ok={check.ok || undefined}>\n <span aria-hidden=\"true\">{check.ok ? \"✓\" : \"!\"}</span>\n <strong>{check.name}</strong>\n <span>{check.ok ? \"Reachable\" : check.message}</span>\n </li>\n ))}\n </ul>\n )}\n </>\n )}\n </div>\n </li>\n );\n })}\n </ul>\n );\n}\n"]}
|
package/dist/styles.css
CHANGED
|
@@ -2968,6 +2968,56 @@ select.sf-input:disabled {
|
|
|
2968
2968
|
margin-block: var(--sf-space-2);
|
|
2969
2969
|
border-radius: var(--sf-radius);
|
|
2970
2970
|
}
|
|
2971
|
+
/* The catalog's Image: a picture the host found an address for, or its description in a dashed box. */
|
|
2972
|
+
.sf-image {
|
|
2973
|
+
display: grid;
|
|
2974
|
+
gap: var(--sf-space-2);
|
|
2975
|
+
justify-items: start;
|
|
2976
|
+
max-width: min(100%, var(--sf-image-width, 100%));
|
|
2977
|
+
margin: 0;
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
.sf-image-body {
|
|
2981
|
+
display: block;
|
|
2982
|
+
max-width: 100%;
|
|
2983
|
+
height: auto;
|
|
2984
|
+
max-height: var(--sf-image-max-height, none);
|
|
2985
|
+
border-radius: var(--sf-radius);
|
|
2986
|
+
object-fit: contain;
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
.sf-image[data-fixed] .sf-image-body,
|
|
2990
|
+
.sf-image[data-fixed] .sf-image-missing {
|
|
2991
|
+
width: 100%;
|
|
2992
|
+
height: var(--sf-image-height);
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
.sf-image[data-fit="cover"] .sf-image-body {
|
|
2996
|
+
object-fit: cover;
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
.sf-image-missing {
|
|
3000
|
+
display: grid;
|
|
3001
|
+
place-items: center;
|
|
3002
|
+
box-sizing: border-box;
|
|
3003
|
+
width: 100%;
|
|
3004
|
+
min-height: calc(var(--sf-space-8) * 2);
|
|
3005
|
+
max-height: var(--sf-image-max-height, none);
|
|
3006
|
+
padding: var(--sf-space-4);
|
|
3007
|
+
border: 1px dashed var(--sf-color-border);
|
|
3008
|
+
border-radius: var(--sf-radius);
|
|
3009
|
+
background: var(--sf-color-bg-3);
|
|
3010
|
+
color: var(--sf-color-muted);
|
|
3011
|
+
font-size: var(--sf-font-size-sm);
|
|
3012
|
+
text-align: center;
|
|
3013
|
+
overflow: hidden;
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
.sf-image figcaption {
|
|
3017
|
+
color: var(--sf-color-muted);
|
|
3018
|
+
font-size: var(--sf-font-size-sm);
|
|
3019
|
+
}
|
|
3020
|
+
|
|
2971
3021
|
.sf-markdown > * {
|
|
2972
3022
|
margin: 0;
|
|
2973
3023
|
}
|
|
@@ -3024,7 +3074,7 @@ select.sf-input:disabled {
|
|
|
3024
3074
|
}
|
|
3025
3075
|
|
|
3026
3076
|
.sf-markdown-table:focus-visible {
|
|
3027
|
-
outline: 2px solid var(--sf-color-focus
|
|
3077
|
+
outline: 2px solid var(--sf-color-focus);
|
|
3028
3078
|
outline-offset: 2px;
|
|
3029
3079
|
}
|
|
3030
3080
|
|
|
@@ -3671,6 +3721,25 @@ select.sf-input:disabled {
|
|
|
3671
3721
|
color: var(--sf-color-danger);
|
|
3672
3722
|
}
|
|
3673
3723
|
|
|
3724
|
+
/* A picture attached to a message: a small thumbnail in the chip, the file's name beside it. */
|
|
3725
|
+
.sf-chat-reference[data-kind="attachment"] {
|
|
3726
|
+
font-family: var(--sf-font);
|
|
3727
|
+
}
|
|
3728
|
+
|
|
3729
|
+
.sf-chat-reference[data-thumbnail] {
|
|
3730
|
+
padding-inline-start: var(--sf-space-1);
|
|
3731
|
+
}
|
|
3732
|
+
|
|
3733
|
+
.sf-chat-thumbnail {
|
|
3734
|
+
flex: none;
|
|
3735
|
+
box-sizing: border-box;
|
|
3736
|
+
width: var(--sf-control-size);
|
|
3737
|
+
height: var(--sf-control-size);
|
|
3738
|
+
border-radius: var(--sf-radius-sm);
|
|
3739
|
+
object-fit: cover;
|
|
3740
|
+
background: var(--sf-color-bg-3);
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3674
3743
|
/* What a message is about that is not data reads as words, not a name. */
|
|
3675
3744
|
.sf-chat-reference[data-kind="context"] {
|
|
3676
3745
|
font-family: var(--sf-font);
|
|
@@ -4285,6 +4354,48 @@ select.sf-input:disabled {
|
|
|
4285
4354
|
margin-inline-start: auto;
|
|
4286
4355
|
}
|
|
4287
4356
|
|
|
4357
|
+
.sf-a2-conversation {
|
|
4358
|
+
display: grid;
|
|
4359
|
+
gap: var(--sf-space-3);
|
|
4360
|
+
min-inline-size: 0;
|
|
4361
|
+
}
|
|
4362
|
+
|
|
4363
|
+
.sf-a2-conversation-thread {
|
|
4364
|
+
display: grid;
|
|
4365
|
+
align-content: start;
|
|
4366
|
+
gap: var(--sf-space-3);
|
|
4367
|
+
max-block-size: 32rem;
|
|
4368
|
+
overflow-y: auto;
|
|
4369
|
+
overscroll-behavior: contain;
|
|
4370
|
+
padding: var(--sf-space-1);
|
|
4371
|
+
border-radius: var(--sf-radius-md);
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4374
|
+
.sf-a2-conversation-thread:focus-visible {
|
|
4375
|
+
outline: 2px solid var(--sf-color-focus);
|
|
4376
|
+
outline-offset: 2px;
|
|
4377
|
+
}
|
|
4378
|
+
|
|
4379
|
+
.sf-a2-conversation-waiting {
|
|
4380
|
+
margin: 0;
|
|
4381
|
+
color: var(--sf-color-muted);
|
|
4382
|
+
font-size: var(--sf-font-size-sm);
|
|
4383
|
+
}
|
|
4384
|
+
|
|
4385
|
+
.sf-a2-conversation-composer {
|
|
4386
|
+
display: flex;
|
|
4387
|
+
gap: var(--sf-space-2);
|
|
4388
|
+
align-items: end;
|
|
4389
|
+
}
|
|
4390
|
+
|
|
4391
|
+
.sf-a2-conversation-composer > textarea {
|
|
4392
|
+
flex: 1;
|
|
4393
|
+
min-inline-size: 0;
|
|
4394
|
+
resize: vertical;
|
|
4395
|
+
field-sizing: content;
|
|
4396
|
+
max-block-size: 10rem;
|
|
4397
|
+
}
|
|
4398
|
+
|
|
4288
4399
|
.sf-a2-message-who {
|
|
4289
4400
|
display: flex;
|
|
4290
4401
|
flex-wrap: wrap;
|
|
@@ -6576,7 +6687,8 @@ select.sf-input:disabled {
|
|
|
6576
6687
|
/* Folded away, the panel waits off the left edge of its stage and slides in when the menu button is pressed: a drawer
|
|
6577
6688
|
beside a dimmed page where there is room, the whole stage where there is not. The stage is the window, or the part
|
|
6578
6689
|
on screen of the region the navigation is drawn in (measured when it opens, since a fixed box cannot be told its
|
|
6579
|
-
container in CSS
|
|
6690
|
+
container in CSS; the offsets are counted from the stage's own containing block, which a contained or
|
|
6691
|
+
transformed holder is, so they are not always the window's), and it clips the drawer, so nothing outside that region is covered even while it slides. Hover
|
|
6580
6692
|
and focus do not open it: a drawer that opened under a passing pointer would cover the page by surprise. */
|
|
6581
6693
|
.sf-sidenav[data-pinned="false"] .sf-sidenav-stage {
|
|
6582
6694
|
display: block;
|
package/dist/styles.layer.css
CHANGED
|
@@ -2970,6 +2970,56 @@ select.sf-input:disabled {
|
|
|
2970
2970
|
margin-block: var(--sf-space-2);
|
|
2971
2971
|
border-radius: var(--sf-radius);
|
|
2972
2972
|
}
|
|
2973
|
+
/* The catalog's Image: a picture the host found an address for, or its description in a dashed box. */
|
|
2974
|
+
.sf-image {
|
|
2975
|
+
display: grid;
|
|
2976
|
+
gap: var(--sf-space-2);
|
|
2977
|
+
justify-items: start;
|
|
2978
|
+
max-width: min(100%, var(--sf-image-width, 100%));
|
|
2979
|
+
margin: 0;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
.sf-image-body {
|
|
2983
|
+
display: block;
|
|
2984
|
+
max-width: 100%;
|
|
2985
|
+
height: auto;
|
|
2986
|
+
max-height: var(--sf-image-max-height, none);
|
|
2987
|
+
border-radius: var(--sf-radius);
|
|
2988
|
+
object-fit: contain;
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
.sf-image[data-fixed] .sf-image-body,
|
|
2992
|
+
.sf-image[data-fixed] .sf-image-missing {
|
|
2993
|
+
width: 100%;
|
|
2994
|
+
height: var(--sf-image-height);
|
|
2995
|
+
}
|
|
2996
|
+
|
|
2997
|
+
.sf-image[data-fit="cover"] .sf-image-body {
|
|
2998
|
+
object-fit: cover;
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
.sf-image-missing {
|
|
3002
|
+
display: grid;
|
|
3003
|
+
place-items: center;
|
|
3004
|
+
box-sizing: border-box;
|
|
3005
|
+
width: 100%;
|
|
3006
|
+
min-height: calc(var(--sf-space-8) * 2);
|
|
3007
|
+
max-height: var(--sf-image-max-height, none);
|
|
3008
|
+
padding: var(--sf-space-4);
|
|
3009
|
+
border: 1px dashed var(--sf-color-border);
|
|
3010
|
+
border-radius: var(--sf-radius);
|
|
3011
|
+
background: var(--sf-color-bg-3);
|
|
3012
|
+
color: var(--sf-color-muted);
|
|
3013
|
+
font-size: var(--sf-font-size-sm);
|
|
3014
|
+
text-align: center;
|
|
3015
|
+
overflow: hidden;
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
.sf-image figcaption {
|
|
3019
|
+
color: var(--sf-color-muted);
|
|
3020
|
+
font-size: var(--sf-font-size-sm);
|
|
3021
|
+
}
|
|
3022
|
+
|
|
2973
3023
|
.sf-markdown > * {
|
|
2974
3024
|
margin: 0;
|
|
2975
3025
|
}
|
|
@@ -3026,7 +3076,7 @@ select.sf-input:disabled {
|
|
|
3026
3076
|
}
|
|
3027
3077
|
|
|
3028
3078
|
.sf-markdown-table:focus-visible {
|
|
3029
|
-
outline: 2px solid var(--sf-color-focus
|
|
3079
|
+
outline: 2px solid var(--sf-color-focus);
|
|
3030
3080
|
outline-offset: 2px;
|
|
3031
3081
|
}
|
|
3032
3082
|
|
|
@@ -3673,6 +3723,25 @@ select.sf-input:disabled {
|
|
|
3673
3723
|
color: var(--sf-color-danger);
|
|
3674
3724
|
}
|
|
3675
3725
|
|
|
3726
|
+
/* A picture attached to a message: a small thumbnail in the chip, the file's name beside it. */
|
|
3727
|
+
.sf-chat-reference[data-kind="attachment"] {
|
|
3728
|
+
font-family: var(--sf-font);
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
.sf-chat-reference[data-thumbnail] {
|
|
3732
|
+
padding-inline-start: var(--sf-space-1);
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
.sf-chat-thumbnail {
|
|
3736
|
+
flex: none;
|
|
3737
|
+
box-sizing: border-box;
|
|
3738
|
+
width: var(--sf-control-size);
|
|
3739
|
+
height: var(--sf-control-size);
|
|
3740
|
+
border-radius: var(--sf-radius-sm);
|
|
3741
|
+
object-fit: cover;
|
|
3742
|
+
background: var(--sf-color-bg-3);
|
|
3743
|
+
}
|
|
3744
|
+
|
|
3676
3745
|
/* What a message is about that is not data reads as words, not a name. */
|
|
3677
3746
|
.sf-chat-reference[data-kind="context"] {
|
|
3678
3747
|
font-family: var(--sf-font);
|
|
@@ -4287,6 +4356,48 @@ select.sf-input:disabled {
|
|
|
4287
4356
|
margin-inline-start: auto;
|
|
4288
4357
|
}
|
|
4289
4358
|
|
|
4359
|
+
.sf-a2-conversation {
|
|
4360
|
+
display: grid;
|
|
4361
|
+
gap: var(--sf-space-3);
|
|
4362
|
+
min-inline-size: 0;
|
|
4363
|
+
}
|
|
4364
|
+
|
|
4365
|
+
.sf-a2-conversation-thread {
|
|
4366
|
+
display: grid;
|
|
4367
|
+
align-content: start;
|
|
4368
|
+
gap: var(--sf-space-3);
|
|
4369
|
+
max-block-size: 32rem;
|
|
4370
|
+
overflow-y: auto;
|
|
4371
|
+
overscroll-behavior: contain;
|
|
4372
|
+
padding: var(--sf-space-1);
|
|
4373
|
+
border-radius: var(--sf-radius-md);
|
|
4374
|
+
}
|
|
4375
|
+
|
|
4376
|
+
.sf-a2-conversation-thread:focus-visible {
|
|
4377
|
+
outline: 2px solid var(--sf-color-focus);
|
|
4378
|
+
outline-offset: 2px;
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
.sf-a2-conversation-waiting {
|
|
4382
|
+
margin: 0;
|
|
4383
|
+
color: var(--sf-color-muted);
|
|
4384
|
+
font-size: var(--sf-font-size-sm);
|
|
4385
|
+
}
|
|
4386
|
+
|
|
4387
|
+
.sf-a2-conversation-composer {
|
|
4388
|
+
display: flex;
|
|
4389
|
+
gap: var(--sf-space-2);
|
|
4390
|
+
align-items: end;
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4393
|
+
.sf-a2-conversation-composer > textarea {
|
|
4394
|
+
flex: 1;
|
|
4395
|
+
min-inline-size: 0;
|
|
4396
|
+
resize: vertical;
|
|
4397
|
+
field-sizing: content;
|
|
4398
|
+
max-block-size: 10rem;
|
|
4399
|
+
}
|
|
4400
|
+
|
|
4290
4401
|
.sf-a2-message-who {
|
|
4291
4402
|
display: flex;
|
|
4292
4403
|
flex-wrap: wrap;
|
|
@@ -6578,7 +6689,8 @@ select.sf-input:disabled {
|
|
|
6578
6689
|
/* Folded away, the panel waits off the left edge of its stage and slides in when the menu button is pressed: a drawer
|
|
6579
6690
|
beside a dimmed page where there is room, the whole stage where there is not. The stage is the window, or the part
|
|
6580
6691
|
on screen of the region the navigation is drawn in (measured when it opens, since a fixed box cannot be told its
|
|
6581
|
-
container in CSS
|
|
6692
|
+
container in CSS; the offsets are counted from the stage's own containing block, which a contained or
|
|
6693
|
+
transformed holder is, so they are not always the window's), and it clips the drawer, so nothing outside that region is covered even while it slides. Hover
|
|
6582
6694
|
and focus do not open it: a drawer that opened under a passing pointer would cover the page by surprise. */
|
|
6583
6695
|
.sf-sidenav[data-pinned="false"] .sf-sidenav-stage {
|
|
6584
6696
|
display: block;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Turns the name or address an image was given into the address to draw, or nothing. The host owns it: it is the
|
|
4
|
+
* only way an address reaches an `<img>` for text or a catalog component an agent wrote.
|
|
5
|
+
*/
|
|
6
|
+
export type ImageResolver = (src: string) => string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Says, once for everything below it, how an image an agent named is turned into an address: the catalog's `Image`
|
|
9
|
+
* and the images in `Markdown` (``) both ask it, unless they are given a `resolveImage` of their own.
|
|
10
|
+
* `SurfaceView` takes `resolveImage` and provides it, so a host with one surface needs no provider.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ImageResolverProvider({ resolve, children }: {
|
|
13
|
+
resolve: ImageResolver | undefined;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
/** The resolver a host provided above, if any. */
|
|
17
|
+
export declare function useImageResolver(): ImageResolver | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Whether an address may be drawn as an image: http(s), a `blob:` the host made from a file, a raster `data:image/`,
|
|
20
|
+
* or a path on the same origin (`/files/1.png`). Never a script, `file:` or a protocol-relative address. Used for
|
|
21
|
+
* what a host's resolver returned and for a preview a host supplies; never for text an agent wrote.
|
|
22
|
+
*/
|
|
23
|
+
export declare function safeImageAddress(value: string | undefined): string | undefined;
|
|
24
|
+
/** The address to draw for an image the text or an agent gave, or nothing: the host's resolver is the only source. */
|
|
25
|
+
export declare function resolveImageAddress(resolve: ImageResolver | undefined, src: string): string | undefined;
|
|
26
|
+
export type ImageFit = "contain" | "cover";
|
|
27
|
+
export interface ImageProps {
|
|
28
|
+
/** What the image is called: the name or address the text or agent gave. It is never loaded as written; the resolver turns it into the address to draw. */
|
|
29
|
+
src: string;
|
|
30
|
+
/** What it shows, for anyone who cannot see it. Required; shown in its place when there is no address. An empty string marks decoration. */
|
|
31
|
+
alt: string;
|
|
32
|
+
caption?: ReactNode;
|
|
33
|
+
/** The most the image is wide, in pixels. It never grows past its container. */
|
|
34
|
+
width?: number;
|
|
35
|
+
/** A fixed height in pixels; the image then fills the box by `fit`. */
|
|
36
|
+
height?: number;
|
|
37
|
+
/** How a fixed box is filled: whole (`contain`, the default) or edge to edge, cropped (`cover`). */
|
|
38
|
+
fit?: ImageFit;
|
|
39
|
+
/** The most the image is tall, in pixels. */
|
|
40
|
+
maxHeight?: number;
|
|
41
|
+
/** Overrides the resolver provided above (`ImageResolverProvider`). */
|
|
42
|
+
resolveImage?: ImageResolver;
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A picture the host decides how to find. The address is drawn only when the host's resolver gives one for `src`;
|
|
47
|
+
* without a resolver, or when it gives nothing, the `alt` text stands in its place, so what a model wrote can never
|
|
48
|
+
* load an address of its own choosing.
|
|
49
|
+
*/
|
|
50
|
+
export declare function Image({ src, alt, caption, width, height, fit, maxHeight, resolveImage, className }: ImageProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const ImageResolverContext = createContext(undefined);
|
|
4
|
+
/**
|
|
5
|
+
* Says, once for everything below it, how an image an agent named is turned into an address: the catalog's `Image`
|
|
6
|
+
* and the images in `Markdown` (``) both ask it, unless they are given a `resolveImage` of their own.
|
|
7
|
+
* `SurfaceView` takes `resolveImage` and provides it, so a host with one surface needs no provider.
|
|
8
|
+
*/
|
|
9
|
+
export function ImageResolverProvider({ resolve, children }) {
|
|
10
|
+
return _jsx(ImageResolverContext.Provider, { value: resolve, children: children });
|
|
11
|
+
}
|
|
12
|
+
/** The resolver a host provided above, if any. */
|
|
13
|
+
export function useImageResolver() {
|
|
14
|
+
return useContext(ImageResolverContext);
|
|
15
|
+
}
|
|
16
|
+
const IMAGE_DATA = /^data:image\/(?:png|jpe?g|gif|webp|avif);/i;
|
|
17
|
+
/**
|
|
18
|
+
* Whether an address may be drawn as an image: http(s), a `blob:` the host made from a file, a raster `data:image/`,
|
|
19
|
+
* or a path on the same origin (`/files/1.png`). Never a script, `file:` or a protocol-relative address. Used for
|
|
20
|
+
* what a host's resolver returned and for a preview a host supplies; never for text an agent wrote.
|
|
21
|
+
*/
|
|
22
|
+
export function safeImageAddress(value) {
|
|
23
|
+
if (!value)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (/^\/(?![/\\])/.test(value))
|
|
26
|
+
return value;
|
|
27
|
+
if (IMAGE_DATA.test(value))
|
|
28
|
+
return value;
|
|
29
|
+
try {
|
|
30
|
+
const url = new URL(value);
|
|
31
|
+
return url.protocol === "https:" || url.protocol === "http:" || url.protocol === "blob:" ? value : undefined;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** The address to draw for an image the text or an agent gave, or nothing: the host's resolver is the only source. */
|
|
38
|
+
export function resolveImageAddress(resolve, src) {
|
|
39
|
+
if (!resolve || !src)
|
|
40
|
+
return undefined;
|
|
41
|
+
try {
|
|
42
|
+
return safeImageAddress(resolve(src));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A picture the host decides how to find. The address is drawn only when the host's resolver gives one for `src`;
|
|
50
|
+
* without a resolver, or when it gives nothing, the `alt` text stands in its place, so what a model wrote can never
|
|
51
|
+
* load an address of its own choosing.
|
|
52
|
+
*/
|
|
53
|
+
export function Image({ src, alt, caption, width, height, fit = "contain", maxHeight, resolveImage, className }) {
|
|
54
|
+
const provided = useImageResolver();
|
|
55
|
+
const address = resolveImageAddress(resolveImage ?? provided, src);
|
|
56
|
+
const style = {};
|
|
57
|
+
if (width)
|
|
58
|
+
style["--sf-image-width"] = `${width}px`;
|
|
59
|
+
if (height)
|
|
60
|
+
style["--sf-image-height"] = `${height}px`;
|
|
61
|
+
if (maxHeight)
|
|
62
|
+
style["--sf-image-max-height"] = `${maxHeight}px`;
|
|
63
|
+
return (_jsxs("figure", { className: ["sf-image", className].filter(Boolean).join(" "), "data-fit": fit, "data-fixed": height ? true : undefined, style: style, children: [address ? (_jsx("img", { className: "sf-image-body", src: address, alt: alt, loading: "lazy", decoding: "async" })) : (_jsx("div", { className: "sf-image-missing", role: alt ? "img" : undefined, "aria-label": alt || undefined, children: _jsx("span", { "aria-hidden": "true", children: alt || "Image" }) })), caption != null && caption !== "" && _jsx("figcaption", { children: caption })] }));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=Image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../src/text/Image.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsC,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAQtF,MAAM,oBAAoB,GAAG,aAAa,CAA4B,SAAS,CAAC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,E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\"react\";\n\n/**\n * Turns the name or address an image was given into the address to draw, or nothing. The host owns it: it is the\n * only way an address reaches an `<img>` for text or a catalog component an agent wrote.\n */\nexport type ImageResolver = (src: string) => string | undefined;\n\nconst ImageResolverContext = createContext<ImageResolver | undefined>(undefined);\n\n/**\n * Says, once for everything below it, how an image an agent named is turned into an address: the catalog's `Image`\n * and the images in `Markdown` (``) both ask it, unless they are given a `resolveImage` of their own.\n * `SurfaceView` takes `resolveImage` and provides it, so a host with one surface needs no provider.\n */\nexport function ImageResolverProvider({ resolve, children }: { resolve: ImageResolver | undefined; children: ReactNode }) {\n return <ImageResolverContext.Provider value={resolve}>{children}</ImageResolverContext.Provider>;\n}\n\n/** The resolver a host provided above, if any. */\nexport function useImageResolver(): ImageResolver | undefined {\n return useContext(ImageResolverContext);\n}\n\nconst IMAGE_DATA = /^data:image\\/(?:png|jpe?g|gif|webp|avif);/i;\n\n/**\n * Whether an address may be drawn as an image: http(s), a `blob:` the host made from a file, a raster `data:image/`,\n * or a path on the same origin (`/files/1.png`). Never a script, `file:` or a protocol-relative address. Used for\n * what a host's resolver returned and for a preview a host supplies; never for text an agent wrote.\n */\nexport function safeImageAddress(value: string | undefined): string | undefined {\n if (!value) return undefined;\n if (/^\\/(?![/\\\\])/.test(value)) return value;\n if (IMAGE_DATA.test(value)) return value;\n try {\n const url = new URL(value);\n return url.protocol === \"https:\" || url.protocol === \"http:\" || url.protocol === \"blob:\" ? value : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** The address to draw for an image the text or an agent gave, or nothing: the host's resolver is the only source. */\nexport function resolveImageAddress(resolve: ImageResolver | undefined, src: string): string | undefined {\n if (!resolve || !src) return undefined;\n try {\n return safeImageAddress(resolve(src));\n } catch {\n return undefined;\n }\n}\n\nexport type ImageFit = \"contain\" | \"cover\";\n\nexport interface ImageProps {\n /** What the image is called: the name or address the text or agent gave. It is never loaded as written; the resolver turns it into the address to draw. */\n src: string;\n /** What it shows, for anyone who cannot see it. Required; shown in its place when there is no address. An empty string marks decoration. */\n alt: string;\n caption?: ReactNode;\n /** The most the image is wide, in pixels. It never grows past its container. */\n width?: number;\n /** A fixed height in pixels; the image then fills the box by `fit`. */\n height?: number;\n /** How a fixed box is filled: whole (`contain`, the default) or edge to edge, cropped (`cover`). */\n fit?: ImageFit;\n /** The most the image is tall, in pixels. */\n maxHeight?: number;\n /** Overrides the resolver provided above (`ImageResolverProvider`). */\n resolveImage?: ImageResolver;\n className?: string;\n}\n\n/**\n * A picture the host decides how to find. The address is drawn only when the host's resolver gives one for `src`;\n * without a resolver, or when it gives nothing, the `alt` text stands in its place, so what a model wrote can never\n * load an address of its own choosing.\n */\nexport function Image({ src, alt, caption, width, height, fit = \"contain\", maxHeight, resolveImage, className }: ImageProps) {\n const provided = useImageResolver();\n const address = resolveImageAddress(resolveImage ?? provided, src);\n const style: Record<string, string> = {};\n if (width) style[\"--sf-image-width\"] = `${width}px`;\n if (height) style[\"--sf-image-height\"] = `${height}px`;\n if (maxHeight) style[\"--sf-image-max-height\"] = `${maxHeight}px`;\n return (\n <figure className={[\"sf-image\", className].filter(Boolean).join(\" \")} data-fit={fit} data-fixed={height ? true : undefined} style={style as CSSProperties}>\n {address ? (\n <img className=\"sf-image-body\" src={address} alt={alt} loading=\"lazy\" decoding=\"async\" />\n ) : (\n <div className=\"sf-image-missing\" role={alt ? \"img\" : undefined} aria-label={alt || undefined}>\n <span aria-hidden=\"true\">{alt || \"Image\"}</span>\n </div>\n )}\n {caption != null && caption !== \"\" && <figcaption>{caption}</figcaption>}\n </figure>\n );\n}\n"]}
|
package/dist/text/Markdown.d.ts
CHANGED
|
@@ -56,7 +56,11 @@ export interface MarkdownProps {
|
|
|
56
56
|
headingStart?: number;
|
|
57
57
|
/** Turns a link the text gives (such as a relative path) into a full http(s) address, or undefined to leave it as text. */
|
|
58
58
|
resolveLink?(href: string): string | undefined;
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Turns an image the text gives (``) into the address to draw (http(s), a `blob:`, a raster `data:image/` or a
|
|
61
|
+
* path on the same origin). Without it, or when it returns undefined, the image's description is shown instead. Left out,
|
|
62
|
+
* the resolver given to `ImageResolverProvider` (or `SurfaceView`'s `resolveImage`) above is used.
|
|
63
|
+
*/
|
|
60
64
|
resolveImage?(src: string): string | undefined;
|
|
61
65
|
/** Called on a plain click on a link, with its full address; return true to handle it in the app, so it does not open a new tab. */
|
|
62
66
|
openLink?(href: string): boolean;
|
package/dist/text/Markdown.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, useMemo, useState } from "react";
|
|
3
3
|
import { highlight } from "./highlight.js";
|
|
4
|
+
import { resolveImageAddress, useImageResolver } from "./Image.js";
|
|
4
5
|
/** Only http(s) and mailto links are rendered as links; anything else stays text. */
|
|
5
6
|
function safeHref(value) {
|
|
6
7
|
try {
|
|
@@ -32,7 +33,7 @@ function inline(text, links = {}) {
|
|
|
32
33
|
// so text from a model cannot load an image from anywhere it likes.
|
|
33
34
|
const split = token.indexOf("](");
|
|
34
35
|
const alt = token.slice(2, split);
|
|
35
|
-
const src = links.image
|
|
36
|
+
const src = resolveImageAddress(links.image, token.slice(split + 2, -1));
|
|
36
37
|
out.push(src ? _jsx("img", { className: "sf-markdown-image", src: src, alt: alt, loading: "lazy", decoding: "async" }, key++) : alt);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
@@ -156,7 +157,8 @@ export function CodeBlock({ code, language, onRun, label, bare, className }) {
|
|
|
156
157
|
* inserted as HTML, so model output cannot add markup or scripts.
|
|
157
158
|
*/
|
|
158
159
|
export function Markdown({ text, onRunSql, inline: oneLine, headingStart = 3, resolveLink, resolveImage, openLink, className }) {
|
|
159
|
-
const
|
|
160
|
+
const provided = useImageResolver();
|
|
161
|
+
const links = { resolve: resolveLink, image: resolveImage ?? provided, open: openLink };
|
|
160
162
|
const line = (value) => inline(value, links);
|
|
161
163
|
if (oneLine)
|
|
162
164
|
return _jsx("span", { className: ["sf-markdown-inline", className].filter(Boolean).join(" "), children: line(text) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../src/text/Markdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qFAAqF;AACrF,SAAS,QAAQ,CAAC,KAAa;IAC7B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACpH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,MAAM,GAAG,2GAA2G,CAAC;AAS3H,uGAAuG;AACvG,SAAS,MAAM,CAAC,IAAY,EAAE,KAAK,GAAU,EAAE;IAC7C,MAAM,GAAG,GAAgB,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAChE,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,KAAK,CAAC,CAAC,CAAC;YAAE,GA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AAC,IAAI,CAAC,IAAxB,KAAK,CAAiC,CAAC;oBACjE,KAAK,MAAM;wBACT,OAAO,eAAS,KAAK,CAAI,CAAC;oBAC5B,KAAK,OAAO;wBACV,OAAO,CAGL,cAAiB,SAAS,EAAC,mBAAmB,EAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAC,QAAQ,gBAAa,UAAU,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,YACjI,4BACE,0BACE,uBACG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC3B,aAAY,KAAK,EAAC,KAAK,YACpB,IAAI,CAAC,IAAI,CAAC,IADJ,CAAC,CAEL,CACN,CAAC,GACC,GACC,EACR,0BACG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAC1B,uBACG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACxB,uBAAa,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAtB,CAAC,CAA2B,CACtC,CAAC,IAHK,CAAC,CAIL,CACN,CAAC,GACI,IACF,IApBA,KAAK,CAqBT,CACP,CAAC;oBACJ;wBACE,OAAO,sBAAgB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAxB,KAAK,CAAwB,CAAC;gBACjD,CAAC;YACH,CAAC,CAAC,EACF,KAAC,QAAQ,KAAG,IACR,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Fragment, type ReactNode, useMemo, useState } from \"react\";\nimport { highlight } from \"./highlight.js\";\n\n/** Only http(s) and mailto links are rendered as links; anything else stays text. */\nfunction safeHref(value: string): string | undefined {\n try {\n const url = new URL(value);\n return url.protocol === \"https:\" || url.protocol === \"http:\" || url.protocol === \"mailto:\" ? url.href : undefined;\n } catch {\n return undefined;\n }\n}\n\nconst INLINE = /(`[^`\\n]+`)|(\\*\\*[^*\\n]+\\*\\*)|(\\*[^*\\n]+\\*|_[^_\\n]+_)|(!\\[[^\\]\\n]*\\]\\([^)\\s]+\\)|\\[[^\\]\\n]+\\]\\([^)\\s]+\\))/g;\n\n/** How a host takes part in links and images; every address is checked again as http(s) before use. */\ninterface Links {\n resolve?: (href: string) => string | undefined;\n image?: (src: string) => string | undefined;\n open?: (href: string) => boolean;\n}\n\n/** Inline Markdown as React nodes: code, bold, italic and links. Never produces HTML from the text. */\nfunction inline(text: string, links: Links = {}): ReactNode[] {\n const out: ReactNode[] = [];\n let last = 0;\n let key = 0;\n for (const match of text.matchAll(INLINE)) {\n if (match.index > last) out.push(text.slice(last, match.index));\n const token = match[0];\n if (match[1]) out.push(<code key={key++}>{token.slice(1, -1)}</code>);\n else if (match[2]) out.push(<strong key={key++}>{inline(token.slice(2, -2), links)}</strong>);\n else if (match[3]) out.push(<em key={key++}>{inline(token.slice(1, -1), links)}</em>);\n else if (token.startsWith(\"!\")) {\n // An image is drawn only when the host gives its address (`resolveImage`); otherwise its description stands in,\n // so text from a model cannot load an image from anywhere it likes.\n const split = token.indexOf(\"](\");\n const alt = token.slice(2, split);\n const src = links.image ? safeHref(links.image(token.slice(split + 2, -1)) ?? \"\") : undefined;\n out.push(src ? <img key={key++} className=\"sf-markdown-image\" src={src} alt={alt} loading=\"lazy\" decoding=\"async\" /> : alt);\n } else {\n const split = token.indexOf(\"](\");\n const label = token.slice(1, split);\n const target = token.slice(split + 2, -1);\n // A host may turn its own links (a relative docs path, an anchor) into safe ones; the result is checked again.\n const href = safeHref(target) ?? (links.resolve ? safeHref(links.resolve(target) ?? \"\") : undefined);\n const open = links.open;\n out.push(\n href ? (\n <a\n key={key++}\n href={href}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n onClick={\n open &&\n ((event) => {\n // A plain click on a link the host keeps (a page of its own) stays in the app; any modifier opens a tab.\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n if (open(href)) event.preventDefault();\n })\n }\n >\n {inline(label, links)}\n </a>\n ) : (\n label\n ),\n );\n }\n last = match.index + token.length;\n }\n if (last < text.length) out.push(text.slice(last));\n return out;\n}\n\ntype Block =\n | { kind: \"heading\"; level: number; text: string }\n | { kind: \"paragraph\"; text: string }\n | { kind: \"code\"; language: string; code: string }\n | { kind: \"list\"; ordered: boolean; items: string[]; start?: number }\n | { kind: \"quote\"; text: string }\n | { kind: \"table\"; head: string[]; rows: string[][] }\n | { kind: \"rule\" };\n\nconst cells = (line: string) =>\n line\n .trim()\n .replace(/^\\||\\|$/g, \"\")\n .split(\"|\")\n .map((cell) => cell.trim());\n\n/** Splits Markdown into blocks. Text still arriving (an unclosed code fence, a half table) is handled. */\nexport function parseMarkdown(source: string): Block[] {\n const lines = source.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const blocks: Block[] = [];\n for (let i = 0; i < lines.length; ) {\n const line = lines[i]!;\n const fence = /^\\s*```(\\S*)\\s*$/.exec(line);\n if (fence) {\n const body: string[] = [];\n for (i++; i < lines.length && !/^\\s*```\\s*$/.test(lines[i]!); i++) body.push(lines[i]!);\n i++;\n blocks.push({ kind: \"code\", language: fence[1] ?? \"\", code: body.join(\"\\n\") });\n continue;\n }\n if (line.trim() === \"\") {\n i++;\n continue;\n }\n const heading = /^(#{1,6})\\s+(.*)$/.exec(line);\n if (heading) {\n blocks.push({ kind: \"heading\", level: heading[1]!.length, text: heading[2]! });\n i++;\n continue;\n }\n if (/^\\s*([-*_])\\s*\\1\\s*\\1[\\s\\-*_]*$/.test(line)) {\n blocks.push({ kind: \"rule\" });\n i++;\n continue;\n }\n if (line.includes(\"|\") && /^\\s*\\|?\\s*:?-{2,}:?\\s*(\\|\\s*:?-{2,}:?\\s*)*\\|?\\s*$/.test(lines[i + 1] ?? \"\")) {\n const head = cells(line);\n const rows: string[][] = [];\n for (i += 2; i < lines.length && lines[i]!.includes(\"|\") && lines[i]!.trim() !== \"\"; i++) rows.push(cells(lines[i]!));\n blocks.push({ kind: \"table\", head, rows });\n continue;\n }\n const bullet = /^\\s*(?:[-*+]|(\\d+)[.)])\\s+(.*)$/.exec(line);\n if (bullet) {\n const ordered = bullet[1] !== undefined;\n const items: string[] = [];\n for (; i < lines.length; i++) {\n const item = /^\\s*(?:[-*+]|(\\d+)[.)])\\s+(.*)$/.exec(lines[i]!);\n if (item && (item[1] !== undefined) === ordered) items.push(item[2]!);\n else if (items.length > 0 && /^\\s{2,}\\S/.test(lines[i]!)) items[items.length - 1] += ` ${lines[i]!.trim()}`;\n else break;\n }\n // A numbered list broken by a code block carries on from its own number (\"2.\" after the code).\n const start = ordered ? Number(bullet[1]) : undefined;\n blocks.push(start !== undefined && start !== 1 ? { kind: \"list\", ordered, items, start } : { kind: \"list\", ordered, items });\n continue;\n }\n if (/^\\s*>/.test(line)) {\n const body: string[] = [];\n for (; i < lines.length && /^\\s*>/.test(lines[i]!); i++) body.push(lines[i]!.replace(/^\\s*>\\s?/, \"\"));\n blocks.push({ kind: \"quote\", text: body.join(\" \") });\n continue;\n }\n const body: string[] = [];\n for (; i < lines.length && lines[i]!.trim() !== \"\" && !/^\\s*(```|#{1,6}\\s|>|[-*+]\\s|\\d+[.)]\\s)/.test(lines[i]!); i++) body.push(lines[i]!.trim());\n if (body.length === 0) body.push(lines[i++]!.trim());\n blocks.push({ kind: \"paragraph\", text: body.join(\" \") });\n }\n return blocks;\n}\n\nexport interface CodeBlockProps {\n code: string;\n /** Shown as a label, e.g. \"sql\". */\n language?: string;\n /** Shows a Run button for SQL and is called with the code. Nothing runs unless a person presses it. */\n onRun?(code: string): void;\n /** Accessible name for the block; defaults to the language. */\n label?: string;\n /** Hide the bar with the language and the Copy button, for code shown as part of a larger view. */\n bare?: boolean;\n className?: string;\n}\n\n/** Code as coloured tokens. Colours come from `--sf-code-*`, so they follow the theme. */\nexport function HighlightedCode({ code, language }: { code: string; language?: string }) {\n const tokens = useMemo(() => highlight(code, language), [code, language]);\n return (\n <code data-language={language || undefined}>\n {tokens.map((token, i) =>\n token.kind ? (\n <span key={i} className={`sf-tok-${token.kind}`}>\n {token.text}\n </span>\n ) : (\n <Fragment key={i}>{token.text}</Fragment>\n ),\n )}\n </code>\n );\n}\n\n/** A block of code with a copy button. */\nexport function CodeBlock({ code, language, onRun, label, bare, className }: CodeBlockProps) {\n const [copied, setCopied] = useState(false);\n const copy = () => {\n void navigator.clipboard?.writeText(code).then(\n () => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1500);\n },\n () => {},\n );\n };\n return (\n <div className={[\"sf-code\", bare && \"sf-code-bare\", className].filter(Boolean).join(\" \")}>\n {!bare && (\n <div className=\"sf-code-bar\">\n <span>{language || \"text\"}</span>\n <span className=\"sf-code-actions\">\n {onRun && (\n <button type=\"button\" className=\"sf-button\" onClick={() => onRun(code)}>\n Run\n </button>\n )}\n <button type=\"button\" className=\"sf-button\" onClick={copy} aria-live=\"polite\">\n {copied ? \"Copied\" : \"Copy\"}\n </button>\n </span>\n </div>\n )}\n <pre tabIndex={0} aria-label={label ?? (language ? `${language} code` : \"Code\")}>\n <HighlightedCode code={code} language={language} />\n </pre>\n </div>\n );\n}\n\nexport interface MarkdownProps {\n /** Markdown text. May be incomplete while it streams in. */\n text: string;\n /** Called when a person presses Run on a SQL code block. Omit to show no Run button. */\n onRunSql?(sql: string): void;\n /** Render one line of inline Markdown (code, emphasis, links) in a span, for labels and descriptions. */\n inline?: boolean;\n /** The heading level a `#` becomes. Defaults to 3, so a reply never outranks the page's own headings. */\n headingStart?: number;\n /** Turns a link the text gives (such as a relative path) into a full http(s) address, or undefined to leave it as text. */\n resolveLink?(href: string): string | undefined;\n /** Turns an image the text gives (``) into a full http(s) address. Without it, or when it returns undefined, the image's description is shown instead. */\n resolveImage?(src: string): string | undefined;\n /** Called on a plain click on a link, with its full address; return true to handle it in the app, so it does not open a new tab. */\n openLink?(href: string): boolean;\n className?: string;\n}\n\n/**\n * Renders Markdown as React elements: headings, paragraphs, lists, quotes,\n * tables, code blocks, and inline code, emphasis and links. The text is never\n * inserted as HTML, so model output cannot add markup or scripts.\n */\nexport function Markdown({ text, onRunSql, inline: oneLine, headingStart = 3, resolveLink, resolveImage, openLink, className }: MarkdownProps) {\n const links: Links = { resolve: resolveLink, image: resolveImage, open: openLink };\n const line = (value: string) => inline(value, links);\n if (oneLine) return <span className={[\"sf-markdown-inline\", className].filter(Boolean).join(\" \")}>{line(text)}</span>;\n return (\n <div className={[\"sf-markdown\", className].filter(Boolean).join(\" \")}>\n {parseMarkdown(text).map((block, index) => {\n switch (block.kind) {\n case \"heading\": {\n // Headings start at h3 so a reply never outranks the page's own headings.\n const Tag = `h${Math.min(6, block.level + Math.max(0, Math.min(5, headingStart - 1)))}` as \"h3\";\n return <Tag key={index}>{line(block.text)}</Tag>;\n }\n case \"code\":\n return <CodeBlock key={index} code={block.code} language={block.language} onRun={onRunSql && /^sql$/i.test(block.language) ? onRunSql : undefined} />;\n case \"list\": {\n const Tag = block.ordered ? \"ol\" : \"ul\";\n return (\n <Tag key={index} start={block.start}>\n {block.items.map((item, i) => (\n <li key={i}>{line(item)}</li>\n ))}\n </Tag>\n );\n }\n case \"quote\":\n return <blockquote key={index}>{line(block.text)}</blockquote>;\n case \"rule\":\n return <hr key={index} />;\n case \"table\":\n return (\n // A wide table scrolls sideways, so it can be focused and scrolled with the arrow keys.\n // biome-ignore lint/a11y/noNoninteractiveTabindex: a scrolling region must be reachable by keyboard.\n <div key={index} className=\"sf-markdown-table\" tabIndex={0} role=\"region\" aria-label={`Table: ${block.head.slice(0, 3).join(\", \")}`}>\n <table>\n <thead>\n <tr>\n {block.head.map((cell, i) => (\n <th key={i} scope=\"col\">\n {line(cell)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {block.rows.map((row, r) => (\n <tr key={r}>\n {block.head.map((_, c) => (\n <td key={c}>{line(row[c] ?? \"\")}</td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n default:\n return <p key={index}>{line(block.text)}</p>;\n }\n })}\n <Fragment />\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../src/text/Markdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnE,qFAAqF;AACrF,SAAS,QAAQ,CAAC,KAAa;IAC7B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACpH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,MAAM,GAAG,2GAA2G,CAAC;AAS3H,uGAAuG;AACvG,SAAS,MAAM,CAAC,IAAY,EAAE,KAAK,GAAU,EAAE;IAC7C,MAAM,GAAG,GAAgB,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAChE,MAAM,KAA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,CAAC;oBACD,KAAK,OAAO;wBACV,OAAO,+BAAyB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAxB,KAAK,CAAiC,CAAC;oBACjE,KAAK,MAAM;wBACT,OAAO,eAAS,KAAK,CAAI,CAAC;oBAC5B,KAAK,OAAO;wBACV,OAAO,CAGL,cAAiB,SAAS,EAAC,mBAAmB,EAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAC,QAAQ,gBAAa,UAAU,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,YACjI,4BACE,0BACE,uBACG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC3B,aAAY,KAAK,EAAC,KAAK,YACpB,IAAI,CAAC,IAAI,CAAC,IADJ,CAAC,CAEL,CACN,CAAC,GACC,GACC,EACR,0BACG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAC1B,uBACG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACxB,uBAAa,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAtB,CAAC,CAA2B,CACtC,CAAC,IAHK,CAAC,CAIL,CACN,CAAC,GACI,IACF,IApBA,KAAK,CAqBT,CACP,CAAC;oBACJ;wBACE,OAAO,sBAAgB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAxB,KAAK,CAAwB,CAAC;gBACjD,CAAC;YACH,CAAC,CAAC,EACF,KAAC,QAAQ,KAAG,IACR,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Fragment, type ReactNode, useMemo, useState } from \"react\";\nimport { highlight } from \"./highlight.js\";\nimport { resolveImageAddress, useImageResolver } from \"./Image.js\";\n\n/** Only http(s) and mailto links are rendered as links; anything else stays text. */\nfunction safeHref(value: string): string | undefined {\n try {\n const url = new URL(value);\n return url.protocol === \"https:\" || url.protocol === \"http:\" || url.protocol === \"mailto:\" ? url.href : undefined;\n } catch {\n return undefined;\n }\n}\n\nconst INLINE = /(`[^`\\n]+`)|(\\*\\*[^*\\n]+\\*\\*)|(\\*[^*\\n]+\\*|_[^_\\n]+_)|(!\\[[^\\]\\n]*\\]\\([^)\\s]+\\)|\\[[^\\]\\n]+\\]\\([^)\\s]+\\))/g;\n\n/** How a host takes part in links and images; every address is checked again as http(s) before use. */\ninterface Links {\n resolve?: (href: string) => string | undefined;\n image?: (src: string) => string | undefined;\n open?: (href: string) => boolean;\n}\n\n/** Inline Markdown as React nodes: code, bold, italic and links. Never produces HTML from the text. */\nfunction inline(text: string, links: Links = {}): ReactNode[] {\n const out: ReactNode[] = [];\n let last = 0;\n let key = 0;\n for (const match of text.matchAll(INLINE)) {\n if (match.index > last) out.push(text.slice(last, match.index));\n const token = match[0];\n if (match[1]) out.push(<code key={key++}>{token.slice(1, -1)}</code>);\n else if (match[2]) out.push(<strong key={key++}>{inline(token.slice(2, -2), links)}</strong>);\n else if (match[3]) out.push(<em key={key++}>{inline(token.slice(1, -1), links)}</em>);\n else if (token.startsWith(\"!\")) {\n // An image is drawn only when the host gives its address (`resolveImage`); otherwise its description stands in,\n // so text from a model cannot load an image from anywhere it likes.\n const split = token.indexOf(\"](\");\n const alt = token.slice(2, split);\n const src = resolveImageAddress(links.image, token.slice(split + 2, -1));\n out.push(src ? <img key={key++} className=\"sf-markdown-image\" src={src} alt={alt} loading=\"lazy\" decoding=\"async\" /> : alt);\n } else {\n const split = token.indexOf(\"](\");\n const label = token.slice(1, split);\n const target = token.slice(split + 2, -1);\n // A host may turn its own links (a relative docs path, an anchor) into safe ones; the result is checked again.\n const href = safeHref(target) ?? (links.resolve ? safeHref(links.resolve(target) ?? \"\") : undefined);\n const open = links.open;\n out.push(\n href ? (\n <a\n key={key++}\n href={href}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n onClick={\n open &&\n ((event) => {\n // A plain click on a link the host keeps (a page of its own) stays in the app; any modifier opens a tab.\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n if (open(href)) event.preventDefault();\n })\n }\n >\n {inline(label, links)}\n </a>\n ) : (\n label\n ),\n );\n }\n last = match.index + token.length;\n }\n if (last < text.length) out.push(text.slice(last));\n return out;\n}\n\ntype Block =\n | { kind: \"heading\"; level: number; text: string }\n | { kind: \"paragraph\"; text: string }\n | { kind: \"code\"; language: string; code: string }\n | { kind: \"list\"; ordered: boolean; items: string[]; start?: number }\n | { kind: \"quote\"; text: string }\n | { kind: \"table\"; head: string[]; rows: string[][] }\n | { kind: \"rule\" };\n\nconst cells = (line: string) =>\n line\n .trim()\n .replace(/^\\||\\|$/g, \"\")\n .split(\"|\")\n .map((cell) => cell.trim());\n\n/** Splits Markdown into blocks. Text still arriving (an unclosed code fence, a half table) is handled. */\nexport function parseMarkdown(source: string): Block[] {\n const lines = source.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const blocks: Block[] = [];\n for (let i = 0; i < lines.length; ) {\n const line = lines[i]!;\n const fence = /^\\s*```(\\S*)\\s*$/.exec(line);\n if (fence) {\n const body: string[] = [];\n for (i++; i < lines.length && !/^\\s*```\\s*$/.test(lines[i]!); i++) body.push(lines[i]!);\n i++;\n blocks.push({ kind: \"code\", language: fence[1] ?? \"\", code: body.join(\"\\n\") });\n continue;\n }\n if (line.trim() === \"\") {\n i++;\n continue;\n }\n const heading = /^(#{1,6})\\s+(.*)$/.exec(line);\n if (heading) {\n blocks.push({ kind: \"heading\", level: heading[1]!.length, text: heading[2]! });\n i++;\n continue;\n }\n if (/^\\s*([-*_])\\s*\\1\\s*\\1[\\s\\-*_]*$/.test(line)) {\n blocks.push({ kind: \"rule\" });\n i++;\n continue;\n }\n if (line.includes(\"|\") && /^\\s*\\|?\\s*:?-{2,}:?\\s*(\\|\\s*:?-{2,}:?\\s*)*\\|?\\s*$/.test(lines[i + 1] ?? \"\")) {\n const head = cells(line);\n const rows: string[][] = [];\n for (i += 2; i < lines.length && lines[i]!.includes(\"|\") && lines[i]!.trim() !== \"\"; i++) rows.push(cells(lines[i]!));\n blocks.push({ kind: \"table\", head, rows });\n continue;\n }\n const bullet = /^\\s*(?:[-*+]|(\\d+)[.)])\\s+(.*)$/.exec(line);\n if (bullet) {\n const ordered = bullet[1] !== undefined;\n const items: string[] = [];\n for (; i < lines.length; i++) {\n const item = /^\\s*(?:[-*+]|(\\d+)[.)])\\s+(.*)$/.exec(lines[i]!);\n if (item && (item[1] !== undefined) === ordered) items.push(item[2]!);\n else if (items.length > 0 && /^\\s{2,}\\S/.test(lines[i]!)) items[items.length - 1] += ` ${lines[i]!.trim()}`;\n else break;\n }\n // A numbered list broken by a code block carries on from its own number (\"2.\" after the code).\n const start = ordered ? Number(bullet[1]) : undefined;\n blocks.push(start !== undefined && start !== 1 ? { kind: \"list\", ordered, items, start } : { kind: \"list\", ordered, items });\n continue;\n }\n if (/^\\s*>/.test(line)) {\n const body: string[] = [];\n for (; i < lines.length && /^\\s*>/.test(lines[i]!); i++) body.push(lines[i]!.replace(/^\\s*>\\s?/, \"\"));\n blocks.push({ kind: \"quote\", text: body.join(\" \") });\n continue;\n }\n const body: string[] = [];\n for (; i < lines.length && lines[i]!.trim() !== \"\" && !/^\\s*(```|#{1,6}\\s|>|[-*+]\\s|\\d+[.)]\\s)/.test(lines[i]!); i++) body.push(lines[i]!.trim());\n if (body.length === 0) body.push(lines[i++]!.trim());\n blocks.push({ kind: \"paragraph\", text: body.join(\" \") });\n }\n return blocks;\n}\n\nexport interface CodeBlockProps {\n code: string;\n /** Shown as a label, e.g. \"sql\". */\n language?: string;\n /** Shows a Run button for SQL and is called with the code. Nothing runs unless a person presses it. */\n onRun?(code: string): void;\n /** Accessible name for the block; defaults to the language. */\n label?: string;\n /** Hide the bar with the language and the Copy button, for code shown as part of a larger view. */\n bare?: boolean;\n className?: string;\n}\n\n/** Code as coloured tokens. Colours come from `--sf-code-*`, so they follow the theme. */\nexport function HighlightedCode({ code, language }: { code: string; language?: string }) {\n const tokens = useMemo(() => highlight(code, language), [code, language]);\n return (\n <code data-language={language || undefined}>\n {tokens.map((token, i) =>\n token.kind ? (\n <span key={i} className={`sf-tok-${token.kind}`}>\n {token.text}\n </span>\n ) : (\n <Fragment key={i}>{token.text}</Fragment>\n ),\n )}\n </code>\n );\n}\n\n/** A block of code with a copy button. */\nexport function CodeBlock({ code, language, onRun, label, bare, className }: CodeBlockProps) {\n const [copied, setCopied] = useState(false);\n const copy = () => {\n void navigator.clipboard?.writeText(code).then(\n () => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1500);\n },\n () => {},\n );\n };\n return (\n <div className={[\"sf-code\", bare && \"sf-code-bare\", className].filter(Boolean).join(\" \")}>\n {!bare && (\n <div className=\"sf-code-bar\">\n <span>{language || \"text\"}</span>\n <span className=\"sf-code-actions\">\n {onRun && (\n <button type=\"button\" className=\"sf-button\" onClick={() => onRun(code)}>\n Run\n </button>\n )}\n <button type=\"button\" className=\"sf-button\" onClick={copy} aria-live=\"polite\">\n {copied ? \"Copied\" : \"Copy\"}\n </button>\n </span>\n </div>\n )}\n <pre tabIndex={0} aria-label={label ?? (language ? `${language} code` : \"Code\")}>\n <HighlightedCode code={code} language={language} />\n </pre>\n </div>\n );\n}\n\nexport interface MarkdownProps {\n /** Markdown text. May be incomplete while it streams in. */\n text: string;\n /** Called when a person presses Run on a SQL code block. Omit to show no Run button. */\n onRunSql?(sql: string): void;\n /** Render one line of inline Markdown (code, emphasis, links) in a span, for labels and descriptions. */\n inline?: boolean;\n /** The heading level a `#` becomes. Defaults to 3, so a reply never outranks the page's own headings. */\n headingStart?: number;\n /** Turns a link the text gives (such as a relative path) into a full http(s) address, or undefined to leave it as text. */\n resolveLink?(href: string): string | undefined;\n /**\n * Turns an image the text gives (``) into the address to draw (http(s), a `blob:`, a raster `data:image/` or a\n * path on the same origin). Without it, or when it returns undefined, the image's description is shown instead. Left out,\n * the resolver given to `ImageResolverProvider` (or `SurfaceView`'s `resolveImage`) above is used.\n */\n resolveImage?(src: string): string | undefined;\n /** Called on a plain click on a link, with its full address; return true to handle it in the app, so it does not open a new tab. */\n openLink?(href: string): boolean;\n className?: string;\n}\n\n/**\n * Renders Markdown as React elements: headings, paragraphs, lists, quotes,\n * tables, code blocks, and inline code, emphasis and links. The text is never\n * inserted as HTML, so model output cannot add markup or scripts.\n */\nexport function Markdown({ text, onRunSql, inline: oneLine, headingStart = 3, resolveLink, resolveImage, openLink, className }: MarkdownProps) {\n const provided = useImageResolver();\n const links: Links = { resolve: resolveLink, image: resolveImage ?? provided, open: openLink };\n const line = (value: string) => inline(value, links);\n if (oneLine) return <span className={[\"sf-markdown-inline\", className].filter(Boolean).join(\" \")}>{line(text)}</span>;\n return (\n <div className={[\"sf-markdown\", className].filter(Boolean).join(\" \")}>\n {parseMarkdown(text).map((block, index) => {\n switch (block.kind) {\n case \"heading\": {\n // Headings start at h3 so a reply never outranks the page's own headings.\n const Tag = `h${Math.min(6, block.level + Math.max(0, Math.min(5, headingStart - 1)))}` as \"h3\";\n return <Tag key={index}>{line(block.text)}</Tag>;\n }\n case \"code\":\n return <CodeBlock key={index} code={block.code} language={block.language} onRun={onRunSql && /^sql$/i.test(block.language) ? onRunSql : undefined} />;\n case \"list\": {\n const Tag = block.ordered ? \"ol\" : \"ul\";\n return (\n <Tag key={index} start={block.start}>\n {block.items.map((item, i) => (\n <li key={i}>{line(item)}</li>\n ))}\n </Tag>\n );\n }\n case \"quote\":\n return <blockquote key={index}>{line(block.text)}</blockquote>;\n case \"rule\":\n return <hr key={index} />;\n case \"table\":\n return (\n // A wide table scrolls sideways, so it can be focused and scrolled with the arrow keys.\n // biome-ignore lint/a11y/noNoninteractiveTabindex: a scrolling region must be reachable by keyboard.\n <div key={index} className=\"sf-markdown-table\" tabIndex={0} role=\"region\" aria-label={`Table: ${block.head.slice(0, 3).join(\", \")}`}>\n <table>\n <thead>\n <tr>\n {block.head.map((cell, i) => (\n <th key={i} scope=\"col\">\n {line(cell)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {block.rows.map((row, r) => (\n <tr key={r}>\n {block.head.map((_, c) => (\n <td key={c}>{line(row[c] ?? \"\")}</td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n default:\n return <p key={index}>{line(block.text)}</p>;\n }\n })}\n <Fragment />\n </div>\n );\n}\n"]}
|
|
@@ -47,6 +47,20 @@ export declare function drawerBox(holder: NavBox | undefined, viewport: {
|
|
|
47
47
|
width: number;
|
|
48
48
|
height: number;
|
|
49
49
|
}, least?: number): NavBox | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Where the drawer's stage is put, in the px its `top` and `left` are counted in. A fixed box is placed from the window
|
|
52
|
+
* unless something around it is its containing block: a `.sf-container` in a browser where a container query brings
|
|
53
|
+
* layout containment (Chrome 156 does not), or anything a host has contained, transformed or filtered. `origin` is where that block starts on screen, measured
|
|
54
|
+
* from the stage itself, and the box is counted from there. With the window as the block nothing changes, and no box
|
|
55
|
+
* stays no box (the stylesheet's own window). Inside another block "the whole window" has to be worked out too.
|
|
56
|
+
*/
|
|
57
|
+
export declare function stageBox(box: NavBox | undefined, origin: {
|
|
58
|
+
top: number;
|
|
59
|
+
left: number;
|
|
60
|
+
}, viewport: {
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
}): NavBox | undefined;
|
|
50
64
|
/** "Site navigation" for "Site", and "Main navigation" left as it is: a label that already says so is not said twice. */
|
|
51
65
|
export declare const navigationName: (label: string) => string;
|
|
52
66
|
/**
|
|
@@ -23,6 +23,31 @@ export function drawerBox(holder, viewport, least = SIDENAV_LEAST) {
|
|
|
23
23
|
return undefined;
|
|
24
24
|
return { top, left, width, height };
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Where the drawer's stage is put, in the px its `top` and `left` are counted in. A fixed box is placed from the window
|
|
28
|
+
* unless something around it is its containing block: a `.sf-container` in a browser where a container query brings
|
|
29
|
+
* layout containment (Chrome 156 does not), or anything a host has contained, transformed or filtered. `origin` is where that block starts on screen, measured
|
|
30
|
+
* from the stage itself, and the box is counted from there. With the window as the block nothing changes, and no box
|
|
31
|
+
* stays no box (the stylesheet's own window). Inside another block "the whole window" has to be worked out too.
|
|
32
|
+
*/
|
|
33
|
+
export function stageBox(box, origin, viewport) {
|
|
34
|
+
if (!origin.top && !origin.left)
|
|
35
|
+
return box;
|
|
36
|
+
const target = box ?? { top: 0, left: 0, width: viewport.width, height: viewport.height };
|
|
37
|
+
return { top: target.top - origin.top, left: target.left - origin.left, width: target.width, height: target.height };
|
|
38
|
+
}
|
|
39
|
+
/** Where on screen a fixed element's containing block starts: where the element is, less the offsets it was given. */
|
|
40
|
+
function fixedOrigin(element) {
|
|
41
|
+
if (!element)
|
|
42
|
+
return { top: 0, left: 0 };
|
|
43
|
+
const rect = element.getBoundingClientRect();
|
|
44
|
+
const style = getComputedStyle(element);
|
|
45
|
+
// A fixed box's computed `top` and `left` are the used px. Anything else (not laid out, no stylesheet) says nothing.
|
|
46
|
+
const top = rect.top - Number.parseFloat(style.top);
|
|
47
|
+
const left = rect.left - Number.parseFloat(style.left);
|
|
48
|
+
// Under half a px is rounding, not a containing block.
|
|
49
|
+
return { top: Math.abs(top) >= 0.5 ? top : 0, left: Math.abs(left) >= 0.5 ? left : 0 };
|
|
50
|
+
}
|
|
26
51
|
/** What holds the navigation when it is drawn inside a region that answers to its own size (a surface, a result). */
|
|
27
52
|
const holderOf = (element) => element?.closest(".sf-container") ?? undefined;
|
|
28
53
|
/** True when the window, or the region the navigation is drawn in, is too narrow to dock it. */
|
|
@@ -76,6 +101,7 @@ export function SideNav({ label, groups, current, onSelect, pinned: given, defau
|
|
|
76
101
|
const pinned = (given ?? kept) && !narrow;
|
|
77
102
|
const [open, setOpen] = useState(false);
|
|
78
103
|
const panel = useRef(null);
|
|
104
|
+
const stage = useRef(null);
|
|
79
105
|
const opener = () => document.getElementById(`${id}-open`);
|
|
80
106
|
const close = () => {
|
|
81
107
|
setOpen(false);
|
|
@@ -90,14 +116,16 @@ export function SideNav({ label, groups, current, onSelect, pinned: given, defau
|
|
|
90
116
|
requestAnimationFrame(() => opener()?.focus());
|
|
91
117
|
};
|
|
92
118
|
const taking = !pinned && open;
|
|
93
|
-
// Where the drawer goes while it is open: the part of its holder on screen, kept current as that moves
|
|
119
|
+
// Where the drawer goes while it is open: the part of its holder on screen, kept current as that moves, and counted
|
|
120
|
+
// from whatever the stage is really placed against (the window, or a holder that contains fixed boxes).
|
|
94
121
|
const [box, setBox] = useState(undefined);
|
|
95
122
|
useLayoutEffect(() => {
|
|
96
123
|
if (!taking)
|
|
97
124
|
return;
|
|
98
125
|
const place = () => {
|
|
99
126
|
const rect = holderOf(root.current)?.getBoundingClientRect();
|
|
100
|
-
const
|
|
127
|
+
const viewport = { width: window.innerWidth, height: window.innerHeight };
|
|
128
|
+
const next = stageBox(drawerBox(rect ? { top: rect.top, left: rect.left, width: rect.width, height: rect.height } : undefined, viewport), fixedOrigin(stage.current), viewport);
|
|
101
129
|
setBox((before) => (before && next && before.top === next.top && before.left === next.left && before.width === next.width && before.height === next.height ? before : next));
|
|
102
130
|
};
|
|
103
131
|
place();
|
|
@@ -144,6 +172,6 @@ export function SideNav({ label, groups, current, onSelect, pinned: given, defau
|
|
|
144
172
|
if (taking)
|
|
145
173
|
close();
|
|
146
174
|
};
|
|
147
|
-
return (_jsxs("div", { ref: root, className: `sf-sidenav${className ? ` ${className}` : ""}`, "data-pinned": pinned, "data-open": open || undefined, "data-narrow": narrow || undefined, style: placed, onKeyDown: onKey, children: [!pinned && (_jsx("button", { id: `${id}-open`, type: "button", className: "sf-sidenav-open", "aria-expanded": open, "aria-controls": `${id}-panel`, "aria-label": `Show ${navigationName(label)}`, onClick: () => setOpen(true), children: _jsx(ControlIcon, { icon: "menu" }) })), _jsxs("div", { className: "sf-sidenav-stage", children: [taking && _jsx("div", { className: "sf-sidenav-backdrop", "aria-hidden": "true", onClick: close }), _jsxs("div", { id: `${id}-panel`, ref: panel, className: "sf-sidenav-panel", role: pinned ? undefined : "dialog", "aria-modal": taking || undefined, "aria-label": pinned ? undefined : navigationName(label), children: [_jsxs("div", { className: "sf-sidenav-top", children: [_jsx("div", { className: "sf-sidenav-header", children: header }), !narrow && (_jsxs("button", { type: "button", className: "sf-sidenav-pin", "aria-pressed": pinned, title: pinned ? "Let the navigation fold away" : "Keep the navigation open", onClick: () => setPinned(!pinned), children: [_jsx(ControlIcon, { icon: pinned ? "fold" : "unfold" }), _jsx("span", { className: "sf-sidenav-pin-label", children: pinned ? "Fold away" : "Keep open" })] })), !pinned && (_jsx("button", { type: "button", className: "sf-sidenav-close", "aria-label": `Close ${navigationName(label)}`, onClick: close, children: _jsx(ControlIcon, { icon: "close" }) }))] }), _jsx("nav", { className: "sf-sidenav-nav", "aria-label": label, children: groups.map((group, g) => (_jsxs("section", { className: "sf-sidenav-group", "aria-labelledby": group.label ? `${id}-group-${g}` : undefined, children: [group.label && (_jsx("h2", { id: `${id}-group-${g}`, className: "sf-sidenav-group-label", children: group.label })), _jsx("ul", { children: group.items.map((item) => (_jsx("li", { children: item.href ? (_jsx("a", { href: item.href, "aria-current": item.id === current ? "page" : undefined, onClick: () => choose(item.id), children: item.label })) : (_jsx("button", { type: "button", "aria-current": item.id === current ? "page" : undefined, onClick: () => choose(item.id), children: item.label })) }, item.id))) })] }, group.label ?? g))) }), footer && _jsx("div", { className: "sf-sidenav-footer", children: footer })] })] })] }));
|
|
175
|
+
return (_jsxs("div", { ref: root, className: `sf-sidenav${className ? ` ${className}` : ""}`, "data-pinned": pinned, "data-open": open || undefined, "data-narrow": narrow || undefined, style: placed, onKeyDown: onKey, children: [!pinned && (_jsx("button", { id: `${id}-open`, type: "button", className: "sf-sidenav-open", "aria-expanded": open, "aria-controls": `${id}-panel`, "aria-label": `Show ${navigationName(label)}`, onClick: () => setOpen(true), children: _jsx(ControlIcon, { icon: "menu" }) })), _jsxs("div", { ref: stage, className: "sf-sidenav-stage", children: [taking && _jsx("div", { className: "sf-sidenav-backdrop", "aria-hidden": "true", onClick: close }), _jsxs("div", { id: `${id}-panel`, ref: panel, className: "sf-sidenav-panel", role: pinned ? undefined : "dialog", "aria-modal": taking || undefined, "aria-label": pinned ? undefined : navigationName(label), children: [_jsxs("div", { className: "sf-sidenav-top", children: [_jsx("div", { className: "sf-sidenav-header", children: header }), !narrow && (_jsxs("button", { type: "button", className: "sf-sidenav-pin", "aria-pressed": pinned, title: pinned ? "Let the navigation fold away" : "Keep the navigation open", onClick: () => setPinned(!pinned), children: [_jsx(ControlIcon, { icon: pinned ? "fold" : "unfold" }), _jsx("span", { className: "sf-sidenav-pin-label", children: pinned ? "Fold away" : "Keep open" })] })), !pinned && (_jsx("button", { type: "button", className: "sf-sidenav-close", "aria-label": `Close ${navigationName(label)}`, onClick: close, children: _jsx(ControlIcon, { icon: "close" }) }))] }), _jsx("nav", { className: "sf-sidenav-nav", "aria-label": label, children: groups.map((group, g) => (_jsxs("section", { className: "sf-sidenav-group", "aria-labelledby": group.label ? `${id}-group-${g}` : undefined, children: [group.label && (_jsx("h2", { id: `${id}-group-${g}`, className: "sf-sidenav-group-label", children: group.label })), _jsx("ul", { children: group.items.map((item) => (_jsx("li", { children: item.href ? (_jsx("a", { href: item.href, "aria-current": item.id === current ? "page" : undefined, onClick: () => choose(item.id), children: item.label })) : (_jsx("button", { type: "button", "aria-current": item.id === current ? "page" : undefined, onClick: () => choose(item.id), children: item.label })) }, item.id))) })] }, group.label ?? g))) }), footer && _jsx("div", { className: "sf-sidenav-footer", children: footer })] })] })] }));
|
|
148
176
|
}
|
|
149
177
|
//# sourceMappingURL=SideNav.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNav.js","sourceRoot":"","sources":["../../src/workspace/SideNav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0E,SAAS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AC,IAAI,CAAC,EAAE,CAAC,YACvG,IAAI,CAAC,KAAK,GACT,CACL,CAAC,CAAC,CAAC,CACF,iBAAQ,IAAI,EAAC,QAAQ,kBAAe,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,YACzG,IAAI,CAAC,KAAK,GACJ,CACV,IATM,IAAI,CAAC,EAAE,CAUX,CACN,CAAC,GACC,KApBO,KAAK,CAAC,KAAK,IAAI,CAAC,CAqBpB,CACX,CAAC,GACE,EACL,MAAM,IAAI,cAAK,SAAS,EAAC,mBAAmB,YAAE,MAAM,GAAO,IACxD,IACA,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, type RefObject, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { ControlIcon } from \"../controls/ItemControls.js\";\n\nexport interface SideNavItem {\n id: string;\n label: string;\n /** Where the item goes. Without one the item is a button and only `onSelect` is called. */\n href?: string;\n}\n\nexport interface SideNavGroup {\n /** A heading over the group's items. */\n label?: string;\n items: SideNavItem[];\n}\n\nexport interface SideNavProps {\n /** What the navigation is for, for assistive technology: \"Playground\". */\n label: string;\n groups: SideNavGroup[];\n /** The id of the item for the page being shown. */\n current?: string;\n onSelect?(id: string): void;\n /** Whether the navigation stays open beside the page. Give it with `onPinnedChange` to hold it yourself. */\n pinned?: boolean;\n /** Whether it starts pinned when it holds the state itself. Defaults to true. */\n defaultPinned?: boolean;\n onPinnedChange?(pinned: boolean): void;\n /** Shown above the items: a name, a status, a picker. */\n header?: ReactNode;\n /** Shown below the items. */\n footer?: ReactNode;\n className?: string;\n}\n\n/** Below this width the navigation is always folded away: docked beside a phone's page it would leave the page no room. */\nexport const SIDENAV_NARROW = \"(max-width: 40rem)\";\n\nconst narrowQuery = () => (typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" ? window.matchMedia(SIDENAV_NARROW) : undefined);\n\n/** The width, in rem, under which whatever holds the navigation is too narrow to dock it beside the page. */\nconst NARROW_REM = 40;\n/** The least room, in px each way, a drawer needs: in a smaller box it takes the window instead. */\nexport const SIDENAV_LEAST = 240;\n\n/** A box on screen, in px from the window's top left. */\nexport interface NavBox {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\n/**\n * Where a folded navigation's drawer goes: the part of its holder that is on screen. Nothing (the whole window) when\n * the holder is not laid out, is off screen, or shows less than `least` px either way.\n */\nexport function drawerBox(holder: NavBox | undefined, viewport: { width: number; height: number }, least = SIDENAV_LEAST): NavBox | undefined {\n if (!holder) return undefined;\n const top = Math.max(holder.top, 0);\n const left = Math.max(holder.left, 0);\n const width = Math.min(holder.left + holder.width, viewport.width) - left;\n const height = Math.min(holder.top + holder.height, viewport.height) - top;\n if (!(width >= least) || !(height >= least)) return undefined;\n return { top, left, width, height };\n}\n\n/** What holds the navigation when it is drawn inside a region that answers to its own size (a surface, a result). */\nconst holderOf = (element: Element | null) => element?.closest(\".sf-container\") ?? undefined;\n\n/** True when the window, or the region the navigation is drawn in, is too narrow to dock it. */\nfunction useNarrow(root: RefObject<HTMLElement | null>): boolean {\n const [narrow, setNarrow] = useState(() => narrowQuery()?.matches ?? false);\n const [tight, setTight] = useState(false);\n useEffect(() => {\n const query = narrowQuery();\n if (!query) return;\n const change = () => setNarrow(query.matches);\n change();\n query.addEventListener(\"change\", change);\n return () => query.removeEventListener(\"change\", change);\n }, []);\n useEffect(() => {\n const holder = holderOf(root.current);\n if (!holder || typeof ResizeObserver === \"undefined\") return;\n const measure = () => {\n const width = holder.getBoundingClientRect().width;\n const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n // A holder that is not laid out says nothing.\n setTight(width > 0 && width < NARROW_REM * rem);\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(holder);\n return () => observer.disconnect();\n }, [root]);\n return narrow || tight;\n}\n\n/** \"Site navigation\" for \"Site\", and \"Main navigation\" left as it is: a label that already says so is not said twice. */\nexport const navigationName = (label: string) => (/\\bnavigation\\s*$/i.test(label) ? label.trim() : `${label.trim()} navigation`);\n\nconst FOCUSABLE = 'a[href], button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Side navigation that can get out of the way. Pinned, it sits beside the page. Unpinned, it keeps only the room its\n * menu button takes: a slim strip where the navigation was, so the button never sits over the page or a host's own\n * toolbar. Pressing it slides the navigation in from the left as a dialog: over the window, or, drawn inside a region\n * that answers to its own size (a surface in a host's canvas, a chat reply), over that region only. Focus moves into\n * it and stays there until it closes, on Escape, on its close button, or when an item is chosen; focus then goes back\n * to the menu button. Where the window or that region is under 40rem wide (`SIDENAV_NARROW`) it is always folded and\n * offers no pin.\n */\nexport function SideNav({ label, groups, current, onSelect, pinned: given, defaultPinned = true, onPinnedChange, header, footer, className }: SideNavProps) {\n const id = useId();\n const [kept, setKept] = useState(defaultPinned);\n const root = useRef<HTMLDivElement>(null);\n const narrow = useNarrow(root);\n // On a narrow screen it is folded whatever was chosen; the choice comes back on a wider one.\n const pinned = (given ?? kept) && !narrow;\n const [open, setOpen] = useState(false);\n const panel = useRef<HTMLDivElement>(null);\n const opener = () => document.getElementById(`${id}-open`);\n const close = () => {\n setOpen(false);\n requestAnimationFrame(() => opener()?.focus());\n };\n const setPinned = (next: boolean) => {\n setKept(next);\n setOpen(false);\n onPinnedChange?.(next);\n // Folding away from the button inside the panel: focus goes to the menu button that opens it again.\n if (!next) requestAnimationFrame(() => opener()?.focus());\n };\n const taking = !pinned && open;\n // Where the drawer goes while it is open: the part of its holder on screen, kept current as that moves.\n const [box, setBox] = useState<NavBox | undefined>(undefined);\n useLayoutEffect(() => {\n if (!taking) return;\n const place = () => {\n const rect = holderOf(root.current)?.getBoundingClientRect();\n const next = drawerBox(rect ? { top: rect.top, left: rect.left, width: rect.width, height: rect.height } : undefined, { width: window.innerWidth, height: window.innerHeight });\n setBox((before) => (before && next && before.top === next.top && before.left === next.left && before.width === next.width && before.height === next.height ? before : next));\n };\n place();\n window.addEventListener(\"resize\", place);\n window.addEventListener(\"scroll\", place, true);\n return () => {\n window.removeEventListener(\"resize\", place);\n window.removeEventListener(\"scroll\", place, true);\n };\n }, [taking]);\n const placed = !pinned && box ? ({ \"--sf-sidenav-top\": `${box.top}px`, \"--sf-sidenav-left\": `${box.left}px`, \"--sf-sidenav-width\": `${box.width}px`, \"--sf-sidenav-height\": `${box.height}px` } as CSSProperties) : undefined;\n // Opened over the page: focus goes in, to the close button first.\n useEffect(() => {\n if (taking) panel.current?.querySelector<HTMLElement>(\".sf-sidenav-close\")?.focus();\n }, [taking]);\n\n const onKey = (event: KeyboardEvent<HTMLDivElement>) => {\n if (!taking) return;\n if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n return;\n }\n // Focus stays inside while it covers the page.\n if (event.key === \"Tab\" && panel.current) {\n const all = [...panel.current.querySelectorAll<HTMLElement>(FOCUSABLE)];\n const first = all[0];\n const last = all[all.length - 1];\n if (!first || !last) return;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n }\n };\n const choose = (item: string) => {\n onSelect?.(item);\n if (taking) close();\n };\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: Escape and Tab are handled here for everything inside; the controls themselves are buttons and links.\n <div ref={root} className={`sf-sidenav${className ? ` ${className}` : \"\"}`} data-pinned={pinned} data-open={open || undefined} data-narrow={narrow || undefined} style={placed} onKeyDown={onKey}>\n {!pinned && (\n <button id={`${id}-open`} type=\"button\" className=\"sf-sidenav-open\" aria-expanded={open} aria-controls={`${id}-panel`} aria-label={`Show ${navigationName(label)}`} onClick={() => setOpen(true)}>\n <ControlIcon icon=\"menu\" />\n </button>\n )}\n {/* Folded, the drawer and the dimmed page behind it live in a stage laid over the holder, which clips the drawer as it slides. */}\n <div className=\"sf-sidenav-stage\">\n {/* The page behind a drawer is dimmed, and a press on it closes the drawer; Escape and the close button do the same. */}\n {/* biome-ignore lint/a11y/useKeyWithClickEvents lint/a11y/noStaticElementInteractions: a pointer's shortcut; the keyboard closes it with Escape or the close button. */}\n {taking && <div className=\"sf-sidenav-backdrop\" aria-hidden=\"true\" onClick={close} />}\n <div\n id={`${id}-panel`}\n ref={panel}\n className=\"sf-sidenav-panel\"\n role={pinned ? undefined : \"dialog\"}\n aria-modal={taking || undefined}\n aria-label={pinned ? undefined : navigationName(label)}\n >\n <div className=\"sf-sidenav-top\">\n <div className=\"sf-sidenav-header\">{header}</div>\n {!narrow && (\n <button type=\"button\" className=\"sf-sidenav-pin\" aria-pressed={pinned} title={pinned ? \"Let the navigation fold away\" : \"Keep the navigation open\"} onClick={() => setPinned(!pinned)}>\n <ControlIcon icon={pinned ? \"fold\" : \"unfold\"} />\n <span className=\"sf-sidenav-pin-label\">{pinned ? \"Fold away\" : \"Keep open\"}</span>\n </button>\n )}\n {!pinned && (\n <button type=\"button\" className=\"sf-sidenav-close\" aria-label={`Close ${navigationName(label)}`} onClick={close}>\n <ControlIcon icon=\"close\" />\n </button>\n )}\n </div>\n <nav className=\"sf-sidenav-nav\" aria-label={label}>\n {groups.map((group, g) => (\n <section key={group.label ?? g} className=\"sf-sidenav-group\" aria-labelledby={group.label ? `${id}-group-${g}` : undefined}>\n {group.label && (\n <h2 id={`${id}-group-${g}`} className=\"sf-sidenav-group-label\">\n {group.label}\n </h2>\n )}\n <ul>\n {group.items.map((item) => (\n <li key={item.id}>\n {item.href ? (\n <a href={item.href} aria-current={item.id === current ? \"page\" : undefined} onClick={() => choose(item.id)}>\n {item.label}\n </a>\n ) : (\n <button type=\"button\" aria-current={item.id === current ? \"page\" : undefined} onClick={() => choose(item.id)}>\n {item.label}\n </button>\n )}\n </li>\n ))}\n </ul>\n </section>\n ))}\n </nav>\n {footer && <div className=\"sf-sidenav-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AAC,CAAC,SAAS,aACvH,KAAK,CAAC,KAAK,IAAI,CACd,aAAI,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE,SAAS,EAAC,wBAAwB,YAC3D,KAAK,CAAC,KAAK,GACT,CACN,EACD,uBACG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACzB,uBACG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CACX,YAAG,IAAI,EAAE,IAAI,CAAC,IAAI,kBAAgB,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,YACvG,IAAI,CAAC,KAAK,GACT,CACL,CAAC,CAAC,CAAC,CACF,iBAAQ,IAAI,EAAC,QAAQ,kBAAe,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,YACzG,IAAI,CAAC,KAAK,GACJ,CACV,IATM,IAAI,CAAC,EAAE,CAUX,CACN,CAAC,GACC,KApBO,KAAK,CAAC,KAAK,IAAI,CAAC,CAqBpB,CACX,CAAC,GACE,EACL,MAAM,IAAI,cAAK,SAAS,EAAC,mBAAmB,YAAE,MAAM,GAAO,IACxD,IACA,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { type CSSProperties, type KeyboardEvent, type ReactNode, type RefObject, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { ControlIcon } from \"../controls/ItemControls.js\";\n\nexport interface SideNavItem {\n id: string;\n label: string;\n /** Where the item goes. Without one the item is a button and only `onSelect` is called. */\n href?: string;\n}\n\nexport interface SideNavGroup {\n /** A heading over the group's items. */\n label?: string;\n items: SideNavItem[];\n}\n\nexport interface SideNavProps {\n /** What the navigation is for, for assistive technology: \"Playground\". */\n label: string;\n groups: SideNavGroup[];\n /** The id of the item for the page being shown. */\n current?: string;\n onSelect?(id: string): void;\n /** Whether the navigation stays open beside the page. Give it with `onPinnedChange` to hold it yourself. */\n pinned?: boolean;\n /** Whether it starts pinned when it holds the state itself. Defaults to true. */\n defaultPinned?: boolean;\n onPinnedChange?(pinned: boolean): void;\n /** Shown above the items: a name, a status, a picker. */\n header?: ReactNode;\n /** Shown below the items. */\n footer?: ReactNode;\n className?: string;\n}\n\n/** Below this width the navigation is always folded away: docked beside a phone's page it would leave the page no room. */\nexport const SIDENAV_NARROW = \"(max-width: 40rem)\";\n\nconst narrowQuery = () => (typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" ? window.matchMedia(SIDENAV_NARROW) : undefined);\n\n/** The width, in rem, under which whatever holds the navigation is too narrow to dock it beside the page. */\nconst NARROW_REM = 40;\n/** The least room, in px each way, a drawer needs: in a smaller box it takes the window instead. */\nexport const SIDENAV_LEAST = 240;\n\n/** A box on screen, in px from the window's top left. */\nexport interface NavBox {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\n/**\n * Where a folded navigation's drawer goes: the part of its holder that is on screen. Nothing (the whole window) when\n * the holder is not laid out, is off screen, or shows less than `least` px either way.\n */\nexport function drawerBox(holder: NavBox | undefined, viewport: { width: number; height: number }, least = SIDENAV_LEAST): NavBox | undefined {\n if (!holder) return undefined;\n const top = Math.max(holder.top, 0);\n const left = Math.max(holder.left, 0);\n const width = Math.min(holder.left + holder.width, viewport.width) - left;\n const height = Math.min(holder.top + holder.height, viewport.height) - top;\n if (!(width >= least) || !(height >= least)) return undefined;\n return { top, left, width, height };\n}\n\n/**\n * Where the drawer's stage is put, in the px its `top` and `left` are counted in. A fixed box is placed from the window\n * unless something around it is its containing block: a `.sf-container` in a browser where a container query brings\n * layout containment (Chrome 156 does not), or anything a host has contained, transformed or filtered. `origin` is where that block starts on screen, measured\n * from the stage itself, and the box is counted from there. With the window as the block nothing changes, and no box\n * stays no box (the stylesheet's own window). Inside another block \"the whole window\" has to be worked out too.\n */\nexport function stageBox(box: NavBox | undefined, origin: { top: number; left: number }, viewport: { width: number; height: number }): NavBox | undefined {\n if (!origin.top && !origin.left) return box;\n const target = box ?? { top: 0, left: 0, width: viewport.width, height: viewport.height };\n return { top: target.top - origin.top, left: target.left - origin.left, width: target.width, height: target.height };\n}\n\n/** Where on screen a fixed element's containing block starts: where the element is, less the offsets it was given. */\nfunction fixedOrigin(element: HTMLElement | null): { top: number; left: number } {\n if (!element) return { top: 0, left: 0 };\n const rect = element.getBoundingClientRect();\n const style = getComputedStyle(element);\n // A fixed box's computed `top` and `left` are the used px. Anything else (not laid out, no stylesheet) says nothing.\n const top = rect.top - Number.parseFloat(style.top);\n const left = rect.left - Number.parseFloat(style.left);\n // Under half a px is rounding, not a containing block.\n return { top: Math.abs(top) >= 0.5 ? top : 0, left: Math.abs(left) >= 0.5 ? left : 0 };\n}\n\n/** What holds the navigation when it is drawn inside a region that answers to its own size (a surface, a result). */\nconst holderOf = (element: Element | null) => element?.closest(\".sf-container\") ?? undefined;\n\n/** True when the window, or the region the navigation is drawn in, is too narrow to dock it. */\nfunction useNarrow(root: RefObject<HTMLElement | null>): boolean {\n const [narrow, setNarrow] = useState(() => narrowQuery()?.matches ?? false);\n const [tight, setTight] = useState(false);\n useEffect(() => {\n const query = narrowQuery();\n if (!query) return;\n const change = () => setNarrow(query.matches);\n change();\n query.addEventListener(\"change\", change);\n return () => query.removeEventListener(\"change\", change);\n }, []);\n useEffect(() => {\n const holder = holderOf(root.current);\n if (!holder || typeof ResizeObserver === \"undefined\") return;\n const measure = () => {\n const width = holder.getBoundingClientRect().width;\n const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n // A holder that is not laid out says nothing.\n setTight(width > 0 && width < NARROW_REM * rem);\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(holder);\n return () => observer.disconnect();\n }, [root]);\n return narrow || tight;\n}\n\n/** \"Site navigation\" for \"Site\", and \"Main navigation\" left as it is: a label that already says so is not said twice. */\nexport const navigationName = (label: string) => (/\\bnavigation\\s*$/i.test(label) ? label.trim() : `${label.trim()} navigation`);\n\nconst FOCUSABLE = 'a[href], button:not([disabled]), select:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Side navigation that can get out of the way. Pinned, it sits beside the page. Unpinned, it keeps only the room its\n * menu button takes: a slim strip where the navigation was, so the button never sits over the page or a host's own\n * toolbar. Pressing it slides the navigation in from the left as a dialog: over the window, or, drawn inside a region\n * that answers to its own size (a surface in a host's canvas, a chat reply), over that region only. Focus moves into\n * it and stays there until it closes, on Escape, on its close button, or when an item is chosen; focus then goes back\n * to the menu button. Where the window or that region is under 40rem wide (`SIDENAV_NARROW`) it is always folded and\n * offers no pin.\n */\nexport function SideNav({ label, groups, current, onSelect, pinned: given, defaultPinned = true, onPinnedChange, header, footer, className }: SideNavProps) {\n const id = useId();\n const [kept, setKept] = useState(defaultPinned);\n const root = useRef<HTMLDivElement>(null);\n const narrow = useNarrow(root);\n // On a narrow screen it is folded whatever was chosen; the choice comes back on a wider one.\n const pinned = (given ?? kept) && !narrow;\n const [open, setOpen] = useState(false);\n const panel = useRef<HTMLDivElement>(null);\n const stage = useRef<HTMLDivElement>(null);\n const opener = () => document.getElementById(`${id}-open`);\n const close = () => {\n setOpen(false);\n requestAnimationFrame(() => opener()?.focus());\n };\n const setPinned = (next: boolean) => {\n setKept(next);\n setOpen(false);\n onPinnedChange?.(next);\n // Folding away from the button inside the panel: focus goes to the menu button that opens it again.\n if (!next) requestAnimationFrame(() => opener()?.focus());\n };\n const taking = !pinned && open;\n // Where the drawer goes while it is open: the part of its holder on screen, kept current as that moves, and counted\n // from whatever the stage is really placed against (the window, or a holder that contains fixed boxes).\n const [box, setBox] = useState<NavBox | undefined>(undefined);\n useLayoutEffect(() => {\n if (!taking) return;\n const place = () => {\n const rect = holderOf(root.current)?.getBoundingClientRect();\n const viewport = { width: window.innerWidth, height: window.innerHeight };\n const next = stageBox(drawerBox(rect ? { top: rect.top, left: rect.left, width: rect.width, height: rect.height } : undefined, viewport), fixedOrigin(stage.current), viewport);\n setBox((before) => (before && next && before.top === next.top && before.left === next.left && before.width === next.width && before.height === next.height ? before : next));\n };\n place();\n window.addEventListener(\"resize\", place);\n window.addEventListener(\"scroll\", place, true);\n return () => {\n window.removeEventListener(\"resize\", place);\n window.removeEventListener(\"scroll\", place, true);\n };\n }, [taking]);\n const placed = !pinned && box ? ({ \"--sf-sidenav-top\": `${box.top}px`, \"--sf-sidenav-left\": `${box.left}px`, \"--sf-sidenav-width\": `${box.width}px`, \"--sf-sidenav-height\": `${box.height}px` } as CSSProperties) : undefined;\n // Opened over the page: focus goes in, to the close button first.\n useEffect(() => {\n if (taking) panel.current?.querySelector<HTMLElement>(\".sf-sidenav-close\")?.focus();\n }, [taking]);\n\n const onKey = (event: KeyboardEvent<HTMLDivElement>) => {\n if (!taking) return;\n if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n return;\n }\n // Focus stays inside while it covers the page.\n if (event.key === \"Tab\" && panel.current) {\n const all = [...panel.current.querySelectorAll<HTMLElement>(FOCUSABLE)];\n const first = all[0];\n const last = all[all.length - 1];\n if (!first || !last) return;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n }\n };\n const choose = (item: string) => {\n onSelect?.(item);\n if (taking) close();\n };\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: Escape and Tab are handled here for everything inside; the controls themselves are buttons and links.\n <div ref={root} className={`sf-sidenav${className ? ` ${className}` : \"\"}`} data-pinned={pinned} data-open={open || undefined} data-narrow={narrow || undefined} style={placed} onKeyDown={onKey}>\n {!pinned && (\n <button id={`${id}-open`} type=\"button\" className=\"sf-sidenav-open\" aria-expanded={open} aria-controls={`${id}-panel`} aria-label={`Show ${navigationName(label)}`} onClick={() => setOpen(true)}>\n <ControlIcon icon=\"menu\" />\n </button>\n )}\n {/* Folded, the drawer and the dimmed page behind it live in a stage laid over the holder, which clips the drawer as it slides. */}\n <div ref={stage} className=\"sf-sidenav-stage\">\n {/* The page behind a drawer is dimmed, and a press on it closes the drawer; Escape and the close button do the same. */}\n {/* biome-ignore lint/a11y/useKeyWithClickEvents lint/a11y/noStaticElementInteractions: a pointer's shortcut; the keyboard closes it with Escape or the close button. */}\n {taking && <div className=\"sf-sidenav-backdrop\" aria-hidden=\"true\" onClick={close} />}\n <div\n id={`${id}-panel`}\n ref={panel}\n className=\"sf-sidenav-panel\"\n role={pinned ? undefined : \"dialog\"}\n aria-modal={taking || undefined}\n aria-label={pinned ? undefined : navigationName(label)}\n >\n <div className=\"sf-sidenav-top\">\n <div className=\"sf-sidenav-header\">{header}</div>\n {!narrow && (\n <button type=\"button\" className=\"sf-sidenav-pin\" aria-pressed={pinned} title={pinned ? \"Let the navigation fold away\" : \"Keep the navigation open\"} onClick={() => setPinned(!pinned)}>\n <ControlIcon icon={pinned ? \"fold\" : \"unfold\"} />\n <span className=\"sf-sidenav-pin-label\">{pinned ? \"Fold away\" : \"Keep open\"}</span>\n </button>\n )}\n {!pinned && (\n <button type=\"button\" className=\"sf-sidenav-close\" aria-label={`Close ${navigationName(label)}`} onClick={close}>\n <ControlIcon icon=\"close\" />\n </button>\n )}\n </div>\n <nav className=\"sf-sidenav-nav\" aria-label={label}>\n {groups.map((group, g) => (\n <section key={group.label ?? g} className=\"sf-sidenav-group\" aria-labelledby={group.label ? `${id}-group-${g}` : undefined}>\n {group.label && (\n <h2 id={`${id}-group-${g}`} className=\"sf-sidenav-group-label\">\n {group.label}\n </h2>\n )}\n <ul>\n {group.items.map((item) => (\n <li key={item.id}>\n {item.href ? (\n <a href={item.href} aria-current={item.id === current ? \"page\" : undefined} onClick={() => choose(item.id)}>\n {item.label}\n </a>\n ) : (\n <button type=\"button\" aria-current={item.id === current ? \"page\" : undefined} onClick={() => choose(item.id)}>\n {item.label}\n </button>\n )}\n </li>\n ))}\n </ul>\n </section>\n ))}\n </nav>\n {footer && <div className=\"sf-sidenav-footer\">{footer}</div>}\n </div>\n </div>\n </div>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surfaces-ui/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React components for Surfaces UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"surfaces-ui",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"jsdom": "^31.0.0",
|
|
54
54
|
"react": "^19.3.1",
|
|
55
55
|
"react-dom": "^19.3.1",
|
|
56
|
-
"@surfaces-ui/discovery": "0.
|
|
56
|
+
"@surfaces-ui/discovery": "0.5.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@bufbuild/protobuf": "^2.17.0",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"@lezer/highlight": "^1.2.5",
|
|
68
68
|
"apache-arrow": "^21.2.0",
|
|
69
69
|
"echarts": "^6.1.0",
|
|
70
|
-
"@surfaces-ui/data": "0.
|
|
71
|
-
"@surfaces-ui/proto": "0.
|
|
72
|
-
"@surfaces-ui/tokens": "0.
|
|
73
|
-
"@surfaces-ui/trace": "0.
|
|
70
|
+
"@surfaces-ui/data": "0.5.0",
|
|
71
|
+
"@surfaces-ui/proto": "0.5.0",
|
|
72
|
+
"@surfaces-ui/tokens": "0.5.0",
|
|
73
|
+
"@surfaces-ui/trace": "0.5.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"react": ">=18",
|