@malloy-publisher/sdk 0.9.14 → 0.9.16
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-5hOs5XnV.cjs.js +171 -0
- package/dist/RenderedResult-DxmHGZNQ.es.js +671 -0
- 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 +7732 -6717
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +31 -7
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +51 -1
- package/dist/components/Dashboard/DashboardTile.d.ts +7 -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 +18 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +7 -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 +47 -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/ArrangeMenu.d.ts +9 -0
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +15 -4
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +3 -1
- package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
- package/dist/components/ReportBuilder/EditorSurface.d.ts +10 -1
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +1 -1
- package/dist/components/ReportBuilder/TileFrame.d.ts +54 -10
- package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
- package/dist/components/ReportBuilder/builderControls.d.ts +19 -0
- 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 +121 -0
- package/dist/components/ReportBuilder/preview.d.ts +59 -10
- package/dist/components/ReportBuilder/sortable.d.ts +12 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +1 -1
- package/dist/components/ReportBuilder/useBuilderShortcuts.d.ts +9 -1
- package/dist/components/ReportBuilder/useEdgeResize.d.ts +84 -0
- package/dist/components/ReportBuilder/useTileReorder.d.ts +30 -3
- package/dist/index.cjs.js +7 -7
- package/dist/index.es.js +3349 -3307
- 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/classes.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +15 -0
- package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-CaYP_OYG.es.js} +6353 -6047
- package/dist/useCompiledDocument-zYEfLogf.cjs.js +142 -0
- package/dist/utils/blankQuoted.d.ts +15 -0
- package/package.json +1 -1
- package/src/builder-entry.ts +1 -0
- package/src/components/Dashboard/DashboardGrid.tsx +129 -10
- package/src/components/Dashboard/DashboardTile.tsx +15 -1
- package/src/components/Dashboard/DashboardView.tsx +64 -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 +39 -6
- package/src/components/RenderedResult/ResultContainer.tsx +99 -10
- package/src/components/RenderedResult/ResultPanel.tsx +25 -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 +71 -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/ArrangeMenu.tsx +80 -0
- package/src/components/ReportBuilder/BuilderBar.tsx +5 -1
- package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -1
- package/src/components/ReportBuilder/BuilderGrid.tsx +142 -35
- package/src/components/ReportBuilder/BuilderToolbar.tsx +4 -0
- 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 +101 -20
- 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 +242 -2
- package/src/components/ReportBuilder/ReportBuilder.tsx +161 -27
- 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.readOnlyTitle.spec.tsx +92 -0
- package/src/components/ReportBuilder/ReportEditor.tsx +13 -0
- package/src/components/ReportBuilder/TileFrame.tsx +366 -170
- 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/builderControls.ts +34 -0
- 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 +401 -0
- package/src/components/ReportBuilder/placement.ts +416 -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 +53 -19
- package/src/components/ReportBuilder/readDocument.ts +197 -29
- package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
- package/src/components/ReportBuilder/sortable.tsx +30 -2
- 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 -58
- package/src/components/ReportBuilder/spliceDocument.ts +139 -91
- 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/useBuilderSession.ts +7 -2
- package/src/components/ReportBuilder/useBuilderShortcuts.ts +25 -1
- package/src/components/ReportBuilder/useEdgeResize.spec.tsx +324 -0
- package/src/components/ReportBuilder/useEdgeResize.ts +397 -0
- package/src/components/ReportBuilder/useTileEditing.ts +16 -3
- package/src/components/ReportBuilder/useTileReorder.ts +143 -6
- package/src/components/given/FilterButton.spec.tsx +27 -11
- package/src/components/given/FilterButton.tsx +19 -6
- package/src/theme/classes.ts +1 -1
- 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-DnBtf-cI.es.js +0 -593
- package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
- package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
- package/dist/components/ReportBuilder/useTileResize.d.ts +0 -32
- package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
- package/src/components/ReportBuilder/useTileResize.spec.tsx +0 -146
- package/src/components/ReportBuilder/useTileResize.ts +0 -133
|
@@ -95,7 +95,7 @@ export interface DashboardDrill {
|
|
|
95
95
|
/**
|
|
96
96
|
* Where a tile's view is declared, and therefore what the builder may edit.
|
|
97
97
|
*
|
|
98
|
-
*
|
|
98
|
+
* Five forms, all of them found in dashboards that ship in this repository, and
|
|
99
99
|
* the distinction decides which affordances a tile gets:
|
|
100
100
|
*
|
|
101
101
|
* - `reference` — `view: revenue_trend is sales_by_month` in this file. Fully
|
|
@@ -117,12 +117,19 @@ export interface DashboardDrill {
|
|
|
117
117
|
* tile is `orders -> by_brand` against an imported source. Nothing about it is
|
|
118
118
|
* editable here, because its tags live on the model's own view and the builder
|
|
119
119
|
* does not write model files. Read and shown, not changed.
|
|
120
|
+
* - `query` — the entry names a query rather than a view: `tiles=["by_carrier"]`
|
|
121
|
+
* over a `query: by_carrier is flights -> { … }`, in this file or the model.
|
|
122
|
+
* The tile runs `run: by_carrier`, exactly as the reader does, and has no
|
|
123
|
+
* `source` of its own. Like `inherited` it is read and shown, and moved or
|
|
124
|
+
* removed in the list, but not changed: its tags sit on a `query:` statement
|
|
125
|
+
* the writer does not locate, and its body may be anything a query can be.
|
|
120
126
|
*/
|
|
121
127
|
export type TileDeclaration =
|
|
122
128
|
| { kind: "reference"; from: string }
|
|
123
129
|
| { kind: "inline" }
|
|
124
130
|
| { kind: "opaque"; why: string }
|
|
125
|
-
| { kind: "inherited" }
|
|
131
|
+
| { kind: "inherited" }
|
|
132
|
+
| { kind: "query" };
|
|
126
133
|
|
|
127
134
|
/** A tile that runs a view: a view shown on the page, plus how it is presented. */
|
|
128
135
|
export interface QueryTile {
|
|
@@ -138,9 +145,10 @@ export interface QueryTile {
|
|
|
138
145
|
/**
|
|
139
146
|
* The source it reads, by NAME — an index would break on reorder. May name a
|
|
140
147
|
* source this file declares in {@link DashboardDocument.sources}, or one it
|
|
141
|
-
* merely imports.
|
|
148
|
+
* merely imports. Absent on a tile that names a query (`declaration.kind`
|
|
149
|
+
* `"query"`), whose source is whatever the query's own definition reads.
|
|
142
150
|
*/
|
|
143
|
-
source
|
|
151
|
+
source?: string;
|
|
144
152
|
declaration: TileDeclaration;
|
|
145
153
|
/**
|
|
146
154
|
* Given bindings: a `+ { where: … }` refinement on a `reference` tile, or a
|
|
@@ -166,15 +174,39 @@ export interface QueryTile {
|
|
|
166
174
|
chartLines?: string[];
|
|
167
175
|
/** The chart tags the tile's view carries, when the catalog knows them: the writer negates only these. Never read from a file. */
|
|
168
176
|
chartCarried?: string[];
|
|
177
|
+
/**
|
|
178
|
+
* Where the tile sits: its entry's `colspan` and `break` in `tiles=[…]`,
|
|
179
|
+
* or else its view's `# colspan` and `# break`. The writer puts a changed
|
|
180
|
+
* layout on the entry, which every tile has, and takes the view's two tags
|
|
181
|
+
* off a view this file declares, so the layout has one home.
|
|
182
|
+
*/
|
|
169
183
|
colspan?: number;
|
|
170
184
|
break?: boolean;
|
|
185
|
+
/** `rowspan=N` on its entry: the grid rows it is tall. Only the entry carries it. */
|
|
186
|
+
rowspan?: number;
|
|
187
|
+
/** `row=N` and `col=N` on its entry: where it sits on a placed report, counted from 1. */
|
|
188
|
+
row?: number;
|
|
189
|
+
col?: number;
|
|
171
190
|
borderless?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* The chart's colour, `#rrggbb`: its first series colour, written as the
|
|
193
|
+
* per-chart theme line `# theme.palette.series=["#…"]` the renderer reads.
|
|
194
|
+
* Absent, the chart takes the theme's own series.
|
|
195
|
+
*/
|
|
196
|
+
color?: string;
|
|
197
|
+
/**
|
|
198
|
+
* The tile's own tags set `theme.palette.series` in a line the builder did
|
|
199
|
+
* not write: a list of two or more colours, or any other spelling. Read from
|
|
200
|
+
* the file, never written. The preview keeps that line when the tile is on
|
|
201
|
+
* Theme, where it otherwise takes a saved builder colour off.
|
|
202
|
+
*/
|
|
203
|
+
ownPalette?: true;
|
|
172
204
|
}
|
|
173
205
|
|
|
174
206
|
/**
|
|
175
207
|
* A markdown tile: prose between the query tiles, written as a `##|(markdown) <name>` block
|
|
176
|
-
* and listed in `tiles=[…]` as `<name> { kind=text }`. Its
|
|
177
|
-
*
|
|
208
|
+
* and listed in `tiles=[…]` as `<name> { kind=text }`. Its layout lives on that list entry,
|
|
209
|
+
* as every tile's does.
|
|
178
210
|
*/
|
|
179
211
|
export interface TextTile {
|
|
180
212
|
kind: "text";
|
|
@@ -183,6 +215,9 @@ export interface TextTile {
|
|
|
183
215
|
markdown: string;
|
|
184
216
|
colspan?: number;
|
|
185
217
|
break?: boolean;
|
|
218
|
+
rowspan?: number;
|
|
219
|
+
row?: number;
|
|
220
|
+
col?: number;
|
|
186
221
|
}
|
|
187
222
|
|
|
188
223
|
export type DashboardTile = QueryTile | TextTile;
|
|
@@ -227,9 +262,32 @@ export interface DashboardSource {
|
|
|
227
262
|
scopedBy?: string[];
|
|
228
263
|
}
|
|
229
264
|
|
|
265
|
+
/**
|
|
266
|
+
* What a query tile runs, as its `tiles=[…]` entry names it: `source -> view`,
|
|
267
|
+
* or a query's bare name. The one spelling every preview, served-tile lookup
|
|
268
|
+
* and new list entry derives from.
|
|
269
|
+
*/
|
|
270
|
+
export const tileExpression = (tile: QueryTile): string =>
|
|
271
|
+
tile.declaration.kind === "query"
|
|
272
|
+
? tile.name
|
|
273
|
+
: `${tile.source} -> ${tile.name}`;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Whether the builder can write nothing about this tile but its place in the
|
|
277
|
+
* list: declared on the model's view (`inherited`), or a named query, whose
|
|
278
|
+
* tags are on a `query:` statement the writer does not edit.
|
|
279
|
+
*/
|
|
280
|
+
export const isReadOnlyTile = (tile: QueryTile): boolean =>
|
|
281
|
+
tile.declaration.kind === "inherited" || tile.declaration.kind === "query";
|
|
282
|
+
|
|
230
283
|
/** A tile's identity across a reorder: what the grid keys on, a drag names and the writer matches. */
|
|
231
284
|
export const tileKey = (tile: DashboardTile) =>
|
|
232
|
-
isTextTile(tile)
|
|
285
|
+
isTextTile(tile)
|
|
286
|
+
? `text.${tile.name}`
|
|
287
|
+
: tile.declaration.kind === "query"
|
|
288
|
+
? // `query` is a Malloy keyword, so no source can carry this prefix.
|
|
289
|
+
`query.${tile.name}`
|
|
290
|
+
: `${tile.source}.${tile.name}`;
|
|
233
291
|
|
|
234
292
|
/** `dimension: <name> is <expression>` in the dashboard's own extension. */
|
|
235
293
|
export interface DashboardDimension {
|
|
@@ -57,7 +57,7 @@ describe("a dashboard with an explicit, empty tile list", () => {
|
|
|
57
57
|
colspan: 6,
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
|
-
expect(out).toContain('tiles=["one_tiles -> vx_tile"]');
|
|
60
|
+
expect(out).toContain('tiles=["one_tiles -> vx_tile" { colspan=6 }]');
|
|
61
61
|
const back = await openDocument(out);
|
|
62
62
|
expect(back.tiles.map(tileKey)).toEqual(["one_tiles.vx_tile"]);
|
|
63
63
|
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { isTextTile } from "./document";
|
|
6
|
+
import { openDocument, queryTile, spliced } from "./testing/fixtures";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A tile's layout lives on its entry in `tiles=[…]`: the place this report
|
|
10
|
+
* puts it. The reader takes the entry over the view's own tags, as the server
|
|
11
|
+
* does, and the writer puts a changed layout there and takes the view's
|
|
12
|
+
* `# colspan` and `# break` off, so the layout has one home.
|
|
13
|
+
*/
|
|
14
|
+
const TAGGED = `## artifact { layout=grid title="T" tiles=["a -> kpis", "a -> trend"] } dashboard { columns=12 }
|
|
15
|
+
import "../m.malloy"
|
|
16
|
+
|
|
17
|
+
source: a is one extend {
|
|
18
|
+
# colspan=6
|
|
19
|
+
# break
|
|
20
|
+
# label="KPIs"
|
|
21
|
+
view: kpis is vk
|
|
22
|
+
|
|
23
|
+
view: trend is vt
|
|
24
|
+
}`;
|
|
25
|
+
|
|
26
|
+
describe("entry layout: reading", () => {
|
|
27
|
+
it("takes the entry's colspan, break and rowspan over the view's tags", async () => {
|
|
28
|
+
const d = await openDocument(
|
|
29
|
+
TAGGED.replace(
|
|
30
|
+
'"a -> kpis", "a -> trend"',
|
|
31
|
+
'"a -> kpis" { colspan=4 break=false rowspan=3 }, "a -> trend" { break }',
|
|
32
|
+
),
|
|
33
|
+
);
|
|
34
|
+
expect(queryTile(d, 0)).toMatchObject({ colspan: 4, rowspan: 3 });
|
|
35
|
+
expect(queryTile(d, 0).break).toBeUndefined();
|
|
36
|
+
expect(queryTile(d, 1)).toMatchObject({ break: true });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("still reads a view's own tags when the entry carries none", async () => {
|
|
40
|
+
const d = await openDocument(TAGGED);
|
|
41
|
+
expect(queryTile(d, 0)).toMatchObject({ colspan: 6, break: true });
|
|
42
|
+
expect(queryTile(d, 0).rowspan).toBeUndefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("reads a text tile's rowspan", async () => {
|
|
46
|
+
const d = await openDocument(
|
|
47
|
+
`## artifact { layout=grid title="T" tiles=[intro { kind=text rowspan=2 }] }\n##|(markdown) intro\nHi\n|##\n`,
|
|
48
|
+
);
|
|
49
|
+
const tile = d.tiles[0];
|
|
50
|
+
expect(isTextTile(tile) && tile.rowspan).toBe(2);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("entry layout: writing", () => {
|
|
55
|
+
it("moves a changed width to the entry, taking the view's layout tags off", async () => {
|
|
56
|
+
const out = await spliced(TAGGED, (d) => {
|
|
57
|
+
d.tiles[0].colspan = 8;
|
|
58
|
+
});
|
|
59
|
+
expect(out).toContain(
|
|
60
|
+
'tiles=["a -> kpis" { colspan=8 break }, "a -> trend"]',
|
|
61
|
+
);
|
|
62
|
+
expect(out).toContain(' # label="KPIs"\n view: kpis is vk');
|
|
63
|
+
expect(out).not.toContain("# colspan");
|
|
64
|
+
expect(out).not.toContain("# break");
|
|
65
|
+
const back = await openDocument(out);
|
|
66
|
+
expect(queryTile(back, 0)).toMatchObject({ colspan: 8, break: true });
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("leaves a view's layout tags alone when only its title changes", async () => {
|
|
70
|
+
const out = await spliced(TAGGED, (d) => {
|
|
71
|
+
queryTile(d, 0).label = "Totals";
|
|
72
|
+
});
|
|
73
|
+
expect(out).toContain('tiles=["a -> kpis", "a -> trend"]');
|
|
74
|
+
expect(out).toContain(
|
|
75
|
+
' # colspan=6\n # break\n # label="Totals"\n view: kpis is vk',
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("writes a rowspan on a query tile and a text tile", async () => {
|
|
80
|
+
const source = TAGGED.replace(
|
|
81
|
+
'"a -> kpis", "a -> trend"',
|
|
82
|
+
'intro { kind=text }, "a -> kpis", "a -> trend"',
|
|
83
|
+
).replace("import", "##|(markdown) intro\nHi\n|##\nimport");
|
|
84
|
+
const out = await spliced(source, (d) => {
|
|
85
|
+
d.tiles[0].rowspan = 2;
|
|
86
|
+
d.tiles[2].rowspan = 5;
|
|
87
|
+
});
|
|
88
|
+
expect(out).toContain(
|
|
89
|
+
'tiles=[intro { kind=text rowspan=2 }, "a -> kpis", "a -> trend" { rowspan=5 }]',
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("drops the braces when an entry's last layout property goes", async () => {
|
|
94
|
+
const source = TAGGED.replace(
|
|
95
|
+
'"a -> trend"',
|
|
96
|
+
'"a -> trend" { rowspan=4 }',
|
|
97
|
+
);
|
|
98
|
+
const out = await spliced(source, (d) => {
|
|
99
|
+
delete d.tiles[1].rowspan;
|
|
100
|
+
});
|
|
101
|
+
expect(out).toContain('tiles=["a -> kpis", "a -> trend"]');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("keeps an entry's spelling and other properties when its layout changes", async () => {
|
|
105
|
+
const source = TAGGED.replace(
|
|
106
|
+
'"a -> trend"',
|
|
107
|
+
'"a->trend" { rowspan=4 kind=query }',
|
|
108
|
+
);
|
|
109
|
+
const out = await spliced(source, (d) => {
|
|
110
|
+
d.tiles[1].rowspan = 6;
|
|
111
|
+
});
|
|
112
|
+
expect(out).toContain('"a->trend" { kind=query rowspan=6 }');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("rewrites an entry that carries layout as written when only the order changes", async () => {
|
|
116
|
+
const source = TAGGED.replace(
|
|
117
|
+
'"a -> trend"',
|
|
118
|
+
'"a -> trend" { rowspan=4 }',
|
|
119
|
+
);
|
|
120
|
+
const out = await spliced(source, (d) => {
|
|
121
|
+
d.tiles = [d.tiles[1], d.tiles[0]];
|
|
122
|
+
// The pattern of breaks is the grid's, not the tiles': see layout.ts.
|
|
123
|
+
delete d.tiles[1].break;
|
|
124
|
+
d.tiles[0].break = undefined;
|
|
125
|
+
});
|
|
126
|
+
expect(out).toContain('tiles=["a -> trend" { rowspan=4 }, "a -> kpis"');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("writes where a placed tile sits, ahead of its size", async () => {
|
|
130
|
+
const out = await spliced(TAGGED, (d) => {
|
|
131
|
+
d.tiles[1].row = 3;
|
|
132
|
+
d.tiles[1].col = 7;
|
|
133
|
+
d.tiles[1].colspan = 6;
|
|
134
|
+
});
|
|
135
|
+
expect(out).toContain('"a -> trend" { row=3 col=7 colspan=6 }');
|
|
136
|
+
const back = await openDocument(out);
|
|
137
|
+
expect(queryTile(back, 1)).toMatchObject({ row: 3, col: 7, colspan: 6 });
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("takes a tile's place off without touching its size", async () => {
|
|
141
|
+
const source = TAGGED.replace(
|
|
142
|
+
'"a -> trend"',
|
|
143
|
+
'"a -> trend" { row=3 col=7 colspan=6 }',
|
|
144
|
+
);
|
|
145
|
+
const out = await spliced(source, (d) => {
|
|
146
|
+
delete d.tiles[1].row;
|
|
147
|
+
delete d.tiles[1].col;
|
|
148
|
+
});
|
|
149
|
+
expect(out).toContain('"a -> trend" { colspan=6 }');
|
|
150
|
+
});
|
|
151
|
+
});
|
|
@@ -15,7 +15,7 @@ const folderOf = (path: string) => path.slice(0, path.lastIndexOf("/") + 1);
|
|
|
15
15
|
* alone would miss the second, and importing a source the file already
|
|
16
16
|
* reaches declares it twice.
|
|
17
17
|
*/
|
|
18
|
-
const resolvedOf = (from: string, documentPath: string) =>
|
|
18
|
+
export const resolvedOf = (from: string, documentPath: string) =>
|
|
19
19
|
new URL(
|
|
20
20
|
from,
|
|
21
21
|
`https://malloy.invalid/${folderOf(documentPath)}`,
|
|
@@ -151,16 +151,20 @@ const ROWS: Row[] = [
|
|
|
151
151
|
outcome: "succeeds",
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
what: "
|
|
154
|
+
// A width moves to the tile's entry and takes the view's `# colspan`
|
|
155
|
+
// with it. That tag sits above a `--` line, so a writer that cannot see
|
|
156
|
+
// it leaves it behind -- and the reader, which lets the entry win, reads
|
|
157
|
+
// the new width back and the round-trip gate is satisfied.
|
|
158
|
+
what: "moves a width off a tag block that holds a `--` comment",
|
|
159
159
|
edit: (d) => {
|
|
160
160
|
tile(d, "kpis").colspan = 3;
|
|
161
161
|
},
|
|
162
162
|
outcome: "succeeds",
|
|
163
|
-
moved: {
|
|
163
|
+
moved: {
|
|
164
|
+
tagText: ["~view:a.kpis"],
|
|
165
|
+
tags: ["~view:a.kpis"],
|
|
166
|
+
declarations: ["~source:a"],
|
|
167
|
+
},
|
|
164
168
|
},
|
|
165
169
|
{
|
|
166
170
|
// The same shape as the row above, in the spelling that also hid a tag
|
|
@@ -169,12 +173,16 @@ const ROWS: Row[] = [
|
|
|
169
173
|
// which here is prose: walking further up to find the real tag must not
|
|
170
174
|
// turn a line inside a comment into an annotation -- to rewrite in place
|
|
171
175
|
// on the writer's side, or to report as a tag on the reader's.
|
|
172
|
-
what: "
|
|
176
|
+
what: "moves a width off a tag block that holds a block comment",
|
|
173
177
|
edit: (d) => {
|
|
174
178
|
tile(d, "counts").colspan = 6;
|
|
175
179
|
},
|
|
176
180
|
outcome: "succeeds",
|
|
177
|
-
moved: {
|
|
181
|
+
moved: {
|
|
182
|
+
tagText: ["~view:a.counts"],
|
|
183
|
+
tags: ["~view:a.counts"],
|
|
184
|
+
declarations: ["~source:a"],
|
|
185
|
+
},
|
|
178
186
|
},
|
|
179
187
|
{
|
|
180
188
|
// A line that is a comment AND a declaration at once. Read as wholly
|
|
@@ -183,12 +191,12 @@ const ROWS: Row[] = [
|
|
|
183
191
|
// to match a tile that never had a label. Nothing downstream can tell:
|
|
184
192
|
// the reader takes tags from the parser and never attributed it to the
|
|
185
193
|
// tile in the first place.
|
|
186
|
-
what: "
|
|
194
|
+
what: "moves a width off a tile below a declaration sharing its line with a comment",
|
|
187
195
|
edit: (d) => {
|
|
188
196
|
tile(d, "trend").colspan = 4;
|
|
189
197
|
},
|
|
190
198
|
outcome: "succeeds",
|
|
191
|
-
moved: { tagText: ["~view:a.trend"] },
|
|
199
|
+
moved: { tagText: ["~view:a.trend"], tags: ["~view:a.trend"] },
|
|
192
200
|
},
|
|
193
201
|
{
|
|
194
202
|
what: "relabels a control",
|
|
@@ -96,6 +96,9 @@ export const tileEntry = (tile: DashboardTile, index: number): GridEntry => ({
|
|
|
96
96
|
index,
|
|
97
97
|
colspan: tile.colspan,
|
|
98
98
|
break: tile.break,
|
|
99
|
+
rowspan: tile.rowspan,
|
|
100
|
+
row: tile.row,
|
|
101
|
+
col: tile.col,
|
|
99
102
|
});
|
|
100
103
|
|
|
101
104
|
/** A gap's id: its drop target's, and the grid's key for it. */
|