@malloy-publisher/sdk 0.8.3 → 0.8.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.
Files changed (44) hide show
  1. package/README.md +14 -65
  2. package/dist/Dashboard-ChyylkTD.cjs.js +136 -0
  3. package/dist/{DocumentStorage-CigwNjz4.es.js → Dashboard-H1kJlDFo.es.js} +23660 -23575
  4. package/dist/{RenderedResult-DpHdrFtp.cjs.js → RenderedResult-AJPMUkAD.cjs.js} +1 -1
  5. package/dist/{RenderedResult-BfayOSk1.es.js → RenderedResult-BRgIgxWh.es.js} +18 -18
  6. package/dist/{ServerProvider-CfUFleYe.es.js → ServerProvider-Boxrv6Ym.es.js} +1481 -1513
  7. package/dist/ServerProvider-CXrOKD6g.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +50 -50
  9. package/dist/builder/index.es.js +2587 -2511
  10. package/dist/client/api.d.ts +187 -1803
  11. package/dist/client/base.d.ts +0 -24
  12. package/dist/client/common.d.ts +4 -35
  13. package/dist/client/configuration.d.ts +25 -18
  14. package/dist/client/index.cjs.js +1 -1
  15. package/dist/client/index.d.ts +1 -1
  16. package/dist/client/index.es.js +62 -59
  17. package/dist/components/DashboardBuilder/malloyText.d.ts +49 -0
  18. package/dist/components/DashboardBuilder/malloyTree.d.ts +2 -18
  19. package/dist/components/DashboardBuilder/readDocument.d.ts +2 -0
  20. package/dist/components/Notebook/NotebookCell.d.ts +3 -2
  21. package/dist/components/Notebook/cellKind.d.ts +20 -0
  22. package/dist/hooks/useQueryResult.d.ts +1 -1
  23. package/dist/index.cjs.js +15 -12
  24. package/dist/index.es.js +4528 -4435
  25. package/openapitools.json +1 -1
  26. package/package.json +3 -3
  27. package/src/components/DashboardBuilder/malloyText.spec.ts +70 -1
  28. package/src/components/DashboardBuilder/malloyText.ts +171 -3
  29. package/src/components/DashboardBuilder/malloyTree.spec.ts +35 -0
  30. package/src/components/DashboardBuilder/malloyTree.ts +28 -4
  31. package/src/components/DashboardBuilder/readDocument.spec.ts +180 -1
  32. package/src/components/DashboardBuilder/readDocument.ts +52 -14
  33. package/src/components/DashboardBuilder/spliceDocument.spec.ts +396 -2
  34. package/src/components/DashboardBuilder/spliceDocument.ts +121 -18
  35. package/src/components/Notebook/Notebook.served.spec.tsx +179 -0
  36. package/src/components/Notebook/Notebook.spec.tsx +33 -2
  37. package/src/components/Notebook/Notebook.tsx +13 -7
  38. package/src/components/Notebook/NotebookCell.tsx +124 -63
  39. package/src/components/Notebook/cellKind.spec.ts +191 -0
  40. package/src/components/Notebook/cellKind.ts +74 -0
  41. package/src/components/Package/Package.notebooks.spec.tsx +90 -0
  42. package/src/components/Package/Package.tsx +18 -4
  43. package/dist/DocumentStorage-DvUNSOiN.cjs.js +0 -134
  44. package/dist/ServerProvider-CuYLH_Yi.cjs.js +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";var ge=Object.create;var le=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var xe=(e,r,t,a)=>{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:!(a=ve(r,o))||a.enumerable});return e};var G=(e,r,t)=>(t=e!=null?ge(ke(e)):{},xe(r||!e||!e.__esModule?le(t,"default",{value:e,enumerable:!0}):t,e));const I=require("react/jsx-runtime"),U=require("@mui/material"),p=require("react"),g=require("./DocumentStorage-DvUNSOiN.cjs.js"),X=require("./ServerProvider-CuYLH_Yi.cjs.js"),v="publisher-drill";function de(e,r){const t=new Set;let a;try{a=e.getMetadata()?.getAllFields()??[]}catch{return t}const o=new Set;for(const n of a)!n||r(n)||n.tag?.tag("hidden")===void 0&&o.add(n.tag?.text("label")??n.name);for(const n of a){if(!n||!r(n))continue;const l=n.tag?.text("label")??n.name;o.has(l)||t.add(l)}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 a=l=>l.closest(".malloy-table")===t,o=new Set;for(const l of t.querySelectorAll(".column-cell.th")){if(!a(l))continue;const s=(l.textContent??"").replace(/\u200b/g,"").trim(),y=B(l);y&&r.has(s)&&o.add(y)}if(o.size===0)continue;const n=new Set;for(const l of t.querySelectorAll(`.${v}[tabindex="0"]`)){if(!a(l))continue;const s=B(l);s&&(n.has(s)?l.tabIndex=-1:n.add(s))}for(const l of t.querySelectorAll(".column-cell.td")){if(!a(l))continue;const s=B(l),y=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(s&&y&&o.has(s)&&!l.querySelector(".malloy-table")){if(l.classList.add(v),l.tabIndex===0)n.add(s);else{const h=n.has(s);h||n.add(s),l.tabIndex=h?-1:0}l.setAttribute("role","button")}}}}function Ce(e){const r=e.closest(".malloy-table"),t=B(e);return!r||!t?[]:Array.from(r.querySelectorAll(`.${v}`)).filter(a=>a.closest(".malloy-table")===r&&B(a)===t)}function ie(e,r){const t=Ce(e),a=t.indexOf(e);if(a===-1)return;const o=r==="first"?t[0]:r==="last"?t[t.length-1]:t[Math.min(Math.max(a+r,0),t.length-1)];if(o){for(const n of t)n.tabIndex=n===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:a}=e,o={background:e.background,font:a.family,title:{color:r,font:a.family},axis:{labelColor:r,titleColor:r,domainColor:t,tickColor:t,gridColor:t,labelFont:a.family,titleFont:a.family},legend:{labelColor:r,titleColor:r,labelFont:a.family,titleFont:a.family},header:{labelColor:r,titleColor:r},range:{category:e.series}};return n=>o}function me(e){if(!e)return;const r=e.tag("theme");if(!r)return;const t={},a=r.tag("palette");if(a){const n={},l=a.textArray("series");l&&l.length>0&&(n.series=l);for(const s of X.PER_MODE_COLOR_KEYS){const y=a.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&&(n[s]=h)}Object.keys(n).length>0&&(t.palette=n)}const o=r.tag("font");if(o){const n={},l=o.text("family");l&&(n.family=l);const s=o.numeric("size");typeof s=="number"&&Number.isFinite(s)&&(n.size=s),Object.keys(n).length>0&&(t.font=n)}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 a;try{({parseAnnotation:a}=await import("@malloydata/malloy-tag"))}catch{return}try{const{tag:o}=a(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 a=g.buildTableCssVars(r,t);for(const[o,n]of Object.entries(a))e.style.setProperty(o,n)}const De=`
1
+ "use strict";var ge=Object.create;var le=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var xe=(e,r,t,a)=>{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:!(a=ve(r,o))||a.enumerable});return e};var G=(e,r,t)=>(t=e!=null?ge(ke(e)):{},xe(r||!e||!e.__esModule?le(t,"default",{value:e,enumerable:!0}):t,e));const I=require("react/jsx-runtime"),U=require("@mui/material"),p=require("react"),g=require("./Dashboard-ChyylkTD.cjs.js"),X=require("./ServerProvider-CXrOKD6g.cjs.js"),v="publisher-drill";function de(e,r){const t=new Set;let a;try{a=e.getMetadata()?.getAllFields()??[]}catch{return t}const o=new Set;for(const n of a)!n||r(n)||n.tag?.tag("hidden")===void 0&&o.add(n.tag?.text("label")??n.name);for(const n of a){if(!n||!r(n))continue;const l=n.tag?.text("label")??n.name;o.has(l)||t.add(l)}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 a=l=>l.closest(".malloy-table")===t,o=new Set;for(const l of t.querySelectorAll(".column-cell.th")){if(!a(l))continue;const s=(l.textContent??"").replace(/\u200b/g,"").trim(),y=B(l);y&&r.has(s)&&o.add(y)}if(o.size===0)continue;const n=new Set;for(const l of t.querySelectorAll(`.${v}[tabindex="0"]`)){if(!a(l))continue;const s=B(l);s&&(n.has(s)?l.tabIndex=-1:n.add(s))}for(const l of t.querySelectorAll(".column-cell.td")){if(!a(l))continue;const s=B(l),y=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(s&&y&&o.has(s)&&!l.querySelector(".malloy-table")){if(l.classList.add(v),l.tabIndex===0)n.add(s);else{const h=n.has(s);h||n.add(s),l.tabIndex=h?-1:0}l.setAttribute("role","button")}}}}function Ce(e){const r=e.closest(".malloy-table"),t=B(e);return!r||!t?[]:Array.from(r.querySelectorAll(`.${v}`)).filter(a=>a.closest(".malloy-table")===r&&B(a)===t)}function ie(e,r){const t=Ce(e),a=t.indexOf(e);if(a===-1)return;const o=r==="first"?t[0]:r==="last"?t[t.length-1]:t[Math.min(Math.max(a+r,0),t.length-1)];if(o){for(const n of t)n.tabIndex=n===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:a}=e,o={background:e.background,font:a.family,title:{color:r,font:a.family},axis:{labelColor:r,titleColor:r,domainColor:t,tickColor:t,gridColor:t,labelFont:a.family,titleFont:a.family},legend:{labelColor:r,titleColor:r,labelFont:a.family,titleFont:a.family},header:{labelColor:r,titleColor:r},range:{category:e.series}};return n=>o}function me(e){if(!e)return;const r=e.tag("theme");if(!r)return;const t={},a=r.tag("palette");if(a){const n={},l=a.textArray("series");l&&l.length>0&&(n.series=l);for(const s of X.PER_MODE_COLOR_KEYS){const y=a.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&&(n[s]=h)}Object.keys(n).length>0&&(t.palette=n)}const o=r.tag("font");if(o){const n={},l=o.text("family");l&&(n.family=l);const s=o.numeric("size");typeof s=="number"&&Number.isFinite(s)&&(n.size=s),Object.keys(n).length>0&&(t.font=n)}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 a;try{({parseAnnotation:a}=await import("@malloydata/malloy-tag"))}catch{return}try{const{tag:o}=a(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 a=g.buildTableCssVars(r,t);for(const[o,n]of Object.entries(a))e.style.setProperty(o,n)}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
@@ -1,8 +1,8 @@
1
1
  import { jsx as I } 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 be, useLayoutEffect as fe } from "react";
4
- import { D as ye, r as K, b as pe, a as ge, m as ve, c as we, d as ae } from "./DocumentStorage-CigwNjz4.es.js";
5
- import { aD as ke, aE as Ce, aF as xe } from "./ServerProvider-CfUFleYe.es.js";
4
+ import { D as ye, r as K, b as pe, a as ge, m as ve, c as we, d as ae } from "./Dashboard-H1kJlDFo.es.js";
5
+ import { aG as ke, aH as Ce, aI as xe } from "./ServerProvider-Boxrv6Ym.es.js";
6
6
  const g = "publisher-drill";
7
7
  function Re(e, r) {
8
8
  const t = /* @__PURE__ */ new Set();
@@ -173,7 +173,7 @@ const Te = async (e, r) => {
173
173
  }).createViz();
174
174
  };
175
175
  typeof window < "u" && import("@malloydata/render");
176
- async function Fe(e) {
176
+ async function _e(e) {
177
177
  if (!e || typeof e != "object") return;
178
178
  const r = e, t = [
179
179
  ...Array.isArray(r.model_annotations) ? r.model_annotations : [],
@@ -198,7 +198,7 @@ async function Fe(e) {
198
198
  return;
199
199
  }
200
200
  }
201
- function _e(e, r, t) {
201
+ function Fe(e, r, t) {
202
202
  const a = pe(r, t);
203
203
  for (const [n, o] of Object.entries(a))
204
204
  e.style.setProperty(n, o);
@@ -373,20 +373,20 @@ function Le({
373
373
  const c = o.current, ie = x.current += 1;
374
374
  let j = !1;
375
375
  const P = () => !j && ie === x.current;
376
- let d, m, B = null, V = 0, M = null, N = null, $ = null, O = null, T = null, F = null, W = null, Q = 0, R = null;
376
+ let d, m, B = null, V = 0, M = null, N = null, $ = null, O = null, T = null, _ = null, W = null, Q = 0, R = null;
377
377
  h.current = !1;
378
378
  let p, E;
379
- const q = (w) => {
379
+ const H = (w) => {
380
380
  if (j || !w.firstElementChild || K(p, E) === "container") return;
381
- const _ = ge(p, E);
382
- if (h.current && !_) return;
381
+ const F = ge(p, E);
382
+ if (h.current && !F) return;
383
383
  const k = ve(
384
384
  w,
385
385
  ae(p)
386
386
  );
387
387
  k > 0 && (h.current = !0, a && k !== Q && (Q = k, a(k)));
388
388
  const S = we(w, ae(p));
389
- _ && S && W !== S && (W = S, F?.disconnect(), F = new ResizeObserver(() => q(w)), F.observe(S));
389
+ F && S && W !== S && (W = S, _?.disconnect(), _ = new ResizeObserver(() => H(w)), _.observe(S));
390
390
  };
391
391
  return (async () => {
392
392
  let w;
@@ -396,7 +396,7 @@ function Le({
396
396
  console.error("Error parsing visualization result:", f);
397
397
  return;
398
398
  }
399
- const _ = await Fe(w), k = _ ? xe([...U, _], X) : G;
399
+ const F = await _e(w), k = F ? xe([...U, F], X) : G;
400
400
  if (!P()) return;
401
401
  try {
402
402
  m = await Te(k, s);
@@ -409,11 +409,11 @@ function Le({
409
409
  return;
410
410
  }
411
411
  const S = v.current;
412
- 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);
412
+ d = document.createElement("div"), d.style.width = "100%", d.style.height = "100%", Fe(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);
413
413
  const u = d;
414
414
  O = new MutationObserver(() => {
415
415
  T && clearTimeout(T), T = setTimeout(() => {
416
- q(u), h.current && O?.disconnect();
416
+ H(u), h.current && O?.disconnect();
417
417
  }, 100);
418
418
  }), O.observe(d, {
419
419
  childList: !0,
@@ -427,7 +427,7 @@ function Le({
427
427
  Z = !0, R && (clearTimeout(R), R = null), S?.viz.remove();
428
428
  for (const f of Array.from(c.children))
429
429
  f !== u && c.removeChild(f);
430
- u.style.position = "", u.style.inset = "", u.style.visibility = "", c.style.position = "", v.current = { viz: se, node: u }, q(u);
430
+ u.style.position = "", u.style.inset = "", u.style.visibility = "", c.style.position = "", v.current = { viz: se, node: u }, H(u);
431
431
  }
432
432
  };
433
433
  try {
@@ -451,14 +451,14 @@ function Le({
451
451
  };
452
452
  A();
453
453
  const re = (i) => {
454
- const D = i.querySelector(".cell-content") ?? i, H = D.getBoundingClientRect();
454
+ const D = i.querySelector(".cell-content") ?? i, q = D.getBoundingClientRect();
455
455
  D.dispatchEvent(
456
456
  new MouseEvent("click", {
457
457
  bubbles: !0,
458
458
  cancelable: !0,
459
459
  view: D.ownerDocument.defaultView,
460
- clientX: Math.round(H.left + H.width / 2),
461
- clientY: Math.round(H.bottom)
460
+ clientX: Math.round(q.left + q.width / 2),
461
+ clientY: Math.round(q.bottom)
462
462
  })
463
463
  );
464
464
  }, te = (i) => i.target?.closest?.(`.${g}`) ?? null, de = (i, b) => {
@@ -492,10 +492,10 @@ function Le({
492
492
  }
493
493
  m.onReady(ee), R = setTimeout(ee, 1e4);
494
494
  } catch (f) {
495
- console.error("Error rendering visualization:", f), O?.disconnect(), F?.disconnect(), B?.disconnect(), m.remove(), m = void 0, u.parentNode === c && c.removeChild(u);
495
+ console.error("Error rendering visualization:", f), O?.disconnect(), _?.disconnect(), B?.disconnect(), m.remove(), m = void 0, u.parentNode === c && c.removeChild(u);
496
496
  }
497
497
  })(), () => {
498
- j = !0, O?.disconnect(), F?.disconnect(), T && clearTimeout(T), R && clearTimeout(R), d && v.current?.node !== d && (M && d.removeEventListener("keydown", M), N && d.removeEventListener("keyup", N), $ && d.removeEventListener("focusin", $), B?.disconnect(), cancelAnimationFrame(V), m?.remove(), d.parentNode === c && c.removeChild(d), c.style.position = "");
498
+ j = !0, O?.disconnect(), _?.disconnect(), T && clearTimeout(T), R && clearTimeout(R), d && v.current?.node !== d && (M && d.removeEventListener("keydown", M), N && d.removeEventListener("keyup", N), $ && d.removeEventListener("focusin", $), B?.disconnect(), cancelAnimationFrame(V), m?.remove(), d.parentNode === c && c.removeChild(d), c.style.position = "");
499
499
  };
500
500
  }, [
501
501
  e,