@malloy-publisher/sdk 0.9.13 → 0.9.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/RenderedResult-BClN_PG6.cjs.js +154 -0
  2. package/dist/{RenderedResult-DnBtf-cI.es.js → RenderedResult-YBzVMVH2.es.js} +295 -234
  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 +7430 -6548
  7. package/dist/client/api.d.ts +30 -6
  8. package/dist/client/index.cjs.js +1 -1
  9. package/dist/client/index.es.js +1 -1
  10. package/dist/components/Dashboard/DashboardGrid.d.ts +49 -1
  11. package/dist/components/Dashboard/DashboardTile.d.ts +5 -2
  12. package/dist/components/Dashboard/DashboardView.d.ts +9 -2
  13. package/dist/components/Dashboard/index.d.ts +1 -1
  14. package/dist/components/Dashboard/promoteMeasureRow.d.ts +5 -7
  15. package/dist/components/Dashboard/useStuck.d.ts +18 -12
  16. package/dist/components/RenderedResult/RenderedResult.d.ts +3 -2
  17. package/dist/components/RenderedResult/ResultContainer.d.ts +11 -1
  18. package/dist/components/RenderedResult/ResultPanel.d.ts +5 -1
  19. package/dist/components/RenderedResult/chartPresentation.d.ts +15 -0
  20. package/dist/components/RenderedResult/chartShapeProblem.d.ts +55 -0
  21. package/dist/components/RenderedResult/resultSizing.d.ts +42 -6
  22. package/dist/components/Report/Report.d.ts +7 -1
  23. package/dist/components/Report/ReportPage.d.ts +7 -0
  24. package/dist/components/Report/layoutRules.d.ts +45 -0
  25. package/dist/components/ReportBuilder/AddTileDialog.d.ts +2 -1
  26. package/dist/components/ReportBuilder/BuilderGrid.d.ts +14 -1
  27. package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
  28. package/dist/components/ReportBuilder/EditorSurface.d.ts +17 -1
  29. package/dist/components/ReportBuilder/ReportEditor.d.ts +18 -0
  30. package/dist/components/ReportBuilder/TileFrame.d.ts +33 -1
  31. package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
  32. package/dist/components/ReportBuilder/catalog.d.ts +23 -0
  33. package/dist/components/ReportBuilder/chartLine.d.ts +38 -5
  34. package/dist/components/ReportBuilder/controls.d.ts +2 -2
  35. package/dist/components/ReportBuilder/document.d.ts +53 -5
  36. package/dist/components/ReportBuilder/imports.d.ts +7 -0
  37. package/dist/components/ReportBuilder/placement.d.ts +75 -0
  38. package/dist/components/ReportBuilder/preview.d.ts +59 -10
  39. package/dist/components/ReportBuilder/sortable.d.ts +3 -1
  40. package/dist/components/ReportBuilder/useTileHeight.d.ts +39 -0
  41. package/dist/components/ReportBuilder/useTileReorder.d.ts +27 -3
  42. package/dist/components/ReportBuilder/useTileResize.d.ts +8 -0
  43. package/dist/index.cjs.js +7 -7
  44. package/dist/index.es.js +3328 -3287
  45. package/dist/text/index.es.js +1 -1
  46. package/dist/{text-entry-72YFLeNk.es.js → text-entry-YKJZbRPo.es.js} +2 -2
  47. package/dist/theme/resolveTheme.d.ts +15 -0
  48. package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-BGk38oaW.es.js} +5097 -4805
  49. package/dist/useCompiledDocument-D9t5ry_t.cjs.js +142 -0
  50. package/dist/utils/blankQuoted.d.ts +15 -0
  51. package/package.json +1 -1
  52. package/src/components/Dashboard/DashboardGrid.tsx +127 -10
  53. package/src/components/Dashboard/DashboardTile.tsx +11 -1
  54. package/src/components/Dashboard/DashboardView.tsx +63 -10
  55. package/src/components/Dashboard/TileCard.tsx +6 -0
  56. package/src/components/Dashboard/index.ts +1 -0
  57. package/src/components/Dashboard/promoteMeasureRow.spec.ts +19 -0
  58. package/src/components/Dashboard/promoteMeasureRow.ts +15 -36
  59. package/src/components/Dashboard/tileHeight.spec.ts +72 -0
  60. package/src/components/Dashboard/useStuck.ts +76 -28
  61. package/src/components/Package/NewDocumentDialog.spec.tsx +20 -16
  62. package/src/components/Package/NewDocumentDialog.tsx +10 -11
  63. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +167 -2
  64. package/src/components/RenderedResult/RenderedResult.tsx +21 -6
  65. package/src/components/RenderedResult/ResultContainer.tsx +60 -7
  66. package/src/components/RenderedResult/ResultPanel.tsx +21 -1
  67. package/src/components/RenderedResult/chartPresentation.spec.ts +153 -0
  68. package/src/components/RenderedResult/chartPresentation.ts +166 -0
  69. package/src/components/RenderedResult/chartShapeProblem.spec.tsx +245 -0
  70. package/src/components/RenderedResult/chartShapeProblem.ts +219 -0
  71. package/src/components/RenderedResult/resultSizing.spec.ts +75 -3
  72. package/src/components/RenderedResult/resultSizing.ts +65 -11
  73. package/src/components/Report/Report.spec.tsx +19 -0
  74. package/src/components/Report/Report.tsx +8 -1
  75. package/src/components/Report/ReportPage.tsx +13 -1
  76. package/src/components/Report/layoutRules.spec.ts +43 -3
  77. package/src/components/Report/layoutRules.ts +70 -0
  78. package/src/components/Report/tileOverflow.spec.tsx +162 -0
  79. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +2 -2
  80. package/src/components/ReportBuilder/AddTileDialog.tsx +11 -6
  81. package/src/components/ReportBuilder/BuilderBar.tsx +1 -1
  82. package/src/components/ReportBuilder/BuilderDialogs.tsx +20 -0
  83. package/src/components/ReportBuilder/BuilderGrid.tsx +126 -20
  84. package/src/components/ReportBuilder/ChartPicker.spec.ts +91 -4
  85. package/src/components/ReportBuilder/ChartPicker.tsx +45 -10
  86. package/src/components/ReportBuilder/DrillDialog.tsx +8 -2
  87. package/src/components/ReportBuilder/EditorSurface.tsx +110 -28
  88. package/src/components/ReportBuilder/FilterDialog.tsx +17 -8
  89. package/src/components/ReportBuilder/FilterStrip.tsx +2 -1
  90. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +193 -2
  91. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
  92. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +2 -2
  93. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +143 -2
  94. package/src/components/ReportBuilder/ReportBuilder.tsx +73 -19
  95. package/src/components/ReportBuilder/ReportEditor.fileModel.spec.tsx +178 -0
  96. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +3 -5
  97. package/src/components/ReportBuilder/ReportEditor.queryVersion.spec.tsx +292 -0
  98. package/src/components/ReportBuilder/ReportEditor.readOnlyTitle.spec.tsx +92 -0
  99. package/src/components/ReportBuilder/ReportEditor.tsx +35 -0
  100. package/src/components/ReportBuilder/TileFrame.tsx +251 -6
  101. package/src/components/ReportBuilder/TileMenu.tsx +259 -20
  102. package/src/components/ReportBuilder/ViewPicker.tsx +4 -3
  103. package/src/components/ReportBuilder/addTileToDocument.spec.ts +34 -0
  104. package/src/components/ReportBuilder/addTileToDocument.ts +26 -1
  105. package/src/components/ReportBuilder/catalog.aggregate.spec.ts +137 -1
  106. package/src/components/ReportBuilder/catalog.ts +90 -37
  107. package/src/components/ReportBuilder/chartLine.spec.ts +42 -5
  108. package/src/components/ReportBuilder/chartLine.ts +80 -2
  109. package/src/components/ReportBuilder/controls.ts +4 -3
  110. package/src/components/ReportBuilder/document.ts +65 -7
  111. package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
  112. package/src/components/ReportBuilder/entryLayout.spec.ts +151 -0
  113. package/src/components/ReportBuilder/imports.ts +1 -1
  114. package/src/components/ReportBuilder/invariants.spec.ts +18 -10
  115. package/src/components/ReportBuilder/layout.ts +3 -0
  116. package/src/components/ReportBuilder/placement.spec.ts +193 -0
  117. package/src/components/ReportBuilder/placement.ts +250 -0
  118. package/src/components/ReportBuilder/preview.shapes.spec.ts +46 -6
  119. package/src/components/ReportBuilder/preview.spec.ts +151 -11
  120. package/src/components/ReportBuilder/preview.ts +203 -40
  121. package/src/components/ReportBuilder/preview.unsaved.compile.spec.ts +190 -0
  122. package/src/components/ReportBuilder/readDocument.spec.ts +46 -2
  123. package/src/components/ReportBuilder/readDocument.ts +194 -23
  124. package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
  125. package/src/components/ReportBuilder/sortable.tsx +4 -0
  126. package/src/components/ReportBuilder/spliceDocument.chart.spec.ts +1 -1
  127. package/src/components/ReportBuilder/spliceDocument.color.spec.ts +80 -0
  128. package/src/components/ReportBuilder/spliceDocument.colspan.spec.ts +78 -0
  129. package/src/components/ReportBuilder/spliceDocument.spec.ts +110 -18
  130. package/src/components/ReportBuilder/spliceDocument.ts +139 -52
  131. package/src/components/ReportBuilder/statementExtent.spec.ts +3 -3
  132. package/src/components/ReportBuilder/testing/reportGivenOrder.json +42 -0
  133. package/src/components/ReportBuilder/textTiles.spec.ts +2 -2
  134. package/src/components/ReportBuilder/tileDisplayTitle.ts +2 -2
  135. package/src/components/ReportBuilder/useTileEditing.ts +16 -3
  136. package/src/components/ReportBuilder/useTileHeight.ts +149 -0
  137. package/src/components/ReportBuilder/useTileReorder.ts +143 -6
  138. package/src/components/ReportBuilder/useTileResize.ts +16 -1
  139. package/src/components/given/FilterButton.spec.tsx +27 -11
  140. package/src/components/given/FilterButton.tsx +19 -6
  141. package/src/theme/resolveTheme.spec.ts +72 -1
  142. package/src/theme/resolveTheme.ts +43 -0
  143. package/src/utils/blankQuoted.spec.ts +50 -0
  144. package/src/utils/blankQuoted.ts +32 -0
  145. package/src/utils/malloyText.ts +2 -1
  146. package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
  147. package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
  148. package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
@@ -16,18 +16,27 @@ import { DashboardDocument, QueryTile } from './document';
16
16
  * moment it is added rather than after a save.
17
17
  */
18
18
  /**
19
- * The controls this document shows: every given some tile binds, this file's
20
- * own declarations first in declaration order, then the model's in the
21
- * manifest's order, whether a tile binds one in this file or reads it through
22
- * the model (`modelReads`, from {@link givensReadThroughModel}).
19
+ * The controls this document shows, in the order the reader shows them: every
20
+ * given some tile binds in this file or reads through the model (`modelReads`,
21
+ * from {@link givensReadThroughModel}).
23
22
  *
24
23
  * That is the reader's rule — only a given some tile reads becomes a control
25
- * — applied to the document instead of the manifest. A local declaration is
26
- * built into a `Given` from its control contract; a model given is the
27
- * manifest's own spec, which carries what the file cannot say (`givenNames` a
28
- * suggest is gated by, for one).
24
+ * — applied to the document instead of the manifest, and so is the order. The
25
+ * server builds the row tile by tile, in tile order, each tile's givens as its
26
+ * compiled query reads them: what the tile's source reads first, then the
27
+ * tile's own `where:` bindings. So here too: per tile, the givens its served
28
+ * self read (`servedReads`), less the bindings since removed, then the tile's
29
+ * current bindings not already listed — a new filter lands after the tile's
30
+ * existing ones, where the save will put it. A model read no tile position
31
+ * accounts for (no `servedReads` given) goes first, in the manifest's order,
32
+ * since a model read is a source's and the reader lists a source's first.
33
+ *
34
+ * A local declaration is built into a `Given` from its control contract, and
35
+ * wins over a model given of the same name; a model given is the manifest's
36
+ * own spec, which carries what the file cannot say (`givenNames` a suggest is
37
+ * gated by, for one).
29
38
  */
30
- export declare function previewGivens(document: DashboardDocument, modelSpecs: readonly Given[], modelReads?: ReadonlySet<string>): Given[];
39
+ export declare function previewGivens(document: DashboardDocument, modelSpecs: readonly Given[], modelReads?: ReadonlySet<string>, servedReads?: ReadonlyMap<string, readonly string[]>): Given[];
31
40
  /**
32
41
  * The givens the document's tiles read through the model rather than through
33
42
  * a binding in this file: a source whose own `where:` reads a given, say.
@@ -69,7 +78,45 @@ export interface PreviewTileQuery {
69
78
  * side reads no given either.
70
79
  */
71
80
  reads: string[] | undefined;
81
+ /**
82
+ * The package model to run on instead of the report's own. Set only where
83
+ * the tile's source comes in through an import the served report does not
84
+ * have yet; see {@link UnsavedSources}.
85
+ */
86
+ modelPath?: string;
87
+ }
88
+ /**
89
+ * What the builder added that the served model does not have yet, so a tile on
90
+ * it can be previewed before the save.
91
+ *
92
+ * Add tile puts a tile on the file's extension of its source, and where the
93
+ * file has none it declares a new one: `source: flights_tiles is flights extend
94
+ * { view: kpis_tile is kpis }`. Until the file is saved and served, the model
95
+ * the tiles run on has no `flights_tiles`, and `flights_tiles -> kpis` fails as
96
+ * a reference to an undefined object. A new extension declares no `where:` and
97
+ * no field, so its views are its base's, and `flights -> kpis` returns what the
98
+ * saved page will.
99
+ */
100
+ export interface UnsavedSources {
101
+ /** The document's extensions that the served model does not declare. */
102
+ sources: ReadonlySet<string>;
103
+ /**
104
+ * The package path of the model to run `base` on, when the served report
105
+ * cannot see `base` because its import is unsaved too. Undefined: the
106
+ * report's own model sees it.
107
+ */
108
+ modelOf?: (base: string) => string | undefined;
72
109
  }
110
+ /**
111
+ * The {@link UnsavedSources} of `document` against the document as it was
112
+ * opened, which is what the served model was built from. Undefined when the
113
+ * document declares no extension the opened one did not.
114
+ *
115
+ * A base the opened file could not see came in with an import this session
116
+ * added, and runs on the model that import names. A report held as text has no
117
+ * imports: its sources are all the run model's.
118
+ */
119
+ export declare function unsavedSources(document: DashboardDocument, opened: DashboardDocument, documentPath: string, textHeld: boolean): UnsavedSources | undefined;
73
120
  /**
74
121
  * A tile's query with the DOCUMENT's bindings, run on the dashboard's own
75
122
  * extension.
@@ -109,4 +156,6 @@ export interface PreviewTileQuery {
109
156
  */
110
157
  export declare function previewTileQuery(document: DashboardDocument, tile: QueryTile, runnable: ReadonlySet<string>, values?: ReadonlyMap<string, GivenValue>,
111
158
  /** What the served file's compiled tile reads (`DashboardTile.givenNames`), when it has this tile. */
112
- served?: readonly string[]): PreviewTileQuery;
159
+ served?: readonly string[],
160
+ /** What the served model does not have yet; see {@link UnsavedSources}. */
161
+ unsaved?: UnsavedSources): PreviewTileQuery;
@@ -37,9 +37,11 @@ interface TileSortableHandles {
37
37
  * `index` is the tile's place in the PREVIEWED order, which is what lets the
38
38
  * library animate a tile to its new slot when that order changes under it.
39
39
  */
40
- export declare function TileSortable({ id, index, children, }: {
40
+ export declare function TileSortable({ id, index, disabled, children, }: {
41
41
  id: string;
42
42
  index: number;
43
+ /** Not movable now: the grid is drawn as one column, where a move means nothing. */
44
+ disabled?: boolean;
43
45
  children: (handles: TileSortableHandles) => ReactNode;
44
46
  }): import("react/jsx-runtime").JSX.Element;
45
47
  /** What a gap drop target carries: the key of the tile the gap follows. */
@@ -0,0 +1,39 @@
1
+ import { RefObject } from 'react';
2
+ import { DashboardTile } from './document';
3
+ /** A height drag in flight: the tile, what it WOULD be, and where its top sits. */
4
+ export interface HeightState {
5
+ index: number;
6
+ /** The rows it would be, or undefined for auto: no `rowspan`, as tall as its row. */
7
+ rows: number | undefined;
8
+ /** Its `rowspan` when the drag began: a release that changed nothing writes nothing. */
9
+ from: number | undefined;
10
+ top: number;
11
+ /** The tile's top against the grid's, where the row guides are drawn from. */
12
+ guideTop: number;
13
+ }
14
+ /**
15
+ * Dragging a tile's bottom edge to set its `rowspan`, in whole grid rows, or
16
+ * back to auto. Previewed by the caller from `height.rows` and written ONCE,
17
+ * on release, so one gesture is one undo step.
18
+ *
19
+ * Auto is a snap point of its own. A tile with no `rowspan` is as tall as its
20
+ * row, and a row of such tiles is as tall as its tallest content, which is
21
+ * almost never a whole number of rows: 492px sits between 5 rows (464) and 6
22
+ * (560). With rows alone a tile could never be dragged level with an auto
23
+ * neighbour; snapping to the row's own height, and writing that as no
24
+ * `rowspan`, is what makes level reachable.
25
+ */
26
+ export declare function useTileHeight({ tiles, gridBox, onStart, commit, }: {
27
+ tiles: readonly DashboardTile[];
28
+ /** Wraps the grid: row-mates are found in it and the row guides are placed against it. */
29
+ gridBox: RefObject<HTMLDivElement | null>;
30
+ /** The tile a drag begins on, which the caller selects. */
31
+ onStart: (index: number) => void;
32
+ /** What to write when the drag ends: rows, or undefined to take the `rowspan` off. */
33
+ commit: (index: number, rows: number | undefined) => void;
34
+ }): {
35
+ height: HeightState;
36
+ startHeight: (event: React.PointerEvent<HTMLDivElement>, index: number) => void;
37
+ onHeight: (event: React.PointerEvent<HTMLDivElement>) => void;
38
+ endHeight: (event: React.PointerEvent<HTMLDivElement>) => void;
39
+ };
@@ -1,4 +1,5 @@
1
- import { DragEndEvent, DragOverEvent } from '@dnd-kit/react';
1
+ import { DragEndEvent, DragMoveEvent, DragOverEvent } from '@dnd-kit/react';
2
+ import { RefObject } from 'react';
2
3
  import { DashboardTile } from './document';
3
4
  /**
4
5
  * Dragging a tile to reorder it. The gesture is `@dnd-kit/react`'s (see
@@ -7,8 +8,18 @@ import { DashboardTile } from './document';
7
8
  * drop into the empty end of a row. The preview is rebuilt on each report and
8
9
  * written ONCE, on release: one history entry for the whole drag.
9
10
  */
10
- export declare function useTileReorder({ tiles, commit, onLanded, }: {
11
+ export declare function useTileReorder({ tiles, commit, onLanded, placement, }: {
11
12
  tiles: DashboardTile[];
13
+ /**
14
+ * Set on a grid report, where a move is free placement: the tile lands in
15
+ * the cell under it and anything it covers is pushed down. Absent, a move
16
+ * reorders the tiles, as a linear report's does.
17
+ */
18
+ placement?: {
19
+ columns: number;
20
+ /** Wraps the grid, so its box is the grid's. */
21
+ gridBox: RefObject<HTMLDivElement | null>;
22
+ };
12
23
  /** The order to write when the drag ends somewhere new. */
13
24
  commit: (next: DashboardTile[]) => void;
14
25
  /** Where the dragged tile came to rest, which the caller selects. */
@@ -16,7 +27,20 @@ export declare function useTileReorder({ tiles, commit, onLanded, }: {
16
27
  }): {
17
28
  dragging: boolean;
18
29
  preview: DashboardTile[];
19
- onDragStart: () => void;
30
+ onDragStart: (event?: {
31
+ operation: {
32
+ source: {
33
+ id: unknown;
34
+ } | null;
35
+ position?: {
36
+ current: {
37
+ x: number;
38
+ y: number;
39
+ };
40
+ };
41
+ };
42
+ }) => void;
43
+ onDragMove: (event: DragMoveEvent) => void;
20
44
  onDragOver: (event: DragOverEvent) => void;
21
45
  onDragEnd: (event: DragEndEvent) => void;
22
46
  };
@@ -1,5 +1,11 @@
1
1
  import { RefObject } from 'react';
2
2
  import { DashboardTile } from './document';
3
+ /**
4
+ * The widest a tile may be dragged: the whole grid, or, for a placed tile, up
5
+ * to the grid's right edge from its column. A right edge dragged past the grid
6
+ * stops there; it never moves the tile's left edge.
7
+ */
8
+ export declare const widestFrom: (tile: DashboardTile | undefined, columns: number) => number;
3
9
  /** A resize in flight: the tile, the width it WOULD be, and the geometry. */
4
10
  export interface ResizeState {
5
11
  index: number;
@@ -8,6 +14,8 @@ export interface ResizeState {
8
14
  from: number;
9
15
  left: number;
10
16
  track: number;
17
+ /** The widest it may go: to the grid's right edge from the column a placed tile starts in. */
18
+ max: number;
11
19
  }
12
20
  /**
13
21
  * Dragging a tile's right edge to set its `colspan`. The width is previewed