@malloy-publisher/sdk 0.9.14 → 0.9.16

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