@malloy-publisher/sdk 0.0.49 → 0.0.51

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),S=require("@malloydata/render"),t=require("react");function C({result:i,height:b,isFillElement:f,onSizeChange:l,onDrill:m}){const e=t.useRef(null),[a,h]=t.useState(!1),[R,v]=t.useState(!1),[y,N]=t.useState(!1),s=t.useRef(null),n=t.useRef(null);if(t.useLayoutEffect(()=>{if(e.current&&i&&!R){v(!0),s.current||(s.current=new Promise(r=>{n.current=r}));const o=new S.MalloyRenderer({onClick:m}).createViz();for(;e.current.firstChild;)e.current.removeChild(e.current.firstChild);const d=new MutationObserver(r=>{for(const c of r)if(c.type==="childList"&&c.addedNodes.length>0&&Array.from(c.addedNodes).some(g=>g.nodeType===Node.ELEMENT_NODE)){d.disconnect(),setTimeout(()=>{h(!0),n.current&&(n.current(),n.current=null,s.current=null)},50);break}});if(e.current){d.observe(e.current,{childList:!0,subtree:!0,characterData:!0});try{o.setResult(JSON.parse(i)),o.render(e.current)}catch(r){console.error("Error rendering visualization:",r),d.disconnect(),h(!0),n.current&&(n.current(),n.current=null,s.current=null)}}}},[i,m,R]),t.useEffect(()=>{h(!1),v(!1),s.current=null,n.current=null},[i]),R&&!a&&s.current)throw s.current;return t.useEffect(()=>{if(!e.current||!a)return;const u=e.current,o=()=>{if(u){const c=u.offsetHeight;c>0?l&&l(c):f&&u.firstChild&&(u.firstChild.offsetHeight==0?f(!0):f(!1))}},d=setTimeout(o,100);let r=null;return y||(r=new MutationObserver(o),r.observe(u,{childList:!0,subtree:!0,attributes:!0})),()=>{clearTimeout(d),r?.disconnect()}},[l,i,f,a]),M.jsx("div",{ref:e,style:{width:"100%",height:b?`${b}px`:"100%"}})}exports.default=C;
@@ -1,20 +1,20 @@
1
- import { j as C } from "./vendor-9erH7dIW.js";
2
- import { i as E } from "./index-BBREesY7.js";
3
- import { useRef as m, useState as R, useLayoutEffect as M, useEffect as w } from "react";
4
- function O({
1
+ import { jsx as M } from "react/jsx-runtime";
2
+ import { MalloyRenderer as N } from "@malloydata/render";
3
+ import { useRef as m, useState as v, useLayoutEffect as H, useEffect as w } from "react";
4
+ function x({
5
5
  result: c,
6
- height: v,
6
+ height: R,
7
7
  isFillElement: d,
8
8
  onSizeChange: f,
9
9
  onDrill: b
10
10
  }) {
11
- const e = m(null), [l, a] = R(!1), [h, p] = R(!1), [x, N] = R(!1), n = m(null), t = m(null);
12
- if (M(() => {
11
+ const e = m(null), [l, a] = v(!1), [h, g] = v(!1), [y, L] = v(!1), n = m(null), t = m(null);
12
+ if (H(() => {
13
13
  if (e.current && c && !h) {
14
- p(!0), n.current || (n.current = new Promise((r) => {
14
+ g(!0), n.current || (n.current = new Promise((r) => {
15
15
  t.current = r;
16
16
  }));
17
- const i = new E.MalloyRenderer({
17
+ const i = new N({
18
18
  onClick: b
19
19
  }).createViz();
20
20
  for (; e.current.firstChild; )
@@ -22,7 +22,7 @@ function O({
22
22
  const o = new MutationObserver((r) => {
23
23
  for (const u of r)
24
24
  if (u.type === "childList" && u.addedNodes.length > 0 && Array.from(u.addedNodes).some(
25
- (g) => g.nodeType === Node.ELEMENT_NODE
25
+ (p) => p.nodeType === Node.ELEMENT_NODE
26
26
  )) {
27
27
  o.disconnect(), setTimeout(() => {
28
28
  a(!0), t.current && (t.current(), t.current = null, n.current = null);
@@ -44,7 +44,7 @@ function O({
44
44
  }
45
45
  }
46
46
  }, [c, b, h]), w(() => {
47
- a(!1), p(!1), n.current = null, t.current = null;
47
+ a(!1), g(!1), n.current = null, t.current = null;
48
48
  }, [c]), h && !l && n.current)
49
49
  throw n.current;
50
50
  return w(() => {
@@ -56,24 +56,24 @@ function O({
56
56
  }
57
57
  }, o = setTimeout(i, 100);
58
58
  let r = null;
59
- return x || (r = new MutationObserver(i), r.observe(s, {
59
+ return y || (r = new MutationObserver(i), r.observe(s, {
60
60
  childList: !0,
61
61
  subtree: !0,
62
62
  attributes: !0
63
63
  })), () => {
64
64
  clearTimeout(o), r?.disconnect();
65
65
  };
66
- }, [f, c, d, l]), /* @__PURE__ */ C.jsx(
66
+ }, [f, c, d, l]), /* @__PURE__ */ M(
67
67
  "div",
68
68
  {
69
69
  ref: e,
70
70
  style: {
71
71
  width: "100%",
72
- height: v ? `${v}px` : "100%"
72
+ height: R ? `${R}px` : "100%"
73
73
  }
74
74
  }
75
75
  );
76
76
  }
77
77
  export {
78
- O as default
78
+ x as default
79
79
  };