@malloy-publisher/sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -9
- package/dist/DocumentStorageProvider-CyOJ0hqf.es.js +24443 -0
- package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
- package/dist/RenderedResult-BnPzJ9Jf.es.js +549 -0
- package/dist/RenderedResult-Dp22kZsQ.cjs.js +115 -0
- package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-BWOEKg0O.es.js} +1256 -1318
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9482 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +100 -42
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +30 -0
- package/dist/components/BackLink.d.ts +32 -0
- package/dist/components/Dashboard/Dashboard.d.ts +19 -14
- package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
- package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
- package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
- package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
- package/dist/components/Dashboard/TileCard.d.ts +44 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +7 -3
- package/dist/components/Dashboard/telemetry.d.ts +48 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +118 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +30 -0
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
- package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
- package/dist/components/DashboardBuilder/controls.d.ts +157 -0
- package/dist/components/DashboardBuilder/diff.d.ts +35 -0
- package/dist/components/DashboardBuilder/document.d.ts +218 -0
- package/dist/components/DashboardBuilder/layout.d.ts +71 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/preview.d.ts +60 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +53 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
- package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +7 -0
- package/dist/components/DocumentStorage/index.d.ts +1 -1
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/ItemRow.d.ts +38 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
- package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
- package/dist/components/Materializations/Materializations.d.ts +7 -3
- package/dist/components/Materializations/ScopeButton.d.ts +18 -0
- package/dist/components/Materializations/SectionLabel.d.ts +7 -4
- package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
- package/dist/components/Materializations/index.d.ts +0 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
- package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
- package/dist/components/Package/index.d.ts +0 -1
- package/dist/components/PackageSection.d.ts +23 -0
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +1 -0
- package/dist/components/buttons.d.ts +53 -0
- package/dist/components/drill/index.d.ts +1 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/index.d.ts +6 -0
- package/dist/components/styles.d.ts +49 -44
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/index.cjs.js +22 -273
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +16888 -44451
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +24 -9
- package/src/builder-entry.ts +55 -0
- package/src/components/AppDialog.tsx +115 -0
- package/src/components/BackLink.tsx +83 -0
- package/src/components/Connections/AddConnectionDialog.tsx +50 -70
- package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
- package/src/components/Connections/EditConnectionDialog.tsx +54 -73
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +165 -175
- package/src/components/Dashboard/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +66 -123
- package/src/components/Dashboard/ExploreDialog.tsx +84 -0
- package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
- package/src/components/Dashboard/RowsDialog.tsx +234 -0
- package/src/components/Dashboard/TileCard.tsx +120 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +70 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
- package/src/components/Dashboard/telemetry.ts +51 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +247 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +852 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +666 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +188 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +567 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +122 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +269 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +562 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +126 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
- package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
- package/src/components/DashboardBuilder/catalog.ts +225 -0
- package/src/components/DashboardBuilder/controls.spec.ts +243 -0
- package/src/components/DashboardBuilder/controls.ts +398 -0
- package/src/components/DashboardBuilder/diff.spec.ts +44 -0
- package/src/components/DashboardBuilder/diff.ts +93 -0
- package/src/components/DashboardBuilder/document.ts +209 -0
- package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
- package/src/components/DashboardBuilder/layout.ts +143 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
- package/src/components/DashboardBuilder/malloyText.ts +151 -0
- package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
- package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -0
- package/src/components/DashboardBuilder/preview.spec.ts +149 -0
- package/src/components/DashboardBuilder/preview.ts +172 -0
- package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
- package/src/components/DashboardBuilder/readDocument.ts +467 -0
- package/src/components/DashboardBuilder/sortable.tsx +151 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +1161 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1135 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +311 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +201 -0
- package/src/components/DashboardBuilder/useDraft.ts +43 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
- package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
- package/src/components/DashboardBuilder/useTileResize.ts +110 -0
- package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +12 -0
- package/src/components/DocumentStorage/index.ts +1 -0
- package/src/components/Environment/About.tsx +16 -62
- package/src/components/Environment/AddPackageDialog.tsx +85 -154
- package/src/components/Environment/Connections.tsx +125 -205
- package/src/components/Environment/DeletePackageDialog.tsx +32 -77
- package/src/components/Environment/EditPackageDialog.tsx +46 -58
- package/src/components/Environment/Environment.tsx +34 -36
- package/src/components/Environment/Packages.tsx +63 -128
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
- package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
- package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
- package/src/components/Home/Home.tsx +101 -214
- package/src/components/ItemRow.tsx +165 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
- package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
- package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
- package/src/components/Materializations/Materializations.tsx +137 -140
- package/src/components/Materializations/ScopeButton.tsx +85 -0
- package/src/components/Materializations/SectionLabel.tsx +7 -4
- package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
- package/src/components/Materializations/TriggerLabel.tsx +36 -0
- package/src/components/Materializations/cron.spec.ts +113 -0
- package/src/components/Materializations/index.ts +0 -1
- package/src/components/Materializations/utils.spec.ts +182 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +33 -72
- package/src/components/Notebook/Notebook.tsx +25 -88
- package/src/components/Notebook/NotebookCell.tsx +35 -183
- package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
- package/src/components/Package/ContentTypeIcon.tsx +10 -12
- package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
- package/src/components/Package/NewDashboardDialog.tsx +265 -0
- package/src/components/Package/Package.tsx +179 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- package/src/components/Prose.spec.tsx +85 -0
- package/src/components/Prose.tsx +179 -0
- package/src/components/QueryResult/QueryResult.tsx +15 -43
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- package/src/components/RenderedResult/ResultContainer.tsx +4 -12
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +1 -0
- package/src/components/ResultsDialog.tsx +8 -32
- package/src/components/buttons.tsx +114 -0
- package/src/components/designSystem.spec.tsx +316 -0
- package/src/components/drill/index.ts +1 -0
- package/src/components/drill/resolveDrill.ts +22 -1
- package/src/components/drill/useDrill.spec.tsx +94 -0
- package/src/components/drill/useDrill.tsx +52 -12
- package/src/components/given/GivensPanel.tsx +1 -1
- package/src/components/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +16 -0
- package/src/components/styles.ts +49 -122
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -0
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/index.ts +9 -0
- package/src/telemetry/consoleEvents.spec.ts +130 -0
- package/src/telemetry/consoleEvents.ts +124 -0
- package/src/theme/defaults.ts +34 -23
- package/src/theme/resolveTheme.spec.ts +9 -4
- package/src/theme/resolveTheme.ts +12 -8
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/src/utils/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/vite.config.ts +5 -0
- package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
- package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
- package/dist/components/Materializations/TriggerChip.d.ts +0 -10
- package/dist/components/Package/Models.d.ts +0 -6
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
- package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
- package/src/components/Materializations/ScheduleCard.tsx +0 -231
- package/src/components/Materializations/TriggerChip.tsx +0 -44
- package/src/components/Package/Models.tsx +0 -71
|
@@ -2,20 +2,34 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { Alert, Box, Stack, Typography } from "@mui/material";
|
|
5
|
-
import
|
|
6
|
-
import { useCallback, useMemo } from "react";
|
|
5
|
+
import { useCallback, useMemo, useState } from "react";
|
|
7
6
|
import type { DashboardManifest } from "../../client";
|
|
8
|
-
import {
|
|
7
|
+
import { useDocumentControls } from "../../hooks/useDocumentControls";
|
|
9
8
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
10
|
-
import { useSuggestOptions } from "../../hooks/useSuggestOptions";
|
|
11
9
|
import { parseResourceUri } from "../../utils/formatting";
|
|
12
10
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
13
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useDrill,
|
|
13
|
+
type DrillBinding,
|
|
14
|
+
type DrillClickPayload,
|
|
15
|
+
type DrillNavigation,
|
|
16
|
+
type DrillRowsRequest,
|
|
17
|
+
} from "../drill";
|
|
14
18
|
import { GivensPanel } from "../given";
|
|
19
|
+
import { Prose } from "../Prose";
|
|
20
|
+
import { givensToRequest } from "../given/paramCodec";
|
|
15
21
|
import { Loading } from "../Loading";
|
|
16
22
|
import { TILE_MAX_HEIGHT } from "../RenderedResult/resultSizing";
|
|
17
23
|
import { useServer } from "../ServerProvider";
|
|
24
|
+
import { DashboardGrid, DEFAULT_COLUMNS } from "./DashboardGrid";
|
|
18
25
|
import { DashboardTile } from "./DashboardTile";
|
|
26
|
+
import { ExploreDialog } from "./ExploreDialog";
|
|
27
|
+
import { RowsDialog, stepsOf, type RowsRequest } from "./RowsDialog";
|
|
28
|
+
import type { DashboardEventHandler } from "./telemetry";
|
|
29
|
+
|
|
30
|
+
// The grid rule moved to `DashboardGrid`, which the builder shares.
|
|
31
|
+
// Re-exported so existing importers of it are unaffected.
|
|
32
|
+
export { DEFAULT_COLUMNS, tileGridColumn } from "./DashboardGrid";
|
|
19
33
|
|
|
20
34
|
export interface DashboardProps {
|
|
21
35
|
/** `publisher://environments/{env}/packages/{pkg}`, optionally `?versionId=`. */
|
|
@@ -58,26 +72,8 @@ export interface DashboardProps {
|
|
|
58
72
|
*/
|
|
59
73
|
height?: number;
|
|
60
74
|
maxResultSize?: number;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/** Grid width when the dashboard declares no `# dashboard { columns=N }`. */
|
|
64
|
-
const DEFAULT_COLUMNS = 2;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The `grid-column` one tile occupies: its `# colspan`, and a `# break` forcing
|
|
68
|
-
* it to start a fresh row.
|
|
69
|
-
*
|
|
70
|
-
* Clamped to the grid width the same way @malloydata/render clamps it, so one
|
|
71
|
-
* view laid out as a composite tile and as a `nest:` under `# dashboard` lands
|
|
72
|
-
* in the same place. A break is `1 / span N` — an explicit start line, which is
|
|
73
|
-
* what pushes the tile down to the next row; the renderer's grid does the same.
|
|
74
|
-
*/
|
|
75
|
-
export function tileGridColumn(
|
|
76
|
-
tile: { colspan?: number; break?: boolean },
|
|
77
|
-
columns: number,
|
|
78
|
-
): string {
|
|
79
|
-
const span = Math.min(tile.colspan ?? 1, columns);
|
|
80
|
-
return tile.break ? `1 / span ${span}` : `span ${span}`;
|
|
75
|
+
/** The rows shown and tiles explored, for the host to log or count. */
|
|
76
|
+
onEvent?: DashboardEventHandler;
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
/**
|
|
@@ -97,6 +93,7 @@ export function Dashboard({
|
|
|
97
93
|
onNavigate,
|
|
98
94
|
height,
|
|
99
95
|
maxResultSize,
|
|
96
|
+
onEvent,
|
|
100
97
|
}: DashboardProps) {
|
|
101
98
|
const parsed = parseResourceUri(resourceUri);
|
|
102
99
|
const { apiClients } = useServer();
|
|
@@ -143,85 +140,72 @@ export function Dashboard({
|
|
|
143
140
|
const manifest = manifestResponse?.data;
|
|
144
141
|
|
|
145
142
|
const specs = useMemo(() => manifest?.givens ?? [], [manifest]);
|
|
146
|
-
const declaredTypes = useMemo(
|
|
147
|
-
() =>
|
|
148
|
-
new Map(
|
|
149
|
-
specs
|
|
150
|
-
.filter((spec) => spec.name !== undefined)
|
|
151
|
-
.map((spec) => [spec.name as string, spec.type]),
|
|
152
|
-
),
|
|
153
|
-
[specs],
|
|
154
|
-
);
|
|
155
143
|
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
(next: Record<string, string>) => {
|
|
162
|
-
if (!isSuccess) return;
|
|
163
|
-
onGivensChange?.(next, Array.from(declaredTypes.keys()));
|
|
164
|
-
},
|
|
165
|
-
[isSuccess, onGivensChange, declaredTypes],
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
const { draft, applied, setGiven, reset, apply, pending } = useGivensState({
|
|
169
|
-
declaredTypes,
|
|
144
|
+
// The control row's state, options and `to=self` drill: the same hook the
|
|
145
|
+
// notebook uses, so a control behaves identically on both surfaces.
|
|
146
|
+
const controls = useDocumentControls({
|
|
147
|
+
specs,
|
|
148
|
+
loaded: isSuccess,
|
|
170
149
|
startingValues: manifest?.startingGivens,
|
|
171
150
|
params: givens,
|
|
172
|
-
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
// repeat. The host reasonably clears its query string, which is exactly the
|
|
180
|
-
// givens the drill just seeded for the dashboard now arriving.
|
|
181
|
-
onParamsChange: isSuccess ? reportGivens : undefined,
|
|
182
|
-
// Which document these edits belong to. Without it the edits are keyed by
|
|
183
|
-
// their starting VALUES alone, so two dashboards whose starting values
|
|
184
|
-
// coincide (the common case: both empty) look like one document, and the
|
|
185
|
-
// one you came from keeps filtering the one you drilled into.
|
|
186
|
-
// The version belongs in that identity too, so a swap between versions
|
|
187
|
-
// drops the edits a reader made to the one they came from. Only the
|
|
188
|
-
// EDITS: `initial` is `startingValues` merged with `params`, so a host
|
|
189
|
-
// that round-trips givens through its own URL hands them straight back
|
|
190
|
-
// and they still apply across the swap. That one is the host's call, and
|
|
191
|
-
// this key neither can nor should overrule it.
|
|
151
|
+
onGivensChange,
|
|
152
|
+
// Which document these edits belong to, version included: two
|
|
153
|
+
// dashboards whose starting values coincide (both empty, usually)
|
|
154
|
+
// would otherwise look like one document, and the one you came from
|
|
155
|
+
// would keep filtering the one you drilled into. Only the EDITS: a host
|
|
156
|
+
// that round-trips givens through its own URL hands them straight back,
|
|
157
|
+
// and they still apply across the swap.
|
|
192
158
|
documentKey: `${environmentName}/${packageName}/${versionId ?? ""}/${dashboard}`,
|
|
193
159
|
// Absent means autorun; only an explicit `autorun=false` batches.
|
|
194
160
|
autorun: manifest?.autorun !== false,
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
const {
|
|
198
|
-
options,
|
|
199
|
-
isLoading: optionsLoading,
|
|
200
|
-
failed: optionsFailed,
|
|
201
|
-
} = useSuggestOptions(
|
|
202
161
|
environmentName,
|
|
203
162
|
packageName,
|
|
204
|
-
manifest?.path,
|
|
205
|
-
specs,
|
|
163
|
+
modelPath: manifest?.path,
|
|
206
164
|
versionId,
|
|
207
|
-
// So a suggest over a gated or scoped source carries the givens it needs.
|
|
208
|
-
{ values: applied, declaredTypes },
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
// `to=self` filters in place. Which givens a tag may set, and setting one
|
|
212
|
-
// from a clicked cell, is the same on both surfaces, so it is shared.
|
|
213
|
-
const { canSelf, onSelf } = useDrillSelf({
|
|
214
|
-
declaredTypes,
|
|
215
|
-
setGiven,
|
|
216
165
|
documentName: dashboard,
|
|
217
166
|
});
|
|
167
|
+
const { applied, declaredTypes, canSelf, onSelf } = controls;
|
|
168
|
+
|
|
169
|
+
// The rows behind a clicked value, and a tile's query in the explorer —
|
|
170
|
+
// the two ways past a number. Composite tiles only: each names its
|
|
171
|
+
// source, which is what the rows are of and what the explorer opens on.
|
|
172
|
+
const [rows, setRows] = useState<RowsRequest | undefined>(undefined);
|
|
173
|
+
const [exploring, setExploring] = useState<string | undefined>(undefined);
|
|
174
|
+
const onRows = useCallback((request: DrillRowsRequest) => {
|
|
175
|
+
const steps = stepsOf(request.context);
|
|
176
|
+
if (steps === undefined) return;
|
|
177
|
+
setRows({
|
|
178
|
+
...steps,
|
|
179
|
+
field: request.field,
|
|
180
|
+
rawValue: request.rawValue,
|
|
181
|
+
label: request.label,
|
|
182
|
+
});
|
|
183
|
+
}, []);
|
|
184
|
+
|
|
185
|
+
// The whole applied row: a source's own `where:` may read any of it, and a
|
|
186
|
+
// given the rows query does not reference is ignored by the server.
|
|
187
|
+
const rowsGivens = useMemo(
|
|
188
|
+
() => givensToRequest(applied, declaredTypes),
|
|
189
|
+
[applied, declaredTypes],
|
|
190
|
+
);
|
|
218
191
|
|
|
219
192
|
const { drill, drillMenu } = useDrill({
|
|
220
193
|
onNavigate,
|
|
221
194
|
onSelf,
|
|
222
195
|
canSelf,
|
|
223
196
|
selfLabel: "Filter this dashboard",
|
|
197
|
+
onRows,
|
|
224
198
|
});
|
|
199
|
+
// Each tile's clicks carry the tile they came from, so the rows behind a
|
|
200
|
+
// value know which source to run against.
|
|
201
|
+
const drillFor = useCallback(
|
|
202
|
+
(tile: string): DrillBinding => ({
|
|
203
|
+
canDrill: drill.canDrill,
|
|
204
|
+
onClick: (payload: DrillClickPayload) =>
|
|
205
|
+
drill.onClick({ ...payload, context: tile }),
|
|
206
|
+
}),
|
|
207
|
+
[drill],
|
|
208
|
+
);
|
|
225
209
|
|
|
226
210
|
// After every hook, so the hook order does not depend on the URI.
|
|
227
211
|
if (!uriNamesBoth) {
|
|
@@ -271,21 +255,7 @@ export function Dashboard({
|
|
|
271
255
|
<Stack spacing={2}>
|
|
272
256
|
<DashboardHeader manifest={manifest} />
|
|
273
257
|
|
|
274
|
-
<GivensPanel
|
|
275
|
-
givens={specs}
|
|
276
|
-
values={draft}
|
|
277
|
-
onChange={setGiven}
|
|
278
|
-
onReset={reset}
|
|
279
|
-
layout="bar"
|
|
280
|
-
options={options}
|
|
281
|
-
optionsLoading={optionsLoading}
|
|
282
|
-
optionsFailed={optionsFailed}
|
|
283
|
-
apply={
|
|
284
|
-
manifest.autorun === false
|
|
285
|
-
? { onApply: apply, pending }
|
|
286
|
-
: undefined
|
|
287
|
-
}
|
|
288
|
-
/>
|
|
258
|
+
<GivensPanel {...controls.panel} layout="bar" />
|
|
289
259
|
|
|
290
260
|
{modelPath === undefined ? (
|
|
291
261
|
<Alert severity="error">
|
|
@@ -311,50 +281,40 @@ export function Dashboard({
|
|
|
311
281
|
// Composite form: each tile runs on its own and the results are
|
|
312
282
|
// combined into one grid here, since no single Malloy result spans
|
|
313
283
|
// them.
|
|
314
|
-
<
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
284
|
+
<DashboardGrid
|
|
285
|
+
tiles={tiles}
|
|
286
|
+
columns={columns}
|
|
287
|
+
// Position too, not the expression alone: `tiles=[…]` can repeat
|
|
288
|
+
// one, which is a typo rather than a request for two identical
|
|
289
|
+
// panels, and keying on the expression made the duplicate warn
|
|
290
|
+
// and reconcile onto its twin.
|
|
291
|
+
keyOf={(tile, index) => `${index}:${tile.query}`}
|
|
292
|
+
renderTile={(tile) => (
|
|
293
|
+
<DashboardTile
|
|
294
|
+
environmentName={environmentName}
|
|
295
|
+
packageName={packageName}
|
|
296
|
+
versionId={versionId}
|
|
297
|
+
modelPath={modelPath}
|
|
298
|
+
tile={tile.query}
|
|
299
|
+
label={tile.label}
|
|
300
|
+
subtitle={tile.subtitle}
|
|
301
|
+
borderless={tile.borderless}
|
|
302
|
+
givens={applied}
|
|
303
|
+
declaredTypes={declaredTypes}
|
|
304
|
+
givenNames={tile.givenNames}
|
|
305
|
+
height={height ?? TILE_MAX_HEIGHT}
|
|
306
|
+
maxResultSize={maxResultSize}
|
|
307
|
+
drill={drillFor(tile.query)}
|
|
308
|
+
onExplore={() => {
|
|
309
|
+
setExploring(tile.query);
|
|
310
|
+
onEvent?.({
|
|
311
|
+
type: "dashboard.explored",
|
|
312
|
+
tile: tile.query,
|
|
313
|
+
});
|
|
337
314
|
}}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
packageName={packageName}
|
|
342
|
-
versionId={versionId}
|
|
343
|
-
modelPath={modelPath}
|
|
344
|
-
tile={tile.query}
|
|
345
|
-
label={tile.label}
|
|
346
|
-
subtitle={tile.subtitle}
|
|
347
|
-
borderless={tile.borderless}
|
|
348
|
-
givens={applied}
|
|
349
|
-
declaredTypes={declaredTypes}
|
|
350
|
-
givenNames={tile.givenNames}
|
|
351
|
-
height={height ?? TILE_MAX_HEIGHT}
|
|
352
|
-
maxResultSize={maxResultSize}
|
|
353
|
-
drill={drill}
|
|
354
|
-
/>
|
|
355
|
-
</Box>
|
|
356
|
-
))}
|
|
357
|
-
</Box>
|
|
315
|
+
/>
|
|
316
|
+
)}
|
|
317
|
+
/>
|
|
358
318
|
) : (
|
|
359
319
|
<Alert severity="warning">
|
|
360
320
|
This dashboard names neither a query nor any tiles.
|
|
@@ -362,6 +322,38 @@ export function Dashboard({
|
|
|
362
322
|
)}
|
|
363
323
|
|
|
364
324
|
{drillMenu}
|
|
325
|
+
{modelPath !== undefined && (
|
|
326
|
+
<>
|
|
327
|
+
<RowsDialog
|
|
328
|
+
request={rows}
|
|
329
|
+
environmentName={environmentName}
|
|
330
|
+
packageName={packageName}
|
|
331
|
+
{...(versionId === undefined ? {} : { versionId })}
|
|
332
|
+
modelPath={modelPath}
|
|
333
|
+
givens={rowsGivens}
|
|
334
|
+
onClose={() => setRows(undefined)}
|
|
335
|
+
onDone={(ok, durationMs) => {
|
|
336
|
+
if (rows)
|
|
337
|
+
onEvent?.({
|
|
338
|
+
type: "dashboard.rows_shown",
|
|
339
|
+
source: rows.source,
|
|
340
|
+
view: rows.view,
|
|
341
|
+
field: rows.field,
|
|
342
|
+
ok,
|
|
343
|
+
durationMs,
|
|
344
|
+
});
|
|
345
|
+
}}
|
|
346
|
+
/>
|
|
347
|
+
<ExploreDialog
|
|
348
|
+
tile={exploring}
|
|
349
|
+
environmentName={environmentName}
|
|
350
|
+
packageName={packageName}
|
|
351
|
+
{...(versionId === undefined ? {} : { versionId })}
|
|
352
|
+
modelPath={modelPath}
|
|
353
|
+
onClose={() => setExploring(undefined)}
|
|
354
|
+
/>
|
|
355
|
+
</>
|
|
356
|
+
)}
|
|
365
357
|
</Stack>
|
|
366
358
|
);
|
|
367
359
|
}
|
|
@@ -381,41 +373,39 @@ export function Dashboard({
|
|
|
381
373
|
* format cannot express yet. This is the half that needs nothing new.
|
|
382
374
|
*/
|
|
383
375
|
function DashboardHeader({ manifest }: { manifest: DashboardManifest }) {
|
|
376
|
+
return (
|
|
377
|
+
<DashboardProse
|
|
378
|
+
title={manifest.title ?? manifest.name}
|
|
379
|
+
{...(manifest.description
|
|
380
|
+
? { description: manifest.description }
|
|
381
|
+
: {})}
|
|
382
|
+
/>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* The prose header itself, over the two fields it actually needs.
|
|
388
|
+
*
|
|
389
|
+
* Separate from {@link DashboardHeader} so the BUILDER can render the same
|
|
390
|
+
* header over a `DashboardDocument` — which carries `title` and `description`
|
|
391
|
+
* but is not a manifest. Same argument as {@link tileGridColumn}: what the
|
|
392
|
+
* builder shows a author is the thing a reader will see, and one component is
|
|
393
|
+
* what stops the two drifting. A builder that restated this markdown block
|
|
394
|
+
* would be one edit away from showing a different header than it writes.
|
|
395
|
+
*/
|
|
396
|
+
export function DashboardProse({
|
|
397
|
+
title,
|
|
398
|
+
description,
|
|
399
|
+
}: {
|
|
400
|
+
title: string;
|
|
401
|
+
description?: string;
|
|
402
|
+
}) {
|
|
384
403
|
return (
|
|
385
404
|
<Box>
|
|
386
405
|
<Typography variant="h5" sx={{ fontWeight: 600 }}>
|
|
387
|
-
{
|
|
406
|
+
{title}
|
|
388
407
|
</Typography>
|
|
389
|
-
{
|
|
390
|
-
<Box
|
|
391
|
-
sx={{
|
|
392
|
-
color: "text.secondary",
|
|
393
|
-
typography: "body2",
|
|
394
|
-
// The block starts flush under the title and ends flush
|
|
395
|
-
// against the controls, so a one-line description sits
|
|
396
|
-
// exactly where the old `Typography` put it and a longer one
|
|
397
|
-
// grows downward rather than pushing the title around.
|
|
398
|
-
"& > :first-of-type": { mt: 0 },
|
|
399
|
-
"& > :last-child": { mb: 0 },
|
|
400
|
-
// Headings in a description are section labels within the
|
|
401
|
-
// page, not competitors to its title, so they stay at body
|
|
402
|
-
// weight and size rather than MUI's h1..h6 scale.
|
|
403
|
-
"& h1, & h2, & h3, & h4, & h5, & h6": {
|
|
404
|
-
fontSize: "inherit",
|
|
405
|
-
fontWeight: 600,
|
|
406
|
-
m: "0.5em 0 0.25em",
|
|
407
|
-
},
|
|
408
|
-
"& p": { m: "0.5em 0" },
|
|
409
|
-
"& ul, & ol": { m: "0.5em 0", pl: 3 },
|
|
410
|
-
"& code": {
|
|
411
|
-
fontFamily: "monospace",
|
|
412
|
-
fontSize: "0.9em",
|
|
413
|
-
},
|
|
414
|
-
}}
|
|
415
|
-
>
|
|
416
|
-
<Markdown>{manifest.description}</Markdown>
|
|
417
|
-
</Box>
|
|
418
|
-
)}
|
|
408
|
+
{description && <Prose variant="caption">{description}</Prose>}
|
|
419
409
|
</Box>
|
|
420
410
|
);
|
|
421
411
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { Stack } from "@mui/material";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The bar above a dashboard, in the one shape both the reader's view and the
|
|
10
|
+
* builder use.
|
|
11
|
+
*
|
|
12
|
+
* Reading and editing are the same page in two states, so the bar that carries
|
|
13
|
+
* the switch is the same bar: same height, same ground, same edge, and the
|
|
14
|
+
* same left and right margins as the dashboard under it — the state on the
|
|
15
|
+
* left, the way out of it on the right. The fixed height is the load-bearing
|
|
16
|
+
* part: it is what makes switching modes move nothing on the page.
|
|
17
|
+
*
|
|
18
|
+
* No horizontal padding of its own: it is laid out inside whatever insets the
|
|
19
|
+
* dashboard, so the left item lines up with the title below it and the right
|
|
20
|
+
* item with the right edge of the grid.
|
|
21
|
+
*/
|
|
22
|
+
export function DashboardBar({
|
|
23
|
+
left,
|
|
24
|
+
children,
|
|
25
|
+
}: {
|
|
26
|
+
/** The page's state, at the left edge: a chip, or nothing while reading. */
|
|
27
|
+
left?: ReactNode;
|
|
28
|
+
/** What can be done about it, at the right edge. */
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
}) {
|
|
31
|
+
const { theme } = usePublisherTheme();
|
|
32
|
+
return (
|
|
33
|
+
<Stack
|
|
34
|
+
direction="row"
|
|
35
|
+
sx={{
|
|
36
|
+
position: "sticky",
|
|
37
|
+
top: 0,
|
|
38
|
+
zIndex: 5,
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
justifyContent: "space-between",
|
|
41
|
+
gap: 1,
|
|
42
|
+
// One height whether or not the bar has anything on the left, so
|
|
43
|
+
// switching modes moves nothing.
|
|
44
|
+
minHeight: 48,
|
|
45
|
+
py: 0.5,
|
|
46
|
+
// The rule is the bar's own edge, not the page's underline: the
|
|
47
|
+
// title below needs room to read as a heading rather than as the
|
|
48
|
+
// bar's caption.
|
|
49
|
+
mb: 3,
|
|
50
|
+
// Its own ground, so the tiles scrolling under it do not show
|
|
51
|
+
// through, and an edge so it reads as a bar rather than a row. The
|
|
52
|
+
// Publisher theme's ground and edge, like every other surface here
|
|
53
|
+
// — MUI's own palette would not follow an instance theme or its
|
|
54
|
+
// dark mode.
|
|
55
|
+
bgcolor: theme.background,
|
|
56
|
+
borderBottom: theme.border,
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
<Stack
|
|
60
|
+
direction="row"
|
|
61
|
+
sx={{
|
|
62
|
+
alignItems: "center",
|
|
63
|
+
gap: 1,
|
|
64
|
+
// The side that gives way: without a zero min-width a hint that
|
|
65
|
+
// will not wrap makes the whole bar wider than the page, and the
|
|
66
|
+
// controls on the right end up past the fold.
|
|
67
|
+
minWidth: 0,
|
|
68
|
+
overflow: "hidden",
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{left}
|
|
72
|
+
</Stack>
|
|
73
|
+
<Stack
|
|
74
|
+
direction="row"
|
|
75
|
+
sx={{
|
|
76
|
+
alignItems: "center",
|
|
77
|
+
gap: 0.5,
|
|
78
|
+
// A button's label never wraps onto a second line; anything
|
|
79
|
+
// beside them gives way first.
|
|
80
|
+
flexShrink: 0,
|
|
81
|
+
"& .MuiButton-root": { whiteSpace: "nowrap" },
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</Stack>
|
|
86
|
+
</Stack>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { Box } from "@mui/material";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
|
|
7
|
+
/** Grid width when the dashboard declares no `# dashboard { columns=N }`. */
|
|
8
|
+
export const DEFAULT_COLUMNS = 2;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The gutter between tiles, in px.
|
|
12
|
+
*
|
|
13
|
+
* A number rather than a `gap: 2` spacing unit because the BUILDER has to do
|
|
14
|
+
* arithmetic with it: turning a dragged edge into a column count means solving
|
|
15
|
+
* for the track width, and that needs the gutter in the same units as a
|
|
16
|
+
* `getBoundingClientRect`. Exported so the value the grid paints and the value
|
|
17
|
+
* the drag solves with cannot drift apart.
|
|
18
|
+
*/
|
|
19
|
+
export const GRID_GAP_PX = 16;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The `grid-column` one tile occupies: its `# colspan`, and a `# break` forcing
|
|
23
|
+
* it to start a fresh row.
|
|
24
|
+
*
|
|
25
|
+
* Clamped to the grid width the same way @malloydata/render clamps it, so one
|
|
26
|
+
* view laid out as a composite tile and as a `nest:` under `# dashboard` lands
|
|
27
|
+
* in the same place. A break is `1 / span N` — an explicit start line, which is
|
|
28
|
+
* what pushes the tile down to the next row; the renderer's grid does the same.
|
|
29
|
+
*/
|
|
30
|
+
export function tileGridColumn(
|
|
31
|
+
tile: { colspan?: number; break?: boolean },
|
|
32
|
+
columns: number,
|
|
33
|
+
): string {
|
|
34
|
+
const span = Math.min(tile.colspan ?? 1, columns);
|
|
35
|
+
return tile.break ? `1 / span ${span}` : `span ${span}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The layout a tile carries, whatever else its own shape holds. */
|
|
39
|
+
export interface GridTile {
|
|
40
|
+
colspan?: number;
|
|
41
|
+
break?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The composite dashboard's grid: the column track, and each tile's place on
|
|
46
|
+
* it.
|
|
47
|
+
*
|
|
48
|
+
* Shared by the READER ({@link Dashboard}) and the BUILDER, which is the whole
|
|
49
|
+
* point of it being a component rather than a rule each surface applies. An
|
|
50
|
+
* author arranging a dashboard is arranging the thing a reader will open, so
|
|
51
|
+
* the two cannot be allowed to lay tiles out even slightly differently; a
|
|
52
|
+
* restated track without the grid item's own `display: grid` ends rows at
|
|
53
|
+
* ragged heights on one surface and level on the other.
|
|
54
|
+
*
|
|
55
|
+
* **Why the item is a grid and not a block.** A grid item stretches to its row,
|
|
56
|
+
* but a block CHILD of one does not — it keeps its content height. Results
|
|
57
|
+
* divide on exactly that line (see `resultSizing`): a table, a map or a
|
|
58
|
+
* `# big_value` sizes to its content, while a plotted chart fills whatever box
|
|
59
|
+
* it is handed. So a block item put a short table beside a tall chart and let
|
|
60
|
+
* the row end twice. Making the item a grid passes the row's height down to the
|
|
61
|
+
* tile, and every card in a row ends level.
|
|
62
|
+
*
|
|
63
|
+
* The tile itself is the caller's: the reader renders a `DashboardTile`, the
|
|
64
|
+
* builder wraps one in its selection outline. Anything this component rendered
|
|
65
|
+
* on their behalf would be a third opinion about what a tile looks like.
|
|
66
|
+
*/
|
|
67
|
+
export function DashboardGrid<T extends GridTile>({
|
|
68
|
+
tiles,
|
|
69
|
+
columns,
|
|
70
|
+
keyOf,
|
|
71
|
+
renderTile,
|
|
72
|
+
}: {
|
|
73
|
+
tiles: readonly T[];
|
|
74
|
+
/** Track count — `# dashboard { columns=N }`, or {@link DEFAULT_COLUMNS}. */
|
|
75
|
+
columns: number;
|
|
76
|
+
/**
|
|
77
|
+
* This tile's React key. Taken from the caller because the two surfaces
|
|
78
|
+
* identify a tile differently and both are right: the manifest's `tiles=[…]`
|
|
79
|
+
* can repeat one expression (a typo, not a request for two identical
|
|
80
|
+
* panels), so the reader keys on position as well.
|
|
81
|
+
*/
|
|
82
|
+
keyOf: (tile: T, index: number) => string;
|
|
83
|
+
renderTile: (tile: T, index: number) => ReactNode;
|
|
84
|
+
}) {
|
|
85
|
+
return (
|
|
86
|
+
<Box
|
|
87
|
+
sx={{
|
|
88
|
+
display: "grid",
|
|
89
|
+
gridTemplateColumns: {
|
|
90
|
+
xs: "1fr",
|
|
91
|
+
md: `repeat(${columns}, minmax(0, 1fr))`,
|
|
92
|
+
},
|
|
93
|
+
gap: `${GRID_GAP_PX}px`,
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
{tiles.map((tile, index) => (
|
|
97
|
+
<Box
|
|
98
|
+
key={keyOf(tile, index)}
|
|
99
|
+
sx={{
|
|
100
|
+
// Load-bearing — see the note above.
|
|
101
|
+
display: "grid",
|
|
102
|
+
// A tile follows its TRACK, whatever it holds. A grid item's
|
|
103
|
+
// minimum width is `auto` — its content's minimum — and a
|
|
104
|
+
// chart's content is an SVG drawn at the width the tile had
|
|
105
|
+
// when it rendered. So without this, narrowing a tile did not
|
|
106
|
+
// narrow it: the item stayed as wide as the old chart, ran
|
|
107
|
+
// under its neighbour, and the renderer's own size observer
|
|
108
|
+
// never saw a change to redraw for. Widening worked, which is
|
|
109
|
+
// what made it look like the chart filled in one direction
|
|
110
|
+
// only. With the minimum at zero the item takes the track's
|
|
111
|
+
// width, the chart's box shrinks with it, and the renderer
|
|
112
|
+
// redraws to fit — the same way it already did on growth.
|
|
113
|
+
minWidth: 0,
|
|
114
|
+
// Only above `md`: the narrow breakpoint is one column, where
|
|
115
|
+
// a span would overflow the grid rather than widen anything.
|
|
116
|
+
gridColumn: { md: tileGridColumn(tile, columns) },
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
{renderTile(tile, index)}
|
|
120
|
+
</Box>
|
|
121
|
+
))}
|
|
122
|
+
</Box>
|
|
123
|
+
);
|
|
124
|
+
}
|