@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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloy-publisher/sdk",
|
|
3
3
|
"description": "Malloy Publisher SDK",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.11",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"build": "bun generate-api-types && bunx vite build",
|
|
76
76
|
"postbuild": "cp ../../node_modules/@malloydata/malloy-explorer/dist/malloy-explorer.css ./dist/malloy-explorer.css && echo '/* SDK Styles */\n@import \"./malloy-explorer.css\";' > ./dist/styles.css",
|
|
77
77
|
"test": "bun test",
|
|
78
|
-
"test:tz": "bun test ./src/components/given/GivenInput.spec.tsx ./src/components/given/paramCodec.spec.ts ./src/utils/malloyLiteral.spec.ts ./src/components/drill/resolveDrill.spec.ts ./src/components/ReportBuilder/preview.spec.ts ./src/components/Materializations/cron.spec.ts ./src/components/Materializations/utils.spec.ts",
|
|
78
|
+
"test:tz": "bun test ./src/components/given/GivenInput.spec.tsx ./src/components/given/filterSummary.spec.ts ./src/components/given/paramCodec.spec.ts ./src/utils/malloyLiteral.spec.ts ./src/components/drill/resolveDrill.spec.ts ./src/components/ReportBuilder/preview.spec.ts ./src/components/Materializations/cron.spec.ts ./src/components/Materializations/utils.spec.ts",
|
|
79
79
|
"lint": "bunx eslint ./src ./test --fix",
|
|
80
80
|
"format": "bunx prettier --write --parser typescript '**/*.{ts,tsx}'",
|
|
81
81
|
"analyze": "bunx vite-bundle-visualizer",
|
package/src/builder-entry.ts
CHANGED
|
@@ -22,6 +22,15 @@ if (typeof globalThis.process === "undefined") {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export { ReportBuilder } from "./components/ReportBuilder/ReportBuilder";
|
|
25
|
+
export type { FixedFilter } from "./components/ReportBuilder/FilterStrip";
|
|
26
|
+
export {
|
|
27
|
+
BuilderBar,
|
|
28
|
+
type BuilderBarProps,
|
|
29
|
+
} from "./components/ReportBuilder/BuilderBar";
|
|
30
|
+
export type {
|
|
31
|
+
BuilderControls,
|
|
32
|
+
BuilderControlsHandler,
|
|
33
|
+
} from "./components/ReportBuilder/builderControls";
|
|
25
34
|
export type {
|
|
26
35
|
BuilderGiven,
|
|
27
36
|
ReportBuilderProps,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { usePublisherTheme } from "../theme/ThemeContext";
|
|
4
5
|
import CloseIcon from "@mui/icons-material/Close";
|
|
5
6
|
import {
|
|
6
7
|
Dialog,
|
|
@@ -37,6 +38,8 @@ export function AppDialog({
|
|
|
37
38
|
maxWidth = "sm",
|
|
38
39
|
showClose = false,
|
|
39
40
|
actions,
|
|
41
|
+
initialFocus,
|
|
42
|
+
className,
|
|
40
43
|
children,
|
|
41
44
|
}: {
|
|
42
45
|
open: boolean;
|
|
@@ -50,9 +53,18 @@ export function AppDialog({
|
|
|
50
53
|
showClose?: boolean;
|
|
51
54
|
/** The buttons, in order. Cancel first, the thing it does last. */
|
|
52
55
|
actions?: React.ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* The control to start in. Focused once the window has opened: a child's
|
|
58
|
+
* own `autoFocus` loses to the focus trap, which takes focus to the
|
|
59
|
+
* window's container as it opens, after the child has mounted.
|
|
60
|
+
*/
|
|
61
|
+
initialFocus?: React.RefObject<HTMLElement | null>;
|
|
62
|
+
/** Classes on the window's root, for a host to style it by. */
|
|
63
|
+
className?: string;
|
|
53
64
|
children: React.ReactNode;
|
|
54
65
|
}) {
|
|
55
66
|
const titleId = useId();
|
|
67
|
+
const ui = usePublisherTheme().theme.ui;
|
|
56
68
|
return (
|
|
57
69
|
<Dialog
|
|
58
70
|
open={open}
|
|
@@ -60,6 +72,17 @@ export function AppDialog({
|
|
|
60
72
|
maxWidth={maxWidth}
|
|
61
73
|
fullWidth
|
|
62
74
|
aria-labelledby={titleId}
|
|
75
|
+
{...(className ? { className } : {})}
|
|
76
|
+
// The host's dialog radius (`ui.radius.dialog`), as every other
|
|
77
|
+
// corner on a report surface takes its token.
|
|
78
|
+
PaperProps={{ sx: { borderRadius: ui.radius.dialog } }}
|
|
79
|
+
{...(initialFocus
|
|
80
|
+
? {
|
|
81
|
+
TransitionProps: {
|
|
82
|
+
onEntered: () => initialFocus.current?.focus(),
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
: {})}
|
|
63
86
|
>
|
|
64
87
|
<DialogTitle
|
|
65
88
|
id={titleId}
|
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { Box } from "@mui/material";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
type RefObject,
|
|
11
|
+
} from "react";
|
|
6
12
|
|
|
7
13
|
/** Grid width when the dashboard declares no `# dashboard { columns=N }`. */
|
|
8
14
|
export const DEFAULT_COLUMNS = 2;
|
|
@@ -24,22 +30,10 @@ export const nudgedSpan = (current: number, delta: 1 | -1, columns: number) =>
|
|
|
24
30
|
export const GRID_GAP_PX = 16;
|
|
25
31
|
|
|
26
32
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* so the builder's selection ring, drawn {@link BARE_RING_OFFSET_PX} clear of
|
|
30
|
-
* a bare tile, never meets the next tile's.
|
|
33
|
+
* How far a bare (uncarded) tile's selection ring sits from its prose: half the
|
|
34
|
+
* {@link GRID_GAP_PX} between tiles, so a ring never reaches into the next tile.
|
|
31
35
|
*/
|
|
32
|
-
export const
|
|
33
|
-
|
|
34
|
-
/** How far a bare (uncarded) tile's selection ring sits from its content. */
|
|
35
|
-
export const BARE_RING_OFFSET_PX = 12;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The space above and below a notebook's description, in both modes: a bare
|
|
39
|
-
* description's ring in the builder is {@link BARE_RING_OFFSET_PX} clear of
|
|
40
|
-
* its text, and needs the room to stay clear of the title and the filters.
|
|
41
|
-
*/
|
|
42
|
-
export const BARE_DESCRIPTION_MARGIN_PX = BARE_RING_OFFSET_PX + 8;
|
|
36
|
+
export const BARE_RING_OFFSET_PX = GRID_GAP_PX / 2;
|
|
43
37
|
|
|
44
38
|
/**
|
|
45
39
|
* The `grid-column` one tile occupies: its `# colspan`, and a `# break` forcing
|
|
@@ -58,6 +52,34 @@ export function tileGridColumn(
|
|
|
58
52
|
return tile.break ? `1 / span ${span}` : `span ${span}`;
|
|
59
53
|
}
|
|
60
54
|
|
|
55
|
+
/** Narrowest a tile that sets no `colspan` is drawn, by the reader and the builder alike. */
|
|
56
|
+
export const MIN_TILE_PX = 240;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The span a tile with no `# colspan` is drawn at in the grid inside `box`:
|
|
60
|
+
* {@link defaultTileSpan} on its measured width. For a surface that lays the
|
|
61
|
+
* grid out itself (the builder, whose width handle and row arithmetic need
|
|
62
|
+
* the span a tile is drawn at, not the one it writes).
|
|
63
|
+
*/
|
|
64
|
+
export function useDefaultTileSpan(
|
|
65
|
+
box: RefObject<HTMLElement | null>,
|
|
66
|
+
columns: number,
|
|
67
|
+
minTilePx: number = MIN_TILE_PX,
|
|
68
|
+
): number {
|
|
69
|
+
const [width, setWidth] = useState(0);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const node = box.current;
|
|
72
|
+
if (!node || typeof ResizeObserver === "undefined") return;
|
|
73
|
+
setWidth(node.getBoundingClientRect().width);
|
|
74
|
+
const observer = new ResizeObserver(([entry]) =>
|
|
75
|
+
setWidth(entry?.contentRect.width ?? 0),
|
|
76
|
+
);
|
|
77
|
+
observer.observe(node);
|
|
78
|
+
return () => observer.disconnect();
|
|
79
|
+
}, [box]);
|
|
80
|
+
return defaultTileSpan(columns, width, minTilePx);
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
/**
|
|
62
84
|
* Columns a tile with no `# colspan` spans so it is at least `minTilePx` wide.
|
|
63
85
|
*
|
|
@@ -131,7 +153,7 @@ export function DashboardGrid<T extends GridTile>({
|
|
|
131
153
|
* builder assumes an unset colspan is one column.
|
|
132
154
|
*/
|
|
133
155
|
minTilePx?: number;
|
|
134
|
-
/** The space between rows
|
|
156
|
+
/** The space between rows. */
|
|
135
157
|
rowGapPx?: number;
|
|
136
158
|
}) {
|
|
137
159
|
const ref = useRef<HTMLDivElement>(null);
|
|
@@ -89,6 +89,13 @@ export interface DashboardTileProps {
|
|
|
89
89
|
preamble?: string;
|
|
90
90
|
/** The server marked this tile unreadable for the viewer: nothing is run. */
|
|
91
91
|
restricted?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Set while a required filter this tile reads has no value: what to say in
|
|
94
|
+
* place of the result ("Waiting for Recall Year."). Nothing is run, since
|
|
95
|
+
* the query would only fail with the compiler's "has no value and no
|
|
96
|
+
* default".
|
|
97
|
+
*/
|
|
98
|
+
waitingFor?: string;
|
|
92
99
|
/** Its position in the report, for the `report.query_failed` it reports. */
|
|
93
100
|
index?: number;
|
|
94
101
|
}
|
|
@@ -141,6 +148,7 @@ export function DashboardTile({
|
|
|
141
148
|
ignoredFilters,
|
|
142
149
|
preamble,
|
|
143
150
|
restricted,
|
|
151
|
+
waitingFor,
|
|
144
152
|
index,
|
|
145
153
|
}: DashboardTileProps) {
|
|
146
154
|
const { theme } = usePublisherTheme();
|
|
@@ -171,7 +179,10 @@ export function DashboardTile({
|
|
|
171
179
|
),
|
|
172
180
|
},
|
|
173
181
|
// Restricted tiles never run; the rest wait to come near the viewport.
|
|
174
|
-
{
|
|
182
|
+
{
|
|
183
|
+
enabled:
|
|
184
|
+
nearViewport && restricted !== true && waitingFor === undefined,
|
|
185
|
+
},
|
|
175
186
|
);
|
|
176
187
|
// Each failed run once: the error is drawn in place, and the report's host
|
|
177
188
|
// hears of it when one is listening.
|
|
@@ -237,7 +248,13 @@ export function DashboardTile({
|
|
|
237
248
|
/>
|
|
238
249
|
)}
|
|
239
250
|
{ignoredFilters && <TileFilterTag ignored={ignoredFilters} />}
|
|
240
|
-
{
|
|
251
|
+
{waitingFor !== undefined ? (
|
|
252
|
+
<Box sx={{ p: 2 }}>
|
|
253
|
+
<Typography variant="body2" role="status" color="text.secondary">
|
|
254
|
+
{waitingFor}
|
|
255
|
+
</Typography>
|
|
256
|
+
</Box>
|
|
257
|
+
) : noAccess ? (
|
|
241
258
|
<Box sx={{ p: 2 }}>
|
|
242
259
|
<Typography variant="body2" role="status" color="text.secondary">
|
|
243
260
|
{RESTRICTED_NOTICE}
|
|
@@ -125,27 +125,154 @@ describe("DashboardView tiles", () => {
|
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
describe("
|
|
129
|
-
it("
|
|
130
|
-
const
|
|
131
|
-
|
|
128
|
+
describe("filters a host writes into the query (literalReads)", () => {
|
|
129
|
+
it("count as read for the tile, and are never sent as givens", async () => {
|
|
130
|
+
const manifest = {
|
|
131
|
+
...base,
|
|
132
|
+
givens: [
|
|
133
|
+
{ name: "REGION", type: "string", label: "Region" },
|
|
134
|
+
// The document's own filter: resolved to a literal by the host.
|
|
135
|
+
{ name: "BRAND", type: "string", label: "Brand" },
|
|
136
|
+
],
|
|
137
|
+
tiles: [
|
|
138
|
+
{
|
|
139
|
+
kind: "query",
|
|
140
|
+
query: "orders -> by_brand",
|
|
141
|
+
givenNames: ["REGION"],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
kind: "query",
|
|
145
|
+
query: "orders -> by_region",
|
|
146
|
+
givenNames: ["REGION"],
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
} as DashboardManifest;
|
|
150
|
+
render(
|
|
151
|
+
<DashboardView
|
|
152
|
+
manifest={manifest}
|
|
153
|
+
environmentName="env"
|
|
154
|
+
packageName="pkg"
|
|
155
|
+
documentName="ops"
|
|
156
|
+
givens={{ REGION: "West", BRAND: "Acme" }}
|
|
157
|
+
literalReads={{ "orders -> by_brand": ["BRAND"] }}
|
|
158
|
+
/>,
|
|
159
|
+
{ wrapper: serverWrapper },
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
await waitFor(() =>
|
|
163
|
+
expect(executeQueryModel.mock.calls.length).toBeGreaterThanOrEqual(2),
|
|
164
|
+
);
|
|
165
|
+
// Only the tile that does not read Brand says so.
|
|
166
|
+
const tags = await screen.findAllByTestId("tile-filter-tag");
|
|
167
|
+
expect(tags.map((tag) => tag.textContent)).toEqual([
|
|
168
|
+
"Doesn't respond to Brand",
|
|
169
|
+
]);
|
|
170
|
+
expect(tags[0].closest("[data-chrome]")?.textContent).toContain(
|
|
171
|
+
"By region",
|
|
172
|
+
);
|
|
173
|
+
// Brand's value reaches no request: the server does not know it.
|
|
174
|
+
for (const call of executeQueryModel.mock.calls)
|
|
175
|
+
expect(JSON.stringify(call[3])).not.toContain("BRAND");
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
describe("a required filter with no value", () => {
|
|
180
|
+
const manifest = {
|
|
181
|
+
...base,
|
|
182
|
+
givens: [
|
|
183
|
+
{
|
|
184
|
+
name: "RECALL_YEAR",
|
|
185
|
+
type: "number",
|
|
186
|
+
label: "Recall Year",
|
|
187
|
+
required: true,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
tiles: [
|
|
191
|
+
{
|
|
192
|
+
kind: "query",
|
|
193
|
+
query: "recalls -> by_year",
|
|
194
|
+
givenNames: ["RECALL_YEAR"],
|
|
195
|
+
label: "By year",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
kind: "query",
|
|
199
|
+
query: "recalls -> everything",
|
|
200
|
+
givenNames: [],
|
|
201
|
+
label: "Everything",
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
} as DashboardManifest;
|
|
205
|
+
const sent = () =>
|
|
206
|
+
executeQueryModel.mock.calls.map(
|
|
207
|
+
(call) => (call[3] as { query?: string }).query,
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
it("runs no tile that reads it, and asks for it once for the page", async () => {
|
|
211
|
+
render(
|
|
212
|
+
<DashboardView
|
|
213
|
+
manifest={manifest}
|
|
214
|
+
environmentName="env"
|
|
215
|
+
packageName="pkg"
|
|
216
|
+
documentName="recalls"
|
|
217
|
+
/>,
|
|
218
|
+
{ wrapper: serverWrapper },
|
|
219
|
+
);
|
|
220
|
+
expect(
|
|
221
|
+
await screen.findByText(
|
|
222
|
+
"Pick a value for Recall Year to see this report.",
|
|
223
|
+
),
|
|
224
|
+
).toBeDefined();
|
|
225
|
+
expect(screen.getByText("Waiting for Recall Year.")).toBeDefined();
|
|
226
|
+
await waitFor(() =>
|
|
227
|
+
expect(sent()).toContain("run: recalls -> everything"),
|
|
228
|
+
);
|
|
229
|
+
expect(sent()).not.toContain("run: recalls -> by_year");
|
|
230
|
+
// The control says it, rather than "Any".
|
|
132
231
|
expect(
|
|
133
|
-
|
|
134
|
-
).
|
|
135
|
-
expect(container.querySelector('[data-chrome="none"]')).toBeNull();
|
|
232
|
+
screen.getByRole("button", { name: "Recall Year: Required" }),
|
|
233
|
+
).toBeDefined();
|
|
136
234
|
});
|
|
137
235
|
|
|
138
|
-
it("
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
236
|
+
it("runs every tile once it has a value, with no prompt", async () => {
|
|
237
|
+
render(
|
|
238
|
+
<DashboardView
|
|
239
|
+
manifest={manifest}
|
|
240
|
+
environmentName="env"
|
|
241
|
+
packageName="pkg"
|
|
242
|
+
documentName="recalls-set"
|
|
243
|
+
givens={{ RECALL_YEAR: "2020" }}
|
|
244
|
+
/>,
|
|
245
|
+
{ wrapper: serverWrapper },
|
|
246
|
+
);
|
|
247
|
+
await waitFor(() => expect(sent()).toContain("run: recalls -> by_year"));
|
|
248
|
+
expect(
|
|
249
|
+
screen.queryByText("Pick a value for Recall Year to see this report."),
|
|
250
|
+
).toBeNull();
|
|
144
251
|
});
|
|
145
252
|
});
|
|
146
253
|
|
|
254
|
+
describe("DashboardView chrome", () => {
|
|
255
|
+
// A linear report and a grid draw the same page: query tiles in cards, text
|
|
256
|
+
// tiles as bare prose, and the title block. `chrome` is accepted and ignored.
|
|
257
|
+
for (const chrome of [undefined, "card", "none"] as const) {
|
|
258
|
+
it(`draws query tiles as cards and text as prose, with chrome ${chrome ?? "unset"}`, async () => {
|
|
259
|
+
const { container } = render(view(chrome), {
|
|
260
|
+
wrapper: serverWrapper,
|
|
261
|
+
});
|
|
262
|
+
const strong = await screen.findByText("reader");
|
|
263
|
+
expect(
|
|
264
|
+
strong.closest("[data-chrome]")?.getAttribute("data-chrome"),
|
|
265
|
+
).toBe("none");
|
|
266
|
+
expect(
|
|
267
|
+
container.querySelectorAll('[data-chrome="card"]'),
|
|
268
|
+
).toHaveLength(2);
|
|
269
|
+
expect(screen.getByRole("heading", { name: "ops" })).toBeDefined();
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
147
274
|
describe("DashboardView header", () => {
|
|
148
|
-
it("
|
|
275
|
+
it("draws a dashboard's description as bare page prose, not a card", async () => {
|
|
149
276
|
render(
|
|
150
277
|
<DashboardView
|
|
151
278
|
manifest={{ ...base, description: "About **this**" }}
|
|
@@ -157,8 +284,82 @@ describe("DashboardView header", () => {
|
|
|
157
284
|
);
|
|
158
285
|
const strong = await screen.findByText("this");
|
|
159
286
|
expect(strong.closest("[data-chrome]")?.getAttribute("data-chrome")).toBe(
|
|
160
|
-
"
|
|
287
|
+
"none",
|
|
288
|
+
);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe("DashboardView layout marker", () => {
|
|
293
|
+
it("marks the page with its layout, and a report that failed to load too", () => {
|
|
294
|
+
const { container, unmount } = render(
|
|
295
|
+
<DashboardView
|
|
296
|
+
manifest={{ ...base, layout: "linear" }}
|
|
297
|
+
environmentName="env"
|
|
298
|
+
packageName="pkg"
|
|
299
|
+
documentName="ops"
|
|
300
|
+
/>,
|
|
301
|
+
{ wrapper: serverWrapper },
|
|
302
|
+
);
|
|
303
|
+
expect(container.querySelector('[data-layout="linear"]')).not.toBeNull();
|
|
304
|
+
unmount();
|
|
305
|
+
|
|
306
|
+
const failed = render(
|
|
307
|
+
<DashboardView
|
|
308
|
+
manifest={{ ...base, layout: "grid", error: "did not compile" }}
|
|
309
|
+
environmentName="env"
|
|
310
|
+
packageName="pkg"
|
|
311
|
+
documentName="ops"
|
|
312
|
+
/>,
|
|
313
|
+
{ wrapper: serverWrapper },
|
|
161
314
|
);
|
|
315
|
+
expect(
|
|
316
|
+
failed.container.querySelector('[data-layout="grid"]'),
|
|
317
|
+
).not.toBeNull();
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
describe("DashboardView prose links", () => {
|
|
322
|
+
const linked = {
|
|
323
|
+
...base,
|
|
324
|
+
tiles: [
|
|
325
|
+
{ kind: "text", name: "intro", markdown: "See [the tour](tour)" },
|
|
326
|
+
],
|
|
327
|
+
} as DashboardManifest;
|
|
328
|
+
|
|
329
|
+
it("leaves a relative link as written when the host has no router", async () => {
|
|
330
|
+
render(
|
|
331
|
+
<DashboardView
|
|
332
|
+
manifest={linked}
|
|
333
|
+
environmentName="env"
|
|
334
|
+
packageName="pkg"
|
|
335
|
+
documentName="ops"
|
|
336
|
+
/>,
|
|
337
|
+
{ wrapper: serverWrapper },
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
const link = await screen.findByRole("link", { name: "the tour" });
|
|
341
|
+
// Its host's routes are unknown here (a version segment, another prefix), so nothing is rewritten.
|
|
342
|
+
expect(link.getAttribute("href")).toBe("tour");
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it("resolves a relative link against the report and hands it to the host's router", async () => {
|
|
346
|
+
const onLinkNavigate = mock((_to: string) => undefined);
|
|
347
|
+
render(
|
|
348
|
+
<DashboardView
|
|
349
|
+
manifest={linked}
|
|
350
|
+
environmentName="env"
|
|
351
|
+
packageName="pkg"
|
|
352
|
+
documentName="ops"
|
|
353
|
+
onLinkNavigate={onLinkNavigate}
|
|
354
|
+
/>,
|
|
355
|
+
{ wrapper: serverWrapper },
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
const link = await screen.findByRole("link", { name: "the tour" });
|
|
359
|
+
expect(link.getAttribute("href")).toBe("/env/pkg/dashboards/tour");
|
|
360
|
+
link.click();
|
|
361
|
+
expect(onLinkNavigate).toHaveBeenCalledTimes(1);
|
|
362
|
+
expect(onLinkNavigate.mock.calls[0][0]).toBe("/env/pkg/dashboards/tour");
|
|
162
363
|
});
|
|
163
364
|
});
|
|
164
365
|
|