@graphysdk/react-renderer 1.9.0-beta.1789558511894 → 1.9.0-beta.1789573335651

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 c=require("./history-chords-CGCTvwgL.cjs"),se=require("./theme.contract.css-Dd-73-Je.cjs");let m=require("@graphysdk/viz-engine"),l=require("react"),a=require("react/jsx-runtime"),A=require("zustand"),B=require("zustand/vanilla"),$=require("clsx");$=c.__toESM($,1);var ne="_1a5iqpb0",oe="_1a5iqpb1";var ae="_1a5iqpb3",ie="_1a5iqpb4",ce="_1a5iqpb5";var L=({errors:e})=>{const[t,...r]=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)(U,{diagnostic:t}),r.length>0&&(0,a.jsx)("ul",{className:"_1a5iqpb2",children:r.map((s,o)=>(0,a.jsx)("li",{children:(0,a.jsx)(U,{diagnostic:s})},`${s.code}-${o}`))})]})},U=({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((r,s)=>Object.is(r,t[s]))}var W=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 r=(0,m.buildDiagnostic)(e);c.logDiagnostics([r]),this.props.onError?.([r]),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)(L,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,a.jsx)(L,{errors:t}):r}},z=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},X=(e,t)=>{const r=e.filter(s=>ue(s,t));return r.length===e.length?e:r},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,Y=[],he=()=>(0,B.createStore)(e=>({selection:Y,setSelection:t=>e(r=>ge(r.selection,t)?r:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:Y})})),ge=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,s)=>{const o=t[s];return o!==void 0&&(0,m.areEditTargetsEqual)(r,o)}),me=process.env.NODE_ENV!=="production",pe=5,fe=e=>{if(!me)return{emit:()=>{},subscribe:()=>ye,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let r=null;return{emit:s=>{const o=e.getLastCompile();if(o){r=s;for(const d of t)d(s,o)}},subscribe:s=>(t.add(s),()=>{t.delete(s)}),getLastTrigger:()=>r,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},ve=()=>(0,B.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,r)=>e(s=>{if(s.lastSnapshot===r)return s;const o={id:s.nextId,label:Se(t),stages:r.stages,durationMs:r.durationMs};return{lastCompile:o,history:be(s.history,o,pe),nextId:s.nextId+1,lastSnapshot:r}})})),ye=()=>{},Se=e=>{switch(e.kind){case"init":return"init";case"input":return"input change";case"data":return"data change";case"command":return e.command.metadata.description}},be=(e,t,r)=>{const s=e.length>=r?e.length-(r-1):0;return[...e.slice(s),t]};function Ee(e){const t=e.filter(z),r=new Set([...Object.keys(c.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),s=[],o=new Set;for(const u of e){const g=de(u);g===null||r.has(g.type)||o.has(g.type)||(o.add(g.type),s.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${g.type}' is registered but has no renderer.`,context:{requested:g.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${g.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const d=new Map;for(const u of t){if("definition"in u)continue;const g=`${u.geom}|${u.coord}`,p=d.get(g);p?p.count+=1:d.set(g,{geom:u.geom,coord:u.coord,count:1})}const i=[];for(const{geom:u,coord:g,count:p}of d.values())p<2||i.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${g}') (${p} entries); the last in the array wins.`,context:{requested:`${u}@${g}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${g}').`});return{errors:s,warnings:i}}function xe(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s)t(i.geom,r.type)!==null||o.has(i.geom)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${i.geom}' under ${r.type} coords; the layer is not painted.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${i.geom}', '${r.type}') via \`defineGeomRenderer\`.`}));return d}function Te(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind!=="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||u.hitTest||c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:i.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 ('${i.geom}', '${r.type}').`}))}return d}function Ce(e){const t=new Set,r=[];for(const s of e.layers){const o=s.identityKey;s.interactive!==!1&&(s.spatialKind!=="render-hit-test"||typeof o!="object"||t.has(s.geom)||s.data.hasVariable(o.variable)||(t.add(s.geom),r.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${s.geom}' keys its identity on '${o.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:s.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 r}function Re(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind!=="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||!u.hitTest||!c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:i.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 qe(e,t){const r=new Set,s=[];for(const o of e.layers)o.interactive!==!1&&(o.spatialKind!=="render-hit-test"||r.has(o.geom)||t.hasCapability(o.geom)||(r.add(o.geom),s.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 s}function Ge(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind==="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||!c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares an overlay render but its layer's spatialKind is '${i.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:i.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,B.createStore)(t=>({scene:e,setScene:r=>t(s=>s.scene===r?s:{scene:r})})),Ne=({input:e,data:t,customPalettes:r,colorScheme:s,plugins:o,resolveRenderer:d,anchorResolver:i,onChange:u,onError:g,onWarnings:p})=>{const T=c.useLatestRef(u),k=c.useLatestRef(g),q=c.useLatestRef(p),[{session:f,compileBus:h}]=(0,l.useState)(()=>{const n=(0,m.createCompiler)({plugins:o});return{session:new m.GraphCompilationSession(n),compileBus:fe(n)}}),[y]=(0,l.useState)(()=>Ee(o??[])),S=(0,l.useRef)(null),[N]=(0,l.useState)(_e),C=(0,l.useRef)(null),b=(0,l.useCallback)(n=>y.errors.length===0?n:[...y.errors,...n??[]],[y]),j=(0,l.useCallback)(n=>{if(!n.ok)return n.errors;if(C.current)C.current.getState().setScene(n.scene);else{const v=ke(n.scene);v.subscribe(N.notify),C.current=v,N.notify()}return null},[N]),[I,D]=(0,l.useState)(()=>{const n=f.compile({input:e,data:t,customPalettes:r,colorScheme:s});return S.current=n,b(j(n))}),G=(0,l.useCallback)(n=>n.ok?[...n.warnings,...xe(n.scene,d),...Te(n.scene,d),...Ce(n.scene),...Re(n.scene,d),...Ge(n.scene,d),...qe(n.scene,i)]:n.warnings,[d,i]),E=(0,l.useCallback)(n=>{n.length!==0&&(c.logDiagnostics(n),k.current?.(n))},[k]),R=(0,l.useCallback)(n=>{n.length!==0&&(c.logDiagnostics(n),q.current?.(n))},[q]);(0,l.useEffect)(()=>{const n=S.current;n&&(E([...y.errors,...n.ok?[]:n.errors]),R([...y.warnings,...G(n)]),n.ok&&h.emit({kind:"init"}))},[h,E,R,y,G]),(0,l.useEffect)(()=>{const n=f.update({input:e,data:t,customPalettes:r,colorScheme:s});if(!n)return;n.sealedInput&&T.current?.(n.sealedInput);const v=j(n.result);D(b(v)),v&&E(v),R(G(n.result)),v||h.emit({kind:n.inputChanged?"input":"data"})},[e,t,r,s,f,h,j,E,R,b,G,T]);const _=(0,l.useCallback)(n=>{D(v=>v===null?v:b(null)),R(G(n))},[b,R,G]),w=(0,l.useCallback)(n=>{n.scene&&C.current?.getState().setScene(n.scene),n.result&&_(n.result),n.command&&h.emit({kind:"command",command:n.command}),n.input&&T.current?.(n.input),n.errors&&E([...n.errors])},[_,h,T,E]),x=(0,l.useCallback)(n=>{for(const v of n)w(v);return n.some(v=>!!v.scene)},[w]),M=(0,l.useCallback)((n,v)=>{x(f.applyCommand(n,v))},[f,x]),ee=(0,l.useCallback)(()=>{x(f.seal())},[f,x]),O=(0,l.useCallback)(()=>x(f.undo()),[f,x]),K=(0,l.useCallback)(()=>x(f.redo()),[f,x]),te=(0,l.useMemo)(()=>({stack:f.history,undo:O,redo:K}),[f,O,K]),re=(0,l.useCallback)(()=>C.current?.getState().scene??null,[]);return{store:C.current,dispatch:M,seal:ee,history:te,subscribe:N.subscribe,getScene:re,compileBus:h,compileErrors:I}},_e=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},Q=({data:e,input:t,plugins:r=[],formattingLocale:s,handleRef:o,onChange:d,onError:i,onWarnings:u,customPalettes:g,colorScheme:p="light",children:T})=>{const[k]=(0,l.useState)(()=>c.createGeomRendererResolver(r.filter(z))),q=(0,l.useId)(),[f]=(0,l.useState)(()=>(0,m.createAnchorResolver)(r)),[h]=(0,l.useState)(()=>he()),y=(0,l.useMemo)(()=>(0,m.createStyleResolver)({colorScheme:p}),[p]),{store:S,dispatch:N,seal:C,history:b,subscribe:j,getScene:I,compileBus:D,compileErrors:G}=Ne({input:t,data:e,customPalettes:g,colorScheme:p,plugins:r,resolveRenderer:k,anchorResolver:f,onChange:d,onError:i,onWarnings:u});(0,l.useEffect)(()=>{if(S)return S.subscribe((_,w)=>{if(_.scene.spec===w.scene.spec)return;const{selection:x,setSelection:M}=h.getState();x.length!==0&&M(X(x,_.scene.spec))})},[S,h]);const E=(0,l.useMemo)(()=>({dispatch:N,seal:C}),[N,C]);(0,l.useImperativeHandle)(o,()=>({commands:E,undo:b.undo,redo:b.redo,subscribe:j,getScene:I,getSelection:()=>h.getState().selection,setSelection:_=>h.getState().setSelection(_),subscribeSelection:h.subscribe}),[E,b,j,I,h]);const R=(0,l.useMemo)(()=>S?{chartId:q,store:S,selectionStore:h,commands:E,history:b,formattingLocale:s,compileBus:D,colorScheme:p,styleResolver:y,anchorResolver:f}:null,[q,S,h,E,b,s,D,p,y,f]);return(0,a.jsx)(W,{forcedErrors:G,onError:i,resetKeys:[t,e],children:R?(0,a.jsx)(c.GraphContext.Provider,{value:R,children:(0,a.jsx)(c.GeomRendererResolverProvider,{value:k,children:T})}):null})};function je(e){const t=(0,m.createGraphyBuilder)(e);return{...t,GraphProvider:s=>(0,a.jsx)(Q,{...s,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",H="drqe3u4",$e="drqe3u5",Le="drqe3u6",Be="drqe3u7",P="drqe3u8",Oe="drqe3u9",Ke="drqe3ua";var Ae="drqe3uc",Ue="drqe3ud",Ye="drqe3ue",Fe="drqe3uf";var Ve="drqe3uh",We="drqe3ui",F={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},V={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},J={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ze=({width:e=380,style:t,className:r}={})=>{const{compileBus:s}=c.useGraphContext(),[o]=(0,l.useState)(()=>ve()),[d,i]=(0,l.useState)(!1),[u,g]=(0,l.useState)(m.isCompilerCachingEnabled);(0,l.useEffect)(()=>{const{recordCompile:h}=o.getState(),y=s.getLastTrigger(),S=s.getLastCompile();return y&&S&&h(y,S),s.subscribe(h)},[o,s]);const p=(0,A.useStore)(o,h=>h.lastCompile),T=(0,A.useStore)(o,h=>h.history),k=s.getCacheStats(),q=p===null&&T.length===0,f=()=>{g(h=>{const y=!h;return(0,m.setCompilerCachingEnabled)(y),y})};return(0,a.jsxs)("div",{className:(0,$.default)(Ke,r),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:q?"production: stats disabled":p?`last: ${p.label} · ${Z(p.durationMs)}`:"awaiting first compile…"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>i(h=>!h),className:Fe,children:d?"▾":"▴"})]}),!d&&(0,a.jsxs)("div",{className:"drqe3ub",children:[(0,a.jsxs)("button",{type:"button",onClick:f,className:u?F.enabled:F.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,a.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!d&&!q&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Xe,{delta:p?.stages,cumulative:k}),(0,a.jsx)(Qe,{entries:T})]})]})},Xe=({delta:e,cumulative:t})=>(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:H,children:"Δ miss"}),(0,a.jsx)("th",{className:H,children:"Δ hit"}),(0,a.jsx)("th",{className:H,children:"total miss"}),(0,a.jsx)("th",{className:H,children:"total hit"})]})}),(0,a.jsx)("tbody",{children:m.COMPILER_STAGE_KEYS.map(r=>{const s=e?.[r],o=Je(s);return(0,a.jsxs)("tr",{className:Ae,children:[(0,a.jsxs)("td",{className:$e,children:[(0,a.jsx)("span",{className:J[o],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:o==="ran"?V.ran:V.dim,children:s?.misses??0}),(0,a.jsx)("td",{className:P,children:s?.hits??0}),(0,a.jsx)("td",{className:P,children:t[r].misses}),(0,a.jsx)("td",{className:P,children:t[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 r=Ze(t.stages,d=>d.misses>0),s=m.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,a.jsxs)("div",{className:Le,children:[(0,a.jsx)("span",{className:J[o],"aria-hidden":!0}),(0,a.jsx)("span",{className:Be,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Oe,children:[r,"/",s," ran · ",Z(t.durationMs)]})]},t.id)})]}),Je=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",Ze=(e,t)=>{let r=0;for(const s of m.COMPILER_STAGE_KEYS)t(e[s])&&(r+=1);return r},Z=e=>e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,et=()=>{const{history:e}=c.useGraphContext(),{stack:t,undo:r,redo:s}=e,o=(0,l.useCallback)(u=>t.subscribe(u),[t]),d=(0,l.useCallback)(()=>t.getSnapshot(),[t]),i=(0,l.useSyncExternalStore)(o,d,d);return(0,l.useMemo)(()=>({...i,undo:r,redo:s}),[i,r,s])},tt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),rt=(e,t={})=>{const{target:r,enabled:s=!0}=t;(0,l.useEffect)(()=>{const o=st(r);if(!s||!o)return;const d=i=>{if(!nt(i)||i.defaultPrevented||ot(i.target))return;const u=c.resolveHistoryStep(i);if(!u)return;const g=e.current;g&&(u==="undo"?g.undo():g.redo())&&i.preventDefault()};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[e,r,s])},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=c.BrandMark;exports.CanvasTextMeasurer=c.CanvasTextMeasurer;exports.DefaultFooter=c.DefaultFooter;exports.DefaultGrid=c.DefaultGrid;exports.DefaultHeader=c.DefaultHeader;exports.DefaultSwatch=c.DefaultSwatch;exports.DefaultTooltip=c.DefaultTooltip;exports.DevToolsPanel=ze;exports.GRAPH_MODES=c.GRAPH_MODES;exports.GraphErrorBoundary=W;exports.GraphErrorPanel=L;exports.GraphProvider=Q;exports.GraphRenderer=c.GraphRenderer;exports.HoverProvider=c.HoverProvider;exports.TextMeasurerProvider=c.TextMeasurerProvider;exports.ThemeProvider=c.ThemeProvider;exports.UnitBoxSvg=Ie;exports.UnitSpaceSvg=De;exports.createGraphyKit=je;exports.darkTheme=c.darkTheme;exports.defineGeomRenderer=c.defineGeomRenderer;exports.lightTheme=c.lightTheme;exports.lightenCss=c.lightenCss;exports.pruneSelection=X;exports.resolveBrandMarkVisual=c.resolveBrandMarkVisual;exports.useElementScreenRect=c.useElementScreenRect;exports.useGeomHitTest=c.useGeomHitTest;exports.useGeomHover=c.useGeomHover;exports.useGraphCommands=c.useGraphCommands;exports.useGraphHandle=c.useGraphHandle;exports.useGraphHistory=et;exports.useGraphHistoryShortcuts=rt;exports.useGraphSelection=c.useGraphSelection;exports.useHandleScene=c.useHandleScene;exports.useHoverState=c.useHoverState;exports.useSceneSelector=c.useSceneSelector;exports.useStyleReaderTree=c.useStyleReaderTree;exports.useStyleReaders=c.useStyleReaders;exports.useStyleResolver=c.useStyleResolver;exports.useTextMeasurer=c.useTextMeasurer;exports.vars=se.vars;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const c=require("./history-chords-CSMD3xY9.cjs"),se=require("./theme.contract.css-Dd-73-Je.cjs");let m=require("@graphysdk/viz-engine"),l=require("react"),a=require("react/jsx-runtime"),A=require("zustand"),B=require("zustand/vanilla"),$=require("clsx");$=c.__toESM($,1);var ne="_1a5iqpb0",oe="_1a5iqpb1";var ae="_1a5iqpb3",ie="_1a5iqpb4",ce="_1a5iqpb5";var L=({errors:e})=>{const[t,...r]=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)(U,{diagnostic:t}),r.length>0&&(0,a.jsx)("ul",{className:"_1a5iqpb2",children:r.map((s,o)=>(0,a.jsx)("li",{children:(0,a.jsx)(U,{diagnostic:s})},`${s.code}-${o}`))})]})},U=({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((r,s)=>Object.is(r,t[s]))}var W=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 r=(0,m.buildDiagnostic)(e);c.logDiagnostics([r]),this.props.onError?.([r]),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)(L,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,a.jsx)(L,{errors:t}):r}},z=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},X=(e,t)=>{const r=e.filter(s=>ue(s,t));return r.length===e.length?e:r},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,Y=[],he=()=>(0,B.createStore)(e=>({selection:Y,setSelection:t=>e(r=>ge(r.selection,t)?r:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:Y})})),ge=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,s)=>{const o=t[s];return o!==void 0&&(0,m.areEditTargetsEqual)(r,o)}),me=process.env.NODE_ENV!=="production",pe=5,fe=e=>{if(!me)return{emit:()=>{},subscribe:()=>ye,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let r=null;return{emit:s=>{const o=e.getLastCompile();if(o){r=s;for(const d of t)d(s,o)}},subscribe:s=>(t.add(s),()=>{t.delete(s)}),getLastTrigger:()=>r,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},ve=()=>(0,B.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,r)=>e(s=>{if(s.lastSnapshot===r)return s;const o={id:s.nextId,label:Se(t),stages:r.stages,durationMs:r.durationMs};return{lastCompile:o,history:be(s.history,o,pe),nextId:s.nextId+1,lastSnapshot:r}})})),ye=()=>{},Se=e=>{switch(e.kind){case"init":return"init";case"input":return"input change";case"data":return"data change";case"command":return e.command.metadata.description}},be=(e,t,r)=>{const s=e.length>=r?e.length-(r-1):0;return[...e.slice(s),t]};function Ee(e){const t=e.filter(z),r=new Set([...Object.keys(c.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),s=[],o=new Set;for(const u of e){const g=de(u);g===null||r.has(g.type)||o.has(g.type)||(o.add(g.type),s.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${g.type}' is registered but has no renderer.`,context:{requested:g.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${g.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const d=new Map;for(const u of t){if("definition"in u)continue;const g=`${u.geom}|${u.coord}`,p=d.get(g);p?p.count+=1:d.set(g,{geom:u.geom,coord:u.coord,count:1})}const i=[];for(const{geom:u,coord:g,count:p}of d.values())p<2||i.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${g}') (${p} entries); the last in the array wins.`,context:{requested:`${u}@${g}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${g}').`});return{errors:s,warnings:i}}function xe(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s)t(i.geom,r.type)!==null||o.has(i.geom)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${i.geom}' under ${r.type} coords; the layer is not painted.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${i.geom}', '${r.type}') via \`defineGeomRenderer\`.`}));return d}function Te(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind!=="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||u.hitTest||c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:i.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 ('${i.geom}', '${r.type}').`}))}return d}function Ce(e){const t=new Set,r=[];for(const s of e.layers){const o=s.identityKey;s.interactive!==!1&&(s.spatialKind!=="render-hit-test"||typeof o!="object"||t.has(s.geom)||s.data.hasVariable(o.variable)||(t.add(s.geom),r.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${s.geom}' keys its identity on '${o.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:s.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 r}function Re(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind!=="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||!u.hitTest||!c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:i.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 r=new Set,s=[];for(const o of e.layers)o.interactive!==!1&&(o.spatialKind!=="render-hit-test"||r.has(o.geom)||t.hasCapability(o.geom)||(r.add(o.geom),s.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 s}function qe(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind==="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||!c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares an overlay render but its layer's spatialKind is '${i.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:i.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,B.createStore)(t=>({scene:e,setScene:r=>t(s=>s.scene===r?s:{scene:r})})),Ne=({input:e,data:t,customPalettes:r,colorScheme:s,plugins:o,resolveRenderer:d,anchorResolver:i,onChange:u,onError:g,onWarnings:p})=>{const T=c.useLatestRef(u),k=c.useLatestRef(g),G=c.useLatestRef(p),[{session:f,compileBus:h}]=(0,l.useState)(()=>{const n=(0,m.createCompiler)({plugins:o});return{session:new m.GraphCompilationSession(n),compileBus:fe(n)}}),[y]=(0,l.useState)(()=>Ee(o??[])),S=(0,l.useRef)(null),[N]=(0,l.useState)(_e),C=(0,l.useRef)(null),b=(0,l.useCallback)(n=>y.errors.length===0?n:[...y.errors,...n??[]],[y]),j=(0,l.useCallback)(n=>{if(!n.ok)return n.errors;if(C.current)C.current.getState().setScene(n.scene);else{const v=ke(n.scene);v.subscribe(N.notify),C.current=v,N.notify()}return null},[N]),[I,D]=(0,l.useState)(()=>{const n=f.compile({input:e,data:t,customPalettes:r,colorScheme:s});return S.current=n,b(j(n))}),q=(0,l.useCallback)(n=>n.ok?[...n.warnings,...xe(n.scene,d),...Te(n.scene,d),...Ce(n.scene),...Re(n.scene,d),...qe(n.scene,d),...Ge(n.scene,i)]:n.warnings,[d,i]),E=(0,l.useCallback)(n=>{n.length!==0&&(c.logDiagnostics(n),k.current?.(n))},[k]),R=(0,l.useCallback)(n=>{n.length!==0&&(c.logDiagnostics(n),G.current?.(n))},[G]);(0,l.useEffect)(()=>{const n=S.current;n&&(E([...y.errors,...n.ok?[]:n.errors]),R([...y.warnings,...q(n)]),n.ok&&h.emit({kind:"init"}))},[h,E,R,y,q]),(0,l.useEffect)(()=>{const n=f.update({input:e,data:t,customPalettes:r,colorScheme:s});if(!n)return;n.sealedInput&&T.current?.(n.sealedInput);const v=j(n.result);D(b(v)),v&&E(v),R(q(n.result)),v||h.emit({kind:n.inputChanged?"input":"data"})},[e,t,r,s,f,h,j,E,R,b,q,T]);const _=(0,l.useCallback)(n=>{D(v=>v===null?v:b(null)),R(q(n))},[b,R,q]),w=(0,l.useCallback)(n=>{n.scene&&C.current?.getState().setScene(n.scene),n.result&&_(n.result),n.command&&h.emit({kind:"command",command:n.command}),n.input&&T.current?.(n.input),n.errors&&E([...n.errors])},[_,h,T,E]),x=(0,l.useCallback)(n=>{for(const v of n)w(v);return n.some(v=>!!v.scene)},[w]),M=(0,l.useCallback)((n,v)=>{x(f.applyCommand(n,v))},[f,x]),ee=(0,l.useCallback)(()=>{x(f.seal())},[f,x]),O=(0,l.useCallback)(()=>x(f.undo()),[f,x]),K=(0,l.useCallback)(()=>x(f.redo()),[f,x]),te=(0,l.useMemo)(()=>({stack:f.history,undo:O,redo:K}),[f,O,K]),re=(0,l.useCallback)(()=>C.current?.getState().scene??null,[]);return{store:C.current,dispatch:M,seal:ee,history:te,subscribe:N.subscribe,getScene:re,compileBus:h,compileErrors:I}},_e=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},Q=({data:e,input:t,plugins:r=[],formattingLocale:s,handleRef:o,onChange:d,onError:i,onWarnings:u,customPalettes:g,colorScheme:p="light",children:T})=>{const[k]=(0,l.useState)(()=>c.createGeomRendererResolver(r.filter(z))),G=(0,l.useId)(),[f]=(0,l.useState)(()=>(0,m.createAnchorResolver)(r)),[h]=(0,l.useState)(()=>he()),y=(0,l.useMemo)(()=>(0,m.createStyleResolver)({colorScheme:p}),[p]),{store:S,dispatch:N,seal:C,history:b,subscribe:j,getScene:I,compileBus:D,compileErrors:q}=Ne({input:t,data:e,customPalettes:g,colorScheme:p,plugins:r,resolveRenderer:k,anchorResolver:f,onChange:d,onError:i,onWarnings:u});(0,l.useEffect)(()=>{if(S)return S.subscribe((_,w)=>{if(_.scene.spec===w.scene.spec)return;const{selection:x,setSelection:M}=h.getState();x.length!==0&&M(X(x,_.scene.spec))})},[S,h]);const E=(0,l.useMemo)(()=>({dispatch:N,seal:C}),[N,C]);(0,l.useImperativeHandle)(o,()=>({commands:E,undo:b.undo,redo:b.redo,subscribe:j,getScene:I,getSelection:()=>h.getState().selection,setSelection:_=>h.getState().setSelection(_),subscribeSelection:h.subscribe}),[E,b,j,I,h]);const R=(0,l.useMemo)(()=>S?{chartId:G,store:S,selectionStore:h,commands:E,history:b,formattingLocale:s,compileBus:D,colorScheme:p,styleResolver:y,anchorResolver:f}:null,[G,S,h,E,b,s,D,p,y,f]);return(0,a.jsx)(W,{forcedErrors:q,onError:i,resetKeys:[t,e],children:R?(0,a.jsx)(c.GraphContext.Provider,{value:R,children:(0,a.jsx)(c.GeomRendererResolverProvider,{value:k,children:T})}):null})};function je(e){const t=(0,m.createGraphyBuilder)(e);return{...t,GraphProvider:s=>(0,a.jsx)(Q,{...s,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",H="drqe3u4",$e="drqe3u5",Le="drqe3u6",Be="drqe3u7",P="drqe3u8",Oe="drqe3u9",Ke="drqe3ua";var Ae="drqe3uc",Ue="drqe3ud",Ye="drqe3ue",Fe="drqe3uf";var Ve="drqe3uh",We="drqe3ui",F={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},V={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},J={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ze=({width:e=380,style:t,className:r}={})=>{const{compileBus:s}=c.useGraphContext(),[o]=(0,l.useState)(()=>ve()),[d,i]=(0,l.useState)(!1),[u,g]=(0,l.useState)(m.isCompilerCachingEnabled);(0,l.useEffect)(()=>{const{recordCompile:h}=o.getState(),y=s.getLastTrigger(),S=s.getLastCompile();return y&&S&&h(y,S),s.subscribe(h)},[o,s]);const p=(0,A.useStore)(o,h=>h.lastCompile),T=(0,A.useStore)(o,h=>h.history),k=s.getCacheStats(),G=p===null&&T.length===0,f=()=>{g(h=>{const y=!h;return(0,m.setCompilerCachingEnabled)(y),y})};return(0,a.jsxs)("div",{className:(0,$.default)(Ke,r),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} · ${Z(p.durationMs)}`:"awaiting first compile…"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>i(h=>!h),className:Fe,children:d?"▾":"▴"})]}),!d&&(0,a.jsxs)("div",{className:"drqe3ub",children:[(0,a.jsxs)("button",{type:"button",onClick:f,className:u?F.enabled:F.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,cumulative:k}),(0,a.jsx)(Qe,{entries:T})]})]})},Xe=({delta:e,cumulative:t})=>(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:H,children:"Δ miss"}),(0,a.jsx)("th",{className:H,children:"Δ hit"}),(0,a.jsx)("th",{className:H,children:"total miss"}),(0,a.jsx)("th",{className:H,children:"total hit"})]})}),(0,a.jsx)("tbody",{children:m.COMPILER_STAGE_KEYS.map(r=>{const s=e?.[r],o=Je(s);return(0,a.jsxs)("tr",{className:Ae,children:[(0,a.jsxs)("td",{className:$e,children:[(0,a.jsx)("span",{className:J[o],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:o==="ran"?V.ran:V.dim,children:s?.misses??0}),(0,a.jsx)("td",{className:P,children:s?.hits??0}),(0,a.jsx)("td",{className:P,children:t[r].misses}),(0,a.jsx)("td",{className:P,children:t[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 r=Ze(t.stages,d=>d.misses>0),s=m.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,a.jsxs)("div",{className:Le,children:[(0,a.jsx)("span",{className:J[o],"aria-hidden":!0}),(0,a.jsx)("span",{className:Be,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Oe,children:[r,"/",s," ran · ",Z(t.durationMs)]})]},t.id)})]}),Je=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",Ze=(e,t)=>{let r=0;for(const s of m.COMPILER_STAGE_KEYS)t(e[s])&&(r+=1);return r},Z=e=>e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,et=()=>{const{history:e}=c.useGraphContext(),{stack:t,undo:r,redo:s}=e,o=(0,l.useCallback)(u=>t.subscribe(u),[t]),d=(0,l.useCallback)(()=>t.getSnapshot(),[t]),i=(0,l.useSyncExternalStore)(o,d,d);return(0,l.useMemo)(()=>({...i,undo:r,redo:s}),[i,r,s])},tt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),rt=(e,t={})=>{const{target:r,enabled:s=!0}=t;(0,l.useEffect)(()=>{const o=st(r);if(!s||!o)return;const d=i=>{if(!nt(i)||i.defaultPrevented||ot(i.target))return;const u=c.resolveHistoryStep(i);if(!u)return;const g=e.current;g&&(u==="undo"?g.undo():g.redo())&&i.preventDefault()};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[e,r,s])},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=c.BrandMark;exports.CanvasTextMeasurer=c.CanvasTextMeasurer;exports.DefaultFooter=c.DefaultFooter;exports.DefaultGrid=c.DefaultGrid;exports.DefaultHeader=c.DefaultHeader;exports.DefaultSwatch=c.DefaultSwatch;exports.DefaultTooltip=c.DefaultTooltip;exports.DevToolsPanel=ze;exports.GRAPH_MODES=c.GRAPH_MODES;exports.GraphErrorBoundary=W;exports.GraphErrorPanel=L;exports.GraphProvider=Q;exports.GraphRenderer=c.GraphRenderer;exports.HoverProvider=c.HoverProvider;exports.TextMeasurerProvider=c.TextMeasurerProvider;exports.ThemeProvider=c.ThemeProvider;exports.UnitBoxSvg=Ie;exports.UnitSpaceSvg=De;exports.createGraphyKit=je;exports.darkTheme=c.darkTheme;exports.defineGeomRenderer=c.defineGeomRenderer;exports.lightTheme=c.lightTheme;exports.lightenCss=c.lightenCss;exports.pruneSelection=X;exports.resolveBrandMarkVisual=c.resolveBrandMarkVisual;exports.stampGridEditTarget=c.stampGridEditTarget;exports.useElementScreenRect=c.useElementScreenRect;exports.useGeomHitTest=c.useGeomHitTest;exports.useGeomHover=c.useGeomHover;exports.useGraphCommands=c.useGraphCommands;exports.useGraphHandle=c.useGraphHandle;exports.useGraphHistory=et;exports.useGraphHistoryShortcuts=rt;exports.useGraphSelection=c.useGraphSelection;exports.useGuidesTakePress=c.useGuidesTakePress;exports.useHandleScene=c.useHandleScene;exports.useHoverState=c.useHoverState;exports.useSceneSelector=c.useSceneSelector;exports.useStyleReaderTree=c.useStyleReaderTree;exports.useStyleReaders=c.useStyleReaders;exports.useStyleResolver=c.useStyleResolver;exports.useTextMeasurer=c.useTextMeasurer;exports.vars=se.vars;
package/dist/index.d.ts CHANGED
@@ -47,6 +47,7 @@ import { RenderHitTester } from '@graphysdk/viz-engine';
47
47
  import { ResolvedHeadlineSize } from '@graphysdk/viz-engine';
48
48
  import { ResolvedSourceStyle } from '@graphysdk/viz-engine';
49
49
  import { ResolvedTextStyle } from '@graphysdk/viz-engine';
50
+ import { ScaledPositionAestheticKey } from '@graphysdk/viz-engine';
50
51
  import { Scene } from '@graphysdk/viz-engine';
51
52
  import { SceneLayer } from '@graphysdk/viz-engine';
52
53
  import { SceneLayerFor } from '@graphysdk/viz-engine';
@@ -183,7 +184,12 @@ export declare const darkTheme: string;
183
184
  /** Default paint for the footer region — caption, source line, and optional footer-anchored badge. */
184
185
  export declare const DefaultFooter: ({ ref, footerRect, mode, caption, isCaptionVisible, source, isSourceVisible, captionStyle, sourceStyle, brandMark, }: FooterSlotProps) => JSX.Element | null;
185
186
 
186
- /** Default paint for the grid region — per-tick gridlines, drawn inside the panel frame rect. */
187
+ /**
188
+ * Default paint for the grid region — per-tick grid lines, drawn inside the panel frame rect. Where a press
189
+ * can take a guide, each drawn line is a stamped group holding the stroke and a transparent hit stroke
190
+ * `GRID_LINE_HIT_WIDTH_PX` wide on the same coordinates. The hit stroke is solid, so a dashed line answers
191
+ * along its whole length, gaps included. Of two crossing lines the one painted later answers.
192
+ */
187
193
  export declare const DefaultGrid: ({ axes, panelBorderSizes, panelFrameRect, panelRect }: GridSlotProps) => JSX.Element;
188
194
 
189
195
  /** Default paint for the header region — title, subtitle, and optional header-anchored badge. */
@@ -236,6 +242,12 @@ export declare interface DevToolsPanelProps {
236
242
  className?: string;
237
243
  }
238
244
 
245
+ /** Addresses the axis a stamped node belongs to. */
246
+ declare const EDIT_TARGET_AXIS_ATTRIBUTE = "data-edit-axis";
247
+
248
+ /** Names the family painted by a node, which the shared pointer resolver reads. */
249
+ declare const EDIT_TARGET_KIND_ATTRIBUTE = "data-edit-kind";
250
+
239
251
  /** Props the renderer passes to the editor layer filling the `EditorSurface` slot. */
240
252
  export declare interface EditorSurfaceSlotProps {
241
253
  /** The frame's content box — the element the layer measures, listens on and aligns its chrome to. */
@@ -694,9 +706,21 @@ export declare interface GraphyKit<P extends readonly Plugin_2[] = readonly Plug
694
706
  GraphProvider: (props: Omit<GraphProviderProps, 'plugins'>) => ReactElement;
695
707
  }
696
708
 
709
+ /** The axis identity spread onto the group holding one grid line's stroke and its hit stroke. */
710
+ export declare type GridEditTargetAttributes = {
711
+ /** The grid family read by the editor. */
712
+ [EDIT_TARGET_KIND_ATTRIBUTE]: 'grid';
713
+ /** The scale the line belongs to, kept as its own key so a secondary axis is told apart from the primary. */
714
+ [EDIT_TARGET_AXIS_ATTRIBUTE]: ScaledPositionAestheticKey;
715
+ };
716
+
697
717
  /**
698
718
  * Props for the Grid slot, overridable via `slots.Grid` on `GraphRenderer`. `panelRect` is in
699
719
  * SVG-local coordinates.
720
+ *
721
+ * A grid filling this slot spreads `stampGridEditTarget` on the group holding each line it draws, with a
722
+ * hit area of its own inside that group, where `useGuidesTakePress` is true; a line it hides or moves
723
+ * takes its hit area with it, and a line it does not stamp takes no press.
700
724
  */
701
725
  export declare interface GridSlotProps {
702
726
  axes: FormattedAxis[];
@@ -808,6 +832,11 @@ declare interface HoverSlice {
808
832
  pointerRegions: readonly PointerRegion[];
809
833
  /** A gesture owns the pointer: the tracker runs no query, so nothing recomputes behind it. */
810
834
  isPointerSuspended: boolean;
835
+ /**
836
+ * An editing surface makes the one query a frame and writes the hover itself: the tracker keeps the
837
+ * viewport and runs no query, so a chart with no such surface mounted keeps its own.
838
+ */
839
+ isQueryOwnedByEditor: boolean;
811
840
  }
812
841
 
813
842
  declare interface HoverStoreActions {
@@ -819,6 +848,7 @@ declare interface HoverStoreActions {
819
848
  */
820
849
  publishPointerRegions: (publisher: string, regions: readonly PointerRegion[]) => void;
821
850
  setPointerSuspended: (next: boolean) => void;
851
+ setQueryOwnedByEditor: (next: boolean) => void;
822
852
  }
823
853
 
824
854
  /** State of the hover store: the current {@link HoverState} plus its setter. */
@@ -981,6 +1011,9 @@ export declare interface SlotOverride<Props, Measure> {
981
1011
  measure: Measure;
982
1012
  }
983
1013
 
1014
+ /** Identifies one drawn grid line of a scale, on the group holding its stroke and its hit stroke. */
1015
+ export declare const stampGridEditTarget: (scaleAestheticKey: ScaledPositionAestheticKey) => GridEditTargetAttributes;
1016
+
984
1017
  /**
985
1018
  * The vocabulary of legend/tooltip/headline marks the {@link Swatch} can paint. A geom picks the one
986
1019
  * that best evokes its on-canvas mark via `swatchShape` on its render contract (see
@@ -1251,6 +1284,12 @@ export declare const useGraphHistoryShortcuts: (handleRef: RefObject<GraphHandle
1251
1284
  */
1252
1285
  export declare const useGraphSelection: () => readonly EditTarget[];
1253
1286
 
1287
+ /**
1288
+ * Whether a press in the chart's mode takes a guide. A guide renderer, the default or a slot, reads it to
1289
+ * give its stamped nodes a hit area and the pointer only where a press on them selects the guide.
1290
+ */
1291
+ export declare const useGuidesTakePress: () => boolean;
1292
+
1254
1293
  /**
1255
1294
  * The graph's scene, re-read whenever the graph changes, or `null` before its first
1256
1295
  * successful compile.