@malloy-publisher/sdk 0.9.9 → 0.9.11
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/RenderedResult-BlNoIiSi.cjs.js +153 -0
- package/dist/{RenderedResult-BHuJpdSn.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
- package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
- package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
- package/dist/builder/index.cjs.js +78 -130
- package/dist/builder/index.es.js +7440 -6727
- package/dist/builder-entry.d.ts +3 -0
- package/dist/client/api.d.ts +26 -22
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +9 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
- package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
- package/dist/components/Dashboard/DashboardView.d.ts +22 -23
- package/dist/components/Dashboard/TileCard.d.ts +10 -3
- package/dist/components/Dashboard/useStuck.d.ts +22 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -5
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
- package/dist/components/Package/PackageProblems.d.ts +14 -0
- package/dist/components/RemoveBadge.d.ts +40 -0
- package/dist/components/Report/Report.d.ts +13 -4
- package/dist/components/Report/ReportPage.d.ts +60 -0
- package/dist/components/Report/layoutRules.d.ts +32 -0
- package/dist/components/Report/reportQuery.d.ts +30 -0
- package/dist/components/Report/telemetry.d.ts +0 -2
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
- package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
- package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
- package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
- package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
- package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -6
- package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
- package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
- package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
- package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
- package/dist/components/ReportBuilder/TileMenu.d.ts +19 -11
- package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
- package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
- package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
- package/dist/components/ReportBuilder/catalog.d.ts +2 -4
- package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
- package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
- package/dist/components/ReportBuilder/preview.d.ts +17 -2
- package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
- package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
- package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
- package/dist/components/ReportBuilder/sortable.d.ts +4 -3
- package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
- package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
- package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
- package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
- package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
- package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
- package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
- package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
- package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
- package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
- package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
- package/dist/components/ServerProvider.d.ts +9 -0
- package/dist/components/controlTokens.d.ts +45 -0
- package/dist/components/drill/markDrillableCells.d.ts +1 -1
- package/dist/components/given/FilterButton.d.ts +35 -0
- package/dist/components/given/GivensPanel.d.ts +2 -1
- package/dist/components/given/filterEditing.d.ts +54 -0
- package/dist/components/given/filterSummary.d.ts +9 -0
- package/dist/components/given/paramCodec.d.ts +11 -0
- package/dist/components/given/required.d.ts +25 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/legacy/index.d.ts +1 -1
- package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
- package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
- package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
- package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
- package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
- package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
- package/dist/components/styles.d.ts +0 -2
- package/dist/hooks/useQueryResult.d.ts +7 -0
- package/dist/index.cjs.js +16 -19
- package/dist/index.es.js +8324 -7769
- package/dist/theme/ThemeContext.d.ts +8 -1
- package/dist/theme/classes.d.ts +49 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/ui.d.ts +75 -0
- package/dist/{useCompiledDocument-1dgF5CC9.es.js → useCompiledDocument-7j5cBjQd.es.js} +8768 -7912
- package/dist/useCompiledDocument-B21sVbb4.cjs.js +141 -0
- package/package.json +2 -2
- package/src/builder-entry.ts +9 -0
- package/src/components/AppDialog.tsx +23 -0
- package/src/components/Dashboard/DashboardGrid.tsx +39 -17
- package/src/components/Dashboard/DashboardTile.tsx +19 -2
- package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
- package/src/components/Dashboard/DashboardView.tsx +136 -105
- package/src/components/Dashboard/RowsDialog.tsx +1 -2
- package/src/components/Dashboard/TileCard.tsx +28 -10
- package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
- package/src/components/Dashboard/useStuck.ts +49 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +8 -6
- package/src/components/DocumentCreate/newNotebook.ts +26 -12
- package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
- package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
- package/src/components/Package/NewDocumentDialog.tsx +383 -119
- package/src/components/Package/Package.artifacts.spec.tsx +1 -1
- package/src/components/Package/Package.create.spec.tsx +7 -6
- package/src/components/Package/Package.tsx +10 -7
- package/src/components/Package/PackageProblems.spec.tsx +41 -0
- package/src/components/Package/PackageProblems.tsx +95 -0
- package/src/components/Prose.tsx +12 -7
- package/src/components/RemoveBadge.tsx +94 -0
- package/src/components/RenderedResult/RenderedResult.tsx +5 -9
- package/src/components/RenderedResult/ResultPanel.tsx +59 -3
- package/src/components/Report/Report.spec.tsx +50 -32
- package/src/components/Report/Report.telemetry.spec.tsx +0 -45
- package/src/components/Report/Report.tsx +45 -77
- package/src/components/Report/ReportPage.tsx +168 -0
- package/src/components/Report/layoutRules.spec.ts +35 -0
- package/src/components/Report/layoutRules.ts +55 -0
- package/src/components/Report/reportQuery.ts +53 -0
- package/src/components/Report/telemetry.ts +0 -2
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
- package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
- package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
- package/src/components/ReportBuilder/BuilderDialogs.tsx +30 -39
- package/src/components/ReportBuilder/BuilderGrid.tsx +43 -31
- package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
- package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
- package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
- package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
- package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
- package/src/components/ReportBuilder/FilterStrip.tsx +129 -150
- package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
- package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -16
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
- package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
- package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +41 -36
- package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
- package/src/components/ReportBuilder/ReportBuilder.tsx +292 -116
- package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
- package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
- package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
- package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
- package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
- package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
- package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
- package/src/components/ReportBuilder/TileFrame.tsx +212 -75
- package/src/components/ReportBuilder/TileMenu.tsx +248 -142
- package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
- package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
- package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
- package/src/components/ReportBuilder/builderControls.ts +164 -0
- package/src/components/ReportBuilder/builderReport.ts +1 -2
- package/src/components/ReportBuilder/catalog.ts +10 -26
- package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
- package/src/components/ReportBuilder/localGiven.ts +56 -0
- package/src/components/ReportBuilder/newDashboard.spec.ts +2 -3
- package/src/components/ReportBuilder/preview.spec.ts +125 -5
- package/src/components/ReportBuilder/preview.ts +60 -44
- package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
- package/src/components/ReportBuilder/readDocument.ts +14 -11
- package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
- package/src/components/ReportBuilder/readForEditor.ts +4 -26
- package/src/components/ReportBuilder/reportTag.ts +28 -7
- package/src/components/ReportBuilder/sortable.tsx +15 -7
- package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
- package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
- package/src/components/ReportBuilder/testing/inline.ts +25 -5
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
- package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
- package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
- package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
- package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
- package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
- package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
- package/src/components/ReportBuilder/useExitGuard.ts +16 -0
- package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
- package/src/components/ReportBuilder/useFilterForm.ts +5 -1
- package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
- package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
- package/src/components/ReportBuilder/useReportDraft.ts +292 -0
- package/src/components/ReportBuilder/useReportEditor.ts +3 -12
- package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
- package/src/components/ReportBuilder/useTileEditing.ts +43 -12
- package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
- package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
- package/src/components/ReportBuilder/widthLabel.ts +26 -0
- package/src/components/ServerProvider.tsx +11 -0
- package/src/components/controlTokens.ts +47 -0
- package/src/components/drill/markDrillableCells.ts +2 -1
- package/src/components/given/FilterButton.spec.tsx +143 -0
- package/src/components/given/FilterButton.tsx +478 -0
- package/src/components/given/GivenInput.spec.tsx +47 -0
- package/src/components/given/GivenInput.tsx +20 -2
- package/src/components/given/GivensPanel.spec.tsx +11 -3
- package/src/components/given/GivensPanel.tsx +45 -44
- package/src/components/given/filterEditing.ts +60 -0
- package/src/components/given/filterSummary.spec.ts +108 -0
- package/src/components/given/filterSummary.ts +109 -0
- package/src/components/given/paramCodec.ts +1 -1
- package/src/components/given/required.spec.ts +60 -0
- package/src/components/given/required.ts +78 -0
- package/src/components/index.ts +9 -0
- package/src/components/legacy/Dashboard.spec.tsx +3 -1
- package/src/components/legacy/index.ts +1 -1
- package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
- package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
- package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
- package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
- package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
- package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
- package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
- package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
- package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
- package/src/components/legacy/malloynb/cellKind.ts +24 -0
- package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
- package/src/components/styles.ts +0 -18
- package/src/hooks/useGivensState.ts +7 -3
- package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
- package/src/hooks/useQueryResult.ts +26 -1
- package/src/theme/ThemeContext.tsx +21 -1
- package/src/theme/classes.ts +52 -0
- package/src/theme/index.ts +8 -0
- package/src/theme/resolveTheme.ts +3 -0
- package/src/theme/types.ts +7 -0
- package/src/theme/ui.spec.tsx +91 -0
- package/src/theme/ui.ts +115 -0
- package/dist/RenderedResult-Bw7EQc42.cjs.js +0 -153
- package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
- package/dist/components/Notebook/cellKind.d.ts +0 -20
- package/dist/components/Report/LinearReport.d.ts +0 -18
- package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
- package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
- package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
- package/dist/useCompiledDocument-BKyRnXmA.cjs.js +0 -141
- package/src/components/Notebook/cellKind.spec.ts +0 -199
- package/src/components/Notebook/cellKind.ts +0 -74
- package/src/components/Report/LinearReport.tsx +0 -71
- package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
- package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
- package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
- package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
- package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
- package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
- package/src/components/legacy/Notebook.served.spec.tsx +0 -183
- /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import type { ComponentProps } from "react";
|
|
6
|
-
import { AppDialog } from "../AppDialog";
|
|
4
|
+
import { useState, type ComponentProps, type ReactNode } from "react";
|
|
7
5
|
import { UnsavedChangesDialog } from "../UnsavedChangesDialog";
|
|
8
|
-
import { AddTileDialog } from "./AddTileDialog";
|
|
6
|
+
import { AddTileDialog, type ViewPreview } from "./AddTileDialog";
|
|
9
7
|
import type { PackageCatalog } from "./catalog";
|
|
8
|
+
import { duplicateBlocked } from "./addTileToDocument";
|
|
10
9
|
import { isQueryTile } from "./document";
|
|
11
10
|
import { DrillDialog } from "./DrillDialog";
|
|
12
11
|
import { FilterDialog } from "./FilterDialog";
|
|
13
12
|
import { TileMenu } from "./TileMenu";
|
|
14
|
-
import
|
|
13
|
+
import { tileDisplayTitle } from "./tileDisplayTitle";
|
|
15
14
|
import type { useControlBindings } from "./useControlBindings";
|
|
16
15
|
import type { ReportEditorHandle } from "./useReportEditor";
|
|
17
16
|
import type { useTileEditing } from "./useTileEditing";
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Every window the builder opens, each driven by state its hooks hold: the
|
|
21
|
-
* filter window, a tile's menu, the clickable-cells window, the
|
|
22
|
-
*
|
|
20
|
+
* filter window, a tile's menu, the clickable-cells window, the
|
|
21
|
+
* unsaved-changes guard and the add-tile picker.
|
|
23
22
|
*/
|
|
24
23
|
export function BuilderDialogs({
|
|
25
24
|
editor,
|
|
@@ -30,8 +29,9 @@ export function BuilderDialogs({
|
|
|
30
29
|
tiles,
|
|
31
30
|
drillSource,
|
|
32
31
|
setDrillSource,
|
|
33
|
-
confirmConversion,
|
|
34
32
|
exitDialog,
|
|
33
|
+
renderViewPreview,
|
|
34
|
+
takenGivenNames,
|
|
35
35
|
}: {
|
|
36
36
|
editor: ReportEditorHandle;
|
|
37
37
|
catalog: PackageCatalog | undefined;
|
|
@@ -42,11 +42,14 @@ export function BuilderDialogs({
|
|
|
42
42
|
/** The source whose clickable cells are being edited, if any. */
|
|
43
43
|
drillSource: string | undefined;
|
|
44
44
|
setDrillSource: (source: string | undefined) => void;
|
|
45
|
-
confirmConversion: ConversionConfirm | undefined;
|
|
46
45
|
exitDialog: ComponentProps<typeof UnsavedChangesDialog>;
|
|
46
|
+
renderViewPreview?: (view: ViewPreview) => ReactNode;
|
|
47
|
+
takenGivenNames?: readonly string[];
|
|
47
48
|
}) {
|
|
48
49
|
const { filterDialog, setFilterDialog } = bindings;
|
|
49
50
|
const { menu, setMenu } = tiles;
|
|
51
|
+
// The tile Clickable cells was opened from, for its window to name.
|
|
52
|
+
const [drillTile, setDrillTile] = useState<string | undefined>();
|
|
50
53
|
// The catalog's view behind the tile whose menu is open, for the charts the
|
|
51
54
|
// picker may offer: a reference tile's base view, else a view of the tile's own name.
|
|
52
55
|
const menuAt =
|
|
@@ -74,6 +77,7 @@ export function BuilderDialogs({
|
|
|
74
77
|
? { control: filterDialog.control }
|
|
75
78
|
: {})}
|
|
76
79
|
available={bindings.available}
|
|
80
|
+
{...(takenGivenNames ? { takenNames: takenGivenNames } : {})}
|
|
77
81
|
{...(catalog ? { fieldsFor: bindings.fieldsFor } : {})}
|
|
78
82
|
onClose={() => setFilterDialog(undefined)}
|
|
79
83
|
onApply={bindings.applyFilter}
|
|
@@ -94,19 +98,25 @@ export function BuilderDialogs({
|
|
|
94
98
|
draft.tiles[at] = next;
|
|
95
99
|
});
|
|
96
100
|
}}
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
view={menuView}
|
|
102
|
+
onDuplicate={() => {
|
|
103
|
+
if (menu) tiles.duplicate(menu.index);
|
|
99
104
|
}}
|
|
100
|
-
{...(
|
|
101
|
-
|
|
105
|
+
{...(menuTile && duplicateBlocked(menuTile) !== undefined
|
|
106
|
+
? { duplicateBlocked: duplicateBlocked(menuTile) }
|
|
107
|
+
: {})}
|
|
108
|
+
{...((editor.document.sources.find(
|
|
109
|
+
(s) => s.name === menuTile?.source,
|
|
110
|
+
)?.dimensions?.length ?? 0) > 0
|
|
102
111
|
? {
|
|
103
|
-
|
|
112
|
+
onDrills: () => {
|
|
113
|
+
setDrillTile(
|
|
114
|
+
menuTile ? tileDisplayTitle(menuTile) : undefined,
|
|
115
|
+
);
|
|
116
|
+
setDrillSource(menuTile?.source);
|
|
117
|
+
},
|
|
104
118
|
}
|
|
105
119
|
: {})}
|
|
106
|
-
view={menuView}
|
|
107
|
-
onDrills={() => {
|
|
108
|
-
setDrillSource(menuTile?.source);
|
|
109
|
-
}}
|
|
110
120
|
/>
|
|
111
121
|
<DrillDialog
|
|
112
122
|
open={drillSource !== undefined}
|
|
@@ -114,6 +124,7 @@ export function BuilderDialogs({
|
|
|
114
124
|
source={editor.document.sources.find((s) => s.name === drillSource)}
|
|
115
125
|
givenNames={bindings.controlList.map((c) => c.name)}
|
|
116
126
|
dashboards={dashboards ?? []}
|
|
127
|
+
{...(drillTile ? { tileLabel: drillTile } : {})}
|
|
117
128
|
onClose={() => setDrillSource(undefined)}
|
|
118
129
|
onApply={(drills) =>
|
|
119
130
|
editor.update((draft) => {
|
|
@@ -126,27 +137,6 @@ export function BuilderDialogs({
|
|
|
126
137
|
})
|
|
127
138
|
}
|
|
128
139
|
/>
|
|
129
|
-
<AppDialog
|
|
130
|
-
open={confirmConversion !== undefined}
|
|
131
|
-
onClose={() => confirmConversion?.stop()}
|
|
132
|
-
title="Convert this report?"
|
|
133
|
-
description="Saving rewrites this report in the tile layout. The builder cannot take that back; the file's history in your repository can."
|
|
134
|
-
actions={
|
|
135
|
-
<>
|
|
136
|
-
<Button onClick={() => confirmConversion?.stop()}>
|
|
137
|
-
Cancel
|
|
138
|
-
</Button>
|
|
139
|
-
<Button
|
|
140
|
-
variant="contained"
|
|
141
|
-
onClick={() => confirmConversion?.go()}
|
|
142
|
-
>
|
|
143
|
-
Convert and save
|
|
144
|
-
</Button>
|
|
145
|
-
</>
|
|
146
|
-
}
|
|
147
|
-
>
|
|
148
|
-
{null}
|
|
149
|
-
</AppDialog>
|
|
150
140
|
<UnsavedChangesDialog {...exitDialog} />
|
|
151
141
|
<AddTileDialog
|
|
152
142
|
open={tiles.addingTile}
|
|
@@ -156,6 +146,7 @@ export function BuilderDialogs({
|
|
|
156
146
|
onClose={tiles.closeAdd}
|
|
157
147
|
onAdd={tiles.addTile}
|
|
158
148
|
onAddText={tiles.addText}
|
|
149
|
+
{...(renderViewPreview ? { renderPreview: renderViewPreview } : {})}
|
|
159
150
|
/>
|
|
160
151
|
</>
|
|
161
152
|
);
|
|
@@ -5,12 +5,9 @@ import { DragDropProvider } from "@dnd-kit/react";
|
|
|
5
5
|
import AddIcon from "@mui/icons-material/Add";
|
|
6
6
|
import { Box, Button } from "@mui/material";
|
|
7
7
|
import type { ReactNode, RefObject } from "react";
|
|
8
|
-
import {
|
|
9
|
-
DashboardGrid,
|
|
10
|
-
GRID_GAP_PX,
|
|
11
|
-
NOTEBOOK_GAP_PX,
|
|
12
|
-
} from "../Dashboard/DashboardGrid";
|
|
8
|
+
import { DashboardGrid, GRID_GAP_PX } from "../Dashboard/DashboardGrid";
|
|
13
9
|
import type { TileChrome, TileHeadingSlots } from "../Dashboard/TileCard";
|
|
10
|
+
import type { LayoutRules } from "../Report/layoutRules";
|
|
14
11
|
import {
|
|
15
12
|
isQueryTile,
|
|
16
13
|
isTextTile,
|
|
@@ -38,15 +35,16 @@ export function BuilderGrid({
|
|
|
38
35
|
reorder,
|
|
39
36
|
resizing,
|
|
40
37
|
gridBox,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
chrome,
|
|
38
|
+
defaultSpan = 1,
|
|
39
|
+
rules,
|
|
44
40
|
canAdd,
|
|
45
41
|
selected,
|
|
46
42
|
flash,
|
|
47
43
|
menuIndex,
|
|
48
44
|
onSelect,
|
|
49
45
|
onOpenMenu,
|
|
46
|
+
onRemove,
|
|
47
|
+
removeBlocked,
|
|
50
48
|
openAdd,
|
|
51
49
|
editTile,
|
|
52
50
|
renderTile,
|
|
@@ -55,9 +53,10 @@ export function BuilderGrid({
|
|
|
55
53
|
reorder: ReturnType<typeof useTileReorder>;
|
|
56
54
|
resizing: ReturnType<typeof useTileResize>;
|
|
57
55
|
gridBox: RefObject<HTMLDivElement | null>;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
/** The span a tile with no `# colspan` is drawn at: as wide as the reader draws it. */
|
|
57
|
+
defaultSpan?: number;
|
|
58
|
+
/** How the document arranges tiles: columns, widths, inserting between. */
|
|
59
|
+
rules: LayoutRules;
|
|
61
60
|
/** Whether there is a catalog to add a tile from. */
|
|
62
61
|
canAdd: boolean;
|
|
63
62
|
selected: number | undefined;
|
|
@@ -66,6 +65,10 @@ export function BuilderGrid({
|
|
|
66
65
|
menuIndex: number | undefined;
|
|
67
66
|
onSelect: (index: number) => void;
|
|
68
67
|
onOpenMenu: (anchor: HTMLElement, index: number) => void;
|
|
68
|
+
/** Take a tile off the report. */
|
|
69
|
+
onRemove: (index: number) => void;
|
|
70
|
+
/** Why no tile can be removed now; set, each × says so instead. */
|
|
71
|
+
removeBlocked?: string;
|
|
69
72
|
openAdd: (at?: number) => void;
|
|
70
73
|
editTile: (key: string, change: (tile: DashboardTile) => void) => void;
|
|
71
74
|
renderTile?: (
|
|
@@ -75,21 +78,30 @@ export function BuilderGrid({
|
|
|
75
78
|
) => ReactNode;
|
|
76
79
|
}) {
|
|
77
80
|
const { dragging, preview, onDragStart, onDragOver, onDragEnd } = reorder;
|
|
81
|
+
const { columns } = rules;
|
|
78
82
|
const { resize, startResize, onResize, endResize } = resizing;
|
|
79
83
|
// What the grid lays out: the document, except mid-gesture, where it is
|
|
80
84
|
// the preview — the tile being resized at its previewed width, or the tiles
|
|
81
85
|
// in their previewed order. So the row reflows under the pointer exactly as
|
|
82
86
|
// it will once the edit lands.
|
|
83
|
-
const
|
|
87
|
+
const drawn = (tile: DashboardTile): DashboardTile =>
|
|
88
|
+
tile.colspan === undefined ? { ...tile, colspan: defaultSpan } : tile;
|
|
89
|
+
const shown = (
|
|
84
90
|
resize !== undefined
|
|
85
91
|
? editor.document.tiles.map((each, index) =>
|
|
86
92
|
index === resize.index ? { ...each, colspan: resize.span } : each,
|
|
87
93
|
)
|
|
88
|
-
: (preview ?? editor.document.tiles)
|
|
94
|
+
: (preview ?? editor.document.tiles)
|
|
95
|
+
).map(drawn);
|
|
89
96
|
// And, while a drag is live, the empty end of every row as a drop target.
|
|
90
|
-
//
|
|
97
|
+
// While an edge is dragged too: narrowing a tile frees columns its row-mate
|
|
98
|
+
// does not take, and an undrawn hole there read as a broken layout rather
|
|
99
|
+
// than room to fill. Not otherwise: a gap is only shown mid-gesture.
|
|
91
100
|
const empty = editor.document.tiles.length === 0;
|
|
92
|
-
const entries =
|
|
101
|
+
const entries =
|
|
102
|
+
dragging || resize !== undefined
|
|
103
|
+
? withGaps(shown, columns)
|
|
104
|
+
: shown.map(tileEntry);
|
|
93
105
|
const heading = (tile: QueryTile) =>
|
|
94
106
|
headingOf(tile, tileDisplayTitle(tile), editTile);
|
|
95
107
|
return (
|
|
@@ -101,14 +113,14 @@ export function BuilderGrid({
|
|
|
101
113
|
onDragEnd={onDragEnd}
|
|
102
114
|
>
|
|
103
115
|
<Box ref={gridBox} sx={{ position: "relative" }}>
|
|
104
|
-
{
|
|
116
|
+
{rules.widths && (dragging || resize !== undefined) && (
|
|
105
117
|
<GridGuides columns={columns} />
|
|
106
118
|
)}
|
|
107
119
|
|
|
108
120
|
<DashboardGrid
|
|
109
121
|
tiles={entries}
|
|
110
122
|
columns={columns}
|
|
111
|
-
rowGapPx={
|
|
123
|
+
rowGapPx={GRID_GAP_PX}
|
|
112
124
|
keyOf={(entry) =>
|
|
113
125
|
entry.kind === "gap"
|
|
114
126
|
? gapId(entry.after)
|
|
@@ -125,13 +137,19 @@ export function BuilderGrid({
|
|
|
125
137
|
selected={index === selected}
|
|
126
138
|
flash={tileKey(each) === flash}
|
|
127
139
|
menuOpen={menuIndex === index}
|
|
128
|
-
|
|
129
|
-
{
|
|
140
|
+
// Prose has no card, in either layout.
|
|
141
|
+
bare={isTextTile(each)}
|
|
142
|
+
// Not on the last tile: the "Add tile" under the
|
|
143
|
+
// list adds there already, and the two drew on top
|
|
144
|
+
// of each other.
|
|
145
|
+
{...(rules.insertBetween &&
|
|
146
|
+
canAdd &&
|
|
147
|
+
index < editor.document.tiles.length - 1
|
|
130
148
|
? {
|
|
131
149
|
onInsertAfter: () => openAdd(index + 1),
|
|
132
150
|
}
|
|
133
151
|
: {})}
|
|
134
|
-
{...(
|
|
152
|
+
{...(rules.widths && resizable(each)
|
|
135
153
|
? {
|
|
136
154
|
resizing: resize?.index === index,
|
|
137
155
|
width: {
|
|
@@ -153,11 +171,12 @@ export function BuilderGrid({
|
|
|
153
171
|
: {})}
|
|
154
172
|
onSelect={() => onSelect(index)}
|
|
155
173
|
onOpenMenu={(anchor) => onOpenMenu(anchor, index)}
|
|
174
|
+
onRemove={() => onRemove(index)}
|
|
175
|
+
{...(removeBlocked ? { removeBlocked } : {})}
|
|
156
176
|
>
|
|
157
177
|
{isTextTile(each) ? (
|
|
158
178
|
<TextTileBody
|
|
159
179
|
tile={each}
|
|
160
|
-
chrome={chrome}
|
|
161
180
|
onChange={(markdown) =>
|
|
162
181
|
editTile(tileKey(each), (tile) => {
|
|
163
182
|
if (isTextTile(tile))
|
|
@@ -165,19 +184,12 @@ export function BuilderGrid({
|
|
|
165
184
|
})
|
|
166
185
|
}
|
|
167
186
|
/>
|
|
168
|
-
) : renderTile
|
|
169
|
-
|
|
170
|
-
renderTile(each, heading(each), chrome)
|
|
187
|
+
) : renderTile ? (
|
|
188
|
+
renderTile(each, heading(each), "card")
|
|
171
189
|
) : (
|
|
172
190
|
<TilePlaceholder
|
|
173
191
|
tile={each}
|
|
174
|
-
chrome={chrome}
|
|
175
192
|
heading={heading(each)}
|
|
176
|
-
{...(editor.pendingOpen
|
|
177
|
-
? {
|
|
178
|
-
note: "Preview appears after you Save",
|
|
179
|
-
}
|
|
180
|
-
: {})}
|
|
181
193
|
/>
|
|
182
194
|
)}
|
|
183
195
|
</TileFrame>
|
|
@@ -186,7 +198,7 @@ export function BuilderGrid({
|
|
|
186
198
|
/>
|
|
187
199
|
</Box>
|
|
188
200
|
</DragDropProvider>
|
|
189
|
-
{
|
|
201
|
+
{rules.insertBetween && canAdd && !empty && (
|
|
190
202
|
<Button
|
|
191
203
|
size="small"
|
|
192
204
|
startIcon={<AddIcon />}
|
|
@@ -1,106 +1,94 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { Box
|
|
4
|
+
import { Box } from "@mui/material";
|
|
5
5
|
import type { ReactNode } from "react";
|
|
6
|
-
import { BARE_DESCRIPTION_MARGIN_PX } from "../Dashboard/DashboardGrid";
|
|
7
|
-
import { TileCard, type TileChrome } from "../Dashboard/TileCard";
|
|
8
6
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
7
|
+
import { ReportHeader, TextTileFrame } from "../Report/ReportPage";
|
|
9
8
|
import { InlineMarkdown } from "./InlineMarkdown";
|
|
10
9
|
import { InlineText } from "./InlineText";
|
|
11
10
|
import { selectionSx } from "./TileFrame";
|
|
12
11
|
import type { ReportEditorHandle } from "./useReportEditor";
|
|
13
12
|
|
|
13
|
+
/** How far the description's selection ring stands off its text. */
|
|
14
|
+
const DESCRIPTION_RING_OFFSET_PX = 12;
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
|
-
* The
|
|
16
|
-
*
|
|
17
|
+
* The reader's {@link ReportHeader}, with its title and description edited
|
|
18
|
+
* where they stand and the builder's actions on the title's line: the same
|
|
19
|
+
* header in the same place, so editing a page does not move it.
|
|
17
20
|
*/
|
|
18
21
|
export function BuilderHeader({
|
|
19
22
|
editor,
|
|
20
23
|
documentSlug,
|
|
21
|
-
chrome,
|
|
22
24
|
actions,
|
|
23
25
|
descriptionSelected,
|
|
24
26
|
selectDescription,
|
|
25
27
|
}: {
|
|
26
28
|
editor: ReportEditorHandle;
|
|
27
|
-
/** Kept for callers; the title reads the same in either layout. */
|
|
28
|
-
notebook?: boolean;
|
|
29
29
|
/** The name a reader's view titles an untitled document with. */
|
|
30
30
|
documentSlug: string | undefined;
|
|
31
|
-
chrome: TileChrome;
|
|
32
31
|
actions: ReactNode;
|
|
33
32
|
descriptionSelected: boolean;
|
|
34
33
|
selectDescription: () => void;
|
|
35
34
|
}) {
|
|
36
35
|
const { theme } = usePublisherTheme();
|
|
37
36
|
return (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
on a dashboard, bare on a notebook, as the reader draws it —
|
|
65
|
-
lifting on hover and selected as a tile is: one selection on the
|
|
66
|
-
page, tile or description. */}
|
|
67
|
-
<Box
|
|
68
|
-
role="group"
|
|
69
|
-
aria-label="Description"
|
|
70
|
-
aria-current={descriptionSelected}
|
|
71
|
-
onPointerDown={selectDescription}
|
|
72
|
-
onFocus={selectDescription}
|
|
73
|
-
sx={
|
|
74
|
-
chrome === "none"
|
|
75
|
-
? { my: `${BARE_DESCRIPTION_MARGIN_PX}px` }
|
|
76
|
-
: undefined
|
|
77
|
-
}
|
|
78
|
-
>
|
|
79
|
-
<TileCard
|
|
80
|
-
chrome={chrome}
|
|
81
|
-
kind="text"
|
|
82
|
-
sx={{
|
|
83
|
-
// Anchors the ring a bare description draws around itself.
|
|
84
|
-
position: "relative",
|
|
85
|
-
overflow: "visible",
|
|
86
|
-
...selectionSx(theme, {
|
|
87
|
-
selected: descriptionSelected,
|
|
88
|
-
bare: chrome === "none",
|
|
89
|
-
}),
|
|
90
|
-
}}
|
|
37
|
+
<ReportHeader
|
|
38
|
+
actions={actions}
|
|
39
|
+
title={
|
|
40
|
+
<InlineText
|
|
41
|
+
value={editor.document.title}
|
|
42
|
+
placeholder={
|
|
43
|
+
// What a reader's view falls back to: the file's own name.
|
|
44
|
+
documentSlug ?? "Untitled report"
|
|
45
|
+
}
|
|
46
|
+
ariaLabel="Report title"
|
|
47
|
+
onCommit={(next) =>
|
|
48
|
+
editor.update((draft) => {
|
|
49
|
+
draft.title = next;
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
53
|
+
}
|
|
54
|
+
description={
|
|
55
|
+
// Selected as a tile is: one selection on the page, tile or
|
|
56
|
+
// description.
|
|
57
|
+
<Box
|
|
58
|
+
role="group"
|
|
59
|
+
aria-label="Description"
|
|
60
|
+
aria-current={descriptionSelected}
|
|
61
|
+
onPointerDown={selectDescription}
|
|
62
|
+
onFocus={selectDescription}
|
|
91
63
|
>
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
64
|
+
<TextTileFrame
|
|
65
|
+
sx={{
|
|
66
|
+
// Anchors the ring the bare description draws around itself.
|
|
67
|
+
position: "relative",
|
|
68
|
+
overflow: "visible",
|
|
69
|
+
// Wider than a grid tile's ring: the description is not in
|
|
70
|
+
// the grid, so its ring is not held inside a gutter, and
|
|
71
|
+
// a paragraph needs more room round it than a tile's prose.
|
|
72
|
+
...selectionSx(theme, {
|
|
73
|
+
selected: descriptionSelected,
|
|
74
|
+
bare: true,
|
|
75
|
+
ringOffset: DESCRIPTION_RING_OFFSET_PX,
|
|
76
|
+
}),
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<InlineMarkdown
|
|
80
|
+
markdown={editor.document.description ?? ""}
|
|
81
|
+
placeholder="Add a description"
|
|
82
|
+
onCommit={(next) =>
|
|
83
|
+
editor.update((draft) => {
|
|
84
|
+
if (next.trim() === "") delete draft.description;
|
|
85
|
+
else draft.description = next;
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
/>
|
|
89
|
+
</TextTileFrame>
|
|
90
|
+
</Box>
|
|
91
|
+
}
|
|
92
|
+
/>
|
|
105
93
|
);
|
|
106
94
|
}
|
|
@@ -19,6 +19,86 @@ import type { ReactNode, Ref } from "react";
|
|
|
19
19
|
import type { SavesTo } from "./documentSession";
|
|
20
20
|
import { SecondaryButton } from "../buttons";
|
|
21
21
|
import { MOD } from "./useBuilderShortcuts";
|
|
22
|
+
import { edgeColor, hoverEdgeColor } from "../controlTokens";
|
|
23
|
+
import { DEFAULT_UI, type ReportUi } from "../../theme/ui";
|
|
24
|
+
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The toolbar's controls at the report surfaces' one size, set here rather
|
|
28
|
+
* than left to the host theme: the row was five shapes (a 29px square toggle,
|
|
29
|
+
* a text link, round 37px icons, a 37px pill), because each control took a
|
|
30
|
+
* different library default.
|
|
31
|
+
*/
|
|
32
|
+
export const controlSx = (
|
|
33
|
+
edge: string,
|
|
34
|
+
hoverEdge: string,
|
|
35
|
+
ui: ReportUi = DEFAULT_UI,
|
|
36
|
+
) =>
|
|
37
|
+
({
|
|
38
|
+
height: ui.size.control,
|
|
39
|
+
minHeight: ui.size.control,
|
|
40
|
+
px: 1.5,
|
|
41
|
+
borderRadius: ui.radius.control,
|
|
42
|
+
boxShadow: "none",
|
|
43
|
+
...ui.type.control,
|
|
44
|
+
"&:hover": { boxShadow: "none" },
|
|
45
|
+
"& .MuiButton-startIcon": { mr: 0.5, "& svg": { fontSize: 18 } },
|
|
46
|
+
// Outlined in the report's one edge, as the segmented control, the
|
|
47
|
+
// filter buttons and the tiles are, rather than the host's button grey.
|
|
48
|
+
"&.MuiButton-outlined": {
|
|
49
|
+
borderColor: edge,
|
|
50
|
+
"&:hover": { borderColor: hoverEdge },
|
|
51
|
+
},
|
|
52
|
+
}) as const;
|
|
53
|
+
|
|
54
|
+
export const iconControlSx = (ui: ReportUi = DEFAULT_UI) =>
|
|
55
|
+
({
|
|
56
|
+
width: ui.size.control,
|
|
57
|
+
height: ui.size.control,
|
|
58
|
+
borderRadius: ui.radius.control,
|
|
59
|
+
"& svg": { fontSize: 18 },
|
|
60
|
+
}) as const;
|
|
61
|
+
|
|
62
|
+
/** Short rules between groups: the height of a label, not of the row. */
|
|
63
|
+
export const dividerSx = {
|
|
64
|
+
height: 20,
|
|
65
|
+
alignSelf: "center",
|
|
66
|
+
mx: 0.5,
|
|
67
|
+
my: 0,
|
|
68
|
+
} as const;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A segmented control, built as an outlined button group: the same edge,
|
|
72
|
+
* height, radius and padding as "+ Tile" beside it, each segment the full
|
|
73
|
+
* height of the control with a rule between them, and the chosen one tinted
|
|
74
|
+
* edge to edge. An inset chip inside the outline read as a control within a
|
|
75
|
+
* control, a size smaller than the button next to it.
|
|
76
|
+
*/
|
|
77
|
+
export const segmentedSx = (edge: string, ui: ReportUi = DEFAULT_UI) =>
|
|
78
|
+
({
|
|
79
|
+
height: ui.size.control,
|
|
80
|
+
boxSizing: "border-box",
|
|
81
|
+
borderRadius: ui.radius.control,
|
|
82
|
+
border: `1px solid ${edge}`,
|
|
83
|
+
overflow: "hidden",
|
|
84
|
+
bgcolor: "background.paper",
|
|
85
|
+
"& .MuiToggleButton-root": {
|
|
86
|
+
border: "none",
|
|
87
|
+
borderRadius: "0 !important",
|
|
88
|
+
m: "0 !important",
|
|
89
|
+
px: 1.5,
|
|
90
|
+
py: 0,
|
|
91
|
+
height: "100%",
|
|
92
|
+
...ui.type.control,
|
|
93
|
+
color: "text.secondary",
|
|
94
|
+
"& + .MuiToggleButton-root": { borderLeft: `1px solid ${edge}` },
|
|
95
|
+
"&:hover": { bgcolor: "action.hover" },
|
|
96
|
+
"&.Mui-selected, &.Mui-selected:hover": {
|
|
97
|
+
bgcolor: "action.selected",
|
|
98
|
+
color: "text.primary",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
}) as const;
|
|
22
102
|
|
|
23
103
|
/** Where Save puts the document, in the words under the button. */
|
|
24
104
|
export const SAVE_TARGET: Record<SavesTo, string> = {
|
|
@@ -83,6 +163,9 @@ export function BuilderToolbar({
|
|
|
83
163
|
layout,
|
|
84
164
|
onLayoutChange,
|
|
85
165
|
}: BuilderToolbarProps) {
|
|
166
|
+
const { theme } = usePublisherTheme();
|
|
167
|
+
const edge = edgeColor(theme.cardBorder);
|
|
168
|
+
const hoverEdge = hoverEdgeColor(theme.cardBorder, theme.tileTitle);
|
|
86
169
|
return (
|
|
87
170
|
<Stack
|
|
88
171
|
direction="row"
|
|
@@ -108,7 +191,7 @@ export function BuilderToolbar({
|
|
|
108
191
|
onChange={(_event, next: "grid" | "linear" | null) => {
|
|
109
192
|
if (next && next !== layout) onLayoutChange(next);
|
|
110
193
|
}}
|
|
111
|
-
sx={
|
|
194
|
+
sx={segmentedSx(edge, theme.ui)}
|
|
112
195
|
>
|
|
113
196
|
<ToggleButton value="linear" aria-label="Linear layout">
|
|
114
197
|
Linear
|
|
@@ -118,24 +201,24 @@ export function BuilderToolbar({
|
|
|
118
201
|
</ToggleButton>
|
|
119
202
|
</ToggleButtonGroup>
|
|
120
203
|
</Tooltip>
|
|
121
|
-
<Divider orientation="vertical"
|
|
204
|
+
<Divider orientation="vertical" sx={dividerSx} />
|
|
122
205
|
</>
|
|
123
206
|
)}
|
|
124
207
|
{/* What the page is made of. */}
|
|
125
208
|
{onAddTile && (
|
|
126
209
|
<Button
|
|
210
|
+
variant="outlined"
|
|
127
211
|
startIcon={<AddIcon />}
|
|
128
212
|
onClick={onAddTile}
|
|
129
213
|
aria-label="Add tile"
|
|
214
|
+
sx={controlSx(edge, hoverEdge, theme.ui)}
|
|
130
215
|
>
|
|
131
216
|
Tile
|
|
132
217
|
</Button>
|
|
133
218
|
)}
|
|
134
219
|
|
|
135
220
|
{/* What happens to a change: take it back, or put it down. */}
|
|
136
|
-
{onAddTile &&
|
|
137
|
-
<Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
|
|
138
|
-
)}
|
|
221
|
+
{onAddTile && <Divider orientation="vertical" sx={dividerSx} />}
|
|
139
222
|
<Tooltip title={`Undo (${MOD}Z)`}>
|
|
140
223
|
{/* A span, because a disabled button dispatches no events and a
|
|
141
224
|
tooltip on one would never show. */}
|
|
@@ -144,7 +227,7 @@ export function BuilderToolbar({
|
|
|
144
227
|
aria-label="Undo"
|
|
145
228
|
disabled={!canUndo}
|
|
146
229
|
onClick={onUndo}
|
|
147
|
-
sx={
|
|
230
|
+
sx={iconControlSx(theme.ui)}
|
|
148
231
|
>
|
|
149
232
|
<UndoIcon fontSize="small" />
|
|
150
233
|
</IconButton>
|
|
@@ -156,7 +239,7 @@ export function BuilderToolbar({
|
|
|
156
239
|
aria-label="Redo"
|
|
157
240
|
disabled={!canRedo}
|
|
158
241
|
onClick={onRedo}
|
|
159
|
-
sx={
|
|
242
|
+
sx={iconControlSx(theme.ui)}
|
|
160
243
|
>
|
|
161
244
|
<RedoIcon fontSize="small" />
|
|
162
245
|
</IconButton>
|
|
@@ -165,7 +248,7 @@ export function BuilderToolbar({
|
|
|
165
248
|
{/* The host's own actions, then Save, which keeps the builder open,
|
|
166
249
|
then Close only when the host opted into it with `onExit`. */}
|
|
167
250
|
{(actions || onSave || onExit) && (
|
|
168
|
-
<Divider orientation="vertical"
|
|
251
|
+
<Divider orientation="vertical" sx={dividerSx} />
|
|
169
252
|
)}
|
|
170
253
|
{actions}
|
|
171
254
|
{onSave ? (
|
|
@@ -184,7 +267,10 @@ export function BuilderToolbar({
|
|
|
184
267
|
onClick={onSave}
|
|
185
268
|
// Wide enough for the longest of the three labels, so
|
|
186
269
|
// the row does not reflow as the state cycles.
|
|
187
|
-
sx={{
|
|
270
|
+
sx={{
|
|
271
|
+
...controlSx(edge, hoverEdge, theme.ui),
|
|
272
|
+
minWidth: 88,
|
|
273
|
+
}}
|
|
188
274
|
>
|
|
189
275
|
{saving ? "Saving…" : dirty ? "Save" : "Saved"}
|
|
190
276
|
</Button>
|