@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.
Files changed (164) hide show
  1. package/dist/RenderedResult-5hOs5XnV.cjs.js +171 -0
  2. package/dist/RenderedResult-DxmHGZNQ.es.js +671 -0
  3. package/dist/{ServerProvider-BV7IoDMR.es.js → ServerProvider-D7neZcTk.es.js} +283 -265
  4. package/dist/ServerProvider-e2369oom.cjs.js +1 -0
  5. package/dist/builder/index.cjs.js +80 -79
  6. package/dist/builder/index.es.js +7732 -6717
  7. package/dist/builder-entry.d.ts +1 -1
  8. package/dist/client/api.d.ts +31 -7
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +1 -1
  11. package/dist/components/Dashboard/DashboardGrid.d.ts +51 -1
  12. package/dist/components/Dashboard/DashboardTile.d.ts +7 -2
  13. package/dist/components/Dashboard/DashboardView.d.ts +9 -2
  14. package/dist/components/Dashboard/index.d.ts +1 -1
  15. package/dist/components/Dashboard/promoteMeasureRow.d.ts +5 -7
  16. package/dist/components/Dashboard/useStuck.d.ts +18 -12
  17. package/dist/components/RenderedResult/RenderedResult.d.ts +3 -2
  18. package/dist/components/RenderedResult/ResultContainer.d.ts +18 -1
  19. package/dist/components/RenderedResult/ResultPanel.d.ts +7 -1
  20. package/dist/components/RenderedResult/chartPresentation.d.ts +15 -0
  21. package/dist/components/RenderedResult/chartShapeProblem.d.ts +55 -0
  22. package/dist/components/RenderedResult/resultSizing.d.ts +47 -6
  23. package/dist/components/Report/Report.d.ts +7 -1
  24. package/dist/components/Report/ReportPage.d.ts +7 -0
  25. package/dist/components/Report/layoutRules.d.ts +45 -0
  26. package/dist/components/ReportBuilder/AddTileDialog.d.ts +2 -1
  27. package/dist/components/ReportBuilder/ArrangeMenu.d.ts +9 -0
  28. package/dist/components/ReportBuilder/BuilderGrid.d.ts +15 -4
  29. package/dist/components/ReportBuilder/BuilderToolbar.d.ts +3 -1
  30. package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
  31. package/dist/components/ReportBuilder/EditorSurface.d.ts +10 -1
  32. package/dist/components/ReportBuilder/ReportBuilder.d.ts +1 -1
  33. package/dist/components/ReportBuilder/TileFrame.d.ts +54 -10
  34. package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
  35. package/dist/components/ReportBuilder/builderControls.d.ts +19 -0
  36. package/dist/components/ReportBuilder/catalog.d.ts +23 -0
  37. package/dist/components/ReportBuilder/chartLine.d.ts +38 -5
  38. package/dist/components/ReportBuilder/controls.d.ts +2 -2
  39. package/dist/components/ReportBuilder/document.d.ts +53 -5
  40. package/dist/components/ReportBuilder/imports.d.ts +7 -0
  41. package/dist/components/ReportBuilder/placement.d.ts +121 -0
  42. package/dist/components/ReportBuilder/preview.d.ts +59 -10
  43. package/dist/components/ReportBuilder/sortable.d.ts +12 -1
  44. package/dist/components/ReportBuilder/useBuilderSession.d.ts +1 -1
  45. package/dist/components/ReportBuilder/useBuilderShortcuts.d.ts +9 -1
  46. package/dist/components/ReportBuilder/useEdgeResize.d.ts +84 -0
  47. package/dist/components/ReportBuilder/useTileReorder.d.ts +30 -3
  48. package/dist/index.cjs.js +7 -7
  49. package/dist/index.es.js +3349 -3307
  50. package/dist/text/index.es.js +1 -1
  51. package/dist/{text-entry-72YFLeNk.es.js → text-entry-YKJZbRPo.es.js} +2 -2
  52. package/dist/theme/classes.d.ts +1 -1
  53. package/dist/theme/resolveTheme.d.ts +15 -0
  54. package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-CaYP_OYG.es.js} +6353 -6047
  55. package/dist/useCompiledDocument-zYEfLogf.cjs.js +142 -0
  56. package/dist/utils/blankQuoted.d.ts +15 -0
  57. package/package.json +1 -1
  58. package/src/builder-entry.ts +1 -0
  59. package/src/components/Dashboard/DashboardGrid.tsx +129 -10
  60. package/src/components/Dashboard/DashboardTile.tsx +15 -1
  61. package/src/components/Dashboard/DashboardView.tsx +64 -10
  62. package/src/components/Dashboard/TileCard.tsx +6 -0
  63. package/src/components/Dashboard/index.ts +1 -0
  64. package/src/components/Dashboard/promoteMeasureRow.spec.ts +19 -0
  65. package/src/components/Dashboard/promoteMeasureRow.ts +15 -36
  66. package/src/components/Dashboard/tileHeight.spec.ts +72 -0
  67. package/src/components/Dashboard/useStuck.ts +76 -28
  68. package/src/components/Package/NewDocumentDialog.spec.tsx +20 -16
  69. package/src/components/Package/NewDocumentDialog.tsx +10 -11
  70. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +167 -2
  71. package/src/components/RenderedResult/RenderedResult.tsx +39 -6
  72. package/src/components/RenderedResult/ResultContainer.tsx +99 -10
  73. package/src/components/RenderedResult/ResultPanel.tsx +25 -1
  74. package/src/components/RenderedResult/chartPresentation.spec.ts +153 -0
  75. package/src/components/RenderedResult/chartPresentation.ts +166 -0
  76. package/src/components/RenderedResult/chartShapeProblem.spec.tsx +245 -0
  77. package/src/components/RenderedResult/chartShapeProblem.ts +219 -0
  78. package/src/components/RenderedResult/resultSizing.spec.ts +75 -3
  79. package/src/components/RenderedResult/resultSizing.ts +71 -11
  80. package/src/components/Report/Report.spec.tsx +19 -0
  81. package/src/components/Report/Report.tsx +8 -1
  82. package/src/components/Report/ReportPage.tsx +13 -1
  83. package/src/components/Report/layoutRules.spec.ts +43 -3
  84. package/src/components/Report/layoutRules.ts +70 -0
  85. package/src/components/Report/tileOverflow.spec.tsx +162 -0
  86. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +2 -2
  87. package/src/components/ReportBuilder/AddTileDialog.tsx +11 -6
  88. package/src/components/ReportBuilder/ArrangeMenu.tsx +80 -0
  89. package/src/components/ReportBuilder/BuilderBar.tsx +5 -1
  90. package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -1
  91. package/src/components/ReportBuilder/BuilderGrid.tsx +142 -35
  92. package/src/components/ReportBuilder/BuilderToolbar.tsx +4 -0
  93. package/src/components/ReportBuilder/ChartPicker.spec.ts +91 -4
  94. package/src/components/ReportBuilder/ChartPicker.tsx +45 -10
  95. package/src/components/ReportBuilder/DrillDialog.tsx +8 -2
  96. package/src/components/ReportBuilder/EditorSurface.tsx +101 -20
  97. package/src/components/ReportBuilder/FilterDialog.tsx +17 -8
  98. package/src/components/ReportBuilder/FilterStrip.tsx +2 -1
  99. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +193 -2
  100. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
  101. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +2 -2
  102. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +242 -2
  103. package/src/components/ReportBuilder/ReportBuilder.tsx +161 -27
  104. package/src/components/ReportBuilder/ReportEditor.fileModel.spec.tsx +178 -0
  105. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +3 -5
  106. package/src/components/ReportBuilder/ReportEditor.readOnlyTitle.spec.tsx +92 -0
  107. package/src/components/ReportBuilder/ReportEditor.tsx +13 -0
  108. package/src/components/ReportBuilder/TileFrame.tsx +366 -170
  109. package/src/components/ReportBuilder/TileMenu.tsx +259 -20
  110. package/src/components/ReportBuilder/ViewPicker.tsx +4 -3
  111. package/src/components/ReportBuilder/addTileToDocument.spec.ts +34 -0
  112. package/src/components/ReportBuilder/addTileToDocument.ts +26 -1
  113. package/src/components/ReportBuilder/builderControls.ts +34 -0
  114. package/src/components/ReportBuilder/catalog.aggregate.spec.ts +137 -1
  115. package/src/components/ReportBuilder/catalog.ts +90 -37
  116. package/src/components/ReportBuilder/chartLine.spec.ts +42 -5
  117. package/src/components/ReportBuilder/chartLine.ts +80 -2
  118. package/src/components/ReportBuilder/controls.ts +4 -3
  119. package/src/components/ReportBuilder/document.ts +65 -7
  120. package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
  121. package/src/components/ReportBuilder/entryLayout.spec.ts +151 -0
  122. package/src/components/ReportBuilder/imports.ts +1 -1
  123. package/src/components/ReportBuilder/invariants.spec.ts +18 -10
  124. package/src/components/ReportBuilder/layout.ts +3 -0
  125. package/src/components/ReportBuilder/placement.spec.ts +401 -0
  126. package/src/components/ReportBuilder/placement.ts +416 -0
  127. package/src/components/ReportBuilder/preview.shapes.spec.ts +46 -6
  128. package/src/components/ReportBuilder/preview.spec.ts +151 -11
  129. package/src/components/ReportBuilder/preview.ts +203 -40
  130. package/src/components/ReportBuilder/preview.unsaved.compile.spec.ts +190 -0
  131. package/src/components/ReportBuilder/readDocument.spec.ts +53 -19
  132. package/src/components/ReportBuilder/readDocument.ts +197 -29
  133. package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
  134. package/src/components/ReportBuilder/sortable.tsx +30 -2
  135. package/src/components/ReportBuilder/spliceDocument.chart.spec.ts +1 -1
  136. package/src/components/ReportBuilder/spliceDocument.color.spec.ts +80 -0
  137. package/src/components/ReportBuilder/spliceDocument.colspan.spec.ts +78 -0
  138. package/src/components/ReportBuilder/spliceDocument.spec.ts +110 -58
  139. package/src/components/ReportBuilder/spliceDocument.ts +139 -91
  140. package/src/components/ReportBuilder/statementExtent.spec.ts +3 -3
  141. package/src/components/ReportBuilder/testing/reportGivenOrder.json +42 -0
  142. package/src/components/ReportBuilder/textTiles.spec.ts +2 -2
  143. package/src/components/ReportBuilder/tileDisplayTitle.ts +2 -2
  144. package/src/components/ReportBuilder/useBuilderSession.ts +7 -2
  145. package/src/components/ReportBuilder/useBuilderShortcuts.ts +25 -1
  146. package/src/components/ReportBuilder/useEdgeResize.spec.tsx +324 -0
  147. package/src/components/ReportBuilder/useEdgeResize.ts +397 -0
  148. package/src/components/ReportBuilder/useTileEditing.ts +16 -3
  149. package/src/components/ReportBuilder/useTileReorder.ts +143 -6
  150. package/src/components/given/FilterButton.spec.tsx +27 -11
  151. package/src/components/given/FilterButton.tsx +19 -6
  152. package/src/theme/classes.ts +1 -1
  153. package/src/theme/resolveTheme.spec.ts +72 -1
  154. package/src/theme/resolveTheme.ts +43 -0
  155. package/src/utils/blankQuoted.spec.ts +50 -0
  156. package/src/utils/blankQuoted.ts +32 -0
  157. package/src/utils/malloyText.ts +2 -1
  158. package/dist/RenderedResult-DnBtf-cI.es.js +0 -593
  159. package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
  160. package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
  161. package/dist/components/ReportBuilder/useTileResize.d.ts +0 -32
  162. package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
  163. package/src/components/ReportBuilder/useTileResize.spec.tsx +0 -146
  164. 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
- * Four forms, all of them found in dashboards that ship in this repository, and
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: string;
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 width and row break live on that
177
- * list entry, since a block has no tags.
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) ? `text.${tile.name}` : `${tile.source}.${tile.name}`;
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
- // The `#` tags this rewrites sit above a `--` line, so a writer that
155
- // cannot see them adds a second `# colspan` rather than patching the one
156
- // that is there -- and the reader, which takes tags from the parser,
157
- // reads the lower one back and the round-trip gate is satisfied.
158
- what: "retags a tile whose tag block holds a `--` comment",
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: { tagText: ["~view:a.kpis"] },
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: "retags a tile whose tag block holds a block comment",
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: { tagText: ["~view:a.counts"] },
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: "retags a tile below a declaration sharing its line with a comment",
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. */