@malloy-publisher/sdk 0.9.4 → 0.9.5
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-DwB0-9Yx.es.js → RenderedResult-BUb2Xvr2.es.js} +34 -19
- package/dist/{RenderedResult-hKjFEqaN.cjs.js → RenderedResult-qnpbr4tc.cjs.js} +15 -3
- package/dist/{ServerProvider-CcSrGaRN.es.js → ServerProvider-C6QQVKPm.es.js} +149 -141
- package/dist/ServerProvider-Gj-im5VD.cjs.js +1 -0
- package/dist/builder/index.cjs.js +82 -82
- package/dist/builder/index.es.js +3242 -3188
- package/dist/client/api.d.ts +49 -10
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +57 -56
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -5
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +3 -1
- package/dist/components/DashboardBuilder/addTileToDocument.d.ts +14 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +5 -1
- package/dist/components/DashboardBuilder/imports.d.ts +11 -12
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +3 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +5 -5
- package/dist/theme/buildVegaThemeOverride.d.ts +7 -3
- package/dist/{useCompiledDocument-BU6d8FPp.es.js → useCompiledDocument-0sxonf6N.es.js} +3707 -3686
- package/dist/{useCompiledDocument-pOg2W-Yt.cjs.js → useCompiledDocument-tBejqZ7s.cjs.js} +31 -31
- package/package.json +2 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -11
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +13 -5
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +5 -0
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +3 -0
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +3 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +10 -2
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +79 -3
- package/src/components/DashboardBuilder/EditorSurface.tsx +30 -2
- package/src/components/DashboardBuilder/addTile.compile.spec.ts +184 -0
- package/src/components/DashboardBuilder/addTileToDocument.spec.ts +58 -0
- package/src/components/DashboardBuilder/addTileToDocument.ts +64 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +1 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +79 -3
- package/src/components/DashboardBuilder/catalog.ts +23 -5
- package/src/components/DashboardBuilder/imports.spec.ts +56 -0
- package/src/components/DashboardBuilder/imports.ts +16 -13
- package/src/components/DashboardBuilder/preview.spec.ts +21 -0
- package/src/components/DashboardBuilder/preview.ts +10 -1
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +24 -9
- package/src/components/DashboardBuilder/spliceDocument.ts +18 -6
- package/src/components/DashboardBuilder/useDashboardEditor.ts +6 -2
- package/src/components/DashboardBuilder/useTileEditing.ts +13 -48
- package/src/components/RenderedResult/RenderedResult.tsx +12 -0
- package/src/components/given/GivenInput.tsx +39 -16
- package/src/components/given/utils.spec.ts +5 -0
- package/src/components/given/utils.ts +1 -1
- package/src/theme/buildVegaThemeOverride.spec.ts +11 -1
- package/src/theme/buildVegaThemeOverride.ts +10 -3
- package/src/timezone_runs.spec.ts +64 -0
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as L } from "react/jsx-runtime";
|
|
2
2
|
import { Box as ne, useTheme as he } from "@mui/material";
|
|
3
|
-
import { Suspense as me, useRef as
|
|
4
|
-
import { D as ge, r as U, l as ve, a as we, b as ke, c as xe, m as Ce, d as Re, e as le } from "./useCompiledDocument-
|
|
5
|
-
import {
|
|
3
|
+
import { Suspense as me, useRef as F, useCallback as be, useMemo as fe, useEffect as ye, useLayoutEffect as pe } from "react";
|
|
4
|
+
import { D as ge, r as U, l as ve, a as we, b as ke, c as xe, m as Ce, d as Re, e as le } from "./useCompiledDocument-0sxonf6N.es.js";
|
|
5
|
+
import { aN as Ee, aL as Se, aO as Ae } from "./ServerProvider-C6QQVKPm.es.js";
|
|
6
6
|
const g = "publisher-drill";
|
|
7
7
|
function Te(e, r) {
|
|
8
8
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -104,7 +104,7 @@ function _e(e) {
|
|
|
104
104
|
mapColor: e.mapColor
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function ze(e) {
|
|
108
108
|
const { foreground: r, axisFaint: t, gridline: l, font: o } = e, a = {
|
|
109
109
|
background: e.background,
|
|
110
110
|
font: o.family,
|
|
@@ -126,10 +126,13 @@ function Fe(e) {
|
|
|
126
126
|
},
|
|
127
127
|
header: { labelColor: r, titleColor: r },
|
|
128
128
|
range: { category: e.series }
|
|
129
|
+
}, n = {
|
|
130
|
+
...a,
|
|
131
|
+
legend: { ...a.legend, orient: "bottom" }
|
|
129
132
|
};
|
|
130
|
-
return (
|
|
133
|
+
return (s) => s === "shape_map" ? n : a;
|
|
131
134
|
}
|
|
132
|
-
function
|
|
135
|
+
function Fe(e) {
|
|
133
136
|
if (!e) return;
|
|
134
137
|
const r = e.tag("theme");
|
|
135
138
|
if (!r) return;
|
|
@@ -160,7 +163,7 @@ const M = "data-publisher-fill", Le = async (e, r) => {
|
|
|
160
163
|
const { MalloyRenderer: t } = await we();
|
|
161
164
|
return new t({
|
|
162
165
|
onClick: r,
|
|
163
|
-
vegaConfigOverride:
|
|
166
|
+
vegaConfigOverride: ze(e),
|
|
164
167
|
// Pass the explicit theme so table chrome and dashboard tiles
|
|
165
168
|
// pick up the operator's colours directly. Without this the
|
|
166
169
|
// renderer's own inline style writes `--malloy-render--*` values
|
|
@@ -188,7 +191,7 @@ async function Me(e) {
|
|
|
188
191
|
}
|
|
189
192
|
try {
|
|
190
193
|
const { tag: o } = l(t);
|
|
191
|
-
return
|
|
194
|
+
return Fe(o);
|
|
192
195
|
} catch (o) {
|
|
193
196
|
console.warn(
|
|
194
197
|
"Failed to parse # theme.* annotations; chart will render with the shell theme.",
|
|
@@ -284,6 +287,18 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
|
|
|
284
287
|
the border's job, and the border is already doing it. */
|
|
285
288
|
box-shadow: none !important;
|
|
286
289
|
}
|
|
290
|
+
/* The strip of big-value cards as a grid, so cards share a width and the last one does not wrap
|
|
291
|
+
alone. The renderer's wrapping flex row sizes each card to its own text. The 250px floor is the
|
|
292
|
+
widest realistic value: it is nowrap at 32px in an overflow:visible card, so a narrower track
|
|
293
|
+
would spill it onto its neighbour. Embedded (a nested big_value) is left as the renderer draws it. */
|
|
294
|
+
.malloy-render .malloy-big-value:not(.malloy-big-value--embedded) {
|
|
295
|
+
display: grid;
|
|
296
|
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
297
|
+
}
|
|
298
|
+
.malloy-render .malloy-big-value-card:not(.malloy-big-value-card--embedded) {
|
|
299
|
+
width: auto;
|
|
300
|
+
max-width: none;
|
|
301
|
+
}
|
|
287
302
|
.malloy-render .malloy-dashboard .dashboard-row-header-separator {
|
|
288
303
|
background: var(--malloy-render--table-border) !important;
|
|
289
304
|
}
|
|
@@ -356,13 +371,13 @@ function $e({
|
|
|
356
371
|
onSizing: o,
|
|
357
372
|
fill: a
|
|
358
373
|
}) {
|
|
359
|
-
const n =
|
|
374
|
+
const n = F(null), s = F(t);
|
|
360
375
|
s.current = t;
|
|
361
376
|
const b = be((c) => {
|
|
362
377
|
s.current?.onClick(c);
|
|
363
|
-
}, []), y = t !== void 0, k =
|
|
378
|
+
}, []), y = t !== void 0, k = F(!1), v = F(
|
|
364
379
|
null
|
|
365
|
-
), P =
|
|
380
|
+
), P = F(0), { theme: X, layers: Y, mode: J } = Se(), W = he().shape.borderRadius, Q = fe(
|
|
366
381
|
() => ({
|
|
367
382
|
radius: `${W}px`,
|
|
368
383
|
padding: `${ge}px`
|
|
@@ -386,13 +401,13 @@ function $e({
|
|
|
386
401
|
if (V || !w.firstElementChild || U(p, R) === "container") return;
|
|
387
402
|
const _ = xe(p, R);
|
|
388
403
|
if (k.current && !_) return;
|
|
389
|
-
const
|
|
390
|
-
|
|
404
|
+
const z = c.hasAttribute(M);
|
|
405
|
+
z && c.removeAttribute(M);
|
|
391
406
|
const E = Ce(
|
|
392
407
|
w,
|
|
393
408
|
le(p)
|
|
394
409
|
);
|
|
395
|
-
|
|
410
|
+
z && c.setAttribute(M, ""), E > 0 && (k.current = !0, l && E !== ee && (ee = E, l(E)));
|
|
396
411
|
const u = Re(w, le(p));
|
|
397
412
|
_ && u && Z !== u && (Z = u, O?.disconnect(), O = new ResizeObserver(() => K(w)), O.observe(u));
|
|
398
413
|
};
|
|
@@ -404,10 +419,10 @@ function $e({
|
|
|
404
419
|
console.error("Error parsing visualization result:", f);
|
|
405
420
|
return;
|
|
406
421
|
}
|
|
407
|
-
const _ = await Me(w),
|
|
422
|
+
const _ = await Me(w), z = _ ? Ae([...Y, _], J) : X;
|
|
408
423
|
if (!q()) return;
|
|
409
424
|
try {
|
|
410
|
-
h = await Le(
|
|
425
|
+
h = await Le(z, b);
|
|
411
426
|
} catch (f) {
|
|
412
427
|
console.error("Failed to create renderer:", f);
|
|
413
428
|
return;
|
|
@@ -417,7 +432,7 @@ function $e({
|
|
|
417
432
|
return;
|
|
418
433
|
}
|
|
419
434
|
const E = v.current;
|
|
420
|
-
d = document.createElement("div"), d.style.width = "100%", d.style.height = "100%", Ie(d,
|
|
435
|
+
d = document.createElement("div"), d.style.width = "100%", d.style.height = "100%", Ie(d, z, Q), c.childElementCount > 0 && (c.style.position = "relative", d.style.position = "absolute", d.style.inset = "0", d.style.visibility = "hidden"), c.appendChild(d);
|
|
421
436
|
const u = d;
|
|
422
437
|
T = new MutationObserver(() => {
|
|
423
438
|
D && clearTimeout(D), D = setTimeout(() => {
|
|
@@ -569,10 +584,10 @@ const Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
569
584
|
export {
|
|
570
585
|
g as D,
|
|
571
586
|
je as R,
|
|
572
|
-
|
|
587
|
+
ze as a,
|
|
573
588
|
_e as b,
|
|
574
589
|
Ge as c,
|
|
575
590
|
Te as d,
|
|
576
591
|
De as m,
|
|
577
|
-
|
|
592
|
+
Fe as r
|
|
578
593
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const M=require("react/jsx-runtime"),X=require("@mui/material"),p=require("react"),b=require("./useCompiledDocument-tBejqZ7s.cjs.js"),Y=require("./ServerProvider-Gj-im5VD.cjs.js"),g="publisher-drill";function de(e,r){const t=new Set;let l;try{l=e.getMetadata()?.getAllFields()??[]}catch{return t}const o=new Set;for(const a of l)!a||r(a)||a.tag?.tag("hidden")===void 0&&o.add(a.tag?.text("label")??a.name);for(const a of l){if(!a||!r(a))continue;const n=a.tag?.text("label")??a.name;o.has(n)||t.add(n)}return t}function B(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 l=n=>n.closest(".malloy-table")===t,o=new Set;for(const n of t.querySelectorAll(".column-cell.th")){if(!l(n))continue;const s=(n.textContent??"").replace(/\u200b/g,"").trim(),f=B(n);f&&r.has(s)&&o.add(f)}if(o.size===0)continue;const a=new Set;for(const n of t.querySelectorAll(`.${g}[tabindex="0"]`)){if(!l(n))continue;const s=B(n);s&&(a.has(s)?n.tabIndex=-1:a.add(s))}for(const n of t.querySelectorAll(".column-cell.td")){if(!l(n))continue;const s=B(n),f=!n.querySelector(".value-null")&&(n.textContent??"").trim()!=="";if(s&&f&&o.has(s)&&!n.querySelector(".malloy-table")){if(n.classList.add(g),n.tabIndex===0)a.add(s);else{const v=a.has(s);v||a.add(s),n.tabIndex=v?-1:0}n.setAttribute("role","button")}}}}function ge(e){const r=e.closest(".malloy-table"),t=B(e);return!r||!t?[]:Array.from(r.querySelectorAll(`.${g}`)).filter(l=>l.closest(".malloy-table")===r&&B(l)===t)}function ie(e,r){const t=ge(e),l=t.indexOf(e);if(l===-1)return;const o=r==="first"?t[0]:r==="last"?t[t.length-1]:t[Math.min(Math.max(l+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,gridline:l,font:o}=e,a={background:e.background,font:o.family,title:{color:r,font:o.family},axis:{labelColor:r,titleColor:r,domainColor:t,tickColor:t,gridColor:l,labelFont:o.family,titleFont:o.family},legend:{labelColor:r,titleColor:r,labelFont:o.family,titleFont:o.family},header:{labelColor:r,titleColor:r},range:{category:e.series}},n={...a,legend:{...a.legend,orient:"bottom"}};return s=>s==="shape_map"?n:a}function me(e){if(!e)return;const r=e.tag("theme");if(!r)return;const t={},l=r.tag("palette");if(l){const a={},n=l.textArray("series");n&&n.length>0&&(a.series=n);for(const s of Y.PER_MODE_COLOR_KEYS){const f=l.tag(s);if(!f)continue;const v={},R=f.text("light"),k=f.text("dark");R&&(v.light=R),k&&(v.dark=k),Object.keys(v).length>0&&(a[s]=v)}Object.keys(a).length>0&&(t.palette=a)}const o=r.tag("font");if(o){const a={},n=o.text("family");n&&(a.family=n);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 I="data-publisher-fill",ve=async(e,r)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:t}=await b.loadMalloyRenderer();return new t({onClick:r,vegaConfigOverride:he(e),theme:ue(e),onError:o=>{console.error("Error rendering visualization:",typeof o,o)}}).createViz()};async function we(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 l;try{({parseAnnotation:l}=await b.loadMalloyTag())}catch{return}try{const{tag:o}=l(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 ke(e,r,t){const l=b.buildTableCssVars(r,t);for(const[o,a]of Object.entries(l))e.style.setProperty(o,a)}const xe=`
|
|
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
|
|
@@ -80,11 +80,23 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
|
|
|
80
80
|
the border's job, and the border is already doing it. */
|
|
81
81
|
box-shadow: none !important;
|
|
82
82
|
}
|
|
83
|
+
/* The strip of big-value cards as a grid, so cards share a width and the last one does not wrap
|
|
84
|
+
alone. The renderer's wrapping flex row sizes each card to its own text. The 250px floor is the
|
|
85
|
+
widest realistic value: it is nowrap at 32px in an overflow:visible card, so a narrower track
|
|
86
|
+
would spill it onto its neighbour. Embedded (a nested big_value) is left as the renderer draws it. */
|
|
87
|
+
.malloy-render .malloy-big-value:not(.malloy-big-value--embedded) {
|
|
88
|
+
display: grid;
|
|
89
|
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
90
|
+
}
|
|
91
|
+
.malloy-render .malloy-big-value-card:not(.malloy-big-value-card--embedded) {
|
|
92
|
+
width: auto;
|
|
93
|
+
max-width: none;
|
|
94
|
+
}
|
|
83
95
|
.malloy-render .malloy-dashboard .dashboard-row-header-separator {
|
|
84
96
|
background: var(--malloy-render--table-border) !important;
|
|
85
97
|
}
|
|
86
98
|
/* !important because the malloy-explorer stylesheet pins these same properties with it. */
|
|
87
|
-
[${
|
|
99
|
+
[${I}] .malloy-table.root {
|
|
88
100
|
height: 100% !important;
|
|
89
101
|
align-content: start !important;
|
|
90
102
|
grid-template-columns: repeat(var(--total-header-size), minmax(max-content, 1fr)) !important;
|
|
@@ -138,4 +150,4 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
|
|
|
138
150
|
color: var(--publisher-drill-link) !important;
|
|
139
151
|
text-decoration: underline;
|
|
140
152
|
}
|
|
141
|
-
`,se="publisher-malloy-renderer-overrides";function Re(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,e.textContent=xe,document.head.appendChild(e)}function Ce({result:e,height:r,drill:t,onSizeChange:l,onSizing:o,fill:a}){const n=p.useRef(null),s=p.useRef(t);s.current=t;const f=p.useCallback(c=>{s.current?.onClick(c)},[]),v=t!==void 0,R=p.useRef(!1),k=p.useRef(null),P=p.useRef(0),{theme:J,layers:W,mode:Q}=Y.usePublisherTheme(),Z=X.useTheme().shape.borderRadius,ee=p.useMemo(()=>({radius:`${Z}px`,padding:`${b.DASHBOARD_CARD_PADDING_PX}px`}),[Z]);return p.useEffect(()=>()=>{P.current+=1;const c=k.current;c?.viz.remove(),c?.node.remove(),k.current=null},[]),p.useLayoutEffect(()=>{if(!n.current||!e)return;Re();const c=n.current,fe=P.current+=1;let V=!1;const H=()=>!V&&fe===P.current;let d,h,j=null,K=0,N=null,$=null,q=null,O=null,
|
|
153
|
+
`,se="publisher-malloy-renderer-overrides";function Re(){if(typeof document>"u"||document.getElementById(se))return;const e=document.createElement("style");e.id=se,e.textContent=xe,document.head.appendChild(e)}function Ce({result:e,height:r,drill:t,onSizeChange:l,onSizing:o,fill:a}){const n=p.useRef(null),s=p.useRef(t);s.current=t;const f=p.useCallback(c=>{s.current?.onClick(c)},[]),v=t!==void 0,R=p.useRef(!1),k=p.useRef(null),P=p.useRef(0),{theme:J,layers:W,mode:Q}=Y.usePublisherTheme(),Z=X.useTheme().shape.borderRadius,ee=p.useMemo(()=>({radius:`${Z}px`,padding:`${b.DASHBOARD_CARD_PADDING_PX}px`}),[Z]);return p.useEffect(()=>()=>{P.current+=1;const c=k.current;c?.viz.remove(),c?.node.remove(),k.current=null},[]),p.useLayoutEffect(()=>{if(!n.current||!e)return;Re();const c=n.current,fe=P.current+=1;let V=!1;const H=()=>!V&&fe===P.current;let d,h,j=null,K=0,N=null,$=null,q=null,O=null,_=null,L=null,re=null,te=0,E=null;R.current=!1;let w,S;const G=x=>{if(V||!x.firstElementChild||b.resultSizing(w,S)==="container")return;const z=b.remeasuresAfterReady(w,S);if(R.current&&!z)return;const F=c.hasAttribute(I);F&&c.removeAttribute(I);const A=b.measureContentHeight(x,b.contentNodeDepth(w));F&&c.setAttribute(I,""),A>0&&(R.current=!0,l&&A!==te&&(te=A,l(A)));const u=b.contentNode(x,b.contentNodeDepth(w));z&&u&&re!==u&&(re=u,L?.disconnect(),L=new ResizeObserver(()=>G(x)),L.observe(u))};return(async()=>{let x;try{x=JSON.parse(e)}catch(y){console.error("Error parsing visualization result:",y);return}const z=await we(x),F=z?Y.resolveTheme([...W,z],Q):J;if(!H())return;try{h=await ve(F,f)}catch(y){console.error("Failed to create renderer:",y);return}if(!H()){h.remove(),h=void 0;return}const A=k.current;d=document.createElement("div"),d.style.width="100%",d.style.height="100%",ke(d,F,ee),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;O=new MutationObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{G(u),R.current&&O?.disconnect()},100)}),O.observe(d,{childList:!0,subtree:!0,attributes:!0});const ye=h;let oe=!1;const ae=()=>{if(!(oe||!H())){oe=!0,E&&(clearTimeout(E),E=null),A?.viz.remove();for(const y of Array.from(c.children))y!==u&&c.removeChild(y);u.style.position="",u.style.inset="",u.style.visibility="",c.style.position="",k.current={viz:ye,node:u},G(u)}};try{h.setResult(x);try{const C=h.getMetadata(),T=C?.getRootField();w=T?.renderAs(),S=T?C?.getPluginsForField(T.key)?.[0]?.sizingStrategy:void 0}catch{w=void 0,S=void 0}o?.(b.resultSizing(w,S)),d.dataset.malloyRenderAs=w??"unknown",d.dataset.malloySizing=b.resultSizing(w,S),h.render(d);const y=s.current;try{if(y){const C=de(h,y.canDrill),T=()=>{try{ce(u,C)}catch(i){console.warn("Drill affordance skipped:",i)}};T();const ne=i=>{const D=i.querySelector(".cell-content")??i,U=D.getBoundingClientRect();D.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:D.ownerDocument.defaultView,clientX:Math.round(U.left+U.width/2),clientY:Math.round(U.bottom)}))},le=i=>i.target?.closest?.(`.${g}`)??null,pe=(i,m)=>{ie(i,m)?.focus()};N=i=>{const m=le(i);if(!m)return;const D=i.key==="ArrowDown"?1:i.key==="ArrowUp"?-1:i.key==="Home"?"first":i.key==="End"?"last":void 0;if(D!==void 0){i.preventDefault(),pe(m,D);return}i.key==="Enter"?(i.preventDefault(),ne(m)):i.key===" "&&i.preventDefault()},$=i=>{if(i.key!==" ")return;const m=le(i);m&&(i.preventDefault(),ne(m))},q=i=>{const m=i.target?.closest?.(`.${g}`);m&&ie(m,0)},u.addEventListener("keydown",N),u.addEventListener("keyup",$),u.addEventListener("focusin",q),C.size>0&&typeof MutationObserver<"u"&&(j=new MutationObserver(()=>{cancelAnimationFrame(K),K=requestAnimationFrame(T)}),j.observe(u,{childList:!0,subtree:!0}))}}catch(C){console.warn("Drill affordance skipped:",C)}h.onReady(ae),E=setTimeout(ae,1e4)}catch(y){console.error("Error rendering visualization:",y),O?.disconnect(),L?.disconnect(),j?.disconnect(),h.remove(),h=void 0,u.parentNode===c&&c.removeChild(u)}})(),()=>{V=!0,O?.disconnect(),L?.disconnect(),_&&clearTimeout(_),E&&clearTimeout(E),d&&k.current?.node!==d&&(N&&d.removeEventListener("keydown",N),$&&d.removeEventListener("keyup",$),q&&d.removeEventListener("focusin",q),j?.disconnect(),cancelAnimationFrame(K),h?.remove(),d.parentNode===c&&c.removeChild(d),c.style.position="")}},[e,f,v,l,o,J,W,Q,ee]),M.jsx("div",{ref:n,...a?{[I]:""}:{},style:{width:"100%",height:r?`${r}px`:"400px"}})}function be(e){return typeof window>"u"?M.jsx(X.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):M.jsx(p.Suspense,{fallback:M.jsx(X.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:M.jsx(Ce,{...e})})}const Ee=Object.freeze(Object.defineProperty({__proto__:null,default:be},Symbol.toStringTag,{value:"Module"}));exports.DRILL_CELL_CLASS=g;exports.RenderedResult=be;exports.RenderedResult$1=Ee;exports.buildMalloyExplicitTheme=ue;exports.buildVegaThemeOverride=he;exports.drillableFieldNames=de;exports.markDrillableCells=ce;exports.readChartAnnotations=me;
|