@malloy-publisher/sdk 0.0.248 → 0.0.250

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 (202) hide show
  1. package/README.md +37 -17
  2. package/TREE_SHAKING.md +5 -0
  3. package/bunfig.toml +3 -0
  4. package/dist/ServerProvider-CcfeBpt3.cjs.js +1 -0
  5. package/dist/{ServerProvider-BxEh3nFI.es.js → ServerProvider-EqBlMMqx.es.js} +1056 -905
  6. package/dist/client/api.d.ts +306 -9
  7. package/dist/client/index.cjs.js +1 -1
  8. package/dist/client/index.es.js +74 -70
  9. package/dist/components/Dashboard/Dashboard.d.ts +49 -0
  10. package/dist/components/Dashboard/DashboardTile.d.ts +48 -0
  11. package/dist/components/Dashboard/index.d.ts +2 -0
  12. package/dist/components/Notebook/Notebook.d.ts +46 -8
  13. package/dist/components/Notebook/NotebookCell.d.ts +37 -3
  14. package/dist/components/Notebook/runPlan.d.ts +29 -0
  15. package/dist/components/Notebook/types.d.ts +10 -0
  16. package/dist/components/Package/ContentTypeIcon.d.ts +17 -1
  17. package/dist/components/Package/Package.d.ts +1 -4
  18. package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
  19. package/dist/components/RenderedResult/ResultContainer.d.ts +3 -1
  20. package/dist/components/ResultsDialog.d.ts +4 -1
  21. package/dist/components/ServerProvider.d.ts +2 -1
  22. package/dist/components/click_helper.d.ts +10 -1
  23. package/dist/components/drill/index.d.ts +3 -0
  24. package/dist/components/drill/markDrillableCells.d.ts +55 -0
  25. package/dist/components/drill/resolveDrill.d.ts +139 -0
  26. package/dist/components/drill/useDrill.d.ts +63 -0
  27. package/dist/components/given/GivenInput.d.ts +27 -3
  28. package/dist/components/given/GivensPanel.d.ts +36 -7
  29. package/dist/components/given/filterValue.d.ts +97 -0
  30. package/dist/components/given/index.d.ts +1 -1
  31. package/dist/components/given/paramCodec.d.ts +60 -0
  32. package/dist/components/index.d.ts +4 -1
  33. package/dist/components/styles.d.ts +31 -0
  34. package/dist/constants/docLinks.d.ts +6 -0
  35. package/dist/{core-C86Rb7tJ.cjs.js → core-CVXEUnnm.cjs.js} +1 -1
  36. package/dist/{core-BuvlzSIX.es.js → core-Cr-9Wkp3.es.js} +1 -1
  37. package/dist/hooks/givenValue.d.ts +10 -0
  38. package/dist/hooks/index.d.ts +3 -1
  39. package/dist/hooks/useGivensState.d.ts +64 -0
  40. package/dist/hooks/useSuggestOptions.d.ts +78 -0
  41. package/dist/index-C-KeIwsG.cjs.js +339 -0
  42. package/dist/{index-BdtAZ5k6.es.js → index-DVkelll3.es.js} +40981 -39669
  43. package/dist/index.cjs.js +1 -1
  44. package/dist/index.es.js +77 -62
  45. package/dist/theme/types.d.ts +9 -0
  46. package/dist/utils/malloyString.d.ts +7 -0
  47. package/package.json +3 -1
  48. package/src/client-entry.ts +3 -0
  49. package/src/components/AnalyzePackageButton.tsx +3 -0
  50. package/src/components/ApiErrorDisplay.tsx +3 -0
  51. package/src/components/Connections/AddConnectionDialog.tsx +13 -1
  52. package/src/components/Connections/DeleteConnectionDialog.tsx +3 -0
  53. package/src/components/Connections/EditConnectionDialog.tsx +3 -0
  54. package/src/components/Connections/common.ts +3 -0
  55. package/src/components/DOMElement/DOMElement.tsx +3 -0
  56. package/src/components/DOMElement/index.ts +3 -0
  57. package/src/components/Dashboard/Dashboard.tsx +398 -0
  58. package/src/components/Dashboard/DashboardTile.tsx +153 -0
  59. package/src/components/Dashboard/index.ts +5 -0
  60. package/src/components/DataAppViewer/DataAppViewer.tsx +3 -0
  61. package/src/components/DataAppViewer/index.ts +3 -0
  62. package/src/components/Environment/About.tsx +3 -0
  63. package/src/components/Environment/AddPackageDialog.tsx +3 -0
  64. package/src/components/Environment/ConnectionExplorer.tsx +3 -0
  65. package/src/components/Environment/Connections.tsx +3 -0
  66. package/src/components/Environment/DeletePackageDialog.tsx +3 -0
  67. package/src/components/Environment/EditPackageDialog.tsx +3 -0
  68. package/src/components/Environment/Environment.tsx +3 -0
  69. package/src/components/Environment/Packages.tsx +3 -0
  70. package/src/components/Environment/index.ts +3 -0
  71. package/src/components/Home/AddEnvironmentDialog.tsx +3 -0
  72. package/src/components/Home/DeleteEnvironmentDialog.tsx +3 -0
  73. package/src/components/Home/EditEnvironmentDialog.tsx +3 -0
  74. package/src/components/Home/Home.tsx +113 -23
  75. package/src/components/Home/index.ts +3 -0
  76. package/src/components/Loading.tsx +3 -0
  77. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +3 -0
  78. package/src/components/Materializations/CreateMaterializationDialog.tsx +3 -0
  79. package/src/components/Materializations/DeleteMaterializationDialog.tsx +3 -0
  80. package/src/components/Materializations/EnvironmentMaterializations.tsx +3 -0
  81. package/src/components/Materializations/ManifestView.tsx +3 -0
  82. package/src/components/Materializations/MaterializationDetailDialog.tsx +3 -0
  83. package/src/components/Materializations/MaterializationRunsList.tsx +3 -0
  84. package/src/components/Materializations/Materializations.tsx +3 -0
  85. package/src/components/Materializations/ScheduleCard.tsx +3 -0
  86. package/src/components/Materializations/SectionLabel.tsx +3 -0
  87. package/src/components/Materializations/SetScheduleDialog.tsx +3 -0
  88. package/src/components/Materializations/TriggerChip.tsx +3 -0
  89. package/src/components/Materializations/cron.ts +3 -0
  90. package/src/components/Materializations/index.ts +3 -0
  91. package/src/components/Materializations/utils.ts +3 -0
  92. package/src/components/Model/Model.tsx +3 -0
  93. package/src/components/Model/ModelCell.tsx +3 -0
  94. package/src/components/Model/ModelExplorer.tsx +3 -0
  95. package/src/components/Model/ModelExplorerDialog.tsx +3 -0
  96. package/src/components/Model/SourcesExplorer.tsx +3 -0
  97. package/src/components/Model/index.ts +3 -0
  98. package/src/components/Model/useModelData.ts +3 -0
  99. package/src/components/Notebook/Notebook.tsx +447 -390
  100. package/src/components/Notebook/NotebookCell.tsx +120 -3
  101. package/src/components/Notebook/index.ts +3 -0
  102. package/src/components/Notebook/runPlan.spec.ts +155 -0
  103. package/src/components/Notebook/runPlan.ts +67 -0
  104. package/src/components/Notebook/types.ts +14 -0
  105. package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
  106. package/src/components/Package/ContentTypeIcon.tsx +80 -6
  107. package/src/components/Package/FileTreeView.tsx +3 -0
  108. package/src/components/Package/Models.tsx +3 -0
  109. package/src/components/Package/Package.tsx +151 -38
  110. package/src/components/Package/index.ts +3 -0
  111. package/src/components/QueryResult/QueryResult.tsx +3 -0
  112. package/src/components/QueryResult/index.ts +3 -0
  113. package/src/components/RenderedResult/RenderedResult.tsx +312 -19
  114. package/src/components/RenderedResult/ResultContainer.tsx +31 -1
  115. package/src/components/RenderedResult/index.ts +3 -0
  116. package/src/components/RenderedResult/renderLogs.spec.ts +3 -0
  117. package/src/components/RenderedResult/renderLogs.ts +3 -0
  118. package/src/components/ResultsDialog.tsx +8 -0
  119. package/src/components/ServerProvider.tsx +5 -0
  120. package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
  121. package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
  122. package/src/components/Workbook/ModelPicker.tsx +3 -0
  123. package/src/components/Workbook/MutableCell.tsx +3 -0
  124. package/src/components/Workbook/Workbook.tsx +3 -0
  125. package/src/components/Workbook/WorkbookList.tsx +3 -0
  126. package/src/components/Workbook/WorkbookManager.ts +3 -0
  127. package/src/components/Workbook/WorkbookStorage.ts +3 -0
  128. package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
  129. package/src/components/Workbook/index.ts +3 -0
  130. package/src/components/click_helper.ts +17 -1
  131. package/src/components/drill/index.ts +28 -0
  132. package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
  133. package/src/components/drill/markDrillableCells.spec.ts +109 -0
  134. package/src/components/drill/markDrillableCells.ts +314 -0
  135. package/src/components/drill/resolveDrill.spec.ts +449 -0
  136. package/src/components/drill/resolveDrill.ts +375 -0
  137. package/src/components/drill/useDrill.tsx +203 -0
  138. package/src/components/filter/DimensionFilter.tsx +3 -0
  139. package/src/components/filter/index.ts +3 -0
  140. package/src/components/filter/utils.ts +16 -5
  141. package/src/components/given/GivenInput.spec.tsx +498 -15
  142. package/src/components/given/GivenInput.tsx +565 -30
  143. package/src/components/given/GivensPanel.spec.tsx +175 -0
  144. package/src/components/given/GivensPanel.tsx +142 -32
  145. package/src/components/given/filterValue.spec.ts +364 -0
  146. package/src/components/given/filterValue.ts +207 -0
  147. package/src/components/given/index.ts +8 -1
  148. package/src/components/given/paramCodec.spec.ts +857 -0
  149. package/src/components/given/paramCodec.ts +483 -0
  150. package/src/components/given/utils.spec.ts +3 -0
  151. package/src/components/given/utils.ts +3 -0
  152. package/src/components/highlighter.ts +3 -0
  153. package/src/components/index.ts +7 -1
  154. package/src/components/styles.ts +38 -3
  155. package/src/constants/docLinks.spec.ts +54 -0
  156. package/src/constants/docLinks.ts +29 -0
  157. package/src/hooks/givenValue.ts +13 -0
  158. package/src/hooks/index.ts +9 -4
  159. package/src/hooks/useDimensionFilters.ts +4 -7
  160. package/src/hooks/useDimensionFiltersFromSpec.ts +3 -0
  161. package/src/hooks/useDimensionFiltersQuery.ts +4 -7
  162. package/src/hooks/useDimensionalFilterRangeData.ts +4 -7
  163. package/src/hooks/useGivensState.spec.ts +449 -0
  164. package/src/hooks/useGivensState.ts +340 -0
  165. package/src/hooks/useModelGivens.ts +3 -0
  166. package/src/hooks/useQueryWithApiError.ts +3 -0
  167. package/src/hooks/useRawQueryData.ts +3 -0
  168. package/src/hooks/useSuggestOptions.spec.ts +112 -0
  169. package/src/hooks/useSuggestOptions.ts +263 -0
  170. package/src/index.ts +3 -0
  171. package/src/react-app-env.d.ts +3 -0
  172. package/src/theme/ThemeContext.tsx +3 -0
  173. package/src/theme/buildMalloyExplicitTheme.ts +3 -0
  174. package/src/theme/buildTableCssVars.spec.ts +3 -0
  175. package/src/theme/buildTableCssVars.ts +7 -0
  176. package/src/theme/buildVegaThemeOverride.spec.ts +3 -0
  177. package/src/theme/buildVegaThemeOverride.ts +3 -0
  178. package/src/theme/defaults.ts +3 -0
  179. package/src/theme/index.ts +3 -0
  180. package/src/theme/keys.ts +3 -0
  181. package/src/theme/readChartAnnotations.spec.ts +3 -0
  182. package/src/theme/readChartAnnotations.ts +3 -0
  183. package/src/theme/resolveTheme.spec.ts +16 -0
  184. package/src/theme/resolveTheme.ts +6 -0
  185. package/src/theme/types.ts +12 -0
  186. package/src/utils/dataAppEmbed.spec.ts +3 -0
  187. package/src/utils/dataAppEmbed.ts +3 -0
  188. package/src/utils/formatting.spec.ts +3 -0
  189. package/src/utils/formatting.ts +3 -0
  190. package/src/utils/malloyString.spec.ts +24 -0
  191. package/src/utils/malloyString.ts +12 -0
  192. package/src/utils/parsing.spec.ts +3 -0
  193. package/src/utils/parsing.ts +3 -0
  194. package/src/utils/queryClient.ts +3 -0
  195. package/test/README.md +21 -10
  196. package/test/setup.ts +3 -0
  197. package/vite.config.ts +3 -0
  198. package/dist/ServerProvider-Dg5S1qBU.cjs.js +0 -1
  199. package/dist/hooks/useGivensForm.d.ts +0 -35
  200. package/dist/index-MES4MGpQ.cjs.js +0 -309
  201. package/src/hooks/useGivensForm.spec.ts +0 -99
  202. package/src/hooks/useGivensForm.ts +0 -107
@@ -0,0 +1,139 @@
1
+ /**
2
+ * The parsed-tag surface this module reads, structurally typed.
3
+ *
4
+ * The renderer hands over an already-parsed `Tag` from `@malloydata/malloy-tag`,
5
+ * so naming the shape rather than importing the class keeps that package a
6
+ * render-time detail: SDK consumers can bundle without it, the same allowance
7
+ * `RenderedResult` makes for its theme annotations.
8
+ */
9
+ export interface DrillTagReader {
10
+ tag(...at: string[]): DrillTagReader | undefined;
11
+ text(...at: string[]): string | undefined;
12
+ textArray(...at: string[]): string[] | undefined;
13
+ }
14
+ /** The clicked field, as much of it as drill reads. */
15
+ export interface DrillField {
16
+ name: string;
17
+ tag?: DrillTagReader;
18
+ /**
19
+ * Whether the field was grouped rather than aggregated. Only dimensions
20
+ * drill: a measure's cell has no dimension value to seed a filter with even
21
+ * when the tag reaches it, so filtering by one would filter by something
22
+ * other than what was clicked. Optional because the renderer's click payload
23
+ * and its field metadata are the two callers and only one is guaranteed to
24
+ * carry the method; absent, the field is taken at its word.
25
+ */
26
+ wasDimension?: () => boolean;
27
+ }
28
+ /**
29
+ * A click from `@malloydata/render`'s `onClick`, narrowed to what drill needs.
30
+ * Mirrors its `MalloyClickEventPayload` without importing it, since the renderer
31
+ * is a lazily-imported dependency here.
32
+ */
33
+ export interface DrillClickPayload {
34
+ field?: DrillField;
35
+ value?: unknown;
36
+ isHeader?: boolean;
37
+ /**
38
+ * The originating click, which the host needs for two things a resolved
39
+ * intent cannot express, where to anchor a menu of destinations, and whether
40
+ * a modifier was held (cmd/ctrl to open in a new tab).
41
+ */
42
+ event?: MouseEvent;
43
+ }
44
+ /** The literal `to=self`: filter the current view instead of leaving it. */
45
+ export declare const DRILL_SELF = "self";
46
+ /**
47
+ * The `to=` destinations a field's `# drill` declares, empty when it declares
48
+ * none or the field cannot drill.
49
+ *
50
+ * Read separately from {@link resolveDrill} because two callers need it: the
51
+ * click, which also needs the clicked value, and the *affordance*, which runs
52
+ * over the result's field metadata before any click to decide which columns read
53
+ * as clickable. Sharing this is what keeps the two honest: a cell that looks
54
+ * clickable is one whose click resolves, because both answers come from here.
55
+ */
56
+ export declare function drillDestinations(field: DrillField | undefined): string[];
57
+ /**
58
+ * A destination slug as a menu label: `category_detail` → `Category detail`.
59
+ *
60
+ * Ported from Malloyyo so the same drill reads the same way in both, rather than
61
+ * naming the file on one and a sentence on the other.
62
+ */
63
+ export declare function humanizeSlug(slug: string): string;
64
+ /**
65
+ * The given a `# drill` on this field would set: `given=` when the tag names
66
+ * one, otherwise the dimension name exactly as the model spells it.
67
+ *
68
+ * Shared with the affordance for the same reason `drillDestinations` is: a cell
69
+ * reads as clickable exactly when clicking it would do something, and deciding
70
+ * "would it" needs the given's name before any click happens.
71
+ */
72
+ export declare function drillGivenName(field: DrillField): string;
73
+ /** Where a `# drill` click wants to go, for the host to route however it routes. */
74
+ export interface DrillNavigation {
75
+ /** The destination dashboard's slug. */
76
+ dashboard: string;
77
+ /**
78
+ * Control values to open it with: the clicked value seeded into the drill's
79
+ * given. Only the seeded given: the source view's other filters are not
80
+ * carried over, since the destination need not bind them.
81
+ */
82
+ givens: Record<string, string>;
83
+ }
84
+ /** What a click asked for, once the tag on the clicked field is read. */
85
+ export interface DrillIntent {
86
+ /** Destinations in declared order: dashboard slugs and/or {@link DRILL_SELF}. */
87
+ to: string[];
88
+ /** The given to seed: the dimension name as spelled, unless `given=` says otherwise. */
89
+ given: string;
90
+ /**
91
+ * The clicked value as Malloy filter syntax, ready to send to a `filter<…>`
92
+ * given. This is the right encoding for a cross-dashboard drill, whose
93
+ * destination declares its own givens and is conventionally `filter<…>`.
94
+ */
95
+ value: string;
96
+ /**
97
+ * The same value before any encoding.
98
+ *
99
+ * Carried because the filter encoding above is only correct for a
100
+ * `filter<…>` target, and a click cannot know what it is aiming at: the
101
+ * destination may be another dashboard entirely. A host that *does* know,
102
+ * `to=self`, where the target given is one of its own: re-encodes from this
103
+ * with {@link encodeDrillValue}. Without it, drilling into a plain `string`
104
+ * given seeded it with backslash-escaped filter syntax and matched nothing.
105
+ */
106
+ rawValue: unknown;
107
+ /** The clicked value as it read on screen, for labelling the destination menu. */
108
+ label: string;
109
+ }
110
+ /**
111
+ * The clicked cell's value as filter syntax, or undefined when it cannot be
112
+ * expressed as one.
113
+ *
114
+ * Encoded from the value's own type rather than the given's, which a click does
115
+ * not know (a notebook cell has no control row to consult). Refusing the cases
116
+ * it cannot encode is deliberate: a drill that filtered by something other than
117
+ * the cell the user clicked would be worse than one that does nothing.
118
+ */
119
+ export declare function drillValueToFilter(value: unknown): string | undefined;
120
+ /**
121
+ * Read the `# drill` intent off a renderer click, or undefined when the click
122
+ * was not on a drillable value.
123
+ *
124
+ * Silent on anything untagged, which is most clicks: this runs on every click
125
+ * the renderer reports, so "not a drill" is the ordinary answer, not a fault.
126
+ */
127
+ export declare function resolveDrill(payload: DrillClickPayload | undefined): DrillIntent | undefined;
128
+ /**
129
+ * A clicked value encoded for a given whose declared type is known.
130
+ *
131
+ * `filter<…>` takes filter syntax, so the value is escaped into a one-value
132
+ * filter list. Every other type takes the value itself: a plain `string` given
133
+ * seeded with `Ben\ &\ Jerry` would match nothing, because the escaping is
134
+ * meaningful only to the filter parser.
135
+ *
136
+ * Undefined when the value has no spelling for that type, which the caller
137
+ * should treat the way it treats an unresolvable drill: do nothing.
138
+ */
139
+ export declare function encodeDrillValue(rawValue: unknown, targetType: string | undefined): string | number | boolean | Date | undefined;
@@ -0,0 +1,63 @@
1
+ import { ReactNode } from 'react';
2
+ import { DrillField, DrillClickPayload, DrillNavigation } from './resolveDrill';
3
+ export interface UseDrillOptions {
4
+ /**
5
+ * Open another dashboard, seeded with the clicked value. Omitted on a surface
6
+ * that cannot navigate, which makes those destinations inert rather than
7
+ * dead-ended.
8
+ */
9
+ onNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
10
+ /**
11
+ * Apply the clicked value to this surface's own control row (`to=self`).
12
+ * Omitted on a surface that has none, such as a notebook cell.
13
+ */
14
+ onSelf?: (given: string, rawValue: unknown) => void;
15
+ /**
16
+ * Whether a `to=self` drill onto this given can actually be honoured: for a
17
+ * notebook, whether it declares that given at all.
18
+ *
19
+ * Without it the affordance says yes to every self-drill and the click is
20
+ * refused afterwards with a console warning, which is the dead link this
21
+ * module exists to avoid. Absent means "any self-drill is fine", the right
22
+ * default for a surface that binds whatever it is handed.
23
+ */
24
+ canSelf?: (given: string) => boolean;
25
+ /**
26
+ * What `to=self` is called in the menu. A notebook filtering itself is not
27
+ * "this dashboard", and the drill tag: written on a shared model dimension,
28
+ * cannot know which document the reader is in, so the surface names itself.
29
+ */
30
+ selfLabel?: string;
31
+ }
32
+ /**
33
+ * What a surface hands to its result renderer to become drillable: the click
34
+ * handler, and the predicate that decides which cells say so.
35
+ *
36
+ * One object because the two must agree. Passing only the handler is what
37
+ * produced the original asymmetry: clicks worked, but nothing looked clickable.
38
+ */
39
+ export interface DrillBinding {
40
+ /**
41
+ * Every cell click. Most carry no `# drill` and mean nothing, so this
42
+ * tolerates being called constantly.
43
+ */
44
+ onClick: (payload: DrillClickPayload) => void;
45
+ /** Whether this field's cells should read as clickable. */
46
+ canDrill: (field: DrillField) => boolean;
47
+ }
48
+ export interface UseDrillResult {
49
+ /** Hand to `ResultContainer`'s (or `RenderedResult`'s) `drill` prop. */
50
+ drill: DrillBinding;
51
+ /** Render anywhere in the subtree: the menu a multi-destination drill opens. */
52
+ drillMenu: ReactNode;
53
+ }
54
+ /**
55
+ * Click-to-drill for any surface that renders a Malloy result.
56
+ *
57
+ * Shared between the dashboard viewer and notebook cells on purpose: `# drill`
58
+ * is declared on a model *dimension*, so it fires wherever that dimension is
59
+ * grouped, and a notebook can therefore drill into a dashboard with no notebook-
60
+ * specific code. What differs between surfaces is only what they can do about it,
61
+ * which is what the two callbacks express.
62
+ */
63
+ export declare function useDrill({ onNavigate, onSelf, selfLabel, canSelf, }: UseDrillOptions): UseDrillResult;
@@ -1,9 +1,33 @@
1
1
  import { Given } from '../../client';
2
- import { GivenValue } from '../../hooks/useGivensForm';
2
+ import { GivenValue } from '../../hooks/givenValue';
3
3
  export interface GivenInputProps {
4
+ /**
5
+ * The declaration, which carries its own presentation (`label`, `control`,
6
+ * `rangeMin`, `rangeMax`) from the control tags on it
7
+ * (`# label="Brand" control=select range_min=0`).
8
+ *
9
+ * Presentation never changes what the given means, just which widget stands
10
+ * in for typing the value by hand. An untagged given falls back to the
11
+ * widget its type implies, which is what notebooks have always rendered.
12
+ */
4
13
  given: Given;
5
14
  value: GivenValue | undefined;
6
15
  onChange: (next: GivenValue) => void;
16
+ /**
17
+ * Options for a `select`/`multiselect`, already resolved from the given's
18
+ * `suggest` query. Resolved by the caller rather than fetched here so this
19
+ * stays a presentational component: the suggest query is an ordinary query
20
+ * against the host's model, which the widget has no business knowing about.
21
+ */
22
+ options?: string[];
23
+ optionsLoading?: boolean;
24
+ /**
25
+ * The `suggest` query for this given failed. Distinguished from an empty
26
+ * `options` because a dropdown looks identical either way, and the two mean
27
+ * opposite things: no values in the data, versus no answer from the server.
28
+ * Free text still works, so the control degrades rather than locking up.
29
+ */
30
+ optionsFailed?: boolean;
7
31
  }
8
32
  /**
9
33
  * Renders an input widget appropriate for the declared given type.
@@ -19,10 +43,10 @@ export interface GivenInputProps {
19
43
  * including an empty string — so typing the field empty (a deliberate `""`)
20
44
  * is distinguishable from unset by the × being present.
21
45
  * - revert → the × affordance calls `onChange(null)`, which drops the override
22
- * (useGivensForm deletes the key) and returns the widget to its unset state.
46
+ * (useGivensState deletes the key) and returns the widget to its unset state.
23
47
  *
24
48
  * A given's model default (if any) is also surfaced as an always-visible
25
49
  * `Default: …` helper line on every widget — including the boolean checkbox,
26
50
  * which gets a wrapping FormControl for the slot.
27
51
  */
28
- export declare function GivenInput({ given, value, onChange }: GivenInputProps): import("react/jsx-runtime").JSX.Element;
52
+ export declare function GivenInput({ given, value, onChange, options, optionsLoading, optionsFailed, }: GivenInputProps): import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,47 @@
1
1
  import { Given } from '../../client';
2
- import { GivenValue } from '../../hooks/useGivensForm';
2
+ import { GivenValue } from '../../hooks/givenValue';
3
+ /**
4
+ * How the control row is laid out.
5
+ *
6
+ * - `panel`: the vertical "Parameters" block a notebook shows above its cells.
7
+ * - `bar`: a horizontal filter bar above a dashboard grid.
8
+ *
9
+ * Two presentations of one control implementation, rather than two
10
+ * implementations: a control gains a behavior (a suggest dropdown, an Apply
11
+ * button) on both surfaces at once.
12
+ */
13
+ export type GivensLayout = "panel" | "bar";
3
14
  export interface GivensPanelProps {
4
15
  givens: Given[];
5
16
  values: Map<string, GivenValue>;
6
17
  onChange: (name: string, value: GivenValue) => void;
7
- onClearAll: () => void;
18
+ onReset: () => void;
19
+ layout?: GivensLayout;
20
+ /** Resolved `suggest` options per given name. */
21
+ options?: Map<string, string[]>;
22
+ optionsLoading?: boolean;
23
+ /** Givens whose `suggest` query failed, from `useSuggestOptions.failed`. */
24
+ optionsFailed?: ReadonlySet<string>;
25
+ /**
26
+ * Set to render an Apply button, for `autorun=false`. Absent means controls
27
+ * take effect as they change, which is the default everywhere.
28
+ */
29
+ apply?: {
30
+ onApply: () => void;
31
+ /** Whether anything has changed since the last apply. */
32
+ pending: boolean;
33
+ };
34
+ /** Overrides the `panel` layout's "Parameters" heading. */
35
+ title?: string;
8
36
  }
9
37
  /**
10
- * Renders the "Parameters" panel — one input per declared `given:`.
38
+ * Renders the control row: one input per declared `given:`.
11
39
  * Returns null when the model declares no givens, so callers can drop
12
40
  * `<GivensPanel ... />` unconditionally without a length guard.
13
41
  *
14
- * A "Reset" button appears in the panel header when at least one value
15
- * is set; it fires `onClearAll` which the parent should wire to
16
- * `useGivensForm.clearAll`.
42
+ * A "Reset" button appears in the header when at least one value is set; it
43
+ * fires `onReset`, which the parent should wire to `useGivensState.reset`. That
44
+ * puts the document's starting values back rather than emptying the row, so the
45
+ * button and the state agree on what "Reset" means.
17
46
  */
18
- export declare function GivensPanel({ givens, values, onChange, onClearAll, }: GivensPanelProps): import("react/jsx-runtime").JSX.Element;
47
+ export declare function GivensPanel({ givens, values, onChange, onReset, layout, options, optionsLoading, optionsFailed, apply, title, }: GivensPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,97 @@
1
+ /** True for the `filter<…>` family, whose values are filter syntax, not plain. */
2
+ export declare function isFilterType(type: string | undefined): boolean;
3
+ /** The `T` of a `filter<T>`, or undefined for any other type. */
4
+ export declare function filterInnerType(type: string | undefined): string | undefined;
5
+ /**
6
+ * Join picked values into one string filter (`"Nike, Levi's"`), which Malloy
7
+ * reads as "any of these".
8
+ *
9
+ * Every value is escaped by the filter package's own printer, so a value that
10
+ * would otherwise read as syntax survives as a literal. A comma does not split
11
+ * it in two, a leading `-` is not a negation, `%` and `_` are not wildcards, and
12
+ * a bare `null` or `empty` is the word rather than the operator.
13
+ *
14
+ * An empty value cannot be carried and is dropped. Malloy's `empty` operator
15
+ * means "null or the empty string", which is a wider question than "the rows
16
+ * whose value is exactly `''`", so there is no faithful spelling for a picked
17
+ * empty option. Dropping it means an all-empty selection encodes to `""`, the
18
+ * empty filter, which is the "All" state.
19
+ *
20
+ * Three kinds of value do not survive, all involving whitespace the grammar
21
+ * treats as structure. None is fixable here without re-introducing the drift
22
+ * this module delegates to avoid, and none can WIDEN a filter, which is the
23
+ * failure that would matter:
24
+ *
25
+ * - **A leading or trailing tab is dropped.** The escaper covers the space
26
+ * character but not the tab, and the parser trims surrounding whitespace, so
27
+ * `"a\t"` comes back as `"a"`: a filter for a different single value, not a
28
+ * broader one. A space in the same position is escaped and does round-trip,
29
+ * and a tab INSIDE a value is untouched.
30
+ * - **An embedded newline makes the whole filter unparseable.** The grammar
31
+ * excludes a bare newline from a match string, so `["a\nb", "c"]` emits
32
+ * `"a\nb, c"` and the parser refuses it outright: `parsed` is null and the
33
+ * log reads `Expected "," … but "\n" found`. The query then errors where the
34
+ * reader can see it, which is the good failure. `decodeFilterList` hands that
35
+ * string back as one opaque value, but that is its display fallback for a
36
+ * filter it cannot represent, NOT a filter that runs and matches the wrong
37
+ * thing. Escaping is not the fix: the library's `unescape` is `/\\(.)/g` and
38
+ * `.` does not match a newline, so the value would return carrying a stray
39
+ * backslash.
40
+ * - **A value that is ENTIRELY whitespace is refused**, rather than encoded.
41
+ * For a tab or an NBSP it HAS to be: the escaper does not cover them, `parse`
42
+ * returns a null clause with an empty log rather than an error, and Malloy
43
+ * compiles a null clause to the SQL constant `true`, so encoding one would
44
+ * match every row. That is the silent widening this module exists to prevent.
45
+ *
46
+ * For a run of ASCII SPACES it is a choice, not a necessity, and the earlier
47
+ * wording here claimed otherwise. Measured: `unparse({operator:"=", values:
48
+ * [" "]})` gives `"\ "` and parses straight back to `[" "]`, so spaces do
49
+ * round-trip. They are dropped anyway to keep ONE rule. The alternative
50
+ * carries spaces and drops tabs, and nothing on screen distinguishes them,
51
+ * so a reader could not predict which of two identical-looking values
52
+ * filtered and which quietly matched everything.
53
+ *
54
+ * The test is JavaScript's `trim()`, which is where this stops: it treats
55
+ * NBSP and the ideographic space as whitespace but NOT U+200B, so a
56
+ * zero-width space survives as an ordinary value. Harmless, since it filters
57
+ * for something useless rather than for everything, but worth the boundary.
58
+ *
59
+ * All three are pinned in the spec so a future change to either side is visible.
60
+ */
61
+ export declare function encodeFilterList(values: readonly string[]): string;
62
+ /**
63
+ * Split a string filter back into the values a multiselect should show
64
+ * selected, undoing {@link encodeFilterList}.
65
+ *
66
+ * Only the list form round-trips. Anything else a filter can express (`-Nike`,
67
+ * `%foo%`, `null`, a `;` conjunction) comes back as a single opaque entry rather
68
+ * than being reinterpreted, so a hand-written filter is preserved rather than
69
+ * mangled by a control that cannot represent it.
70
+ */
71
+ export declare function decodeFilterList(value: string): string[];
72
+ /**
73
+ * Whether a filter is one a picker can represent, and therefore one it may
74
+ * safely re-encode.
75
+ *
76
+ * The picker's selection round-trips through {@link decodeFilterList} and
77
+ * {@link encodeFilterList}, and that is only faithful for the list form. A
78
+ * negation, a wildcard, or a conjunction comes back as one opaque entry so the
79
+ * control can show *something*, but the next edit would re-encode that entry as
80
+ * a literal: turning `-Nike` from "everything except Nike" into a search for
81
+ * the five-character string `-Nike`. A caller that can fall back to a plain text
82
+ * box should ask this first and do so, which keeps the author's filter both
83
+ * visible and intact.
84
+ */
85
+ export declare function isPlainFilterList(value: string | undefined): boolean;
86
+ /** A lower-bound number filter, which is what a one-handled slider means. */
87
+ export declare function encodeAtLeast(value: number): string;
88
+ /**
89
+ * The bound back out of {@link encodeAtLeast}, or undefined for any other filter.
90
+ *
91
+ * Through the library for the same reason the string side is: a hand-rolled
92
+ * `/^>=\s*(-?\d+(?:\.\d+)?)$/` was narrower than the grammar it was standing
93
+ * in for, so `>= 1e3` and `>= .5`, both of which the parser accepts and
94
+ * `unparse` round-trips, read back as undefined and the slider silently showed
95
+ * no lower bound at all.
96
+ */
97
+ export declare function decodeAtLeast(value: string): number | undefined;
@@ -1,2 +1,2 @@
1
1
  export { GivenInput, type GivenInputProps } from './GivenInput';
2
- export { GivensPanel, type GivensPanelProps } from './GivensPanel';
2
+ export { GivensPanel, type GivensLayout, type GivensPanelProps, } from './GivensPanel';
@@ -0,0 +1,60 @@
1
+ import { GivenValue } from '../../hooks/givenValue';
2
+ /**
3
+ * A given's value as a query-parameter string, or undefined when there is
4
+ * nothing to put in the URL (an unset given, which the server fills from the
5
+ * model default).
6
+ *
7
+ * An empty string is a real value, not an absence: for a `filter<…>` it is the
8
+ * empty filter, i.e. "All", which is meaningfully different from leaving the
9
+ * declared default in place.
10
+ */
11
+ export declare function givenToParam(value: GivenValue | undefined, type: string | undefined): string | undefined;
12
+ /** The three calendar fields a picked day is read from, as dayjs exposes them. */
13
+ export interface PickedDay {
14
+ year(): number;
15
+ /** Zero-based, as `Date` and dayjs both have it. */
16
+ month(): number;
17
+ date(): number;
18
+ }
19
+ /**
20
+ * The instant to store for a calendar day the user picked in a date control.
21
+ *
22
+ * Built in UTC from the day's own fields, NOT by taking the instant off the
23
+ * picker. MUI's adapter resolves its default timezone to LOCAL here (this SDK
24
+ * loads dayjs's `utc` plugin but not `timezone`), so the value it hands back is
25
+ * local midnight-ish at the reference time-of-day, while both the read side of
26
+ * the control and {@link dateToRequest} take the UTC day. Those two readings
27
+ * differ by a day for any offset that crosses midnight: in Sydney, clicking
28
+ * 5 January stored 4 January and the field then redrew as the 4th, so the click
29
+ * appeared to jump backwards.
30
+ */
31
+ export declare function pickedDayToUtc(day: PickedDay, previous?: Date): Date;
32
+ /** Read a query-parameter string back as a value of the declared type. */
33
+ export declare function paramToGiven(type: string | undefined, raw: string): GivenValue;
34
+ /**
35
+ * The whole control row as query parameters, dropping unset givens so a
36
+ * default-state dashboard has a clean URL.
37
+ */
38
+ export declare function givensToParams(values: ReadonlyMap<string, GivenValue>, declaredTypes: ReadonlyMap<string, string | undefined>): Record<string, string>;
39
+ /**
40
+ * Control values as the `givens` map a query request takes.
41
+ *
42
+ * Unlike the URL form this keeps types: a `number` given goes over as a
43
+ * number, because the server type-checks each value against its declaration.
44
+ * Only `Date` needs converting, since JSON has no date, and converting it
45
+ * needs the declared type (see {@link dateToRequest}).
46
+ *
47
+ * `only` narrows the map to a named subset, which is how a composite tile is
48
+ * run with just the givens it references instead of the whole control row.
49
+ */
50
+ export declare function givensToRequest(values: ReadonlyMap<string, GivenValue>, declaredTypes: ReadonlyMap<string, string | undefined>, only?: readonly string[]): Record<string, unknown>;
51
+ /**
52
+ * Read query parameters into control values, keeping only the names the
53
+ * dashboard actually declares.
54
+ *
55
+ * A URL can name anything; binding a given the model does not surface fails the
56
+ * query outright, so an unrecognized parameter is ignored rather than passed
57
+ * along. That also means an unrelated query parameter on the page's URL (a
58
+ * tracking tag, say) cannot break the dashboard.
59
+ */
60
+ export declare function paramsToGivens(params: Record<string, string>, declaredTypes: ReadonlyMap<string, string | undefined>): Map<string, GivenValue>;
@@ -1,8 +1,11 @@
1
1
  export { AnalyzePackageButton } from './AnalyzePackageButton';
2
- export { useRouterClickHandler } from './click_helper';
2
+ export { useRouterClickHandler, type NavigationClick } from './click_helper';
3
+ export * from './Dashboard';
3
4
  export * from './DataAppViewer';
5
+ export * from './drill';
4
6
  export * from './Environment';
5
7
  export * from './filter';
8
+ export * from './given';
6
9
  export * from './Home';
7
10
  export * from './Loading';
8
11
  export * from './Materializations';
@@ -13,6 +13,37 @@ export declare const MALLOY_BRAND: {
13
13
  readonly orange: "#e47404";
14
14
  readonly darkBlue: "#1474a4";
15
15
  };
16
+ /**
17
+ * Accents that extend the logo's three, for the places that need more colors
18
+ * than the brand supplies. The package page gives every kind of content its
19
+ * own, and three kinds became six.
20
+ *
21
+ * Their own family rather than borrowings from the chart series
22
+ * (`theme/defaults.ts`), because the two have opposite constraints. A series
23
+ * color fills a large area and can be light; these sit behind a white icon as a
24
+ * small solid backplate, where the icon has to stay legible. Measured against
25
+ * white: violet 5.5:1, magenta 4.6:1, moss 3.9:1, so all three clear 3:1, the
26
+ * WCAG minimum for a graphical object. The nearest series hues do not: `#aacd85`
27
+ * sage is 1.8:1, `#ec72b8` pink 2.7:1, `#b87ced` violet 2.9:1.
28
+ *
29
+ * These three were picked against the bar, but they are not the only colors it
30
+ * now binds. `CONTENT_TINT` in `Package/ContentTypeIcon.tsx` paints all three of
31
+ * `MALLOY_BRAND` behind glyphs as well, and `ContentTypeIcon.spec.ts` holds two
32
+ * of them to the same 3:1: orange at 3.09:1 and darkBlue at 5.17:1. Orange
33
+ * clears it by 0.09, so retuning it lighter turns that suite red, in a file a
34
+ * brand change would not otherwise open. For those two the bar is a component
35
+ * constraint, not only a brand decision.
36
+ *
37
+ * Teal is the exception at 2.5:1, below the bar and inherited from the logo, so
38
+ * the row it backs carries a white-on-teal glyph that does not meet the
39
+ * standard. Pre-existing, not introduced here. The spec grandfathers it by
40
+ * content type rather than by color, so a new type handed teal still fails.
41
+ */
42
+ export declare const MALLOY_ACCENT: {
43
+ readonly violet: "#7c4dcc";
44
+ readonly magenta: "#c2478f";
45
+ readonly moss: "#5c8f3f";
46
+ };
16
47
  /**
17
48
  * Monospace font stack used by code-like surfaces inside the SDK
18
49
  * (file-path labels in PackageItemRow, code blocks, etc.). Matches the
@@ -3,4 +3,10 @@ export declare const DOC_LINKS: {
3
3
  readonly publishing: "https://docs.malloydata.dev/documentation/user_guides/publishing/publishing";
4
4
  readonly explorer: "https://docs.malloydata.dev/documentation/user_guides/publishing/explorer";
5
5
  readonly mcpAgents: "https://docs.malloydata.dev/documentation/user_guides/publishing/mcp_agents";
6
+ readonly surfaces: "https://github.com/malloydata/publisher/blob/main/docs/choosing-a-surface.md";
7
+ readonly dashboards: "https://github.com/malloydata/publisher/blob/main/docs/dashboards.md";
8
+ readonly dataApps: "https://github.com/malloydata/publisher/blob/main/docs/html-data-apps.md";
9
+ readonly givens: "https://github.com/malloydata/publisher/blob/main/docs/givens.md";
10
+ readonly materialization: "https://github.com/malloydata/publisher/blob/main/docs/materialization.md";
11
+ readonly connections: "https://github.com/malloydata/publisher/blob/main/docs/connections.md";
6
12
  };