@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
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  import { NavigationClick } from '../click_helper';
2
3
  import { TileChrome } from '../Dashboard/TileCard';
3
4
  import { DrillNavigation } from '../drill';
@@ -58,6 +59,11 @@ export interface ReportProps {
58
59
  * while the builder loads over it.
59
60
  */
60
61
  manifestStaleTime?: number;
62
+ /**
63
+ * The host's actions for the report (a download, its own menu), drawn at
64
+ * the end of the title's line rather than on a row of their own above it.
65
+ */
66
+ actions?: ReactNode;
61
67
  }
62
68
  /**
63
69
  * A report of either layout, from `GET …/reports/{path}`: a grid drawn as a
@@ -67,5 +73,5 @@ export interface ReportProps {
67
73
  * Host-agnostic, like `Dashboard`: it takes props rather than reading a
68
74
  * router, and hands navigation and URL state back to whoever mounted it.
69
75
  */
70
- export declare function Report({ resourceUri, path, givens, onGivensChange, onNavigate, onLinkNavigate, height, maxResultSize, onEvent, chrome, manifestStaleTime, }: ReportProps): import("react/jsx-runtime").JSX.Element;
76
+ export declare function Report({ resourceUri, path, givens, onGivensChange, onNavigate, onLinkNavigate, height, maxResultSize, onEvent, chrome, manifestStaleTime, actions, }: ReportProps): import("react/jsx-runtime").JSX.Element;
71
77
  export default Report;
@@ -16,6 +16,13 @@ import { ReactNode } from 'react';
16
16
  * below MUI's app bar, popovers and dialogs.
17
17
  */
18
18
  export declare const STICKY_CONTROLS_Z = 4;
19
+ /**
20
+ * The CSS custom property a host sets, on any ancestor of a report, to the
21
+ * height of what it pins above the report in the same scroller. The control
22
+ * row pins that far down instead of at the scroller's edge, so the two stack
23
+ * rather than overlap. Unset, it is 0.
24
+ */
25
+ export declare const STICKY_TOP_VAR = "--publisher-sticky-top";
19
26
  /**
20
27
  * A report page, top to bottom: anything that must be said before it
21
28
  * (`notice`), the header, the control row, then the body (the tiles, and
@@ -26,7 +26,52 @@ export interface LayoutRules {
26
26
  * inserting; a grid is arranged by dragging, so it adds at the end.
27
27
  */
28
28
  insertBetween: boolean;
29
+ /**
30
+ * The cap on a query tile's result, or undefined for none. A grid keeps its
31
+ * rows even, so a tile is one panel among several: it stops at
32
+ * {@link TILE_MAX_HEIGHT} and scrolls past it. A linear report is read top
33
+ * to bottom and nothing beside a tile sets its height, so a tile grows to
34
+ * fit what it holds, the way the single-query form already does: a row of
35
+ * KPI cards that wraps one per line in a narrow column shows every card. A
36
+ * table is the exception, held by {@link tableMaxHeight}. A
37
+ * chart, which has no height of its own, still draws at the uncapped
38
+ * default (see `resolveResultHeight`).
39
+ */
40
+ tileMaxHeight: number | undefined;
41
+ /**
42
+ * A further cap on a tile whose result is a table, or undefined for none
43
+ * beyond {@link tileMaxHeight}. A linear report's tiles grow to fit, but a
44
+ * long table at full length pushes the rest of the report a screen or more
45
+ * down, so a table stops at {@link LINEAR_TABLE_MAX_HEIGHT} and scrolls
46
+ * inside its tile under its pinned header row. A grid needs none: its tile
47
+ * cap is lower. See `resultCap`.
48
+ */
49
+ tableMaxHeight: number | undefined;
29
50
  }
51
+ /**
52
+ * The `# colspan` to write for a tile `span` columns wide, or undefined to
53
+ * write none because the tile draws the same without one.
54
+ *
55
+ * A tile with no colspan is one column, except that the reader widens it until
56
+ * it is at least `MIN_TILE_PX` wide (`defaultTileSpan`). In a grid of one or two
57
+ * columns, one column is already that wide wherever the grid is laid out in
58
+ * columns (two columns of 240px need a box of 496px). So there a written
59
+ * `colspan=1` only repeats the default. In a wider grid an unset tile can be
60
+ * drawn wider than one column, and an explicit 1 is the author's choice to keep.
61
+ *
62
+ * `drawnWithout` is the span the caller draws an unset tile at now, when it
63
+ * measures one (the builder does): a width the author just set to 1 is still
64
+ * written while the tile would draw wider without it.
65
+ */
66
+ export declare function writtenSpan(span: number, columns: number, drawnWithout?: number): number | undefined;
67
+ /**
68
+ * The tile with its width as {@link writtenSpan} would write it: a `colspan`,
69
+ * or none. A copy, so a caller puts it back in its list rather than writing
70
+ * through an entry it looked up.
71
+ */
72
+ export declare function withSpan<T extends {
73
+ colspan?: number;
74
+ }>(tile: T, span: number, columns: number, drawnWithout?: number): T;
30
75
  export declare function layoutRules(layout: ReportLayout | undefined,
31
76
  /** `# dashboard { columns=N }` as the file has it. */
32
77
  declaredColumns?: number): LayoutRules;
@@ -30,7 +30,8 @@ export interface NewTile {
30
30
  chart?: ChartPick | "none";
31
31
  /** The chart tags the view carries, so the chart line negates only those. */
32
32
  chartCarried?: string[];
33
- colspan: number;
33
+ /** Columns the tile spans; absent writes none, where that draws the same (`writtenSpan`). */
34
+ colspan?: number;
34
35
  }
35
36
  /** A view the picker shows a preview of, as the tile it would add. */
36
37
  export interface ViewPreview {
@@ -0,0 +1,9 @@
1
+ import { ArrangeActions } from './builderControls';
2
+ /**
3
+ * The layout of a placed grid report as a whole: closing its gaps, or letting
4
+ * its tiles flow again. One menu shared by the builder's own toolbar and the
5
+ * bar a host draws, so the two cannot offer different things.
6
+ */
7
+ export declare function ArrangeMenu({ arrange }: {
8
+ arrange: ArrangeActions;
9
+ }): import("react/jsx-runtime").JSX.Element;
@@ -4,16 +4,27 @@ import { LayoutRules } from '../Report/layoutRules';
4
4
  import { DashboardTile, QueryTile } from './document';
5
5
  import { ReportEditorHandle } from './useReportEditor';
6
6
  import { useTileReorder } from './useTileReorder';
7
- import { useTileResize } from './useTileResize';
7
+ import { useEdgeResize } from './useEdgeResize';
8
8
  /**
9
9
  * The builder's tiles, on the SAME grid the dashboard renders on, each drawn
10
10
  * by the caller's `renderTile` inside a `TileFrame` that carries the
11
- * affordances: selection, the grip and menu, the width handle.
11
+ * affordances: selection, the menu, and its edges and corners.
12
12
  */
13
- export declare function BuilderGrid({ editor, reorder, resizing, gridBox, defaultSpan, rules, canAdd, selected, flash, menuIndex, onSelect, onOpenMenu, onRemove, removeBlocked, openAdd, editTile, renderTile, }: {
13
+ export declare function BuilderGrid({ editor, reorder, edging, place, arrange, gridBox, defaultSpan, rules, canAdd, selected, flash, menuIndex, onSelect, onOpenMenu, onRemove, removeBlocked, openAdd, editTile, renderTile, }: {
14
14
  editor: ReportEditorHandle;
15
15
  reorder: ReturnType<typeof useTileReorder>;
16
- resizing: ReturnType<typeof useTileResize>;
16
+ /** Every edge and corner of a tile, dragged to resize it. */
17
+ edging: ReturnType<typeof useEdgeResize>;
18
+ /**
19
+ * The tiles after the one at `index` changed size: on a placed report,
20
+ * whatever it now covers pushed down. Identity elsewhere.
21
+ */
22
+ place?: (tiles: DashboardTile[], index: number) => DashboardTile[];
23
+ /**
24
+ * Whether tiles can be moved and widened here. Off while a grid is drawn
25
+ * as one column (a window narrower than the grid), where neither shows.
26
+ */
27
+ arrange?: boolean;
17
28
  gridBox: RefObject<HTMLDivElement | null>;
18
29
  /** The span a tile with no `# colspan` is drawn at: as wide as the reader draws it. */
19
30
  defaultSpan?: number;
@@ -120,6 +120,8 @@ export interface BuilderToolbarProps {
120
120
  actions?: ReactNode;
121
121
  /** Open the add-tile picker. Absent when the host passed no catalog to pick from. */
122
122
  onAddTile?: () => void;
123
+ /** The arrange menu, on a report whose tiles are placed; drawn before Tile. */
124
+ arrange?: ReactNode;
123
125
  /**
124
126
  * Leave the builder: draws Close after Save, for a host that opts in. The
125
127
  * Console leaves from its own header and passes nothing.
@@ -132,4 +134,4 @@ export interface BuilderToolbarProps {
132
134
  */
133
135
  saveStatus?: SaveStatusProps;
134
136
  }
135
- export declare function BuilderToolbar({ canUndo, canRedo, onUndo, onRedo, dirty, saving, onSave, savesTo, saveLabel, saveButton, actions, onAddTile, onExit, saveStatus, }: BuilderToolbarProps): import("react/jsx-runtime").JSX.Element;
137
+ export declare function BuilderToolbar({ canUndo, canRedo, onUndo, onRedo, dirty, saving, onSave, savesTo, saveLabel, saveButton, actions, onAddTile, arrange, onExit, saveStatus, }: BuilderToolbarProps): import("react/jsx-runtime").JSX.Element;
@@ -6,6 +6,8 @@ export interface ChartChoice {
6
6
  /** Listed but not pickable; `reason` says what the view would need. */
7
7
  disabled?: boolean;
8
8
  reason?: string;
9
+ /** A quiet second line on a choice that can be picked: what it means. */
10
+ hint?: string;
9
11
  }
10
12
  /** Why a view is absent, so the reason on a disabled choice says whether to wait or to pick another. */
11
13
  export type ViewStatus = "loading" | "unlisted";
@@ -13,11 +15,11 @@ export type ViewStatus = "loading" | "unlisted";
13
15
  * Every chart a cell can be set to; one the view cannot render is listed disabled with its reason, so it is discoverable rather than missing.
14
16
  * Whatever the cell has now stays selectable, so the select never shows a value it does not offer.
15
17
  */
16
- export declare function chartChoices(view: Pick<CatalogView, "chart" | "aggregateOnly"> | undefined, current: ChartState, viewStatus?: ViewStatus): ChartChoice[];
18
+ export declare function chartChoices(view: Pick<CatalogView, "chart" | "aggregateOnly" | "shape"> | undefined, current: ChartState, viewStatus?: ViewStatus): ChartChoice[];
17
19
  export declare function ChartPicker({ state, view, viewStatus, cellLabel, disabledReason, onOpen, onChange, variant, }: {
18
20
  state: ChartState;
19
21
  /** The catalog's view this cell runs, when it is one the catalog knows. */
20
- view: Pick<CatalogView, "chart" | "aggregateOnly"> | undefined;
22
+ view: Pick<CatalogView, "chart" | "aggregateOnly" | "shape"> | undefined;
21
23
  /** Why `view` is absent, worded into the reasons on the charts that need its shape. */
22
24
  viewStatus?: ViewStatus;
23
25
  /** Which cell this is, so the control is named apart from its neighbours. */
@@ -1,10 +1,19 @@
1
+ import { CompiledModel } from '../../client';
1
2
  import { ReportLayout } from '../Package/documentLocation';
2
3
  import { DashboardDocument } from './document';
3
4
  import { SavesTo } from './documentSession';
4
5
  import { TextSourceOptions } from './ReportEditor';
5
6
  import { ReportEventHandler } from '../Report/telemetry';
6
7
  import { BuilderControlsHandler } from './builderControls';
7
- export declare function EditorSurface({ textSource, environmentName, packageName, modelPath, versionId, queryVersionId, opened, replaces, onSave, onDirtyChange, onExit, onOpenModel, onControlsChange, draftKey, onEvent, savesTo, saveLabel, note, }: {
8
+ export declare function EditorSurface({ textSource, environmentName, packageName, modelPath, versionId, queryVersionId, opened, replaces, onSave, onDirtyChange, onExit, onOpenModel, onControlsChange, draftKey, onEvent, savesTo, saveLabel, note, fileModel, }: {
9
+ /**
10
+ * The file's own compiled model as the package serves it, for the shapes
11
+ * of the views it declares (which charts each tile can take). Absent for a
12
+ * document held as text, whose compile answer carries no per-view shapes,
13
+ * and whenever the opened text is not the one this model compiled (a kept
14
+ * draft, the host's record, a held-back version): the catalog answers then.
15
+ */
16
+ fileModel?: CompiledModel;
8
17
  textSource?: TextSourceOptions;
9
18
  environmentName: string;
10
19
  packageName: string;
@@ -26,7 +26,7 @@ export type { BuilderGiven } from './controls';
26
26
  * draws its own card AND its own heading. Nesting one inside a card of ours
27
27
  * would show a card in a card under two titles — which is precisely not what a
28
28
  * reader sees. So every affordance is drawn AROUND whatever the caller renders:
29
- * an outline for selection, a grip and a menu in the corners.
29
+ * an outline for selection, a menu in the corner, and edges that resize.
30
30
  *
31
31
  * **Everything here is on the thing it changes.** Set a tile's width from its menu, and drag
32
32
  * the tile itself to reorder — into the empty end of a row
@@ -4,13 +4,14 @@ import { SystemStyleObject } from '@mui/system';
4
4
  import { ResolvedTheme } from '../../theme/types';
5
5
  import { TileChrome, TileHeadingSlots } from '../Dashboard/TileCard';
6
6
  import { DashboardTile, QueryTile } from './document';
7
+ import { Edges } from './useEdgeResize';
7
8
  /**
8
9
  * Everything the builder draws AROUND a tile: the selection outline, the menu
9
- * button, the handle at the right edge and, in a notebook, the insert button. The tile
10
+ * button, the resize edges and corners and, in a notebook, the insert button. The tile
10
11
  * itself is `children` — the host's real `DashboardTile`, or a placeholder
11
12
  * saying what the tile will run.
12
13
  */
13
- export declare function TileFrame({ tile, index, selected, flash, menuOpen, bare, onInsertAfter, onSelect, onOpenMenu, onRemove, removeBlocked, resizing, width, onResizeStart, onResizeMove, onResizeEnd, children, }: {
14
+ export declare function TileFrame({ tile, index, selected, flash, menuOpen, bare, onInsertAfter, onSelect, onOpenMenu, onRemove, removeBlocked, width, edges, heightEdge, fixed, children, }: {
14
15
  tile: DashboardTile;
15
16
  index: number;
16
17
  selected: boolean;
@@ -32,18 +33,47 @@ export declare function TileFrame({ tile, index, selected, flash, menuOpen, bare
32
33
  onRemove: () => void;
33
34
  /** Why it cannot be removed (a saved report keeps one tile); the × says so instead. */
34
35
  removeBlocked?: string;
35
- /** This tile's edge is being dragged. */
36
- resizing?: boolean;
37
- /** Dragging the right edge sets the width; absent, the tile has no edge handle (one column, or tags the file does not own). */
38
- onResizeStart?: (event: PointerEvent<HTMLDivElement>) => void;
39
- onResizeMove?: (event: PointerEvent<HTMLDivElement>) => void;
40
- onResizeEnd?: (event: PointerEvent<HTMLDivElement>) => void;
41
- /** The tile's width and the grid's, and a step of one column: the edge's keyboard route. */
36
+ /**
37
+ * The tile's edges and corners, dragged to resize it. Nothing is drawn on
38
+ * them: the cursor turns to a two-headed arrow over an edge and a diagonal
39
+ * one over a corner. Absent, the tile cannot be resized by pointer.
40
+ */
41
+ edges?: {
42
+ /** The right edge (and its corners): off while the grid is one column. */
43
+ right: boolean;
44
+ /** The left and top edges too, which move a place: a grid drawn as a grid. */
45
+ all: boolean;
46
+ start: (event: PointerEvent<HTMLElement>, edges: Edges) => void;
47
+ move: (event: PointerEvent<HTMLElement>) => void;
48
+ end: (event: PointerEvent<HTMLElement>) => void;
49
+ /** What the drag would make the tile, in words, while this tile is resized. */
50
+ label?: string;
51
+ };
52
+ /** The tile's width and the grid's, and a step of one column: the right edge's keyboard route. */
42
53
  width?: {
43
54
  span: number;
44
55
  columns: number;
56
+ /** The widest it may go, when that is less than the grid: a placed tile stops at the right edge. */
57
+ max?: number;
45
58
  onStep: (to: number) => void;
46
59
  };
60
+ /** The tile cannot be moved now (the grid is drawn as one column). */
61
+ fixed?: boolean;
62
+ /**
63
+ * The bottom edge's keyboard route: focused, the arrow keys step the height
64
+ * a row at a time, and Delete puts the tile back to auto height, as a
65
+ * double-click on the edge does.
66
+ */
67
+ heightEdge?: {
68
+ /** Its rows: the set height, or the drag's preview; absent on auto, as tall as its row. */
69
+ rows: number | undefined;
70
+ /** The fewest rows offered before anything is known of what the tile draws. */
71
+ min: number;
72
+ /** The fewest rows offered for what the tile draws now: two for cards or a table, three for a chart. */
73
+ minFor?: (frame: Element | null) => number;
74
+ /** A keyboard step, or `undefined` to fit the content again. */
75
+ onStep: (to: number | undefined) => void;
76
+ };
47
77
  children: ReactNode;
48
78
  }): import("react/jsx-runtime").JSX.Element;
49
79
  /** How far the selection stands outside what it selects: its halo. */
@@ -89,6 +119,20 @@ export declare function GapTarget({ after }: {
89
119
  * Column guides, drawn only during a gesture: a flow grid is invisible until
90
120
  * you are trying to land on it.
91
121
  */
92
- export declare function GridGuides({ columns }: {
122
+ export declare function GridGuides({ columns, faint, }: {
93
123
  columns: number;
124
+ /** Drawn fainter, as a hint while nothing is dragged. */
125
+ faint?: boolean;
126
+ }): import("react/jsx-runtime").JSX.Element;
127
+ /**
128
+ * The rows a height snaps to, drawn while a tile's bottom edge is dragged: a
129
+ * faint band per row across the whole canvas, the way {@link GridGuides}
130
+ * draws the columns a width snaps to. Rows are counted from the dragged
131
+ * tile's top, since tiles flow and the grid has no row lines of its own.
132
+ * Behind the tiles and held inside the grid.
133
+ */
134
+ export declare function RowGuides({ top, faint, }: {
135
+ top: number;
136
+ /** Drawn fainter, as a hint while nothing is dragged. */
137
+ faint?: boolean;
94
138
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { CatalogView } from './catalog';
2
2
  import { DashboardTile } from './document';
3
+ import { ViewStatus } from './ChartPicker';
3
4
  /**
4
5
  * A tile's own settings, on the tile: a menu off its ⋯ button, so editing it
5
6
  * never means scrolling away from it. Its chart (a submenu, each pick drawn at
@@ -33,6 +34,8 @@ export interface TileMenuProps {
33
34
  /** Why the tile cannot be copied, when it cannot: Duplicate is then listed, greyed, with this under it. */
34
35
  duplicateBlocked?: string;
35
36
  /** The catalog's view the tile shows, when the catalog knows it: what decides which charts are offered. */
36
- view?: Pick<CatalogView, "chart" | "aggregateOnly">;
37
+ view?: Pick<CatalogView, "chart" | "aggregateOnly" | "shape">;
38
+ /** Why `view` is absent: still loading, or a view the catalog does not list. */
39
+ viewStatus?: ViewStatus;
37
40
  }
38
- export declare function TileMenu({ anchor, tile, onClose, onCommit, onDrills, onDuplicate, duplicateBlocked, view, }: TileMenuProps): import("react/jsx-runtime").JSX.Element;
41
+ export declare function TileMenu({ anchor, tile, onClose, onCommit, onDrills, onDuplicate, duplicateBlocked, view, viewStatus, }: TileMenuProps): import("react/jsx-runtime").JSX.Element;
@@ -31,6 +31,11 @@ export interface BuilderControls {
31
31
  /** Why a filter cannot be added here, when it cannot; `filter` is then absent. */
32
32
  filterUnavailable?: string;
33
33
  };
34
+ /**
35
+ * The layout as a whole, on a grid report whose tiles are placed: close
36
+ * its gaps, or let its tiles flow again. Absent on a report that flows.
37
+ */
38
+ arrange?: ArrangeActions;
34
39
  /** Leave the builder: asks first when edits are unsaved. Absent unless the host passed `onExit`. */
35
40
  exit?: () => void;
36
41
  /**
@@ -57,6 +62,20 @@ export interface BuilderControls {
57
62
  /** The author has seen the restored edits: `restored` goes. Present while `restored` is, and not pending. */
58
63
  dismissRestored?: () => void;
59
64
  }
65
+ /**
66
+ * What can be done to a placed report's layout as a whole, as
67
+ * {@link BuilderControls.arrange} offers it.
68
+ */
69
+ export interface ArrangeActions {
70
+ /**
71
+ * Slide every tile up into the empty space above it. Present only when
72
+ * there is such a gap: absent means there is nothing to close, and a host
73
+ * draws the action disabled (or not at all).
74
+ */
75
+ pack?: () => void;
76
+ /** Take every tile's place off, so the report flows again; sizes are kept. */
77
+ flow: () => void;
78
+ }
60
79
  /** What a host passes to take over the builder's page-level controls. */
61
80
  export type BuilderControlsHandler = (controls: BuilderControls | undefined) => void;
62
81
  /**
@@ -30,6 +30,13 @@ export interface CatalogView {
30
30
  chart?: string;
31
31
  /** Every output column is an aggregate, which is the only shape `big_value` renders. Absent when the model did not say. */
32
32
  aggregateOnly?: boolean;
33
+ /** How many of its output columns are group-bys and how many are totals, when the model said: what decides which charts can draw it. */
34
+ shape?: ViewShape;
35
+ }
36
+ /** A view's output columns by role: a group-by is a field a chart can put on its x axis, a total one it can put on its y axis. */
37
+ export interface ViewShape {
38
+ groupBys: number;
39
+ totals: number;
33
40
  }
34
41
  export interface CatalogSource {
35
42
  name: string;
@@ -52,7 +59,23 @@ export interface CatalogSource {
52
59
  }
53
60
  export interface PackageCatalog {
54
61
  sources: CatalogSource[];
62
+ /**
63
+ * The views the report file itself declares, by source then view, from the
64
+ * file's own compiled model: an inline `view: kpis is { aggregate: … }` is
65
+ * in no other model, so without these the builder could not tell which
66
+ * charts such a tile can take. Absent until that model has answered.
67
+ */
68
+ documentViews?: Map<string, Map<string, CatalogView>>;
55
69
  }
70
+ /**
71
+ * The views a report file declares, from its own compiled model, keyed by
72
+ * source then view. The file's sources extend the package's, so its model
73
+ * lists their views too; only the ones under the file's own source names are
74
+ * the file's, and those are what a tile in it names. Each carries the chart
75
+ * its view declares, as a catalog view does: a pick negates that tag, and
76
+ * without it a `# line_chart` view picked as a bar would ask for both.
77
+ */
78
+ export declare function documentViewsOf(model: CompiledModel): Map<string, Map<string, CatalogView>>;
56
79
  /**
57
80
  * The fields a filter on `source` may name: its dimensions, joins included as
58
81
  * paths. Measures are not filterable with `where:` and are left out. Undefined
@@ -1,11 +1,7 @@
1
- /**
2
- * The one `# <chart>` tag line a builder writes above a tile or a query cell.
3
- * Pure text, with no Malloy import, so both writers and the main entry can reach it.
4
- */
5
1
  /** The renderer's chart tags, as they are spelled in a model. */
6
2
  export declare const CHART_TAGS: string[];
7
3
  /** The tags the renderer has a plugin for, in the order a line negates them. */
8
- declare const PLUGIN_TAGS: readonly ["line_chart", "bar_chart", "big_value", "scatter_chart", "shape_map", "segment_map"];
4
+ declare const PLUGIN_TAGS: readonly ["line_chart", "bar_chart", "big_value", "scatter_chart", "shape_map", "segment_map", "combo_chart"];
9
5
  export type ChartPick = (typeof PLUGIN_TAGS)[number];
10
6
  /** What a picker holds: a chart, no chart (a table), the view's own (no line), or a line the builder does not model. */
11
7
  export type ChartState = ChartPick | "none" | "default" | "custom";
@@ -18,16 +14,53 @@ export interface ChartLineParts {
18
14
  export declare function parseChartLine(line: string): ChartLineParts | undefined;
19
15
  /** Some other `#` tag line that names a chart tag (`# bar_chart { size=spark }`), which a chart edit must leave alone. */
20
16
  export declare function mentionsChartTag(line: string): boolean;
17
+ /**
18
+ * The line that previews "Default" on a tile whose saved body may carry
19
+ * a chart line of its own: the chart tags taken off, and nothing put on.
20
+ * Unlike Table's line it does not negate `viz`, so it is not a choice of
21
+ * rendering: what the view's own shape gives is what draws.
22
+ *
23
+ * `big_value` is left alone. A one-row view of totals draws as big numbers
24
+ * with no tag at all (see `promoteMeasureRowToKpis`), which is what "From the
25
+ * view" must show; measured, a `# big_value` after a `# -big_value` in the
26
+ * same result does not bring the cards back, and the tile drew a one-row
27
+ * table. Big value can only have been picked on such a view, so keeping it
28
+ * changes nothing that Default would otherwise show.
29
+ */
30
+ export declare function chartResetLine(): string;
21
31
  /**
22
32
  * The line for a pick. Given the chart tags the view carries it negates only those; without them
23
33
  * (the catalog does not know the view) it negates every other chart tag. `-viz` stays either way,
24
34
  * since the catalog does not report a `viz=` tag.
35
+ *
36
+ * Table also negates `big_value` always. A one-row view of totals draws as big numbers with no
37
+ * tag of its own (`promoteMeasureRowToKpis` puts `# big_value` ahead of the view's lines), so
38
+ * "the view carries none" is not "nothing to take off": only a `-big_value` after it draws a table.
25
39
  */
26
40
  export declare function chartLineText(chart: ChartPick | "none", carried?: readonly string[]): string;
27
41
  /** The picker state of a tile's or cell's recognized chart lines. */
28
42
  export declare function chartStateOf(lines: string[]): ChartState;
29
43
  /** What a tile's `#` lines say about its chart: nothing (undefined), a state, or "custom" when any line names a chart tag the builder does not model. */
30
44
  export declare function chartStateOfTagLines(lines: string[]): ChartState | undefined;
45
+ /** The colour a builder-written colour line sets, or undefined for any other line. */
46
+ export declare function seriesColorOf(line: string): string | undefined;
47
+ /** The colour line for a tile's chart colour. */
48
+ export declare const seriesColorLine: (color: string) => string;
49
+ /**
50
+ * The line that takes a saved colour line off, for a preview of a tile set
51
+ * back to the theme's colours. The tag parser deletes just that path, so any
52
+ * other `theme.*` setting on the view stays.
53
+ */
54
+ export declare const seriesColorResetLine = "# -theme.palette.series";
55
+ /** Whether a colour is one the builder writes: `#rrggbb`. */
56
+ export declare const isSeriesColor: (value: string) => boolean;
57
+ /**
58
+ * A theme colour as the builder writes it (`#rrggbb`, lower case), or
59
+ * undefined for one it cannot write. A host theme may spell its series `#abc`,
60
+ * which is widened; a named colour or `rgb()` is not offered, since a line
61
+ * holding one would not read back (`seriesColorOf`).
62
+ */
63
+ export declare function seriesColorFrom(value: string): string | undefined;
31
64
  /** The lines of `lines` that are about the chart, recognized or not: what a "custom" state is made of. */
32
65
  export declare const chartLinesOf: (lines: string[]) => string[];
33
66
  export {};
@@ -131,8 +131,8 @@ export interface MappingRow {
131
131
  * `inline` tile's own first stage — `TreeStage.wheres` in `malloyTree`, which
132
132
  * is the parse tree's answer rather than a depth count. Both forms are
133
133
  * declarations this file owns and the reader reads back. An `inherited` tile is declared on the
134
- * model's source, which the builder never writes, so it is the one kind this
135
- * excludes, and so is an `opaque` one: its body has no single block a binding
134
+ * model's source, which the builder never writes, so it is excluded, as is a
135
+ * named `query` tile, and so is an `opaque` one: its body has no single block a binding
136
136
  * belongs in, which the reader can see before a save is ever attempted.
137
137
  */
138
138
  export declare const canBind: (tile: DashboardTile) => tile is QueryTile;
@@ -80,7 +80,7 @@ export interface DashboardDrill {
80
80
  /**
81
81
  * Where a tile's view is declared, and therefore what the builder may edit.
82
82
  *
83
- * Four forms, all of them found in dashboards that ship in this repository, and
83
+ * Five forms, all of them found in dashboards that ship in this repository, and
84
84
  * the distinction decides which affordances a tile gets:
85
85
  *
86
86
  * - `reference` — `view: revenue_trend is sales_by_month` in this file. Fully
@@ -102,6 +102,12 @@ export interface DashboardDrill {
102
102
  * tile is `orders -> by_brand` against an imported source. Nothing about it is
103
103
  * editable here, because its tags live on the model's own view and the builder
104
104
  * does not write model files. Read and shown, not changed.
105
+ * - `query` — the entry names a query rather than a view: `tiles=["by_carrier"]`
106
+ * over a `query: by_carrier is flights -> { … }`, in this file or the model.
107
+ * The tile runs `run: by_carrier`, exactly as the reader does, and has no
108
+ * `source` of its own. Like `inherited` it is read and shown, and moved or
109
+ * removed in the list, but not changed: its tags sit on a `query:` statement
110
+ * the writer does not locate, and its body may be anything a query can be.
105
111
  */
106
112
  export type TileDeclaration = {
107
113
  kind: "reference";
@@ -113,6 +119,8 @@ export type TileDeclaration = {
113
119
  why: string;
114
120
  } | {
115
121
  kind: "inherited";
122
+ } | {
123
+ kind: "query";
116
124
  };
117
125
  /** A tile that runs a view: a view shown on the page, plus how it is presented. */
118
126
  export interface QueryTile {
@@ -128,9 +136,10 @@ export interface QueryTile {
128
136
  /**
129
137
  * The source it reads, by NAME — an index would break on reorder. May name a
130
138
  * source this file declares in {@link DashboardDocument.sources}, or one it
131
- * merely imports.
139
+ * merely imports. Absent on a tile that names a query (`declaration.kind`
140
+ * `"query"`), whose source is whatever the query's own definition reads.
132
141
  */
133
- source: string;
142
+ source?: string;
134
143
  declaration: TileDeclaration;
135
144
  /**
136
145
  * Given bindings: a `+ { where: … }` refinement on a `reference` tile, or a
@@ -160,14 +169,38 @@ export interface QueryTile {
160
169
  chartLines?: string[];
161
170
  /** The chart tags the tile's view carries, when the catalog knows them: the writer negates only these. Never read from a file. */
162
171
  chartCarried?: string[];
172
+ /**
173
+ * Where the tile sits: its entry's `colspan` and `break` in `tiles=[…]`,
174
+ * or else its view's `# colspan` and `# break`. The writer puts a changed
175
+ * layout on the entry, which every tile has, and takes the view's two tags
176
+ * off a view this file declares, so the layout has one home.
177
+ */
163
178
  colspan?: number;
164
179
  break?: boolean;
180
+ /** `rowspan=N` on its entry: the grid rows it is tall. Only the entry carries it. */
181
+ rowspan?: number;
182
+ /** `row=N` and `col=N` on its entry: where it sits on a placed report, counted from 1. */
183
+ row?: number;
184
+ col?: number;
165
185
  borderless?: boolean;
186
+ /**
187
+ * The chart's colour, `#rrggbb`: its first series colour, written as the
188
+ * per-chart theme line `# theme.palette.series=["#…"]` the renderer reads.
189
+ * Absent, the chart takes the theme's own series.
190
+ */
191
+ color?: string;
192
+ /**
193
+ * The tile's own tags set `theme.palette.series` in a line the builder did
194
+ * not write: a list of two or more colours, or any other spelling. Read from
195
+ * the file, never written. The preview keeps that line when the tile is on
196
+ * Theme, where it otherwise takes a saved builder colour off.
197
+ */
198
+ ownPalette?: true;
166
199
  }
167
200
  /**
168
201
  * A markdown tile: prose between the query tiles, written as a `##|(markdown) <name>` block
169
- * and listed in `tiles=[…]` as `<name> { kind=text }`. Its width and row break live on that
170
- * list entry, since a block has no tags.
202
+ * and listed in `tiles=[…]` as `<name> { kind=text }`. Its layout lives on that list entry,
203
+ * as every tile's does.
171
204
  */
172
205
  export interface TextTile {
173
206
  kind: "text";
@@ -176,6 +209,9 @@ export interface TextTile {
176
209
  markdown: string;
177
210
  colspan?: number;
178
211
  break?: boolean;
212
+ rowspan?: number;
213
+ row?: number;
214
+ col?: number;
179
215
  }
180
216
  export type DashboardTile = QueryTile | TextTile;
181
217
  export declare const isTextTile: (tile: DashboardTile) => tile is TextTile;
@@ -211,6 +247,18 @@ export interface DashboardSource {
211
247
  /** Givens the extension's own `where:`s read, which filter every tile on it. Read-only: never written. */
212
248
  scopedBy?: string[];
213
249
  }
250
+ /**
251
+ * What a query tile runs, as its `tiles=[…]` entry names it: `source -> view`,
252
+ * or a query's bare name. The one spelling every preview, served-tile lookup
253
+ * and new list entry derives from.
254
+ */
255
+ export declare const tileExpression: (tile: QueryTile) => string;
256
+ /**
257
+ * Whether the builder can write nothing about this tile but its place in the
258
+ * list: declared on the model's view (`inherited`), or a named query, whose
259
+ * tags are on a `query:` statement the writer does not edit.
260
+ */
261
+ export declare const isReadOnlyTile: (tile: QueryTile) => boolean;
214
262
  /** A tile's identity across a reorder: what the grid keys on, a drag names and the writer matches. */
215
263
  export declare const tileKey: (tile: DashboardTile) => string;
216
264
  /** `dimension: <name> is <expression>` in the dashboard's own extension. */
@@ -1,4 +1,11 @@
1
1
  import { DashboardDocument, DashboardImport } from './document';
2
+ /**
3
+ * The package path an import names, read from where the document sits, so
4
+ * `"../m.malloy"` and `"./../m.malloy"` are the same model: comparing the text
5
+ * alone would miss the second, and importing a source the file already
6
+ * reaches declares it twice.
7
+ */
8
+ export declare const resolvedOf: (from: string, documentPath: string) => string;
2
9
  /**
3
10
  * How the report at `documentPath` names the model at `modelPath`: relative to
4
11
  * the report's own folder, with no leading `./` (`"storefront.malloy"` beside