@graphysdk/react-renderer 1.9.0-beta.1790233123402 → 1.9.0-beta.1790263076123

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/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const i=require("./use-target-boundary-DMdRic0P.cjs"),se=require("./theme.contract.css-DKDKSByt.cjs");let m=require("@graphysdk/viz-engine"),l=require("react"),a=require("react/jsx-runtime"),Y=require("zustand"),O=require("zustand/vanilla"),L=require("clsx");L=i.__toESM(L,1);var ne="_1a5iqpb0",oe="_1a5iqpb1";var ae="_1a5iqpb3",ie="_1a5iqpb4",ce="_1a5iqpb5";var B=({errors:e})=>{const[t,...s]=e;return(0,a.jsxs)("div",{role:"alert",className:ne,children:[(0,a.jsx)("strong",{className:oe,children:"This chart could not be rendered."}),t&&(0,a.jsx)(F,{diagnostic:t}),s.length>0&&(0,a.jsx)("ul",{className:"_1a5iqpb2",children:s.map((r,o)=>(0,a.jsx)("li",{children:(0,a.jsx)(F,{diagnostic:r})},`${r.code}-${o}`))})]})},F=({diagnostic:e})=>(0,a.jsxs)("div",{className:ae,children:[(0,a.jsx)("span",{className:ie,children:e.code}),(0,a.jsx)("p",{className:ce,children:e.message}),e.suggestion&&(0,a.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function le(e=[],t=[]){return e.length===t.length&&e.every((s,r)=>Object.is(s,t[r]))}var X=class extends l.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,m.buildDiagnostic)(e)}}componentDidCatch(e,t){const s=(0,m.buildDiagnostic)(e);i.logDiagnostics([s]),this.props.onError?.([s]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!le(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,a.jsx)(B,{errors:[e]});const{forcedErrors:t,children:s}=this.props;return t&&t.length>0?(0,a.jsx)(B,{errors:t}):s}},Q=e=>typeof e=="object"&&"geom"in e&&"render"in e,de=e=>{const t=(0,m.resolveDefinition)(e);return t instanceof m.Geom?t:null},J=(e,t)=>{const s=e.filter(r=>ue(r,t));return s.length===e.length?e:s},ue=(e,t)=>e.kind==="annotation"?(0,m.findAnnotation)(t.annotations,e.id)!==null:e.kind==="observations"||e.kind==="layer"&&e.layerId!==void 0?(0,m.findLayerById)(t.layers,e.layerId)!==void 0:!0,V=[],ge=()=>(0,O.createStore)(e=>({selection:V,setSelection:t=>e(s=>he(s.selection,t)?s:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:V})})),he=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((s,r)=>{const o=t[r];return o!==void 0&&(0,m.areEditTargetsEqual)(s,o)}),me=process.env.NODE_ENV!=="production",pe=5,ve=e=>{if(!me)return{emit:()=>{},subscribe:()=>ye,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let s=null;return{emit:r=>{const o=e.getLastCompile();if(o){s=r;for(const d of t)d(r,o)}},subscribe:r=>(t.add(r),()=>{t.delete(r)}),getLastTrigger:()=>s,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},fe=()=>(0,O.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,s)=>e(r=>{if(r.lastSnapshot===s)return r;const o={id:r.nextId,label:Se(t),stages:s.stages,stageDurationsMs:s.stageDurationsMs,durationMs:s.durationMs};return{lastCompile:o,history:be(r.history,o,pe),nextId:r.nextId+1,lastSnapshot:s}})})),ye=()=>{},Se=e=>{switch(e.kind){case"init":return"init";case"spec":return"spec change";case"data":return"data change";case"command":return e.command.metadata.description}},be=(e,t,s)=>{const r=e.length>=s?e.length-(s-1):0;return[...e.slice(r),t]};function Ee(e){const t=e.filter(Q),s=new Set([...Object.keys(i.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),r=[],o=new Set;for(const u of e){const h=de(u);h===null||s.has(h.type)||o.has(h.type)||(o.add(h.type),r.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${h.type}' is registered but has no renderer.`,context:{requested:h.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${h.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const d=new Map;for(const u of t){if("definition"in u)continue;const h=`${u.geom}|${u.coord}`,p=d.get(h);p?p.count+=1:d.set(h,{geom:u.geom,coord:u.coord,count:1})}const c=[];for(const{geom:u,coord:h,count:p}of d.values())p<2||c.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${h}') (${p} entries); the last in the array wins.`,context:{requested:`${u}@${h}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${h}').`});return{errors:r,warnings:c}}function Te(e,t){const{coordSystem:s,layers:r}=e,o=new Set,d=[];for(const c of r)t(c.geom,s.type)!==null||o.has(c.geom)||(o.add(c.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${c.geom}' under ${s.type} coords; the layer is not painted.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${c.geom}', '${s.type}') via \`defineGeomRenderer\`.`}));return d}function xe(e,t){const{coordSystem:s,layers:r}=e,o=new Set,d=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||o.has(c.geom))continue;const u=t(c.geom,s.type);u===null||u.hitTest||i.isOverlayHosted(u)||(o.add(c.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Add a \`hitTest\` factory (precomputed geometry) or an overlay render (\`{ fn, options: { overlay: true } }\`, live simulation) to the renderer for ('${c.geom}', '${s.type}').`}))}return d}function Re(e){const t=new Set,s=[];for(const r of e.layers){const o=r.identityKey;r.interactive!==!1&&(r.spatialKind!=="render-hit-test"||typeof o!="object"||t.has(r.geom)||r.data.hasVariable(o.variable)||(t.add(r.geom),s.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${r.geom}' keys its identity on '${o.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:r.geom,kind:"geom-renderer"},suggestion:`Emit the '${o.variable}' column from the geom's \`compile()\`, or point \`identityKey\` at a column it does emit.`})))}return s}function Ce(e,t){const{coordSystem:s,layers:r}=e,o=new Set,d=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||o.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!u.hitTest||!i.isOverlayHosted(u)||(o.add(c.geom),d.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR an overlay render (`{ fn, options: { overlay: true } }`) for a live simulation."}))}return d}function Ge(e,t){const s=new Set,r=[];for(const o of e.layers)o.interactive!==!1&&(o.spatialKind!=="render-hit-test"||s.has(o.geom)||t.hasCapability(o.geom)||(s.add(o.geom),r.push({kind:"user-input",severity:"warning",code:"MISSING_ANCHOR_CAPABILITY",message:`Geom '${o.geom}' declares no \`resolveAnchorPosition\`; its observations cannot be annotated, so the editor overlay paints no creation trigger on them.`,context:{requested:o.geom,kind:"geom-renderer"},suggestion:"Implement `resolveAnchorPosition(observation, context)` on the geom, returning the normalised panel position an annotation on that observation belongs at."})));return r}function qe(e,t){const{coordSystem:s,layers:r}=e,o=new Set,d=[];for(const c of r){if(c.interactive===!1||c.spatialKind==="render-hit-test"||o.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!i.isOverlayHosted(u)||(o.add(c.geom),d.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares an overlay render but its layer's spatialKind is '${c.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the scene layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return d}var ke=e=>(0,O.createStore)(t=>({scene:e,setScene:s=>t(r=>r.scene===s?r:{scene:s})})),Ne=({spec:e,data:t,customPalettes:s,colorScheme:r,plugins:o,resolveRenderer:d,anchorResolver:c,onSpecChange:u,onError:h,onWarnings:p})=>{const T=i.useLatestRef(u),j=i.useLatestRef(h),G=i.useLatestRef(p),[{session:v,compileBus:g}]=(0,l.useState)(()=>{const n=(0,m.createCompiler)({plugins:o});return{session:new m.GraphCompilationSession(n),compileBus:ve(n)}}),[y]=(0,l.useState)(()=>Ee(o??[])),q=(0,l.useRef)(null),[S]=(0,l.useState)(je),x=(0,l.useRef)(null),k=(0,l.useCallback)(n=>y.errors.length===0?n:[...y.errors,...n??[]],[y]),R=(0,l.useCallback)(n=>{if(!n.ok)return n.errors;if(x.current)x.current.getState().setScene(n.scene);else{const f=ke(n.scene);f.subscribe(S.notify),x.current=f,S.notify()}return null},[S]),[H,D]=(0,l.useState)(()=>{const n=v.compile({spec:e,data:t,customPalettes:s,colorScheme:r});return q.current=n,k(R(n))}),C=(0,l.useCallback)(n=>n.ok?[...n.warnings,...Te(n.scene,d),...xe(n.scene,d),...Re(n.scene),...Ce(n.scene,d),...qe(n.scene,d),...Ge(n.scene,c)]:n.warnings,[d,c]),N=(0,l.useCallback)(n=>{n.length!==0&&(i.logDiagnostics(n),j.current?.(n))},[j]),b=(0,l.useCallback)(n=>{n.length!==0&&(i.logDiagnostics(n),G.current?.(n))},[G]);(0,l.useEffect)(()=>{const n=q.current;n&&(N([...y.errors,...n.ok?[]:n.errors]),b([...y.warnings,...C(n)]),n.ok&&g.emit({kind:"init"}))},[g,N,b,y,C]),(0,l.useEffect)(()=>{const n=v.update({spec:e,data:t,customPalettes:s,colorScheme:r});if(!n)return;n.committedSpec&&T.current?.(n.committedSpec);const f=R(n.result);D(k(f)),f&&N(f),b(C(n.result)),f||g.emit({kind:n.specChanged?"spec":"data"})},[e,t,s,r,v,g,R,N,b,k,C,T]);const I=(0,l.useCallback)(n=>{D(f=>f===null?f:k(null)),b(C(n))},[k,b,C]),_=(0,l.useCallback)(n=>{n.scene&&x.current?.getState().setScene(n.scene),n.result&&I(n.result),n.command&&g.emit({kind:"command",command:n.command}),n.spec&&T.current?.(n.spec),n.errors&&N([...n.errors])},[I,g,T,N]),E=(0,l.useCallback)(n=>{for(const f of n)_(f);return n.some(f=>!!f.scene)},[_]),M=(0,l.useCallback)((n,f)=>{E(v.applyCommand(n,f))},[v,E]),$=(0,l.useCallback)(()=>{E(v.commit())},[v,E]),K=(0,l.useCallback)(()=>E(v.undo()),[v,E]),U=(0,l.useCallback)(()=>E(v.redo()),[v,E]),te=(0,l.useMemo)(()=>({stack:v.history,undo:K,redo:U}),[v,K,U]),re=(0,l.useCallback)(()=>x.current?.getState().scene??null,[]);return{store:x.current,dispatch:M,commit:$,history:te,subscribe:S.subscribe,getScene:re,compileBus:g,compileErrors:H}},je=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},Z=({data:e,spec:t,plugins:s=[],formattingLocale:r,handleRef:o,onSpecChange:d,onError:c,onWarnings:u,customPalettes:h,colorScheme:p="light",children:T})=>{const[j]=(0,l.useState)(()=>i.createGeomRendererResolver(s.filter(Q))),G=(0,l.useId)(),[v]=(0,l.useState)(()=>(0,m.createAnchorResolver)(s)),[g]=(0,l.useState)(()=>ge()),[y]=(0,l.useState)(()=>i.createTargetBoundaryStore()),q=(0,l.useMemo)(()=>(0,m.createStyleResolver)({colorScheme:p}),[p]),{store:S,dispatch:x,commit:k,history:R,subscribe:H,getScene:D,compileBus:C,compileErrors:N}=Ne({spec:t,data:e,customPalettes:h,colorScheme:p,plugins:s,resolveRenderer:j,anchorResolver:v,onSpecChange:d,onError:c,onWarnings:u});(0,l.useEffect)(()=>{if(S)return S.subscribe((_,E)=>{if(_.scene.spec===E.scene.spec)return;const{selection:M,setSelection:$}=g.getState();M.length!==0&&$(J(M,_.scene.spec))})},[S,g]);const b=(0,l.useMemo)(()=>({dispatch:x,commit:k}),[x,k]);(0,l.useImperativeHandle)(o,()=>({commands:b,undo:R.undo,redo:R.redo,subscribe:H,getScene:D,getSelection:()=>g.getState().selection,setSelection:_=>g.getState().setSelection(_),subscribeSelection:g.subscribe}),[b,R,H,D,g]);const I=(0,l.useMemo)(()=>S?{chartId:G,store:S,selectionStore:g,targetBoundaryStore:y,commands:b,history:R,formattingLocale:r,compileBus:C,colorScheme:p,styleResolver:q,anchorResolver:v}:null,[G,S,g,y,b,R,r,C,p,q,v]);return(0,a.jsx)(X,{forcedErrors:N,onError:c,resetKeys:[t,e],children:I?(0,a.jsx)(i.GraphContext.Provider,{value:I,children:(0,a.jsx)(i.GeomRendererResolverProvider,{value:j,children:T})}):null})};function _e(e){const t=(0,m.createSpecBuilder)(e);return{...t,GraphProvider:r=>(0,a.jsx)(Z,{...r,plugins:t.plugins})}}var De=({children:e,...t})=>(0,a.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),Ie=({box:e,children:t})=>(0,a.jsx)("svg",{x:(0,m.toPercent)(e.x0),y:(0,m.toPercent)(e.y0),width:(0,m.toPercent)(e.x1-e.x0),height:(0,m.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:t}),we="drqe3u0",He="drqe3u1",Me="drqe3u2",Pe="drqe3u3",w="drqe3u4",$e="drqe3u5",Le="drqe3u6",Be="drqe3u7",P="drqe3u8",Oe="drqe3u9",Ae="drqe3ua";var Ke="drqe3uc",Ue="drqe3ud",Ye="drqe3ue",Fe="drqe3uf";var Ve="drqe3uh",We="drqe3ui",W={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},z={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},ee={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ze=({width:e=440,style:t,className:s}={})=>{const{compileBus:r}=i.useGraphContext(),[o]=(0,l.useState)(()=>fe()),[d,c]=(0,l.useState)(!1),[u,h]=(0,l.useState)(m.isCompilerCachingEnabled);(0,l.useEffect)(()=>{const{recordCompile:g}=o.getState(),y=r.getLastTrigger(),q=r.getLastCompile();return y&&q&&g(y,q),r.subscribe(g)},[o,r]);const p=(0,Y.useStore)(o,g=>g.lastCompile),T=(0,Y.useStore)(o,g=>g.history),j=r.getCacheStats(),G=p===null&&T.length===0,v=()=>{h(g=>{const y=!g;return(0,m.setCompilerCachingEnabled)(y),y})};return(0,a.jsxs)("div",{className:(0,L.default)(Ae,s),style:{width:e,...t},children:[(0,a.jsxs)("div",{className:we,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:He,children:"compile cache"}),(0,a.jsx)("div",{className:Ye,children:G?"production: stats disabled":p?`last: ${p.label} · ${A(p.durationMs)}`:"awaiting first compile…"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>c(g=>!g),className:Fe,children:d?"▾":"▴"})]}),!d&&(0,a.jsxs)("div",{className:"drqe3ub",children:[(0,a.jsxs)("button",{type:"button",onClick:v,className:u?W.enabled:W.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,a.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!d&&!G&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Xe,{delta:p?.stages,durations:p?.stageDurationsMs,cumulative:j}),(0,a.jsx)(Qe,{entries:T})]})]})},Xe=({delta:e,durations:t,cumulative:s})=>(0,a.jsxs)("table",{className:Me,children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:Ve,children:[(0,a.jsx)("th",{className:Pe,children:"stage"}),(0,a.jsx)("th",{className:w,children:"time"}),(0,a.jsx)("th",{className:w,children:"Δ miss"}),(0,a.jsx)("th",{className:w,children:"Δ hit"}),(0,a.jsx)("th",{className:w,children:"total miss"}),(0,a.jsx)("th",{className:w,children:"total hit"})]})}),(0,a.jsx)("tbody",{children:m.COMPILER_STAGE_KEYS.map(r=>{const o=e?.[r],d=Je(o);return(0,a.jsxs)("tr",{className:Ke,children:[(0,a.jsxs)("td",{className:$e,children:[(0,a.jsx)("span",{className:ee[d],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:P,children:t===void 0||d==="untouched"?"—":A(t[r])}),(0,a.jsx)("td",{className:d==="ran"?z.ran:z.dim,children:o?.misses??0}),(0,a.jsx)("td",{className:P,children:o?.hits??0}),(0,a.jsx)("td",{className:P,children:s[r].misses}),(0,a.jsx)("td",{className:P,children:s[r].hits})]},r)})})]}),Qe=({entries:e})=>e.length===0?null:(0,a.jsxs)("div",{className:Ue,children:[(0,a.jsx)("div",{className:We,children:"recent compiles"}),e.map(t=>{const s=Ze(t.stages,d=>d.misses>0),r=m.COMPILER_STAGE_KEYS.length,o=s===0?"cached":"ran";return(0,a.jsxs)("div",{className:Le,children:[(0,a.jsx)("span",{className:ee[o],"aria-hidden":!0}),(0,a.jsx)("span",{className:Be,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Oe,children:[s,"/",r," ran · ",A(t.durationMs)]})]},t.id)})]}),Je=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",Ze=(e,t)=>{let s=0;for(const r of m.COMPILER_STAGE_KEYS)t(e[r])&&(s+=1);return s},A=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,et=()=>{const{history:e}=i.useGraphContext(),{stack:t,undo:s,redo:r}=e,o=(0,l.useCallback)(u=>t.subscribe(u),[t]),d=(0,l.useCallback)(()=>t.getSnapshot(),[t]),c=(0,l.useSyncExternalStore)(o,d,d);return(0,l.useMemo)(()=>({...c,undo:s,redo:r}),[c,s,r])},tt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),rt=(e,t={})=>{const{target:s,enabled:r=!0}=t;(0,l.useEffect)(()=>{const o=st(s);if(!r||!o)return;const d=c=>{if(!nt(c)||c.defaultPrevented||ot(c.target))return;const u=i.resolveHistoryStep(c);if(!u)return;const h=e.current;h&&(u==="undo"?h.undo():h.redo())&&c.preventDefault()};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[e,s,r])},st=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,nt=e=>"key"in e,ot=e=>e instanceof HTMLInputElement?!tt.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1;exports.BrandMark=i.BrandMark;exports.CanvasTextMeasurer=i.CanvasTextMeasurer;exports.DefaultFooter=i.DefaultFooter;exports.DefaultGrid=i.DefaultGrid;exports.DefaultHeader=i.DefaultHeader;exports.DefaultSwatch=i.DefaultSwatch;exports.DefaultTooltip=i.DefaultTooltip;exports.DevToolsPanel=ze;exports.GRAPH_MODES=i.GRAPH_MODES;exports.GraphErrorBoundary=X;exports.GraphErrorPanel=B;exports.GraphProvider=Z;exports.GraphRenderer=i.GraphRenderer;exports.HoverProvider=i.HoverProvider;exports.TextMeasurerProvider=i.TextMeasurerProvider;exports.ThemeProvider=i.ThemeProvider;exports.UnitBoxSvg=Ie;exports.UnitSpaceSvg=De;exports.createGraphyKit=_e;exports.darkTheme=i.darkTheme;exports.defineGeomRenderer=i.defineGeomRenderer;exports.lightTheme=i.lightTheme;exports.lightenCss=i.lightenCss;exports.pruneSelection=J;exports.resolveBrandMarkVisual=i.resolveBrandMarkVisual;exports.stampAxisEditTarget=i.stampAxisEditTarget;exports.stampGridEditTarget=i.stampGridEditTarget;exports.stampLegendEditTarget=i.stampLegendEditTarget;exports.useElementScreenRect=i.useElementScreenRect;exports.useGeomHitTest=i.useGeomHitTest;exports.useGeomHover=i.useGeomHover;exports.useGeomReaderTree=i.useGeomReaderTree;exports.useGraphCommands=i.useGraphCommands;exports.useGraphHandle=i.useGraphHandle;exports.useGraphHistory=et;exports.useGraphHistoryShortcuts=rt;exports.useGraphSelection=i.useGraphSelection;exports.useGuidesTakePress=i.useGuidesTakePress;exports.useHandleScene=i.useHandleScene;exports.useHoverState=i.useHoverState;exports.useResolvedStyle=i.useResolvedStyle;exports.useSceneSelector=i.useSceneSelector;exports.useStyleReaderTree=i.useStyleReaderTree;exports.useStyleReaders=i.useStyleReaders;exports.useStyleResolver=i.useStyleResolver;exports.useTargetBoundary=i.useTargetBoundary;exports.useTextMeasurer=i.useTextMeasurer;exports.vars=se.vars;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const i=require("./use-target-boundary-CfIbCLSH.cjs"),se=require("./theme.contract.css-DKDKSByt.cjs");let m=require("@graphysdk/viz-engine"),l=require("react"),a=require("react/jsx-runtime"),Y=require("zustand"),O=require("zustand/vanilla"),L=require("clsx");L=i.__toESM(L,1);var ne="_1a5iqpb0",oe="_1a5iqpb1";var ae="_1a5iqpb3",ie="_1a5iqpb4",ce="_1a5iqpb5";var B=({errors:e})=>{const[t,...s]=e;return(0,a.jsxs)("div",{role:"alert",className:ne,children:[(0,a.jsx)("strong",{className:oe,children:"This chart could not be rendered."}),t&&(0,a.jsx)(F,{diagnostic:t}),s.length>0&&(0,a.jsx)("ul",{className:"_1a5iqpb2",children:s.map((r,o)=>(0,a.jsx)("li",{children:(0,a.jsx)(F,{diagnostic:r})},`${r.code}-${o}`))})]})},F=({diagnostic:e})=>(0,a.jsxs)("div",{className:ae,children:[(0,a.jsx)("span",{className:ie,children:e.code}),(0,a.jsx)("p",{className:ce,children:e.message}),e.suggestion&&(0,a.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function le(e=[],t=[]){return e.length===t.length&&e.every((s,r)=>Object.is(s,t[r]))}var X=class extends l.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,m.buildDiagnostic)(e)}}componentDidCatch(e,t){const s=(0,m.buildDiagnostic)(e);i.logDiagnostics([s]),this.props.onError?.([s]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!le(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,a.jsx)(B,{errors:[e]});const{forcedErrors:t,children:s}=this.props;return t&&t.length>0?(0,a.jsx)(B,{errors:t}):s}},Q=e=>typeof e=="object"&&"geom"in e&&"render"in e,de=e=>{const t=(0,m.resolveDefinition)(e);return t instanceof m.Geom?t:null},J=(e,t)=>{const s=e.filter(r=>ue(r,t));return s.length===e.length?e:s},ue=(e,t)=>e.kind==="annotation"?(0,m.findAnnotation)(t.annotations,e.id)!==null:e.kind==="observations"||e.kind==="layer"&&e.layerId!==void 0?(0,m.findLayerById)(t.layers,e.layerId)!==void 0:!0,V=[],ge=()=>(0,O.createStore)(e=>({selection:V,setSelection:t=>e(s=>he(s.selection,t)?s:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:V})})),he=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((s,r)=>{const o=t[r];return o!==void 0&&(0,m.areEditTargetsEqual)(s,o)}),me=process.env.NODE_ENV!=="production",pe=5,ve=e=>{if(!me)return{emit:()=>{},subscribe:()=>ye,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let s=null;return{emit:r=>{const o=e.getLastCompile();if(o){s=r;for(const d of t)d(r,o)}},subscribe:r=>(t.add(r),()=>{t.delete(r)}),getLastTrigger:()=>s,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},fe=()=>(0,O.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,s)=>e(r=>{if(r.lastSnapshot===s)return r;const o={id:r.nextId,label:Se(t),stages:s.stages,stageDurationsMs:s.stageDurationsMs,durationMs:s.durationMs};return{lastCompile:o,history:be(r.history,o,pe),nextId:r.nextId+1,lastSnapshot:s}})})),ye=()=>{},Se=e=>{switch(e.kind){case"init":return"init";case"spec":return"spec change";case"data":return"data change";case"command":return e.command.metadata.description}},be=(e,t,s)=>{const r=e.length>=s?e.length-(s-1):0;return[...e.slice(r),t]};function Ee(e){const t=e.filter(Q),s=new Set([...Object.keys(i.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),r=[],o=new Set;for(const u of e){const h=de(u);h===null||s.has(h.type)||o.has(h.type)||(o.add(h.type),r.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${h.type}' is registered but has no renderer.`,context:{requested:h.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${h.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const d=new Map;for(const u of t){if("definition"in u)continue;const h=`${u.geom}|${u.coord}`,p=d.get(h);p?p.count+=1:d.set(h,{geom:u.geom,coord:u.coord,count:1})}const c=[];for(const{geom:u,coord:h,count:p}of d.values())p<2||c.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${h}') (${p} entries); the last in the array wins.`,context:{requested:`${u}@${h}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${h}').`});return{errors:r,warnings:c}}function Te(e,t){const{coordSystem:s,layers:r}=e,o=new Set,d=[];for(const c of r)t(c.geom,s.type)!==null||o.has(c.geom)||(o.add(c.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${c.geom}' under ${s.type} coords; the layer is not painted.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${c.geom}', '${s.type}') via \`defineGeomRenderer\`.`}));return d}function xe(e,t){const{coordSystem:s,layers:r}=e,o=new Set,d=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||o.has(c.geom))continue;const u=t(c.geom,s.type);u===null||u.hitTest||i.isOverlayHosted(u)||(o.add(c.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Add a \`hitTest\` factory (precomputed geometry) or an overlay render (\`{ fn, options: { overlay: true } }\`, live simulation) to the renderer for ('${c.geom}', '${s.type}').`}))}return d}function Re(e){const t=new Set,s=[];for(const r of e.layers){const o=r.identityKey;r.interactive!==!1&&(r.spatialKind!=="render-hit-test"||typeof o!="object"||t.has(r.geom)||r.data.hasVariable(o.variable)||(t.add(r.geom),s.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${r.geom}' keys its identity on '${o.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:r.geom,kind:"geom-renderer"},suggestion:`Emit the '${o.variable}' column from the geom's \`compile()\`, or point \`identityKey\` at a column it does emit.`})))}return s}function Ce(e,t){const{coordSystem:s,layers:r}=e,o=new Set,d=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||o.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!u.hitTest||!i.isOverlayHosted(u)||(o.add(c.geom),d.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR an overlay render (`{ fn, options: { overlay: true } }`) for a live simulation."}))}return d}function Ge(e,t){const s=new Set,r=[];for(const o of e.layers)o.interactive!==!1&&(o.spatialKind!=="render-hit-test"||s.has(o.geom)||t.hasCapability(o.geom)||(s.add(o.geom),r.push({kind:"user-input",severity:"warning",code:"MISSING_ANCHOR_CAPABILITY",message:`Geom '${o.geom}' declares no \`resolveAnchorPosition\`; its observations cannot be annotated, so the editor overlay paints no creation trigger on them.`,context:{requested:o.geom,kind:"geom-renderer"},suggestion:"Implement `resolveAnchorPosition(observation, context)` on the geom, returning the normalised panel position an annotation on that observation belongs at."})));return r}function qe(e,t){const{coordSystem:s,layers:r}=e,o=new Set,d=[];for(const c of r){if(c.interactive===!1||c.spatialKind==="render-hit-test"||o.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!i.isOverlayHosted(u)||(o.add(c.geom),d.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares an overlay render but its layer's spatialKind is '${c.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the scene layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return d}var ke=e=>(0,O.createStore)(t=>({scene:e,setScene:s=>t(r=>r.scene===s?r:{scene:s})})),Ne=({spec:e,data:t,customPalettes:s,colorScheme:r,plugins:o,resolveRenderer:d,anchorResolver:c,onSpecChange:u,onError:h,onWarnings:p})=>{const T=i.useLatestRef(u),j=i.useLatestRef(h),G=i.useLatestRef(p),[{session:v,compileBus:g}]=(0,l.useState)(()=>{const n=(0,m.createCompiler)({plugins:o});return{session:new m.GraphCompilationSession(n),compileBus:ve(n)}}),[y]=(0,l.useState)(()=>Ee(o??[])),q=(0,l.useRef)(null),[S]=(0,l.useState)(je),x=(0,l.useRef)(null),k=(0,l.useCallback)(n=>y.errors.length===0?n:[...y.errors,...n??[]],[y]),R=(0,l.useCallback)(n=>{if(!n.ok)return n.errors;if(x.current)x.current.getState().setScene(n.scene);else{const f=ke(n.scene);f.subscribe(S.notify),x.current=f,S.notify()}return null},[S]),[H,D]=(0,l.useState)(()=>{const n=v.compile({spec:e,data:t,customPalettes:s,colorScheme:r});return q.current=n,k(R(n))}),C=(0,l.useCallback)(n=>n.ok?[...n.warnings,...Te(n.scene,d),...xe(n.scene,d),...Re(n.scene),...Ce(n.scene,d),...qe(n.scene,d),...Ge(n.scene,c)]:n.warnings,[d,c]),N=(0,l.useCallback)(n=>{n.length!==0&&(i.logDiagnostics(n),j.current?.(n))},[j]),b=(0,l.useCallback)(n=>{n.length!==0&&(i.logDiagnostics(n),G.current?.(n))},[G]);(0,l.useEffect)(()=>{const n=q.current;n&&(N([...y.errors,...n.ok?[]:n.errors]),b([...y.warnings,...C(n)]),n.ok&&g.emit({kind:"init"}))},[g,N,b,y,C]),(0,l.useEffect)(()=>{const n=v.update({spec:e,data:t,customPalettes:s,colorScheme:r});if(!n)return;n.committedSpec&&T.current?.(n.committedSpec);const f=R(n.result);D(k(f)),f&&N(f),b(C(n.result)),f||g.emit({kind:n.specChanged?"spec":"data"})},[e,t,s,r,v,g,R,N,b,k,C,T]);const I=(0,l.useCallback)(n=>{D(f=>f===null?f:k(null)),b(C(n))},[k,b,C]),_=(0,l.useCallback)(n=>{n.scene&&x.current?.getState().setScene(n.scene),n.result&&I(n.result),n.command&&g.emit({kind:"command",command:n.command}),n.spec&&T.current?.(n.spec),n.errors&&N([...n.errors])},[I,g,T,N]),E=(0,l.useCallback)(n=>{for(const f of n)_(f);return n.some(f=>!!f.scene)},[_]),M=(0,l.useCallback)((n,f)=>{E(v.applyCommand(n,f))},[v,E]),$=(0,l.useCallback)(()=>{E(v.commit())},[v,E]),K=(0,l.useCallback)(()=>E(v.undo()),[v,E]),U=(0,l.useCallback)(()=>E(v.redo()),[v,E]),te=(0,l.useMemo)(()=>({stack:v.history,undo:K,redo:U}),[v,K,U]),re=(0,l.useCallback)(()=>x.current?.getState().scene??null,[]);return{store:x.current,dispatch:M,commit:$,history:te,subscribe:S.subscribe,getScene:re,compileBus:g,compileErrors:H}},je=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},Z=({data:e,spec:t,plugins:s=[],formattingLocale:r,handleRef:o,onSpecChange:d,onError:c,onWarnings:u,customPalettes:h,colorScheme:p="light",children:T})=>{const[j]=(0,l.useState)(()=>i.createGeomRendererResolver(s.filter(Q))),G=(0,l.useId)(),[v]=(0,l.useState)(()=>(0,m.createAnchorResolver)(s)),[g]=(0,l.useState)(()=>ge()),[y]=(0,l.useState)(()=>i.createTargetBoundaryStore()),q=(0,l.useMemo)(()=>(0,m.createStyleResolver)({colorScheme:p}),[p]),{store:S,dispatch:x,commit:k,history:R,subscribe:H,getScene:D,compileBus:C,compileErrors:N}=Ne({spec:t,data:e,customPalettes:h,colorScheme:p,plugins:s,resolveRenderer:j,anchorResolver:v,onSpecChange:d,onError:c,onWarnings:u});(0,l.useEffect)(()=>{if(S)return S.subscribe((_,E)=>{if(_.scene.spec===E.scene.spec)return;const{selection:M,setSelection:$}=g.getState();M.length!==0&&$(J(M,_.scene.spec))})},[S,g]);const b=(0,l.useMemo)(()=>({dispatch:x,commit:k}),[x,k]);(0,l.useImperativeHandle)(o,()=>({commands:b,undo:R.undo,redo:R.redo,subscribe:H,getScene:D,getSelection:()=>g.getState().selection,setSelection:_=>g.getState().setSelection(_),subscribeSelection:g.subscribe}),[b,R,H,D,g]);const I=(0,l.useMemo)(()=>S?{chartId:G,store:S,selectionStore:g,targetBoundaryStore:y,commands:b,history:R,formattingLocale:r,compileBus:C,colorScheme:p,styleResolver:q,anchorResolver:v}:null,[G,S,g,y,b,R,r,C,p,q,v]);return(0,a.jsx)(X,{forcedErrors:N,onError:c,resetKeys:[t,e],children:I?(0,a.jsx)(i.GraphContext.Provider,{value:I,children:(0,a.jsx)(i.GeomRendererResolverProvider,{value:j,children:T})}):null})};function _e(e){const t=(0,m.createSpecBuilder)(e);return{...t,GraphProvider:r=>(0,a.jsx)(Z,{...r,plugins:t.plugins})}}var De=({children:e,...t})=>(0,a.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),Ie=({box:e,children:t})=>(0,a.jsx)("svg",{x:(0,m.toPercent)(e.x0),y:(0,m.toPercent)(e.y0),width:(0,m.toPercent)(e.x1-e.x0),height:(0,m.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:t}),we="drqe3u0",He="drqe3u1",Me="drqe3u2",Pe="drqe3u3",w="drqe3u4",$e="drqe3u5",Le="drqe3u6",Be="drqe3u7",P="drqe3u8",Oe="drqe3u9",Ae="drqe3ua";var Ke="drqe3uc",Ue="drqe3ud",Ye="drqe3ue",Fe="drqe3uf";var Ve="drqe3uh",We="drqe3ui",W={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},z={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},ee={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ze=({width:e=440,style:t,className:s}={})=>{const{compileBus:r}=i.useGraphContext(),[o]=(0,l.useState)(()=>fe()),[d,c]=(0,l.useState)(!1),[u,h]=(0,l.useState)(m.isCompilerCachingEnabled);(0,l.useEffect)(()=>{const{recordCompile:g}=o.getState(),y=r.getLastTrigger(),q=r.getLastCompile();return y&&q&&g(y,q),r.subscribe(g)},[o,r]);const p=(0,Y.useStore)(o,g=>g.lastCompile),T=(0,Y.useStore)(o,g=>g.history),j=r.getCacheStats(),G=p===null&&T.length===0,v=()=>{h(g=>{const y=!g;return(0,m.setCompilerCachingEnabled)(y),y})};return(0,a.jsxs)("div",{className:(0,L.default)(Ae,s),style:{width:e,...t},children:[(0,a.jsxs)("div",{className:we,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:He,children:"compile cache"}),(0,a.jsx)("div",{className:Ye,children:G?"production: stats disabled":p?`last: ${p.label} · ${A(p.durationMs)}`:"awaiting first compile…"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>c(g=>!g),className:Fe,children:d?"▾":"▴"})]}),!d&&(0,a.jsxs)("div",{className:"drqe3ub",children:[(0,a.jsxs)("button",{type:"button",onClick:v,className:u?W.enabled:W.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,a.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!d&&!G&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Xe,{delta:p?.stages,durations:p?.stageDurationsMs,cumulative:j}),(0,a.jsx)(Qe,{entries:T})]})]})},Xe=({delta:e,durations:t,cumulative:s})=>(0,a.jsxs)("table",{className:Me,children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:Ve,children:[(0,a.jsx)("th",{className:Pe,children:"stage"}),(0,a.jsx)("th",{className:w,children:"time"}),(0,a.jsx)("th",{className:w,children:"Δ miss"}),(0,a.jsx)("th",{className:w,children:"Δ hit"}),(0,a.jsx)("th",{className:w,children:"total miss"}),(0,a.jsx)("th",{className:w,children:"total hit"})]})}),(0,a.jsx)("tbody",{children:m.COMPILER_STAGE_KEYS.map(r=>{const o=e?.[r],d=Je(o);return(0,a.jsxs)("tr",{className:Ke,children:[(0,a.jsxs)("td",{className:$e,children:[(0,a.jsx)("span",{className:ee[d],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:P,children:t===void 0||d==="untouched"?"—":A(t[r])}),(0,a.jsx)("td",{className:d==="ran"?z.ran:z.dim,children:o?.misses??0}),(0,a.jsx)("td",{className:P,children:o?.hits??0}),(0,a.jsx)("td",{className:P,children:s[r].misses}),(0,a.jsx)("td",{className:P,children:s[r].hits})]},r)})})]}),Qe=({entries:e})=>e.length===0?null:(0,a.jsxs)("div",{className:Ue,children:[(0,a.jsx)("div",{className:We,children:"recent compiles"}),e.map(t=>{const s=Ze(t.stages,d=>d.misses>0),r=m.COMPILER_STAGE_KEYS.length,o=s===0?"cached":"ran";return(0,a.jsxs)("div",{className:Le,children:[(0,a.jsx)("span",{className:ee[o],"aria-hidden":!0}),(0,a.jsx)("span",{className:Be,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Oe,children:[s,"/",r," ran · ",A(t.durationMs)]})]},t.id)})]}),Je=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",Ze=(e,t)=>{let s=0;for(const r of m.COMPILER_STAGE_KEYS)t(e[r])&&(s+=1);return s},A=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,et=()=>{const{history:e}=i.useGraphContext(),{stack:t,undo:s,redo:r}=e,o=(0,l.useCallback)(u=>t.subscribe(u),[t]),d=(0,l.useCallback)(()=>t.getSnapshot(),[t]),c=(0,l.useSyncExternalStore)(o,d,d);return(0,l.useMemo)(()=>({...c,undo:s,redo:r}),[c,s,r])},tt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),rt=(e,t={})=>{const{target:s,enabled:r=!0}=t;(0,l.useEffect)(()=>{const o=st(s);if(!r||!o)return;const d=c=>{if(!nt(c)||c.defaultPrevented||ot(c.target))return;const u=i.resolveHistoryStep(c);if(!u)return;const h=e.current;h&&(u==="undo"?h.undo():h.redo())&&c.preventDefault()};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[e,s,r])},st=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,nt=e=>"key"in e,ot=e=>e instanceof HTMLInputElement?!tt.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1;exports.BrandMark=i.BrandMark;exports.CanvasTextMeasurer=i.CanvasTextMeasurer;exports.DefaultFooter=i.DefaultFooter;exports.DefaultGrid=i.DefaultGrid;exports.DefaultHeader=i.DefaultHeader;exports.DefaultSwatch=i.DefaultSwatch;exports.DefaultTooltip=i.DefaultTooltip;exports.DevToolsPanel=ze;exports.GRAPH_MODES=i.GRAPH_MODES;exports.GraphErrorBoundary=X;exports.GraphErrorPanel=B;exports.GraphProvider=Z;exports.GraphRenderer=i.GraphRenderer;exports.HoverProvider=i.HoverProvider;exports.TextMeasurerProvider=i.TextMeasurerProvider;exports.ThemeProvider=i.ThemeProvider;exports.UnitBoxSvg=Ie;exports.UnitSpaceSvg=De;exports.createGraphyKit=_e;exports.darkTheme=i.darkTheme;exports.defineGeomRenderer=i.defineGeomRenderer;exports.lightTheme=i.lightTheme;exports.lightenCss=i.lightenCss;exports.pruneSelection=J;exports.resolveBrandMarkVisual=i.resolveBrandMarkVisual;exports.stampAxisEditTarget=i.stampAxisEditTarget;exports.stampGridEditTarget=i.stampGridEditTarget;exports.stampLegendEditTarget=i.stampLegendEditTarget;exports.useElementScreenRect=i.useElementScreenRect;exports.useGeomHitTest=i.useGeomHitTest;exports.useGeomHover=i.useGeomHover;exports.useGeomReaderTree=i.useGeomReaderTree;exports.useGraphCommands=i.useGraphCommands;exports.useGraphHandle=i.useGraphHandle;exports.useGraphHistory=et;exports.useGraphHistoryShortcuts=rt;exports.useGraphSelection=i.useGraphSelection;exports.useGuidesTakePress=i.useGuidesTakePress;exports.useHandleScene=i.useHandleScene;exports.useHoverState=i.useHoverState;exports.useResolvedStyle=i.useResolvedStyle;exports.useSceneSelector=i.useSceneSelector;exports.useStyleReaderTree=i.useStyleReaderTree;exports.useStyleReaders=i.useStyleReaders;exports.useStyleResolver=i.useStyleResolver;exports.useTargetBoundary=i.useTargetBoundary;exports.useTextMeasurer=i.useTextMeasurer;exports.vars=se.vars;
package/dist/index.d.ts CHANGED
@@ -53,6 +53,7 @@ import { SourceContent } from '@graphysdk/viz-engine';
53
53
  import { Spec } from '@graphysdk/viz-engine';
54
54
  import { SpecBuilder } from '@graphysdk/viz-engine';
55
55
  import { StoreApi } from 'zustand';
56
+ import { StylePointSymbol } from '@graphysdk/viz-engine';
56
57
  import { StyleReadersForLayer } from '@graphysdk/viz-engine';
57
58
  import { StyleReaderTree } from '@graphysdk/viz-engine';
58
59
  import { StyleResolver } from '@graphysdk/viz-engine';
@@ -216,7 +217,7 @@ export declare const DefaultGrid: ({ axes, panelBorderSizes, panelFrameRect, pan
216
217
  export declare const DefaultHeader: ({ ref, headerRect, mode, title, isTitleVisible, subtitle, isSubtitleVisible, headingStyle, subtitleStyle, brandMark, }: HeaderSlotProps) => JSX.Element | null;
217
218
 
218
219
  /** The built-in glyph for each {@link SwatchShape}. */
219
- export declare const DefaultSwatch: ({ shape, color, lineType, width, height, strokeWidth, alpha, cornerRadius, }: Omit<SwatchSlotProps, "surface" | "label">) => JSX.Element;
220
+ export declare const DefaultSwatch: ({ shape, color, lineType, width, height, strokeWidth, alpha, cornerRadius, symbol, }: Omit<SwatchSlotProps, "surface" | "label">) => JSX.Element;
220
221
 
221
222
  /**
222
223
  * Default tooltip body. Paints the box, heading, and rows from the formatted {@link content}, and
@@ -1112,6 +1113,26 @@ declare interface SelectionStoreActions {
1112
1113
  /** State of the selection store: what the graph holds selected plus the actions replacing it. */
1113
1114
  export declare type SelectionStoreState = SelectionSlice & SelectionStoreActions;
1114
1115
 
1116
+ /** The stretch of one side of the target boundary the selection reaches, in that side's own axis. */
1117
+ export declare interface SideSpan {
1118
+ /** The smaller end, where a menu on that side starts, except below or above on a right-to-left page. */
1119
+ from: number;
1120
+ /** The larger end, where a menu below or above starts on a right-to-left page. */
1121
+ to: number;
1122
+ }
1123
+
1124
+ /** A selection's four side spans. `left` and `right` are two y values; `top` and `bottom` are two x values. */
1125
+ export declare interface SideSpans {
1126
+ /** The stretch of the top side, as two x values, which a menu above lines up with. */
1127
+ top: SideSpan;
1128
+ /** The stretch of the right side, as two y values, which a menu to the right lines up with. */
1129
+ right: SideSpan;
1130
+ /** The stretch of the bottom side, as two x values, which a menu below lines up with. */
1131
+ bottom: SideSpan;
1132
+ /** The stretch of the left side, as two y values, which a menu to the left lines up with. */
1133
+ left: SideSpan;
1134
+ }
1135
+
1115
1136
  /**
1116
1137
  * Passed as the second argument to a layout-coupled slot's `measure`, so it can size its band from
1117
1138
  * real text metrics — the same Canvas-backed measurer the built-in measurers use — rather than
@@ -1200,6 +1221,8 @@ export declare interface SwatchSlotProps {
1200
1221
  alpha?: number;
1201
1222
  /** Square corner radius in px. Omit so {@link DefaultSwatch} keeps `rx={2}`. */
1202
1223
  cornerRadius?: number;
1224
+ /** The glyph a circle swatch draws, the owning point layer's `symbol`. Omit for a circle. */
1225
+ symbol?: StylePointSymbol;
1203
1226
  }
1204
1227
 
1205
1228
  /** The UI surface a swatch is painted on. Lets a Swatch slot restyle one surface and delegate the rest. */
@@ -1211,6 +1234,14 @@ export declare interface TargetBoundary {
1211
1234
  frame: Rect;
1212
1235
  /** The same box on screen, in client pixels, which a host places a menu of its own against. */
1213
1236
  client: Rect;
1237
+ /**
1238
+ * The stretch of each of `frame`'s sides the selection reaches, in the same pixels. A menu lined up with the
1239
+ * span of the side it stands on stands beside the part of the selection reaching that side, rather than beside
1240
+ * whatever set the corner of the box.
1241
+ */
1242
+ frameSpans: SideSpans;
1243
+ /** The same four stretches on screen, in the client pixels `client` is in, which a host lines its own menu up by. */
1244
+ clientSpans: SideSpans;
1214
1245
  }
1215
1246
 
1216
1247
  declare interface TargetBoundarySlice {
@@ -1525,11 +1556,16 @@ export declare const useStyleResolver: () => StyleResolver;
1525
1556
  * frame's size changes, and moves its `client` box with the page. `null` while nothing is selected, where the
1526
1557
  * chart draws nothing for what is, and on a chart no editor is mounted on.
1527
1558
  *
1559
+ * `clientSpans` is `client`'s counterpart for the four side spans, so a menu placed by one lines up with the other.
1560
+ * `frame` and `frameSpans` are the same two in the chart's own layout pixels.
1561
+ *
1528
1562
  * @example
1529
1563
  * ```tsx
1530
1564
  * const boundary = useTargetBoundary();
1531
1565
  * if (boundary === null) return null;
1532
- * return <MyMenu style={{ left: boundary.client.x + boundary.client.width + 8, top: boundary.client.y }} />;
1566
+ * // Beside the right side, level with the part of the selection that reaches it. Client pixels are the viewport's.
1567
+ * const left = boundary.client.x + boundary.client.width + 8;
1568
+ * return <MyMenu style={{ position: 'fixed', left, top: boundary.clientSpans.right.from }} />;
1533
1569
  * ```
1534
1570
  */
1535
1571
  export declare const useTargetBoundary: () => TargetBoundary | null;