@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.
- package/dist/RenderedResult-BClN_PG6.cjs.js +154 -0
- package/dist/{RenderedResult-DnBtf-cI.es.js → RenderedResult-YBzVMVH2.es.js} +295 -234
- package/dist/{ServerProvider-BV7IoDMR.es.js → ServerProvider-D7neZcTk.es.js} +283 -265
- package/dist/ServerProvider-e2369oom.cjs.js +1 -0
- package/dist/builder/index.cjs.js +80 -79
- package/dist/builder/index.es.js +7430 -6548
- package/dist/client/api.d.ts +30 -6
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +49 -1
- package/dist/components/Dashboard/DashboardTile.d.ts +5 -2
- package/dist/components/Dashboard/DashboardView.d.ts +9 -2
- package/dist/components/Dashboard/index.d.ts +1 -1
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +5 -7
- package/dist/components/Dashboard/useStuck.d.ts +18 -12
- package/dist/components/RenderedResult/RenderedResult.d.ts +3 -2
- package/dist/components/RenderedResult/ResultContainer.d.ts +11 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +5 -1
- package/dist/components/RenderedResult/chartPresentation.d.ts +15 -0
- package/dist/components/RenderedResult/chartShapeProblem.d.ts +55 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +42 -6
- package/dist/components/Report/Report.d.ts +7 -1
- package/dist/components/Report/ReportPage.d.ts +7 -0
- package/dist/components/Report/layoutRules.d.ts +45 -0
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +2 -1
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +14 -1
- package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
- package/dist/components/ReportBuilder/EditorSurface.d.ts +17 -1
- package/dist/components/ReportBuilder/ReportEditor.d.ts +18 -0
- package/dist/components/ReportBuilder/TileFrame.d.ts +33 -1
- package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
- package/dist/components/ReportBuilder/catalog.d.ts +23 -0
- package/dist/components/ReportBuilder/chartLine.d.ts +38 -5
- package/dist/components/ReportBuilder/controls.d.ts +2 -2
- package/dist/components/ReportBuilder/document.d.ts +53 -5
- package/dist/components/ReportBuilder/imports.d.ts +7 -0
- package/dist/components/ReportBuilder/placement.d.ts +75 -0
- package/dist/components/ReportBuilder/preview.d.ts +59 -10
- package/dist/components/ReportBuilder/sortable.d.ts +3 -1
- package/dist/components/ReportBuilder/useTileHeight.d.ts +39 -0
- package/dist/components/ReportBuilder/useTileReorder.d.ts +27 -3
- package/dist/components/ReportBuilder/useTileResize.d.ts +8 -0
- package/dist/index.cjs.js +7 -7
- package/dist/index.es.js +3328 -3287
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-72YFLeNk.es.js → text-entry-YKJZbRPo.es.js} +2 -2
- package/dist/theme/resolveTheme.d.ts +15 -0
- package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-BGk38oaW.es.js} +5097 -4805
- package/dist/useCompiledDocument-D9t5ry_t.cjs.js +142 -0
- package/dist/utils/blankQuoted.d.ts +15 -0
- package/package.json +1 -1
- package/src/components/Dashboard/DashboardGrid.tsx +127 -10
- package/src/components/Dashboard/DashboardTile.tsx +11 -1
- package/src/components/Dashboard/DashboardView.tsx +63 -10
- package/src/components/Dashboard/TileCard.tsx +6 -0
- package/src/components/Dashboard/index.ts +1 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +19 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +15 -36
- package/src/components/Dashboard/tileHeight.spec.ts +72 -0
- package/src/components/Dashboard/useStuck.ts +76 -28
- package/src/components/Package/NewDocumentDialog.spec.tsx +20 -16
- package/src/components/Package/NewDocumentDialog.tsx +10 -11
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +167 -2
- package/src/components/RenderedResult/RenderedResult.tsx +21 -6
- package/src/components/RenderedResult/ResultContainer.tsx +60 -7
- package/src/components/RenderedResult/ResultPanel.tsx +21 -1
- package/src/components/RenderedResult/chartPresentation.spec.ts +153 -0
- package/src/components/RenderedResult/chartPresentation.ts +166 -0
- package/src/components/RenderedResult/chartShapeProblem.spec.tsx +245 -0
- package/src/components/RenderedResult/chartShapeProblem.ts +219 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +75 -3
- package/src/components/RenderedResult/resultSizing.ts +65 -11
- package/src/components/Report/Report.spec.tsx +19 -0
- package/src/components/Report/Report.tsx +8 -1
- package/src/components/Report/ReportPage.tsx +13 -1
- package/src/components/Report/layoutRules.spec.ts +43 -3
- package/src/components/Report/layoutRules.ts +70 -0
- package/src/components/Report/tileOverflow.spec.tsx +162 -0
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +2 -2
- package/src/components/ReportBuilder/AddTileDialog.tsx +11 -6
- package/src/components/ReportBuilder/BuilderBar.tsx +1 -1
- package/src/components/ReportBuilder/BuilderDialogs.tsx +20 -0
- package/src/components/ReportBuilder/BuilderGrid.tsx +126 -20
- package/src/components/ReportBuilder/ChartPicker.spec.ts +91 -4
- package/src/components/ReportBuilder/ChartPicker.tsx +45 -10
- package/src/components/ReportBuilder/DrillDialog.tsx +8 -2
- package/src/components/ReportBuilder/EditorSurface.tsx +110 -28
- package/src/components/ReportBuilder/FilterDialog.tsx +17 -8
- package/src/components/ReportBuilder/FilterStrip.tsx +2 -1
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +193 -2
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +2 -2
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +143 -2
- package/src/components/ReportBuilder/ReportBuilder.tsx +73 -19
- package/src/components/ReportBuilder/ReportEditor.fileModel.spec.tsx +178 -0
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +3 -5
- package/src/components/ReportBuilder/ReportEditor.queryVersion.spec.tsx +292 -0
- package/src/components/ReportBuilder/ReportEditor.readOnlyTitle.spec.tsx +92 -0
- package/src/components/ReportBuilder/ReportEditor.tsx +35 -0
- package/src/components/ReportBuilder/TileFrame.tsx +251 -6
- package/src/components/ReportBuilder/TileMenu.tsx +259 -20
- package/src/components/ReportBuilder/ViewPicker.tsx +4 -3
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +34 -0
- package/src/components/ReportBuilder/addTileToDocument.ts +26 -1
- package/src/components/ReportBuilder/catalog.aggregate.spec.ts +137 -1
- package/src/components/ReportBuilder/catalog.ts +90 -37
- package/src/components/ReportBuilder/chartLine.spec.ts +42 -5
- package/src/components/ReportBuilder/chartLine.ts +80 -2
- package/src/components/ReportBuilder/controls.ts +4 -3
- package/src/components/ReportBuilder/document.ts +65 -7
- package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
- package/src/components/ReportBuilder/entryLayout.spec.ts +151 -0
- package/src/components/ReportBuilder/imports.ts +1 -1
- package/src/components/ReportBuilder/invariants.spec.ts +18 -10
- package/src/components/ReportBuilder/layout.ts +3 -0
- package/src/components/ReportBuilder/placement.spec.ts +193 -0
- package/src/components/ReportBuilder/placement.ts +250 -0
- package/src/components/ReportBuilder/preview.shapes.spec.ts +46 -6
- package/src/components/ReportBuilder/preview.spec.ts +151 -11
- package/src/components/ReportBuilder/preview.ts +203 -40
- package/src/components/ReportBuilder/preview.unsaved.compile.spec.ts +190 -0
- package/src/components/ReportBuilder/readDocument.spec.ts +46 -2
- package/src/components/ReportBuilder/readDocument.ts +194 -23
- package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
- package/src/components/ReportBuilder/sortable.tsx +4 -0
- package/src/components/ReportBuilder/spliceDocument.chart.spec.ts +1 -1
- package/src/components/ReportBuilder/spliceDocument.color.spec.ts +80 -0
- package/src/components/ReportBuilder/spliceDocument.colspan.spec.ts +78 -0
- package/src/components/ReportBuilder/spliceDocument.spec.ts +110 -18
- package/src/components/ReportBuilder/spliceDocument.ts +139 -52
- package/src/components/ReportBuilder/statementExtent.spec.ts +3 -3
- package/src/components/ReportBuilder/testing/reportGivenOrder.json +42 -0
- package/src/components/ReportBuilder/textTiles.spec.ts +2 -2
- package/src/components/ReportBuilder/tileDisplayTitle.ts +2 -2
- package/src/components/ReportBuilder/useTileEditing.ts +16 -3
- package/src/components/ReportBuilder/useTileHeight.ts +149 -0
- package/src/components/ReportBuilder/useTileReorder.ts +143 -6
- package/src/components/ReportBuilder/useTileResize.ts +16 -1
- package/src/components/given/FilterButton.spec.tsx +27 -11
- package/src/components/given/FilterButton.tsx +19 -6
- package/src/theme/resolveTheme.spec.ts +72 -1
- package/src/theme/resolveTheme.ts +43 -0
- package/src/utils/blankQuoted.spec.ts +50 -0
- package/src/utils/blankQuoted.ts +32 -0
- package/src/utils/malloyText.ts +2 -1
- package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
- package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
- package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { Suspense as
|
|
4
|
-
import { r as
|
|
5
|
-
import { ba as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const
|
|
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
|
|
13
|
+
return o;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const r = /* @__PURE__ */ new Set();
|
|
16
16
|
for (const a of l)
|
|
17
|
-
!a ||
|
|
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 || !
|
|
19
|
+
if (!a || !t(a)) continue;
|
|
20
20
|
const n = a.tag?.text("label") ?? a.name;
|
|
21
|
-
|
|
21
|
+
r.has(n) || o.add(n);
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return o;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
return
|
|
25
|
+
function L(e) {
|
|
26
|
+
const t = /^\s*(\d+)/.exec(e.style?.gridColumn ?? "");
|
|
27
|
+
return t ? t[1] : void 0;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
if (
|
|
31
|
-
for (const
|
|
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") ===
|
|
35
|
-
for (const n of
|
|
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
|
|
40
|
-
|
|
39
|
+
const i = (n.textContent ?? "").replace(/\u200b/g, "").trim(), h = L(n);
|
|
40
|
+
h && t.has(i) && r.add(h);
|
|
41
41
|
}
|
|
42
|
-
if (
|
|
42
|
+
if (r.size === 0) continue;
|
|
43
43
|
const a = /* @__PURE__ */ new Set();
|
|
44
|
-
for (const n of
|
|
45
|
-
`.${
|
|
44
|
+
for (const n of o.querySelectorAll(
|
|
45
|
+
`.${v}[tabindex="0"]`
|
|
46
46
|
)) {
|
|
47
47
|
if (!l(n)) continue;
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const i = L(n);
|
|
49
|
+
i && (a.has(i) ? n.tabIndex = -1 : a.add(i));
|
|
50
50
|
}
|
|
51
|
-
for (const n of
|
|
51
|
+
for (const n of o.querySelectorAll(
|
|
52
52
|
".column-cell.td"
|
|
53
53
|
)) {
|
|
54
54
|
if (!l(n)) continue;
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
if (n.classList.add(
|
|
58
|
-
a.add(
|
|
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
|
|
61
|
-
|
|
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
|
|
69
|
-
const
|
|
70
|
-
return !
|
|
71
|
-
|
|
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") ===
|
|
73
|
+
(l) => l.closest(".malloy-table") === t && L(l) === o
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
76
|
+
function se(e, t) {
|
|
77
|
+
const o = Ie(e), l = o.indexOf(e);
|
|
78
78
|
if (l === -1) return;
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
for (const a of
|
|
82
|
-
return
|
|
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
|
|
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
|
|
108
|
-
const { foreground:
|
|
107
|
+
function Be(e) {
|
|
108
|
+
const { foreground: t, axisFaint: o, gridline: l, font: r } = e, a = {
|
|
109
109
|
background: e.background,
|
|
110
|
-
font:
|
|
111
|
-
title: { color:
|
|
110
|
+
font: r.family,
|
|
111
|
+
title: { color: t, font: r.family },
|
|
112
112
|
axis: {
|
|
113
|
-
labelColor:
|
|
114
|
-
titleColor:
|
|
115
|
-
domainColor:
|
|
116
|
-
tickColor:
|
|
113
|
+
labelColor: t,
|
|
114
|
+
titleColor: t,
|
|
115
|
+
domainColor: o,
|
|
116
|
+
tickColor: o,
|
|
117
117
|
gridColor: l,
|
|
118
|
-
labelFont:
|
|
119
|
-
titleFont:
|
|
118
|
+
labelFont: r.family,
|
|
119
|
+
titleFont: r.family
|
|
120
120
|
},
|
|
121
121
|
legend: {
|
|
122
|
-
labelColor:
|
|
123
|
-
titleColor:
|
|
124
|
-
labelFont:
|
|
125
|
-
titleFont:
|
|
122
|
+
labelColor: t,
|
|
123
|
+
titleColor: t,
|
|
124
|
+
labelFont: r.family,
|
|
125
|
+
titleFont: r.family
|
|
126
126
|
},
|
|
127
|
-
header: { labelColor:
|
|
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 (
|
|
133
|
+
return (i) => i === "shape_map" ? n : a;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function Ne(e) {
|
|
136
136
|
if (!e) return;
|
|
137
|
-
const
|
|
138
|
-
if (!
|
|
139
|
-
const
|
|
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
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
146
|
-
const
|
|
147
|
-
k && (
|
|
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 && (
|
|
149
|
+
Object.keys(a).length > 0 && (o.palette = a);
|
|
150
150
|
}
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
153
|
-
const a = {}, n =
|
|
151
|
+
const r = t.tag("font");
|
|
152
|
+
if (r) {
|
|
153
|
+
const a = {}, n = r.text("family");
|
|
154
154
|
n && (a.family = n);
|
|
155
|
-
const
|
|
156
|
-
typeof
|
|
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(
|
|
158
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
159
159
|
}
|
|
160
|
-
const
|
|
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:
|
|
164
|
-
return new
|
|
165
|
-
onClick:
|
|
166
|
-
vegaConfigOverride:
|
|
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:
|
|
173
|
-
onError: (
|
|
174
|
-
console.error("Error rendering visualization:", typeof
|
|
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
|
|
237
|
+
async function Ge(e) {
|
|
179
238
|
if (!e || typeof e != "object") return;
|
|
180
|
-
const
|
|
181
|
-
...Array.isArray(
|
|
182
|
-
...Array.isArray(
|
|
183
|
-
...Array.isArray(
|
|
184
|
-
].map((
|
|
185
|
-
if (
|
|
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
|
|
247
|
+
({ parseAnnotation: l } = await Ce());
|
|
189
248
|
} catch {
|
|
190
249
|
return;
|
|
191
250
|
}
|
|
192
251
|
try {
|
|
193
|
-
const { tag:
|
|
194
|
-
return
|
|
195
|
-
} catch (
|
|
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:
|
|
257
|
+
{ error: r, lines: o }
|
|
199
258
|
);
|
|
200
259
|
return;
|
|
201
260
|
}
|
|
202
261
|
}
|
|
203
|
-
function
|
|
204
|
-
const l =
|
|
205
|
-
for (const [
|
|
206
|
-
e.style.setProperty(
|
|
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
|
|
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
|
-
[${
|
|
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 .${
|
|
400
|
+
.malloy-render .${v} {
|
|
342
401
|
cursor: pointer;
|
|
343
402
|
}
|
|
344
|
-
.malloy-render .${
|
|
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 .${
|
|
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 .${
|
|
415
|
+
.malloy-render .${v}:focus-visible > .cell-content {
|
|
357
416
|
color: var(--publisher-drill-link) !important;
|
|
358
417
|
text-decoration: underline;
|
|
359
418
|
}
|
|
360
|
-
`,
|
|
361
|
-
function
|
|
362
|
-
if (typeof document > "u" || document.getElementById(
|
|
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 =
|
|
423
|
+
e.id = ce, e.textContent = Je, document.head.appendChild(e);
|
|
365
424
|
}
|
|
366
|
-
function
|
|
425
|
+
function Ze({
|
|
367
426
|
result: e,
|
|
368
|
-
height:
|
|
369
|
-
drill:
|
|
427
|
+
height: t,
|
|
428
|
+
drill: o,
|
|
370
429
|
onSizeChange: l,
|
|
371
|
-
onSizing:
|
|
430
|
+
onSizing: r,
|
|
372
431
|
fill: a
|
|
373
432
|
}) {
|
|
374
|
-
const n =
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
}, []),
|
|
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
|
-
),
|
|
439
|
+
), H = M(0), { theme: B, layers: q, mode: J } = De(), Q = ge(
|
|
381
440
|
() => ({
|
|
382
441
|
radius: B.ui.radius.tile,
|
|
383
|
-
padding: `${
|
|
442
|
+
padding: `${xe}px`
|
|
384
443
|
}),
|
|
385
444
|
[B.ui.radius.tile]
|
|
386
445
|
);
|
|
387
|
-
return
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
}, []),
|
|
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
|
-
|
|
394
|
-
const
|
|
395
|
-
let
|
|
396
|
-
const
|
|
397
|
-
let
|
|
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
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
const
|
|
403
|
-
if (k.current && !
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
const E =
|
|
407
|
-
|
|
408
|
-
|
|
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
|
-
|
|
411
|
-
const u =
|
|
412
|
-
|
|
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
|
|
474
|
+
let g;
|
|
416
475
|
try {
|
|
417
|
-
|
|
418
|
-
} catch (
|
|
419
|
-
console.error("Error parsing visualization result:",
|
|
476
|
+
g = JSON.parse(e);
|
|
477
|
+
} catch (m) {
|
|
478
|
+
console.error("Error parsing visualization result:", m);
|
|
420
479
|
return;
|
|
421
480
|
}
|
|
422
|
-
const
|
|
423
|
-
if (!
|
|
481
|
+
const O = await Ge(g), F = O ? Oe([...q, Fe(q, O)], J) : B;
|
|
482
|
+
if (!X()) return;
|
|
424
483
|
try {
|
|
425
|
-
|
|
426
|
-
} catch (
|
|
427
|
-
console.error("Failed to create renderer:",
|
|
484
|
+
b = await Ue(F, h);
|
|
485
|
+
} catch (m) {
|
|
486
|
+
console.error("Failed to create renderer:", m);
|
|
428
487
|
return;
|
|
429
488
|
}
|
|
430
|
-
if (!
|
|
431
|
-
|
|
489
|
+
if (!X()) {
|
|
490
|
+
b.remove(), b = void 0;
|
|
432
491
|
return;
|
|
433
492
|
}
|
|
434
|
-
const E =
|
|
435
|
-
|
|
436
|
-
const u =
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
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
|
-
}),
|
|
500
|
+
}), S.observe(c, {
|
|
442
501
|
childList: !0,
|
|
443
502
|
subtree: !0,
|
|
444
503
|
attributes: !0
|
|
445
504
|
});
|
|
446
|
-
const
|
|
447
|
-
let
|
|
505
|
+
const be = b;
|
|
506
|
+
let te = !1;
|
|
448
507
|
const re = () => {
|
|
449
|
-
if (!(
|
|
450
|
-
|
|
451
|
-
for (const
|
|
452
|
-
|
|
453
|
-
u.style.position = "", u.style.inset = "", u.style.visibility = "",
|
|
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
|
-
|
|
516
|
+
b.setResult(qe(g));
|
|
458
517
|
try {
|
|
459
|
-
const x =
|
|
460
|
-
|
|
518
|
+
const x = b.getMetadata(), _ = x?.getRootField();
|
|
519
|
+
y = _?.renderAs(), R = _ ? x?.getPluginsForField(_.key)?.[0]?.sizingStrategy : void 0;
|
|
461
520
|
} catch {
|
|
462
|
-
|
|
521
|
+
y = void 0, R = void 0;
|
|
463
522
|
}
|
|
464
|
-
|
|
465
|
-
const
|
|
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 (
|
|
468
|
-
const x =
|
|
528
|
+
if (oe) {
|
|
529
|
+
const x = Me(b, oe.canDrill), _ = () => {
|
|
469
530
|
try {
|
|
470
|
-
|
|
471
|
-
} catch (
|
|
472
|
-
console.warn("Drill affordance skipped:",
|
|
531
|
+
ze(u, x);
|
|
532
|
+
} catch (s) {
|
|
533
|
+
console.warn("Drill affordance skipped:", s);
|
|
473
534
|
}
|
|
474
535
|
};
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
const A =
|
|
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
|
-
},
|
|
488
|
-
|
|
548
|
+
}, ne = (s) => s.target?.closest?.(`.${v}`) ?? null, fe = (s, f) => {
|
|
549
|
+
se(s, f)?.focus();
|
|
489
550
|
};
|
|
490
|
-
$ = (
|
|
491
|
-
const
|
|
492
|
-
if (!
|
|
493
|
-
const A =
|
|
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
|
-
|
|
556
|
+
s.preventDefault(), fe(f, A);
|
|
496
557
|
return;
|
|
497
558
|
}
|
|
498
|
-
|
|
499
|
-
},
|
|
500
|
-
if (
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
},
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
}, u.addEventListener("keydown", $), u.addEventListener("keyup",
|
|
507
|
-
cancelAnimationFrame(K), K = requestAnimationFrame(
|
|
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
|
-
|
|
517
|
-
} catch (
|
|
518
|
-
console.error("Error rendering visualization:",
|
|
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
|
-
|
|
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
|
-
|
|
526
|
-
|
|
586
|
+
h,
|
|
587
|
+
p,
|
|
527
588
|
l,
|
|
528
|
-
|
|
589
|
+
r,
|
|
529
590
|
B,
|
|
530
|
-
|
|
591
|
+
q,
|
|
531
592
|
J,
|
|
532
|
-
|
|
533
|
-
]), /* @__PURE__ */
|
|
593
|
+
Q
|
|
594
|
+
]), /* @__PURE__ */ z(
|
|
534
595
|
"div",
|
|
535
596
|
{
|
|
536
597
|
ref: n,
|
|
537
|
-
...a ? { [
|
|
598
|
+
...a ? { [I]: "" } : {},
|
|
538
599
|
style: {
|
|
539
600
|
width: "100%",
|
|
540
|
-
height:
|
|
601
|
+
height: t ? `${t}px` : "400px"
|
|
541
602
|
}
|
|
542
603
|
}
|
|
543
604
|
);
|
|
544
605
|
}
|
|
545
|
-
function
|
|
546
|
-
return typeof window > "u" ? /* @__PURE__ */
|
|
547
|
-
|
|
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__ */
|
|
560
|
-
|
|
620
|
+
) : /* @__PURE__ */ z(
|
|
621
|
+
ye,
|
|
561
622
|
{
|
|
562
|
-
fallback: /* @__PURE__ */
|
|
563
|
-
|
|
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__ */
|
|
637
|
+
children: /* @__PURE__ */ z(Ze, { ...e })
|
|
577
638
|
}
|
|
578
639
|
);
|
|
579
640
|
}
|
|
580
|
-
const
|
|
641
|
+
const lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
581
642
|
__proto__: null,
|
|
582
|
-
default:
|
|
643
|
+
default: et
|
|
583
644
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
584
645
|
export {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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
|
};
|