@malloy-publisher/sdk 0.3.1 → 0.4.0
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/README.md +14 -9
- package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorageProvider-CyOJ0hqf.es.js} +7114 -6939
- package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
- package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-BnPzJ9Jf.es.js} +64 -57
- package/dist/{RenderedResult-CPi6uQWq.cjs.js → RenderedResult-Dp22kZsQ.cjs.js} +2 -2
- package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
- package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
- package/dist/builder/index.cjs.js +41 -41
- package/dist/builder/index.es.js +2752 -2831
- package/dist/client/api.d.ts +100 -42
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +30 -0
- package/dist/components/BackLink.d.ts +32 -0
- package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
- package/dist/components/Dashboard/telemetry.d.ts +10 -5
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +8 -2
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +8 -10
- package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
- package/dist/components/ItemRow.d.ts +38 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
- package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
- package/dist/components/Materializations/Materializations.d.ts +7 -3
- package/dist/components/Materializations/ScopeButton.d.ts +18 -0
- package/dist/components/Materializations/SectionLabel.d.ts +7 -4
- package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
- package/dist/components/Materializations/index.d.ts +0 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
- package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
- package/dist/components/Package/index.d.ts +0 -1
- package/dist/components/PackageSection.d.ts +23 -0
- package/dist/components/buttons.d.ts +53 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/styles.d.ts +49 -40
- package/dist/hooks/useCrudMutation.d.ts +42 -0
- package/dist/index.cjs.js +22 -26
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +17425 -20672
- package/dist/telemetry/consoleEvents.d.ts +60 -0
- package/dist/utils/sha256.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/AppDialog.tsx +115 -0
- package/src/components/BackLink.tsx +83 -0
- package/src/components/Connections/AddConnectionDialog.tsx +50 -70
- package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
- package/src/components/Connections/EditConnectionDialog.tsx +54 -73
- package/src/components/Dashboard/DashboardBar.tsx +88 -0
- package/src/components/Dashboard/telemetry.ts +10 -3
- package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +184 -171
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
- package/src/components/DashboardBuilder/DashboardEditor.tsx +135 -61
- package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
- package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
- package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
- package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
- package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
- package/src/components/DashboardBuilder/newDashboard.ts +48 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
- package/src/components/Environment/About.tsx +14 -28
- package/src/components/Environment/AddPackageDialog.tsx +85 -154
- package/src/components/Environment/Connections.tsx +125 -205
- package/src/components/Environment/DeletePackageDialog.tsx +32 -77
- package/src/components/Environment/EditPackageDialog.tsx +46 -58
- package/src/components/Environment/Environment.tsx +34 -36
- package/src/components/Environment/Packages.tsx +63 -128
- package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
- package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
- package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
- package/src/components/Home/Home.tsx +101 -214
- package/src/components/ItemRow.tsx +165 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
- package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
- package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
- package/src/components/Materializations/Materializations.tsx +137 -140
- package/src/components/Materializations/ScopeButton.tsx +85 -0
- package/src/components/Materializations/SectionLabel.tsx +7 -4
- package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
- package/src/components/Materializations/TriggerLabel.tsx +36 -0
- package/src/components/Materializations/cron.spec.ts +113 -0
- package/src/components/Materializations/index.ts +0 -1
- package/src/components/Materializations/utils.spec.ts +182 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
- package/src/components/Package/ContentTypeIcon.tsx +10 -12
- package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
- package/src/components/Package/NewDashboardDialog.tsx +265 -0
- package/src/components/Package/Package.tsx +179 -238
- package/src/components/Package/index.ts +0 -1
- package/src/components/PackageSection.tsx +85 -0
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
- package/src/components/RenderedResult/RenderedResult.tsx +22 -8
- package/src/components/ResultsDialog.tsx +8 -32
- package/src/components/buttons.tsx +114 -0
- package/src/components/designSystem.spec.tsx +316 -0
- package/src/components/given/paramCodec.spec.ts +1 -1
- package/src/components/index.ts +10 -0
- package/src/components/styles.ts +49 -85
- package/src/hooks/useCrudMutation.spec.tsx +119 -0
- package/src/hooks/useCrudMutation.tsx +85 -0
- package/src/index.ts +9 -0
- package/src/telemetry/consoleEvents.spec.ts +130 -0
- package/src/telemetry/consoleEvents.ts +124 -0
- package/src/theme/defaults.ts +34 -23
- package/src/theme/resolveTheme.spec.ts +9 -4
- package/src/theme/resolveTheme.ts +12 -8
- package/src/utils/sha256.ts +13 -0
- package/test/README.md +1 -1
- package/test/serverProvider.tsx +5 -2
- package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
- package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
- package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
- package/dist/components/Materializations/TriggerChip.d.ts +0 -10
- package/dist/components/Package/Models.d.ts +0 -6
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
- package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
- package/src/components/Materializations/ScheduleCard.tsx +0 -231
- package/src/components/Materializations/TriggerChip.tsx +0 -44
- package/src/components/Package/Models.tsx +0 -71
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as L } from "react/jsx-runtime";
|
|
2
2
|
import { Box as oe, useTheme as ce } from "@mui/material";
|
|
3
3
|
import { Suspense as ue, useRef as z, useCallback as he, useMemo as me, useEffect as fe, useLayoutEffect as be } from "react";
|
|
4
|
-
import { D as ye, r as K, b as pe, a as ve, m as ge, c as we, d as ae } from "./DocumentStorageProvider-
|
|
5
|
-
import { aD as ke, aE as Ce, aF as xe } from "./ServerProvider-
|
|
4
|
+
import { D as ye, r as K, b as pe, a as ve, m as ge, c as we, d as ae } from "./DocumentStorageProvider-CyOJ0hqf.es.js";
|
|
5
|
+
import { aD as ke, aE as Ce, aF as xe } from "./ServerProvider-BWOEKg0O.es.js";
|
|
6
6
|
const v = "publisher-drill";
|
|
7
7
|
function Re(e, r) {
|
|
8
8
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -36,8 +36,8 @@ function Ee(e, r) {
|
|
|
36
36
|
".column-cell.th"
|
|
37
37
|
)) {
|
|
38
38
|
if (!a(l)) continue;
|
|
39
|
-
const s = (l.textContent ?? "").replace(/\u200b/g, "").trim(),
|
|
40
|
-
|
|
39
|
+
const s = (l.textContent ?? "").replace(/\u200b/g, "").trim(), y = B(l);
|
|
40
|
+
y && r.has(s) && n.add(y);
|
|
41
41
|
}
|
|
42
42
|
if (n.size === 0) continue;
|
|
43
43
|
const o = /* @__PURE__ */ new Set();
|
|
@@ -52,13 +52,13 @@ function Ee(e, r) {
|
|
|
52
52
|
".column-cell.td"
|
|
53
53
|
)) {
|
|
54
54
|
if (!a(l)) continue;
|
|
55
|
-
const s = B(l),
|
|
56
|
-
if (s &&
|
|
55
|
+
const s = B(l), y = !l.querySelector(".value-null") && (l.textContent ?? "").trim() !== "";
|
|
56
|
+
if (s && y && n.has(s) && !l.querySelector(".malloy-table")) {
|
|
57
57
|
if (l.classList.add(v), l.tabIndex === 0)
|
|
58
58
|
o.add(s);
|
|
59
59
|
else {
|
|
60
|
-
const
|
|
61
|
-
|
|
60
|
+
const h = o.has(s);
|
|
61
|
+
h || o.add(s), l.tabIndex = h ? -1 : 0;
|
|
62
62
|
}
|
|
63
63
|
l.setAttribute("role", "button");
|
|
64
64
|
}
|
|
@@ -138,10 +138,10 @@ function Oe(e) {
|
|
|
138
138
|
const o = {}, l = a.textArray("series");
|
|
139
139
|
l && l.length > 0 && (o.series = l);
|
|
140
140
|
for (const s of ke) {
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
144
|
-
g && (
|
|
141
|
+
const y = a.tag(s);
|
|
142
|
+
if (!y) continue;
|
|
143
|
+
const h = {}, g = y.text("light"), x = y.text("dark");
|
|
144
|
+
g && (h.light = g), x && (h.dark = x), Object.keys(h).length > 0 && (o[s] = h);
|
|
145
145
|
}
|
|
146
146
|
Object.keys(o).length > 0 && (t.palette = o);
|
|
147
147
|
}
|
|
@@ -332,11 +332,11 @@ function Be({
|
|
|
332
332
|
}) {
|
|
333
333
|
const o = z(null), l = z(t);
|
|
334
334
|
l.current = t;
|
|
335
|
-
const s = he((
|
|
336
|
-
l.current?.onClick(
|
|
337
|
-
}, []),
|
|
335
|
+
const s = he((c) => {
|
|
336
|
+
l.current?.onClick(c);
|
|
337
|
+
}, []), y = t !== void 0, h = z(!1), g = z(
|
|
338
338
|
null
|
|
339
|
-
),
|
|
339
|
+
), x = z(0), { theme: G, layers: U, mode: X } = Ce(), Y = ce().shape.borderRadius, J = me(
|
|
340
340
|
() => ({
|
|
341
341
|
radius: `${Y}px`,
|
|
342
342
|
padding: `${ye}px`
|
|
@@ -344,54 +344,56 @@ function Be({
|
|
|
344
344
|
[Y]
|
|
345
345
|
);
|
|
346
346
|
return fe(() => () => {
|
|
347
|
-
|
|
347
|
+
x.current += 1;
|
|
348
|
+
const c = g.current;
|
|
349
|
+
c?.viz.remove(), c?.node.remove(), g.current = null;
|
|
348
350
|
}, []), be(() => {
|
|
349
351
|
if (!o.current || !e) return;
|
|
350
352
|
Le();
|
|
351
|
-
const
|
|
353
|
+
const c = o.current, ie = x.current += 1;
|
|
352
354
|
let P = !1;
|
|
353
|
-
const j = () => !P && ie ===
|
|
354
|
-
let d, m, M = null, V = 0, I = null, N = null, $ = null, O = null, F = null, T = null, W = null, Q = 0,
|
|
355
|
-
|
|
356
|
-
let p,
|
|
355
|
+
const j = () => !P && ie === x.current;
|
|
356
|
+
let d, m, M = null, V = 0, I = null, N = null, $ = null, O = null, F = null, T = null, W = null, Q = 0, R = null;
|
|
357
|
+
h.current = !1;
|
|
358
|
+
let p, E;
|
|
357
359
|
const q = (w) => {
|
|
358
|
-
if (P || !w.firstElementChild || K(p,
|
|
359
|
-
const _ = ve(p,
|
|
360
|
-
if (
|
|
361
|
-
const
|
|
360
|
+
if (P || !w.firstElementChild || K(p, E) === "container") return;
|
|
361
|
+
const _ = ve(p, E);
|
|
362
|
+
if (h.current && !_) return;
|
|
363
|
+
const k = ge(
|
|
362
364
|
w,
|
|
363
365
|
ae(p)
|
|
364
366
|
);
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
_ &&
|
|
367
|
+
k > 0 && (h.current = !0, a && k !== Q && (Q = k, a(k)));
|
|
368
|
+
const S = we(w, ae(p));
|
|
369
|
+
_ && S && W !== S && (W = S, T?.disconnect(), T = new ResizeObserver(() => q(w)), T.observe(S));
|
|
368
370
|
};
|
|
369
371
|
return (async () => {
|
|
370
372
|
let w;
|
|
371
373
|
try {
|
|
372
374
|
w = JSON.parse(e);
|
|
373
|
-
} catch (
|
|
374
|
-
console.error("Error parsing visualization result:",
|
|
375
|
+
} catch (b) {
|
|
376
|
+
console.error("Error parsing visualization result:", b);
|
|
375
377
|
return;
|
|
376
378
|
}
|
|
377
|
-
const _ = await Te(w),
|
|
379
|
+
const _ = await Te(w), k = _ ? xe([...U, _], X) : G;
|
|
378
380
|
if (!j()) return;
|
|
379
381
|
try {
|
|
380
|
-
m = await Fe(
|
|
381
|
-
} catch (
|
|
382
|
-
console.error("Failed to create renderer:",
|
|
382
|
+
m = await Fe(k, s);
|
|
383
|
+
} catch (b) {
|
|
384
|
+
console.error("Failed to create renderer:", b);
|
|
383
385
|
return;
|
|
384
386
|
}
|
|
385
387
|
if (!j()) {
|
|
386
388
|
m.remove(), m = void 0;
|
|
387
389
|
return;
|
|
388
390
|
}
|
|
389
|
-
const
|
|
390
|
-
d = document.createElement("div"), d.style.width = "100%", d.style.height = "100%", _e(d,
|
|
391
|
-
const
|
|
391
|
+
const S = g.current;
|
|
392
|
+
d = document.createElement("div"), d.style.width = "100%", d.style.height = "100%", _e(d, k, J), c.childElementCount > 0 && (c.style.position = "relative", d.style.position = "absolute", d.style.inset = "0", d.style.visibility = "hidden"), c.appendChild(d);
|
|
393
|
+
const u = d;
|
|
392
394
|
O = new MutationObserver(() => {
|
|
393
395
|
F && clearTimeout(F), F = setTimeout(() => {
|
|
394
|
-
q(
|
|
396
|
+
q(u), h.current && O?.disconnect();
|
|
395
397
|
}, 100);
|
|
396
398
|
}), O.observe(d, {
|
|
397
399
|
childList: !0,
|
|
@@ -401,23 +403,28 @@ function Be({
|
|
|
401
403
|
const se = m;
|
|
402
404
|
let Z = !1;
|
|
403
405
|
const ee = () => {
|
|
404
|
-
|
|
406
|
+
if (!(Z || !j())) {
|
|
407
|
+
Z = !0, R && (clearTimeout(R), R = null), S?.viz.remove();
|
|
408
|
+
for (const b of Array.from(c.children))
|
|
409
|
+
b !== u && c.removeChild(b);
|
|
410
|
+
u.style.position = "", u.style.inset = "", u.style.visibility = "", c.style.position = "", g.current = { viz: se, node: u }, q(u);
|
|
411
|
+
}
|
|
405
412
|
};
|
|
406
413
|
try {
|
|
407
414
|
m.setResult(w);
|
|
408
415
|
try {
|
|
409
|
-
const
|
|
410
|
-
p = A?.renderAs(),
|
|
416
|
+
const C = m.getMetadata(), A = C?.getRootField();
|
|
417
|
+
p = A?.renderAs(), E = A ? C?.getPluginsForField(A.key)?.[0]?.sizingStrategy : void 0;
|
|
411
418
|
} catch {
|
|
412
|
-
p = void 0,
|
|
419
|
+
p = void 0, E = void 0;
|
|
413
420
|
}
|
|
414
|
-
n?.(K(p,
|
|
415
|
-
const
|
|
421
|
+
n?.(K(p, E)), d.dataset.malloyRenderAs = p ?? "unknown", d.dataset.malloySizing = K(p, E), m.render(d);
|
|
422
|
+
const b = l.current;
|
|
416
423
|
try {
|
|
417
|
-
if (
|
|
418
|
-
const
|
|
424
|
+
if (b) {
|
|
425
|
+
const C = Re(m, b.canDrill), A = () => {
|
|
419
426
|
try {
|
|
420
|
-
Ee(
|
|
427
|
+
Ee(u, C);
|
|
421
428
|
} catch (i) {
|
|
422
429
|
console.warn("Drill affordance skipped:", i);
|
|
423
430
|
}
|
|
@@ -453,27 +460,27 @@ function Be({
|
|
|
453
460
|
}, $ = (i) => {
|
|
454
461
|
const f = i.target?.closest?.(`.${v}`);
|
|
455
462
|
f && ne(f, 0);
|
|
456
|
-
},
|
|
463
|
+
}, u.addEventListener("keydown", I), u.addEventListener("keyup", N), u.addEventListener("focusin", $), C.size > 0 && typeof MutationObserver < "u" && (M = new MutationObserver(() => {
|
|
457
464
|
cancelAnimationFrame(V), V = requestAnimationFrame(A);
|
|
458
|
-
}), M.observe(
|
|
465
|
+
}), M.observe(u, {
|
|
459
466
|
childList: !0,
|
|
460
467
|
subtree: !0
|
|
461
468
|
}));
|
|
462
469
|
}
|
|
463
|
-
} catch (
|
|
464
|
-
console.warn("Drill affordance skipped:",
|
|
470
|
+
} catch (C) {
|
|
471
|
+
console.warn("Drill affordance skipped:", C);
|
|
465
472
|
}
|
|
466
|
-
m.onReady(ee),
|
|
467
|
-
} catch (
|
|
468
|
-
console.error("Error rendering visualization:",
|
|
473
|
+
m.onReady(ee), R = setTimeout(ee, 1e4);
|
|
474
|
+
} catch (b) {
|
|
475
|
+
console.error("Error rendering visualization:", b), O?.disconnect(), T?.disconnect(), M?.disconnect(), m.remove(), m = void 0, u.parentNode === c && c.removeChild(u);
|
|
469
476
|
}
|
|
470
477
|
})(), () => {
|
|
471
|
-
P = !0, O?.disconnect(), T?.disconnect(), F && clearTimeout(F),
|
|
478
|
+
P = !0, O?.disconnect(), T?.disconnect(), F && clearTimeout(F), R && clearTimeout(R), d && g.current?.node !== d && (I && d.removeEventListener("keydown", I), N && d.removeEventListener("keyup", N), $ && d.removeEventListener("focusin", $), M?.disconnect(), cancelAnimationFrame(V), m?.remove(), d.parentNode === c && c.removeChild(d), c.style.position = "");
|
|
472
479
|
};
|
|
473
480
|
}, [
|
|
474
481
|
e,
|
|
475
482
|
s,
|
|
476
|
-
|
|
483
|
+
y,
|
|
477
484
|
a,
|
|
478
485
|
n,
|
|
479
486
|
G,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ve=Object.create;var le=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var ve=Object.create;var le=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Ce=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of we(r))!Re.call(e,o)&&o!==t&&le(e,o,{get:()=>r[o],enumerable:!(n=ge(r,o))||n.enumerable});return e};var G=(e,r,t)=>(t=e!=null?ve(ke(e)):{},Ce(r||!e||!e.__esModule?le(t,"default",{value:e,enumerable:!0}):t,e));const B=require("react/jsx-runtime"),U=require("@mui/material"),p=require("react"),v=require("./DocumentStorageProvider-DGPQEd_l.cjs.js"),X=require("./ServerProvider-Cc489A3f.cjs.js"),g="publisher-drill";function de(e,r){const t=new Set;let n;try{n=e.getMetadata()?.getAllFields()??[]}catch{return t}const o=new Set;for(const a of n)!a||r(a)||a.tag?.tag("hidden")===void 0&&o.add(a.tag?.text("label")??a.name);for(const a of n){if(!a||!r(a))continue;const l=a.tag?.text("label")??a.name;o.has(l)||t.add(l)}return t}function M(e){const r=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return r?r[1]:void 0}function ce(e,r){if(r.size!==0)for(const t of e.querySelectorAll(".malloy-table")){const n=l=>l.closest(".malloy-table")===t,o=new Set;for(const l of t.querySelectorAll(".column-cell.th")){if(!n(l))continue;const s=(l.textContent??"").replace(/\u200b/g,"").trim(),y=M(l);y&&r.has(s)&&o.add(y)}if(o.size===0)continue;const a=new Set;for(const l of t.querySelectorAll(`.${g}[tabindex="0"]`)){if(!n(l))continue;const s=M(l);s&&(a.has(s)?l.tabIndex=-1:a.add(s))}for(const l of t.querySelectorAll(".column-cell.td")){if(!n(l))continue;const s=M(l),y=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(s&&y&&o.has(s)&&!l.querySelector(".malloy-table")){if(l.classList.add(g),l.tabIndex===0)a.add(s);else{const h=a.has(s);h||a.add(s),l.tabIndex=h?-1:0}l.setAttribute("role","button")}}}}function xe(e){const r=e.closest(".malloy-table"),t=M(e);return!r||!t?[]:Array.from(r.querySelectorAll(`.${g}`)).filter(n=>n.closest(".malloy-table")===r&&M(n)===t)}function ie(e,r){const t=xe(e),n=t.indexOf(e);if(n===-1)return;const o=r==="first"?t[0]:r==="last"?t[t.length-1]:t[Math.min(Math.max(n+r,0),t.length-1)];if(o){for(const a of t)a.tabIndex=a===o?0:-1;return o}}function ue(e){return{background:e.dashboardRoot,tableBackground:e.tableBackground,tableHeaderColor:e.tableHeader,tableBodyColor:e.tableBody,tableBorder:e.border,tablePinnedBackground:e.tableHeaderBackground,tablePinnedBorder:e.pinnedBorder,tableFontSize:`${e.font.size}px`,fontFamily:e.font.family,mapColor:e.mapColor}}function he(e){const{foreground:r,axisFaint:t,font:n}=e,o={background:e.background,font:n.family,title:{color:r,font:n.family},axis:{labelColor:r,titleColor:r,domainColor:t,tickColor:t,gridColor:t,labelFont:n.family,titleFont:n.family},legend:{labelColor:r,titleColor:r,labelFont:n.family,titleFont:n.family},header:{labelColor:r,titleColor:r},range:{category:e.series}};return a=>o}function me(e){if(!e)return;const r=e.tag("theme");if(!r)return;const t={},n=r.tag("palette");if(n){const a={},l=n.textArray("series");l&&l.length>0&&(a.series=l);for(const s of X.PER_MODE_COLOR_KEYS){const y=n.tag(s);if(!y)continue;const h={},k=y.text("light"),E=y.text("dark");k&&(h.light=k),E&&(h.dark=E),Object.keys(h).length>0&&(a[s]=h)}Object.keys(a).length>0&&(t.palette=a)}const o=r.tag("font");if(o){const a={},l=o.text("family");l&&(a.family=l);const s=o.numeric("size");typeof s=="number"&&Number.isFinite(s)&&(a.size=s),Object.keys(a).length>0&&(t.font=a)}return Object.keys(t).length>0?t:void 0}const Ee=async(e,r)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:t}=await import("@malloydata/render");return new t({onClick:r,vegaConfigOverride:he(e),theme:ue(e),onError:o=>{console.error("Error rendering visualization:",typeof o,o)}}).createViz()};typeof window<"u"&&import("@malloydata/render");async function Se(e){if(!e||typeof e!="object")return;const r=e,t=[...Array.isArray(r.model_annotations)?r.model_annotations:[],...Array.isArray(r.source_annotations)?r.source_annotations:[],...Array.isArray(r.annotations)?r.annotations:[]].map(o=>typeof o?.value=="string"?o.value:void 0).filter(o=>!!o);if(t.length===0)return;let n;try{({parseAnnotation:n}=await import("@malloydata/malloy-tag"))}catch{return}try{const{tag:o}=n(t);return me(o)}catch(o){console.warn("Failed to parse # theme.* annotations; chart will render with the shell theme.",{error:o,lines:t});return}}function Ae(e,r,t){const n=v.buildTableCssVars(r,t);for(const[o,a]of Object.entries(n))e.style.setProperty(o,a)}const De=`
|
|
2
2
|
/* Card geometry, through the renderer's OWN theme vars rather than over the top
|
|
3
3
|
of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
|
|
4
4
|
passes each through to the --malloy-render--* the card CSS reads, so a value
|
|
@@ -112,4 +112,4 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
|
|
|
112
112
|
color: var(--publisher-drill-link) !important;
|
|
113
113
|
text-decoration: underline;
|
|
114
114
|
}
|
|
115
|
-
`,se="publisher-malloy-renderer-overrides";function Oe(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,e.textContent=De,document.head.appendChild(e)}function Te({result:e,height:r,drill:t,onSizeChange:n,onSizing:o}){const a=p.useRef(null),l=p.useRef(t);l.current=t;const s=p.useCallback(
|
|
115
|
+
`,se="publisher-malloy-renderer-overrides";function Oe(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,e.textContent=De,document.head.appendChild(e)}function Te({result:e,height:r,drill:t,onSizeChange:n,onSizing:o}){const a=p.useRef(null),l=p.useRef(t);l.current=t;const s=p.useCallback(c=>{l.current?.onClick(c)},[]),y=t!==void 0,h=p.useRef(!1),k=p.useRef(null),E=p.useRef(0),{theme:Y,layers:J,mode:W}=X.usePublisherTheme(),Q=U.useTheme().shape.borderRadius,Z=p.useMemo(()=>({radius:`${Q}px`,padding:`${v.DASHBOARD_CARD_PADDING_PX}px`}),[Q]);return p.useEffect(()=>()=>{E.current+=1;const c=k.current;c?.viz.remove(),c?.node.remove(),k.current=null},[]),p.useLayoutEffect(()=>{if(!a.current||!e)return;Oe();const c=a.current,fe=E.current+=1;let P=!1;const q=()=>!P&&fe===E.current;let d,m,I=null,V=0,N=null,j=null,$=null,L=null,_=null,z=null,ee=null,re=0,S=null;h.current=!1;let w,A;const H=R=>{if(P||!R.firstElementChild||v.resultSizing(w,A)==="container")return;const F=v.remeasuresAfterReady(w,A);if(h.current&&!F)return;const C=v.measureContentHeight(R,v.contentNodeDepth(w));C>0&&(h.current=!0,n&&C!==re&&(re=C,n(C)));const D=v.contentNode(R,v.contentNodeDepth(w));F&&D&&ee!==D&&(ee=D,z?.disconnect(),z=new ResizeObserver(()=>H(R)),z.observe(D))};return(async()=>{let R;try{R=JSON.parse(e)}catch(f){console.error("Error parsing visualization result:",f);return}const F=await Se(R),C=F?X.resolveTheme([...J,F],W):Y;if(!q())return;try{m=await Ee(C,s)}catch(f){console.error("Failed to create renderer:",f);return}if(!q()){m.remove(),m=void 0;return}const D=k.current;d=document.createElement("div"),d.style.width="100%",d.style.height="100%",Ae(d,C,Z),c.childElementCount>0&&(c.style.position="relative",d.style.position="absolute",d.style.inset="0",d.style.visibility="hidden"),c.appendChild(d);const u=d;L=new MutationObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{H(u),h.current&&L?.disconnect()},100)}),L.observe(d,{childList:!0,subtree:!0,attributes:!0});const ye=m;let te=!1;const oe=()=>{if(!(te||!q())){te=!0,S&&(clearTimeout(S),S=null),D?.viz.remove();for(const f of Array.from(c.children))f!==u&&c.removeChild(f);u.style.position="",u.style.inset="",u.style.visibility="",c.style.position="",k.current={viz:ye,node:u},H(u)}};try{m.setResult(R);try{const x=m.getMetadata(),O=x?.getRootField();w=O?.renderAs(),A=O?x?.getPluginsForField(O.key)?.[0]?.sizingStrategy:void 0}catch{w=void 0,A=void 0}o?.(v.resultSizing(w,A)),d.dataset.malloyRenderAs=w??"unknown",d.dataset.malloySizing=v.resultSizing(w,A),m.render(d);const f=l.current;try{if(f){const x=de(m,f.canDrill),O=()=>{try{ce(u,x)}catch(i){console.warn("Drill affordance skipped:",i)}};O();const ne=i=>{const T=i.querySelector(".cell-content")??i,K=T.getBoundingClientRect();T.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:T.ownerDocument.defaultView,clientX:Math.round(K.left+K.width/2),clientY:Math.round(K.bottom)}))},ae=i=>i.target?.closest?.(`.${g}`)??null,pe=(i,b)=>{ie(i,b)?.focus()};N=i=>{const b=ae(i);if(!b)return;const T=i.key==="ArrowDown"?1:i.key==="ArrowUp"?-1:i.key==="Home"?"first":i.key==="End"?"last":void 0;if(T!==void 0){i.preventDefault(),pe(b,T);return}i.key==="Enter"?(i.preventDefault(),ne(b)):i.key===" "&&i.preventDefault()},j=i=>{if(i.key!==" ")return;const b=ae(i);b&&(i.preventDefault(),ne(b))},$=i=>{const b=i.target?.closest?.(`.${g}`);b&&ie(b,0)},u.addEventListener("keydown",N),u.addEventListener("keyup",j),u.addEventListener("focusin",$),x.size>0&&typeof MutationObserver<"u"&&(I=new MutationObserver(()=>{cancelAnimationFrame(V),V=requestAnimationFrame(O)}),I.observe(u,{childList:!0,subtree:!0}))}}catch(x){console.warn("Drill affordance skipped:",x)}m.onReady(oe),S=setTimeout(oe,1e4)}catch(f){console.error("Error rendering visualization:",f),L?.disconnect(),z?.disconnect(),I?.disconnect(),m.remove(),m=void 0,u.parentNode===c&&c.removeChild(u)}})(),()=>{P=!0,L?.disconnect(),z?.disconnect(),_&&clearTimeout(_),S&&clearTimeout(S),d&&k.current?.node!==d&&(N&&d.removeEventListener("keydown",N),j&&d.removeEventListener("keyup",j),$&&d.removeEventListener("focusin",$),I?.disconnect(),cancelAnimationFrame(V),m?.remove(),d.parentNode===c&&c.removeChild(d),c.style.position="")}},[e,s,y,n,o,Y,J,W,Z]),B.jsx("div",{ref:a,style:{width:"100%",height:r?`${r}px`:"400px"}})}function be(e){return typeof window>"u"?B.jsx(U.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):B.jsx(p.Suspense,{fallback:B.jsx(U.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:B.jsx(Te,{...e})})}const Le=Object.freeze(Object.defineProperty({__proto__:null,default:be},Symbol.toStringTag,{value:"Module"}));exports.DRILL_CELL_CLASS=g;exports.RenderedResult=be;exports.RenderedResult$1=Le;exports.buildMalloyExplicitTheme=ue;exports.buildVegaThemeOverride=he;exports.drillableFieldNames=de;exports.markDrillableCells=ce;exports.readChartAnnotations=me;
|