@malloy-publisher/sdk 0.9.13 → 0.9.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/RenderedResult-BClN_PG6.cjs.js +154 -0
  2. package/dist/{RenderedResult-DnBtf-cI.es.js → RenderedResult-YBzVMVH2.es.js} +295 -234
  3. package/dist/{ServerProvider-BV7IoDMR.es.js → ServerProvider-D7neZcTk.es.js} +283 -265
  4. package/dist/ServerProvider-e2369oom.cjs.js +1 -0
  5. package/dist/builder/index.cjs.js +80 -79
  6. package/dist/builder/index.es.js +7430 -6548
  7. package/dist/client/api.d.ts +30 -6
  8. package/dist/client/index.cjs.js +1 -1
  9. package/dist/client/index.es.js +1 -1
  10. package/dist/components/Dashboard/DashboardGrid.d.ts +49 -1
  11. package/dist/components/Dashboard/DashboardTile.d.ts +5 -2
  12. package/dist/components/Dashboard/DashboardView.d.ts +9 -2
  13. package/dist/components/Dashboard/index.d.ts +1 -1
  14. package/dist/components/Dashboard/promoteMeasureRow.d.ts +5 -7
  15. package/dist/components/Dashboard/useStuck.d.ts +18 -12
  16. package/dist/components/RenderedResult/RenderedResult.d.ts +3 -2
  17. package/dist/components/RenderedResult/ResultContainer.d.ts +11 -1
  18. package/dist/components/RenderedResult/ResultPanel.d.ts +5 -1
  19. package/dist/components/RenderedResult/chartPresentation.d.ts +15 -0
  20. package/dist/components/RenderedResult/chartShapeProblem.d.ts +55 -0
  21. package/dist/components/RenderedResult/resultSizing.d.ts +42 -6
  22. package/dist/components/Report/Report.d.ts +7 -1
  23. package/dist/components/Report/ReportPage.d.ts +7 -0
  24. package/dist/components/Report/layoutRules.d.ts +45 -0
  25. package/dist/components/ReportBuilder/AddTileDialog.d.ts +2 -1
  26. package/dist/components/ReportBuilder/BuilderGrid.d.ts +14 -1
  27. package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
  28. package/dist/components/ReportBuilder/EditorSurface.d.ts +17 -1
  29. package/dist/components/ReportBuilder/ReportEditor.d.ts +18 -0
  30. package/dist/components/ReportBuilder/TileFrame.d.ts +33 -1
  31. package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
  32. package/dist/components/ReportBuilder/catalog.d.ts +23 -0
  33. package/dist/components/ReportBuilder/chartLine.d.ts +38 -5
  34. package/dist/components/ReportBuilder/controls.d.ts +2 -2
  35. package/dist/components/ReportBuilder/document.d.ts +53 -5
  36. package/dist/components/ReportBuilder/imports.d.ts +7 -0
  37. package/dist/components/ReportBuilder/placement.d.ts +75 -0
  38. package/dist/components/ReportBuilder/preview.d.ts +59 -10
  39. package/dist/components/ReportBuilder/sortable.d.ts +3 -1
  40. package/dist/components/ReportBuilder/useTileHeight.d.ts +39 -0
  41. package/dist/components/ReportBuilder/useTileReorder.d.ts +27 -3
  42. package/dist/components/ReportBuilder/useTileResize.d.ts +8 -0
  43. package/dist/index.cjs.js +7 -7
  44. package/dist/index.es.js +3328 -3287
  45. package/dist/text/index.es.js +1 -1
  46. package/dist/{text-entry-72YFLeNk.es.js → text-entry-YKJZbRPo.es.js} +2 -2
  47. package/dist/theme/resolveTheme.d.ts +15 -0
  48. package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-BGk38oaW.es.js} +5097 -4805
  49. package/dist/useCompiledDocument-D9t5ry_t.cjs.js +142 -0
  50. package/dist/utils/blankQuoted.d.ts +15 -0
  51. package/package.json +1 -1
  52. package/src/components/Dashboard/DashboardGrid.tsx +127 -10
  53. package/src/components/Dashboard/DashboardTile.tsx +11 -1
  54. package/src/components/Dashboard/DashboardView.tsx +63 -10
  55. package/src/components/Dashboard/TileCard.tsx +6 -0
  56. package/src/components/Dashboard/index.ts +1 -0
  57. package/src/components/Dashboard/promoteMeasureRow.spec.ts +19 -0
  58. package/src/components/Dashboard/promoteMeasureRow.ts +15 -36
  59. package/src/components/Dashboard/tileHeight.spec.ts +72 -0
  60. package/src/components/Dashboard/useStuck.ts +76 -28
  61. package/src/components/Package/NewDocumentDialog.spec.tsx +20 -16
  62. package/src/components/Package/NewDocumentDialog.tsx +10 -11
  63. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +167 -2
  64. package/src/components/RenderedResult/RenderedResult.tsx +21 -6
  65. package/src/components/RenderedResult/ResultContainer.tsx +60 -7
  66. package/src/components/RenderedResult/ResultPanel.tsx +21 -1
  67. package/src/components/RenderedResult/chartPresentation.spec.ts +153 -0
  68. package/src/components/RenderedResult/chartPresentation.ts +166 -0
  69. package/src/components/RenderedResult/chartShapeProblem.spec.tsx +245 -0
  70. package/src/components/RenderedResult/chartShapeProblem.ts +219 -0
  71. package/src/components/RenderedResult/resultSizing.spec.ts +75 -3
  72. package/src/components/RenderedResult/resultSizing.ts +65 -11
  73. package/src/components/Report/Report.spec.tsx +19 -0
  74. package/src/components/Report/Report.tsx +8 -1
  75. package/src/components/Report/ReportPage.tsx +13 -1
  76. package/src/components/Report/layoutRules.spec.ts +43 -3
  77. package/src/components/Report/layoutRules.ts +70 -0
  78. package/src/components/Report/tileOverflow.spec.tsx +162 -0
  79. package/src/components/ReportBuilder/AddTileDialog.spec.tsx +2 -2
  80. package/src/components/ReportBuilder/AddTileDialog.tsx +11 -6
  81. package/src/components/ReportBuilder/BuilderBar.tsx +1 -1
  82. package/src/components/ReportBuilder/BuilderDialogs.tsx +20 -0
  83. package/src/components/ReportBuilder/BuilderGrid.tsx +126 -20
  84. package/src/components/ReportBuilder/ChartPicker.spec.ts +91 -4
  85. package/src/components/ReportBuilder/ChartPicker.tsx +45 -10
  86. package/src/components/ReportBuilder/DrillDialog.tsx +8 -2
  87. package/src/components/ReportBuilder/EditorSurface.tsx +110 -28
  88. package/src/components/ReportBuilder/FilterDialog.tsx +17 -8
  89. package/src/components/ReportBuilder/FilterStrip.tsx +2 -1
  90. package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +193 -2
  91. package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
  92. package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +2 -2
  93. package/src/components/ReportBuilder/ReportBuilder.spec.tsx +143 -2
  94. package/src/components/ReportBuilder/ReportBuilder.tsx +73 -19
  95. package/src/components/ReportBuilder/ReportEditor.fileModel.spec.tsx +178 -0
  96. package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +3 -5
  97. package/src/components/ReportBuilder/ReportEditor.queryVersion.spec.tsx +292 -0
  98. package/src/components/ReportBuilder/ReportEditor.readOnlyTitle.spec.tsx +92 -0
  99. package/src/components/ReportBuilder/ReportEditor.tsx +35 -0
  100. package/src/components/ReportBuilder/TileFrame.tsx +251 -6
  101. package/src/components/ReportBuilder/TileMenu.tsx +259 -20
  102. package/src/components/ReportBuilder/ViewPicker.tsx +4 -3
  103. package/src/components/ReportBuilder/addTileToDocument.spec.ts +34 -0
  104. package/src/components/ReportBuilder/addTileToDocument.ts +26 -1
  105. package/src/components/ReportBuilder/catalog.aggregate.spec.ts +137 -1
  106. package/src/components/ReportBuilder/catalog.ts +90 -37
  107. package/src/components/ReportBuilder/chartLine.spec.ts +42 -5
  108. package/src/components/ReportBuilder/chartLine.ts +80 -2
  109. package/src/components/ReportBuilder/controls.ts +4 -3
  110. package/src/components/ReportBuilder/document.ts +65 -7
  111. package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
  112. package/src/components/ReportBuilder/entryLayout.spec.ts +151 -0
  113. package/src/components/ReportBuilder/imports.ts +1 -1
  114. package/src/components/ReportBuilder/invariants.spec.ts +18 -10
  115. package/src/components/ReportBuilder/layout.ts +3 -0
  116. package/src/components/ReportBuilder/placement.spec.ts +193 -0
  117. package/src/components/ReportBuilder/placement.ts +250 -0
  118. package/src/components/ReportBuilder/preview.shapes.spec.ts +46 -6
  119. package/src/components/ReportBuilder/preview.spec.ts +151 -11
  120. package/src/components/ReportBuilder/preview.ts +203 -40
  121. package/src/components/ReportBuilder/preview.unsaved.compile.spec.ts +190 -0
  122. package/src/components/ReportBuilder/readDocument.spec.ts +46 -2
  123. package/src/components/ReportBuilder/readDocument.ts +194 -23
  124. package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
  125. package/src/components/ReportBuilder/sortable.tsx +4 -0
  126. package/src/components/ReportBuilder/spliceDocument.chart.spec.ts +1 -1
  127. package/src/components/ReportBuilder/spliceDocument.color.spec.ts +80 -0
  128. package/src/components/ReportBuilder/spliceDocument.colspan.spec.ts +78 -0
  129. package/src/components/ReportBuilder/spliceDocument.spec.ts +110 -18
  130. package/src/components/ReportBuilder/spliceDocument.ts +139 -52
  131. package/src/components/ReportBuilder/statementExtent.spec.ts +3 -3
  132. package/src/components/ReportBuilder/testing/reportGivenOrder.json +42 -0
  133. package/src/components/ReportBuilder/textTiles.spec.ts +2 -2
  134. package/src/components/ReportBuilder/tileDisplayTitle.ts +2 -2
  135. package/src/components/ReportBuilder/useTileEditing.ts +16 -3
  136. package/src/components/ReportBuilder/useTileHeight.ts +149 -0
  137. package/src/components/ReportBuilder/useTileReorder.ts +143 -6
  138. package/src/components/ReportBuilder/useTileResize.ts +16 -1
  139. package/src/components/given/FilterButton.spec.tsx +27 -11
  140. package/src/components/given/FilterButton.tsx +19 -6
  141. package/src/theme/resolveTheme.spec.ts +72 -1
  142. package/src/theme/resolveTheme.ts +43 -0
  143. package/src/utils/blankQuoted.spec.ts +50 -0
  144. package/src/utils/blankQuoted.ts +32 -0
  145. package/src/utils/malloyText.ts +2 -1
  146. package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
  147. package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
  148. package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
@@ -1,88 +1,88 @@
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();
1
+ import { jsx as z } from "react/jsx-runtime";
2
+ import { Box as le } from "@mui/material";
3
+ import { Suspense as ye, useRef as M, useCallback as pe, useMemo as ge, useEffect as ve, useLayoutEffect as we } from "react";
4
+ import { r as ke, a as ue, D as xe, b as G, l as Ce, c as Re, d as Ee, e as _e, m as Ae, f as Se, g as ie } from "./useCompiledDocument-BGk38oaW.es.js";
5
+ import { ba as Te, b8 as De, bb as Oe, bc as Fe } from "./ServerProvider-D7neZcTk.es.js";
6
+ const v = ke.drillCell;
7
+ function Me(e, t) {
8
+ const o = /* @__PURE__ */ new Set();
9
9
  let l;
10
10
  try {
11
11
  l = e.getMetadata()?.getAllFields() ?? [];
12
12
  } catch {
13
- return t;
13
+ return o;
14
14
  }
15
- const o = /* @__PURE__ */ new Set();
15
+ const r = /* @__PURE__ */ new Set();
16
16
  for (const a of l)
17
- !a || r(a) || a.tag?.tag("hidden") === void 0 && o.add(a.tag?.text("label") ?? a.name);
17
+ !a || t(a) || a.tag?.tag("hidden") === void 0 && r.add(a.tag?.text("label") ?? a.name);
18
18
  for (const a of l) {
19
- if (!a || !r(a)) continue;
19
+ if (!a || !t(a)) continue;
20
20
  const n = a.tag?.text("label") ?? a.name;
21
- o.has(n) || t.add(n);
21
+ r.has(n) || o.add(n);
22
22
  }
23
- return t;
23
+ return o;
24
24
  }
25
- function I(e) {
26
- const r = /^\s*(\d+)/.exec(e.style?.gridColumn ?? "");
27
- return r ? r[1] : void 0;
25
+ function L(e) {
26
+ const t = /^\s*(\d+)/.exec(e.style?.gridColumn ?? "");
27
+ return t ? t[1] : void 0;
28
28
  }
29
- function Te(e, r) {
30
- if (r.size !== 0)
31
- for (const t of e.querySelectorAll(
29
+ function ze(e, t) {
30
+ if (t.size !== 0)
31
+ for (const o of e.querySelectorAll(
32
32
  ".malloy-table"
33
33
  )) {
34
- const l = (n) => n.closest(".malloy-table") === t, o = /* @__PURE__ */ new Set();
35
- for (const n of t.querySelectorAll(
34
+ const l = (n) => n.closest(".malloy-table") === o, r = /* @__PURE__ */ new Set();
35
+ for (const n of o.querySelectorAll(
36
36
  ".column-cell.th"
37
37
  )) {
38
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);
39
+ const i = (n.textContent ?? "").replace(/\u200b/g, "").trim(), h = L(n);
40
+ h && t.has(i) && r.add(h);
41
41
  }
42
- if (o.size === 0) continue;
42
+ if (r.size === 0) continue;
43
43
  const a = /* @__PURE__ */ new Set();
44
- for (const n of t.querySelectorAll(
45
- `.${g}[tabindex="0"]`
44
+ for (const n of o.querySelectorAll(
45
+ `.${v}[tabindex="0"]`
46
46
  )) {
47
47
  if (!l(n)) continue;
48
- const s = I(n);
49
- s && (a.has(s) ? n.tabIndex = -1 : a.add(s));
48
+ const i = L(n);
49
+ i && (a.has(i) ? n.tabIndex = -1 : a.add(i));
50
50
  }
51
- for (const n of t.querySelectorAll(
51
+ for (const n of o.querySelectorAll(
52
52
  ".column-cell.td"
53
53
  )) {
54
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);
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
+ a.add(i);
59
59
  else {
60
- const y = a.has(s);
61
- y || a.add(s), n.tabIndex = y ? -1 : 0;
60
+ const p = a.has(i);
61
+ p || a.add(i), n.tabIndex = p ? -1 : 0;
62
62
  }
63
63
  n.setAttribute("role", "button");
64
64
  }
65
65
  }
66
66
  }
67
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}`)
68
+ function Ie(e) {
69
+ const t = e.closest(".malloy-table"), o = L(e);
70
+ return !t || !o ? [] : Array.from(
71
+ t.querySelectorAll(`.${v}`)
72
72
  ).filter(
73
- (l) => l.closest(".malloy-table") === r && I(l) === t
73
+ (l) => l.closest(".malloy-table") === t && L(l) === o
74
74
  );
75
75
  }
76
- function le(e, r) {
77
- const t = De(e), l = t.indexOf(e);
76
+ function se(e, t) {
77
+ const o = Ie(e), l = o.indexOf(e);
78
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;
79
+ const r = t === "first" ? o[0] : t === "last" ? o[o.length - 1] : o[Math.min(Math.max(l + t, 0), o.length - 1)];
80
+ if (r) {
81
+ for (const a of o) a.tabIndex = a === r ? 0 : -1;
82
+ return r;
83
83
  }
84
84
  }
85
- function Oe(e) {
85
+ function Le(e) {
86
86
  return {
87
87
  background: e.dashboardRoot,
88
88
  tableBackground: e.tableBackground,
@@ -104,108 +104,167 @@ function Oe(e) {
104
104
  mapColor: e.mapColor
105
105
  };
106
106
  }
107
- function _e(e) {
108
- const { foreground: r, axisFaint: t, gridline: l, font: o } = e, a = {
107
+ function Be(e) {
108
+ const { foreground: t, axisFaint: o, gridline: l, font: r } = e, a = {
109
109
  background: e.background,
110
- font: o.family,
111
- title: { color: r, font: o.family },
110
+ font: r.family,
111
+ title: { color: t, font: r.family },
112
112
  axis: {
113
- labelColor: r,
114
- titleColor: r,
115
- domainColor: t,
116
- tickColor: t,
113
+ labelColor: t,
114
+ titleColor: t,
115
+ domainColor: o,
116
+ tickColor: o,
117
117
  gridColor: l,
118
- labelFont: o.family,
119
- titleFont: o.family
118
+ labelFont: r.family,
119
+ titleFont: r.family
120
120
  },
121
121
  legend: {
122
- labelColor: r,
123
- titleColor: r,
124
- labelFont: o.family,
125
- titleFont: o.family
122
+ labelColor: t,
123
+ titleColor: t,
124
+ labelFont: r.family,
125
+ titleFont: r.family
126
126
  },
127
- header: { labelColor: r, titleColor: r },
127
+ header: { labelColor: t, titleColor: t },
128
128
  range: { category: e.series }
129
129
  }, n = {
130
130
  ...a,
131
131
  legend: { ...a.legend, orient: "bottom" }
132
132
  };
133
- return (s) => s === "shape_map" ? n : a;
133
+ return (i) => i === "shape_map" ? n : a;
134
134
  }
135
- function ze(e) {
135
+ function Ne(e) {
136
136
  if (!e) return;
137
- const r = e.tag("theme");
138
- if (!r) return;
139
- const t = {}, l = r.tag("palette");
137
+ const t = e.tag("theme");
138
+ if (!t) return;
139
+ const o = {}, l = t.tag("palette");
140
140
  if (l) {
141
141
  const a = {}, n = l.textArray("series");
142
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);
143
+ for (const i of Te) {
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 && (a[i] = p);
148
148
  }
149
- Object.keys(a).length > 0 && (t.palette = a);
149
+ Object.keys(a).length > 0 && (o.palette = a);
150
150
  }
151
- const o = r.tag("font");
152
- if (o) {
153
- const a = {}, n = o.text("family");
151
+ const r = t.tag("font");
152
+ if (r) {
153
+ const a = {}, n = r.text("family");
154
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);
155
+ const i = r.numeric("size");
156
+ typeof i == "number" && Number.isFinite(i) && (a.size = i), Object.keys(a).length > 0 && (o.font = a);
157
157
  }
158
- return Object.keys(t).length > 0 ? t : void 0;
158
+ return Object.keys(o).length > 0 ? o : void 0;
159
159
  }
160
- const M = "data-publisher-fill", Fe = async (e, r) => {
160
+ const Y = (e) => (e ?? []).map((t) => t?.value).filter((t) => typeof t == "string");
161
+ function $e(e) {
162
+ const t = e.replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim();
163
+ return t.charAt(0).toUpperCase() + t.slice(1);
164
+ }
165
+ const Pe = (e) => Y(e.annotations).some((t) => {
166
+ const o = t.trim();
167
+ return /^#[^("]/.test(o) && /(?:^#|[\s{])label\s*=/.test(o);
168
+ }), je = (e) => `"${e.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`, He = (e) => e.type?.element_type?.fields ?? e.type?.fields;
169
+ function he(e, t) {
170
+ let o = !1;
171
+ return { fields: e.map((r) => {
172
+ const a = He(r);
173
+ if (a) {
174
+ const i = he(
175
+ a,
176
+ ue(Y(r.annotations))
177
+ );
178
+ if (!i.changed) return r;
179
+ o = !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 || Pe(r)) return r;
190
+ const n = $e(r.name);
191
+ return n === r.name ? r : (o = !0, {
192
+ ...r,
193
+ annotations: [
194
+ { value: `# label=${je(n)}
195
+ ` },
196
+ ...r.annotations ?? []
197
+ ]
198
+ });
199
+ }), changed: o };
200
+ }
201
+ function qe(e) {
202
+ if (!e || typeof e != "object") return e;
203
+ const t = e, o = t.schema?.fields;
204
+ if (!Array.isArray(o)) return e;
205
+ const { fields: l, changed: r } = he(
206
+ o,
207
+ ue(Y(t.annotations))
208
+ );
209
+ return r ? { ...t, schema: { ...t.schema, fields: l } } : e;
210
+ }
211
+ const de = 320, Ve = 10, Xe = 96, Ke = 4e3;
212
+ function We(e, t) {
213
+ if (e !== "bar" && e !== "combo" && e !== "line" && e !== "chart" && e !== "scatter_chart")
214
+ return;
215
+ if (e !== "bar" && e !== "combo") return de;
216
+ const o = t?.data?.array_value?.length, l = o === void 0 ? 0 : o * Ve + Xe;
217
+ return Math.min(Math.max(de, l), Ke);
218
+ }
219
+ const I = "data-publisher-fill", Ue = async (e, t) => {
161
220
  if (typeof window > "u")
162
221
  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),
222
+ const { MalloyRenderer: o } = await Re();
223
+ return new o({
224
+ onClick: t,
225
+ vegaConfigOverride: Be(e),
167
226
  // Pass the explicit theme so table chrome and dashboard tiles
168
227
  // pick up the operator's colours directly. Without this the
169
228
  // renderer's own inline style writes `--malloy-render--*` values
170
229
  // sourced from its built-in defaults and shadows whatever we set
171
230
  // on the outer wrapper.
172
- theme: Oe(e),
173
- onError: (o) => {
174
- console.error("Error rendering visualization:", typeof o, o);
231
+ theme: Le(e),
232
+ onError: (r) => {
233
+ console.error("Error rendering visualization:", typeof r, r);
175
234
  }
176
235
  }).createViz();
177
236
  };
178
- async function Le(e) {
237
+ async function Ge(e) {
179
238
  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;
239
+ const t = e, o = [
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 (o.length === 0) return;
186
245
  let l;
187
246
  try {
188
- ({ parseAnnotation: l } = await ge());
247
+ ({ parseAnnotation: l } = await Ce());
189
248
  } catch {
190
249
  return;
191
250
  }
192
251
  try {
193
- const { tag: o } = l(t);
194
- return ze(o);
195
- } catch (o) {
252
+ const { tag: r } = l(o);
253
+ return Ne(r);
254
+ } catch (r) {
196
255
  console.warn(
197
256
  "Failed to parse # theme.* annotations; chart will render with the shell theme.",
198
- { error: o, lines: t }
257
+ { error: r, lines: o }
199
258
  );
200
259
  return;
201
260
  }
202
261
  }
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);
262
+ function Ye(e, t, o) {
263
+ const l = Ee(t, o);
264
+ for (const [r, a] of Object.entries(l))
265
+ e.style.setProperty(r, a);
207
266
  }
208
- const Ie = `
267
+ const Je = `
209
268
  /* Card geometry, through the renderer's OWN theme vars rather than over the top
210
269
  of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
211
270
  passes each through to the --malloy-render--* the card CSS reads, so a value
@@ -303,7 +362,7 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
303
362
  background: var(--malloy-render--table-border) !important;
304
363
  }
305
364
  /* !important because the malloy-explorer stylesheet pins these same properties with it. */
306
- [${M}] .malloy-table.root {
365
+ [${I}] .malloy-table.root {
307
366
  height: 100% !important;
308
367
  align-content: start !important;
309
368
  grid-template-columns: repeat(var(--total-header-size), minmax(max-content, 1fr)) !important;
@@ -338,10 +397,10 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
338
397
  and the only thing that tells a reader a cell navigates. Kept off the
339
398
  resting state deliberately: a column painted blue competes with the data.
340
399
  (No backticks in here: this is inside a template literal.) */
341
- .malloy-render .${g} {
400
+ .malloy-render .${v} {
342
401
  cursor: pointer;
343
402
  }
344
- .malloy-render .${g}:hover > .cell-content {
403
+ .malloy-render .${v}:hover > .cell-content {
345
404
  color: var(--publisher-drill-link) !important;
346
405
  text-decoration: underline;
347
406
  }
@@ -349,132 +408,134 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
349
408
  something a keyboard user can produce, and a focus ring is not something a
350
409
  mouse user sees. focus-visible rather than focus, so a click does not leave a
351
410
  ring behind it. (No backticks in here: this is inside a template literal.) */
352
- .malloy-render .${g}:focus-visible {
411
+ .malloy-render .${v}:focus-visible {
353
412
  outline: 2px solid var(--publisher-drill-link);
354
413
  outline-offset: -2px;
355
414
  }
356
- .malloy-render .${g}:focus-visible > .cell-content {
415
+ .malloy-render .${v}:focus-visible > .cell-content {
357
416
  color: var(--publisher-drill-link) !important;
358
417
  text-decoration: underline;
359
418
  }
360
- `, ie = "publisher-malloy-renderer-overrides";
361
- function Be() {
362
- if (typeof document > "u" || document.getElementById(ie)) return;
419
+ `, ce = "publisher-malloy-renderer-overrides";
420
+ function Qe() {
421
+ if (typeof document > "u" || document.getElementById(ce)) return;
363
422
  const e = document.createElement("style");
364
- e.id = ie, e.textContent = Ie, document.head.appendChild(e);
423
+ e.id = ce, e.textContent = Je, document.head.appendChild(e);
365
424
  }
366
- function Ne({
425
+ function Ze({
367
426
  result: e,
368
- height: r,
369
- drill: t,
427
+ height: t,
428
+ drill: o,
370
429
  onSizeChange: l,
371
- onSizing: o,
430
+ onSizing: r,
372
431
  fill: a
373
432
  }) {
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(
433
+ const n = M(null), i = M(o);
434
+ i.current = o;
435
+ const h = pe((d) => {
436
+ i.current?.onClick(d);
437
+ }, []), p = o !== void 0, k = M(!1), w = M(
379
438
  null
380
- ), V = F(0), { theme: B, layers: Y, mode: J } = Ee(), W = me(
439
+ ), H = M(0), { theme: B, layers: q, mode: J } = De(), Q = ge(
381
440
  () => ({
382
441
  radius: B.ui.radius.tile,
383
- padding: `${pe}px`
442
+ padding: `${xe}px`
384
443
  }),
385
444
  [B.ui.radius.tile]
386
445
  );
387
- return be(() => () => {
388
- V.current += 1;
389
- const c = v.current;
390
- c?.viz.remove(), c?.node.remove(), v.current = null;
391
- }, []), fe(() => {
446
+ return ve(() => () => {
447
+ H.current += 1;
448
+ const d = w.current;
449
+ d?.viz.remove(), d?.node.remove(), w.current = null;
450
+ }, []), we(() => {
392
451
  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;
452
+ Qe();
453
+ const d = n.current, me = H.current += 1;
454
+ let V = !1;
455
+ const X = () => !V && me === H.current;
456
+ let c, b, N = null, K = 0, $ = null, P = null, j = null, S = null, T = null, D = null, Z = null, ee = 0, C = null;
398
457
  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)
458
+ let y, R;
459
+ const W = (g) => {
460
+ if (V || !g.firstElementChild || G(y, R) === "container") return;
461
+ const O = _e(y, R);
462
+ if (k.current && !O) return;
463
+ const F = d.hasAttribute(I);
464
+ F && d.removeAttribute(I);
465
+ const E = Ae(
466
+ g,
467
+ ie(y)
409
468
  );
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));
469
+ F && d.setAttribute(I, ""), E > 0 && (k.current = !0, l && E !== ee && (ee = E, l(E)));
470
+ const u = Se(g, ie(y));
471
+ O && u && Z !== u && (Z = u, D?.disconnect(), D = new ResizeObserver(() => W(g)), D.observe(u));
413
472
  };
414
473
  return (async () => {
415
- let w;
474
+ let g;
416
475
  try {
417
- w = JSON.parse(e);
418
- } catch (f) {
419
- console.error("Error parsing visualization result:", f);
476
+ g = JSON.parse(e);
477
+ } catch (m) {
478
+ console.error("Error parsing visualization result:", m);
420
479
  return;
421
480
  }
422
- const _ = await Le(w), z = _ ? Se([...Y, _], J) : B;
423
- if (!H()) return;
481
+ const O = await Ge(g), F = O ? Oe([...q, Fe(q, O)], J) : B;
482
+ if (!X()) return;
424
483
  try {
425
- h = await Fe(z, b);
426
- } catch (f) {
427
- console.error("Failed to create renderer:", f);
484
+ b = await Ue(F, h);
485
+ } catch (m) {
486
+ console.error("Failed to create renderer:", m);
428
487
  return;
429
488
  }
430
- if (!H()) {
431
- h.remove(), h = void 0;
489
+ if (!X()) {
490
+ b.remove(), b = void 0;
432
491
  return;
433
492
  }
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();
493
+ const E = w.current;
494
+ c = document.createElement("div"), c.style.width = "100%", c.style.height = "100%", Ye(c, F, Q), d.childElementCount > 0 && (d.style.position = "relative", c.style.position = "absolute", c.style.inset = "0", c.style.visibility = "hidden"), d.appendChild(c);
495
+ const u = c;
496
+ S = new MutationObserver(() => {
497
+ T && clearTimeout(T), T = setTimeout(() => {
498
+ W(u), k.current && S?.disconnect();
440
499
  }, 100);
441
- }), T.observe(d, {
500
+ }), S.observe(c, {
442
501
  childList: !0,
443
502
  subtree: !0,
444
503
  attributes: !0
445
504
  });
446
- const de = h;
447
- let ee = !1;
505
+ const be = b;
506
+ let te = !1;
448
507
  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);
508
+ if (!(te || !X())) {
509
+ te = !0, C && (clearTimeout(C), C = null), E?.viz.remove();
510
+ for (const m of Array.from(d.children))
511
+ m !== u && d.removeChild(m);
512
+ u.style.position = "", u.style.inset = "", u.style.visibility = "", d.style.position = "", w.current = { viz: be, node: u }, W(u);
454
513
  }
455
514
  };
456
515
  try {
457
- h.setResult(w);
516
+ b.setResult(qe(g));
458
517
  try {
459
- const x = h.getMetadata(), S = x?.getRootField();
460
- p = S?.renderAs(), R = S ? x?.getPluginsForField(S.key)?.[0]?.sizingStrategy : void 0;
518
+ const x = b.getMetadata(), _ = x?.getRootField();
519
+ y = _?.renderAs(), R = _ ? x?.getPluginsForField(_.key)?.[0]?.sizingStrategy : void 0;
461
520
  } catch {
462
- p = void 0, R = void 0;
521
+ y = void 0, R = void 0;
463
522
  }
464
- o?.(X(p, R)), d.dataset.malloyRenderAs = p ?? "unknown", d.dataset.malloySizing = X(p, R), h.render(d);
465
- const f = s.current;
523
+ r?.(G(y, R), y), c.dataset.malloyRenderAs = y ?? "unknown", c.dataset.malloySizing = G(y, R);
524
+ const m = We(y, g);
525
+ 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);
526
+ const oe = i.current;
466
527
  try {
467
- if (f) {
468
- const x = Ae(h, f.canDrill), S = () => {
528
+ if (oe) {
529
+ const x = Me(b, oe.canDrill), _ = () => {
469
530
  try {
470
- Te(u, x);
471
- } catch (i) {
472
- console.warn("Drill affordance skipped:", i);
531
+ ze(u, x);
532
+ } catch (s) {
533
+ console.warn("Drill affordance skipped:", s);
473
534
  }
474
535
  };
475
- S();
476
- const te = (i) => {
477
- const A = i.querySelector(".cell-content") ?? i, U = A.getBoundingClientRect();
536
+ _();
537
+ const ae = (s) => {
538
+ const A = s.querySelector(".cell-content") ?? s, U = A.getBoundingClientRect();
478
539
  A.dispatchEvent(
479
540
  new MouseEvent("click", {
480
541
  bubbles: !0,
@@ -484,27 +545,27 @@ function Ne({
484
545
  clientY: Math.round(U.bottom)
485
546
  })
486
547
  );
487
- }, oe = (i) => i.target?.closest?.(`.${g}`) ?? null, ce = (i, m) => {
488
- le(i, m)?.focus();
548
+ }, ne = (s) => s.target?.closest?.(`.${v}`) ?? null, fe = (s, f) => {
549
+ se(s, f)?.focus();
489
550
  };
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;
551
+ $ = (s) => {
552
+ const f = ne(s);
553
+ if (!f) return;
554
+ const A = s.key === "ArrowDown" ? 1 : s.key === "ArrowUp" ? -1 : s.key === "Home" ? "first" : s.key === "End" ? "last" : void 0;
494
555
  if (A !== void 0) {
495
- i.preventDefault(), ce(m, A);
556
+ s.preventDefault(), fe(f, A);
496
557
  return;
497
558
  }
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);
559
+ s.key === "Enter" ? (s.preventDefault(), ae(f)) : s.key === " " && s.preventDefault();
560
+ }, P = (s) => {
561
+ if (s.key !== " ") return;
562
+ const f = ne(s);
563
+ f && (s.preventDefault(), ae(f));
564
+ }, j = (s) => {
565
+ const f = s.target?.closest?.(`.${v}`);
566
+ f && se(f, 0);
567
+ }, u.addEventListener("keydown", $), u.addEventListener("keyup", P), u.addEventListener("focusin", j), x.size > 0 && typeof MutationObserver < "u" && (N = new MutationObserver(() => {
568
+ cancelAnimationFrame(K), K = requestAnimationFrame(_);
508
569
  }), N.observe(u, {
509
570
  childList: !0,
510
571
  subtree: !0
@@ -513,38 +574,38 @@ function Ne({
513
574
  } catch (x) {
514
575
  console.warn("Drill affordance skipped:", x);
515
576
  }
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);
577
+ b.onReady(re), C = setTimeout(re, 1e4);
578
+ } catch (m) {
579
+ console.error("Error rendering visualization:", m), S?.disconnect(), D?.disconnect(), N?.disconnect(), b.remove(), b = void 0, u.parentNode === d && d.removeChild(u);
519
580
  }
520
581
  })(), () => {
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 = "");
582
+ V = !0, S?.disconnect(), D?.disconnect(), T && clearTimeout(T), C && clearTimeout(C), c && w.current?.node !== c && ($ && c.removeEventListener("keydown", $), P && c.removeEventListener("keyup", P), j && c.removeEventListener("focusin", j), N?.disconnect(), cancelAnimationFrame(K), b?.remove(), c.parentNode === d && d.removeChild(c), d.style.position = "");
522
583
  };
523
584
  }, [
524
585
  e,
525
- b,
526
- y,
586
+ h,
587
+ p,
527
588
  l,
528
- o,
589
+ r,
529
590
  B,
530
- Y,
591
+ q,
531
592
  J,
532
- W
533
- ]), /* @__PURE__ */ L(
593
+ Q
594
+ ]), /* @__PURE__ */ z(
534
595
  "div",
535
596
  {
536
597
  ref: n,
537
- ...a ? { [M]: "" } : {},
598
+ ...a ? { [I]: "" } : {},
538
599
  style: {
539
600
  width: "100%",
540
- height: r ? `${r}px` : "400px"
601
+ height: t ? `${t}px` : "400px"
541
602
  }
542
603
  }
543
604
  );
544
605
  }
545
- function $e(e) {
546
- return typeof window > "u" ? /* @__PURE__ */ L(
547
- ae,
606
+ function et(e) {
607
+ return typeof window > "u" ? /* @__PURE__ */ z(
608
+ le,
548
609
  {
549
610
  sx: {
550
611
  width: "100%",
@@ -556,11 +617,11 @@ function $e(e) {
556
617
  },
557
618
  children: "Loading..."
558
619
  }
559
- ) : /* @__PURE__ */ L(
560
- ue,
620
+ ) : /* @__PURE__ */ z(
621
+ ye,
561
622
  {
562
- fallback: /* @__PURE__ */ L(
563
- ae,
623
+ fallback: /* @__PURE__ */ z(
624
+ le,
564
625
  {
565
626
  sx: {
566
627
  width: "100%",
@@ -573,21 +634,21 @@ function $e(e) {
573
634
  children: "Loading visualization..."
574
635
  }
575
636
  ),
576
- children: /* @__PURE__ */ L(Ne, { ...e })
637
+ children: /* @__PURE__ */ z(Ze, { ...e })
577
638
  }
578
639
  );
579
640
  }
580
- const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
641
+ const lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
581
642
  __proto__: null,
582
- default: $e
643
+ default: et
583
644
  }, Symbol.toStringTag, { value: "Module" }));
584
645
  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
646
+ v as D,
647
+ et as R,
648
+ Be as a,
649
+ Le as b,
650
+ lt as c,
651
+ Me as d,
652
+ ze as m,
653
+ Ne as r
593
654
  };