@malloy-publisher/sdk 0.9.2 → 0.9.4
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-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
- package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
- package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +112 -115
- package/dist/builder/index.es.js +11766 -11502
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +170 -9
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +93 -89
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/DashboardGrid.d.ts +18 -3
- package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
- package/dist/components/Dashboard/DashboardView.d.ts +38 -3
- package/dist/components/Dashboard/TileCard.d.ts +16 -2
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +3 -2
- package/dist/components/Dashboard/telemetry.d.ts +2 -1
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +14 -17
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
- package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
- package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
- package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
- package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +4 -7
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +32 -0
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/Package.d.ts +16 -1
- package/dist/components/Package/index.d.ts +1 -1
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +9760 -10363
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
- package/dist/text-entry.d.ts +1 -1
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/package.json +11 -11
- package/src/builder-entry.ts +1 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +2 -2
- package/src/components/Dashboard/DashboardGrid.tsx +23 -5
- package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
- package/src/components/Dashboard/DashboardTile.tsx +95 -31
- package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
- package/src/components/Dashboard/DashboardView.tsx +165 -89
- package/src/components/Dashboard/RowsDialog.tsx +3 -2
- package/src/components/Dashboard/TileCard.tsx +17 -2
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +11 -2
- package/src/components/Dashboard/telemetry.ts +2 -1
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +86 -113
- package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
- package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
- package/src/components/DashboardBuilder/InlineText.tsx +23 -17
- package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
- package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
- package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
- package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
- package/src/components/DashboardBuilder/catalog.ts +0 -36
- package/src/components/DashboardBuilder/controls.spec.ts +1 -1
- package/src/components/DashboardBuilder/controls.ts +1 -1
- package/src/components/DashboardBuilder/documentSession.ts +3 -2
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1 -1
- package/src/components/DashboardBuilder/malloyTree.ts +5 -1
- package/src/components/DashboardBuilder/newDashboard.ts +1 -1
- package/src/components/DashboardBuilder/preview.ts +1 -1
- package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
- package/src/components/DashboardBuilder/readDocument.ts +10 -4
- package/src/components/DashboardBuilder/readForEditor.ts +7 -2
- package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
- package/src/components/DashboardBuilder/sortable.tsx +11 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/inline.ts +1 -1
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +43 -1
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
- package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +146 -0
- package/src/components/DashboardBuilder/useTileResize.ts +133 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/guards.ts +1 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +6 -2
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/Package.artifacts.spec.tsx +8 -12
- package/src/components/Package/Package.create.spec.tsx +22 -1
- package/src/components/Package/Package.tsx +51 -27
- package/src/components/Package/index.ts +1 -1
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +5 -7
- package/src/components/RenderedResult/ResultContainer.tsx +7 -2
- package/src/components/RenderedResult/ResultPanel.tsx +20 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.tsx +2 -8
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +1 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +7 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/text-entry.ts +1 -1
- package/src/textEntry.spec.ts +2 -8
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/queryClient.ts +8 -0
- package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
- package/dist/ServerProvider-HRqT3w1C.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -7
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
- package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
|
@@ -2,25 +2,20 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import AddIcon from "@mui/icons-material/Add";
|
|
5
|
-
import TuneIcon from "@mui/icons-material/Tune";
|
|
6
5
|
import CheckIcon from "@mui/icons-material/Check";
|
|
7
|
-
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
|
|
8
6
|
import RedoIcon from "@mui/icons-material/Redo";
|
|
9
7
|
import UndoIcon from "@mui/icons-material/Undo";
|
|
10
8
|
import {
|
|
11
9
|
Box,
|
|
12
10
|
Button,
|
|
13
|
-
Chip,
|
|
14
11
|
Divider,
|
|
15
12
|
IconButton,
|
|
13
|
+
Stack,
|
|
16
14
|
Tooltip,
|
|
17
|
-
Typography,
|
|
18
15
|
} from "@mui/material";
|
|
19
16
|
import type { ReactNode, Ref } from "react";
|
|
20
|
-
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
21
|
-
import { SecondaryButton } from "../buttons";
|
|
22
|
-
import { DashboardBar } from "../Dashboard/DashboardBar";
|
|
23
17
|
import type { SavesTo } from "./documentSession";
|
|
18
|
+
import { SecondaryButton } from "../buttons";
|
|
24
19
|
import { MOD } from "./useBuilderShortcuts";
|
|
25
20
|
|
|
26
21
|
/** Where Save puts the document, in the words under the button. */
|
|
@@ -31,17 +26,13 @@ export const SAVE_TARGET: Record<SavesTo, string> = {
|
|
|
31
26
|
};
|
|
32
27
|
|
|
33
28
|
/**
|
|
34
|
-
* The
|
|
35
|
-
*
|
|
36
|
-
* the reader's view uses, so switching modes swaps the contents of one bar
|
|
37
|
-
* rather than replacing one bar with a different one.
|
|
29
|
+
* The builder's actions, as one row with no bar of its own, at the right of
|
|
30
|
+
* the page title's line.
|
|
38
31
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* reader's own header (title and description) stays in the page below it
|
|
44
|
-
* rather than being repeated here.
|
|
32
|
+
* Grouped by what they do, separated rather than run together: change the page
|
|
33
|
+
* (a tile), take a change back (undo, redo), and keep it (Save,
|
|
34
|
+
* which saves in place: the builder stays open, and leaving is the page's
|
|
35
|
+
* own navigation).
|
|
45
36
|
*/
|
|
46
37
|
export interface BuilderToolbarProps {
|
|
47
38
|
canUndo: boolean;
|
|
@@ -52,20 +43,21 @@ export interface BuilderToolbarProps {
|
|
|
52
43
|
saving: boolean;
|
|
53
44
|
/** Absent when the builder has nowhere to save: no Save, no unsaved marker. */
|
|
54
45
|
onSave?: () => void;
|
|
55
|
-
/** Where Save writes, shown
|
|
46
|
+
/** Where Save writes, shown in its tooltip. */
|
|
56
47
|
savesTo?: SavesTo;
|
|
57
48
|
/** The backend's own words for where Save writes; replaces the generic line for `savesTo`. */
|
|
58
49
|
saveLabel?: string;
|
|
59
50
|
/** The Save button, so focus can return to it after an Undo save. */
|
|
60
51
|
saveButton?: Ref<HTMLButtonElement>;
|
|
61
|
-
/** The host's own extra actions, beside
|
|
52
|
+
/** The host's own extra actions, beside Save. */
|
|
62
53
|
actions?: ReactNode;
|
|
63
|
-
/** Leave editing: draws "Close" at the right edge. Absent, no such button. */
|
|
64
|
-
onExit?: () => void;
|
|
65
54
|
/** Open the add-tile picker. Absent when the host passed no catalog to pick from. */
|
|
66
55
|
onAddTile?: () => void;
|
|
67
|
-
/**
|
|
68
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Leave the builder: draws Close after Save, for a host that opts in. The
|
|
58
|
+
* Console leaves from its own header and passes nothing.
|
|
59
|
+
*/
|
|
60
|
+
onExit?: () => void;
|
|
69
61
|
}
|
|
70
62
|
|
|
71
63
|
export function BuilderToolbar({
|
|
@@ -80,37 +72,21 @@ export function BuilderToolbar({
|
|
|
80
72
|
saveLabel,
|
|
81
73
|
saveButton,
|
|
82
74
|
actions,
|
|
83
|
-
onExit,
|
|
84
75
|
onAddTile,
|
|
85
|
-
|
|
76
|
+
onExit,
|
|
86
77
|
}: BuilderToolbarProps) {
|
|
87
|
-
const { theme } = usePublisherTheme();
|
|
88
78
|
return (
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
sx={{
|
|
101
|
-
height: 37,
|
|
102
|
-
fontSize: "0.875rem",
|
|
103
|
-
fontWeight: 500,
|
|
104
|
-
// The app's own chip: the page's edge and its secondary
|
|
105
|
-
// text, not a filled blue badge borrowed from the drill
|
|
106
|
-
// link, which read as a notification rather than a state.
|
|
107
|
-
border: theme.border,
|
|
108
|
-
color: theme.tileTitle,
|
|
109
|
-
"& .MuiChip-icon": { color: "inherit" },
|
|
110
|
-
"& .MuiChip-label": { fontSize: "0.875rem" },
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
}
|
|
79
|
+
<Stack
|
|
80
|
+
direction="row"
|
|
81
|
+
aria-label="Builder actions"
|
|
82
|
+
sx={{
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
gap: 0.5,
|
|
85
|
+
// A button's label never wraps onto a second line; the filter
|
|
86
|
+
// chips beside the row give way first.
|
|
87
|
+
flexShrink: 0,
|
|
88
|
+
"& .MuiButton-root": { whiteSpace: "nowrap" },
|
|
89
|
+
}}
|
|
114
90
|
>
|
|
115
91
|
{/* What the page is made of. */}
|
|
116
92
|
{onAddTile && (
|
|
@@ -122,17 +98,11 @@ export function BuilderToolbar({
|
|
|
122
98
|
Tile
|
|
123
99
|
</Button>
|
|
124
100
|
)}
|
|
125
|
-
{onSettings && (
|
|
126
|
-
<Button
|
|
127
|
-
startIcon={<TuneIcon />}
|
|
128
|
-
onClick={(event) => onSettings(event.currentTarget)}
|
|
129
|
-
>
|
|
130
|
-
Settings
|
|
131
|
-
</Button>
|
|
132
|
-
)}
|
|
133
101
|
|
|
134
102
|
{/* What happens to a change: take it back, or put it down. */}
|
|
135
|
-
|
|
103
|
+
{onAddTile && (
|
|
104
|
+
<Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
|
|
105
|
+
)}
|
|
136
106
|
<Tooltip title={`Undo (${MOD}Z)`}>
|
|
137
107
|
{/* A span, because a disabled button dispatches no events and a
|
|
138
108
|
tooltip on one would never show. */}
|
|
@@ -159,61 +129,64 @@ export function BuilderToolbar({
|
|
|
159
129
|
</IconButton>
|
|
160
130
|
</span>
|
|
161
131
|
</Tooltip>
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
{saving
|
|
186
|
-
? "Saving…"
|
|
187
|
-
: dirty
|
|
188
|
-
? "Save changes"
|
|
189
|
-
: "Saved"}
|
|
190
|
-
</Button>
|
|
191
|
-
</span>
|
|
192
|
-
</Tooltip>
|
|
193
|
-
<Typography
|
|
194
|
-
variant="caption"
|
|
195
|
-
sx={{ fontSize: 11, lineHeight: 1.2, opacity: 0.7 }}
|
|
132
|
+
{/* The host's own actions, then Save, which keeps the builder open,
|
|
133
|
+
then Close only when the host opted into it with `onExit`. */}
|
|
134
|
+
{(actions || onSave || onExit) && (
|
|
135
|
+
<Divider orientation="vertical" flexItem sx={{ mx: 0.5 }} />
|
|
136
|
+
)}
|
|
137
|
+
{actions}
|
|
138
|
+
{onSave ? (
|
|
139
|
+
<Tooltip
|
|
140
|
+
title={
|
|
141
|
+
dirty
|
|
142
|
+
? `Save (${MOD}S) · ${saveLabel ?? SAVE_TARGET[savesTo]}`
|
|
143
|
+
: (saveLabel ?? SAVE_TARGET[savesTo])
|
|
144
|
+
}
|
|
145
|
+
>
|
|
146
|
+
<span>
|
|
147
|
+
<Button
|
|
148
|
+
ref={saveButton}
|
|
149
|
+
variant={dirty ? "contained" : "outlined"}
|
|
150
|
+
disabled={!dirty || saving}
|
|
151
|
+
onClick={onSave}
|
|
152
|
+
// Wide enough for the longest of the three labels, so
|
|
153
|
+
// the row does not reflow as the state cycles.
|
|
154
|
+
sx={{ minWidth: 124 }}
|
|
196
155
|
>
|
|
197
|
-
{
|
|
198
|
-
</
|
|
199
|
-
</
|
|
200
|
-
|
|
156
|
+
{saving ? "Saving…" : dirty ? "Save" : "Saved"}
|
|
157
|
+
</Button>
|
|
158
|
+
</span>
|
|
159
|
+
</Tooltip>
|
|
160
|
+
) : null}
|
|
161
|
+
{onSave && (
|
|
162
|
+
// The save state, said aloud: the button's face changes, which a
|
|
163
|
+
// screen reader does not announce on its own.
|
|
164
|
+
<Box
|
|
165
|
+
component="span"
|
|
166
|
+
aria-live="polite"
|
|
167
|
+
sx={{
|
|
168
|
+
position: "absolute",
|
|
169
|
+
width: "1px",
|
|
170
|
+
height: "1px",
|
|
171
|
+
overflow: "hidden",
|
|
172
|
+
clipPath: "inset(50%)",
|
|
173
|
+
whiteSpace: "nowrap",
|
|
174
|
+
}}
|
|
175
|
+
>
|
|
176
|
+
{saving
|
|
177
|
+
? "Saving"
|
|
178
|
+
: dirty
|
|
179
|
+
? "Unsaved changes"
|
|
180
|
+
: "All changes saved"}
|
|
181
|
+
</Box>
|
|
201
182
|
)}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
{onExit && (
|
|
209
|
-
<SecondaryButton
|
|
210
|
-
label="Close"
|
|
211
|
-
icon={<CheckIcon />}
|
|
212
|
-
onClick={onExit}
|
|
213
|
-
/>
|
|
214
|
-
)}
|
|
215
|
-
</>
|
|
183
|
+
{onExit && (
|
|
184
|
+
<SecondaryButton
|
|
185
|
+
label="Close"
|
|
186
|
+
icon={<CheckIcon />}
|
|
187
|
+
onClick={onExit}
|
|
188
|
+
/>
|
|
216
189
|
)}
|
|
217
|
-
</
|
|
190
|
+
</Stack>
|
|
218
191
|
);
|
|
219
192
|
}
|
|
@@ -88,6 +88,7 @@ export function ChartPicker({
|
|
|
88
88
|
disabledReason,
|
|
89
89
|
onOpen,
|
|
90
90
|
onChange,
|
|
91
|
+
variant = "standard",
|
|
91
92
|
}: {
|
|
92
93
|
state: ChartState;
|
|
93
94
|
/** The catalog's view this cell runs, when it is one the catalog knows. */
|
|
@@ -100,6 +101,8 @@ export function ChartPicker({
|
|
|
100
101
|
/** The choices are being looked at, which is when a host may fetch what it needs to offer more. */
|
|
101
102
|
onOpen?: () => void;
|
|
102
103
|
onChange: (next: ChartState) => void;
|
|
104
|
+
/** The field's look: underlined in a compact menu, outlined beside a dialog's other fields. */
|
|
105
|
+
variant?: "standard" | "outlined";
|
|
103
106
|
}) {
|
|
104
107
|
const choices = chartChoices(view, state, viewStatus);
|
|
105
108
|
const reasonId = useId();
|
|
@@ -107,7 +110,7 @@ export function ChartPicker({
|
|
|
107
110
|
<TextField
|
|
108
111
|
select
|
|
109
112
|
size="small"
|
|
110
|
-
variant=
|
|
113
|
+
variant={variant}
|
|
111
114
|
label="Viz type"
|
|
112
115
|
value={state}
|
|
113
116
|
disabled={disabledReason !== undefined}
|
|
@@ -92,7 +92,7 @@ describe("DashboardBuilder: charts", () => {
|
|
|
92
92
|
choose("a by_cat", "Line");
|
|
93
93
|
closeMenu();
|
|
94
94
|
fireEvent.click(
|
|
95
|
-
screen.getByRole("button", { name: "Save
|
|
95
|
+
screen.getByRole("button", { name: "Save", hidden: true }),
|
|
96
96
|
);
|
|
97
97
|
await waitFor(() => expect(written).toBeDefined());
|
|
98
98
|
expect(written).toContain(
|
|
@@ -110,7 +110,7 @@ describe("DashboardBuilder: charts", () => {
|
|
|
110
110
|
choose("a by_cat", "From the view");
|
|
111
111
|
closeMenu();
|
|
112
112
|
const save = screen.queryByRole("button", {
|
|
113
|
-
name: "Save
|
|
113
|
+
name: "Save",
|
|
114
114
|
hidden: true,
|
|
115
115
|
});
|
|
116
116
|
expect(save === null || (save as HTMLButtonElement).disabled).toBe(true);
|
|
@@ -133,9 +133,9 @@ describe("DashboardBuilder: charts", () => {
|
|
|
133
133
|
).toBe("true");
|
|
134
134
|
expect(screen.getByText(/is not one the builder models/)).toBeDefined();
|
|
135
135
|
closeMenu();
|
|
136
|
-
editInline("
|
|
136
|
+
editInline("By brand", "Tile title", "Brands");
|
|
137
137
|
fireEvent.click(
|
|
138
|
-
screen.getByRole("button", { name: "Save
|
|
138
|
+
screen.getByRole("button", { name: "Save", hidden: true }),
|
|
139
139
|
);
|
|
140
140
|
await waitFor(() => expect(written).toBeDefined());
|
|
141
141
|
expect(written).toContain(" # bar_chart { size=spark }\n");
|
|
@@ -180,7 +180,7 @@ describe("DashboardBuilder: charts", () => {
|
|
|
180
180
|
choose("new tile", "Big value");
|
|
181
181
|
fireEvent.click(screen.getByRole("button", { name: "Add tile" }));
|
|
182
182
|
fireEvent.click(
|
|
183
|
-
screen.getByRole("button", { name: "Save
|
|
183
|
+
screen.getByRole("button", { name: "Save", hidden: true }),
|
|
184
184
|
);
|
|
185
185
|
await waitFor(() => expect(written).toBeDefined());
|
|
186
186
|
expect(written).toContain(
|
|
@@ -28,9 +28,9 @@ source: a is scoped_orders extend {
|
|
|
28
28
|
|
|
29
29
|
const mount = async (
|
|
30
30
|
options: {
|
|
31
|
-
onExit?: () => void;
|
|
32
31
|
onSave?: (source: string) => Promise<void> | void;
|
|
33
32
|
onDirtyChange?: (dirty: boolean) => void;
|
|
33
|
+
onExit?: () => void;
|
|
34
34
|
} = {},
|
|
35
35
|
) => {
|
|
36
36
|
const document = await openDocument(SOURCE);
|
|
@@ -38,8 +38,8 @@ const mount = async (
|
|
|
38
38
|
<DashboardBuilder
|
|
39
39
|
source={SOURCE}
|
|
40
40
|
document={document}
|
|
41
|
-
{...(options.onExit ? { onExit: options.onExit } : {})}
|
|
42
41
|
{...(options.onSave ? { onSave: options.onSave } : {})}
|
|
42
|
+
{...(options.onExit ? { onExit: options.onExit } : {})}
|
|
43
43
|
{...(options.onDirtyChange
|
|
44
44
|
? { onDirtyChange: options.onDirtyChange }
|
|
45
45
|
: {})}
|
|
@@ -57,79 +57,35 @@ const retitle = () => {
|
|
|
57
57
|
const shortcut = (key: string) =>
|
|
58
58
|
fireEvent.keyDown(window, { key, ctrlKey: true, metaKey: true });
|
|
59
59
|
|
|
60
|
-
const dialogs = () => screen.getAllByRole("dialog", { hidden: true });
|
|
61
|
-
|
|
62
|
-
const settleTick = () => act(async () => {});
|
|
63
|
-
|
|
64
60
|
afterEach(cleanup);
|
|
65
61
|
|
|
66
62
|
describe("DashboardBuilder: leaving", () => {
|
|
67
|
-
it("
|
|
68
|
-
await mount();
|
|
69
|
-
expect(
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("exits at once when nothing is unsaved", async () => {
|
|
73
|
-
const onExit = mock(() => {});
|
|
74
|
-
await mount({ onExit });
|
|
75
|
-
fireEvent.click(button("Close"));
|
|
76
|
-
expect(onExit).toHaveBeenCalledTimes(1);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("asks first when there are edits, and Keep editing stays", async () => {
|
|
80
|
-
const onExit = mock(() => {});
|
|
81
|
-
await mount({ onExit, onSave: async () => {} });
|
|
82
|
-
retitle();
|
|
83
|
-
fireEvent.click(button("Close"));
|
|
84
|
-
expect(screen.getByRole("dialog")).toBeDefined();
|
|
85
|
-
fireEvent.click(button("Keep editing"));
|
|
86
|
-
expect(onExit).not.toHaveBeenCalled();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("Discard changes exits without saving", async () => {
|
|
90
|
-
const onExit = mock(() => {});
|
|
91
|
-
const onSave = mock(async () => {});
|
|
92
|
-
await mount({ onExit, onSave });
|
|
63
|
+
it("draws Save and no Close when it can save", async () => {
|
|
64
|
+
await mount({ onSave: async () => {} });
|
|
65
|
+
expect(button("Saved").hasAttribute("disabled")).toBe(true);
|
|
93
66
|
retitle();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
expect(onExit).toHaveBeenCalledTimes(1);
|
|
97
|
-
expect(onSave).not.toHaveBeenCalled();
|
|
67
|
+
expect(button("Save")).toBeDefined();
|
|
68
|
+
expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
|
|
98
69
|
});
|
|
99
70
|
|
|
100
|
-
it("Save and
|
|
101
|
-
const onExit = mock(() => {});
|
|
71
|
+
it("Save saves in place and stays in the builder", async () => {
|
|
102
72
|
const onSave = mock(async () => {});
|
|
103
|
-
await mount({
|
|
73
|
+
await mount({ onSave });
|
|
104
74
|
retitle();
|
|
105
|
-
fireEvent.click(button("
|
|
106
|
-
|
|
107
|
-
await waitFor(() => expect(onExit).toHaveBeenCalledTimes(1));
|
|
75
|
+
fireEvent.click(button("Save"));
|
|
76
|
+
await waitFor(() => expect(button("Saved")).toBeDefined());
|
|
108
77
|
expect(onSave).toHaveBeenCalledTimes(1);
|
|
109
78
|
});
|
|
110
79
|
|
|
111
80
|
it("stays open when the save fails", async () => {
|
|
112
|
-
const onExit = mock(() => {});
|
|
113
81
|
const onSave = mock(async () => {
|
|
114
82
|
throw new Error("nope");
|
|
115
83
|
});
|
|
116
|
-
await mount({
|
|
84
|
+
await mount({ onSave });
|
|
117
85
|
retitle();
|
|
118
|
-
fireEvent.click(button("
|
|
119
|
-
fireEvent.click(button("Save and exit"));
|
|
86
|
+
fireEvent.click(button("Save"));
|
|
120
87
|
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
121
88
|
await screen.findByText(/nope/);
|
|
122
|
-
expect(onExit).not.toHaveBeenCalled();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("offers no Save and exit when the builder cannot save", async () => {
|
|
126
|
-
await mount({ onExit: () => {} });
|
|
127
|
-
retitle();
|
|
128
|
-
fireEvent.click(button("Close"));
|
|
129
|
-
expect(
|
|
130
|
-
screen.queryByRole("button", { name: "Save and exit" }),
|
|
131
|
-
).toBeNull();
|
|
132
|
-
expect(button("Discard changes")).toBeDefined();
|
|
133
89
|
});
|
|
134
90
|
|
|
135
91
|
it("reports clean when it unmounts dirty", async () => {
|
|
@@ -144,48 +100,83 @@ describe("DashboardBuilder: leaving", () => {
|
|
|
144
100
|
|
|
145
101
|
const removeTile = () => {
|
|
146
102
|
fireEvent.click(screen.getByLabelText("Settings for By category"));
|
|
147
|
-
fireEvent.click(screen.getByRole("button", { name: "
|
|
103
|
+
fireEvent.click(screen.getByRole("button", { name: "Delete" }));
|
|
148
104
|
};
|
|
149
105
|
|
|
150
106
|
describe("DashboardBuilder: leaving with a structural edit", () => {
|
|
151
|
-
it("
|
|
107
|
+
it("Save writes a structural edit at once, once, and stays open", async () => {
|
|
152
108
|
const onSave = mock(async () => {});
|
|
153
|
-
await mount({
|
|
109
|
+
await mount({ onSave });
|
|
154
110
|
removeTile();
|
|
155
|
-
fireEvent.click(button("
|
|
156
|
-
|
|
157
|
-
shortcut("z");
|
|
158
|
-
await settleTick();
|
|
159
|
-
expect(dialogs()).toHaveLength(1);
|
|
160
|
-
expect(onSave).not.toHaveBeenCalled();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("Save and exit writes a structural edit at once, saving once and exiting once", async () => {
|
|
164
|
-
const onExit = mock(() => {});
|
|
165
|
-
const onSave = mock(async () => {});
|
|
166
|
-
await mount({ onExit, onSave });
|
|
167
|
-
removeTile();
|
|
168
|
-
fireEvent.click(button("Close"));
|
|
169
|
-
fireEvent.click(button("Save and exit"));
|
|
170
|
-
await waitFor(() => expect(onExit).toHaveBeenCalledTimes(1));
|
|
111
|
+
fireEvent.click(button("Save"));
|
|
112
|
+
await waitFor(() => expect(button("Saved")).toBeDefined());
|
|
171
113
|
expect(onSave).toHaveBeenCalledTimes(1);
|
|
172
114
|
});
|
|
173
115
|
|
|
174
|
-
it("
|
|
175
|
-
const onExit = mock(() => {});
|
|
116
|
+
it("holds the button through a save in flight, so a second press cannot write twice", async () => {
|
|
176
117
|
let finish = () => {};
|
|
177
118
|
const onSave = mock(
|
|
178
119
|
() => new Promise<void>((resolve) => (finish = resolve)),
|
|
179
120
|
);
|
|
180
|
-
await mount({
|
|
121
|
+
await mount({ onSave });
|
|
181
122
|
retitle();
|
|
182
|
-
|
|
123
|
+
shortcut("s");
|
|
183
124
|
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
125
|
+
expect(button("Saving…").hasAttribute("disabled")).toBe(true);
|
|
126
|
+
fireEvent.click(button("Saving…"));
|
|
127
|
+
await act(async () => finish());
|
|
128
|
+
await screen.findByRole("button", { name: "Saved" });
|
|
129
|
+
expect(onSave).toHaveBeenCalledTimes(1);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe("DashboardBuilder: a host's opt-in Close", () => {
|
|
134
|
+
it("draws no Close unless the host passes onExit", async () => {
|
|
135
|
+
await mount({ onSave: async () => {} });
|
|
136
|
+
expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("draws Close beside Save, and leaves at once when nothing is unsaved", async () => {
|
|
140
|
+
const onExit = mock(() => {});
|
|
141
|
+
await mount({ onSave: async () => {}, onExit });
|
|
142
|
+
expect(button("Saved")).toBeDefined();
|
|
184
143
|
fireEvent.click(button("Close"));
|
|
185
|
-
|
|
186
|
-
|
|
144
|
+
expect(onExit).toHaveBeenCalledTimes(1);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("asks first when there are edits, and Keep editing stays", async () => {
|
|
148
|
+
const onExit = mock(() => {});
|
|
149
|
+
await mount({ onSave: async () => {}, onExit });
|
|
150
|
+
retitle();
|
|
151
|
+
fireEvent.click(button("Close"));
|
|
152
|
+
fireEvent.click(
|
|
153
|
+
await screen.findByRole("button", { name: "Keep editing" }),
|
|
154
|
+
);
|
|
187
155
|
expect(onExit).not.toHaveBeenCalled();
|
|
188
|
-
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("Discard changes leaves without saving", async () => {
|
|
159
|
+
const onExit = mock(() => {});
|
|
160
|
+
const onSave = mock(async () => {});
|
|
161
|
+
await mount({ onSave, onExit });
|
|
162
|
+
retitle();
|
|
163
|
+
fireEvent.click(button("Close"));
|
|
164
|
+
fireEvent.click(
|
|
165
|
+
await screen.findByRole("button", { name: "Discard changes" }),
|
|
166
|
+
);
|
|
167
|
+
expect(onExit).toHaveBeenCalledTimes(1);
|
|
168
|
+
expect(onSave).not.toHaveBeenCalled();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("Save and exit saves, then leaves", async () => {
|
|
172
|
+
const onExit = mock(() => {});
|
|
173
|
+
const onSave = mock(async () => {});
|
|
174
|
+
await mount({ onSave, onExit });
|
|
175
|
+
retitle();
|
|
176
|
+
fireEvent.click(button("Close"));
|
|
177
|
+
fireEvent.click(
|
|
178
|
+
await screen.findByRole("button", { name: "Save and exit" }),
|
|
179
|
+
);
|
|
189
180
|
await waitFor(() => expect(onExit).toHaveBeenCalledTimes(1));
|
|
190
181
|
expect(onSave).toHaveBeenCalledTimes(1);
|
|
191
182
|
});
|