@malloy-publisher/sdk 0.9.14 → 0.9.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/RenderedResult-5hOs5XnV.cjs.js +171 -0
  2. package/dist/RenderedResult-DxmHGZNQ.es.js +671 -0
  3. package/dist/{ServerProvider-BV7IoDMR.es.js → ServerProvider-D7neZcTk.es.js} +283 -265
  4. package/dist/ServerProvider-e2369oom.cjs.js +1 -0
  5. package/dist/builder/index.cjs.js +80 -79
  6. package/dist/builder/index.es.js +7732 -6717
  7. package/dist/builder-entry.d.ts +1 -1
  8. package/dist/client/api.d.ts +31 -7
  9. package/dist/client/index.cjs.js +1 -1
  10. package/dist/client/index.es.js +1 -1
  11. package/dist/components/Dashboard/DashboardGrid.d.ts +51 -1
  12. package/dist/components/Dashboard/DashboardTile.d.ts +7 -2
  13. package/dist/components/Dashboard/DashboardView.d.ts +9 -2
  14. package/dist/components/Dashboard/index.d.ts +1 -1
  15. package/dist/components/Dashboard/promoteMeasureRow.d.ts +5 -7
  16. package/dist/components/Dashboard/useStuck.d.ts +18 -12
  17. package/dist/components/RenderedResult/RenderedResult.d.ts +3 -2
  18. package/dist/components/RenderedResult/ResultContainer.d.ts +18 -1
  19. package/dist/components/RenderedResult/ResultPanel.d.ts +7 -1
  20. package/dist/components/RenderedResult/chartPresentation.d.ts +15 -0
  21. package/dist/components/RenderedResult/chartShapeProblem.d.ts +55 -0
  22. package/dist/components/RenderedResult/resultSizing.d.ts +47 -6
  23. package/dist/components/Report/Report.d.ts +7 -1
  24. package/dist/components/Report/ReportPage.d.ts +7 -0
  25. package/dist/components/Report/layoutRules.d.ts +45 -0
  26. package/dist/components/ReportBuilder/AddTileDialog.d.ts +2 -1
  27. package/dist/components/ReportBuilder/ArrangeMenu.d.ts +9 -0
  28. package/dist/components/ReportBuilder/BuilderGrid.d.ts +15 -4
  29. package/dist/components/ReportBuilder/BuilderToolbar.d.ts +3 -1
  30. package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
  31. package/dist/components/ReportBuilder/EditorSurface.d.ts +10 -1
  32. package/dist/components/ReportBuilder/ReportBuilder.d.ts +1 -1
  33. package/dist/components/ReportBuilder/TileFrame.d.ts +54 -10
  34. package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
  35. package/dist/components/ReportBuilder/builderControls.d.ts +19 -0
  36. package/dist/components/ReportBuilder/catalog.d.ts +23 -0
  37. package/dist/components/ReportBuilder/chartLine.d.ts +38 -5
  38. package/dist/components/ReportBuilder/controls.d.ts +2 -2
  39. package/dist/components/ReportBuilder/document.d.ts +53 -5
  40. package/dist/components/ReportBuilder/imports.d.ts +7 -0
  41. package/dist/components/ReportBuilder/placement.d.ts +121 -0
  42. package/dist/components/ReportBuilder/preview.d.ts +59 -10
  43. package/dist/components/ReportBuilder/sortable.d.ts +12 -1
  44. package/dist/components/ReportBuilder/useBuilderSession.d.ts +1 -1
  45. package/dist/components/ReportBuilder/useBuilderShortcuts.d.ts +9 -1
  46. package/dist/components/ReportBuilder/useEdgeResize.d.ts +84 -0
  47. package/dist/components/ReportBuilder/useTileReorder.d.ts +30 -3
  48. package/dist/index.cjs.js +7 -7
  49. package/dist/index.es.js +3349 -3307
  50. package/dist/text/index.es.js +1 -1
  51. package/dist/{text-entry-72YFLeNk.es.js → text-entry-YKJZbRPo.es.js} +2 -2
  52. package/dist/theme/classes.d.ts +1 -1
  53. package/dist/theme/resolveTheme.d.ts +15 -0
  54. package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-CaYP_OYG.es.js} +6353 -6047
  55. package/dist/useCompiledDocument-zYEfLogf.cjs.js +142 -0
  56. package/dist/utils/blankQuoted.d.ts +15 -0
  57. package/package.json +1 -1
  58. package/src/builder-entry.ts +1 -0
  59. package/src/components/Dashboard/DashboardGrid.tsx +129 -10
  60. package/src/components/Dashboard/DashboardTile.tsx +15 -1
  61. package/src/components/Dashboard/DashboardView.tsx +64 -10
  62. package/src/components/Dashboard/TileCard.tsx +6 -0
  63. package/src/components/Dashboard/index.ts +1 -0
  64. package/src/components/Dashboard/promoteMeasureRow.spec.ts +19 -0
  65. package/src/components/Dashboard/promoteMeasureRow.ts +15 -36
  66. package/src/components/Dashboard/tileHeight.spec.ts +72 -0
  67. package/src/components/Dashboard/useStuck.ts +76 -28
  68. package/src/components/Package/NewDocumentDialog.spec.tsx +20 -16
  69. package/src/components/Package/NewDocumentDialog.tsx +10 -11
  70. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +167 -2
  71. package/src/components/RenderedResult/RenderedResult.tsx +39 -6
  72. package/src/components/RenderedResult/ResultContainer.tsx +99 -10
  73. package/src/components/RenderedResult/ResultPanel.tsx +25 -1
  74. package/src/components/RenderedResult/chartPresentation.spec.ts +153 -0
  75. package/src/components/RenderedResult/chartPresentation.ts +166 -0
  76. package/src/components/RenderedResult/chartShapeProblem.spec.tsx +245 -0
  77. package/src/components/RenderedResult/chartShapeProblem.ts +219 -0
  78. package/src/components/RenderedResult/resultSizing.spec.ts +75 -3
  79. package/src/components/RenderedResult/resultSizing.ts +71 -11
  80. package/src/components/Report/Report.spec.tsx +19 -0
  81. package/src/components/Report/Report.tsx +8 -1
  82. package/src/components/Report/ReportPage.tsx +13 -1
  83. package/src/components/Report/layoutRules.spec.ts +43 -3
  84. package/src/components/Report/layoutRules.ts +70 -0
  85. package/src/components/Report/tileOverflow.spec.tsx +162 -0
  86. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +2 -2
  87. package/src/components/ReportBuilder/AddTileDialog.tsx +11 -6
  88. package/src/components/ReportBuilder/ArrangeMenu.tsx +80 -0
  89. package/src/components/ReportBuilder/BuilderBar.tsx +5 -1
  90. package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -1
  91. package/src/components/ReportBuilder/BuilderGrid.tsx +142 -35
  92. package/src/components/ReportBuilder/BuilderToolbar.tsx +4 -0
  93. package/src/components/ReportBuilder/ChartPicker.spec.ts +91 -4
  94. package/src/components/ReportBuilder/ChartPicker.tsx +45 -10
  95. package/src/components/ReportBuilder/DrillDialog.tsx +8 -2
  96. package/src/components/ReportBuilder/EditorSurface.tsx +101 -20
  97. package/src/components/ReportBuilder/FilterDialog.tsx +17 -8
  98. package/src/components/ReportBuilder/FilterStrip.tsx +2 -1
  99. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +193 -2
  100. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
  101. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +2 -2
  102. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +242 -2
  103. package/src/components/ReportBuilder/ReportBuilder.tsx +161 -27
  104. package/src/components/ReportBuilder/ReportEditor.fileModel.spec.tsx +178 -0
  105. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +3 -5
  106. package/src/components/ReportBuilder/ReportEditor.readOnlyTitle.spec.tsx +92 -0
  107. package/src/components/ReportBuilder/ReportEditor.tsx +13 -0
  108. package/src/components/ReportBuilder/TileFrame.tsx +366 -170
  109. package/src/components/ReportBuilder/TileMenu.tsx +259 -20
  110. package/src/components/ReportBuilder/ViewPicker.tsx +4 -3
  111. package/src/components/ReportBuilder/addTileToDocument.spec.ts +34 -0
  112. package/src/components/ReportBuilder/addTileToDocument.ts +26 -1
  113. package/src/components/ReportBuilder/builderControls.ts +34 -0
  114. package/src/components/ReportBuilder/catalog.aggregate.spec.ts +137 -1
  115. package/src/components/ReportBuilder/catalog.ts +90 -37
  116. package/src/components/ReportBuilder/chartLine.spec.ts +42 -5
  117. package/src/components/ReportBuilder/chartLine.ts +80 -2
  118. package/src/components/ReportBuilder/controls.ts +4 -3
  119. package/src/components/ReportBuilder/document.ts +65 -7
  120. package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
  121. package/src/components/ReportBuilder/entryLayout.spec.ts +151 -0
  122. package/src/components/ReportBuilder/imports.ts +1 -1
  123. package/src/components/ReportBuilder/invariants.spec.ts +18 -10
  124. package/src/components/ReportBuilder/layout.ts +3 -0
  125. package/src/components/ReportBuilder/placement.spec.ts +401 -0
  126. package/src/components/ReportBuilder/placement.ts +416 -0
  127. package/src/components/ReportBuilder/preview.shapes.spec.ts +46 -6
  128. package/src/components/ReportBuilder/preview.spec.ts +151 -11
  129. package/src/components/ReportBuilder/preview.ts +203 -40
  130. package/src/components/ReportBuilder/preview.unsaved.compile.spec.ts +190 -0
  131. package/src/components/ReportBuilder/readDocument.spec.ts +53 -19
  132. package/src/components/ReportBuilder/readDocument.ts +197 -29
  133. package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
  134. package/src/components/ReportBuilder/sortable.tsx +30 -2
  135. package/src/components/ReportBuilder/spliceDocument.chart.spec.ts +1 -1
  136. package/src/components/ReportBuilder/spliceDocument.color.spec.ts +80 -0
  137. package/src/components/ReportBuilder/spliceDocument.colspan.spec.ts +78 -0
  138. package/src/components/ReportBuilder/spliceDocument.spec.ts +110 -58
  139. package/src/components/ReportBuilder/spliceDocument.ts +139 -91
  140. package/src/components/ReportBuilder/statementExtent.spec.ts +3 -3
  141. package/src/components/ReportBuilder/testing/reportGivenOrder.json +42 -0
  142. package/src/components/ReportBuilder/textTiles.spec.ts +2 -2
  143. package/src/components/ReportBuilder/tileDisplayTitle.ts +2 -2
  144. package/src/components/ReportBuilder/useBuilderSession.ts +7 -2
  145. package/src/components/ReportBuilder/useBuilderShortcuts.ts +25 -1
  146. package/src/components/ReportBuilder/useEdgeResize.spec.tsx +324 -0
  147. package/src/components/ReportBuilder/useEdgeResize.ts +397 -0
  148. package/src/components/ReportBuilder/useTileEditing.ts +16 -3
  149. package/src/components/ReportBuilder/useTileReorder.ts +143 -6
  150. package/src/components/given/FilterButton.spec.tsx +27 -11
  151. package/src/components/given/FilterButton.tsx +19 -6
  152. package/src/theme/classes.ts +1 -1
  153. package/src/theme/resolveTheme.spec.ts +72 -1
  154. package/src/theme/resolveTheme.ts +43 -0
  155. package/src/utils/blankQuoted.spec.ts +50 -0
  156. package/src/utils/blankQuoted.ts +32 -0
  157. package/src/utils/malloyText.ts +2 -1
  158. package/dist/RenderedResult-DnBtf-cI.es.js +0 -593
  159. package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
  160. package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
  161. package/dist/components/ReportBuilder/useTileResize.d.ts +0 -32
  162. package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
  163. package/src/components/ReportBuilder/useTileResize.spec.tsx +0 -146
  164. package/src/components/ReportBuilder/useTileResize.ts +0 -133
@@ -0,0 +1,671 @@
1
+ import { jsx as M } from "react/jsx-runtime";
2
+ import { Box as ie } from "@mui/material";
3
+ import { Suspense as pe, useRef as z, useCallback as ge, useMemo as ve, useEffect as we, useLayoutEffect as ke } from "react";
4
+ import { r as xe, a as he, D as Ce, b as Y, T as H, l as Re, c as Ee, d as Te, e as _e, m as Ae, f as Se, g as se } from "./useCompiledDocument-CaYP_OYG.es.js";
5
+ import { ba as De, b8 as Oe, bb as Fe, bc as ze } from "./ServerProvider-D7neZcTk.es.js";
6
+ const v = xe.drillCell;
7
+ function Me(e, t) {
8
+ const a = /* @__PURE__ */ new Set();
9
+ let l;
10
+ try {
11
+ l = e.getMetadata()?.getAllFields() ?? [];
12
+ } catch {
13
+ return a;
14
+ }
15
+ const r = /* @__PURE__ */ new Set();
16
+ for (const o of l)
17
+ !o || t(o) || o.tag?.tag("hidden") === void 0 && r.add(o.tag?.text("label") ?? o.name);
18
+ for (const o of l) {
19
+ if (!o || !t(o)) continue;
20
+ const n = o.tag?.text("label") ?? o.name;
21
+ r.has(n) || a.add(n);
22
+ }
23
+ return a;
24
+ }
25
+ function L(e) {
26
+ const t = /^\s*(\d+)/.exec(e.style?.gridColumn ?? "");
27
+ return t ? t[1] : void 0;
28
+ }
29
+ function Ie(e, t) {
30
+ if (t.size !== 0)
31
+ for (const a of e.querySelectorAll(
32
+ ".malloy-table"
33
+ )) {
34
+ const l = (n) => n.closest(".malloy-table") === a, r = /* @__PURE__ */ new Set();
35
+ for (const n of a.querySelectorAll(
36
+ ".column-cell.th"
37
+ )) {
38
+ if (!l(n)) continue;
39
+ const i = (n.textContent ?? "").replace(/\u200b/g, "").trim(), h = L(n);
40
+ h && t.has(i) && r.add(h);
41
+ }
42
+ if (r.size === 0) continue;
43
+ const o = /* @__PURE__ */ new Set();
44
+ for (const n of a.querySelectorAll(
45
+ `.${v}[tabindex="0"]`
46
+ )) {
47
+ if (!l(n)) continue;
48
+ const i = L(n);
49
+ i && (o.has(i) ? n.tabIndex = -1 : o.add(i));
50
+ }
51
+ for (const n of a.querySelectorAll(
52
+ ".column-cell.td"
53
+ )) {
54
+ if (!l(n)) continue;
55
+ const i = L(n), h = !n.querySelector(".value-null") && (n.textContent ?? "").trim() !== "";
56
+ if (i && h && r.has(i) && !n.querySelector(".malloy-table")) {
57
+ if (n.classList.add(v), n.tabIndex === 0)
58
+ o.add(i);
59
+ else {
60
+ const p = o.has(i);
61
+ p || o.add(i), n.tabIndex = p ? -1 : 0;
62
+ }
63
+ n.setAttribute("role", "button");
64
+ }
65
+ }
66
+ }
67
+ }
68
+ function Le(e) {
69
+ const t = e.closest(".malloy-table"), a = L(e);
70
+ return !t || !a ? [] : Array.from(
71
+ t.querySelectorAll(`.${v}`)
72
+ ).filter(
73
+ (l) => l.closest(".malloy-table") === t && L(l) === a
74
+ );
75
+ }
76
+ function de(e, t) {
77
+ const a = Le(e), l = a.indexOf(e);
78
+ if (l === -1) return;
79
+ const r = t === "first" ? a[0] : t === "last" ? a[a.length - 1] : a[Math.min(Math.max(l + t, 0), a.length - 1)];
80
+ if (r) {
81
+ for (const o of a) o.tabIndex = o === r ? 0 : -1;
82
+ return r;
83
+ }
84
+ }
85
+ function $e(e) {
86
+ return {
87
+ background: e.dashboardRoot,
88
+ tableBackground: e.tableBackground,
89
+ tableHeaderColor: e.tableHeader,
90
+ tableBodyColor: e.tableBody,
91
+ tableBorder: e.border,
92
+ // Header row background (operator-customizable, NEW). The
93
+ // renderer reuses tablePinnedBackground for any pinned header
94
+ // cell; we additionally paint the regular header row from the
95
+ // same var via injectRendererOverrides so non-pinned tables
96
+ // also show the header band.
97
+ tablePinnedBackground: e.tableHeaderBackground,
98
+ tablePinnedBorder: e.pinnedBorder,
99
+ tableFontSize: `${e.font.size}px`,
100
+ fontFamily: e.font.family,
101
+ // Saturated end of the choropleth gradient. The renderer
102
+ // generates a low-to-high ramp from a neutral grey to this
103
+ // colour for shape-map / segment-map plugins via getColorScale.
104
+ mapColor: e.mapColor
105
+ };
106
+ }
107
+ function Be(e) {
108
+ const { foreground: t, axisFaint: a, gridline: l, font: r } = e, o = {
109
+ background: e.background,
110
+ font: r.family,
111
+ title: { color: t, font: r.family },
112
+ axis: {
113
+ labelColor: t,
114
+ titleColor: t,
115
+ domainColor: a,
116
+ tickColor: a,
117
+ gridColor: l,
118
+ labelFont: r.family,
119
+ titleFont: r.family
120
+ },
121
+ legend: {
122
+ labelColor: t,
123
+ titleColor: t,
124
+ labelFont: r.family,
125
+ titleFont: r.family
126
+ },
127
+ header: { labelColor: t, titleColor: t },
128
+ range: { category: e.series }
129
+ }, n = {
130
+ ...o,
131
+ legend: { ...o.legend, orient: "bottom" }
132
+ };
133
+ return (i) => i === "shape_map" ? n : o;
134
+ }
135
+ function Ne(e) {
136
+ if (!e) return;
137
+ const t = e.tag("theme");
138
+ if (!t) return;
139
+ const a = {}, l = t.tag("palette");
140
+ if (l) {
141
+ const o = {}, n = l.textArray("series");
142
+ n && n.length > 0 && (o.series = n);
143
+ for (const i of De) {
144
+ const h = l.tag(i);
145
+ if (!h) continue;
146
+ const p = {}, k = h.text("light"), w = h.text("dark");
147
+ k && (p.light = k), w && (p.dark = w), Object.keys(p).length > 0 && (o[i] = p);
148
+ }
149
+ Object.keys(o).length > 0 && (a.palette = o);
150
+ }
151
+ const r = t.tag("font");
152
+ if (r) {
153
+ const o = {}, n = r.text("family");
154
+ n && (o.family = n);
155
+ const i = r.numeric("size");
156
+ typeof i == "number" && Number.isFinite(i) && (o.size = i), Object.keys(o).length > 0 && (a.font = o);
157
+ }
158
+ return Object.keys(a).length > 0 ? a : void 0;
159
+ }
160
+ const J = (e) => (e ?? []).map((t) => t?.value).filter((t) => typeof t == "string");
161
+ function Pe(e) {
162
+ const t = e.replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim();
163
+ return t.charAt(0).toUpperCase() + t.slice(1);
164
+ }
165
+ const je = (e) => J(e.annotations).some((t) => {
166
+ const a = t.trim();
167
+ return /^#[^("]/.test(a) && /(?:^#|[\s{])label\s*=/.test(a);
168
+ }), He = (e) => `"${e.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`, qe = (e) => e.type?.element_type?.fields ?? e.type?.fields;
169
+ function me(e, t) {
170
+ let a = !1;
171
+ return { fields: e.map((r) => {
172
+ const o = qe(r);
173
+ if (o) {
174
+ const i = me(
175
+ o,
176
+ he(J(r.annotations))
177
+ );
178
+ if (!i.changed) return r;
179
+ a = !0;
180
+ const h = r.type?.element_type ? {
181
+ ...r.type,
182
+ element_type: {
183
+ ...r.type.element_type,
184
+ fields: i.fields
185
+ }
186
+ } : { ...r.type, fields: i.fields };
187
+ return { ...r, type: h };
188
+ }
189
+ if (!t || !r.name || je(r)) return r;
190
+ const n = Pe(r.name);
191
+ return n === r.name ? r : (a = !0, {
192
+ ...r,
193
+ annotations: [
194
+ { value: `# label=${He(n)}
195
+ ` },
196
+ ...r.annotations ?? []
197
+ ]
198
+ });
199
+ }), changed: a };
200
+ }
201
+ function Ve(e) {
202
+ if (!e || typeof e != "object") return e;
203
+ const t = e, a = t.schema?.fields;
204
+ if (!Array.isArray(a)) return e;
205
+ const { fields: l, changed: r } = me(
206
+ a,
207
+ he(J(t.annotations))
208
+ );
209
+ return r ? { ...t, schema: { ...t.schema, fields: l } } : e;
210
+ }
211
+ const ce = 320, Xe = 10, Ke = 96, We = 4e3;
212
+ function Ge(e, t) {
213
+ if (e !== "bar" && e !== "combo" && e !== "line" && e !== "chart" && e !== "scatter_chart")
214
+ return;
215
+ if (e !== "bar" && e !== "combo") return ce;
216
+ const a = t?.data?.array_value?.length, l = a === void 0 ? 0 : a * Xe + Ke;
217
+ return Math.min(Math.max(ce, l), We);
218
+ }
219
+ const I = "data-publisher-fill", Ue = async (e, t) => {
220
+ if (typeof window > "u")
221
+ throw new Error("MalloyRenderer can only be used in browser environment");
222
+ const { MalloyRenderer: a } = await Ee();
223
+ return new a({
224
+ onClick: t,
225
+ vegaConfigOverride: Be(e),
226
+ // Pass the explicit theme so table chrome and dashboard tiles
227
+ // pick up the operator's colours directly. Without this the
228
+ // renderer's own inline style writes `--malloy-render--*` values
229
+ // sourced from its built-in defaults and shadows whatever we set
230
+ // on the outer wrapper.
231
+ theme: $e(e),
232
+ onError: (r) => {
233
+ console.error("Error rendering visualization:", typeof r, r);
234
+ }
235
+ }).createViz();
236
+ };
237
+ async function Ye(e) {
238
+ if (!e || typeof e != "object") return;
239
+ const t = e, a = [
240
+ ...Array.isArray(t.model_annotations) ? t.model_annotations : [],
241
+ ...Array.isArray(t.source_annotations) ? t.source_annotations : [],
242
+ ...Array.isArray(t.annotations) ? t.annotations : []
243
+ ].map((r) => typeof r?.value == "string" ? r.value : void 0).filter((r) => !!r);
244
+ if (a.length === 0) return;
245
+ let l;
246
+ try {
247
+ ({ parseAnnotation: l } = await Re());
248
+ } catch {
249
+ return;
250
+ }
251
+ try {
252
+ const { tag: r } = l(a);
253
+ return Ne(r);
254
+ } catch (r) {
255
+ console.warn(
256
+ "Failed to parse # theme.* annotations; chart will render with the shell theme.",
257
+ { error: r, lines: a }
258
+ );
259
+ return;
260
+ }
261
+ }
262
+ function Je(e, t, a) {
263
+ const l = Te(t, a);
264
+ for (const [r, o] of Object.entries(l))
265
+ e.style.setProperty(r, o);
266
+ }
267
+ const Qe = `
268
+ /* Card geometry, through the renderer's OWN theme vars rather than over the top
269
+ of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
270
+ passes each through to the --malloy-render--* the card CSS reads, so a value
271
+ inherited from our wrapper loses to that declaration however early it is set:
272
+ this has to be a rule on the same element, at higher specificity. Doubling the
273
+ class does that, and then no !important is needed — which matters, because
274
+ !important here also lands on .dashboard-item-borderless and repaints a card
275
+ the author asked to have no card. */
276
+ .malloy-render.malloy-render {
277
+ --malloy-theme--dashboard-card-radius: var(--publisher-dashboard-card-radius);
278
+ --malloy-theme--dashboard-card-padding: var(--publisher-dashboard-card-padding);
279
+ }
280
+ /* dashboard.css hardcodes background: #f7f9fc on .malloy-dashboard
281
+ and .dashboard-row-header, which would paint light grey in dark
282
+ mode and also bleed an operator-picked palette.background across
283
+ the panel chrome in light. Both surfaces use
284
+ --malloy-render--background here, which buildMalloyExplicitTheme
285
+ wires to dashboardRoot: a mode-keyed neutral that stays decoupled
286
+ from palette.background (the chart canvas) on purpose. Selectors
287
+ are duplicated at higher specificity to beat the renderer s own
288
+ scoped rules. */
289
+ .malloy-render .malloy-dashboard,
290
+ .malloy-render.malloy-render .malloy-dashboard,
291
+ div.malloy-render .malloy-dashboard {
292
+ /* --publisher-dashboard-root is set on the outer Publisher wrapper
293
+ (see buildTableCssVars) and stays decoupled from
294
+ --malloy-render--background, which gets shadowed inside the
295
+ renderer when a theme.background annotation is present. The
296
+ dedicated var means the panel between tiles always paints the
297
+ operator neutral dashboardRoot regardless of annotations. */
298
+ background: var(--publisher-dashboard-root) !important;
299
+ background-color: var(--publisher-dashboard-root) !important;
300
+ color: var(--malloy-render--table-body-color) !important;
301
+ }
302
+ .malloy-render .malloy-dashboard .dashboard-row,
303
+ .malloy-render .malloy-dashboard .dashboard-row-body,
304
+ .malloy-render .malloy-dashboard .dashboard-row-header,
305
+ .malloy-render.malloy-render .malloy-dashboard .dashboard-row-header,
306
+ div.malloy-render .malloy-dashboard .dashboard-row-header {
307
+ /* Belt + suspenders: dashboard.css hardcodes .dashboard-row-header
308
+ to #f7f9fc, and row / row-body have no explicit background but
309
+ get caught in any annotation-driven inline writes. Force all of
310
+ them to the neutral panel colour. */
311
+ background: var(--publisher-dashboard-root) !important;
312
+ background-color: var(--publisher-dashboard-root) !important;
313
+ }
314
+ .malloy-render .malloy-dashboard .dashboard-item:not(.dashboard-item-borderless) {
315
+ /* Tile padding around each chart / table. Uses our custom
316
+ --malloy-render--tile-background so the operator can theme the
317
+ tile separately from the table header row (which paints from
318
+ --malloy-render--table-pinned-background below).
319
+
320
+ A flat bordered card rather than the renderer's shadow ring, which is what
321
+ makes it match the composite tile's Paper. :not(borderless) because
322
+ # borderless asks for no card at all, and an !important background and
323
+ border drew one anyway. */
324
+ background: var(--malloy-render--tile-background) !important;
325
+ color: var(--malloy-render--table-body-color) !important;
326
+ box-shadow: none !important;
327
+ /* The card edge, not the table gridline: --publisher-dashboard-card-border,
328
+ the same value TileCard paints, so the renderer's card and the composite
329
+ one are outlined identically. */
330
+ border: var(--publisher-dashboard-card-border) !important;
331
+ }
332
+ /* The renderer's big-value card — the small card a "# big_value" measure sits
333
+ in, several to a row inside one tile. (No backticks in here: this is inside
334
+ a template literal.) Its own CSS gives it a 0.55px edge in
335
+ #e5e7eb: a sub-pixel width, and a grey off the slate ramp everything else on
336
+ the page is on. It is a dashboard card like any other, so it takes the card
337
+ edge and stops being the one card outlined in a hairline nobody can see. */
338
+ .malloy-render .malloy-big-value-card {
339
+ border: var(--publisher-dashboard-card-border) !important;
340
+ /* Its shadow is a four-layer Tailwind stack, and only two of those layers
341
+ are a shadow: the other is "0 0 0 1px #e5e7eb", a spread ring drawn as a
342
+ second border OVER the real one. So the border above was landing
343
+ underneath a ring in the renderer's own grey, and the card kept both a
344
+ lifted look the flat cards around it do not have and an edge we did not
345
+ pick. Dropped whole rather than rebuilt layer by layer: the ring's job is
346
+ the border's job, and the border is already doing it. */
347
+ box-shadow: none !important;
348
+ }
349
+ /* The strip of big-value cards as a grid, so cards share a width and the last one does not wrap
350
+ alone. The renderer's wrapping flex row sizes each card to its own text. The 250px floor is the
351
+ widest realistic value: it is nowrap at 32px in an overflow:visible card, so a narrower track
352
+ would spill it onto its neighbour. Embedded (a nested big_value) is left as the renderer draws it. */
353
+ .malloy-render .malloy-big-value:not(.malloy-big-value--embedded) {
354
+ display: grid;
355
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
356
+ }
357
+ .malloy-render .malloy-big-value-card:not(.malloy-big-value-card--embedded) {
358
+ width: auto;
359
+ max-width: none;
360
+ }
361
+ /* Compact, in a tile set shorter than its cards (ResultContainer marks it tight): smaller values,
362
+ tighter cards and a 190px floor, which a 22px value still fits in, so five cards share a row of
363
+ about a thousand pixels instead of wrapping into rows the tile has no room for. */
364
+ [${H}] .malloy-render .malloy-big-value:not(.malloy-big-value--embedded) {
365
+ grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
366
+ gap: 8px;
367
+ padding: 8px;
368
+ }
369
+ [${H}] .malloy-render .malloy-big-value-card:not(.malloy-big-value-card--embedded) {
370
+ padding: 9px 14px;
371
+ }
372
+ [${H}] .malloy-render .malloy-big-value-value {
373
+ font-size: 22px;
374
+ }
375
+ [${H}] .malloy-render .malloy-big-value-label {
376
+ font-size: 11px;
377
+ }
378
+ .malloy-render .malloy-dashboard .dashboard-row-header-separator {
379
+ background: var(--malloy-render--table-border) !important;
380
+ }
381
+ /* !important because the malloy-explorer stylesheet pins these same properties with it. */
382
+ [${I}] .malloy-table.root {
383
+ height: 100% !important;
384
+ align-content: start !important;
385
+ grid-template-columns: repeat(var(--total-header-size), minmax(max-content, 1fr)) !important;
386
+ }
387
+ .malloy-render .malloy-table .th.column-cell {
388
+ /* Non-pinned tables have no header background in the renderer's
389
+ own CSS (only pinned scrolled tables paint the pinned-header
390
+ with this var). Force the same value here so every table has a
391
+ visible header band reflecting the operator's choice. */
392
+ background: var(--malloy-render--table-pinned-background) !important;
393
+ }
394
+ .malloy-render .dashboard-item-title,
395
+ .malloy-render .dashboard-dimension-name {
396
+ color: var(--malloy-render--label-color) !important;
397
+ }
398
+ .malloy-render .dashboard-item-value,
399
+ .malloy-render .dashboard-item-value-measure,
400
+ .malloy-render .dashboard-dimension-value {
401
+ color: var(--malloy-render--value-color) !important;
402
+ }
403
+ .malloy-render .malloy-table,
404
+ .malloy-render .malloy-list {
405
+ color: var(--malloy-render--table-body-color) !important;
406
+ }
407
+ .malloy-render .column-cell.th,
408
+ .malloy-render .cell-content.header {
409
+ color: var(--malloy-render--table-header-color) !important;
410
+ }
411
+ /* A cell whose column declares a "# drill" this surface can honor, marked
412
+ by markDrillableCells. Ordinary text with a pointer cursor until hovered,
413
+ then it reads as a link: the same affordance Malloyyo gives the same tag,
414
+ and the only thing that tells a reader a cell navigates. Kept off the
415
+ resting state deliberately: a column painted blue competes with the data.
416
+ (No backticks in here: this is inside a template literal.) */
417
+ .malloy-render .${v} {
418
+ cursor: pointer;
419
+ }
420
+ .malloy-render .${v}:hover > .cell-content {
421
+ color: var(--publisher-drill-link) !important;
422
+ text-decoration: underline;
423
+ }
424
+ /* Keyboard focus reads the same as hover, plus a ring: a hover colour is not
425
+ something a keyboard user can produce, and a focus ring is not something a
426
+ mouse user sees. focus-visible rather than focus, so a click does not leave a
427
+ ring behind it. (No backticks in here: this is inside a template literal.) */
428
+ .malloy-render .${v}:focus-visible {
429
+ outline: 2px solid var(--publisher-drill-link);
430
+ outline-offset: -2px;
431
+ }
432
+ .malloy-render .${v}:focus-visible > .cell-content {
433
+ color: var(--publisher-drill-link) !important;
434
+ text-decoration: underline;
435
+ }
436
+ `, ue = "publisher-malloy-renderer-overrides";
437
+ function Ze() {
438
+ if (typeof document > "u" || document.getElementById(ue)) return;
439
+ const e = document.createElement("style");
440
+ e.id = ue, e.textContent = Qe, document.head.appendChild(e);
441
+ }
442
+ function et({
443
+ result: e,
444
+ height: t,
445
+ drill: a,
446
+ onSizeChange: l,
447
+ onSizing: r,
448
+ fill: o
449
+ }) {
450
+ const n = z(null), i = z(a);
451
+ i.current = a;
452
+ const h = ge((d) => {
453
+ i.current?.onClick(d);
454
+ }, []), p = a !== void 0, k = z(!1), w = z(
455
+ null
456
+ ), q = z(0), { theme: $, layers: V, mode: Q } = Oe(), Z = ve(
457
+ () => ({
458
+ radius: $.ui.radius.tile,
459
+ padding: `${Ce}px`
460
+ }),
461
+ [$.ui.radius.tile]
462
+ );
463
+ return we(() => () => {
464
+ q.current += 1;
465
+ const d = w.current;
466
+ d?.viz.remove(), d?.node.remove(), w.current = null;
467
+ }, []), ke(() => {
468
+ if (!n.current || !e) return;
469
+ Ze();
470
+ const d = n.current, be = q.current += 1;
471
+ let X = !1;
472
+ const K = () => !X && be === q.current;
473
+ let c, b, B = null, W = 0, N = null, P = null, j = null, A = null, S = null, D = null, ee = null, te = 0, C = null;
474
+ k.current = !1;
475
+ let y, R;
476
+ const G = (g) => {
477
+ if (X || !g.firstElementChild || Y(y, R) === "container") return;
478
+ const O = _e(y, R);
479
+ if (k.current && !O) return;
480
+ const F = d.hasAttribute(I);
481
+ F && d.removeAttribute(I);
482
+ const E = Ae(
483
+ g,
484
+ se(y)
485
+ );
486
+ F && d.setAttribute(I, ""), E > 0 && (k.current = !0, l && E !== te && (te = E, l(E)));
487
+ const u = Se(g, se(y));
488
+ O && u && ee !== u && (ee = u, D?.disconnect(), D = new ResizeObserver(() => G(g)), D.observe(u));
489
+ };
490
+ return (async () => {
491
+ let g;
492
+ try {
493
+ g = JSON.parse(e);
494
+ } catch (m) {
495
+ console.error("Error parsing visualization result:", m);
496
+ return;
497
+ }
498
+ const O = await Ye(g), F = O ? Fe([...V, ze(V, O)], Q) : $;
499
+ if (!K()) return;
500
+ try {
501
+ b = await Ue(F, h);
502
+ } catch (m) {
503
+ console.error("Failed to create renderer:", m);
504
+ return;
505
+ }
506
+ if (!K()) {
507
+ b.remove(), b = void 0;
508
+ return;
509
+ }
510
+ const E = w.current;
511
+ c = document.createElement("div"), c.style.width = "100%", c.style.height = "100%", Je(c, F, Z), d.childElementCount > 0 && (d.style.position = "relative", c.style.position = "absolute", c.style.inset = "0", c.style.visibility = "hidden"), d.appendChild(c);
512
+ const u = c;
513
+ A = new MutationObserver(() => {
514
+ S && clearTimeout(S), S = setTimeout(() => {
515
+ G(u), k.current && A?.disconnect();
516
+ }, 100);
517
+ }), A.observe(c, {
518
+ childList: !0,
519
+ subtree: !0,
520
+ attributes: !0
521
+ });
522
+ const fe = b;
523
+ let re = !1;
524
+ const ae = () => {
525
+ if (!(re || !K())) {
526
+ re = !0, C && (clearTimeout(C), C = null), E?.viz.remove();
527
+ for (const m of Array.from(d.children))
528
+ m !== u && d.removeChild(m);
529
+ u.style.position = "", u.style.inset = "", u.style.visibility = "", d.style.position = "", w.current = { viz: fe, node: u }, G(u);
530
+ }
531
+ };
532
+ try {
533
+ b.setResult(Ve(g));
534
+ try {
535
+ const x = b.getMetadata(), T = x?.getRootField();
536
+ y = T?.renderAs(), R = T ? x?.getPluginsForField(T.key)?.[0]?.sizingStrategy : void 0;
537
+ } catch {
538
+ y = void 0, R = void 0;
539
+ }
540
+ r?.(Y(y, R), y), c.dataset.malloyRenderAs = y ?? "unknown", c.dataset.malloySizing = Y(y, R);
541
+ const m = Ge(y, g);
542
+ c.style.minWidth = m === void 0 ? "" : `${m}px`, d.style.overflowX = m === void 0 ? "" : "auto", d.style.overflowY = m === void 0 ? "" : "hidden", b.render(c);
543
+ const oe = i.current;
544
+ try {
545
+ if (oe) {
546
+ const x = Me(b, oe.canDrill), T = () => {
547
+ try {
548
+ Ie(u, x);
549
+ } catch (s) {
550
+ console.warn("Drill affordance skipped:", s);
551
+ }
552
+ };
553
+ T();
554
+ const ne = (s) => {
555
+ const _ = s.querySelector(".cell-content") ?? s, U = _.getBoundingClientRect();
556
+ _.dispatchEvent(
557
+ new MouseEvent("click", {
558
+ bubbles: !0,
559
+ cancelable: !0,
560
+ view: _.ownerDocument.defaultView,
561
+ clientX: Math.round(U.left + U.width / 2),
562
+ clientY: Math.round(U.bottom)
563
+ })
564
+ );
565
+ }, le = (s) => s.target?.closest?.(`.${v}`) ?? null, ye = (s, f) => {
566
+ de(s, f)?.focus();
567
+ };
568
+ N = (s) => {
569
+ const f = le(s);
570
+ if (!f) return;
571
+ const _ = s.key === "ArrowDown" ? 1 : s.key === "ArrowUp" ? -1 : s.key === "Home" ? "first" : s.key === "End" ? "last" : void 0;
572
+ if (_ !== void 0) {
573
+ s.preventDefault(), ye(f, _);
574
+ return;
575
+ }
576
+ s.key === "Enter" ? (s.preventDefault(), ne(f)) : s.key === " " && s.preventDefault();
577
+ }, P = (s) => {
578
+ if (s.key !== " ") return;
579
+ const f = le(s);
580
+ f && (s.preventDefault(), ne(f));
581
+ }, j = (s) => {
582
+ const f = s.target?.closest?.(`.${v}`);
583
+ f && de(f, 0);
584
+ }, u.addEventListener("keydown", N), u.addEventListener("keyup", P), u.addEventListener("focusin", j), x.size > 0 && typeof MutationObserver < "u" && (B = new MutationObserver(() => {
585
+ cancelAnimationFrame(W), W = requestAnimationFrame(T);
586
+ }), B.observe(u, {
587
+ childList: !0,
588
+ subtree: !0
589
+ }));
590
+ }
591
+ } catch (x) {
592
+ console.warn("Drill affordance skipped:", x);
593
+ }
594
+ b.onReady(ae), C = setTimeout(ae, 1e4);
595
+ } catch (m) {
596
+ console.error("Error rendering visualization:", m), A?.disconnect(), D?.disconnect(), B?.disconnect(), b.remove(), b = void 0, u.parentNode === d && d.removeChild(u);
597
+ }
598
+ })(), () => {
599
+ X = !0, A?.disconnect(), D?.disconnect(), S && clearTimeout(S), C && clearTimeout(C), c && w.current?.node !== c && (N && c.removeEventListener("keydown", N), P && c.removeEventListener("keyup", P), j && c.removeEventListener("focusin", j), B?.disconnect(), cancelAnimationFrame(W), b?.remove(), c.parentNode === d && d.removeChild(c), d.style.position = "");
600
+ };
601
+ }, [
602
+ e,
603
+ h,
604
+ p,
605
+ l,
606
+ r,
607
+ $,
608
+ V,
609
+ Q,
610
+ Z
611
+ ]), /* @__PURE__ */ M(
612
+ "div",
613
+ {
614
+ ref: n,
615
+ ...o ? { [I]: "" } : {},
616
+ style: {
617
+ width: "100%",
618
+ height: t ? `${t}px` : "400px"
619
+ }
620
+ }
621
+ );
622
+ }
623
+ function tt(e) {
624
+ return typeof window > "u" ? /* @__PURE__ */ M(
625
+ ie,
626
+ {
627
+ sx: {
628
+ width: "100%",
629
+ height: e.height ? `${e.height}px` : "100%",
630
+ display: "flex",
631
+ alignItems: "center",
632
+ justifyContent: "center",
633
+ color: "text.secondary"
634
+ },
635
+ children: "Loading..."
636
+ }
637
+ ) : /* @__PURE__ */ M(
638
+ pe,
639
+ {
640
+ fallback: /* @__PURE__ */ M(
641
+ ie,
642
+ {
643
+ sx: {
644
+ width: "100%",
645
+ height: e.height ? `${e.height}px` : "100%",
646
+ display: "flex",
647
+ alignItems: "center",
648
+ justifyContent: "center",
649
+ color: "text.secondary"
650
+ },
651
+ children: "Loading visualization..."
652
+ }
653
+ ),
654
+ children: /* @__PURE__ */ M(et, { ...e })
655
+ }
656
+ );
657
+ }
658
+ const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
659
+ __proto__: null,
660
+ default: tt
661
+ }, Symbol.toStringTag, { value: "Module" }));
662
+ export {
663
+ v as D,
664
+ tt as R,
665
+ Be as a,
666
+ $e as b,
667
+ it as c,
668
+ Me as d,
669
+ Ie as m,
670
+ Ne as r
671
+ };