@malloy-publisher/sdk 0.9.13 → 0.9.15
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-BClN_PG6.cjs.js +154 -0
- package/dist/{RenderedResult-DnBtf-cI.es.js → RenderedResult-YBzVMVH2.es.js} +295 -234
- package/dist/{ServerProvider-BV7IoDMR.es.js → ServerProvider-D7neZcTk.es.js} +283 -265
- package/dist/ServerProvider-e2369oom.cjs.js +1 -0
- package/dist/builder/index.cjs.js +80 -79
- package/dist/builder/index.es.js +7430 -6548
- package/dist/client/api.d.ts +30 -6
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +49 -1
- package/dist/components/Dashboard/DashboardTile.d.ts +5 -2
- package/dist/components/Dashboard/DashboardView.d.ts +9 -2
- package/dist/components/Dashboard/index.d.ts +1 -1
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +5 -7
- package/dist/components/Dashboard/useStuck.d.ts +18 -12
- package/dist/components/RenderedResult/RenderedResult.d.ts +3 -2
- package/dist/components/RenderedResult/ResultContainer.d.ts +11 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +5 -1
- package/dist/components/RenderedResult/chartPresentation.d.ts +15 -0
- package/dist/components/RenderedResult/chartShapeProblem.d.ts +55 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +42 -6
- package/dist/components/Report/Report.d.ts +7 -1
- package/dist/components/Report/ReportPage.d.ts +7 -0
- package/dist/components/Report/layoutRules.d.ts +45 -0
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +2 -1
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +14 -1
- package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
- package/dist/components/ReportBuilder/EditorSurface.d.ts +17 -1
- package/dist/components/ReportBuilder/ReportEditor.d.ts +18 -0
- package/dist/components/ReportBuilder/TileFrame.d.ts +33 -1
- package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
- package/dist/components/ReportBuilder/catalog.d.ts +23 -0
- package/dist/components/ReportBuilder/chartLine.d.ts +38 -5
- package/dist/components/ReportBuilder/controls.d.ts +2 -2
- package/dist/components/ReportBuilder/document.d.ts +53 -5
- package/dist/components/ReportBuilder/imports.d.ts +7 -0
- package/dist/components/ReportBuilder/placement.d.ts +75 -0
- package/dist/components/ReportBuilder/preview.d.ts +59 -10
- package/dist/components/ReportBuilder/sortable.d.ts +3 -1
- package/dist/components/ReportBuilder/useTileHeight.d.ts +39 -0
- package/dist/components/ReportBuilder/useTileReorder.d.ts +27 -3
- package/dist/components/ReportBuilder/useTileResize.d.ts +8 -0
- package/dist/index.cjs.js +7 -7
- package/dist/index.es.js +3328 -3287
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-72YFLeNk.es.js → text-entry-YKJZbRPo.es.js} +2 -2
- package/dist/theme/resolveTheme.d.ts +15 -0
- package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-BGk38oaW.es.js} +5097 -4805
- package/dist/useCompiledDocument-D9t5ry_t.cjs.js +142 -0
- package/dist/utils/blankQuoted.d.ts +15 -0
- package/package.json +1 -1
- package/src/components/Dashboard/DashboardGrid.tsx +127 -10
- package/src/components/Dashboard/DashboardTile.tsx +11 -1
- package/src/components/Dashboard/DashboardView.tsx +63 -10
- package/src/components/Dashboard/TileCard.tsx +6 -0
- package/src/components/Dashboard/index.ts +1 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +19 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +15 -36
- package/src/components/Dashboard/tileHeight.spec.ts +72 -0
- package/src/components/Dashboard/useStuck.ts +76 -28
- package/src/components/Package/NewDocumentDialog.spec.tsx +20 -16
- package/src/components/Package/NewDocumentDialog.tsx +10 -11
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +167 -2
- package/src/components/RenderedResult/RenderedResult.tsx +21 -6
- package/src/components/RenderedResult/ResultContainer.tsx +60 -7
- package/src/components/RenderedResult/ResultPanel.tsx +21 -1
- package/src/components/RenderedResult/chartPresentation.spec.ts +153 -0
- package/src/components/RenderedResult/chartPresentation.ts +166 -0
- package/src/components/RenderedResult/chartShapeProblem.spec.tsx +245 -0
- package/src/components/RenderedResult/chartShapeProblem.ts +219 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +75 -3
- package/src/components/RenderedResult/resultSizing.ts +65 -11
- package/src/components/Report/Report.spec.tsx +19 -0
- package/src/components/Report/Report.tsx +8 -1
- package/src/components/Report/ReportPage.tsx +13 -1
- package/src/components/Report/layoutRules.spec.ts +43 -3
- package/src/components/Report/layoutRules.ts +70 -0
- package/src/components/Report/tileOverflow.spec.tsx +162 -0
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +2 -2
- package/src/components/ReportBuilder/AddTileDialog.tsx +11 -6
- package/src/components/ReportBuilder/BuilderBar.tsx +1 -1
- package/src/components/ReportBuilder/BuilderDialogs.tsx +20 -0
- package/src/components/ReportBuilder/BuilderGrid.tsx +126 -20
- package/src/components/ReportBuilder/ChartPicker.spec.ts +91 -4
- package/src/components/ReportBuilder/ChartPicker.tsx +45 -10
- package/src/components/ReportBuilder/DrillDialog.tsx +8 -2
- package/src/components/ReportBuilder/EditorSurface.tsx +110 -28
- package/src/components/ReportBuilder/FilterDialog.tsx +17 -8
- package/src/components/ReportBuilder/FilterStrip.tsx +2 -1
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +193 -2
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +2 -2
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +143 -2
- package/src/components/ReportBuilder/ReportBuilder.tsx +73 -19
- package/src/components/ReportBuilder/ReportEditor.fileModel.spec.tsx +178 -0
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +3 -5
- package/src/components/ReportBuilder/ReportEditor.queryVersion.spec.tsx +292 -0
- package/src/components/ReportBuilder/ReportEditor.readOnlyTitle.spec.tsx +92 -0
- package/src/components/ReportBuilder/ReportEditor.tsx +35 -0
- package/src/components/ReportBuilder/TileFrame.tsx +251 -6
- package/src/components/ReportBuilder/TileMenu.tsx +259 -20
- package/src/components/ReportBuilder/ViewPicker.tsx +4 -3
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +34 -0
- package/src/components/ReportBuilder/addTileToDocument.ts +26 -1
- package/src/components/ReportBuilder/catalog.aggregate.spec.ts +137 -1
- package/src/components/ReportBuilder/catalog.ts +90 -37
- package/src/components/ReportBuilder/chartLine.spec.ts +42 -5
- package/src/components/ReportBuilder/chartLine.ts +80 -2
- package/src/components/ReportBuilder/controls.ts +4 -3
- package/src/components/ReportBuilder/document.ts +65 -7
- package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
- package/src/components/ReportBuilder/entryLayout.spec.ts +151 -0
- package/src/components/ReportBuilder/imports.ts +1 -1
- package/src/components/ReportBuilder/invariants.spec.ts +18 -10
- package/src/components/ReportBuilder/layout.ts +3 -0
- package/src/components/ReportBuilder/placement.spec.ts +193 -0
- package/src/components/ReportBuilder/placement.ts +250 -0
- package/src/components/ReportBuilder/preview.shapes.spec.ts +46 -6
- package/src/components/ReportBuilder/preview.spec.ts +151 -11
- package/src/components/ReportBuilder/preview.ts +203 -40
- package/src/components/ReportBuilder/preview.unsaved.compile.spec.ts +190 -0
- package/src/components/ReportBuilder/readDocument.spec.ts +46 -2
- package/src/components/ReportBuilder/readDocument.ts +194 -23
- package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
- package/src/components/ReportBuilder/sortable.tsx +4 -0
- package/src/components/ReportBuilder/spliceDocument.chart.spec.ts +1 -1
- package/src/components/ReportBuilder/spliceDocument.color.spec.ts +80 -0
- package/src/components/ReportBuilder/spliceDocument.colspan.spec.ts +78 -0
- package/src/components/ReportBuilder/spliceDocument.spec.ts +110 -18
- package/src/components/ReportBuilder/spliceDocument.ts +139 -52
- package/src/components/ReportBuilder/statementExtent.spec.ts +3 -3
- package/src/components/ReportBuilder/testing/reportGivenOrder.json +42 -0
- package/src/components/ReportBuilder/textTiles.spec.ts +2 -2
- package/src/components/ReportBuilder/tileDisplayTitle.ts +2 -2
- package/src/components/ReportBuilder/useTileEditing.ts +16 -3
- package/src/components/ReportBuilder/useTileHeight.ts +149 -0
- package/src/components/ReportBuilder/useTileReorder.ts +143 -6
- package/src/components/ReportBuilder/useTileResize.ts +16 -1
- package/src/components/given/FilterButton.spec.tsx +27 -11
- package/src/components/given/FilterButton.tsx +19 -6
- package/src/theme/resolveTheme.spec.ts +72 -1
- package/src/theme/resolveTheme.ts +43 -0
- package/src/utils/blankQuoted.spec.ts +50 -0
- package/src/utils/blankQuoted.ts +32 -0
- package/src/utils/malloyText.ts +2 -1
- package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
- package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
- package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
|
@@ -57,6 +57,23 @@ export function BuilderDialogs({
|
|
|
57
57
|
const menuTile = menuAt && isQueryTile(menuAt) ? menuAt : undefined;
|
|
58
58
|
const menuView = (() => {
|
|
59
59
|
if (!menuTile || !catalog) return undefined;
|
|
60
|
+
// A view this file declares is read off the file's own compiled model:
|
|
61
|
+
// an inline body is in no other model the catalog has.
|
|
62
|
+
const declared = catalog.documentViews
|
|
63
|
+
?.get(menuTile.source ?? "")
|
|
64
|
+
?.get(menuTile.name);
|
|
65
|
+
if (
|
|
66
|
+
declared &&
|
|
67
|
+
editor.document.sources.some((s) => s.name === menuTile.source)
|
|
68
|
+
)
|
|
69
|
+
return declared;
|
|
70
|
+
// An inline or opaque body is not a view of the base source, so a base
|
|
71
|
+
// view that happens to share its name says nothing about its shape.
|
|
72
|
+
if (
|
|
73
|
+
menuTile.declaration.kind === "inline" ||
|
|
74
|
+
menuTile.declaration.kind === "opaque"
|
|
75
|
+
)
|
|
76
|
+
return undefined;
|
|
60
77
|
const base =
|
|
61
78
|
editor.document.sources.find((s) => s.name === menuTile.source)
|
|
62
79
|
?.base ?? menuTile.source;
|
|
@@ -99,6 +116,9 @@ export function BuilderDialogs({
|
|
|
99
116
|
});
|
|
100
117
|
}}
|
|
101
118
|
view={menuView}
|
|
119
|
+
{...(menuView === undefined && menuTile
|
|
120
|
+
? { viewStatus: catalog ? "unlisted" : "loading" }
|
|
121
|
+
: {})}
|
|
102
122
|
onDuplicate={() => {
|
|
103
123
|
if (menu) tiles.duplicate(menu.index);
|
|
104
124
|
}}
|
|
@@ -5,11 +5,17 @@ import { DragDropProvider } from "@dnd-kit/react";
|
|
|
5
5
|
import AddIcon from "@mui/icons-material/Add";
|
|
6
6
|
import { Box, Button } from "@mui/material";
|
|
7
7
|
import type { ReactNode, RefObject } from "react";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
DashboardGrid,
|
|
10
|
+
GRID_GAP_PX,
|
|
11
|
+
isPlaced,
|
|
12
|
+
PLACED_DEFAULT_ROWSPAN,
|
|
13
|
+
} from "../Dashboard/DashboardGrid";
|
|
9
14
|
import type { TileChrome, TileHeadingSlots } from "../Dashboard/TileCard";
|
|
10
|
-
import type
|
|
15
|
+
import { withSpan, type LayoutRules } from "../Report/layoutRules";
|
|
11
16
|
import {
|
|
12
17
|
isQueryTile,
|
|
18
|
+
isReadOnlyTile,
|
|
13
19
|
isTextTile,
|
|
14
20
|
tileKey,
|
|
15
21
|
type DashboardTile,
|
|
@@ -17,13 +23,21 @@ import {
|
|
|
17
23
|
} from "./document";
|
|
18
24
|
import { InlineText } from "./InlineText";
|
|
19
25
|
import { gapId, tileEntry, withGaps } from "./layout";
|
|
26
|
+
import { minRowsOf, rowsOf } from "./placement";
|
|
20
27
|
import { builderSensors } from "./sortable";
|
|
21
28
|
import { TextTileBody } from "./TextTileBody";
|
|
22
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
GapTarget,
|
|
31
|
+
GridGuides,
|
|
32
|
+
RowGuides,
|
|
33
|
+
TileFrame,
|
|
34
|
+
TilePlaceholder,
|
|
35
|
+
} from "./TileFrame";
|
|
23
36
|
import { tileDisplayTitle } from "./tileDisplayTitle";
|
|
24
37
|
import type { ReportEditorHandle } from "./useReportEditor";
|
|
25
38
|
import type { useTileReorder } from "./useTileReorder";
|
|
26
|
-
import type {
|
|
39
|
+
import type { useTileHeight } from "./useTileHeight";
|
|
40
|
+
import { widestFrom, type useTileResize } from "./useTileResize";
|
|
27
41
|
|
|
28
42
|
/**
|
|
29
43
|
* The builder's tiles, on the SAME grid the dashboard renders on, each drawn
|
|
@@ -34,6 +48,9 @@ export function BuilderGrid({
|
|
|
34
48
|
editor,
|
|
35
49
|
reorder,
|
|
36
50
|
resizing,
|
|
51
|
+
sizing,
|
|
52
|
+
place = (tiles) => tiles,
|
|
53
|
+
arrange = true,
|
|
37
54
|
gridBox,
|
|
38
55
|
defaultSpan = 1,
|
|
39
56
|
rules,
|
|
@@ -52,6 +69,18 @@ export function BuilderGrid({
|
|
|
52
69
|
editor: ReportEditorHandle;
|
|
53
70
|
reorder: ReturnType<typeof useTileReorder>;
|
|
54
71
|
resizing: ReturnType<typeof useTileResize>;
|
|
72
|
+
/** The bottom edges: a tile's height, dragged in whole rows. */
|
|
73
|
+
sizing?: ReturnType<typeof useTileHeight>;
|
|
74
|
+
/**
|
|
75
|
+
* The tiles after the one at `index` changed size: on a placed report,
|
|
76
|
+
* whatever it now covers pushed down. Identity elsewhere.
|
|
77
|
+
*/
|
|
78
|
+
place?: (tiles: DashboardTile[], index: number) => DashboardTile[];
|
|
79
|
+
/**
|
|
80
|
+
* Whether tiles can be moved and widened here. Off while a grid is drawn
|
|
81
|
+
* as one column (a window narrower than the grid), where neither shows.
|
|
82
|
+
*/
|
|
83
|
+
arrange?: boolean;
|
|
55
84
|
gridBox: RefObject<HTMLDivElement | null>;
|
|
56
85
|
/** The span a tile with no `# colspan` is drawn at: as wide as the reader draws it. */
|
|
57
86
|
defaultSpan?: number;
|
|
@@ -77,9 +106,11 @@ export function BuilderGrid({
|
|
|
77
106
|
chrome?: TileChrome,
|
|
78
107
|
) => ReactNode;
|
|
79
108
|
}) {
|
|
80
|
-
const { dragging, preview, onDragStart, onDragOver, onDragEnd } =
|
|
109
|
+
const { dragging, preview, onDragStart, onDragMove, onDragOver, onDragEnd } =
|
|
110
|
+
reorder;
|
|
81
111
|
const { columns } = rules;
|
|
82
112
|
const { resize, startResize, onResize, endResize } = resizing;
|
|
113
|
+
const tall = sizing?.height;
|
|
83
114
|
// What the grid lays out: the document, except mid-gesture, where it is
|
|
84
115
|
// the preview — the tile being resized at its previewed width, or the tiles
|
|
85
116
|
// in their previewed order. So the row reflows under the pointer exactly as
|
|
@@ -88,18 +119,32 @@ export function BuilderGrid({
|
|
|
88
119
|
tile.colspan === undefined ? { ...tile, colspan: defaultSpan } : tile;
|
|
89
120
|
const shown = (
|
|
90
121
|
resize !== undefined
|
|
91
|
-
?
|
|
92
|
-
|
|
122
|
+
? place(
|
|
123
|
+
editor.document.tiles.map((each, index) =>
|
|
124
|
+
index === resize.index
|
|
125
|
+
? { ...each, colspan: resize.span }
|
|
126
|
+
: each,
|
|
127
|
+
),
|
|
128
|
+
resize.index,
|
|
93
129
|
)
|
|
94
|
-
:
|
|
130
|
+
: tall !== undefined
|
|
131
|
+
? place(
|
|
132
|
+
editor.document.tiles.map((each, index) =>
|
|
133
|
+
index === tall.index ? withRowspan(each, tall.rows) : each,
|
|
134
|
+
),
|
|
135
|
+
tall.index,
|
|
136
|
+
)
|
|
137
|
+
: (preview ?? editor.document.tiles)
|
|
95
138
|
).map(drawn);
|
|
139
|
+
// Placed, every cell is somewhere to drop, so there are no row ends to offer.
|
|
140
|
+
const placed = isPlaced(shown);
|
|
96
141
|
// And, while a drag is live, the empty end of every row as a drop target.
|
|
97
142
|
// While an edge is dragged too: narrowing a tile frees columns its row-mate
|
|
98
143
|
// does not take, and an undrawn hole there read as a broken layout rather
|
|
99
144
|
// than room to fill. Not otherwise: a gap is only shown mid-gesture.
|
|
100
145
|
const empty = editor.document.tiles.length === 0;
|
|
101
146
|
const entries =
|
|
102
|
-
dragging || resize !== undefined
|
|
147
|
+
(dragging || resize !== undefined) && !placed
|
|
103
148
|
? withGaps(shown, columns)
|
|
104
149
|
: shown.map(tileEntry);
|
|
105
150
|
const heading = (tile: QueryTile) =>
|
|
@@ -109,6 +154,7 @@ export function BuilderGrid({
|
|
|
109
154
|
<DragDropProvider
|
|
110
155
|
sensors={builderSensors}
|
|
111
156
|
onDragStart={onDragStart}
|
|
157
|
+
onDragMove={onDragMove}
|
|
112
158
|
onDragOver={onDragOver}
|
|
113
159
|
onDragEnd={onDragEnd}
|
|
114
160
|
>
|
|
@@ -116,11 +162,23 @@ export function BuilderGrid({
|
|
|
116
162
|
{rules.widths && (dragging || resize !== undefined) && (
|
|
117
163
|
<GridGuides columns={columns} />
|
|
118
164
|
)}
|
|
165
|
+
{tall !== undefined ? (
|
|
166
|
+
<RowGuides top={tall.guideTop} />
|
|
167
|
+
) : (
|
|
168
|
+
// Placed, a move snaps to rows as well as columns.
|
|
169
|
+
placed &&
|
|
170
|
+
(dragging || resize !== undefined) && <RowGuides top={0} />
|
|
171
|
+
)}
|
|
119
172
|
|
|
120
173
|
<DashboardGrid
|
|
121
174
|
tiles={entries}
|
|
122
175
|
columns={columns}
|
|
123
176
|
rowGapPx={GRID_GAP_PX}
|
|
177
|
+
defaultRowspan={(entry) =>
|
|
178
|
+
entry.kind === "tile"
|
|
179
|
+
? rowsOf(entry.tile)
|
|
180
|
+
: PLACED_DEFAULT_ROWSPAN.query
|
|
181
|
+
}
|
|
124
182
|
keyOf={(entry) =>
|
|
125
183
|
entry.kind === "gap"
|
|
126
184
|
? gapId(entry.after)
|
|
@@ -149,17 +207,34 @@ export function BuilderGrid({
|
|
|
149
207
|
onInsertAfter: () => openAdd(index + 1),
|
|
150
208
|
}
|
|
151
209
|
: {})}
|
|
152
|
-
{
|
|
210
|
+
fixed={!arrange}
|
|
211
|
+
{...(rules.widths && arrange
|
|
153
212
|
? {
|
|
154
213
|
resizing: resize?.index === index,
|
|
155
214
|
width: {
|
|
156
215
|
span: each.colspan ?? 1,
|
|
157
216
|
columns,
|
|
217
|
+
max: widestFrom(each, columns),
|
|
158
218
|
onStep: (to: number) => {
|
|
159
219
|
if (to === (each.colspan ?? 1)) return;
|
|
160
220
|
editor.update((draft) => {
|
|
221
|
+
if (
|
|
222
|
+
!Number.isInteger(index) ||
|
|
223
|
+
index < 0
|
|
224
|
+
)
|
|
225
|
+
return;
|
|
161
226
|
const tile = draft.tiles[index];
|
|
162
|
-
if (tile)
|
|
227
|
+
if (tile)
|
|
228
|
+
draft.tiles[index] = withSpan(
|
|
229
|
+
tile,
|
|
230
|
+
to,
|
|
231
|
+
columns,
|
|
232
|
+
defaultSpan,
|
|
233
|
+
);
|
|
234
|
+
draft.tiles = place(
|
|
235
|
+
draft.tiles,
|
|
236
|
+
index,
|
|
237
|
+
);
|
|
163
238
|
});
|
|
164
239
|
},
|
|
165
240
|
},
|
|
@@ -169,6 +244,36 @@ export function BuilderGrid({
|
|
|
169
244
|
onResizeEnd: endResize,
|
|
170
245
|
}
|
|
171
246
|
: {})}
|
|
247
|
+
{...(rules.widths && sizing
|
|
248
|
+
? {
|
|
249
|
+
heightEdge: {
|
|
250
|
+
rows: each.rowspan,
|
|
251
|
+
dragging: tall?.index === index,
|
|
252
|
+
min: minRowsOf(each),
|
|
253
|
+
onStart: (event) =>
|
|
254
|
+
sizing.startHeight(event, index),
|
|
255
|
+
onMove: sizing.onHeight,
|
|
256
|
+
onEnd: sizing.endHeight,
|
|
257
|
+
onStep: (to) =>
|
|
258
|
+
editor.update((draft) => {
|
|
259
|
+
if (
|
|
260
|
+
!Number.isInteger(index) ||
|
|
261
|
+
index < 0
|
|
262
|
+
)
|
|
263
|
+
return;
|
|
264
|
+
const tile = draft.tiles[index];
|
|
265
|
+
if (!tile) return;
|
|
266
|
+
if (to === undefined)
|
|
267
|
+
delete tile.rowspan;
|
|
268
|
+
else tile.rowspan = to;
|
|
269
|
+
draft.tiles = place(
|
|
270
|
+
draft.tiles,
|
|
271
|
+
index,
|
|
272
|
+
);
|
|
273
|
+
}),
|
|
274
|
+
},
|
|
275
|
+
}
|
|
276
|
+
: {})}
|
|
172
277
|
onSelect={() => onSelect(index)}
|
|
173
278
|
onOpenMenu={(anchor) => onOpenMenu(anchor, index)}
|
|
174
279
|
onRemove={() => onRemove(index)}
|
|
@@ -213,13 +318,22 @@ export function BuilderGrid({
|
|
|
213
318
|
);
|
|
214
319
|
}
|
|
215
320
|
|
|
321
|
+
/** A tile at a dragged height: its rows, or auto with no `rowspan` at all. */
|
|
322
|
+
const withRowspan = (
|
|
323
|
+
tile: DashboardTile,
|
|
324
|
+
rows: number | undefined,
|
|
325
|
+
): DashboardTile => {
|
|
326
|
+
const { rowspan: _rowspan, ...rest } = tile;
|
|
327
|
+
return rows === undefined ? rest : { ...rest, rowspan: rows };
|
|
328
|
+
};
|
|
329
|
+
|
|
216
330
|
/** A query tile's title and subtitle as fields on the tile, unless the model owns them. */
|
|
217
331
|
const headingOf = (
|
|
218
332
|
tile: QueryTile,
|
|
219
333
|
fallback: string,
|
|
220
334
|
editTile: (key: string, change: (tile: DashboardTile) => void) => void,
|
|
221
335
|
): TileHeadingSlots | undefined => {
|
|
222
|
-
if (tile
|
|
336
|
+
if (isReadOnlyTile(tile)) return undefined;
|
|
223
337
|
const key = tileKey(tile);
|
|
224
338
|
const set = (field: "label" | "subtitle") => (next: string) =>
|
|
225
339
|
editTile(key, (each) => {
|
|
@@ -247,11 +361,3 @@ const headingOf = (
|
|
|
247
361
|
),
|
|
248
362
|
};
|
|
249
363
|
};
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Whether dragging this tile's edge can be saved: its width is a tag this file
|
|
253
|
-
* owns. An inherited tile's tags live on the model's view, which the builder
|
|
254
|
-
* does not write.
|
|
255
|
-
*/
|
|
256
|
-
const resizable = (tile: DashboardTile): boolean =>
|
|
257
|
-
isTextTile(tile) || tile.declaration.kind !== "inherited";
|
|
@@ -27,6 +27,7 @@ describe("chartChoices", () => {
|
|
|
27
27
|
"scatter_chart",
|
|
28
28
|
"shape_map",
|
|
29
29
|
"segment_map",
|
|
30
|
+
"combo_chart",
|
|
30
31
|
]);
|
|
31
32
|
expect(enabled(undefined, "default")).toEqual([
|
|
32
33
|
"default",
|
|
@@ -37,13 +38,21 @@ describe("chartChoices", () => {
|
|
|
37
38
|
]);
|
|
38
39
|
});
|
|
39
40
|
|
|
41
|
+
it("names the model's own chart Default, with a quiet line saying where it is set", () => {
|
|
42
|
+
expect(chartChoices(undefined, "default")[0]).toEqual({
|
|
43
|
+
value: "default",
|
|
44
|
+
label: "Default",
|
|
45
|
+
hint: "As set in the model",
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
40
49
|
it("enables big_value only for an aggregate-only view, and says what it needs otherwise", () => {
|
|
41
50
|
expect(enabled({ aggregateOnly: true }, "default")).toContain(
|
|
42
51
|
"big_value",
|
|
43
52
|
);
|
|
44
53
|
expect(choice("big_value", {}, "default")).toMatchObject({
|
|
45
54
|
disabled: true,
|
|
46
|
-
reason: "Needs
|
|
55
|
+
reason: "Needs results that are only totals (no group by)",
|
|
47
56
|
});
|
|
48
57
|
});
|
|
49
58
|
|
|
@@ -56,16 +65,31 @@ describe("chartChoices", () => {
|
|
|
56
65
|
choice("shape_map", { chart: "bar_chart" }, "default"),
|
|
57
66
|
).toMatchObject({
|
|
58
67
|
disabled: true,
|
|
59
|
-
reason: "Needs a
|
|
68
|
+
reason: "Needs a map chart set in the model",
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("enables a combo chart for a view with a group by and exactly two totals, and says what it needs otherwise", () => {
|
|
73
|
+
expect(
|
|
74
|
+
enabled({ shape: { groupBys: 1, totals: 2 } }, "default"),
|
|
75
|
+
).toContain("combo_chart");
|
|
76
|
+
expect(enabled({ chart: "combo_chart" }, "default")).toContain(
|
|
77
|
+
"combo_chart",
|
|
78
|
+
);
|
|
79
|
+
expect(choice("combo_chart", {}, "default")).toMatchObject({
|
|
80
|
+
label: "Bar and line",
|
|
81
|
+
disabled: true,
|
|
82
|
+
reason:
|
|
83
|
+
"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line",
|
|
60
84
|
});
|
|
61
85
|
});
|
|
62
86
|
|
|
63
87
|
it("words the reason by why the view's shape is unknown", () => {
|
|
64
88
|
expect(choice("big_value", undefined, "default", "loading").reason).toBe(
|
|
65
|
-
"Still loading this
|
|
89
|
+
"Still loading this tile's details",
|
|
66
90
|
);
|
|
67
91
|
expect(choice("shape_map", undefined, "default", "unlisted").reason).toBe(
|
|
68
|
-
"Not
|
|
92
|
+
"Not in the model's list, so its shape is unknown",
|
|
69
93
|
);
|
|
70
94
|
});
|
|
71
95
|
|
|
@@ -75,3 +99,66 @@ describe("chartChoices", () => {
|
|
|
75
99
|
expect(values({}, "custom")).toContain("custom");
|
|
76
100
|
});
|
|
77
101
|
});
|
|
102
|
+
|
|
103
|
+
describe("chartChoices on a view whose shape the model reported", () => {
|
|
104
|
+
const totalsOnly = {
|
|
105
|
+
aggregateOnly: true,
|
|
106
|
+
shape: { groupBys: 0, totals: 3 },
|
|
107
|
+
} as const;
|
|
108
|
+
|
|
109
|
+
it("greys out every chart that plots rows on a view of totals only, saying what is missing", () => {
|
|
110
|
+
// A scatter chart plots the first two columns, so two totals draw.
|
|
111
|
+
expect(enabled(totalsOnly, "default")).toEqual([
|
|
112
|
+
"default",
|
|
113
|
+
"none",
|
|
114
|
+
"big_value",
|
|
115
|
+
"scatter_chart",
|
|
116
|
+
]);
|
|
117
|
+
for (const pick of ["line_chart", "bar_chart"])
|
|
118
|
+
expect(choice(pick, totalsOnly, "default").reason).toMatch(
|
|
119
|
+
/^This view has no field for the x-axis: a .* chart needs a group by, such as a date or a category$/,
|
|
120
|
+
);
|
|
121
|
+
const oneTotal = {
|
|
122
|
+
aggregateOnly: true,
|
|
123
|
+
shape: { groupBys: 0, totals: 1 },
|
|
124
|
+
};
|
|
125
|
+
expect(choice("scatter_chart", oneTotal, "default").reason).toBe(
|
|
126
|
+
"This view has no field for the x-axis: a scatter chart needs a group by, such as a date or a category",
|
|
127
|
+
);
|
|
128
|
+
expect(choice("combo_chart", totalsOnly, "default").reason).toBe(
|
|
129
|
+
"This view has no field for the x-axis: a bar and line chart needs a group by, such as a date or a category",
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("says a grouped view is more than one row when big numbers are asked for", () => {
|
|
134
|
+
const grouped = { shape: { groupBys: 1, totals: 1 } };
|
|
135
|
+
expect(choice("big_value", grouped, "default").reason).toBe(
|
|
136
|
+
"This view has a group by, so it is more than one row; big numbers need a view of totals only",
|
|
137
|
+
);
|
|
138
|
+
expect(enabled(grouped, "default")).toContain("line_chart");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("says a view with no total has nothing for the y-axis", () => {
|
|
142
|
+
const noTotals = { shape: { groupBys: 2, totals: 0 } };
|
|
143
|
+
expect(choice("bar_chart", noTotals, "default").reason).toBe(
|
|
144
|
+
"This view has no total for the y-axis: a bar chart needs at least one aggregate",
|
|
145
|
+
);
|
|
146
|
+
// A scatter chart may plot two group-bys against each other, as the
|
|
147
|
+
// result panel also allows.
|
|
148
|
+
expect(enabled(noTotals, "default")).toContain("scatter_chart");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("does not say a view of totals and a nest has a group by", () => {
|
|
152
|
+
const nested = { shape: { groupBys: 0, totals: 1 } };
|
|
153
|
+
expect(choice("big_value", nested, "default").reason).toBe(
|
|
154
|
+
"Needs results that are only totals (no group by)",
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("names the count when a bar and line chart gets the wrong number of totals", () => {
|
|
159
|
+
const three = { shape: { groupBys: 1, totals: 3 } };
|
|
160
|
+
expect(choice("combo_chart", three, "default").reason).toBe(
|
|
161
|
+
"A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has 3",
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -5,6 +5,7 @@ import { ListItemText, MenuItem, TextField } from "@mui/material";
|
|
|
5
5
|
import { useId } from "react";
|
|
6
6
|
import type { CatalogView } from "./catalog";
|
|
7
7
|
import type { ChartPick, ChartState } from "./chartLine";
|
|
8
|
+
import { chartShapeGap } from "../RenderedResult/chartShapeProblem";
|
|
8
9
|
|
|
9
10
|
export interface ChartChoice {
|
|
10
11
|
value: ChartState;
|
|
@@ -12,8 +13,14 @@ export interface ChartChoice {
|
|
|
12
13
|
/** Listed but not pickable; `reason` says what the view would need. */
|
|
13
14
|
disabled?: boolean;
|
|
14
15
|
reason?: string;
|
|
16
|
+
/** A quiet second line on a choice that can be picked: what it means. */
|
|
17
|
+
hint?: string;
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
/** The reason a chart that plots rows cannot draw a view with no group-by: said in the reader's words, not the renderer's. */
|
|
21
|
+
const NO_X_AXIS = (chart: string) =>
|
|
22
|
+
`This view has no field for the x-axis: ${chart.toLowerCase()} needs a group by, such as a date or a category`;
|
|
23
|
+
|
|
17
24
|
/** Why a view is absent, so the reason on a disabled choice says whether to wait or to pick another. */
|
|
18
25
|
export type ViewStatus = "loading" | "unlisted";
|
|
19
26
|
|
|
@@ -24,6 +31,7 @@ const LABELS: Record<ChartPick, string> = {
|
|
|
24
31
|
scatter_chart: "Scatter",
|
|
25
32
|
shape_map: "Shape map",
|
|
26
33
|
segment_map: "Segment map",
|
|
34
|
+
combo_chart: "Bar and line",
|
|
27
35
|
};
|
|
28
36
|
|
|
29
37
|
/**
|
|
@@ -31,7 +39,7 @@ const LABELS: Record<ChartPick, string> = {
|
|
|
31
39
|
* Whatever the cell has now stays selectable, so the select never shows a value it does not offer.
|
|
32
40
|
*/
|
|
33
41
|
export function chartChoices(
|
|
34
|
-
view: Pick<CatalogView, "chart" | "aggregateOnly"> | undefined,
|
|
42
|
+
view: Pick<CatalogView, "chart" | "aggregateOnly" | "shape"> | undefined,
|
|
35
43
|
current: ChartState,
|
|
36
44
|
viewStatus?: ViewStatus,
|
|
37
45
|
): ChartChoice[] {
|
|
@@ -39,21 +47,45 @@ export function chartChoices(
|
|
|
39
47
|
view !== undefined
|
|
40
48
|
? undefined
|
|
41
49
|
: viewStatus === "loading"
|
|
42
|
-
? "Still loading this
|
|
50
|
+
? "Still loading this tile's details"
|
|
43
51
|
: viewStatus === "unlisted"
|
|
44
|
-
? "Not
|
|
52
|
+
? "Not in the model's list, so its shape is unknown"
|
|
45
53
|
: undefined;
|
|
54
|
+
const shape = view?.shape;
|
|
46
55
|
const reasonFor = (pick: ChartPick): string | undefined => {
|
|
47
56
|
if (current === pick) return undefined;
|
|
48
57
|
if (pick === "big_value")
|
|
49
58
|
return view?.aggregateOnly === true
|
|
50
59
|
? undefined
|
|
51
|
-
:
|
|
60
|
+
: shape && shape.groupBys > 0
|
|
61
|
+
? "This view has a group by, so it is more than one row; big numbers need a view of totals only"
|
|
62
|
+
: (unknown ?? "Needs results that are only totals (no group by)");
|
|
52
63
|
if (pick === "shape_map" || pick === "segment_map")
|
|
53
64
|
return view?.chart === pick
|
|
54
65
|
? undefined
|
|
55
|
-
: (unknown ?? "Needs a
|
|
56
|
-
return undefined;
|
|
66
|
+
: (unknown ?? "Needs a map chart set in the model");
|
|
67
|
+
if (view?.chart === pick) return undefined;
|
|
68
|
+
// The charts that plot rows, by the same rule the result panel applies.
|
|
69
|
+
// An unknown shape leaves them pickable, since nothing says they cannot
|
|
70
|
+
// draw, except a bar and line chart, which few views can fill: a bare
|
|
71
|
+
// `# combo_chart` draws the first total as bars on the left axis and the
|
|
72
|
+
// second as a line on the right, and any other count is an error.
|
|
73
|
+
if (!shape)
|
|
74
|
+
return pick === "combo_chart"
|
|
75
|
+
? (unknown ??
|
|
76
|
+
"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line")
|
|
77
|
+
: undefined;
|
|
78
|
+
const chart = `A ${LABELS[pick].toLowerCase()} chart`;
|
|
79
|
+
switch (chartShapeGap(pick, shape)) {
|
|
80
|
+
case "no_x_axis":
|
|
81
|
+
return NO_X_AXIS(chart);
|
|
82
|
+
case "combo_totals":
|
|
83
|
+
return `A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has ${shape.totals}`;
|
|
84
|
+
case "no_y_axis":
|
|
85
|
+
return `This view has no total for the y-axis: ${chart.toLowerCase()} needs at least one aggregate`;
|
|
86
|
+
default:
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
57
89
|
};
|
|
58
90
|
const picks: ChartPick[] = [
|
|
59
91
|
"line_chart",
|
|
@@ -62,9 +94,10 @@ export function chartChoices(
|
|
|
62
94
|
"scatter_chart",
|
|
63
95
|
"shape_map",
|
|
64
96
|
"segment_map",
|
|
97
|
+
"combo_chart",
|
|
65
98
|
];
|
|
66
99
|
return [
|
|
67
|
-
{ value: "default", label: "
|
|
100
|
+
{ value: "default", label: "Default", hint: "As set in the model" },
|
|
68
101
|
{ value: "none", label: "Table" },
|
|
69
102
|
...picks.map((pick): ChartChoice => {
|
|
70
103
|
const reason = reasonFor(pick);
|
|
@@ -92,7 +125,7 @@ export function ChartPicker({
|
|
|
92
125
|
}: {
|
|
93
126
|
state: ChartState;
|
|
94
127
|
/** The catalog's view this cell runs, when it is one the catalog knows. */
|
|
95
|
-
view: Pick<CatalogView, "chart" | "aggregateOnly"> | undefined;
|
|
128
|
+
view: Pick<CatalogView, "chart" | "aggregateOnly" | "shape"> | undefined;
|
|
96
129
|
/** Why `view` is absent, worded into the reasons on the charts that need its shape. */
|
|
97
130
|
viewStatus?: ViewStatus;
|
|
98
131
|
/** Which cell this is, so the control is named apart from its neighbours. */
|
|
@@ -125,7 +158,7 @@ export function ChartPicker({
|
|
|
125
158
|
FormHelperTextProps={{ id: reasonId }}
|
|
126
159
|
SelectProps={{
|
|
127
160
|
...(onOpen ? { onOpen } : {}),
|
|
128
|
-
// The menu items carry a reason line; the closed field shows the label alone.
|
|
161
|
+
// The menu items carry a reason or hint line; the closed field shows the label alone.
|
|
129
162
|
renderValue: (value) =>
|
|
130
163
|
choices.find((choice) => choice.value === value)?.label ??
|
|
131
164
|
String(value),
|
|
@@ -147,7 +180,9 @@ export function ChartPicker({
|
|
|
147
180
|
>
|
|
148
181
|
<ListItemText
|
|
149
182
|
primary={choice.label}
|
|
150
|
-
{...(choice.reason
|
|
183
|
+
{...((choice.reason ?? choice.hint)
|
|
184
|
+
? { secondary: choice.reason ?? choice.hint }
|
|
185
|
+
: {})}
|
|
151
186
|
/>
|
|
152
187
|
</MenuItem>
|
|
153
188
|
))}
|
|
@@ -153,8 +153,14 @@ export function DrillDialog({
|
|
|
153
153
|
{tileLabel} ·{" "}
|
|
154
154
|
</Box>
|
|
155
155
|
)}
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
{/* The renderer reports a click on a table cell and on nothing
|
|
157
|
+
a chart draws, and the builder renders its tiles with no
|
|
158
|
+
click handling at all, because a press there selects the
|
|
159
|
+
tile. Both are said here, or the setting looks broken. */}
|
|
160
|
+
A click on a table cell sets a filter to its value, on this
|
|
161
|
+
report or on the one it opens. Bars, lines and points on a chart
|
|
162
|
+
do not respond to a click. Clicks work in the report, not while
|
|
163
|
+
you edit it.
|
|
158
164
|
</>
|
|
159
165
|
}
|
|
160
166
|
actions={
|