@malloy-publisher/sdk 0.18.6 → 0.18.7
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-D0SdTDx-.cjs.js → RenderedResult-B7Vw2U4r.cjs.js} +1 -1
- package/dist/{RenderedResult-cJiP774J.es.js → RenderedResult-BkBdGb49.es.js} +35 -35
- package/dist/{ServerProvider-BRGSDxay.es.js → ServerProvider-Caw1M640.es.js} +1386 -1162
- package/dist/ServerProvider-DorQnQ-Q.cjs.js +1 -0
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +452 -27
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +146 -131
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +344 -344
- package/dist/{useCompiledDocument-BNtiFhPK.es.js → useCompiledDocument-C3k5Ro8W.es.js} +2 -2
- package/dist/{useCompiledDocument-DanZRwMi.cjs.js → useCompiledDocument-CqI1slum.cjs.js} +2 -2
- package/package.json +1 -1
- package/dist/ServerProvider-BexMzLld.cjs.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const $=require("react/jsx-runtime"),de=require("@mui/material"),w=require("react"),u=require("./useCompiledDocument-
|
|
1
|
+
"use strict";const $=require("react/jsx-runtime"),de=require("@mui/material"),w=require("react"),u=require("./useCompiledDocument-CqI1slum.cjs.js"),G=require("./ServerProvider-DorQnQ-Q.cjs.js"),v=u.reportClasses.drillCell;function me(e,t){const r=new Set;let a;try{a=e.getMetadata()?.getAllFields()??[]}catch{return r}const o=new Set;for(const n of a)!n||t(n)||n.tag?.tag("hidden")===void 0&&o.add(n.tag?.text("label")??n.name);for(const n of a){if(!n||!t(n))continue;const l=n.tag?.text("label")??n.name;o.has(l)||r.add(l)}return r}function j(e){const t=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return t?t[1]:void 0}function be(e,t){if(t.size!==0)for(const r of e.querySelectorAll(".malloy-table")){const a=l=>l.closest(".malloy-table")===r,o=new Set;for(const l of r.querySelectorAll(".column-cell.th")){if(!a(l))continue;const i=(l.textContent??"").replace(/\u200b/g,"").trim(),m=j(l);m&&t.has(i)&&o.add(m)}if(o.size===0)continue;const n=new Set;for(const l of r.querySelectorAll(`.${v}[tabindex="0"]`)){if(!a(l))continue;const i=j(l);i&&(n.has(i)?l.tabIndex=-1:n.add(i))}for(const l of r.querySelectorAll(".column-cell.td")){if(!a(l))continue;const i=j(l),m=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(i&&m&&o.has(i)&&!l.querySelector(".malloy-table")){if(l.classList.add(v),l.tabIndex===0)n.add(i);else{const p=n.has(i);p||n.add(i),l.tabIndex=p?-1:0}l.setAttribute("role","button")}}}}function Ce(e){const t=e.closest(".malloy-table"),r=j(e);return!t||!r?[]:Array.from(t.querySelectorAll(`.${v}`)).filter(a=>a.closest(".malloy-table")===t&&j(a)===r)}function ce(e,t){const r=Ce(e),a=r.indexOf(e);if(a===-1)return;const o=t==="first"?r[0]:t==="last"?r[r.length-1]:r[Math.min(Math.max(a+t,0),r.length-1)];if(o){for(const n of r)n.tabIndex=n===o?0:-1;return o}}function fe(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 ye(e){const{foreground:t,axisFaint:r,gridline:a,font:o}=e,n={background:e.background,font:o.family,title:{color:t,font:o.family},axis:{labelColor:t,titleColor:t,domainColor:r,tickColor:r,gridColor:a,labelFont:o.family,titleFont:o.family},legend:{labelColor:t,titleColor:t,labelFont:o.family,titleFont:o.family},header:{labelColor:t,titleColor:t},range:{category:e.series}},l={...n,legend:{...n.legend,orient:"bottom"}};return i=>i==="shape_map"?l:n}function pe(e){if(!e)return;const t=e.tag("theme");if(!t)return;const r={},a=t.tag("palette");if(a){const n={},l=a.textArray("series");l&&l.length>0&&(n.series=l);for(const i of G.PER_MODE_COLOR_KEYS){const m=a.tag(i);if(!m)continue;const p={},C=m.text("light"),x=m.text("dark");C&&(p.light=C),x&&(p.dark=x),Object.keys(p).length>0&&(n[i]=p)}Object.keys(n).length>0&&(r.palette=n)}const o=t.tag("font");if(o){const n={},l=o.text("family");l&&(n.family=l);const i=o.numeric("size");typeof i=="number"&&Number.isFinite(i)&&(n.size=i),Object.keys(n).length>0&&(r.font=n)}return Object.keys(r).length>0?r:void 0}const ee=e=>(e??[]).map(t=>t?.value).filter(t=>typeof t=="string");function Re(e){const t=e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const Te=e=>ee(e.annotations).some(t=>{const r=t.trim();return/^#[^("]/.test(r)&&/(?:^#|[\s{])label\s*=/.test(r)}),Ae=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Ee=e=>e.type?.element_type?.fields??e.type?.fields;function ge(e,t){let r=!1;return{fields:e.map(o=>{const n=Ee(o);if(n){const i=ge(n,u.requestsRowChart(ee(o.annotations)));if(!i.changed)return o;r=!0;const m=o.type?.element_type?{...o.type,element_type:{...o.type.element_type,fields:i.fields}}:{...o.type,fields:i.fields};return{...o,type:m}}if(!t||!o.name||Te(o))return o;const l=Re(o.name);return l===o.name?o:(r=!0,{...o,annotations:[{value:`# label=${Ae(l)}
|
|
2
2
|
`},...o.annotations??[]]})}),changed:r}}function Se(e){if(!e||typeof e!="object")return e;const t=e,r=t.schema?.fields;if(!Array.isArray(r))return e;const{fields:a,changed:o}=ge(r,u.requestsRowChart(ee(t.annotations)));return o?{...t,schema:{...t.schema,fields:a}}:e}const ue=320,_e=10,De=96,Oe=4e3;function Fe(e,t){if(e!=="bar"&&e!=="combo"&&e!=="line"&&e!=="chart"&&e!=="scatter_chart")return;if(e!=="bar"&&e!=="combo")return ue;const r=t?.data?.array_value?.length,a=r===void 0?0:r*_e+De;return Math.min(Math.max(ue,a),Oe)}function Le(e){let t;return{onClick:r=>{const a={...r,...ze(r)};t=a,queueMicrotask(()=>{t===a&&(t=void 0),e(a)})},onDrill:r=>{const a=t;t=void 0,a&&r.stableDrillClauses!==void 0&&(a.drillClauses=r.stableDrillClauses)}}}function ze(e){const t=e.field;try{const r=t?.getEffectiveQueryTimezone?.();return r?{timezone:r}:{}}catch{return{}}}function Ie(e){const t=r=>{let a=!1;try{a=r.isArray?.()===!0}catch{a=!1}a&&"stableDrillFilters"in r&&Object.defineProperty(r,"stableDrillFilters",{configurable:!0,get:()=>[]});for(const o of r.fields??[])t(o)};e&&t(e)}const B="data-publisher-fill";let X;function ve(){if(X===void 0)try{X=new Function("return true")()===!0}catch{X=!1}return X}const Me=async(e,t,r)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:a}=await u.loadMalloyRenderer();return new a({onClick:t,...r?{onDrill:r,tableConfig:{enableDrill:!0}}:{},vegaConfigOverride:ye(e),...ve()?{}:{useVegaInterpreter:!0},theme:fe(e),onError:n=>{console.error("Error rendering visualization:",typeof n,n)}}).createViz()};async function $e(e){if(!e||typeof e!="object")return;const t=e,r=[...Array.isArray(t.model_annotations)?t.model_annotations:[],...Array.isArray(t.source_annotations)?t.source_annotations:[],...Array.isArray(t.annotations)?t.annotations:[]].map(o=>typeof o?.value=="string"?o.value:void 0).filter(o=>!!o);if(r.length===0)return;let a;try{({parseAnnotation:a}=await u.loadMalloyTag())}catch{return}try{const{tag:o}=a(r);return pe(o)}catch(o){console.warn("Failed to parse # theme.* annotations; chart will render with the shell theme.",{error:o,lines:r});return}}function Be(e,t,r){const a=u.buildTableCssVars(t,r);for(const[o,n]of Object.entries(a))e.style.setProperty(o,n)}const je=`
|
|
3
3
|
/* Card geometry, through the renderer's OWN theme vars rather than over the top
|
|
4
4
|
of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as M } from "react/jsx-runtime";
|
|
2
2
|
import { Box as de } from "@mui/material";
|
|
3
|
-
import { Suspense as we, useRef as
|
|
4
|
-
import { r as Ce, a as fe, D as Re, b as Z, T as V, l as Ee, c as Ae, d as Te, e as Se, R as _e, m as De, f as Oe, g as ue } from "./useCompiledDocument-
|
|
5
|
-
import {
|
|
3
|
+
import { Suspense as we, useRef as L, useMemo as ce, useEffect as ke, useLayoutEffect as xe } from "react";
|
|
4
|
+
import { r as Ce, a as fe, D as Re, b as Z, T as V, l as Ee, c as Ae, d as Te, e as Se, R as _e, m as De, f as Oe, g as ue } from "./useCompiledDocument-C3k5Ro8W.es.js";
|
|
5
|
+
import { bI as Fe, bG as ze, bJ as Ie, bK as Le } from "./ServerProvider-Caw1M640.es.js";
|
|
6
6
|
const g = Ce.drillCell;
|
|
7
|
-
function
|
|
7
|
+
function Me(e, t) {
|
|
8
8
|
const r = /* @__PURE__ */ new Set();
|
|
9
9
|
let a;
|
|
10
10
|
try {
|
|
@@ -208,13 +208,13 @@ function We(e) {
|
|
|
208
208
|
);
|
|
209
209
|
return o ? { ...t, schema: { ...t.schema, fields: a } } : e;
|
|
210
210
|
}
|
|
211
|
-
const me = 320, Ke = 10,
|
|
212
|
-
function
|
|
211
|
+
const me = 320, Ke = 10, Ge = 96, Ue = 4e3;
|
|
212
|
+
function Ye(e, t) {
|
|
213
213
|
if (e !== "bar" && e !== "combo" && e !== "line" && e !== "chart" && e !== "scatter_chart")
|
|
214
214
|
return;
|
|
215
215
|
if (e !== "bar" && e !== "combo") return me;
|
|
216
|
-
const r = t?.data?.array_value?.length, a = r === void 0 ? 0 : r * Ke +
|
|
217
|
-
return Math.min(Math.max(me, a),
|
|
216
|
+
const r = t?.data?.array_value?.length, a = r === void 0 ? 0 : r * Ke + Ge;
|
|
217
|
+
return Math.min(Math.max(me, a), Ue);
|
|
218
218
|
}
|
|
219
219
|
function Je(e) {
|
|
220
220
|
let t;
|
|
@@ -514,14 +514,14 @@ function nt({
|
|
|
514
514
|
onSizing: o,
|
|
515
515
|
fill: n
|
|
516
516
|
}) {
|
|
517
|
-
const l =
|
|
517
|
+
const l = L(null), i = L(r);
|
|
518
518
|
i.current = r;
|
|
519
519
|
const h = ce(
|
|
520
520
|
() => Je((d) => i.current?.onClick(d)),
|
|
521
521
|
[]
|
|
522
|
-
), y = r !== void 0, k =
|
|
522
|
+
), y = r !== void 0, k = L(!1), w = L(
|
|
523
523
|
null
|
|
524
|
-
), W =
|
|
524
|
+
), W = L(0), { theme: N, layers: K, mode: te } = ze(), re = ce(
|
|
525
525
|
() => ({
|
|
526
526
|
radius: N.ui.radius.tile,
|
|
527
527
|
padding: `${Re}px`
|
|
@@ -536,17 +536,17 @@ function nt({
|
|
|
536
536
|
if (!l.current || !e) return;
|
|
537
537
|
at();
|
|
538
538
|
const d = l.current, ge = W.current += 1;
|
|
539
|
-
let
|
|
540
|
-
const
|
|
541
|
-
let c, b, P = null,
|
|
539
|
+
let G = !1;
|
|
540
|
+
const U = () => !G && ge === W.current;
|
|
541
|
+
let c, b, P = null, Y = 0, j = null, H = null, q = null, D = null, O = null, F = null, oe = null, ae = 0, A = null;
|
|
542
542
|
k.current = !1;
|
|
543
543
|
let p, T;
|
|
544
544
|
const J = (v) => {
|
|
545
|
-
if (
|
|
545
|
+
if (G || !v.firstElementChild || Z(p, T) === "container") return;
|
|
546
546
|
const z = Se(p, T);
|
|
547
547
|
if (k.current && !z) return;
|
|
548
|
-
const
|
|
549
|
-
|
|
548
|
+
const I = d.hasAttribute($);
|
|
549
|
+
I && d.removeAttribute($);
|
|
550
550
|
const x = d.closest(
|
|
551
551
|
`.${_e}`
|
|
552
552
|
), u = x?.style.overflowY;
|
|
@@ -555,7 +555,7 @@ function nt({
|
|
|
555
555
|
v,
|
|
556
556
|
ue(p)
|
|
557
557
|
);
|
|
558
|
-
x && (x.style.overflowY = u ?? ""),
|
|
558
|
+
x && (x.style.overflowY = u ?? ""), I && d.setAttribute($, ""), S > 0 && (k.current = !0, a && S !== ae && (ae = S, a(S)));
|
|
559
559
|
const C = Oe(v, ue(p));
|
|
560
560
|
z && C && oe !== C && (oe = C, F?.disconnect(), F = new ResizeObserver(() => J(v)), F.observe(C));
|
|
561
561
|
};
|
|
@@ -567,11 +567,11 @@ function nt({
|
|
|
567
567
|
console.error("Error parsing visualization result:", m);
|
|
568
568
|
return;
|
|
569
569
|
}
|
|
570
|
-
const z = await tt(v),
|
|
571
|
-
if (!
|
|
570
|
+
const z = await tt(v), I = z ? Ie([...K, Le(K, z)], te) : N;
|
|
571
|
+
if (!U()) return;
|
|
572
572
|
try {
|
|
573
573
|
b = await et(
|
|
574
|
-
|
|
574
|
+
I,
|
|
575
575
|
h.onClick,
|
|
576
576
|
y ? h.onDrill : void 0
|
|
577
577
|
);
|
|
@@ -579,12 +579,12 @@ function nt({
|
|
|
579
579
|
console.error("Failed to create renderer:", m);
|
|
580
580
|
return;
|
|
581
581
|
}
|
|
582
|
-
if (!
|
|
582
|
+
if (!U()) {
|
|
583
583
|
b.remove(), b = void 0;
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
586
586
|
const x = w.current;
|
|
587
|
-
c = document.createElement("div"), c.style.width = "100%", c.style.height = "100%", rt(c,
|
|
587
|
+
c = document.createElement("div"), c.style.width = "100%", c.style.height = "100%", rt(c, I, re), d.childElementCount > 0 && (d.style.position = "relative", c.style.position = "absolute", c.style.inset = "0", c.style.visibility = "hidden"), d.appendChild(c);
|
|
588
588
|
const u = c;
|
|
589
589
|
D = new MutationObserver(() => {
|
|
590
590
|
O && clearTimeout(O), O = setTimeout(() => {
|
|
@@ -598,7 +598,7 @@ function nt({
|
|
|
598
598
|
const S = b;
|
|
599
599
|
let C = !1;
|
|
600
600
|
const ne = () => {
|
|
601
|
-
if (!(C || !
|
|
601
|
+
if (!(C || !U())) {
|
|
602
602
|
C = !0, A && (clearTimeout(A), A = null), x?.viz.remove();
|
|
603
603
|
for (const m of Array.from(d.children))
|
|
604
604
|
m !== u && d.removeChild(m);
|
|
@@ -614,12 +614,12 @@ function nt({
|
|
|
614
614
|
p = void 0, T = void 0;
|
|
615
615
|
}
|
|
616
616
|
o?.(Z(p, T), p), c.dataset.malloyRenderAs = p ?? "unknown", c.dataset.malloySizing = Z(p, T);
|
|
617
|
-
const m =
|
|
617
|
+
const m = Ye(p, v);
|
|
618
618
|
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);
|
|
619
619
|
const le = i.current;
|
|
620
620
|
try {
|
|
621
621
|
if (le) {
|
|
622
|
-
const R =
|
|
622
|
+
const R = Me(b, le.canDrill), E = () => {
|
|
623
623
|
try {
|
|
624
624
|
$e(u, R);
|
|
625
625
|
} catch (s) {
|
|
@@ -658,7 +658,7 @@ function nt({
|
|
|
658
658
|
const f = s.target?.closest?.(`.${g}`);
|
|
659
659
|
f && he(f, 0);
|
|
660
660
|
}, u.addEventListener("keydown", j), u.addEventListener("keyup", H), u.addEventListener("focusin", q), R.size > 0 && typeof MutationObserver < "u" && (P = new MutationObserver(() => {
|
|
661
|
-
cancelAnimationFrame(
|
|
661
|
+
cancelAnimationFrame(Y), Y = requestAnimationFrame(E);
|
|
662
662
|
}), P.observe(u, {
|
|
663
663
|
childList: !0,
|
|
664
664
|
subtree: !0
|
|
@@ -672,7 +672,7 @@ function nt({
|
|
|
672
672
|
console.error("Error rendering visualization:", m), D?.disconnect(), F?.disconnect(), P?.disconnect(), b.remove(), b = void 0, u.parentNode === d && d.removeChild(u);
|
|
673
673
|
}
|
|
674
674
|
})(), () => {
|
|
675
|
-
|
|
675
|
+
G = !0, D?.disconnect(), F?.disconnect(), O && clearTimeout(O), A && clearTimeout(A), c && w.current?.node !== c && (j && c.removeEventListener("keydown", j), H && c.removeEventListener("keyup", H), q && c.removeEventListener("focusin", q), P?.disconnect(), cancelAnimationFrame(Y), b?.remove(), c.parentNode === d && d.removeChild(c), d.style.position = "");
|
|
676
676
|
};
|
|
677
677
|
}, [
|
|
678
678
|
e,
|
|
@@ -684,7 +684,7 @@ function nt({
|
|
|
684
684
|
K,
|
|
685
685
|
te,
|
|
686
686
|
re
|
|
687
|
-
]), /* @__PURE__ */
|
|
687
|
+
]), /* @__PURE__ */ M(
|
|
688
688
|
"div",
|
|
689
689
|
{
|
|
690
690
|
ref: l,
|
|
@@ -697,7 +697,7 @@ function nt({
|
|
|
697
697
|
);
|
|
698
698
|
}
|
|
699
699
|
function lt(e) {
|
|
700
|
-
return typeof window > "u" ? /* @__PURE__ */
|
|
700
|
+
return typeof window > "u" ? /* @__PURE__ */ M(
|
|
701
701
|
de,
|
|
702
702
|
{
|
|
703
703
|
sx: {
|
|
@@ -710,10 +710,10 @@ function lt(e) {
|
|
|
710
710
|
},
|
|
711
711
|
children: "Loading..."
|
|
712
712
|
}
|
|
713
|
-
) : /* @__PURE__ */
|
|
713
|
+
) : /* @__PURE__ */ M(
|
|
714
714
|
we,
|
|
715
715
|
{
|
|
716
|
-
fallback: /* @__PURE__ */
|
|
716
|
+
fallback: /* @__PURE__ */ M(
|
|
717
717
|
de,
|
|
718
718
|
{
|
|
719
719
|
sx: {
|
|
@@ -727,7 +727,7 @@ function lt(e) {
|
|
|
727
727
|
children: "Loading visualization..."
|
|
728
728
|
}
|
|
729
729
|
),
|
|
730
|
-
children: /* @__PURE__ */
|
|
730
|
+
children: /* @__PURE__ */ M(nt, { ...e })
|
|
731
731
|
}
|
|
732
732
|
);
|
|
733
733
|
}
|
|
@@ -742,7 +742,7 @@ export {
|
|
|
742
742
|
Pe as a,
|
|
743
743
|
Ne as b,
|
|
744
744
|
ht as c,
|
|
745
|
-
|
|
745
|
+
Me as d,
|
|
746
746
|
$e as m,
|
|
747
747
|
je as r
|
|
748
748
|
};
|