@malloy-publisher/sdk 0.9.16 → 0.10.0

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 (41) hide show
  1. package/dist/{RenderedResult-5hOs5XnV.cjs.js → RenderedResult-B5f4qOjp.cjs.js} +1 -1
  2. package/dist/{RenderedResult-DxmHGZNQ.es.js → RenderedResult-DiDsN6JE.es.js} +1 -1
  3. package/dist/builder/index.cjs.js +17 -17
  4. package/dist/builder/index.es.js +277 -265
  5. package/dist/components/ReportBuilder/TextTileBody.d.ts +9 -2
  6. package/dist/components/legacy/malloynb/CellRunnerView.d.ts +6 -6
  7. package/dist/hooks/useSettled.d.ts +5 -8
  8. package/dist/hooks/useSettledDraft.d.ts +33 -0
  9. package/dist/index.cjs.js +10 -10
  10. package/dist/index.es.js +3769 -3779
  11. package/dist/useCompiledDocument-C995sQ3j.cjs.js +142 -0
  12. package/dist/{useCompiledDocument-CaYP_OYG.es.js → useCompiledDocument-CRmmbUza.es.js} +5449 -5294
  13. package/dist/utils/malloyLiteral.d.ts +2 -0
  14. package/package.json +11 -16
  15. package/src/components/ReportBuilder/BuilderGrid.tsx +1 -0
  16. package/src/components/ReportBuilder/TextTileBody.tsx +24 -4
  17. package/src/components/ReportBuilder/placement.spec.ts +27 -0
  18. package/src/components/ReportBuilder/placement.ts +8 -4
  19. package/src/components/given/GivenInput.spec.tsx +447 -2
  20. package/src/components/given/GivenInput.tsx +192 -80
  21. package/src/components/given/GivensPanel.spec.tsx +59 -0
  22. package/src/components/given/GivensPanel.tsx +14 -2
  23. package/src/components/legacy/malloynb/CellRunnerView.tsx +6 -6
  24. package/src/hooks/useDimensionFilters.ts +1 -35
  25. package/src/hooks/useDimensionFiltersQuery.ts +2 -36
  26. package/src/hooks/useDimensionalFilterRangeData.ts +1 -35
  27. package/src/hooks/useGivensState.spec.ts +106 -1
  28. package/src/hooks/useGivensState.ts +48 -13
  29. package/src/hooks/useSettled.ts +5 -8
  30. package/src/hooks/useSettledDraft.ts +127 -0
  31. package/src/utils/malloyLiteral.spec.ts +12 -1
  32. package/src/utils/malloyLiteral.ts +32 -0
  33. package/vite.config.ts +0 -2
  34. package/.eslintrc +0 -36
  35. package/dist/components/DOMElement/DOMElement.d.ts +0 -5
  36. package/dist/components/DOMElement/index.d.ts +0 -1
  37. package/dist/components/Package/FileTreeView.d.ts +0 -9
  38. package/dist/useCompiledDocument-zYEfLogf.cjs.js +0 -142
  39. package/src/components/DOMElement/DOMElement.tsx +0 -22
  40. package/src/components/DOMElement/index.ts +0 -4
  41. package/src/components/Package/FileTreeView.tsx +0 -244
@@ -1,4 +1,4 @@
1
- "use strict";const L=require("react/jsx-runtime"),ie=require("@mui/material"),g=require("react"),h=require("./useCompiledDocument-zYEfLogf.cjs.js"),H=require("./ServerProvider-e2369oom.cjs.js"),v=h.reportClasses.drillCell;function ue(e,t){const o=new Set;let l;try{l=e.getMetadata()?.getAllFields()??[]}catch{return o}const r=new Set;for(const a of l)!a||t(a)||a.tag?.tag("hidden")===void 0&&r.add(a.tag?.text("label")??a.name);for(const a of l){if(!a||!t(a))continue;const n=a.tag?.text("label")??a.name;r.has(n)||o.add(n)}return o}function $(e){const t=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return t?t[1]:void 0}function he(e,t){if(t.size!==0)for(const o of e.querySelectorAll(".malloy-table")){const l=n=>n.closest(".malloy-table")===o,r=new Set;for(const n of o.querySelectorAll(".column-cell.th")){if(!l(n))continue;const i=(n.textContent??"").replace(/\u200b/g,"").trim(),m=$(n);m&&t.has(i)&&r.add(m)}if(r.size===0)continue;const a=new Set;for(const n of o.querySelectorAll(`.${v}[tabindex="0"]`)){if(!l(n))continue;const i=$(n);i&&(a.has(i)?n.tabIndex=-1:a.add(i))}for(const n of o.querySelectorAll(".column-cell.td")){if(!l(n))continue;const i=$(n),m=!n.querySelector(".value-null")&&(n.textContent??"").trim()!=="";if(i&&m&&r.has(i)&&!n.querySelector(".malloy-table")){if(n.classList.add(v),n.tabIndex===0)a.add(i);else{const w=a.has(i);w||a.add(i),n.tabIndex=w?-1:0}n.setAttribute("role","button")}}}}function ke(e){const t=e.closest(".malloy-table"),o=$(e);return!t||!o?[]:Array.from(t.querySelectorAll(`.${v}`)).filter(l=>l.closest(".malloy-table")===t&&$(l)===o)}function se(e,t){const o=ke(e),l=o.indexOf(e);if(l===-1)return;const r=t==="first"?o[0]:t==="last"?o[o.length-1]:o[Math.min(Math.max(l+t,0),o.length-1)];if(r){for(const a of o)a.tabIndex=a===r?0:-1;return r}}function me(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 be(e){const{foreground:t,axisFaint:o,gridline:l,font:r}=e,a={background:e.background,font:r.family,title:{color:t,font:r.family},axis:{labelColor:t,titleColor:t,domainColor:o,tickColor:o,gridColor:l,labelFont:r.family,titleFont:r.family},legend:{labelColor:t,titleColor:t,labelFont:r.family,titleFont:r.family},header:{labelColor:t,titleColor:t},range:{category:e.series}},n={...a,legend:{...a.legend,orient:"bottom"}};return i=>i==="shape_map"?n:a}function ye(e){if(!e)return;const t=e.tag("theme");if(!t)return;const o={},l=t.tag("palette");if(l){const a={},n=l.textArray("series");n&&n.length>0&&(a.series=n);for(const i of H.PER_MODE_COLOR_KEYS){const m=l.tag(i);if(!m)continue;const w={},C=m.text("light"),x=m.text("dark");C&&(w.light=C),x&&(w.dark=x),Object.keys(w).length>0&&(a[i]=w)}Object.keys(a).length>0&&(o.palette=a)}const r=t.tag("font");if(r){const a={},n=r.text("family");n&&(a.family=n);const i=r.numeric("size");typeof i=="number"&&Number.isFinite(i)&&(a.size=i),Object.keys(a).length>0&&(o.font=a)}return Object.keys(o).length>0?o:void 0}const J=e=>(e??[]).map(t=>t?.value).filter(t=>typeof t=="string");function xe(e){const t=e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const Ce=e=>J(e.annotations).some(t=>{const o=t.trim();return/^#[^("]/.test(o)&&/(?:^#|[\s{])label\s*=/.test(o)}),Re=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Te=e=>e.type?.element_type?.fields??e.type?.fields;function fe(e,t){let o=!1;return{fields:e.map(r=>{const a=Te(r);if(a){const i=fe(a,h.requestsRowChart(J(r.annotations)));if(!i.changed)return r;o=!0;const m=r.type?.element_type?{...r.type,element_type:{...r.type.element_type,fields:i.fields}}:{...r.type,fields:i.fields};return{...r,type:m}}if(!t||!r.name||Ce(r))return r;const n=xe(r.name);return n===r.name?r:(o=!0,{...r,annotations:[{value:`# label=${Re(n)}
1
+ "use strict";const L=require("react/jsx-runtime"),ie=require("@mui/material"),g=require("react"),h=require("./useCompiledDocument-C995sQ3j.cjs.js"),H=require("./ServerProvider-e2369oom.cjs.js"),v=h.reportClasses.drillCell;function ue(e,t){const o=new Set;let l;try{l=e.getMetadata()?.getAllFields()??[]}catch{return o}const r=new Set;for(const a of l)!a||t(a)||a.tag?.tag("hidden")===void 0&&r.add(a.tag?.text("label")??a.name);for(const a of l){if(!a||!t(a))continue;const n=a.tag?.text("label")??a.name;r.has(n)||o.add(n)}return o}function $(e){const t=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return t?t[1]:void 0}function he(e,t){if(t.size!==0)for(const o of e.querySelectorAll(".malloy-table")){const l=n=>n.closest(".malloy-table")===o,r=new Set;for(const n of o.querySelectorAll(".column-cell.th")){if(!l(n))continue;const i=(n.textContent??"").replace(/\u200b/g,"").trim(),m=$(n);m&&t.has(i)&&r.add(m)}if(r.size===0)continue;const a=new Set;for(const n of o.querySelectorAll(`.${v}[tabindex="0"]`)){if(!l(n))continue;const i=$(n);i&&(a.has(i)?n.tabIndex=-1:a.add(i))}for(const n of o.querySelectorAll(".column-cell.td")){if(!l(n))continue;const i=$(n),m=!n.querySelector(".value-null")&&(n.textContent??"").trim()!=="";if(i&&m&&r.has(i)&&!n.querySelector(".malloy-table")){if(n.classList.add(v),n.tabIndex===0)a.add(i);else{const w=a.has(i);w||a.add(i),n.tabIndex=w?-1:0}n.setAttribute("role","button")}}}}function ke(e){const t=e.closest(".malloy-table"),o=$(e);return!t||!o?[]:Array.from(t.querySelectorAll(`.${v}`)).filter(l=>l.closest(".malloy-table")===t&&$(l)===o)}function se(e,t){const o=ke(e),l=o.indexOf(e);if(l===-1)return;const r=t==="first"?o[0]:t==="last"?o[o.length-1]:o[Math.min(Math.max(l+t,0),o.length-1)];if(r){for(const a of o)a.tabIndex=a===r?0:-1;return r}}function me(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 be(e){const{foreground:t,axisFaint:o,gridline:l,font:r}=e,a={background:e.background,font:r.family,title:{color:t,font:r.family},axis:{labelColor:t,titleColor:t,domainColor:o,tickColor:o,gridColor:l,labelFont:r.family,titleFont:r.family},legend:{labelColor:t,titleColor:t,labelFont:r.family,titleFont:r.family},header:{labelColor:t,titleColor:t},range:{category:e.series}},n={...a,legend:{...a.legend,orient:"bottom"}};return i=>i==="shape_map"?n:a}function ye(e){if(!e)return;const t=e.tag("theme");if(!t)return;const o={},l=t.tag("palette");if(l){const a={},n=l.textArray("series");n&&n.length>0&&(a.series=n);for(const i of H.PER_MODE_COLOR_KEYS){const m=l.tag(i);if(!m)continue;const w={},C=m.text("light"),x=m.text("dark");C&&(w.light=C),x&&(w.dark=x),Object.keys(w).length>0&&(a[i]=w)}Object.keys(a).length>0&&(o.palette=a)}const r=t.tag("font");if(r){const a={},n=r.text("family");n&&(a.family=n);const i=r.numeric("size");typeof i=="number"&&Number.isFinite(i)&&(a.size=i),Object.keys(a).length>0&&(o.font=a)}return Object.keys(o).length>0?o:void 0}const J=e=>(e??[]).map(t=>t?.value).filter(t=>typeof t=="string");function xe(e){const t=e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const Ce=e=>J(e.annotations).some(t=>{const o=t.trim();return/^#[^("]/.test(o)&&/(?:^#|[\s{])label\s*=/.test(o)}),Re=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Te=e=>e.type?.element_type?.fields??e.type?.fields;function fe(e,t){let o=!1;return{fields:e.map(r=>{const a=Te(r);if(a){const i=fe(a,h.requestsRowChart(J(r.annotations)));if(!i.changed)return r;o=!0;const m=r.type?.element_type?{...r.type,element_type:{...r.type.element_type,fields:i.fields}}:{...r.type,fields:i.fields};return{...r,type:m}}if(!t||!r.name||Ce(r))return r;const n=xe(r.name);return n===r.name?r:(o=!0,{...r,annotations:[{value:`# label=${Re(n)}
2
2
  `},...r.annotations??[]]})}),changed:o}}function _e(e){if(!e||typeof e!="object")return e;const t=e,o=t.schema?.fields;if(!Array.isArray(o))return e;const{fields:l,changed:r}=fe(o,h.requestsRowChart(J(t.annotations)));return r?{...t,schema:{...t.schema,fields:l}}:e}const de=320,Ae=10,Ee=96,Se=4e3;function De(e,t){if(e!=="bar"&&e!=="combo"&&e!=="line"&&e!=="chart"&&e!=="scatter_chart")return;if(e!=="bar"&&e!=="combo")return de;const o=t?.data?.array_value?.length,l=o===void 0?0:o*Ae+Ee;return Math.min(Math.max(de,l),Se)}const M="data-publisher-fill",Ie=async(e,t)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:o}=await h.loadMalloyRenderer();return new o({onClick:t,vegaConfigOverride:be(e),theme:me(e),onError:r=>{console.error("Error rendering visualization:",typeof r,r)}}).createViz()};async function Oe(e){if(!e||typeof e!="object")return;const t=e,o=[...Array.isArray(t.model_annotations)?t.model_annotations:[],...Array.isArray(t.source_annotations)?t.source_annotations:[],...Array.isArray(t.annotations)?t.annotations:[]].map(r=>typeof r?.value=="string"?r.value:void 0).filter(r=>!!r);if(o.length===0)return;let l;try{({parseAnnotation:l}=await h.loadMalloyTag())}catch{return}try{const{tag:r}=l(o);return ye(r)}catch(r){console.warn("Failed to parse # theme.* annotations; chart will render with the shell theme.",{error:r,lines:o});return}}function ze(e,t,o){const l=h.buildTableCssVars(t,o);for(const[r,a]of Object.entries(l))e.style.setProperty(r,a)}const Fe=`
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,7 +1,7 @@
1
1
  import { jsx as M } from "react/jsx-runtime";
2
2
  import { Box as ie } from "@mui/material";
3
3
  import { Suspense as pe, useRef as z, useCallback as ge, useMemo as ve, useEffect as we, useLayoutEffect as ke } from "react";
4
- import { r as xe, a as he, D as Ce, b as Y, T as H, l as Re, c as Ee, d as Te, e as _e, m as Ae, f as Se, g as se } from "./useCompiledDocument-CaYP_OYG.es.js";
4
+ import { r as xe, a as he, D as Ce, b as Y, T as H, l as Re, c as Ee, d as Te, e as _e, m as Ae, f as Se, g as se } from "./useCompiledDocument-CRmmbUza.es.js";
5
5
  import { ba as De, b8 as Oe, bb as Fe, bc as ze } from "./ServerProvider-D7neZcTk.es.js";
6
6
  const v = xe.drillCell;
7
7
  function Me(e, t) {