@malloy-publisher/sdk 0.9.15 → 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.
- package/dist/{RenderedResult-BClN_PG6.cjs.js → RenderedResult-5hOs5XnV.cjs.js} +21 -4
- package/dist/{RenderedResult-YBzVMVH2.es.js → RenderedResult-DxmHGZNQ.es.js} +204 -187
- package/dist/builder/index.cjs.js +75 -75
- package/dist/builder/index.es.js +5329 -5193
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +1 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +2 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/resultSizing.d.ts +5 -0
- package/dist/components/ReportBuilder/ArrangeMenu.d.ts +9 -0
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +5 -7
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +3 -1
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +1 -1
- package/dist/components/ReportBuilder/TileFrame.d.ts +34 -22
- package/dist/components/ReportBuilder/builderControls.d.ts +19 -0
- package/dist/components/ReportBuilder/placement.d.ts +48 -2
- package/dist/components/ReportBuilder/sortable.d.ts +9 -0
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +1 -1
- package/dist/components/ReportBuilder/useBuilderShortcuts.d.ts +9 -1
- package/dist/components/ReportBuilder/useEdgeResize.d.ts +84 -0
- package/dist/components/ReportBuilder/useTileReorder.d.ts +3 -0
- package/dist/index.cjs.js +5 -5
- package/dist/index.es.js +489 -488
- package/dist/theme/classes.d.ts +1 -1
- package/dist/{useCompiledDocument-BGk38oaW.es.js → useCompiledDocument-CaYP_OYG.es.js} +4021 -4007
- package/dist/{useCompiledDocument-D9t5ry_t.cjs.js → useCompiledDocument-zYEfLogf.cjs.js} +32 -32
- package/package.json +1 -1
- package/src/builder-entry.ts +1 -0
- package/src/components/Dashboard/DashboardGrid.tsx +2 -0
- package/src/components/Dashboard/DashboardTile.tsx +4 -0
- package/src/components/Dashboard/DashboardView.tsx +1 -0
- package/src/components/RenderedResult/RenderedResult.tsx +18 -0
- package/src/components/RenderedResult/ResultContainer.tsx +39 -3
- package/src/components/RenderedResult/ResultPanel.tsx +4 -0
- package/src/components/RenderedResult/resultSizing.ts +6 -0
- package/src/components/ReportBuilder/ArrangeMenu.tsx +80 -0
- package/src/components/ReportBuilder/BuilderBar.tsx +4 -0
- package/src/components/ReportBuilder/BuilderDialogs.tsx +8 -1
- package/src/components/ReportBuilder/BuilderGrid.tsx +61 -60
- package/src/components/ReportBuilder/BuilderToolbar.tsx +4 -0
- package/src/components/ReportBuilder/EditorSurface.tsx +9 -2
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +99 -0
- package/src/components/ReportBuilder/ReportBuilder.tsx +110 -30
- package/src/components/ReportBuilder/TileFrame.tsx +261 -310
- package/src/components/ReportBuilder/builderControls.ts +34 -0
- package/src/components/ReportBuilder/placement.spec.ts +208 -0
- package/src/components/ReportBuilder/placement.ts +175 -9
- package/src/components/ReportBuilder/readDocument.spec.ts +7 -17
- package/src/components/ReportBuilder/readDocument.ts +3 -6
- package/src/components/ReportBuilder/sortable.tsx +26 -2
- package/src/components/ReportBuilder/spliceDocument.spec.ts +0 -40
- package/src/components/ReportBuilder/spliceDocument.ts +0 -39
- package/src/components/ReportBuilder/useBuilderSession.ts +7 -2
- package/src/components/ReportBuilder/useBuilderShortcuts.ts +25 -1
- package/src/components/ReportBuilder/useEdgeResize.spec.tsx +324 -0
- package/src/components/ReportBuilder/useEdgeResize.ts +397 -0
- package/src/components/ReportBuilder/useTileReorder.ts +1 -1
- package/src/theme/classes.ts +1 -1
- package/dist/components/ReportBuilder/useTileHeight.d.ts +0 -39
- package/dist/components/ReportBuilder/useTileResize.d.ts +0 -40
- package/src/components/ReportBuilder/useTileHeight.ts +0 -149
- package/src/components/ReportBuilder/useTileResize.spec.tsx +0 -146
- package/src/components/ReportBuilder/useTileResize.ts +0 -148
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { Suspense as
|
|
4
|
-
import { r as
|
|
5
|
-
import { ba as
|
|
6
|
-
const v =
|
|
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
7
|
function Me(e, t) {
|
|
8
|
-
const
|
|
8
|
+
const a = /* @__PURE__ */ new Set();
|
|
9
9
|
let l;
|
|
10
10
|
try {
|
|
11
11
|
l = e.getMetadata()?.getAllFields() ?? [];
|
|
12
12
|
} catch {
|
|
13
|
-
return
|
|
13
|
+
return a;
|
|
14
14
|
}
|
|
15
15
|
const r = /* @__PURE__ */ new Set();
|
|
16
|
-
for (const
|
|
17
|
-
!
|
|
18
|
-
for (const
|
|
19
|
-
if (!
|
|
20
|
-
const n =
|
|
21
|
-
r.has(n) ||
|
|
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
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return a;
|
|
24
24
|
}
|
|
25
25
|
function L(e) {
|
|
26
26
|
const t = /^\s*(\d+)/.exec(e.style?.gridColumn ?? "");
|
|
27
27
|
return t ? t[1] : void 0;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function Ie(e, t) {
|
|
30
30
|
if (t.size !== 0)
|
|
31
|
-
for (const
|
|
31
|
+
for (const a of e.querySelectorAll(
|
|
32
32
|
".malloy-table"
|
|
33
33
|
)) {
|
|
34
|
-
const l = (n) => n.closest(".malloy-table") ===
|
|
35
|
-
for (const n of
|
|
34
|
+
const l = (n) => n.closest(".malloy-table") === a, r = /* @__PURE__ */ new Set();
|
|
35
|
+
for (const n of a.querySelectorAll(
|
|
36
36
|
".column-cell.th"
|
|
37
37
|
)) {
|
|
38
38
|
if (!l(n)) continue;
|
|
@@ -40,49 +40,49 @@ function ze(e, t) {
|
|
|
40
40
|
h && t.has(i) && r.add(h);
|
|
41
41
|
}
|
|
42
42
|
if (r.size === 0) continue;
|
|
43
|
-
const
|
|
44
|
-
for (const n of
|
|
43
|
+
const o = /* @__PURE__ */ new Set();
|
|
44
|
+
for (const n of a.querySelectorAll(
|
|
45
45
|
`.${v}[tabindex="0"]`
|
|
46
46
|
)) {
|
|
47
47
|
if (!l(n)) continue;
|
|
48
48
|
const i = L(n);
|
|
49
|
-
i && (
|
|
49
|
+
i && (o.has(i) ? n.tabIndex = -1 : o.add(i));
|
|
50
50
|
}
|
|
51
|
-
for (const n of
|
|
51
|
+
for (const n of a.querySelectorAll(
|
|
52
52
|
".column-cell.td"
|
|
53
53
|
)) {
|
|
54
54
|
if (!l(n)) continue;
|
|
55
55
|
const i = L(n), h = !n.querySelector(".value-null") && (n.textContent ?? "").trim() !== "";
|
|
56
56
|
if (i && h && r.has(i) && !n.querySelector(".malloy-table")) {
|
|
57
57
|
if (n.classList.add(v), n.tabIndex === 0)
|
|
58
|
-
|
|
58
|
+
o.add(i);
|
|
59
59
|
else {
|
|
60
|
-
const p =
|
|
61
|
-
p ||
|
|
60
|
+
const p = o.has(i);
|
|
61
|
+
p || o.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
|
|
69
|
-
const t = e.closest(".malloy-table"),
|
|
70
|
-
return !t || !
|
|
68
|
+
function Le(e) {
|
|
69
|
+
const t = e.closest(".malloy-table"), a = L(e);
|
|
70
|
+
return !t || !a ? [] : Array.from(
|
|
71
71
|
t.querySelectorAll(`.${v}`)
|
|
72
72
|
).filter(
|
|
73
|
-
(l) => l.closest(".malloy-table") === t && L(l) ===
|
|
73
|
+
(l) => l.closest(".malloy-table") === t && L(l) === a
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
76
|
+
function de(e, t) {
|
|
77
|
+
const a = Le(e), l = a.indexOf(e);
|
|
78
78
|
if (l === -1) return;
|
|
79
|
-
const r = t === "first" ?
|
|
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
80
|
if (r) {
|
|
81
|
-
for (const
|
|
81
|
+
for (const o of a) o.tabIndex = o === r ? 0 : -1;
|
|
82
82
|
return r;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function $e(e) {
|
|
86
86
|
return {
|
|
87
87
|
background: e.dashboardRoot,
|
|
88
88
|
tableBackground: e.tableBackground,
|
|
@@ -105,15 +105,15 @@ function Le(e) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
function Be(e) {
|
|
108
|
-
const { foreground: t, axisFaint:
|
|
108
|
+
const { foreground: t, axisFaint: a, gridline: l, font: r } = e, o = {
|
|
109
109
|
background: e.background,
|
|
110
110
|
font: r.family,
|
|
111
111
|
title: { color: t, font: r.family },
|
|
112
112
|
axis: {
|
|
113
113
|
labelColor: t,
|
|
114
114
|
titleColor: t,
|
|
115
|
-
domainColor:
|
|
116
|
-
tickColor:
|
|
115
|
+
domainColor: a,
|
|
116
|
+
tickColor: a,
|
|
117
117
|
gridColor: l,
|
|
118
118
|
labelFont: r.family,
|
|
119
119
|
titleFont: r.family
|
|
@@ -127,56 +127,56 @@ function Be(e) {
|
|
|
127
127
|
header: { labelColor: t, titleColor: t },
|
|
128
128
|
range: { category: e.series }
|
|
129
129
|
}, n = {
|
|
130
|
-
...
|
|
131
|
-
legend: { ...
|
|
130
|
+
...o,
|
|
131
|
+
legend: { ...o.legend, orient: "bottom" }
|
|
132
132
|
};
|
|
133
|
-
return (i) => i === "shape_map" ? n :
|
|
133
|
+
return (i) => i === "shape_map" ? n : o;
|
|
134
134
|
}
|
|
135
135
|
function Ne(e) {
|
|
136
136
|
if (!e) return;
|
|
137
137
|
const t = e.tag("theme");
|
|
138
138
|
if (!t) return;
|
|
139
|
-
const
|
|
139
|
+
const a = {}, l = t.tag("palette");
|
|
140
140
|
if (l) {
|
|
141
|
-
const
|
|
142
|
-
n && n.length > 0 && (
|
|
143
|
-
for (const i of
|
|
141
|
+
const o = {}, n = l.textArray("series");
|
|
142
|
+
n && n.length > 0 && (o.series = n);
|
|
143
|
+
for (const i of De) {
|
|
144
144
|
const h = l.tag(i);
|
|
145
145
|
if (!h) continue;
|
|
146
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 && (
|
|
147
|
+
k && (p.light = k), w && (p.dark = w), Object.keys(p).length > 0 && (o[i] = p);
|
|
148
148
|
}
|
|
149
|
-
Object.keys(
|
|
149
|
+
Object.keys(o).length > 0 && (a.palette = o);
|
|
150
150
|
}
|
|
151
151
|
const r = t.tag("font");
|
|
152
152
|
if (r) {
|
|
153
|
-
const
|
|
154
|
-
n && (
|
|
153
|
+
const o = {}, n = r.text("family");
|
|
154
|
+
n && (o.family = n);
|
|
155
155
|
const i = r.numeric("size");
|
|
156
|
-
typeof i == "number" && Number.isFinite(i) && (
|
|
156
|
+
typeof i == "number" && Number.isFinite(i) && (o.size = i), Object.keys(o).length > 0 && (a.font = o);
|
|
157
157
|
}
|
|
158
|
-
return Object.keys(
|
|
158
|
+
return Object.keys(a).length > 0 ? a : void 0;
|
|
159
159
|
}
|
|
160
|
-
const
|
|
161
|
-
function
|
|
160
|
+
const J = (e) => (e ?? []).map((t) => t?.value).filter((t) => typeof t == "string");
|
|
161
|
+
function Pe(e) {
|
|
162
162
|
const t = e.replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim();
|
|
163
163
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
164
164
|
}
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
return /^#[^("]/.test(
|
|
168
|
-
}),
|
|
169
|
-
function
|
|
170
|
-
let
|
|
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
171
|
return { fields: e.map((r) => {
|
|
172
|
-
const
|
|
173
|
-
if (
|
|
174
|
-
const i =
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
const o = qe(r);
|
|
173
|
+
if (o) {
|
|
174
|
+
const i = me(
|
|
175
|
+
o,
|
|
176
|
+
he(J(r.annotations))
|
|
177
177
|
);
|
|
178
178
|
if (!i.changed) return r;
|
|
179
|
-
|
|
179
|
+
a = !0;
|
|
180
180
|
const h = r.type?.element_type ? {
|
|
181
181
|
...r.type,
|
|
182
182
|
element_type: {
|
|
@@ -186,41 +186,41 @@ function he(e, t) {
|
|
|
186
186
|
} : { ...r.type, fields: i.fields };
|
|
187
187
|
return { ...r, type: h };
|
|
188
188
|
}
|
|
189
|
-
if (!t || !r.name ||
|
|
190
|
-
const n =
|
|
191
|
-
return n === r.name ? r : (
|
|
189
|
+
if (!t || !r.name || je(r)) return r;
|
|
190
|
+
const n = Pe(r.name);
|
|
191
|
+
return n === r.name ? r : (a = !0, {
|
|
192
192
|
...r,
|
|
193
193
|
annotations: [
|
|
194
|
-
{ value: `# label=${
|
|
194
|
+
{ value: `# label=${He(n)}
|
|
195
195
|
` },
|
|
196
196
|
...r.annotations ?? []
|
|
197
197
|
]
|
|
198
198
|
});
|
|
199
|
-
}), changed:
|
|
199
|
+
}), changed: a };
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function Ve(e) {
|
|
202
202
|
if (!e || typeof e != "object") return e;
|
|
203
|
-
const t = e,
|
|
204
|
-
if (!Array.isArray(
|
|
205
|
-
const { fields: l, changed: r } =
|
|
206
|
-
|
|
207
|
-
|
|
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
208
|
);
|
|
209
209
|
return r ? { ...t, schema: { ...t.schema, fields: l } } : e;
|
|
210
210
|
}
|
|
211
|
-
const
|
|
212
|
-
function
|
|
211
|
+
const ce = 320, Xe = 10, Ke = 96, We = 4e3;
|
|
212
|
+
function Ge(e, t) {
|
|
213
213
|
if (e !== "bar" && e !== "combo" && e !== "line" && e !== "chart" && e !== "scatter_chart")
|
|
214
214
|
return;
|
|
215
|
-
if (e !== "bar" && e !== "combo") return
|
|
216
|
-
const
|
|
217
|
-
return Math.min(Math.max(
|
|
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
218
|
}
|
|
219
219
|
const I = "data-publisher-fill", Ue = async (e, t) => {
|
|
220
220
|
if (typeof window > "u")
|
|
221
221
|
throw new Error("MalloyRenderer can only be used in browser environment");
|
|
222
|
-
const { MalloyRenderer:
|
|
223
|
-
return new
|
|
222
|
+
const { MalloyRenderer: a } = await Ee();
|
|
223
|
+
return new a({
|
|
224
224
|
onClick: t,
|
|
225
225
|
vegaConfigOverride: Be(e),
|
|
226
226
|
// Pass the explicit theme so table chrome and dashboard tiles
|
|
@@ -228,43 +228,43 @@ const I = "data-publisher-fill", Ue = async (e, t) => {
|
|
|
228
228
|
// renderer's own inline style writes `--malloy-render--*` values
|
|
229
229
|
// sourced from its built-in defaults and shadows whatever we set
|
|
230
230
|
// on the outer wrapper.
|
|
231
|
-
theme:
|
|
231
|
+
theme: $e(e),
|
|
232
232
|
onError: (r) => {
|
|
233
233
|
console.error("Error rendering visualization:", typeof r, r);
|
|
234
234
|
}
|
|
235
235
|
}).createViz();
|
|
236
236
|
};
|
|
237
|
-
async function
|
|
237
|
+
async function Ye(e) {
|
|
238
238
|
if (!e || typeof e != "object") return;
|
|
239
|
-
const t = e,
|
|
239
|
+
const t = e, a = [
|
|
240
240
|
...Array.isArray(t.model_annotations) ? t.model_annotations : [],
|
|
241
241
|
...Array.isArray(t.source_annotations) ? t.source_annotations : [],
|
|
242
242
|
...Array.isArray(t.annotations) ? t.annotations : []
|
|
243
243
|
].map((r) => typeof r?.value == "string" ? r.value : void 0).filter((r) => !!r);
|
|
244
|
-
if (
|
|
244
|
+
if (a.length === 0) return;
|
|
245
245
|
let l;
|
|
246
246
|
try {
|
|
247
|
-
({ parseAnnotation: l } = await
|
|
247
|
+
({ parseAnnotation: l } = await Re());
|
|
248
248
|
} catch {
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
251
|
try {
|
|
252
|
-
const { tag: r } = l(
|
|
252
|
+
const { tag: r } = l(a);
|
|
253
253
|
return Ne(r);
|
|
254
254
|
} catch (r) {
|
|
255
255
|
console.warn(
|
|
256
256
|
"Failed to parse # theme.* annotations; chart will render with the shell theme.",
|
|
257
|
-
{ error: r, lines:
|
|
257
|
+
{ error: r, lines: a }
|
|
258
258
|
);
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
function
|
|
263
|
-
const l =
|
|
264
|
-
for (const [r,
|
|
265
|
-
e.style.setProperty(r,
|
|
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
266
|
}
|
|
267
|
-
const
|
|
267
|
+
const Qe = `
|
|
268
268
|
/* Card geometry, through the renderer's OWN theme vars rather than over the top
|
|
269
269
|
of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
|
|
270
270
|
passes each through to the --malloy-render--* the card CSS reads, so a value
|
|
@@ -358,6 +358,23 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
|
|
|
358
358
|
width: auto;
|
|
359
359
|
max-width: none;
|
|
360
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
|
+
}
|
|
361
378
|
.malloy-render .malloy-dashboard .dashboard-row-header-separator {
|
|
362
379
|
background: var(--malloy-render--table-border) !important;
|
|
363
380
|
}
|
|
@@ -416,59 +433,59 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
|
|
|
416
433
|
color: var(--publisher-drill-link) !important;
|
|
417
434
|
text-decoration: underline;
|
|
418
435
|
}
|
|
419
|
-
`,
|
|
420
|
-
function
|
|
421
|
-
if (typeof document > "u" || document.getElementById(
|
|
436
|
+
`, ue = "publisher-malloy-renderer-overrides";
|
|
437
|
+
function Ze() {
|
|
438
|
+
if (typeof document > "u" || document.getElementById(ue)) return;
|
|
422
439
|
const e = document.createElement("style");
|
|
423
|
-
e.id =
|
|
440
|
+
e.id = ue, e.textContent = Qe, document.head.appendChild(e);
|
|
424
441
|
}
|
|
425
|
-
function
|
|
442
|
+
function et({
|
|
426
443
|
result: e,
|
|
427
444
|
height: t,
|
|
428
|
-
drill:
|
|
445
|
+
drill: a,
|
|
429
446
|
onSizeChange: l,
|
|
430
447
|
onSizing: r,
|
|
431
|
-
fill:
|
|
448
|
+
fill: o
|
|
432
449
|
}) {
|
|
433
|
-
const n =
|
|
434
|
-
i.current =
|
|
435
|
-
const h =
|
|
450
|
+
const n = z(null), i = z(a);
|
|
451
|
+
i.current = a;
|
|
452
|
+
const h = ge((d) => {
|
|
436
453
|
i.current?.onClick(d);
|
|
437
|
-
}, []), p =
|
|
454
|
+
}, []), p = a !== void 0, k = z(!1), w = z(
|
|
438
455
|
null
|
|
439
|
-
),
|
|
456
|
+
), q = z(0), { theme: $, layers: V, mode: Q } = Oe(), Z = ve(
|
|
440
457
|
() => ({
|
|
441
|
-
radius:
|
|
442
|
-
padding: `${
|
|
458
|
+
radius: $.ui.radius.tile,
|
|
459
|
+
padding: `${Ce}px`
|
|
443
460
|
}),
|
|
444
|
-
[
|
|
461
|
+
[$.ui.radius.tile]
|
|
445
462
|
);
|
|
446
|
-
return
|
|
447
|
-
|
|
463
|
+
return we(() => () => {
|
|
464
|
+
q.current += 1;
|
|
448
465
|
const d = w.current;
|
|
449
466
|
d?.viz.remove(), d?.node.remove(), w.current = null;
|
|
450
|
-
}, []),
|
|
467
|
+
}, []), ke(() => {
|
|
451
468
|
if (!n.current || !e) return;
|
|
452
|
-
|
|
453
|
-
const d = n.current,
|
|
454
|
-
let
|
|
455
|
-
const
|
|
456
|
-
let c, b,
|
|
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;
|
|
457
474
|
k.current = !1;
|
|
458
475
|
let y, R;
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
476
|
+
const G = (g) => {
|
|
477
|
+
if (X || !g.firstElementChild || Y(y, R) === "container") return;
|
|
461
478
|
const O = _e(y, R);
|
|
462
479
|
if (k.current && !O) return;
|
|
463
480
|
const F = d.hasAttribute(I);
|
|
464
481
|
F && d.removeAttribute(I);
|
|
465
482
|
const E = Ae(
|
|
466
483
|
g,
|
|
467
|
-
|
|
484
|
+
se(y)
|
|
468
485
|
);
|
|
469
|
-
F && d.setAttribute(I, ""), E > 0 && (k.current = !0, l && E !==
|
|
470
|
-
const u = Se(g,
|
|
471
|
-
O && u &&
|
|
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));
|
|
472
489
|
};
|
|
473
490
|
return (async () => {
|
|
474
491
|
let g;
|
|
@@ -478,95 +495,95 @@ function Ze({
|
|
|
478
495
|
console.error("Error parsing visualization result:", m);
|
|
479
496
|
return;
|
|
480
497
|
}
|
|
481
|
-
const O = await
|
|
482
|
-
if (!
|
|
498
|
+
const O = await Ye(g), F = O ? Fe([...V, ze(V, O)], Q) : $;
|
|
499
|
+
if (!K()) return;
|
|
483
500
|
try {
|
|
484
501
|
b = await Ue(F, h);
|
|
485
502
|
} catch (m) {
|
|
486
503
|
console.error("Failed to create renderer:", m);
|
|
487
504
|
return;
|
|
488
505
|
}
|
|
489
|
-
if (!
|
|
506
|
+
if (!K()) {
|
|
490
507
|
b.remove(), b = void 0;
|
|
491
508
|
return;
|
|
492
509
|
}
|
|
493
510
|
const E = w.current;
|
|
494
|
-
c = document.createElement("div"), c.style.width = "100%", c.style.height = "100%",
|
|
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);
|
|
495
512
|
const u = c;
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
513
|
+
A = new MutationObserver(() => {
|
|
514
|
+
S && clearTimeout(S), S = setTimeout(() => {
|
|
515
|
+
G(u), k.current && A?.disconnect();
|
|
499
516
|
}, 100);
|
|
500
|
-
}),
|
|
517
|
+
}), A.observe(c, {
|
|
501
518
|
childList: !0,
|
|
502
519
|
subtree: !0,
|
|
503
520
|
attributes: !0
|
|
504
521
|
});
|
|
505
|
-
const
|
|
506
|
-
let
|
|
507
|
-
const
|
|
508
|
-
if (!(
|
|
509
|
-
|
|
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();
|
|
510
527
|
for (const m of Array.from(d.children))
|
|
511
528
|
m !== u && d.removeChild(m);
|
|
512
|
-
u.style.position = "", u.style.inset = "", u.style.visibility = "", d.style.position = "", w.current = { viz:
|
|
529
|
+
u.style.position = "", u.style.inset = "", u.style.visibility = "", d.style.position = "", w.current = { viz: fe, node: u }, G(u);
|
|
513
530
|
}
|
|
514
531
|
};
|
|
515
532
|
try {
|
|
516
|
-
b.setResult(
|
|
533
|
+
b.setResult(Ve(g));
|
|
517
534
|
try {
|
|
518
|
-
const x = b.getMetadata(),
|
|
519
|
-
y =
|
|
535
|
+
const x = b.getMetadata(), T = x?.getRootField();
|
|
536
|
+
y = T?.renderAs(), R = T ? x?.getPluginsForField(T.key)?.[0]?.sizingStrategy : void 0;
|
|
520
537
|
} catch {
|
|
521
538
|
y = void 0, R = void 0;
|
|
522
539
|
}
|
|
523
|
-
r?.(
|
|
524
|
-
const m =
|
|
540
|
+
r?.(Y(y, R), y), c.dataset.malloyRenderAs = y ?? "unknown", c.dataset.malloySizing = Y(y, R);
|
|
541
|
+
const m = Ge(y, g);
|
|
525
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);
|
|
526
543
|
const oe = i.current;
|
|
527
544
|
try {
|
|
528
545
|
if (oe) {
|
|
529
|
-
const x = Me(b, oe.canDrill),
|
|
546
|
+
const x = Me(b, oe.canDrill), T = () => {
|
|
530
547
|
try {
|
|
531
|
-
|
|
548
|
+
Ie(u, x);
|
|
532
549
|
} catch (s) {
|
|
533
550
|
console.warn("Drill affordance skipped:", s);
|
|
534
551
|
}
|
|
535
552
|
};
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
const
|
|
539
|
-
|
|
553
|
+
T();
|
|
554
|
+
const ne = (s) => {
|
|
555
|
+
const _ = s.querySelector(".cell-content") ?? s, U = _.getBoundingClientRect();
|
|
556
|
+
_.dispatchEvent(
|
|
540
557
|
new MouseEvent("click", {
|
|
541
558
|
bubbles: !0,
|
|
542
559
|
cancelable: !0,
|
|
543
|
-
view:
|
|
560
|
+
view: _.ownerDocument.defaultView,
|
|
544
561
|
clientX: Math.round(U.left + U.width / 2),
|
|
545
562
|
clientY: Math.round(U.bottom)
|
|
546
563
|
})
|
|
547
564
|
);
|
|
548
|
-
},
|
|
549
|
-
|
|
565
|
+
}, le = (s) => s.target?.closest?.(`.${v}`) ?? null, ye = (s, f) => {
|
|
566
|
+
de(s, f)?.focus();
|
|
550
567
|
};
|
|
551
|
-
|
|
552
|
-
const f =
|
|
568
|
+
N = (s) => {
|
|
569
|
+
const f = le(s);
|
|
553
570
|
if (!f) return;
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
s.preventDefault(),
|
|
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, _);
|
|
557
574
|
return;
|
|
558
575
|
}
|
|
559
|
-
s.key === "Enter" ? (s.preventDefault(),
|
|
576
|
+
s.key === "Enter" ? (s.preventDefault(), ne(f)) : s.key === " " && s.preventDefault();
|
|
560
577
|
}, P = (s) => {
|
|
561
578
|
if (s.key !== " ") return;
|
|
562
|
-
const f =
|
|
563
|
-
f && (s.preventDefault(),
|
|
579
|
+
const f = le(s);
|
|
580
|
+
f && (s.preventDefault(), ne(f));
|
|
564
581
|
}, j = (s) => {
|
|
565
582
|
const f = s.target?.closest?.(`.${v}`);
|
|
566
|
-
f &&
|
|
567
|
-
}, u.addEventListener("keydown",
|
|
568
|
-
cancelAnimationFrame(
|
|
569
|
-
}),
|
|
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, {
|
|
570
587
|
childList: !0,
|
|
571
588
|
subtree: !0
|
|
572
589
|
}));
|
|
@@ -574,12 +591,12 @@ function Ze({
|
|
|
574
591
|
} catch (x) {
|
|
575
592
|
console.warn("Drill affordance skipped:", x);
|
|
576
593
|
}
|
|
577
|
-
b.onReady(
|
|
594
|
+
b.onReady(ae), C = setTimeout(ae, 1e4);
|
|
578
595
|
} catch (m) {
|
|
579
|
-
console.error("Error rendering visualization:", 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);
|
|
580
597
|
}
|
|
581
598
|
})(), () => {
|
|
582
|
-
|
|
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 = "");
|
|
583
600
|
};
|
|
584
601
|
}, [
|
|
585
602
|
e,
|
|
@@ -587,15 +604,15 @@ function Ze({
|
|
|
587
604
|
p,
|
|
588
605
|
l,
|
|
589
606
|
r,
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
]), /* @__PURE__ */
|
|
607
|
+
$,
|
|
608
|
+
V,
|
|
609
|
+
Q,
|
|
610
|
+
Z
|
|
611
|
+
]), /* @__PURE__ */ M(
|
|
595
612
|
"div",
|
|
596
613
|
{
|
|
597
614
|
ref: n,
|
|
598
|
-
...
|
|
615
|
+
...o ? { [I]: "" } : {},
|
|
599
616
|
style: {
|
|
600
617
|
width: "100%",
|
|
601
618
|
height: t ? `${t}px` : "400px"
|
|
@@ -603,9 +620,9 @@ function Ze({
|
|
|
603
620
|
}
|
|
604
621
|
);
|
|
605
622
|
}
|
|
606
|
-
function
|
|
607
|
-
return typeof window > "u" ? /* @__PURE__ */
|
|
608
|
-
|
|
623
|
+
function tt(e) {
|
|
624
|
+
return typeof window > "u" ? /* @__PURE__ */ M(
|
|
625
|
+
ie,
|
|
609
626
|
{
|
|
610
627
|
sx: {
|
|
611
628
|
width: "100%",
|
|
@@ -617,11 +634,11 @@ function et(e) {
|
|
|
617
634
|
},
|
|
618
635
|
children: "Loading..."
|
|
619
636
|
}
|
|
620
|
-
) : /* @__PURE__ */
|
|
621
|
-
|
|
637
|
+
) : /* @__PURE__ */ M(
|
|
638
|
+
pe,
|
|
622
639
|
{
|
|
623
|
-
fallback: /* @__PURE__ */
|
|
624
|
-
|
|
640
|
+
fallback: /* @__PURE__ */ M(
|
|
641
|
+
ie,
|
|
625
642
|
{
|
|
626
643
|
sx: {
|
|
627
644
|
width: "100%",
|
|
@@ -634,21 +651,21 @@ function et(e) {
|
|
|
634
651
|
children: "Loading visualization..."
|
|
635
652
|
}
|
|
636
653
|
),
|
|
637
|
-
children: /* @__PURE__ */
|
|
654
|
+
children: /* @__PURE__ */ M(et, { ...e })
|
|
638
655
|
}
|
|
639
656
|
);
|
|
640
657
|
}
|
|
641
|
-
const
|
|
658
|
+
const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
642
659
|
__proto__: null,
|
|
643
|
-
default:
|
|
660
|
+
default: tt
|
|
644
661
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
645
662
|
export {
|
|
646
663
|
v as D,
|
|
647
|
-
|
|
664
|
+
tt as R,
|
|
648
665
|
Be as a,
|
|
649
|
-
|
|
650
|
-
|
|
666
|
+
$e as b,
|
|
667
|
+
it as c,
|
|
651
668
|
Me as d,
|
|
652
|
-
|
|
669
|
+
Ie as m,
|
|
653
670
|
Ne as r
|
|
654
671
|
};
|