@malloy-publisher/sdk 0.9.0 → 0.9.2
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/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
- package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
- package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
- package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
- package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
- package/dist/builder/index.cjs.js +146 -58
- package/dist/builder/index.es.js +9076 -6479
- package/dist/builder-entry.d.ts +4 -0
- package/dist/client/api.d.ts +82 -48
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +84 -82
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
- package/dist/components/Dashboard/DashboardView.d.ts +36 -0
- package/dist/components/Dashboard/TileCard.d.ts +15 -4
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/index.d.ts +3 -0
- package/dist/components/Dashboard/telemetry.d.ts +15 -3
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +1 -0
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +4 -0
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9714 -7072
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CbbBcZl8.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/utils/clock.d.ts +2 -0
- package/package.json +10 -1
- package/src/builder-entry.ts +35 -0
- package/src/components/Dashboard/Dashboard.tsx +27 -278
- package/src/components/Dashboard/DashboardGrid.tsx +68 -7
- package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
- package/src/components/Dashboard/DashboardTile.tsx +31 -4
- package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
- package/src/components/Dashboard/DashboardView.tsx +352 -0
- package/src/components/Dashboard/RowsDialog.tsx +1 -1
- package/src/components/Dashboard/TileCard.tsx +44 -10
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/index.ts +3 -0
- package/src/components/Dashboard/telemetry.ts +16 -5
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
- package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
- package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
- package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
- package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
- package/src/components/DashboardBuilder/InlineText.tsx +106 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
- package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
- package/src/components/DashboardBuilder/catalog.ts +61 -21
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +257 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
- package/src/components/DashboardBuilder/malloyText.ts +181 -27
- package/src/components/DashboardBuilder/malloyTree.ts +155 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
- package/src/components/DashboardBuilder/readDocument.ts +130 -44
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +47 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
- package/src/components/DashboardBuilder/sortable.tsx +2 -12
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +66 -27
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +190 -0
- package/src/components/Package/Package.create.spec.tsx +380 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +366 -171
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +13 -0
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/RenderedResult/RenderedResult.tsx +18 -1
- package/src/components/RenderedResult/ResultContainer.tsx +44 -11
- package/src/components/RenderedResult/ResultPanel.tsx +4 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +3 -3
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useQueryResult.ts +16 -0
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +118 -0
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
- package/src/components/DashboardBuilder/useTileResize.ts +0 -110
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
cleanup,
|
|
6
|
+
fireEvent,
|
|
7
|
+
render,
|
|
8
|
+
screen,
|
|
9
|
+
waitFor,
|
|
10
|
+
within,
|
|
11
|
+
} from "@testing-library/react";
|
|
12
|
+
import { afterEach, describe, expect, it } from "bun:test";
|
|
13
|
+
import {
|
|
14
|
+
MAX_COLUMNS,
|
|
15
|
+
nudgedSpan,
|
|
16
|
+
presetSpan,
|
|
17
|
+
} from "../Dashboard/DashboardGrid";
|
|
18
|
+
import { SettingsPopover, type PageSettings } from "./SettingsPopover";
|
|
19
|
+
|
|
20
|
+
afterEach(cleanup);
|
|
21
|
+
|
|
22
|
+
function open(settings: PageSettings, onCommit = (_: PageSettings) => {}) {
|
|
23
|
+
const anchor = document.body.appendChild(document.createElement("button"));
|
|
24
|
+
render(
|
|
25
|
+
<SettingsPopover
|
|
26
|
+
anchor={anchor}
|
|
27
|
+
settings={settings}
|
|
28
|
+
inUse={new Set()}
|
|
29
|
+
onClose={() => {}}
|
|
30
|
+
onCommit={onCommit}
|
|
31
|
+
/>,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const select = () => screen.getByLabelText("Grid width");
|
|
36
|
+
const options = async () => {
|
|
37
|
+
fireEvent.mouseDown(select());
|
|
38
|
+
const list = await screen.findByRole("listbox");
|
|
39
|
+
return within(list)
|
|
40
|
+
.getAllByRole("option")
|
|
41
|
+
.map((o) => o.textContent);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
describe("Grid width", () => {
|
|
45
|
+
it("shows 2 for an unset file, with no separate Default item", async () => {
|
|
46
|
+
open({ imports: [] });
|
|
47
|
+
expect(select().textContent).toBe("2");
|
|
48
|
+
const shown = await options();
|
|
49
|
+
expect(shown.filter((t) => t === "2")).toHaveLength(1);
|
|
50
|
+
expect(shown.some((t) => /default/i.test(t ?? ""))).toBe(false);
|
|
51
|
+
expect(shown.at(-1)).toBe(String(MAX_COLUMNS));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("still lists a width the file wrote that is not a usual one", async () => {
|
|
55
|
+
open({ imports: [], columns: 10 });
|
|
56
|
+
expect(select().textContent).toBe("10");
|
|
57
|
+
expect(await options()).toContain("10");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("writes the picked width", async () => {
|
|
61
|
+
let next: PageSettings | undefined;
|
|
62
|
+
open({ imports: [] }, (s) => (next = s));
|
|
63
|
+
fireEvent.mouseDown(select());
|
|
64
|
+
const list = await screen.findByRole("listbox");
|
|
65
|
+
fireEvent.click(within(list).getByText("12"));
|
|
66
|
+
fireEvent.keyDown(list, { key: "Escape" });
|
|
67
|
+
await waitFor(() => expect(next?.columns).toBe(12));
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("nudgedSpan", () => {
|
|
72
|
+
it("stays within the grid and never passes the builder maximum", () => {
|
|
73
|
+
expect(nudgedSpan(1, -1, 12)).toBe(1);
|
|
74
|
+
expect(nudgedSpan(12, 1, 12)).toBe(12);
|
|
75
|
+
expect(nudgedSpan(5, 1, 12)).toBe(6);
|
|
76
|
+
expect(nudgedSpan(MAX_COLUMNS, 1, 36)).toBe(MAX_COLUMNS);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe("presetSpan", () => {
|
|
81
|
+
it("takes a fraction of the grid and never passes the builder maximum", () => {
|
|
82
|
+
expect(presetSpan(12, 3)).toBe(4);
|
|
83
|
+
expect(presetSpan(2, 4)).toBe(1);
|
|
84
|
+
expect(presetSpan(36, 1)).toBe(MAX_COLUMNS);
|
|
85
|
+
expect(presetSpan(36, 2)).toBe(18);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -1,51 +1,100 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import CancelIcon from "@mui/icons-material/Cancel";
|
|
4
5
|
import {
|
|
6
|
+
Chip,
|
|
5
7
|
FormControlLabel,
|
|
6
8
|
MenuItem,
|
|
7
9
|
Popover,
|
|
8
10
|
Stack,
|
|
9
11
|
Switch,
|
|
10
12
|
TextField,
|
|
13
|
+
ToggleButton,
|
|
14
|
+
ToggleButtonGroup,
|
|
11
15
|
Typography,
|
|
12
16
|
} from "@mui/material";
|
|
17
|
+
import { DEFAULT_COLUMNS, MAX_COLUMNS } from "../Dashboard/DashboardGrid";
|
|
13
18
|
import { useDraft } from "./useDraft";
|
|
14
19
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
15
|
-
import type {
|
|
20
|
+
import type { PackageCatalog } from "./catalog";
|
|
21
|
+
import type {
|
|
22
|
+
DashboardDocument,
|
|
23
|
+
DashboardImport,
|
|
24
|
+
DocumentKind,
|
|
25
|
+
} from "./document";
|
|
16
26
|
|
|
17
27
|
/**
|
|
18
|
-
* The page's own settings, off the edit bar:
|
|
19
|
-
*
|
|
20
|
-
*
|
|
28
|
+
* The page's own settings, off the edit bar: what it shows as, the grid's
|
|
29
|
+
* width, whether controls run as they change or behind an Apply button, and
|
|
30
|
+
* the sources it imports. Its title and description are edited on the page. Edits commit on close
|
|
31
|
+
* (`useDraft`).
|
|
21
32
|
*/
|
|
22
33
|
export interface PageSettings {
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
/** Absent reads as a dashboard. */
|
|
35
|
+
kind?: DocumentKind;
|
|
25
36
|
columns?: number;
|
|
26
37
|
autorun?: boolean;
|
|
38
|
+
/** A `{ names }` import is edited as sources; a whole-file import is shown and left alone. */
|
|
39
|
+
imports: DashboardImport[];
|
|
27
40
|
}
|
|
28
41
|
|
|
29
42
|
export const settingsOf = (document: DashboardDocument): PageSettings => ({
|
|
30
|
-
|
|
31
|
-
...(document.
|
|
32
|
-
? {}
|
|
33
|
-
: { description: document.description }),
|
|
43
|
+
imports: document.imports,
|
|
44
|
+
...(document.kind === undefined ? {} : { kind: document.kind }),
|
|
34
45
|
...(document.columns === undefined ? {} : { columns: document.columns }),
|
|
35
46
|
...(document.autorun === undefined ? {} : { autorun: document.autorun }),
|
|
36
47
|
});
|
|
37
48
|
|
|
38
|
-
/**
|
|
39
|
-
const
|
|
49
|
+
/** Where a model is imported from: documents sit one folder below the package root. */
|
|
50
|
+
const importPathOf = (modelPath: string) => `../${modelPath}`;
|
|
51
|
+
|
|
52
|
+
/** `settings` with `name` from `modelPath` imported. */
|
|
53
|
+
export function withSource(
|
|
54
|
+
imports: DashboardImport[],
|
|
55
|
+
name: string,
|
|
56
|
+
modelPath: string,
|
|
57
|
+
): DashboardImport[] {
|
|
58
|
+
const from = importPathOf(modelPath);
|
|
59
|
+
if (imports.some((i) => i.kind === "names" && i.names.includes(name)))
|
|
60
|
+
return imports;
|
|
61
|
+
const at = imports.findIndex((i) => i.kind === "names" && i.from === from);
|
|
62
|
+
if (at < 0) return [...imports, { kind: "names", names: [name], from }];
|
|
63
|
+
return imports.map((i, index) =>
|
|
64
|
+
index === at && i.kind === "names"
|
|
65
|
+
? { ...i, names: [...i.names, name] }
|
|
66
|
+
: i,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** `imports` without the source `name`; its statement goes with its last name. */
|
|
71
|
+
export const withoutSource = (
|
|
72
|
+
imports: DashboardImport[],
|
|
73
|
+
name: string,
|
|
74
|
+
): DashboardImport[] =>
|
|
75
|
+
imports.flatMap((i) => {
|
|
76
|
+
if (i.kind !== "names" || !i.names.includes(name)) return [i];
|
|
77
|
+
const names = i.names.filter((n) => n !== name);
|
|
78
|
+
return names.length === 0 ? [] : [{ ...i, names }];
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/** The divisors of 12 from 2 up, and 24; the file may say any other width. */
|
|
82
|
+
const WIDTHS = [2, 3, 4, 6, 12, MAX_COLUMNS];
|
|
40
83
|
|
|
41
84
|
export function SettingsPopover({
|
|
42
85
|
anchor,
|
|
43
86
|
settings,
|
|
87
|
+
catalog,
|
|
88
|
+
inUse,
|
|
44
89
|
onClose,
|
|
45
90
|
onCommit,
|
|
46
91
|
}: {
|
|
47
92
|
anchor: HTMLElement | null;
|
|
48
93
|
settings: PageSettings;
|
|
94
|
+
/** What the package offers to import; without it the sources are shown, not edited. */
|
|
95
|
+
catalog?: PackageCatalog | undefined;
|
|
96
|
+
/** Sources a tile or extension reads, which cannot be taken off. */
|
|
97
|
+
inUse: ReadonlySet<string>;
|
|
49
98
|
onClose: () => void;
|
|
50
99
|
/** Called once, on close, only when something changed. */
|
|
51
100
|
onCommit: (next: PageSettings) => void;
|
|
@@ -58,10 +107,22 @@ export function SettingsPopover({
|
|
|
58
107
|
onClose,
|
|
59
108
|
);
|
|
60
109
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
:
|
|
110
|
+
const notebook = draft?.kind === "notebook";
|
|
111
|
+
const imported = new Set(
|
|
112
|
+
(draft?.imports ?? []).flatMap((i) =>
|
|
113
|
+
i.kind === "names" ? i.names : [],
|
|
114
|
+
),
|
|
115
|
+
);
|
|
116
|
+
const offered = (catalog?.sources ?? []).filter(
|
|
117
|
+
(source) =>
|
|
118
|
+
!imported.has(source.name) &&
|
|
119
|
+
!source.modelPath.startsWith("dashboards/") &&
|
|
120
|
+
!source.modelPath.startsWith("notebooks/"),
|
|
121
|
+
);
|
|
122
|
+
const shown = draft?.columns ?? DEFAULT_COLUMNS;
|
|
123
|
+
const widths = WIDTHS.includes(shown)
|
|
124
|
+
? WIDTHS
|
|
125
|
+
: [...WIDTHS, shown].sort((a, b) => a - b);
|
|
65
126
|
|
|
66
127
|
return (
|
|
67
128
|
<Popover
|
|
@@ -78,59 +139,156 @@ export function SettingsPopover({
|
|
|
78
139
|
variant="overline"
|
|
79
140
|
sx={{ color: theme.tileTitle, lineHeight: 1.5 }}
|
|
80
141
|
>
|
|
81
|
-
Dashboard
|
|
142
|
+
{notebook ? "Notebook" : "Dashboard"}
|
|
82
143
|
</Typography>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
autoFocus
|
|
88
|
-
inputProps={{ "aria-label": "Dashboard title" }}
|
|
89
|
-
onChange={(event) =>
|
|
90
|
-
patch((s) => {
|
|
91
|
-
s.title = event.target.value;
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
/>
|
|
95
|
-
<TextField
|
|
96
|
-
size="small"
|
|
97
|
-
label="Description"
|
|
98
|
-
multiline
|
|
99
|
-
minRows={3}
|
|
100
|
-
maxRows={10}
|
|
101
|
-
value={draft.description ?? ""}
|
|
102
|
-
helperText="Markdown. A blank line starts a new paragraph."
|
|
103
|
-
inputProps={{ "aria-label": "Dashboard description" }}
|
|
104
|
-
onChange={(event) =>
|
|
105
|
-
patch((s) => {
|
|
106
|
-
const v = event.target.value;
|
|
107
|
-
if (v.trim() === "") delete s.description;
|
|
108
|
-
else s.description = v;
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
/>
|
|
112
|
-
<TextField
|
|
113
|
-
select
|
|
114
|
-
size="small"
|
|
115
|
-
label="Grid width"
|
|
116
|
-
value={draft.columns ?? ""}
|
|
117
|
-
helperText="Columns across the page. Tiles are placed in these."
|
|
118
|
-
inputProps={{ "aria-label": "Grid width" }}
|
|
119
|
-
onChange={(event) =>
|
|
120
|
-
patch((s) => {
|
|
121
|
-
const v = Number(event.target.value);
|
|
122
|
-
if (!v) delete s.columns;
|
|
123
|
-
else s.columns = v;
|
|
124
|
-
})
|
|
125
|
-
}
|
|
144
|
+
{/* A notebook is the same file with one column, so switching is a tag edit, not a move. */}
|
|
145
|
+
<Stack
|
|
146
|
+
direction="row"
|
|
147
|
+
sx={{ gap: 1, alignItems: "center", flexWrap: "wrap" }}
|
|
126
148
|
>
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
149
|
+
<Typography variant="caption" sx={{ color: theme.tileTitle }}>
|
|
150
|
+
Show as
|
|
151
|
+
</Typography>
|
|
152
|
+
<ToggleButtonGroup
|
|
153
|
+
size="small"
|
|
154
|
+
exclusive
|
|
155
|
+
value={notebook ? "notebook" : "dashboard"}
|
|
156
|
+
aria-label="Show as"
|
|
157
|
+
onChange={(_, next: DocumentKind | null) => {
|
|
158
|
+
if (next === null) return;
|
|
159
|
+
patch((s) => {
|
|
160
|
+
if (next === "notebook") {
|
|
161
|
+
s.kind = "notebook";
|
|
162
|
+
delete s.columns;
|
|
163
|
+
} else delete s.kind;
|
|
164
|
+
});
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<ToggleButton value="dashboard" sx={{ px: 1.5 }}>
|
|
168
|
+
Dashboard
|
|
169
|
+
</ToggleButton>
|
|
170
|
+
<ToggleButton value="notebook" sx={{ px: 1.5 }}>
|
|
171
|
+
Notebook
|
|
172
|
+
</ToggleButton>
|
|
173
|
+
</ToggleButtonGroup>
|
|
174
|
+
</Stack>
|
|
175
|
+
{!notebook && (
|
|
176
|
+
<TextField
|
|
177
|
+
select
|
|
178
|
+
size="small"
|
|
179
|
+
label="Grid width"
|
|
180
|
+
value={shown}
|
|
181
|
+
helperText="Columns across the page. Tiles are placed in these."
|
|
182
|
+
inputProps={{ "aria-label": "Grid width" }}
|
|
183
|
+
onChange={(event) =>
|
|
184
|
+
patch((s) => {
|
|
185
|
+
s.columns = Number(event.target.value);
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
{widths.map((w) => (
|
|
190
|
+
<MenuItem key={w} value={w}>
|
|
191
|
+
{w}
|
|
192
|
+
</MenuItem>
|
|
193
|
+
))}
|
|
194
|
+
</TextField>
|
|
195
|
+
)}
|
|
196
|
+
<Stack sx={{ gap: 0.75 }}>
|
|
197
|
+
<Typography variant="caption" sx={{ color: theme.tileTitle }}>
|
|
198
|
+
Sources
|
|
199
|
+
</Typography>
|
|
200
|
+
<Stack
|
|
201
|
+
direction="row"
|
|
202
|
+
aria-label="Sources"
|
|
203
|
+
sx={{ gap: 0.75, flexWrap: "wrap" }}
|
|
204
|
+
>
|
|
205
|
+
{draft.imports.length === 0 && (
|
|
206
|
+
<Typography variant="body2" sx={{ opacity: 0.7 }}>
|
|
207
|
+
None imported.
|
|
208
|
+
</Typography>
|
|
209
|
+
)}
|
|
210
|
+
{draft.imports.flatMap((entry) =>
|
|
211
|
+
entry.kind === "all"
|
|
212
|
+
? [
|
|
213
|
+
<Chip
|
|
214
|
+
key={`all ${entry.from}`}
|
|
215
|
+
size="small"
|
|
216
|
+
variant="outlined"
|
|
217
|
+
label={entry.from}
|
|
218
|
+
title="Every declaration in this file; edit it in the file"
|
|
219
|
+
/>,
|
|
220
|
+
]
|
|
221
|
+
: entry.names.map((name) => (
|
|
222
|
+
<Chip
|
|
223
|
+
key={`${entry.from} ${name}`}
|
|
224
|
+
size="small"
|
|
225
|
+
label={name}
|
|
226
|
+
title={
|
|
227
|
+
inUse.has(name)
|
|
228
|
+
? `${name} from ${entry.from}; a tile reads it`
|
|
229
|
+
: `${name} from ${entry.from}`
|
|
230
|
+
}
|
|
231
|
+
{...(inUse.has(name)
|
|
232
|
+
? {}
|
|
233
|
+
: {
|
|
234
|
+
onDelete: () =>
|
|
235
|
+
patch((s) => {
|
|
236
|
+
s.imports = withoutSource(
|
|
237
|
+
s.imports,
|
|
238
|
+
name,
|
|
239
|
+
);
|
|
240
|
+
}),
|
|
241
|
+
deleteIcon: (
|
|
242
|
+
<CancelIcon
|
|
243
|
+
aria-label={`Remove source ${name}`}
|
|
244
|
+
/>
|
|
245
|
+
),
|
|
246
|
+
})}
|
|
247
|
+
/>
|
|
248
|
+
)),
|
|
249
|
+
)}
|
|
250
|
+
</Stack>
|
|
251
|
+
{catalog && offered.length > 0 && (
|
|
252
|
+
<TextField
|
|
253
|
+
select
|
|
254
|
+
size="small"
|
|
255
|
+
label="Add a source"
|
|
256
|
+
value=""
|
|
257
|
+
inputProps={{ "aria-label": "Add a source" }}
|
|
258
|
+
onChange={(event) => {
|
|
259
|
+
const picked = offered.find(
|
|
260
|
+
(source) =>
|
|
261
|
+
`${source.modelPath} ${source.name}` ===
|
|
262
|
+
event.target.value,
|
|
263
|
+
);
|
|
264
|
+
if (!picked) return;
|
|
265
|
+
patch((s) => {
|
|
266
|
+
s.imports = withSource(
|
|
267
|
+
s.imports,
|
|
268
|
+
picked.name,
|
|
269
|
+
picked.modelPath,
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
}}
|
|
273
|
+
>
|
|
274
|
+
{offered.map((source) => (
|
|
275
|
+
<MenuItem
|
|
276
|
+
key={`${source.modelPath} ${source.name}`}
|
|
277
|
+
value={`${source.modelPath} ${source.name}`}
|
|
278
|
+
>
|
|
279
|
+
{source.name}
|
|
280
|
+
<Typography
|
|
281
|
+
component="span"
|
|
282
|
+
variant="caption"
|
|
283
|
+
sx={{ ml: 1, opacity: 0.7 }}
|
|
284
|
+
>
|
|
285
|
+
{source.modelPath}
|
|
286
|
+
</Typography>
|
|
287
|
+
</MenuItem>
|
|
288
|
+
))}
|
|
289
|
+
</TextField>
|
|
290
|
+
)}
|
|
291
|
+
</Stack>
|
|
134
292
|
<FormControlLabel
|
|
135
293
|
control={
|
|
136
294
|
<Switch
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Box,
|
|
6
|
+
Chip,
|
|
7
|
+
List,
|
|
8
|
+
ListItemButton,
|
|
9
|
+
ListItemText,
|
|
10
|
+
MenuItem,
|
|
11
|
+
TextField,
|
|
12
|
+
Typography,
|
|
13
|
+
} from "@mui/material";
|
|
14
|
+
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
15
|
+
import type { CatalogSource } from "./catalog";
|
|
16
|
+
|
|
17
|
+
/** A source select and the list of its views, which is what both "add a tile" and "add a query" pick from. */
|
|
18
|
+
export function SourceViewPicker({
|
|
19
|
+
sources,
|
|
20
|
+
source,
|
|
21
|
+
view,
|
|
22
|
+
onSource,
|
|
23
|
+
onView,
|
|
24
|
+
}: {
|
|
25
|
+
sources: CatalogSource[];
|
|
26
|
+
source: string;
|
|
27
|
+
view: string;
|
|
28
|
+
onSource: (name: string) => void;
|
|
29
|
+
onView: (name: string) => void;
|
|
30
|
+
}) {
|
|
31
|
+
const { theme } = usePublisherTheme();
|
|
32
|
+
const picked = sources.find((s) => s.name === source);
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<TextField
|
|
36
|
+
select
|
|
37
|
+
size="small"
|
|
38
|
+
label="Source"
|
|
39
|
+
value={source}
|
|
40
|
+
onChange={(event) => onSource(event.target.value)}
|
|
41
|
+
inputProps={{ "aria-label": "Source" }}
|
|
42
|
+
>
|
|
43
|
+
{sources.map((s) => (
|
|
44
|
+
<MenuItem
|
|
45
|
+
key={s.name}
|
|
46
|
+
value={s.name}
|
|
47
|
+
disabled={s.views.length === 0}
|
|
48
|
+
>
|
|
49
|
+
{s.name}
|
|
50
|
+
{s.views.length === 0 && (
|
|
51
|
+
<Typography
|
|
52
|
+
component="span"
|
|
53
|
+
variant="caption"
|
|
54
|
+
sx={{ ml: 1 }}
|
|
55
|
+
>
|
|
56
|
+
declares no views
|
|
57
|
+
</Typography>
|
|
58
|
+
)}
|
|
59
|
+
{s.description && (
|
|
60
|
+
<Typography
|
|
61
|
+
component="span"
|
|
62
|
+
variant="caption"
|
|
63
|
+
sx={{ ml: 1, opacity: 0.6 }}
|
|
64
|
+
>
|
|
65
|
+
{s.description}
|
|
66
|
+
</Typography>
|
|
67
|
+
)}
|
|
68
|
+
</MenuItem>
|
|
69
|
+
))}
|
|
70
|
+
</TextField>
|
|
71
|
+
<Box>
|
|
72
|
+
<Typography variant="subtitle2" sx={{ mb: 0.5 }}>
|
|
73
|
+
View
|
|
74
|
+
</Typography>
|
|
75
|
+
<List
|
|
76
|
+
dense
|
|
77
|
+
disablePadding
|
|
78
|
+
aria-label="Views"
|
|
79
|
+
sx={{
|
|
80
|
+
maxHeight: "min(280px, 30vh)",
|
|
81
|
+
overflowY: "auto",
|
|
82
|
+
border: theme.border,
|
|
83
|
+
borderRadius: 1,
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{(picked?.views ?? []).map((v) => (
|
|
87
|
+
<ListItemButton
|
|
88
|
+
key={v.name}
|
|
89
|
+
selected={view === v.name}
|
|
90
|
+
onClick={() => onView(v.name)}
|
|
91
|
+
aria-label={`View ${v.name}`}
|
|
92
|
+
>
|
|
93
|
+
<ListItemText
|
|
94
|
+
primary={v.name}
|
|
95
|
+
secondary={v.description}
|
|
96
|
+
primaryTypographyProps={{
|
|
97
|
+
fontFamily: "ui-monospace, monospace",
|
|
98
|
+
fontSize: 13,
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
{v.chart && (
|
|
102
|
+
<Chip
|
|
103
|
+
size="small"
|
|
104
|
+
variant="outlined"
|
|
105
|
+
label={v.chart.replace(/_chart$/, "")}
|
|
106
|
+
/>
|
|
107
|
+
)}
|
|
108
|
+
</ListItemButton>
|
|
109
|
+
))}
|
|
110
|
+
{picked && picked.views.length === 0 && (
|
|
111
|
+
<Typography
|
|
112
|
+
variant="body2"
|
|
113
|
+
sx={{ p: 1.5, color: theme.tileTitle }}
|
|
114
|
+
>
|
|
115
|
+
This source declares no views.
|
|
116
|
+
</Typography>
|
|
117
|
+
)}
|
|
118
|
+
</List>
|
|
119
|
+
</Box>
|
|
120
|
+
</>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { TileCard } from "../Dashboard/TileCard";
|
|
5
|
+
import { InlineMarkdown } from "./InlineMarkdown";
|
|
6
|
+
import type { TextTile } from "./document";
|
|
7
|
+
|
|
8
|
+
export const TEXT_TILE_PLACEHOLDER =
|
|
9
|
+
"Write markdown: # heading, **bold**, - list";
|
|
10
|
+
|
|
11
|
+
/** A text tile as the builder draws it: its markdown, edited in place. */
|
|
12
|
+
export function TextTileBody({
|
|
13
|
+
tile,
|
|
14
|
+
onChange,
|
|
15
|
+
}: {
|
|
16
|
+
tile: TextTile;
|
|
17
|
+
onChange: (markdown: string) => void;
|
|
18
|
+
}) {
|
|
19
|
+
return (
|
|
20
|
+
<TileCard sx={{ minHeight: 72 }}>
|
|
21
|
+
<InlineMarkdown
|
|
22
|
+
markdown={tile.markdown}
|
|
23
|
+
placeholder={TEXT_TILE_PLACEHOLDER}
|
|
24
|
+
onCommit={onChange}
|
|
25
|
+
/>
|
|
26
|
+
</TileCard>
|
|
27
|
+
);
|
|
28
|
+
}
|