@malloy-publisher/sdk 0.3.1 → 0.4.1

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 (136) hide show
  1. package/README.md +33 -9
  2. package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorage-BiFqO15i.es.js} +7126 -6943
  3. package/dist/DocumentStorage-CMyLifsz.cjs.js +134 -0
  4. package/dist/RenderedResult-CZzE8wv-.cjs.js +115 -0
  5. package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-CvrmYyr5.es.js} +64 -57
  6. package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
  7. package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +52 -52
  9. package/dist/builder/index.es.js +3961 -3960
  10. package/dist/client/api.d.ts +100 -42
  11. package/dist/client/index.cjs.js +1 -1
  12. package/dist/client/index.es.js +1 -1
  13. package/dist/components/AppDialog.d.ts +30 -0
  14. package/dist/components/BackLink.d.ts +32 -0
  15. package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
  16. package/dist/components/Dashboard/telemetry.d.ts +24 -7
  17. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
  18. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +20 -2
  19. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +21 -11
  20. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  21. package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
  22. package/dist/components/DocumentStorage/DocumentStorage.d.ts +69 -5
  23. package/dist/components/DocumentStorage/index.d.ts +1 -0
  24. package/dist/components/ItemRow.d.ts +38 -0
  25. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  26. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  27. package/dist/components/Materializations/Materializations.d.ts +7 -3
  28. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  29. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  30. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  31. package/dist/components/Materializations/index.d.ts +0 -1
  32. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  33. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  34. package/dist/components/Package/index.d.ts +0 -1
  35. package/dist/components/PackageSection.d.ts +23 -0
  36. package/dist/components/buttons.d.ts +53 -0
  37. package/dist/components/index.d.ts +5 -0
  38. package/dist/components/styles.d.ts +49 -40
  39. package/dist/hooks/useCrudMutation.d.ts +42 -0
  40. package/dist/index.cjs.js +22 -26
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.es.js +17431 -20676
  43. package/dist/telemetry/consoleEvents.d.ts +60 -0
  44. package/dist/utils/sha256.d.ts +2 -0
  45. package/package.json +1 -1
  46. package/src/components/AppDialog.tsx +115 -0
  47. package/src/components/BackLink.tsx +83 -0
  48. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  49. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  50. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  51. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  52. package/src/components/Dashboard/telemetry.ts +24 -5
  53. package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
  54. package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
  55. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
  56. package/src/components/DashboardBuilder/DashboardBuilder.tsx +202 -171
  57. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +706 -0
  58. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  59. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
  60. package/src/components/DashboardBuilder/DashboardEditor.tsx +442 -94
  61. package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
  62. package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
  63. package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
  64. package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
  65. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  66. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  67. package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
  68. package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
  69. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
  70. package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
  71. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +7 -6
  72. package/src/components/DocumentStorage/DocumentStorage.ts +78 -5
  73. package/src/components/DocumentStorage/index.ts +1 -0
  74. package/src/components/Environment/About.tsx +14 -28
  75. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  76. package/src/components/Environment/Connections.tsx +125 -205
  77. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  78. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  79. package/src/components/Environment/Environment.tsx +34 -36
  80. package/src/components/Environment/Packages.tsx +63 -128
  81. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  82. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  83. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  84. package/src/components/Home/Home.tsx +101 -214
  85. package/src/components/ItemRow.tsx +165 -0
  86. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  87. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  88. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  89. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  90. package/src/components/Materializations/Materializations.tsx +137 -140
  91. package/src/components/Materializations/ScopeButton.tsx +85 -0
  92. package/src/components/Materializations/SectionLabel.tsx +7 -4
  93. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  94. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  95. package/src/components/Materializations/cron.spec.ts +113 -0
  96. package/src/components/Materializations/index.ts +0 -1
  97. package/src/components/Materializations/utils.spec.ts +182 -0
  98. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  99. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  100. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  101. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  102. package/src/components/Package/Package.tsx +184 -238
  103. package/src/components/Package/index.ts +0 -1
  104. package/src/components/PackageSection.tsx +85 -0
  105. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  106. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  107. package/src/components/ResultsDialog.tsx +8 -32
  108. package/src/components/buttons.tsx +114 -0
  109. package/src/components/designSystem.spec.tsx +316 -0
  110. package/src/components/given/paramCodec.spec.ts +1 -1
  111. package/src/components/index.ts +10 -0
  112. package/src/components/styles.ts +49 -85
  113. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  114. package/src/hooks/useCrudMutation.tsx +85 -0
  115. package/src/index.ts +9 -0
  116. package/src/telemetry/consoleEvents.spec.ts +130 -0
  117. package/src/telemetry/consoleEvents.ts +124 -0
  118. package/src/theme/defaults.ts +34 -23
  119. package/src/theme/resolveTheme.spec.ts +9 -4
  120. package/src/theme/resolveTheme.ts +12 -8
  121. package/src/utils/sha256.ts +13 -0
  122. package/test/README.md +1 -1
  123. package/test/serverProvider.tsx +5 -2
  124. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
  125. package/dist/RenderedResult-CPi6uQWq.cjs.js +0 -115
  126. package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
  127. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  128. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  129. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  130. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  131. package/dist/components/Package/Models.d.ts +0 -6
  132. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  133. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  134. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  135. package/src/components/Materializations/TriggerChip.tsx +0 -44
  136. package/src/components/Package/Models.tsx +0 -71
@@ -0,0 +1,115 @@
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("./DocumentStorage-CMyLifsz.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
+ /* Card geometry, through the renderer's OWN theme vars rather than over the top
3
+ of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
4
+ passes each through to the --malloy-render--* the card CSS reads, so a value
5
+ inherited from our wrapper loses to that declaration however early it is set:
6
+ this has to be a rule on the same element, at higher specificity. Doubling the
7
+ class does that, and then no !important is needed — which matters, because
8
+ !important here also lands on .dashboard-item-borderless and repaints a card
9
+ the author asked to have no card. */
10
+ .malloy-render.malloy-render {
11
+ --malloy-theme--dashboard-card-radius: var(--publisher-dashboard-card-radius);
12
+ --malloy-theme--dashboard-card-padding: var(--publisher-dashboard-card-padding);
13
+ }
14
+ /* dashboard.css hardcodes background: #f7f9fc on .malloy-dashboard
15
+ and .dashboard-row-header, which would paint light grey in dark
16
+ mode and also bleed an operator-picked palette.background across
17
+ the panel chrome in light. Both surfaces use
18
+ --malloy-render--background here, which buildMalloyExplicitTheme
19
+ wires to dashboardRoot: a mode-keyed neutral that stays decoupled
20
+ from palette.background (the chart canvas) on purpose. Selectors
21
+ are duplicated at higher specificity to beat the renderer s own
22
+ scoped rules. */
23
+ .malloy-render .malloy-dashboard,
24
+ .malloy-render.malloy-render .malloy-dashboard,
25
+ div.malloy-render .malloy-dashboard {
26
+ /* --publisher-dashboard-root is set on the outer Publisher wrapper
27
+ (see buildTableCssVars) and stays decoupled from
28
+ --malloy-render--background, which gets shadowed inside the
29
+ renderer when a theme.background annotation is present. The
30
+ dedicated var means the panel between tiles always paints the
31
+ operator neutral dashboardRoot regardless of annotations. */
32
+ background: var(--publisher-dashboard-root) !important;
33
+ background-color: var(--publisher-dashboard-root) !important;
34
+ color: var(--malloy-render--table-body-color) !important;
35
+ }
36
+ .malloy-render .malloy-dashboard .dashboard-row,
37
+ .malloy-render .malloy-dashboard .dashboard-row-body,
38
+ .malloy-render .malloy-dashboard .dashboard-row-header,
39
+ .malloy-render.malloy-render .malloy-dashboard .dashboard-row-header,
40
+ div.malloy-render .malloy-dashboard .dashboard-row-header {
41
+ /* Belt + suspenders: dashboard.css hardcodes .dashboard-row-header
42
+ to #f7f9fc, and row / row-body have no explicit background but
43
+ get caught in any annotation-driven inline writes. Force all of
44
+ them to the neutral panel colour. */
45
+ background: var(--publisher-dashboard-root) !important;
46
+ background-color: var(--publisher-dashboard-root) !important;
47
+ }
48
+ .malloy-render .malloy-dashboard .dashboard-item:not(.dashboard-item-borderless) {
49
+ /* Tile padding around each chart / table. Uses our custom
50
+ --malloy-render--tile-background so the operator can theme the
51
+ tile separately from the table header row (which paints from
52
+ --malloy-render--table-pinned-background below).
53
+
54
+ A flat bordered card rather than the renderer's shadow ring, which is what
55
+ makes it match the composite tile's Paper. :not(borderless) because
56
+ # borderless asks for no card at all, and an !important background and
57
+ border drew one anyway. */
58
+ background: var(--malloy-render--tile-background) !important;
59
+ color: var(--malloy-render--table-body-color) !important;
60
+ box-shadow: none !important;
61
+ border: var(--malloy-render--table-border) !important;
62
+ }
63
+ .malloy-render .malloy-dashboard .dashboard-row-header-separator {
64
+ background: var(--malloy-render--table-border) !important;
65
+ }
66
+ .malloy-render .malloy-table .th.column-cell {
67
+ /* Non-pinned tables have no header background in the renderer's
68
+ own CSS (only pinned scrolled tables paint the pinned-header
69
+ with this var). Force the same value here so every table has a
70
+ visible header band reflecting the operator's choice. */
71
+ background: var(--malloy-render--table-pinned-background) !important;
72
+ }
73
+ .malloy-render .dashboard-item-title,
74
+ .malloy-render .dashboard-dimension-name {
75
+ color: var(--malloy-render--label-color) !important;
76
+ }
77
+ .malloy-render .dashboard-item-value,
78
+ .malloy-render .dashboard-item-value-measure,
79
+ .malloy-render .dashboard-dimension-value {
80
+ color: var(--malloy-render--value-color) !important;
81
+ }
82
+ .malloy-render .malloy-table,
83
+ .malloy-render .malloy-list {
84
+ color: var(--malloy-render--table-body-color) !important;
85
+ }
86
+ .malloy-render .column-cell.th,
87
+ .malloy-render .cell-content.header {
88
+ color: var(--malloy-render--table-header-color) !important;
89
+ }
90
+ /* A cell whose column declares a "# drill" this surface can honor, marked
91
+ by markDrillableCells. Ordinary text with a pointer cursor until hovered,
92
+ then it reads as a link: the same affordance Malloyyo gives the same tag,
93
+ and the only thing that tells a reader a cell navigates. Kept off the
94
+ resting state deliberately: a column painted blue competes with the data.
95
+ (No backticks in here: this is inside a template literal.) */
96
+ .malloy-render .${g} {
97
+ cursor: pointer;
98
+ }
99
+ .malloy-render .${g}:hover > .cell-content {
100
+ color: var(--publisher-drill-link) !important;
101
+ text-decoration: underline;
102
+ }
103
+ /* Keyboard focus reads the same as hover, plus a ring: a hover colour is not
104
+ something a keyboard user can produce, and a focus ring is not something a
105
+ mouse user sees. focus-visible rather than focus, so a click does not leave a
106
+ ring behind it. (No backticks in here: this is inside a template literal.) */
107
+ .malloy-render .${g}:focus-visible {
108
+ outline: 2px solid var(--publisher-drill-link);
109
+ outline-offset: -2px;
110
+ }
111
+ .malloy-render .${g}:focus-visible > .cell-content {
112
+ color: var(--publisher-drill-link) !important;
113
+ text-decoration: underline;
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(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 q=!1;const P=()=>!q&&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(q||!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(!P())return;try{m=await Ee(C,s)}catch(f){console.error("Failed to create renderer:",f);return}if(!P()){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||!P())){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)}})(),()=>{q=!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;
@@ -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-tGvodI8f.es.js";
5
- import { aD as ke, aE as Ce, aF as xe } from "./ServerProvider-X2Ma0HRs.es.js";
4
+ import { D as ye, r as K, b as pe, a as ve, m as ge, c as we, d as ae } from "./DocumentStorage-BiFqO15i.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(), b = B(l);
40
- b && r.has(s) && n.add(b);
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), b = !l.querySelector(".value-null") && (l.textContent ?? "").trim() !== "";
56
- if (s && b && n.has(s) && !l.querySelector(".malloy-table")) {
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 u = o.has(s);
61
- u || o.add(s), l.tabIndex = u ? -1 : 0;
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 b = a.tag(s);
142
- if (!b) continue;
143
- const u = {}, g = b.text("light"), R = b.text("dark");
144
- g && (u.light = g), R && (u.dark = R), Object.keys(u).length > 0 && (o[s] = u);
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((h) => {
336
- l.current?.onClick(h);
337
- }, []), b = t !== void 0, u = z(!1), g = z(
335
+ const s = he((c) => {
336
+ l.current?.onClick(c);
337
+ }, []), y = t !== void 0, h = z(!1), g = z(
338
338
  null
339
- ), R = z(0), { theme: G, layers: U, mode: X } = Ce(), Y = ce().shape.borderRadius, J = me(
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
- R.current += 1, g.current?.viz.remove(), g.current = null;
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 h = o.current, ie = R.current += 1;
353
+ const c = o.current, ie = x.current += 1;
352
354
  let P = !1;
353
- const j = () => !P && ie === R.current;
354
- let d, m, M = null, V = 0, I = null, N = null, $ = null, O = null, F = null, T = null, W = null, Q = 0, E = null;
355
- u.current = !1;
356
- let p, S;
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, S) === "container") return;
359
- const _ = ve(p, S);
360
- if (u.current && !_) return;
361
- const C = ge(
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
- C > 0 && (u.current = !0, a && C !== Q && (Q = C, a(C)));
366
- const y = we(w, ae(p));
367
- _ && y && W !== y && (W = y, T?.disconnect(), T = new ResizeObserver(() => q(w)), T.observe(y));
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 (k) {
374
- console.error("Error parsing visualization result:", k);
375
+ } catch (b) {
376
+ console.error("Error parsing visualization result:", b);
375
377
  return;
376
378
  }
377
- const _ = await Te(w), C = _ ? xe([...U, _], X) : G;
379
+ const _ = await Te(w), k = _ ? xe([...U, _], X) : G;
378
380
  if (!j()) return;
379
381
  try {
380
- m = await Fe(C, s);
381
- } catch (k) {
382
- console.error("Failed to create renderer:", k);
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 y = g.current;
390
- d = document.createElement("div"), d.style.width = "100%", d.style.height = "100%", _e(d, C, J), y && (h.style.position = "relative", d.style.position = "absolute", d.style.inset = "0", d.style.visibility = "hidden"), h.appendChild(d);
391
- const c = d;
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(c), u.current && O?.disconnect();
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
- Z || !j() || (Z = !0, E && (clearTimeout(E), E = null), y && (y.viz.remove(), y.node.parentNode === h && h.removeChild(y.node)), c.style.position = "", c.style.inset = "", c.style.visibility = "", h.style.position = "", g.current = { viz: se, node: c }, q(c));
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 x = m.getMetadata(), A = x?.getRootField();
410
- p = A?.renderAs(), S = A ? x?.getPluginsForField(A.key)?.[0]?.sizingStrategy : void 0;
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, S = void 0;
419
+ p = void 0, E = void 0;
413
420
  }
414
- n?.(K(p, S)), d.dataset.malloyRenderAs = p ?? "unknown", d.dataset.malloySizing = K(p, S), m.render(d);
415
- const k = l.current;
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 (k) {
418
- const x = Re(m, k.canDrill), A = () => {
424
+ if (b) {
425
+ const C = Re(m, b.canDrill), A = () => {
419
426
  try {
420
- Ee(c, x);
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
- }, c.addEventListener("keydown", I), c.addEventListener("keyup", N), c.addEventListener("focusin", $), x.size > 0 && typeof MutationObserver < "u" && (M = new MutationObserver(() => {
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(c, {
465
+ }), M.observe(u, {
459
466
  childList: !0,
460
467
  subtree: !0
461
468
  }));
462
469
  }
463
- } catch (x) {
464
- console.warn("Drill affordance skipped:", x);
470
+ } catch (C) {
471
+ console.warn("Drill affordance skipped:", C);
465
472
  }
466
- m.onReady(ee), E = setTimeout(ee, 1e4);
467
- } catch (k) {
468
- console.error("Error rendering visualization:", k), O?.disconnect(), T?.disconnect(), M?.disconnect(), m.remove(), m = void 0, c.parentNode === h && h.removeChild(c);
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), E && clearTimeout(E), 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 === h && h.removeChild(d), h.style.position = "");
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
- b,
483
+ y,
477
484
  a,
478
485
  n,
479
486
  G,