@malloy-publisher/sdk 0.9.10 → 0.9.12

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 (263) hide show
  1. package/dist/{RenderedResult-Dp1Qdajz.es.js → RenderedResult-CDiXJAh9.es.js} +102 -102
  2. package/dist/RenderedResult-De51QvsZ.cjs.js +153 -0
  3. package/dist/ServerProvider-DKrBcXL7.cjs.js +1 -0
  4. package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-RvKSbvnL.es.js} +622 -587
  5. package/dist/builder/index.cjs.js +78 -130
  6. package/dist/builder/index.es.js +7493 -6769
  7. package/dist/builder-entry.d.ts +3 -0
  8. package/dist/client/api.d.ts +72 -23
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +1 -1
  11. package/dist/components/AppDialog.d.ts +9 -1
  12. package/dist/components/Connections/common.d.ts +11 -3
  13. package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
  14. package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
  15. package/dist/components/Dashboard/DashboardView.d.ts +22 -34
  16. package/dist/components/Dashboard/TileCard.d.ts +10 -3
  17. package/dist/components/Dashboard/useStuck.d.ts +15 -7
  18. package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
  19. package/dist/components/Package/PackageProblems.d.ts +14 -0
  20. package/dist/components/RemoveBadge.d.ts +40 -0
  21. package/dist/components/Report/Report.d.ts +13 -4
  22. package/dist/components/Report/ReportPage.d.ts +60 -0
  23. package/dist/components/Report/layoutRules.d.ts +32 -0
  24. package/dist/components/Report/reportQuery.d.ts +30 -0
  25. package/dist/components/Report/telemetry.d.ts +0 -2
  26. package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
  27. package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
  28. package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
  29. package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
  30. package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
  31. package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
  32. package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
  33. package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
  34. package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
  35. package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -8
  36. package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
  37. package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
  38. package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
  39. package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
  40. package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
  41. package/dist/components/ReportBuilder/TileMenu.d.ts +12 -9
  42. package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
  43. package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
  44. package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
  45. package/dist/components/ReportBuilder/catalog.d.ts +2 -4
  46. package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
  47. package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
  48. package/dist/components/ReportBuilder/preview.d.ts +17 -2
  49. package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
  50. package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
  51. package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
  52. package/dist/components/ReportBuilder/sortable.d.ts +4 -3
  53. package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
  54. package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
  55. package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
  56. package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
  57. package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
  58. package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
  59. package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
  60. package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
  61. package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
  62. package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
  63. package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
  64. package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
  65. package/dist/components/ServerProvider.d.ts +9 -0
  66. package/dist/components/controlTokens.d.ts +45 -0
  67. package/dist/components/drill/markDrillableCells.d.ts +1 -1
  68. package/dist/components/given/FilterButton.d.ts +35 -0
  69. package/dist/components/given/GivensPanel.d.ts +2 -1
  70. package/dist/components/given/filterEditing.d.ts +54 -0
  71. package/dist/components/given/filterSummary.d.ts +9 -0
  72. package/dist/components/given/paramCodec.d.ts +11 -0
  73. package/dist/components/given/required.d.ts +25 -0
  74. package/dist/components/index.d.ts +3 -0
  75. package/dist/components/legacy/index.d.ts +1 -1
  76. package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
  77. package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
  78. package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
  79. package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
  80. package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
  81. package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
  82. package/dist/components/styles.d.ts +0 -2
  83. package/dist/hooks/useQueryResult.d.ts +7 -0
  84. package/dist/index.cjs.js +16 -19
  85. package/dist/index.es.js +8418 -7722
  86. package/dist/theme/ThemeContext.d.ts +8 -1
  87. package/dist/theme/classes.d.ts +49 -0
  88. package/dist/theme/index.d.ts +2 -0
  89. package/dist/theme/types.d.ts +7 -0
  90. package/dist/theme/ui.d.ts +75 -0
  91. package/dist/{useCompiledDocument-BMPDvdFx.es.js → useCompiledDocument-Bf4RSfB6.es.js} +8669 -7851
  92. package/dist/useCompiledDocument-XsQz85Ri.cjs.js +141 -0
  93. package/package.json +2 -2
  94. package/src/builder-entry.ts +9 -0
  95. package/src/components/AppDialog.tsx +23 -0
  96. package/src/components/Connections/AddConnectionDialog.tsx +34 -2
  97. package/src/components/Connections/EditConnectionDialog.tsx +45 -3
  98. package/src/components/Connections/common.spec.ts +69 -0
  99. package/src/components/Connections/common.ts +132 -0
  100. package/src/components/Dashboard/DashboardGrid.tsx +39 -17
  101. package/src/components/Dashboard/DashboardTile.tsx +19 -2
  102. package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
  103. package/src/components/Dashboard/DashboardView.tsx +137 -155
  104. package/src/components/Dashboard/RowsDialog.tsx +1 -2
  105. package/src/components/Dashboard/TileCard.tsx +28 -10
  106. package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
  107. package/src/components/Dashboard/useStuck.ts +28 -17
  108. package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
  109. package/src/components/Environment/Connections.tsx +1 -0
  110. package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
  111. package/src/components/Package/NewDocumentDialog.tsx +383 -119
  112. package/src/components/Package/Package.artifacts.spec.tsx +1 -1
  113. package/src/components/Package/Package.create.spec.tsx +7 -6
  114. package/src/components/Package/Package.tsx +10 -7
  115. package/src/components/Package/PackageProblems.spec.tsx +41 -0
  116. package/src/components/Package/PackageProblems.tsx +95 -0
  117. package/src/components/Prose.tsx +12 -7
  118. package/src/components/RemoveBadge.tsx +94 -0
  119. package/src/components/RenderedResult/RenderedResult.tsx +5 -9
  120. package/src/components/RenderedResult/ResultPanel.tsx +59 -3
  121. package/src/components/Report/Report.spec.tsx +50 -32
  122. package/src/components/Report/Report.telemetry.spec.tsx +0 -45
  123. package/src/components/Report/Report.tsx +45 -77
  124. package/src/components/Report/ReportPage.tsx +168 -0
  125. package/src/components/Report/layoutRules.spec.ts +35 -0
  126. package/src/components/Report/layoutRules.ts +55 -0
  127. package/src/components/Report/reportQuery.ts +53 -0
  128. package/src/components/Report/telemetry.ts +0 -2
  129. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
  130. package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
  131. package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
  132. package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -39
  133. package/src/components/ReportBuilder/BuilderGrid.tsx +31 -29
  134. package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
  135. package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
  136. package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
  137. package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
  138. package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
  139. package/src/components/ReportBuilder/FilterStrip.tsx +130 -151
  140. package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
  141. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
  142. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
  143. package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
  144. package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -15
  145. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
  146. package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
  147. package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
  148. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +37 -31
  149. package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
  150. package/src/components/ReportBuilder/ReportBuilder.tsx +292 -117
  151. package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
  152. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
  153. package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
  154. package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
  155. package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
  156. package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
  157. package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
  158. package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
  159. package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
  160. package/src/components/ReportBuilder/TileFrame.tsx +212 -75
  161. package/src/components/ReportBuilder/TileMenu.tsx +241 -140
  162. package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
  163. package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
  164. package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
  165. package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
  166. package/src/components/ReportBuilder/builderControls.ts +164 -0
  167. package/src/components/ReportBuilder/builderReport.ts +1 -2
  168. package/src/components/ReportBuilder/catalog.ts +10 -26
  169. package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
  170. package/src/components/ReportBuilder/localGiven.ts +56 -0
  171. package/src/components/ReportBuilder/preview.spec.ts +125 -5
  172. package/src/components/ReportBuilder/preview.ts +60 -44
  173. package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
  174. package/src/components/ReportBuilder/readDocument.ts +14 -11
  175. package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
  176. package/src/components/ReportBuilder/readForEditor.ts +4 -26
  177. package/src/components/ReportBuilder/reportTag.ts +28 -7
  178. package/src/components/ReportBuilder/sortable.tsx +15 -7
  179. package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
  180. package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
  181. package/src/components/ReportBuilder/testing/inline.ts +25 -5
  182. package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
  183. package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
  184. package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
  185. package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
  186. package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
  187. package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
  188. package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
  189. package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
  190. package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
  191. package/src/components/ReportBuilder/useExitGuard.ts +16 -0
  192. package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
  193. package/src/components/ReportBuilder/useFilterForm.ts +5 -1
  194. package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
  195. package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
  196. package/src/components/ReportBuilder/useReportDraft.ts +292 -0
  197. package/src/components/ReportBuilder/useReportEditor.ts +3 -12
  198. package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
  199. package/src/components/ReportBuilder/useTileEditing.ts +43 -12
  200. package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
  201. package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
  202. package/src/components/ReportBuilder/widthLabel.ts +26 -0
  203. package/src/components/ServerProvider.tsx +11 -0
  204. package/src/components/controlTokens.ts +47 -0
  205. package/src/components/drill/markDrillableCells.ts +2 -1
  206. package/src/components/given/FilterButton.spec.tsx +143 -0
  207. package/src/components/given/FilterButton.tsx +478 -0
  208. package/src/components/given/GivenInput.spec.tsx +47 -0
  209. package/src/components/given/GivenInput.tsx +20 -2
  210. package/src/components/given/GivensPanel.spec.tsx +11 -3
  211. package/src/components/given/GivensPanel.tsx +45 -44
  212. package/src/components/given/filterEditing.ts +60 -0
  213. package/src/components/given/filterSummary.spec.ts +108 -0
  214. package/src/components/given/filterSummary.ts +109 -0
  215. package/src/components/given/paramCodec.ts +1 -1
  216. package/src/components/given/required.spec.ts +60 -0
  217. package/src/components/given/required.ts +78 -0
  218. package/src/components/index.ts +9 -0
  219. package/src/components/legacy/Dashboard.spec.tsx +3 -1
  220. package/src/components/legacy/index.ts +1 -1
  221. package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
  222. package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
  223. package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
  224. package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
  225. package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
  226. package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
  227. package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
  228. package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
  229. package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
  230. package/src/components/legacy/malloynb/cellKind.ts +24 -0
  231. package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
  232. package/src/components/styles.ts +0 -18
  233. package/src/hooks/useGivensState.ts +7 -3
  234. package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
  235. package/src/hooks/useQueryResult.ts +26 -1
  236. package/src/theme/ThemeContext.tsx +21 -1
  237. package/src/theme/classes.ts +52 -0
  238. package/src/theme/index.ts +8 -0
  239. package/src/theme/resolveTheme.ts +3 -0
  240. package/src/theme/types.ts +7 -0
  241. package/src/theme/ui.spec.tsx +91 -0
  242. package/src/theme/ui.ts +115 -0
  243. package/dist/RenderedResult-BcgYjkZ0.cjs.js +0 -153
  244. package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
  245. package/dist/components/Notebook/cellKind.d.ts +0 -20
  246. package/dist/components/Report/LinearReport.d.ts +0 -18
  247. package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
  248. package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
  249. package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
  250. package/dist/useCompiledDocument-UY28ITET.cjs.js +0 -141
  251. package/src/components/Notebook/cellKind.spec.ts +0 -199
  252. package/src/components/Notebook/cellKind.ts +0 -74
  253. package/src/components/Report/LinearReport.tsx +0 -71
  254. package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
  255. package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
  256. package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
  257. package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
  258. package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
  259. package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
  260. package/src/components/legacy/Notebook.served.spec.tsx +0 -183
  261. /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
  262. /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
  263. /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
@@ -0,0 +1,12 @@
1
+ import { Given } from '../../client';
2
+ import { LocalGiven } from './document';
3
+ /**
4
+ * A `given:` a report declares itself, as the `Given` spec its filter control
5
+ * is drawn from: the spec the server would publish for the same declaration
6
+ * once the report is served.
7
+ *
8
+ * Exported for a host that holds a report as text and draws its controls
9
+ * itself, so a filter it declares looks and behaves as it will once the
10
+ * report is published.
11
+ */
12
+ export declare function localGivenSpec(local: LocalGiven): Given;
@@ -17,7 +17,9 @@ import { DashboardDocument, QueryTile } from './document';
17
17
  */
18
18
  /**
19
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.
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}).
21
23
  *
22
24
  * That is the reader's rule — only a given some tile reads becomes a control
23
25
  * — applied to the document instead of the manifest. A local declaration is
@@ -25,7 +27,20 @@ import { DashboardDocument, QueryTile } from './document';
25
27
  * manifest's own spec, which carries what the file cannot say (`givenNames` a
26
28
  * suggest is gated by, for one).
27
29
  */
28
- export declare function previewGivens(document: DashboardDocument, modelSpecs: readonly Given[]): Given[];
30
+ export declare function previewGivens(document: DashboardDocument, modelSpecs: readonly Given[], modelReads?: ReadonlySet<string>): Given[];
31
+ /**
32
+ * The givens the document's tiles read through the model rather than through
33
+ * a binding in this file: a source whose own `where:` reads a given, say.
34
+ *
35
+ * The server says what each served tile reads (`servedReads`, by tile
36
+ * expression), bindings in the file included. What the file bound when it
37
+ * was opened is taken back out, so what is left is what the model reads; a
38
+ * binding the author removes then takes its control with it. A tile the
39
+ * server has not compiled (new, or under a new name) is read by the served
40
+ * tile with the same expression, if there is one, and otherwise reads
41
+ * nothing until the next save.
42
+ */
43
+ export declare function givensReadThroughModel(document: DashboardDocument, opened: DashboardDocument, servedReads: ReadonlyMap<string, readonly string[]>): Set<string>;
29
44
  /** A tile expression as the server keys it, so `a->b` and `a -> b` match. */
30
45
  export declare function tileExpressionKey(expression: string): string;
31
46
  /** A tile's query as the document has it, and the givens it sends. */
@@ -29,8 +29,6 @@ export interface ReadFailure {
29
29
  reason: string;
30
30
  /** 1-based, for a message that can point at the line. */
31
31
  line?: number;
32
- /** The file is a linear report in the run-cell format, which `convertLegacyNotebook` turns into a tile layout. */
33
- legacyNotebook?: true;
34
32
  }
35
33
  export type ReadResult = {
36
34
  ok: true;
@@ -1,16 +1,11 @@
1
1
  import { DashboardDocument } from './document';
2
- /** A file opened for editing: its document, and the conversion it is the result of when the file is a cell-format notebook. */
2
+ /** A file opened for editing: its document, or why it cannot be opened. */
3
3
  export type EditorOpen = {
4
4
  ok: true;
5
5
  document: DashboardDocument;
6
- /** `from` is the text on disk, `to` the layout text it converts to. */
7
- conversion?: {
8
- from: string;
9
- to: string;
10
- };
11
6
  } | {
12
7
  ok: false;
13
8
  reason: string;
14
9
  };
15
- /** Read `text` for the builder, converting a cell-format notebook rather than refusing it. */
10
+ /** Read `text` for the builder, with the line a refusal points at in its reason. */
16
11
  export declare function readForEditor(text: string): Promise<EditorOpen>;
@@ -16,6 +16,9 @@ export type ReportTag = {
16
16
  } | {
17
17
  status: "kind-removed";
18
18
  kind: string;
19
+ } | {
20
+ status: "cells-removed";
21
+ unknownLayout?: string;
19
22
  } | {
20
23
  status: "report";
21
24
  layout: ReportLayout;
@@ -30,9 +33,14 @@ type TagReads = {
30
33
  tag(key: string): TagReads | undefined;
31
34
  text(key: string): string | undefined;
32
35
  has(key: string): boolean;
36
+ array(key: string): unknown[] | undefined;
33
37
  };
34
38
  /** Why a `kind=` tag makes no report, and the fix: the server's message, word for word. */
35
39
  export declare const kindRemovedReason: (kind: string) => string;
40
+ /** Why a tileless tag naming an unknown layout makes no report, and the fix: the server's message, capitalized. */
41
+ export declare const unknownLayoutReason: (layout: string) => string;
42
+ /** Why a linear tag with no `tiles` makes no report, and the fix: the server's message, capitalized. */
43
+ export declare const CELLS_REMOVED_REASON = "A linear report written as `run:` cells is no longer read, so this file is not a report. Fix: list its tiles in `tiles=[\u2026]` (a text tile per prose block, a query tile per view), or remove the `## artifact` tag.";
36
44
  /**
37
45
  * The one reader of a report's tag in the SDK, over a file's model-level
38
46
  * notes (`ParsedMalloy.modelNotes`). The server's `readReportTag` is the same
@@ -40,7 +48,9 @@ export declare const kindRemovedReason: (kind: string) => string;
40
48
  *
41
49
  * The layout, first match wins: `layout=grid|linear`; else grid when the tag
42
50
  * lists `tiles` (an empty list counts) or a model-level `dashboard { … }` grid
43
- * tag is present; else linear.
51
+ * tag is present; else linear. A linear tag with no `tiles` key (an empty
52
+ * list counts as one) is the retired cell format, and no report. A `tiles`
53
+ * that is not a list (`tiles=foo`) is a tag the reader cannot use: unparsed.
44
54
  */
45
55
  export declare function readReportTag(modelNotes: readonly string[], parseAnnotation: (lines: string[]) => Parsed): ReportTag;
46
56
  /**
@@ -6,9 +6,10 @@ export declare const GAP_TYPE = "gap";
6
6
  /**
7
7
  * The sensors: the library's own, with one addition.
8
8
  *
9
- * `activatorElements`: the whole tile starts a pointer drag,
10
- * not only the grip. A 22px corner that appears on hover is not a target a
11
- * reader finds; the whole card is. The grip stays the `handle`, which is what
9
+ * `activatorElements`: the whole tile starts a pointer drag, not only the
10
+ * grip, except inside its rendered result (see `preventActivation`). A 22px
11
+ * corner that appears on hover is not a target a reader finds; the card's
12
+ * heading and padding are. The grip stays the `handle`, which is what
12
13
  * gives it keyboard focus and the screen-reader instructions — and, by the
13
14
  * library's own rule, a press on the handle drags at once while a press
14
15
  * anywhere else on the card waits for a short hold or a few pixels of travel,
@@ -1,4 +1,8 @@
1
1
  /** Edit a line of text where it is shown: click it, type, and commit (Enter) or leave another way. */
2
2
  export declare function editInline(shown: string, label: string, next: string, key?: "Enter" | "Escape", scope?: HTMLElement): void;
3
3
  /** Close an open tile menu: Escape inside it, now that no field in it holds focus. */
4
- export declare const closeMenu: () => boolean;
4
+ export declare function closeMenu(): void;
5
+ /** A view in the add-tile picker, by its Malloy name; within one source's group when `source` is given. */
6
+ export declare const viewOption: (view: string, source?: string) => HTMLElement;
7
+ /** {@link viewOption}, once the picker has listed it. */
8
+ export declare const findViewOption: (view: string) => Promise<HTMLElement>;
@@ -33,7 +33,6 @@ export declare function useBuilderSelection({ editor, gridBox, }: {
33
33
  canRedo: boolean;
34
34
  dirty: boolean;
35
35
  edited: boolean;
36
- pendingOpen: boolean;
37
36
  error?: string;
38
37
  update: (change: (draft: DashboardDocument) => void) => void;
39
38
  save: () => Promise< SaveOutcome>;
@@ -7,11 +7,9 @@ export interface SessionEditor<D, L extends LastSave = LastSave> {
7
7
  /** The document as of the last save (or open). */
8
8
  saved: D;
9
9
  dirty: boolean;
10
- /** Unsaved edits made by a person, when that differs from `dirty` (an open that is unsaved before any edit); absent means `dirty`. */
10
+ /** Unsaved edits made by a person, when that differs from `dirty`; absent means `dirty`. */
11
11
  edited?: boolean;
12
12
  structural: boolean;
13
- /** Whether the document opened unsaved (a conversion); the save that clears it reports so. */
14
- pendingOpen?: boolean;
15
13
  canUndo: boolean;
16
14
  canRedo: boolean;
17
15
  undo: () => void;
@@ -34,19 +32,27 @@ export interface SessionReport {
34
32
  export interface SessionSaveInfo {
35
33
  size: number;
36
34
  structural: boolean;
37
- /** The save wrote a document that opened unsaved. */
38
- fromOpen: boolean;
39
35
  durationMs: number;
40
36
  }
41
37
  export interface BuilderSessionOptions<D, L extends LastSave = LastSave> {
42
38
  editor: SessionEditor<D, L>;
43
39
  onSave?: SaveHandler<D>;
44
- onDirtyChange?: (dirty: boolean) => void;
40
+ /**
41
+ * Whether there are unsaved edits, and (second) whether leaving now would
42
+ * lose any: false while the edits are kept elsewhere (`keepsEdits`).
43
+ */
44
+ onDirtyChange?: (dirty: boolean, wouldLose: boolean) => void;
45
45
  /** The host's way out, opted into: draws Close, which asks first when edits are unsaved. */
46
46
  onExit?: () => void;
47
47
  onChange?: (document: D) => void;
48
48
  /** Unsaved state the editor does not hold, such as an open text draft. */
49
49
  extraDirty?: boolean;
50
+ /**
51
+ * The document's edits are kept elsewhere as they are made (a draft in this
52
+ * browser), so leaving loses only what the editor does not hold yet: the host
53
+ * is told dirty for `extraDirty` alone. Close and Done still see every edit.
54
+ */
55
+ keepsEdits?: boolean;
50
56
  report: SessionReport;
51
57
  /** What the notice counts and calls them: "tile" or "cell". */
52
58
  unit: {
@@ -65,11 +71,19 @@ export interface BuilderSessionOptions<D, L extends LastSave = LastSave> {
65
71
  */
66
72
  export declare function useBuilderSession<D, L extends LastSave & {
67
73
  removedComments?: string[];
68
- } = LastSave>({ editor, onSave, onDirtyChange, onExit, onChange, extraDirty, report, unit, prepare, shortcuts, }: BuilderSessionOptions<D, L>): {
74
+ } = LastSave>({ editor, onSave, onDirtyChange, onExit, onChange, extraDirty, keepsEdits, report, unit, prepare, shortcuts, }: BuilderSessionOptions<D, L>): {
75
+ /** Write the file back as it was before the last save, and put the edits back unsaved. */
76
+ undoSave: () => Promise<void> | void;
77
+ canUndoSave: boolean;
78
+ lastSave: L;
79
+ toolbarProps: Pick<BuilderToolbarProps, "onExit" | "onSave" | "dirty" | "canUndo" | "canRedo" | "onUndo" | "onRedo" | "saving" | "saveButton">;
80
+ done?: () => void;
69
81
  saving: boolean;
70
82
  save: () => Promise<void> | void;
71
83
  exitGuard: {
72
84
  requestExit: () => void;
85
+ saveAndExit: () => void;
86
+ finishing: boolean;
73
87
  dialog: {
74
88
  open: boolean;
75
89
  canSave: boolean;
@@ -78,9 +92,4 @@ export declare function useBuilderSession<D, L extends LastSave & {
78
92
  onSaveAndExit: () => void;
79
93
  };
80
94
  };
81
- /** Write the file back as it was before the last save, and put the edits back unsaved. */
82
- undoSave: () => Promise<void> | void;
83
- canUndoSave: boolean;
84
- lastSave: L;
85
- toolbarProps: Pick<BuilderToolbarProps, "onSave" | "canUndo" | "canRedo" | "onUndo" | "onRedo" | "dirty" | "saving" | "saveButton" | "onExit">;
86
95
  };
@@ -18,12 +18,10 @@ export interface DocumentEditor<T> {
18
18
  source: string;
19
19
  canUndo: boolean;
20
20
  canRedo: boolean;
21
- /** Whether saving would change the file: the document differs from what was saved, or it opened that way ({@link DocumentEditorOptions.opensDirty}). */
21
+ /** Whether saving would change the file: the document differs from what was saved, or an undone save left its draft text in no file. */
22
22
  dirty: boolean;
23
- /** Whether the document differs from what was saved, or an undone save left its draft text in no file: work to lose, leaving out an `opensDirty` open that nothing has touched. */
23
+ /** The same as `dirty`: work to lose. */
24
24
  edited: boolean;
25
- /** Whether the document opened unsaved and no save has written it since ({@link DocumentEditorOptions.opensDirty}). */
26
- pendingOpen: boolean;
27
25
  /**
28
26
  * Why the last save did not happen. The document is untouched when this is
29
27
  * set: a refused write keeps the reader's work and reports a defect in the
@@ -93,8 +91,6 @@ export interface DocumentEditorOptions<T> {
93
91
  onSave?: SaveHandler<T>;
94
92
  /** Patch the document into the file, or say why that was refused. */
95
93
  splice: (source: string, document: T) => Promise<SpliceResult>;
96
- /** The open is itself unsaved: the document is a conversion of the file, so Save is on before any edit and Undo save returns to it. */
97
- opensDirty?: boolean;
98
94
  /** The file the first save overwrites when it is not `source` (a draft opened over the package's file): what Undo save writes back. */
99
95
  replaces?: string;
100
96
  /** Whether `document` differs structurally from `saved`; omit for never. */
@@ -9,6 +9,9 @@ export interface ExitGuardOptions {
9
9
  /** "Close" exits at once when clean and asks otherwise; "Save and exit" exits only once its own save settles clean. */
10
10
  export declare function useExitGuard({ dirty, saving, canSave, save, onExit, }: ExitGuardOptions): {
11
11
  requestExit: () => void;
12
+ saveAndExit: () => void;
13
+ /** Done is writing, or waiting on a write already under way. */
14
+ finishing: boolean;
12
15
  dialog: {
13
16
  open: boolean;
14
17
  canSave: boolean;
@@ -16,11 +16,13 @@ export declare const titleCase: (name: string) => string;
16
16
  * which field, what stands in the way of applying, and the payload an Apply
17
17
  * hands back. No MUI in here, so it can be exercised without a dialog.
18
18
  */
19
- export declare function useFilterForm({ open, document, control, available, fieldsFor, onApply, }: {
19
+ export declare function useFilterForm({ open, document, control, available, takenNames, fieldsFor, onApply, }: {
20
20
  open: boolean;
21
21
  document: DashboardDocument;
22
22
  control: BuilderControl | undefined;
23
23
  available: readonly BuilderControl[];
24
+ /** Names a new filter must not take: the model's givens the page does not show, say. */
25
+ takenNames?: readonly string[];
24
26
  fieldsFor?: (tile: QueryTile) => readonly CatalogField[] | undefined;
25
27
  onApply: (given: string, rows: MappingRow[], declare?: LocalGiven) => void;
26
28
  }): {
@@ -8,10 +8,6 @@ export declare const LEGACY_REFUSAL = "a .malloynb notebook is read, not edited.
8
8
  export interface OpenedDocument {
9
9
  source: string;
10
10
  document: DashboardDocument;
11
- conversion?: {
12
- from: string;
13
- to: string;
14
- };
15
11
  /** The package file when this opened, which a draft's save overwrites. */
16
12
  packageText?: string;
17
13
  generation: number;
@@ -0,0 +1,66 @@
1
+ import { ReportEditorHandle } from './useReportEditor';
2
+ /** Where drafts are kept: `localStorage`, behind one seam a test can replace. */
3
+ export declare const draftStore: {
4
+ storage: () => Storage;
5
+ };
6
+ /** What the builder found on opening, for the notice that says so. */
7
+ export interface RestoredDraft {
8
+ savedAt: number;
9
+ /**
10
+ * The file changed since the draft was kept. The draft is then OFFERED, not
11
+ * applied: it is a whole document, and putting it back would undo whatever
12
+ * changed the file (another author's save, an agent's write). Restoring it
13
+ * is the author's call, and says it replaces the current version.
14
+ */
15
+ stale: boolean;
16
+ /** Still to choose: a stale draft not yet restored or discarded. */
17
+ pending: boolean;
18
+ }
19
+ /** The report a draft is kept for. */
20
+ export interface ReportDraftTarget {
21
+ environmentName: string;
22
+ packageName: string;
23
+ /** The report's package path, `sales/q3.malloy`. */
24
+ path: string;
25
+ /** The package version the edits were made on; none for the live package. */
26
+ versionId?: string;
27
+ }
28
+ /**
29
+ * The key the builder keeps a report's draft under: one per server, report and
30
+ * version, so a draft is never restored onto a file it was not made on.
31
+ * `server` is the `ServerProvider`'s server: its `baseURL`, or this page's own
32
+ * `/api/v0` when it was given none.
33
+ */
34
+ export declare function reportDraftKey(target: ReportDraftTarget & {
35
+ server: string;
36
+ }): string;
37
+ /**
38
+ * Drop drafts kept in this browser: for a host that deleted, renamed or
39
+ * replaced a report itself, so its old edits are not offered again.
40
+ *
41
+ * Given a report, every draft kept for it goes, on any server and any version,
42
+ * unless `server` or `versionId` narrow it. Given a key from
43
+ * {@link reportDraftKey}, that one draft.
44
+ */
45
+ export declare function clearReportDraft(target: string | (ReportDraftTarget & {
46
+ server?: string;
47
+ })): void;
48
+ /** Whether this browser keeps drafts at all. */
49
+ export declare function draftStorageAvailable(): boolean;
50
+ /** A short, stable fingerprint of a file's text; not a security hash. */
51
+ export declare function textFingerprint(text: string): string;
52
+ export declare function useReportDraft(key: string | undefined, editor: ReportEditorHandle,
53
+ /** The file the builder opened on. */
54
+ opened: string): {
55
+ /** When unsaved edits were last kept in this browser; undefined when none are. */
56
+ keptAt: number | undefined;
57
+ /** The draft the builder opened with, until the notice is dismissed. */
58
+ restored: RestoredDraft | undefined;
59
+ dismissRestored: () => void;
60
+ /** Put the document back to the file's, as one undoable edit; the draft goes with the edits. */
61
+ discard: () => void;
62
+ /** Whether the browser is holding the edits: false once a write was refused. */
63
+ keeping: boolean;
64
+ /** Apply an offered (stale) draft, replacing the current version. */
65
+ restoreOffered: () => void;
66
+ };
@@ -9,15 +9,6 @@ export declare function useReportEditor(options: {
9
9
  document: DashboardDocument;
10
10
  /** Persist the patched file. Rejecting leaves the editor dirty. */
11
11
  onSave?: SaveHandler<DashboardDocument>;
12
- /**
13
- * A cell-format notebook the document is the conversion of: while `source`
14
- * is `from` the edits are spliced into `to`, the layout text it converts to,
15
- * and the open is unsaved ({@link DocumentEditorOptions.opensDirty}).
16
- */
17
- conversion?: {
18
- from: string;
19
- to: string;
20
- };
21
12
  /** The file a save overwrites when `source` is a draft of it ({@link DocumentEditorOptions.replaces}). */
22
13
  replaces?: string;
23
14
  /** The sources a document held as text sees without an `import`. */
@@ -1,15 +1,16 @@
1
1
  import { NewTile } from './AddTileDialog';
2
2
  import { DashboardTile } from './document';
3
+ import { LayoutRules } from '../Report/layoutRules';
3
4
  import { ReportEditorHandle } from './useReportEditor';
4
5
  import { Dispatch, SetStateAction } from 'react';
5
6
  /**
6
7
  * Adding, changing and removing tiles, with the add-tile picker and a tile's
7
8
  * menu that they are reached from.
8
9
  */
9
- export declare function useTileEditing({ editor, notebook, columns, modelPath, textHeld, selectTile, deselectTile, }: {
10
+ export declare function useTileEditing({ editor, rules, modelPath, textHeld, selectTile, deselectTile, }: {
10
11
  editor: ReportEditorHandle;
11
- notebook: boolean;
12
- columns: number;
12
+ /** How the document arranges tiles: whether an added tile carries a width, and how wide a new text tile starts. */
13
+ rules: LayoutRules;
13
14
  /** The document's file within the package, which a tile's import is relative to. */
14
15
  modelPath: string | undefined;
15
16
  /** The document is held as text: it has no `import`, so a tile's source is the run model's and nothing is imported. */
@@ -30,6 +31,8 @@ export declare function useTileEditing({ editor, notebook, columns, modelPath, t
30
31
  closeAdd: () => void;
31
32
  addTile: (tile: NewTile) => void;
32
33
  addText: () => void;
34
+ appendText: () => void;
33
35
  editTile: (key: string, change: (tile: DashboardTile) => void) => void;
34
36
  removeTile: (index: number) => void;
37
+ duplicate: (index: number) => void;
35
38
  };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * What a view's raw annotations say, read with no Malloy parser: its doc line
3
+ * and the chart it declares. Kept apart from `catalog.ts`, which parses tags,
4
+ * so the main entry (New report) can read them without the parser.
5
+ */
6
+ /** `#(doc) Revenue by product category\n` -> `Revenue by product category`. */
7
+ export declare function docOf(annotations: string[] | undefined): string | undefined;
8
+ /** `# bar_chart\n` -> `bar_chart`. Only the renderer's own chart tags count. */
9
+ export declare function chartOf(annotations: string[] | undefined): string | undefined;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * What a tile's width reads as while it is dragged: `8 of 12 · Two-thirds`,
3
+ * or `5 of 12` where the width is no common fraction, and `12 of 12 · Full
4
+ * width` at the grid's edge.
5
+ */
6
+ export declare function widthLabel(span: number, columns: number): string;
@@ -1,5 +1,6 @@
1
1
  import { default as React, ReactNode } from 'react';
2
2
  import { ConnectionsApi, DashboardsApi, DataAppsApi, DatabasesApi, EnvironmentsApi, MaterializationsApi, ModelsApi, NotebooksApi, PackagesApi, PublisherApi, ReportsApi, WatchModeApi } from '../client';
3
+ import { ReportUiOverrides } from '../theme/ui';
3
4
  import { Theme } from '../theme/types';
4
5
  export interface ServerContextValue {
5
6
  server: string;
@@ -42,6 +43,14 @@ export interface ServerProviderProps {
42
43
  * single-mode.
43
44
  */
44
45
  theme?: Theme;
46
+ /**
47
+ * The host's design tokens for the report reader's and builder's chrome:
48
+ * radii, control sizes, the type scale, the mono face, the menu shadow. Any
49
+ * subset; the rest stay the SDK's. Colour is the host's MUI palette and the
50
+ * theme above, not this. See `ReportUi`, and `reportClasses` for styling
51
+ * what tokens do not reach.
52
+ */
53
+ ui?: ReportUiOverrides;
45
54
  }
46
55
  declare const getApiClients: (baseURL?: string, accessToken?: () => Promise<string>) => {
47
56
  models: ModelsApi;
@@ -0,0 +1,45 @@
1
+ import { UiTextStyle } from '..';
2
+ /**
3
+ * Helpers every report surface draws its edges and prose with. The sizes,
4
+ * radii and type are the theme's `ui` tokens (`theme/ui.ts`), one set the host
5
+ * can override, rather than the host MUI theme's `shape.borderRadius` and
6
+ * button sizes: a builder whose buttons took the host's pill radius and 37px
7
+ * height beside its own 6px, 28px chips is what made one toolbar row show five
8
+ * shapes. Colour comes from the host (palette) and the instance theme (accent,
9
+ * card edge).
10
+ */
11
+ /**
12
+ * The SDK's default chrome tokens, as constants. Components read the host's
13
+ * through the theme (`usePublisherTheme().theme.ui`), so a host's `ui` reaches
14
+ * them; these are the defaults it overrides, kept for code written against them.
15
+ */
16
+ /** @deprecated Read `theme.ui.size.control`. */
17
+ export declare const CONTROL_HEIGHT_PX: number;
18
+ /** @deprecated Read `theme.ui.size.chip`. */
19
+ export declare const CHIP_HEIGHT_PX: number;
20
+ /** @deprecated Read `theme.ui.radius.control`. */
21
+ export declare const CONTROL_RADIUS: string;
22
+ /** @deprecated Read `theme.ui.radius.tile`. */
23
+ export declare const TILE_RADIUS: string;
24
+ /** @deprecated Read `theme.ui.radius.dialog`. */
25
+ export declare const DIALOG_RADIUS: string;
26
+ /** @deprecated Read `theme.ui.type`. */
27
+ export declare const TYPE: {
28
+ pageTitle: UiTextStyle;
29
+ tileTitle: UiTextStyle;
30
+ prose: UiTextStyle;
31
+ control: UiTextStyle;
32
+ caption: UiTextStyle;
33
+ label: UiTextStyle;
34
+ code: UiTextStyle;
35
+ };
36
+ /** How wide report prose runs before it wraps: a readable line, not the grid's width. */
37
+ export declare const PROSE_MAX_WIDTH = "72ch";
38
+ /**
39
+ * The colour of the instance theme's card edge (`cardBorder`, a `1px solid`
40
+ * shorthand). Every outlined thing on a report (tiles, filter buttons, their
41
+ * popovers) is drawn in it, so the page has one edge weight, not two.
42
+ */
43
+ export declare const edgeColor: (cardBorder: string) => string;
44
+ /** The edge one step darker: what a hovered tile or filter button shows. */
45
+ export declare const hoverEdgeColor: (cardBorder: string, ink: string) => string;
@@ -4,7 +4,7 @@ import { DrillField } from './resolveDrill';
4
4
  * Malloyyo's counterpart is `dash-drill`; the name is local to each app's
5
5
  * stylesheet, and only the tag grammar is a compatibility surface.
6
6
  */
7
- export declare const DRILL_CELL_CLASS = "publisher-drill";
7
+ export declare const DRILL_CELL_CLASS: "publisher-drill";
8
8
  /** As much of the renderer's viz handle as the affordance reads. */
9
9
  export interface DrillMetadataSource {
10
10
  getMetadata: () => {
@@ -0,0 +1,35 @@
1
+ import { GivenInputProps } from './GivenInput';
2
+ /**
3
+ * One filter in a report's control row: a 32px button that names the filter
4
+ * and says what it is set to (`Category All`, `Ordered since Jan 1, 2023`),
5
+ * and opens the filter's full control in a popover.
6
+ *
7
+ * The row reads at a glance and costs one line, where a form field per filter
8
+ * cost two (the field, then a `Default:` caption under it) and wrapped. Every
9
+ * kind of control (picker, range, time range, date, boolean, text) opens the
10
+ * same way, so the row has one shape whatever the filters are.
11
+ *
12
+ * Set to a value of its own, the button is tinted in the accent and carries a
13
+ * clear (×), which drops the value back to the model default, as the control's
14
+ * own × does. The default itself reads as a value, not as a hint.
15
+ *
16
+ * Inside the builder ({@link useFilterEditing}) the same button is where the
17
+ * filter is configured: a remove badge on its corner while it is hovered or
18
+ * focused, and its settings from the popover. Distinct from the clear (×):
19
+ * that one empties the value, the badge takes the filter off the report.
20
+ */
21
+ export declare function FilterButton(props: GivenInputProps): import("react/jsx-runtime").JSX.Element;
22
+ /**
23
+ * A filter the row has no live control for, as a button that opens its
24
+ * settings. Mostly a filter the file declares that no tile reads yet
25
+ * (`unused`): dashed and faint, saying so in words, and its settings are where
26
+ * it is bound to tiles. Also every filter when the builder has no live row to
27
+ * draw (no server to run one), so filters can still be edited.
28
+ */
29
+ export declare function FilterSettingsButton({ name, label, unused, }: {
30
+ name: string;
31
+ label: string;
32
+ unused?: boolean;
33
+ }): import("react/jsx-runtime").JSX.Element;
34
+ /** The row's last slot in the builder: declare or bind another filter. */
35
+ export declare function AddFilterButton(): import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,8 @@ import { GivenValue } from '../../hooks/givenValue';
4
4
  * How the control row is laid out.
5
5
  *
6
6
  * - `panel`: the vertical "Filters" block a notebook shows above its cells.
7
- * - `bar`: a horizontal filter bar above a dashboard grid.
7
+ * - `bar`: a report's row of filter buttons, one per control, each opening
8
+ * its control in a popover (`FilterButton`). Both report layouts use it.
8
9
  *
9
10
  * Two presentations of one control implementation, rather than two
10
11
  * implementations: a control gains a behavior (a suggest dropdown, an Apply
@@ -0,0 +1,54 @@
1
+ import { Context } from 'react';
2
+ /**
3
+ * What the report builder adds to a report's row of filter buttons, so the
4
+ * row a reader uses is also the one place a filter is configured: no second
5
+ * row of chips naming the same filters again.
6
+ *
7
+ * Provided by the builder around the host's control row; absent everywhere
8
+ * else, where the row is the reader's and offers no editing at all.
9
+ */
10
+ export interface FilterEditing {
11
+ /** The builder's word on one filter, by given name; undefined when it does not know the name. */
12
+ stateOf: (name: string) => FilterEditState | undefined;
13
+ /**
14
+ * Filters the file declares that the row has no control for (no tile reads
15
+ * them yet), shown after the row's own so they can still be configured or
16
+ * removed.
17
+ */
18
+ unrendered: {
19
+ name: string;
20
+ label: string;
21
+ }[];
22
+ /** Open a filter's settings: which tiles it applies to, its label and kind. */
23
+ onEdit: (name: string) => void;
24
+ /** Take a filter off the report. */
25
+ onRemove: (name: string) => void;
26
+ /** Declare a new filter, or bind one the model offers. */
27
+ onAdd: () => void;
28
+ /** Why adding is off; set, the add button is disabled and says why. */
29
+ addDisabledReason?: string;
30
+ /**
31
+ * Where the report opens each filter (`## artifact { givens { … } }`), as
32
+ * written in the file; undefined when it opens at the declared default.
33
+ * Any filter has one, the model's included: it is the report's to say.
34
+ */
35
+ startingValueOf?: (name: string) => string | undefined;
36
+ /** Open the report with this filter at `text` (as the file spells it), or at its default when undefined. */
37
+ setStartingValue?: (name: string, text: string | undefined) => void;
38
+ }
39
+ export interface FilterEditState {
40
+ /** Why a tile cannot take this filter's binding, when one cannot. */
41
+ problem?: string;
42
+ /** Where the filter is declared: this file, or the model it imports. */
43
+ origin: "dashboard" | "model";
44
+ /**
45
+ * Set when a tile reads the filter through the model rather than a binding
46
+ * in this file: why it can be set but not removed or configured here.
47
+ */
48
+ fixed?: string;
49
+ /** Open the model that sets it, when the host can. */
50
+ openModel?: () => void;
51
+ }
52
+ export declare const FilterEditingContext: Context<FilterEditing>;
53
+ /** The builder's filter editing, when the row is drawn inside the builder. */
54
+ export declare const useFilterEditing: () => FilterEditing;
@@ -0,0 +1,9 @@
1
+ import { Given } from '../../client';
2
+ import { GivenValue } from '../../hooks/givenValue';
3
+ /**
4
+ * The few words a filter button shows for its given's current value: `All`,
5
+ * `Outerwear +2`, `Jan 1, 2023`, `≥ 50`, `Last 30 days`. Unset, the model
6
+ * default stands in, read the same way, so a default looks like the value it
7
+ * is rather than a hint under the control. The full value is the popover's.
8
+ */
9
+ export declare function summarizeGivenValue(given: Given, value: GivenValue | undefined): string;
@@ -29,6 +29,17 @@ export interface PickedDay {
29
29
  * appeared to jump backwards.
30
30
  */
31
31
  export declare function pickedDayToUtc(day: PickedDay, previous?: Date): Date;
32
+ /**
33
+ * Whether `""` is a value the user can mean for this type, rather than "unset".
34
+ *
35
+ * A DENYLIST, to agree with `paramToGiven`'s `default` arm. As an allowlist it
36
+ * named the three types that keep `""` and treated everything else as unset,
37
+ * while the switch below passes any unrecognised type through untouched: a
38
+ * deliberate `""` on a type neither knew about was written to the URL and read
39
+ * back as unset. Naming the types that cannot hold an empty value keeps the two
40
+ * in step as new types arrive.
41
+ */
42
+ export declare function isEmptyStringMeaningful(type: string | undefined): boolean;
32
43
  /** Read a query-parameter string back as a value of the declared type. */
33
44
  export declare function paramToGiven(type: string | undefined, raw: string): GivenValue;
34
45
  /**