@graphysdk/react-renderer 1.9.0-beta.1793788324987 → 1.9.0-beta.1793799752548
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/editable.cjs +1 -1
- package/dist/editable.mjs +21 -21
- package/dist/{history-chords-CSUG-Nyi.js → history-chords-DC1G9pA2.js} +2218 -2204
- package/dist/history-chords-DDANG01l.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +57 -21
- package/dist/index.mjs +258 -256
- package/package.json +3 -3
- package/dist/history-chords-QMnUaJIS.cjs +0 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const s=require("./history-chords-QMnUaJIS.cjs");let h=require("@graphysdk/viz-engine"),u=require("react"),i=require("react/jsx-runtime"),z=require("zustand"),F=require("motion/react"),V=require("zustand/vanilla"),W=require("clsx");W=s.__toESM(W,1);var fe="_1a5iqpb0",pe="_1a5iqpb1";var ve="_1a5iqpb3",Se="_1a5iqpb4",ye="_1a5iqpb5";var Y=({errors:e})=>{const[t,...r]=e;return(0,i.jsxs)("div",{role:"alert",className:fe,children:[(0,i.jsx)("strong",{className:pe,children:"This chart could not be rendered."}),t&&(0,i.jsx)(Q,{diagnostic:t}),r.length>0&&(0,i.jsx)("ul",{className:"_1a5iqpb2",children:r.map((n,o)=>(0,i.jsx)("li",{children:(0,i.jsx)(Q,{diagnostic:n})},`${n.code}-${o}`))})]})},Q=({diagnostic:e})=>(0,i.jsxs)("div",{className:ve,children:[(0,i.jsx)("span",{className:Se,children:e.code}),(0,i.jsx)("p",{className:ye,children:e.message}),e.suggestion&&(0,i.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function be(e=[],t=[]){return e.length===t.length&&e.every((r,n)=>Object.is(r,t[n]))}var oe=class extends u.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,h.buildDiagnostic)(e)}}componentDidCatch(e,t){const r=(0,h.buildDiagnostic)(e);s.logDiagnostics([r]),this.props.onError?.([r]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!be(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,i.jsx)(Y,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,i.jsx)(Y,{errors:t}):r}},ie=e=>typeof e=="object"&&"geom"in e&&"render"in e,ae=e=>{const t=(0,h.resolveDefinition)(e);return t instanceof h.Geom?t:null},le=(e,t)=>{const r=e.filter(n=>Ge(n,t));return r.length===e.length?e:r},Ge=(e,t)=>e.kind==="annotation"?(0,h.findAnnotation)(t.annotations,e.id)!==null:e.kind==="observations"||e.kind==="layer"&&e.layerId!==void 0?(0,h.findLayerById)(t.layers,e.layerId)!==void 0:!0,J=[],xe=()=>(0,V.createStore)(e=>({selection:J,setSelection:t=>e(r=>Te(r.selection,t)?r:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:J})})),Te=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,n)=>{const o=t[n];return o!==void 0&&(0,h.areEditTargetsEqual)(r,o)}),Ee=5,Re=e=>{if(!s.IS_DEV)return{emit:()=>{},subscribe:()=>Ce,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let r=null;return{emit:n=>{const o=e.getLastCompile();if(o){r=n;for(const l of t)l(n,o)}},subscribe:n=>(t.add(n),()=>{t.delete(n)}),getLastTrigger:()=>r,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},Pe=()=>(0,V.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,r)=>e(n=>{if(n.lastSnapshot===r)return n;const o={id:n.nextId,label:Ie(t),stages:r.stages,stageDurationsMs:r.stageDurationsMs,durationMs:r.durationMs};return{lastCompile:o,history:je(n.history,o,Ee),nextId:n.nextId+1,lastSnapshot:r}})})),Ce=()=>{},Ie=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}},je=(e,t,r)=>{const n=e.length>=r?e.length-(r-1):0;return[...e.slice(n),t]};function Z(e){const t=e.filter(ie),r=new Set([...Object.keys(s.BUILT_IN_GEOM_RENDERERS),...t.map(d=>d.geom)]),n=[],o=new Set;for(const d of e){const m=ae(d);m===null||r.has(m.type)||o.has(m.type)||(o.add(m.type),n.push({kind:"userInput",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${m.type}' is registered but has no renderer.`,context:{requested:m.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${m.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const l=new Map;for(const d of t){if("definition"in d)continue;const m=`${d.geom}|${d.coord}`,p=l.get(m);p?p.count+=1:l.set(m,{geom:d.geom,coord:d.coord,count:1})}const c=[];for(const{geom:d,coord:m,count:p}of l.values())p<2||c.push({kind:"userInput",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${d}', '${m}') (${p} entries); the last in the array wins.`,context:{requested:`${d}@${m}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${d}', '${m}').`});return c.push(...Me(e)),{errors:n,warnings:c}}function Ne(e,t){const{coordSystem:r,layers:n}=e,o=new Set,l=[];for(const c of n)t(c.geom,r.type)!==null||o.has(c.geom)||(o.add(c.geom),l.push({kind:"userInput",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${c.geom}' under ${r.type} coords; the layer is not painted.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${c.geom}', '${r.type}') via \`defineGeomRenderer\`.`}));return l}function De(e,t){const{coordSystem:r,layers:n}=e,o=new Set,l=[];for(const c of n){if(c.interactive===!1||c.spatialKind!=="renderHitTest"||o.has(c.geom))continue;const d=t(c.geom,r.type);d===null||d.hitTest||s.isLiveRender(d)||(o.add(c.geom),l.push({kind:"userInput",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares spatialKind 'renderHitTest' 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 a live render (\`{ fn, options: { live: true } }\`, live simulation) to the renderer for ('${c.geom}', '${r.type}').`}))}return l}function Le(e){const t=new Set,r=[];for(const n of e.layers){const o=n.identityKey;n.interactive!==!1&&(n.spatialKind!=="renderHitTest"||typeof o!="object"||t.has(n.geom)||n.data.hasVariable(o.variable)||(t.add(n.geom),r.push({kind:"userInput",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${n.geom}' keys its identity on '${o.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:n.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 _e(e,t){const{coordSystem:r,layers:n}=e,o=new Set,l=[];for(const c of n){if(c.interactive===!1||c.spatialKind!=="renderHitTest"||o.has(c.geom))continue;const d=t(c.geom,r.type);d===null||!d.hitTest||!s.isLiveRender(d)||(o.add(c.geom),l.push({kind:"userInput",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares both a \`hitTest\` factory and a live render; these are alternatives, so only the live render is used.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR a live render (`{ fn, options: { live: true } }`) for a live simulation."}))}return l}function ke(e,t){const r=new Set,n=[];for(const o of e.layers)o.interactive!==!1&&(o.spatialKind!=="renderHitTest"||r.has(o.geom)||t.hasCapability(o.geom)||(r.add(o.geom),n.push({kind:"userInput",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 n}function qe(e,t){const{coordSystem:r,layers:n}=e,o=new Set,l=[];for(const c of n){if(c.interactive===!1||c.spatialKind==="renderHitTest"||o.has(c.geom))continue;const d=t(c.geom,r.type);d===null||!s.isLiveRender(d)||(o.add(c.geom),l.push({kind:"userInput",severity:"warning",code:"LIVE_RENDER_REQUIRES_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares a live render but its layer's spatialKind is '${c.spatialKind}', not 'renderHitTest'; its push-path hover resolves to nothing.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'renderHitTest' so the scene layer carries the `byKey` index the live render's `pushHover` resolves against."}))}return l}function we(e,t){let r;return e.layers.flatMap((n,o)=>s.isLiveRender(t(n.geom,e.coordSystem.type))?He(n)?(r??=(0,h.createStyleResolver)().readers(e),(r.geom(n).get("overpaint",void 0,"hovered")?.length??0)===0?[]:[{kind:"userInput",severity:"warning",code:"INVALID_STYLE_RULE",message:`Style 'overpaint' in state 'hovered' is not supported on live geom '${n.geom}' (layer '${n.id}'); it is ignored.`,context:{param:"overpaint",layerIndex:o,requested:n.geom},suggestion:"Remove the hovered overpaint, or paint the hover treatment in the geom's live render."}]):[]:[])}var He=e=>[e.styles.defaults,e.styles.overrides].some(t=>t.some(r=>r.state==="hovered"&&(r.declarations.overpaint?.length??0)>0));function Me(e){const t=new Set,r=[];for(const n of e){const o=ae(n);o===null||t.has(o.type)||o.dataLabelCoordTypes.length===0||o.getDataLabelPlacements!==void 0||(t.add(o.type),r.push({kind:"userInput",severity:"warning",code:"MISSING_DATA_LABEL_PLACEMENT",message:`Geom '${o.type}' declares \`dataLabelCoordTypes\` but implements no \`getDataLabelPlacements\`; its layers paint no data labels.`,context:{requested:o.type,kind:"geom-renderer"},suggestion:"Implement `getDataLabelPlacements(context)` on the geom, or drop `dataLabelCoordTypes` so the compiler warns the author off the flag."}))}return r}var Ae=e=>(0,V.createStore)(t=>({scene:e,setScene:r=>t(n=>n.scene===r?n:{scene:r})})),Oe=({spec:e,data:t,colorScheme:r,plugins:n,theme:o,resolveRenderer:l,anchorResolver:c,onSpecChange:d,onError:m,onWarnings:p})=>{const R=s.useLatestRef(d),D=s.useLatestRef(m),E=s.useLatestRef(p),[{session:v,compileBus:f,findGeom:y}]=(0,u.useState)(()=>{const a=(0,h.createCompiler)({plugins:n,theme:o});return{session:new h.GraphCompilationSession(a),compileBus:Re(a),findGeom:g=>a.findGeom(g)}}),[b]=(0,u.useState)(()=>{const a=Z(n??[]),g=Z(o?.plugins??[]);return{errors:[...g.errors,...a.errors],warnings:[...g.warnings,...a.warnings]}}),q=(0,u.useRef)(null),[j]=(0,u.useState)($e),x=(0,u.useRef)(null),S=(0,u.useCallback)(a=>b.errors.length===0?a:[...b.errors,...a??[]],[b]),L=(0,u.useCallback)(a=>{if(!a.ok)return a.errors;if(x.current)x.current.getState().setScene(a.scene);else{const g=Ae(a.scene);g.subscribe(j.notify),x.current=g,j.notify()}return null},[j]),[O,P]=(0,u.useState)(()=>{const a=v.compile({spec:e,data:t,colorScheme:r});return q.current=a,S(L(a))}),C=(0,u.useCallback)(a=>a.ok?[...a.warnings,...Ne(a.scene,l),...De(a.scene,l),...Le(a.scene),..._e(a.scene,l),...qe(a.scene,l),...we(a.scene,l),...ke(a.scene,c)]:a.warnings,[l,c]),I=(0,u.useCallback)(a=>{a.length!==0&&(s.logDiagnostics(a),D.current?.(a))},[D]),G=(0,u.useCallback)(a=>{a.length!==0&&(s.logDiagnostics(a),E.current?.(a))},[E]);(0,u.useEffect)(()=>{const a=q.current;a&&(I([...b.errors,...a.ok?[]:a.errors]),G([...b.warnings,...C(a)]),a.ok&&f.emit({kind:"init"}))},[f,I,G,b,C]),(0,u.useEffect)(()=>{const a=v.update({spec:e,data:t,colorScheme:r});if(!a)return;a.committedSpec&&R.current?.(a.committedSpec);const g=L(a.result);P(S(g)),g&&I(g),G(C(a.result)),g||f.emit({kind:a.hasSpecChange?"spec":"data"})},[e,t,r,v,f,L,I,G,S,C,R]);const w=(0,u.useCallback)(a=>{P(g=>g===null?g:S(null)),G(C(a))},[S,G,C]),H=(0,u.useCallback)(a=>{a.scene&&x.current?.getState().setScene(a.scene),a.result&&w(a.result),a.command&&f.emit({kind:"command",command:a.command}),a.spec&&R.current?.(a.spec),a.errors&&I([...a.errors])},[w,f,R,I]),T=(0,u.useCallback)(a=>{for(const g of a)H(g);return a.some(g=>!!g.scene)},[H]),K=(0,u.useCallback)((a,g)=>{T(v.applyCommand(a,g))},[v,T]),$=(0,u.useCallback)(()=>{T(v.commit())},[v,T]),N=(0,u.useCallback)(()=>T(v.undo()),[v,T]),M=(0,u.useCallback)(()=>T(v.redo()),[v,T]),_=(0,u.useMemo)(()=>({stack:v.history,undo:N,redo:M}),[v,N,M]),U=(0,u.useCallback)(()=>x.current?.getState().scene??null,[]);return{store:x.current,dispatch:K,commit:$,history:_,subscribe:j.subscribe,getScene:U,compileBus:f,compileErrors:O,findGeom:y}},$e=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},ce=({data:e,spec:t,plugins:r=[],theme:n,glyphs:o,formattingLocale:l,handleRef:c,onSpecChange:d,onError:m,onWarnings:p,colorScheme:R="light",children:D})=>{const E=Be(l,p),[v]=(0,u.useState)(()=>n),[f]=(0,u.useState)(()=>s.mergeGlyphs(n?.glyphs,o)),y=v?.colorScheme??R,[b]=(0,u.useState)(()=>s.createGeomRendererResolver([...v?.plugins??[],...r].filter(ie))),q=(0,u.useId)(),[j]=(0,u.useState)(()=>(0,h.createAnchorResolver)(r)),[x]=(0,u.useState)(()=>(0,h.createDataLabelPlacementResolver)(r)),[S]=(0,u.useState)(()=>xe()),[L]=(0,u.useState)(()=>s.createTargetBoundaryStore()),O=(0,u.useMemo)(()=>(0,h.createStyleResolver)({colorScheme:y}),[y]),{store:P,dispatch:C,commit:I,history:G,subscribe:w,getScene:H,compileBus:T,compileErrors:K,findGeom:$}=Oe({spec:t,data:e,colorScheme:y,plugins:r,theme:v,resolveRenderer:b,anchorResolver:j,onSpecChange:d,onError:m,onWarnings:p});(0,u.useEffect)(()=>{if(P)return P.subscribe((_,U)=>{if(_.scene.spec===U.scene.spec)return;const{selection:a,setSelection:g}=S.getState();a.length!==0&&g(le(a,_.scene.spec))})},[P,S]);const N=(0,u.useMemo)(()=>({dispatch:C,commit:I}),[C,I]);(0,u.useImperativeHandle)(c,()=>({commands:N,undo:G.undo,redo:G.redo,subscribe:w,getScene:H,formattingLocale:E,getSelection:()=>S.getState().selection,setSelection:_=>S.getState().setSelection(_),subscribeSelection:S.subscribe,canPlaceDataLabels:x.hasCapability,canFormatDataLabelsAsPercentages:x.hasPercentageFormat,getGlyphs:()=>f}),[N,G,w,H,E,S,x,f]);const M=(0,u.useMemo)(()=>P?{chartId:q,store:P,selectionStore:S,targetBoundaryStore:L,commands:N,history:G,formattingLocale:E,compileBus:T,colorScheme:y,styleResolver:O,anchorResolver:j,findGeom:$}:null,[q,P,S,L,N,G,E,T,y,O,j,$]);return(0,i.jsx)(oe,{forcedErrors:K,onError:m,resetKeys:[t,e],children:M?(0,i.jsx)(s.GraphContext.Provider,{value:M,children:(0,i.jsx)(s.GeomRendererResolverProvider,{value:b,children:(0,i.jsx)(s.DataLabelPlacementResolverProvider,{value:x,children:(0,i.jsx)(s.GeomShapesProvider,{shapes:v?.shapes,children:(0,i.jsx)(s.GlyphRegistryProvider,{glyphs:f,children:D})})})})}):null})},Be=(e,t)=>{const r=s.useLatestRef(t);return(0,u.useEffect)(()=>{if(e===void 0||(0,h.findIntlLocale)(e)!==void 0)return;const n=[{severity:"warning",kind:"userInput",code:"INVALID_FORMATTING_LOCALE",message:`formattingLocale '${e}' is not a tag Intl can format in, so the chart formats in ${h.DEFAULT_LOCALE}.`}];s.logDiagnostics(n),r.current?.(n)},[e,r]),e===void 0?void 0:(0,h.canonicalizeLocale)(e)};function Fe({theme:e,glyphs:t,...r}={}){const n=(0,h.createSpecBuilder)(r);return{...n,GraphProvider:l=>(0,i.jsx)(ce,{...l,plugins:n.plugins,theme:e,glyphs:t})}}var k=(e,t)=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(!e.endsWith("%"))return null;const r=Number.parseFloat(e);return Number.isFinite(r)?r/100*t:null},Ke=({x:e,y:t,width:r,height:n},o)=>{const l=k(e,o.width),c=k(t,o.height),d=k(r,o.width),m=k(n,o.height);return l===null||c===null||d===null||m===null?null:{x:l,y:c,width:d,height:m}},ue=({animateTransitions:e,cx:t,cy:r,r:n,effects:o,...l})=>{const c=s.toGeomEffectsStyle(o);return e?(0,i.jsx)(F.motion.circle,{initial:!1,animate:{cx:t,cy:r,r:n},transition:s.DEFAULT_SPRING_TRANSITION,style:c,...l}):(0,i.jsx)("circle",{cx:t,cy:r,r:n,style:c,...l})},de=({animateTransitions:e,x1:t,y1:r,x2:n,y2:o,effects:l,...c})=>{const d=s.toGeomEffectsStyle(l);return e?(0,i.jsx)(F.motion.line,{initial:!1,animate:{x1:t,y1:r,x2:n,y2:o},transition:s.DEFAULT_SPRING_TRANSITION,style:d,...c}):(0,i.jsx)("line",{x1:t,y1:r,x2:n,y2:o,style:d,...c})},me=({animateTransitions:e,x:t,y:r,width:n,height:o,rx:l,ry:c,effects:d,...m})=>{const p=s.toGeomEffectsStyle(d);return e?(0,i.jsx)(F.motion.rect,{initial:!1,animate:{attrX:t,attrY:r,width:n,height:o,...l!==void 0&&c!==void 0?{rx:l,ry:c}:{}},transition:s.DEFAULT_SPRING_TRANSITION,style:p,...m}):(0,i.jsx)("rect",{x:t,y:r,width:n,height:o,rx:l,ry:c,style:p,...m})},he=({animateTransitions:e,d:t,source:r,effects:n,...o})=>{const l=s.toGeomEffectsStyle(n);return e?(0,i.jsx)(Ve,{d:t,source:r,style:l,...o}):(0,i.jsx)("path",{d:t,style:l,...o})},Ue=e=>{const{Circle:t}=s.useGeomShapes(),{symbol:r,...n}=e;return r!==void 0&&r!=="circle"?(0,i.jsx)("g",{style:s.toGeomEffectsStyle(e.effects),"data-testid":e["data-testid"],children:(0,i.jsx)(s.PointSymbol,{symbol:r,cx:ee(e.cx),cy:ee(e.cy),size:e.r*2,fill:e.fill??"currentColor",fillOpacity:e.fillOpacity,opacity:e.opacity,stroke:e.stroke,strokeOpacity:e.strokeOpacity,strokeWidth:e.strokeWidth,motion:e.animateTransitions?{transition:s.DEFAULT_SPRING_TRANSITION,intro:!1,fadesIn:!1}:null})}):t===void 0?ue(n):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(t,{...n})})},ze=e=>{const{Line:t}=s.useGeomShapes();return t===void 0?de(e):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(t,{...e})})},We=({cornerRadius:e,...t})=>{const{Rect:r}=s.useGeomShapes(),n=s.useGeomPanelPixelSize(),o=s.useGeomPixelsPerUnit(),l={...t,...Xe(e,t,n,o)};return r===void 0?me(l):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(r,{...l})})},Ye=e=>{const{Path:t}=s.useGeomShapes();return t===void 0?he(e):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(t,{...e})})},ee=e=>typeof e=="number"?`${e}px`:e,Ve=({d:e,source:t,...r})=>{const n=s.useSvgPathMorph(e,s.DEFAULT_SPRING_TRANSITION,t);return(0,i.jsx)(F.motion.path,{d:n,...r})},Xe=(e,t,r,n)=>{if(e===void 0)return{};const o=(0,h.foldGeomCornerRadii)(e);if(o===void 0)return{};const l=Qe(t,r,n);if(l===null)return o==="full"?{}:re((0,h.resolveGeomCornerRadiusPx)({cornerRadius:o}),n);const c=Math.min((0,h.resolveGeomCornerRadiusPx)({cornerRadius:o,box:l}),Math.min(l.width,l.height)/2);return re(c,n)},Qe=(e,t,r)=>{const n=te(e.width,t?.width,r.x),o=te(e.height,t?.height,r.y);return n===null||o===null?null:{width:n,height:o}},te=(e,t,r)=>{if(typeof e=="number")return Number.isFinite(e)?Math.abs(e)*r:null;if(t===void 0)return null;const n=k(e,t);return n===null?null:Math.abs(n)},re=(e,t)=>t.x<=0||t.y<=0?{rx:0,ry:0}:{rx:e/t.x,ry:e/t.y},Je=({children:e,...t})=>{const r=s.useGeomPanelPixelSize();return(0,i.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:(0,i.jsx)(s.GeomPanelSizeProvider,{size:r,space:"unit",children:e})})},Ze=({box:e,children:t})=>{const r=s.useGeomPanelSize(),n=r===null?null:r.width*(e.x1-e.x0),o=r===null?null:r.height*(e.y1-e.y0),l=(0,u.useMemo)(()=>n===null||o===null?null:{width:n,height:o},[n,o]);return(0,i.jsx)("svg",{x:(0,h.toPercent)(e.x0),y:(0,h.toPercent)(e.y0),width:(0,h.toPercent)(e.x1-e.x0),height:(0,h.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:(0,i.jsx)(s.GeomPanelSizeProvider,{size:l,children:t})})},et="drqe3u0",tt="drqe3u1",rt="drqe3u2",nt="drqe3u3",A="drqe3u4",st="drqe3u5",ot="drqe3u6",it="drqe3u7",B="drqe3u8",at="drqe3u9",lt="drqe3ua";var ct="drqe3uc",ut="drqe3ud",dt="drqe3ue",mt="drqe3uf";var ht="drqe3uh",gt="drqe3ui",ne={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},se={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},ge={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ft=({width:e=440,style:t,className:r}={})=>{const{compileBus:n}=s.useGraphContext(),[o]=(0,u.useState)(()=>Pe()),[l,c]=(0,u.useState)(!1),[d,m]=(0,u.useState)(h.isCompilerCachingEnabled);(0,u.useEffect)(()=>{const{recordCompile:f}=o.getState(),y=n.getLastTrigger(),b=n.getLastCompile();return y&&b&&f(y,b),n.subscribe(f)},[o,n]);const p=(0,z.useStore)(o,f=>f.lastCompile),R=(0,z.useStore)(o,f=>f.history),D=n.getCacheStats(),E=p===null&&R.length===0,v=()=>{m(f=>{const y=!f;return(0,h.setCompilerCachingEnabled)(y),y})};return(0,i.jsxs)("div",{className:(0,W.default)(lt,r),style:{width:e,...t},children:[(0,i.jsxs)("div",{className:et,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:tt,children:"compile cache"}),(0,i.jsx)("div",{className:dt,children:E?"production: stats disabled":p?`last: ${p.label} · ${X(p.durationMs)}`:"awaiting first compile…"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>c(f=>!f),className:mt,children:l?"▾":"▴"})]}),!l&&(0,i.jsxs)("div",{className:"drqe3ub",children:[(0,i.jsxs)("button",{type:"button",onClick:v,className:d?ne.enabled:ne.disabled,"aria-pressed":d,children:["cache ",d?"enabled":"disabled"]}),(0,i.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!l&&!E&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(pt,{delta:p?.stages,durations:p?.stageDurationsMs,cumulative:D}),(0,i.jsx)(vt,{entries:R})]})]})},pt=({delta:e,durations:t,cumulative:r})=>(0,i.jsxs)("table",{className:rt,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:ht,children:[(0,i.jsx)("th",{className:nt,children:"stage"}),(0,i.jsx)("th",{className:A,children:"time"}),(0,i.jsx)("th",{className:A,children:"Δ miss"}),(0,i.jsx)("th",{className:A,children:"Δ hit"}),(0,i.jsx)("th",{className:A,children:"total miss"}),(0,i.jsx)("th",{className:A,children:"total hit"})]})}),(0,i.jsx)("tbody",{children:h.COMPILER_STAGE_KEYS.map(n=>{const o=e?.[n],l=St(o);return(0,i.jsxs)("tr",{className:ct,children:[(0,i.jsxs)("td",{className:st,children:[(0,i.jsx)("span",{className:ge[l],"aria-hidden":!0})," ",n]}),(0,i.jsx)("td",{className:B,children:t===void 0||l==="untouched"?"—":X(t[n])}),(0,i.jsx)("td",{className:l==="ran"?se.ran:se.dim,children:o?.misses??0}),(0,i.jsx)("td",{className:B,children:o?.hits??0}),(0,i.jsx)("td",{className:B,children:r[n].misses}),(0,i.jsx)("td",{className:B,children:r[n].hits})]},n)})})]}),vt=({entries:e})=>e.length===0?null:(0,i.jsxs)("div",{className:ut,children:[(0,i.jsx)("div",{className:gt,children:"recent compiles"}),e.map(t=>{const r=yt(t.stages,l=>l.misses>0),n=h.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,i.jsxs)("div",{className:ot,children:[(0,i.jsx)("span",{className:ge[o],"aria-hidden":!0}),(0,i.jsx)("span",{className:it,title:t.label,children:t.label}),(0,i.jsxs)("span",{className:at,children:[r,"/",n," ran · ",X(t.durationMs)]})]},t.id)})]}),St=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",yt=(e,t)=>{let r=0;for(const n of h.COMPILER_STAGE_KEYS)t(e[n])&&(r+=1);return r},X=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,bt=()=>{const{history:e}=s.useGraphContext(),{stack:t,undo:r,redo:n}=e,o=(0,u.useCallback)(d=>t.subscribe(d),[t]),l=(0,u.useCallback)(()=>t.getSnapshot(),[t]),c=(0,u.useSyncExternalStore)(o,l,l);return(0,u.useMemo)(()=>({...c,undo:r,redo:n}),[c,r,n])},Gt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),xt=(e,t={})=>{const{target:r,enabled:n=!0}=t;(0,u.useEffect)(()=>{const o=Tt(r);if(!n||!o)return;const l=c=>{if(!Et(c)||c.defaultPrevented||Rt(c.target))return;const d=s.resolveHistoryStep(c);if(!d)return;const m=e.current;m&&(d==="undo"?m.undo():m.redo())&&c.preventDefault()};return o.addEventListener("keydown",l),()=>o.removeEventListener("keydown",l)},[e,r,n])},Tt=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,Et=e=>"key"in e,Rt=e=>e instanceof HTMLInputElement?!Gt.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1,Pt=()=>{const{targetBoundaryStore:e}=s.useGraphContext();return(0,z.useStore)(e,t=>t.boundary)};exports.CanvasTextMeasurer=s.CanvasTextMeasurer;exports.DefaultFooter=s.DefaultFooter;exports.DefaultGeomCircle=ue;exports.DefaultGeomLine=de;exports.DefaultGeomPath=he;exports.DefaultGeomRect=me;exports.DefaultGrid=s.DefaultGrid;exports.DefaultHeader=s.DefaultHeader;exports.DefaultSwatch=s.DefaultSwatch;exports.DefaultTooltip=s.DefaultTooltip;exports.DevToolsPanel=ft;exports.GRAPH_MODES=s.GRAPH_MODES;exports.GeomCircle=Ue;exports.GeomLine=ze;exports.GeomOverpaint=s.GeomOverpaint;exports.GeomPath=Ye;exports.GeomRect=We;exports.GraphErrorBoundary=oe;exports.GraphErrorPanel=Y;exports.GraphProvider=ce;exports.GraphRenderer=s.GraphRenderer;exports.GraphyBadge=s.GraphyBadge;exports.HoverProvider=s.HoverProvider;exports.IntlProvider=s.ChartIntlProvider;exports.IntroFade=s.IntroFade;exports.IntroWipeClip=s.IntroWipeClip;exports.TextMeasurerProvider=s.TextMeasurerProvider;exports.ThemeProvider=s.ThemeProvider;exports.UnitBoxSvg=Ze;exports.UnitSpaceSvg=Je;exports.buildDotsEditOutlineShapes=s.buildDotsEditOutlineShapes;exports.createGraphyKit=Fe;exports.darkTheme=s.darkTheme;exports.defineGeomRenderer=s.defineGeomRenderer;exports.defineGlyph=s.defineGlyph;exports.getBuiltInEditOutlineShapes=s.getBuiltInEditOutlineShapes;exports.lightTheme=s.lightTheme;exports.lightenCss=s.lightenCss;exports.projectPointCartesian=s.projectPointCartesian;exports.pruneSelection=le;exports.readPositionPixels=k;exports.readRectPixels=Ke;exports.resolveGraphyBadgeVariant=s.resolveGraphyBadgeVariant;exports.resolvePathStroke=s.resolvePathStroke;exports.scalePointToPanel=s.scalePointToPanel;exports.stampAxisEditTarget=s.stampAxisEditTarget;exports.stampGridEditTarget=s.stampGridEditTarget;exports.stampLegendEditTarget=s.stampLegendEditTarget;exports.useElementScreenRect=s.useElementScreenRect;exports.useFormattingLocale=s.useFormattingLocale;exports.useGeomHitTest=s.useGeomHitTest;exports.useGeomHover=s.useGeomHover;exports.useGeomPanelSize=s.useGeomPanelSize;exports.useGeomReaderTree=s.useGeomReaderTree;exports.useGeomStyleReader=s.useGeomStyleReader;exports.useGraphCommands=s.useGraphCommands;exports.useGraphHandle=s.useGraphHandle;exports.useGraphHistory=bt;exports.useGraphHistoryShortcuts=xt;exports.useGraphLocale=s.useGraphLocale;exports.useGraphSelection=s.useGraphSelection;exports.useGuidesTakePress=s.useGuidesTakePress;exports.useHandleScene=s.useHandleScene;exports.useHoverState=s.useHoverState;exports.usePaintDefs=s.usePaintDefs;exports.useResolvedStyle=s.useResolvedStyle;exports.useSceneSelector=s.useSceneSelector;exports.useStyleReaderTree=s.useStyleReaderTree;exports.useStyleResolver=s.useStyleResolver;exports.useTargetBoundary=Pt;exports.useTextMeasurer=s.useTextMeasurer;exports.vars=s.vars;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const s=require("./history-chords-DDANG01l.cjs");let h=require("@graphysdk/viz-engine"),u=require("react"),i=require("react/jsx-runtime"),U=require("zustand"),F=require("motion/react"),Y=require("zustand/vanilla"),V=require("clsx");V=s.__toESM(V,1);var fe="_1a5iqpb0",pe="_1a5iqpb1";var ve="_1a5iqpb3",Se="_1a5iqpb4",ye="_1a5iqpb5";var W=({errors:e})=>{const[t,...r]=e;return(0,i.jsxs)("div",{role:"alert",className:fe,children:[(0,i.jsx)("strong",{className:pe,children:"This chart could not be rendered."}),t&&(0,i.jsx)(Q,{diagnostic:t}),r.length>0&&(0,i.jsx)("ul",{className:"_1a5iqpb2",children:r.map((n,o)=>(0,i.jsx)("li",{children:(0,i.jsx)(Q,{diagnostic:n})},`${n.code}-${o}`))})]})},Q=({diagnostic:e})=>(0,i.jsxs)("div",{className:ve,children:[(0,i.jsx)("span",{className:Se,children:e.code}),(0,i.jsx)("p",{className:ye,children:e.message}),e.suggestion&&(0,i.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function Ge(e=[],t=[]){return e.length===t.length&&e.every((r,n)=>Object.is(r,t[n]))}var oe=class extends u.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,h.buildDiagnostic)(e)}}componentDidCatch(e,t){const r=(0,h.buildDiagnostic)(e);s.logDiagnostics([r]),this.props.onError?.([r]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!Ge(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,i.jsx)(W,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,i.jsx)(W,{errors:t}):r}},ie=e=>typeof e=="object"&&"geom"in e&&"render"in e,ae=e=>{const t=(0,h.resolveDefinition)(e);return t instanceof h.Geom?t:null},le=(e,t)=>{const r=e.filter(n=>be(n,t));return r.length===e.length?e:r},be=(e,t)=>e.kind==="annotation"?(0,h.findAnnotation)(t.annotations,e.id)!==null:e.kind==="observations"||e.kind==="layer"&&e.layerId!==void 0?(0,h.findLayerById)(t.layers,e.layerId)!==void 0:!0,J=[],Te=()=>(0,Y.createStore)(e=>({selection:J,setSelection:t=>e(r=>xe(r.selection,t)?r:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:J})})),xe=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,n)=>{const o=t[n];return o!==void 0&&(0,h.areEditTargetsEqual)(r,o)}),Ee=5,Re=e=>{if(!s.IS_DEV)return{emit:()=>{},subscribe:()=>Ce,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let r=null;return{emit:n=>{const o=e.getLastCompile();if(o){r=n;for(const l of t)l(n,o)}},subscribe:n=>(t.add(n),()=>{t.delete(n)}),getLastTrigger:()=>r,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},Pe=()=>(0,Y.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,r)=>e(n=>{if(n.lastSnapshot===r)return n;const o={id:n.nextId,label:Ie(t),stages:r.stages,stageDurationsMs:r.stageDurationsMs,durationMs:r.durationMs};return{lastCompile:o,history:je(n.history,o,Ee),nextId:n.nextId+1,lastSnapshot:r}})})),Ce=()=>{},Ie=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}},je=(e,t,r)=>{const n=e.length>=r?e.length-(r-1):0;return[...e.slice(n),t]};function Z(e){const t=e.filter(ie),r=new Set([...Object.keys(s.BUILT_IN_GEOM_RENDERERS),...t.map(d=>d.geom)]),n=[],o=new Set;for(const d of e){const m=ae(d);m===null||r.has(m.type)||o.has(m.type)||(o.add(m.type),n.push({kind:"userInput",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${m.type}' is registered but has no renderer.`,context:{requested:m.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${m.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const l=new Map;for(const d of t){if("definition"in d)continue;const m=`${d.geom}|${d.coord}`,p=l.get(m);p?p.count+=1:l.set(m,{geom:d.geom,coord:d.coord,count:1})}const c=[];for(const{geom:d,coord:m,count:p}of l.values())p<2||c.push({kind:"userInput",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${d}', '${m}') (${p} entries); the last in the array wins.`,context:{requested:`${d}@${m}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${d}', '${m}').`});return c.push(...Me(e)),{errors:n,warnings:c}}function Ne(e,t){const{coordSystem:r,layers:n}=e,o=new Set,l=[];for(const c of n)t(c.geom,r.type)!==null||o.has(c.geom)||(o.add(c.geom),l.push({kind:"userInput",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${c.geom}' under ${r.type} coords; the layer is not painted.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${c.geom}', '${r.type}') via \`defineGeomRenderer\`.`}));return l}function De(e,t){const{coordSystem:r,layers:n}=e,o=new Set,l=[];for(const c of n){if(c.interactive===!1||c.spatialKind!=="renderHitTest"||o.has(c.geom))continue;const d=t(c.geom,r.type);d===null||d.hitTest||s.isLiveRender(d)||(o.add(c.geom),l.push({kind:"userInput",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares spatialKind 'renderHitTest' 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 a live render (\`{ fn, options: { live: true } }\`, live simulation) to the renderer for ('${c.geom}', '${r.type}').`}))}return l}function Le(e){const t=new Set,r=[];for(const n of e.layers){const o=n.identityKey;n.interactive!==!1&&(n.spatialKind!=="renderHitTest"||typeof o!="object"||t.has(n.geom)||n.data.hasVariable(o.variable)||(t.add(n.geom),r.push({kind:"userInput",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${n.geom}' keys its identity on '${o.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:n.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 _e(e,t){const{coordSystem:r,layers:n}=e,o=new Set,l=[];for(const c of n){if(c.interactive===!1||c.spatialKind!=="renderHitTest"||o.has(c.geom))continue;const d=t(c.geom,r.type);d===null||!d.hitTest||!s.isLiveRender(d)||(o.add(c.geom),l.push({kind:"userInput",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares both a \`hitTest\` factory and a live render; these are alternatives, so only the live render is used.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR a live render (`{ fn, options: { live: true } }`) for a live simulation."}))}return l}function ke(e,t){const r=new Set,n=[];for(const o of e.layers)o.interactive!==!1&&(o.spatialKind!=="renderHitTest"||r.has(o.geom)||t.hasCapability(o.geom)||(r.add(o.geom),n.push({kind:"userInput",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 n}function we(e,t){const{coordSystem:r,layers:n}=e,o=new Set,l=[];for(const c of n){if(c.interactive===!1||c.spatialKind==="renderHitTest"||o.has(c.geom))continue;const d=t(c.geom,r.type);d===null||!s.isLiveRender(d)||(o.add(c.geom),l.push({kind:"userInput",severity:"warning",code:"LIVE_RENDER_REQUIRES_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares a live render but its layer's spatialKind is '${c.spatialKind}', not 'renderHitTest'; its push-path hover resolves to nothing.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'renderHitTest' so the scene layer carries the `byKey` index the live render's `pushHover` resolves against."}))}return l}function qe(e,t){let r;return e.layers.flatMap((n,o)=>s.isLiveRender(t(n.geom,e.coordSystem.type))?He(n)?(r??=(0,h.createStyleResolver)().readers(e),(r.geom(n).get("overpaint",void 0,"hovered")?.length??0)===0?[]:[{kind:"userInput",severity:"warning",code:"INVALID_STYLE_RULE",message:`Style 'overpaint' in state 'hovered' is not supported on live geom '${n.geom}' (layer '${n.id}'); it is ignored.`,context:{param:"overpaint",layerIndex:o,requested:n.geom},suggestion:"Remove the hovered overpaint, or paint the hover treatment in the geom's live render."}]):[]:[])}var He=e=>[e.styles.defaults,e.styles.overrides].some(t=>t.some(r=>r.state==="hovered"&&(r.declarations.overpaint?.length??0)>0));function Me(e){const t=new Set,r=[];for(const n of e){const o=ae(n);o===null||t.has(o.type)||o.dataLabelCoordTypes.length===0||o.getDataLabelPlacements!==void 0||(t.add(o.type),r.push({kind:"userInput",severity:"warning",code:"MISSING_DATA_LABEL_PLACEMENT",message:`Geom '${o.type}' declares \`dataLabelCoordTypes\` but implements no \`getDataLabelPlacements\`; its layers paint no data labels.`,context:{requested:o.type,kind:"geom-renderer"},suggestion:"Implement `getDataLabelPlacements(context)` on the geom, or drop `dataLabelCoordTypes` so the compiler warns the author off the flag."}))}return r}var Ae=e=>(0,Y.createStore)(t=>({scene:e,setScene:r=>t(n=>n.scene===r?n:{scene:r})})),Oe=({spec:e,data:t,colorScheme:r,plugins:n,theme:o,resolveRenderer:l,anchorResolver:c,onSpecChange:d,onError:m,onWarnings:p})=>{const R=s.useLatestRef(d),D=s.useLatestRef(m),E=s.useLatestRef(p),[{session:v,compileBus:f,findGeom:y}]=(0,u.useState)(()=>{const a=(0,h.createCompiler)({plugins:n,theme:o});return{session:new h.GraphCompilationSession(a),compileBus:Re(a),findGeom:g=>a.findGeom(g)}}),[G]=(0,u.useState)(()=>{const a=Z(n??[]),g=Z(o?.plugins??[]);return{errors:[...g.errors,...a.errors],warnings:[...g.warnings,...a.warnings]}}),w=(0,u.useRef)(null),[j]=(0,u.useState)($e),T=(0,u.useRef)(null),S=(0,u.useCallback)(a=>G.errors.length===0?a:[...G.errors,...a??[]],[G]),L=(0,u.useCallback)(a=>{if(!a.ok)return a.errors;if(T.current)T.current.getState().setScene(a.scene);else{const g=Ae(a.scene);g.subscribe(j.notify),T.current=g,j.notify()}return null},[j]),[O,P]=(0,u.useState)(()=>{const a=v.compile({spec:e,data:t,colorScheme:r});return w.current=a,S(L(a))}),C=(0,u.useCallback)(a=>a.ok?[...a.warnings,...Ne(a.scene,l),...De(a.scene,l),...Le(a.scene),..._e(a.scene,l),...we(a.scene,l),...qe(a.scene,l),...ke(a.scene,c)]:a.warnings,[l,c]),I=(0,u.useCallback)(a=>{a.length!==0&&(s.logDiagnostics(a),D.current?.(a))},[D]),b=(0,u.useCallback)(a=>{a.length!==0&&(s.logDiagnostics(a),E.current?.(a))},[E]);(0,u.useEffect)(()=>{const a=w.current;a&&(I([...G.errors,...a.ok?[]:a.errors]),b([...G.warnings,...C(a)]),a.ok&&f.emit({kind:"init"}))},[f,I,b,G,C]),(0,u.useEffect)(()=>{const a=v.update({spec:e,data:t,colorScheme:r});if(!a)return;a.committedSpec&&R.current?.(a.committedSpec);const g=L(a.result);P(S(g)),g&&I(g),b(C(a.result)),g||f.emit({kind:a.hasSpecChange?"spec":"data"})},[e,t,r,v,f,L,I,b,S,C,R]);const q=(0,u.useCallback)(a=>{P(g=>g===null?g:S(null)),b(C(a))},[S,b,C]),H=(0,u.useCallback)(a=>{a.scene&&T.current?.getState().setScene(a.scene),a.result&&q(a.result),a.command&&f.emit({kind:"command",command:a.command}),a.spec&&R.current?.(a.spec),a.errors&&I([...a.errors])},[q,f,R,I]),x=(0,u.useCallback)(a=>{for(const g of a)H(g);return a.some(g=>!!g.scene)},[H]),z=(0,u.useCallback)((a,g)=>{x(v.applyCommand(a,g))},[v,x]),$=(0,u.useCallback)(()=>{x(v.commit())},[v,x]),N=(0,u.useCallback)(()=>x(v.undo()),[v,x]),M=(0,u.useCallback)(()=>x(v.redo()),[v,x]),_=(0,u.useMemo)(()=>({stack:v.history,undo:N,redo:M}),[v,N,M]),K=(0,u.useCallback)(()=>T.current?.getState().scene??null,[]);return{store:T.current,dispatch:z,commit:$,history:_,subscribe:j.subscribe,getScene:K,compileBus:f,compileErrors:O,findGeom:y}},$e=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},ce=({data:e,spec:t,plugins:r=[],theme:n,glyphs:o,formattingLocale:l,handleRef:c,onSpecChange:d,onError:m,onWarnings:p,colorScheme:R="light",children:D})=>{const E=Be(l,p),[v]=(0,u.useState)(()=>n),[f]=(0,u.useState)(()=>s.mergeGlyphs(n?.glyphs,o)),y=v?.colorScheme??R,[G]=(0,u.useState)(()=>s.createGeomRendererResolver([...v?.plugins??[],...r].filter(ie))),w=(0,u.useId)(),[j]=(0,u.useState)(()=>(0,h.createAnchorResolver)(r)),[T]=(0,u.useState)(()=>(0,h.createDataLabelPlacementResolver)(r)),[S]=(0,u.useState)(()=>Te()),[L]=(0,u.useState)(()=>s.createTargetBoundaryStore()),O=(0,u.useMemo)(()=>(0,h.createStyleResolver)({colorScheme:y}),[y]),{store:P,dispatch:C,commit:I,history:b,subscribe:q,getScene:H,compileBus:x,compileErrors:z,findGeom:$}=Oe({spec:t,data:e,colorScheme:y,plugins:r,theme:v,resolveRenderer:G,anchorResolver:j,onSpecChange:d,onError:m,onWarnings:p});(0,u.useEffect)(()=>{if(P)return P.subscribe((_,K)=>{if(_.scene.spec===K.scene.spec)return;const{selection:a,setSelection:g}=S.getState();a.length!==0&&g(le(a,_.scene.spec))})},[P,S]);const N=(0,u.useMemo)(()=>({dispatch:C,commit:I}),[C,I]);(0,u.useImperativeHandle)(c,()=>({commands:N,undo:b.undo,redo:b.redo,subscribe:q,getScene:H,formattingLocale:E,getSelection:()=>S.getState().selection,setSelection:_=>S.getState().setSelection(_),subscribeSelection:S.subscribe,canPlaceDataLabels:T.hasCapability,canFormatDataLabelsAsPercentages:T.hasPercentageFormat,getGlyphs:()=>f}),[N,b,q,H,E,S,T,f]);const M=(0,u.useMemo)(()=>P?{chartId:w,store:P,selectionStore:S,targetBoundaryStore:L,commands:N,history:b,formattingLocale:E,compileBus:x,colorScheme:y,styleResolver:O,anchorResolver:j,findGeom:$}:null,[w,P,S,L,N,b,E,x,y,O,j,$]);return(0,i.jsx)(oe,{forcedErrors:z,onError:m,resetKeys:[t,e],children:M?(0,i.jsx)(s.GraphContext.Provider,{value:M,children:(0,i.jsx)(s.GeomRendererResolverProvider,{value:G,children:(0,i.jsx)(s.DataLabelPlacementResolverProvider,{value:T,children:(0,i.jsx)(s.GeomShapesProvider,{shapes:v?.shapes,children:(0,i.jsx)(s.GlyphRegistryProvider,{glyphs:f,children:D})})})})}):null})},Be=(e,t)=>{const r=s.useLatestRef(t);return(0,u.useEffect)(()=>{if(e===void 0||(0,h.findIntlLocale)(e)!==void 0)return;const n=[{severity:"warning",kind:"userInput",code:"INVALID_FORMATTING_LOCALE",message:`formattingLocale '${e}' is not a tag Intl can format in, so the chart formats in ${h.DEFAULT_LOCALE}.`}];s.logDiagnostics(n),r.current?.(n)},[e,r]),e===void 0?void 0:(0,h.canonicalizeLocale)(e)};function Fe({theme:e,glyphs:t,...r}={}){const n=(0,h.createSpecBuilder)(r);return{...n,GraphProvider:l=>(0,i.jsx)(ce,{...l,plugins:n.plugins,theme:e,glyphs:t})}}var k=(e,t)=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(!e.endsWith("%"))return null;const r=Number.parseFloat(e);return Number.isFinite(r)?r/100*t:null},ze=({x:e,y:t,width:r,height:n},o)=>{const l=k(e,o.width),c=k(t,o.height),d=k(r,o.width),m=k(n,o.height);return l===null||c===null||d===null||m===null?null:{x:l,y:c,width:d,height:m}},ue=({animateTransitions:e,cx:t,cy:r,r:n,effects:o,...l})=>{const c=s.toGeomEffectsStyle(o);return e?(0,i.jsx)(F.motion.circle,{initial:!1,animate:{cx:t,cy:r,r:n},transition:s.DEFAULT_SPRING_TRANSITION,style:c,...l}):(0,i.jsx)("circle",{cx:t,cy:r,r:n,style:c,...l})},de=({animateTransitions:e,x1:t,y1:r,x2:n,y2:o,effects:l,...c})=>{const d=s.toGeomEffectsStyle(l);return e?(0,i.jsx)(F.motion.line,{initial:!1,animate:{x1:t,y1:r,x2:n,y2:o},transition:s.DEFAULT_SPRING_TRANSITION,style:d,...c}):(0,i.jsx)("line",{x1:t,y1:r,x2:n,y2:o,style:d,...c})},me=({animateTransitions:e,x:t,y:r,width:n,height:o,rx:l,ry:c,effects:d,...m})=>{const p=s.toGeomEffectsStyle(d);return e?(0,i.jsx)(F.motion.rect,{initial:!1,animate:{attrX:t,attrY:r,width:n,height:o,...l!==void 0&&c!==void 0?{rx:l,ry:c}:{}},transition:s.DEFAULT_SPRING_TRANSITION,style:p,...m}):(0,i.jsx)("rect",{x:t,y:r,width:n,height:o,rx:l,ry:c,style:p,...m})},he=({animateTransitions:e,d:t,source:r,effects:n,...o})=>{const l=s.toGeomEffectsStyle(n);return e?(0,i.jsx)(Ye,{d:t,source:r,style:l,...o}):(0,i.jsx)("path",{d:t,style:l,...o})},Ke=e=>{const{Circle:t}=s.useGeomShapes(),{symbol:r,...n}=e;return r!==void 0&&r!=="circle"?(0,i.jsx)("g",{style:s.toGeomEffectsStyle(e.effects),"data-testid":e["data-testid"],children:(0,i.jsx)(s.PointSymbol,{symbol:r,cx:ee(e.cx),cy:ee(e.cy),size:e.r*2,fill:e.fill??"currentColor",fillOpacity:e.fillOpacity,opacity:e.opacity,stroke:e.stroke,strokeOpacity:e.strokeOpacity,strokeWidth:e.strokeWidth,motion:e.animateTransitions?{transition:s.DEFAULT_SPRING_TRANSITION,intro:!1,fadesIn:!1}:null})}):t===void 0?ue(n):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(t,{...n})})},Ue=e=>{const{Line:t}=s.useGeomShapes();return t===void 0?de(e):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(t,{...e})})},Ve=({cornerRadius:e,...t})=>{const{Rect:r}=s.useGeomShapes(),n=s.useGeomViewport()?.size??null,o=s.useGeomPixelsPerUnit(),l={...t,...Xe(e,t,n,o)};return r===void 0?me(l):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(r,{...l})})},We=e=>{const{Path:t}=s.useGeomShapes();return t===void 0?he(e):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(t,{...e})})},ee=e=>typeof e=="number"?`${e}px`:e,Ye=({d:e,source:t,...r})=>{const n=s.useSvgPathMorph(e,s.DEFAULT_SPRING_TRANSITION,t);return(0,i.jsx)(F.motion.path,{d:n,...r})},Xe=(e,t,r,n)=>{if(e===void 0)return{};const o=(0,h.foldGeomCornerRadii)(e);if(o===void 0)return{};const l=Qe(t,r,n);if(l===null)return o==="full"?{}:re((0,h.resolveGeomCornerRadiusPx)({cornerRadius:o}),n);const c=Math.min((0,h.resolveGeomCornerRadiusPx)({cornerRadius:o,box:l}),Math.min(l.width,l.height)/2);return re(c,n)},Qe=(e,t,r)=>{const n=te(e.width,t?.width,r.x),o=te(e.height,t?.height,r.y);return n===null||o===null?null:{width:n,height:o}},te=(e,t,r)=>{if(typeof e=="number")return Number.isFinite(e)?Math.abs(e)*r:null;if(t===void 0)return null;const n=k(e,t);return n===null?null:Math.abs(n)},re=(e,t)=>t.x<=0||t.y<=0?{rx:0,ry:0}:{rx:e/t.x,ry:e/t.y},Je=({children:e,...t})=>{const r=s.useGeomViewport()?.size??null;return(0,i.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:(0,i.jsx)(s.GeomViewportProvider,{size:r,space:"unit",children:e})})},Ze=({box:e,children:t})=>{const r=s.useGeomViewportSize(),n=r===null?null:r.width*(e.x1-e.x0),o=r===null?null:r.height*(e.y1-e.y0),l=(0,u.useMemo)(()=>n===null||o===null?null:{width:n,height:o},[n,o]);return(0,i.jsx)("svg",{x:(0,h.toPercent)(e.x0),y:(0,h.toPercent)(e.y0),width:(0,h.toPercent)(e.x1-e.x0),height:(0,h.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:(0,i.jsx)(s.GeomViewportProvider,{size:l,children:t})})},et="drqe3u0",tt="drqe3u1",rt="drqe3u2",nt="drqe3u3",A="drqe3u4",st="drqe3u5",ot="drqe3u6",it="drqe3u7",B="drqe3u8",at="drqe3u9",lt="drqe3ua";var ct="drqe3uc",ut="drqe3ud",dt="drqe3ue",mt="drqe3uf";var ht="drqe3uh",gt="drqe3ui",ne={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},se={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},ge={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ft=({width:e=440,style:t,className:r}={})=>{const{compileBus:n}=s.useGraphContext(),[o]=(0,u.useState)(()=>Pe()),[l,c]=(0,u.useState)(!1),[d,m]=(0,u.useState)(h.isCompilerCachingEnabled);(0,u.useEffect)(()=>{const{recordCompile:f}=o.getState(),y=n.getLastTrigger(),G=n.getLastCompile();return y&&G&&f(y,G),n.subscribe(f)},[o,n]);const p=(0,U.useStore)(o,f=>f.lastCompile),R=(0,U.useStore)(o,f=>f.history),D=n.getCacheStats(),E=p===null&&R.length===0,v=()=>{m(f=>{const y=!f;return(0,h.setCompilerCachingEnabled)(y),y})};return(0,i.jsxs)("div",{className:(0,V.default)(lt,r),style:{width:e,...t},children:[(0,i.jsxs)("div",{className:et,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:tt,children:"compile cache"}),(0,i.jsx)("div",{className:dt,children:E?"production: stats disabled":p?`last: ${p.label} · ${X(p.durationMs)}`:"awaiting first compile…"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>c(f=>!f),className:mt,children:l?"▾":"▴"})]}),!l&&(0,i.jsxs)("div",{className:"drqe3ub",children:[(0,i.jsxs)("button",{type:"button",onClick:v,className:d?ne.enabled:ne.disabled,"aria-pressed":d,children:["cache ",d?"enabled":"disabled"]}),(0,i.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!l&&!E&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(pt,{delta:p?.stages,durations:p?.stageDurationsMs,cumulative:D}),(0,i.jsx)(vt,{entries:R})]})]})},pt=({delta:e,durations:t,cumulative:r})=>(0,i.jsxs)("table",{className:rt,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:ht,children:[(0,i.jsx)("th",{className:nt,children:"stage"}),(0,i.jsx)("th",{className:A,children:"time"}),(0,i.jsx)("th",{className:A,children:"Δ miss"}),(0,i.jsx)("th",{className:A,children:"Δ hit"}),(0,i.jsx)("th",{className:A,children:"total miss"}),(0,i.jsx)("th",{className:A,children:"total hit"})]})}),(0,i.jsx)("tbody",{children:h.COMPILER_STAGE_KEYS.map(n=>{const o=e?.[n],l=St(o);return(0,i.jsxs)("tr",{className:ct,children:[(0,i.jsxs)("td",{className:st,children:[(0,i.jsx)("span",{className:ge[l],"aria-hidden":!0})," ",n]}),(0,i.jsx)("td",{className:B,children:t===void 0||l==="untouched"?"—":X(t[n])}),(0,i.jsx)("td",{className:l==="ran"?se.ran:se.dim,children:o?.misses??0}),(0,i.jsx)("td",{className:B,children:o?.hits??0}),(0,i.jsx)("td",{className:B,children:r[n].misses}),(0,i.jsx)("td",{className:B,children:r[n].hits})]},n)})})]}),vt=({entries:e})=>e.length===0?null:(0,i.jsxs)("div",{className:ut,children:[(0,i.jsx)("div",{className:gt,children:"recent compiles"}),e.map(t=>{const r=yt(t.stages,l=>l.misses>0),n=h.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,i.jsxs)("div",{className:ot,children:[(0,i.jsx)("span",{className:ge[o],"aria-hidden":!0}),(0,i.jsx)("span",{className:it,title:t.label,children:t.label}),(0,i.jsxs)("span",{className:at,children:[r,"/",n," ran · ",X(t.durationMs)]})]},t.id)})]}),St=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",yt=(e,t)=>{let r=0;for(const n of h.COMPILER_STAGE_KEYS)t(e[n])&&(r+=1);return r},X=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,Gt=()=>{const{history:e}=s.useGraphContext(),{stack:t,undo:r,redo:n}=e,o=(0,u.useCallback)(d=>t.subscribe(d),[t]),l=(0,u.useCallback)(()=>t.getSnapshot(),[t]),c=(0,u.useSyncExternalStore)(o,l,l);return(0,u.useMemo)(()=>({...c,undo:r,redo:n}),[c,r,n])},bt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),Tt=(e,t={})=>{const{target:r,enabled:n=!0}=t;(0,u.useEffect)(()=>{const o=xt(r);if(!n||!o)return;const l=c=>{if(!Et(c)||c.defaultPrevented||Rt(c.target))return;const d=s.resolveHistoryStep(c);if(!d)return;const m=e.current;m&&(d==="undo"?m.undo():m.redo())&&c.preventDefault()};return o.addEventListener("keydown",l),()=>o.removeEventListener("keydown",l)},[e,r,n])},xt=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,Et=e=>"key"in e,Rt=e=>e instanceof HTMLInputElement?!bt.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1,Pt=()=>{const{targetBoundaryStore:e}=s.useGraphContext();return(0,U.useStore)(e,t=>t.boundary)};exports.CanvasTextMeasurer=s.CanvasTextMeasurer;exports.DefaultFooter=s.DefaultFooter;exports.DefaultGeomCircle=ue;exports.DefaultGeomLine=de;exports.DefaultGeomPath=he;exports.DefaultGeomRect=me;exports.DefaultGrid=s.DefaultGrid;exports.DefaultHeader=s.DefaultHeader;exports.DefaultSwatch=s.DefaultSwatch;exports.DefaultTooltip=s.DefaultTooltip;exports.DevToolsPanel=ft;exports.GRAPH_MODES=s.GRAPH_MODES;exports.GeomCircle=Ke;exports.GeomLine=Ue;exports.GeomOverpaint=s.GeomOverpaint;exports.GeomPanelSizeProvider=s.GeomPanelSizeProvider;exports.GeomPath=We;exports.GeomRect=Ve;exports.GraphErrorBoundary=oe;exports.GraphErrorPanel=W;exports.GraphProvider=ce;exports.GraphRenderer=s.GraphRenderer;exports.GraphyBadge=s.GraphyBadge;exports.HoverProvider=s.HoverProvider;exports.IntlProvider=s.ChartIntlProvider;exports.IntroFade=s.IntroFade;exports.IntroWipeClip=s.IntroWipeClip;exports.TextMeasurerProvider=s.TextMeasurerProvider;exports.ThemeProvider=s.ThemeProvider;exports.UnitBoxSvg=Ze;exports.UnitSpaceSvg=Je;exports.buildDotsEditOutlineShapes=s.buildDotsEditOutlineShapes;exports.createGraphyKit=Fe;exports.darkTheme=s.darkTheme;exports.defineGeomRenderer=s.defineGeomRenderer;exports.defineGlyph=s.defineGlyph;exports.getBuiltInEditOutlineShapes=s.getBuiltInEditOutlineShapes;exports.lightTheme=s.lightTheme;exports.lightenCss=s.lightenCss;exports.projectPointCartesian=s.projectPointCartesian;exports.pruneSelection=le;exports.readPositionPixels=k;exports.readRectPixels=ze;exports.resolveGraphyBadgeVariant=s.resolveGraphyBadgeVariant;exports.resolvePathStroke=s.resolvePathStroke;exports.scalePointToPanel=s.scalePointToPanel;exports.stampAxisEditTarget=s.stampAxisEditTarget;exports.stampGridEditTarget=s.stampGridEditTarget;exports.stampLegendEditTarget=s.stampLegendEditTarget;exports.useElementScreenRect=s.useElementScreenRect;exports.useFormattingLocale=s.useFormattingLocale;exports.useGeomHitTest=s.useGeomHitTest;exports.useGeomHover=s.useGeomHover;exports.useGeomPanelSize=s.useGeomPanelSize;exports.useGeomReaderTree=s.useGeomReaderTree;exports.useGeomStyleReader=s.useGeomStyleReader;exports.useGeomViewportSize=s.useGeomViewportSize;exports.useGraphCommands=s.useGraphCommands;exports.useGraphHandle=s.useGraphHandle;exports.useGraphHistory=Gt;exports.useGraphHistoryShortcuts=Tt;exports.useGraphLocale=s.useGraphLocale;exports.useGraphSelection=s.useGraphSelection;exports.useGuidesTakePress=s.useGuidesTakePress;exports.useHandleScene=s.useHandleScene;exports.useHoverState=s.useHoverState;exports.usePaintDefs=s.usePaintDefs;exports.useResolvedStyle=s.useResolvedStyle;exports.useSceneSelector=s.useSceneSelector;exports.useStyleReaderTree=s.useStyleReaderTree;exports.useStyleResolver=s.useStyleResolver;exports.useTargetBoundary=Pt;exports.useTextMeasurer=s.useTextMeasurer;exports.vars=s.vars;
|
package/dist/index.d.ts
CHANGED
|
@@ -857,6 +857,15 @@ export declare interface GeomCircleProps {
|
|
|
857
857
|
/** A custom geom `getEditOutlineShapes` handler's input: the observations to outline as a layer, plus `sourceLayer`. */
|
|
858
858
|
export declare type GeomEditOutlineShapesRendererInput = EditOutlineShapesInput;
|
|
859
859
|
|
|
860
|
+
/** The input a geom's {@link GeomRenderContract.hitTest} factory receives: the render input plus the panel. */
|
|
861
|
+
export declare type GeomHitTestInput<G extends GeomName | string = string, C extends CoordKind = CoordKind> = GeomRenderInput<G, C> & {
|
|
862
|
+
/**
|
|
863
|
+
* The panel's size in pixels: the data rectangle geoms paint into, already inset from axes and chrome, so marks are
|
|
864
|
+
* placed in local `0…width` / `0…height`.
|
|
865
|
+
*/
|
|
866
|
+
panelSize: BoxSize;
|
|
867
|
+
};
|
|
868
|
+
|
|
860
869
|
/** A custom geom `renderHoverCompanions` handler's input: the layer, coord system, and the primary and related hover hits. */
|
|
861
870
|
export declare type GeomHoverCompanionsRendererInput = HoverCompanionsRenderInput;
|
|
862
871
|
|
|
@@ -880,6 +889,18 @@ export declare interface GeomHoverPush {
|
|
|
880
889
|
/** A custom geom `renderHover` handler's input: the hovered layer plus the primary/group/related hover hits. */
|
|
881
890
|
export declare type GeomHoverRendererInput = HoverRenderInput;
|
|
882
891
|
|
|
892
|
+
/**
|
|
893
|
+
* The props of a geom's {@link GeomRenderContract.LayerProvider}: always the full layer, whichever subset a paint
|
|
894
|
+
* inside it receives.
|
|
895
|
+
*/
|
|
896
|
+
export declare interface GeomLayerProviderProps<G extends GeomName | string = string, C extends CoordKind = CoordKind> extends GeomRenderInputBase {
|
|
897
|
+
layer: SceneLayerOf<G>;
|
|
898
|
+
coordSystem: CoordSystemFor<C>;
|
|
899
|
+
/** The panel's size in pixels, which changes on every resize frame. */
|
|
900
|
+
panelSize: BoxSize;
|
|
901
|
+
children: ReactNode;
|
|
902
|
+
}
|
|
903
|
+
|
|
883
904
|
export declare const GeomLine: (props: GeomLineProps) => JSX.Element;
|
|
884
905
|
|
|
885
906
|
export declare interface GeomLineProps {
|
|
@@ -932,7 +953,7 @@ export declare type GeomOverlayAnchorRendererInput = OverlayAnchorInput;
|
|
|
932
953
|
* {medians}
|
|
933
954
|
* </>
|
|
934
955
|
*/
|
|
935
|
-
export declare const GeomOverpaint: (
|
|
956
|
+
export declare const GeomOverpaint: ({ styleReaders, state, children }: GeomOverpaintProps) => JSX.Element;
|
|
936
957
|
|
|
937
958
|
export declare interface GeomOverpaintProps {
|
|
938
959
|
/** The geom's readers; the overpaint is read from them. */
|
|
@@ -942,6 +963,12 @@ export declare interface GeomOverpaintProps {
|
|
|
942
963
|
children: ReactNode;
|
|
943
964
|
}
|
|
944
965
|
|
|
966
|
+
/** Holds the panel a geom layer paints in, so a theme's shape can draw in pixels what the geom placed in percent. */
|
|
967
|
+
export declare const GeomPanelSizeProvider: ({ size, children }: {
|
|
968
|
+
size: BoxSize;
|
|
969
|
+
children: ReactNode;
|
|
970
|
+
}) => JSX.Element;
|
|
971
|
+
|
|
945
972
|
export declare const GeomPath: (props: GeomPathProps) => JSX.Element;
|
|
946
973
|
|
|
947
974
|
export declare interface GeomPathProps {
|
|
@@ -1040,6 +1067,13 @@ export declare interface GeomRenderContract<G extends GeomName | string = string
|
|
|
1040
1067
|
* no overpaint.
|
|
1041
1068
|
*/
|
|
1042
1069
|
overpaintPlacement?: OverpaintPlacement;
|
|
1070
|
+
/**
|
|
1071
|
+
* Wraps a layer's {@link render}, {@link renderHighlight} and {@link renderHover} in one component, so a value they
|
|
1072
|
+
* share is computed once a layer and reaches them through its own context. It receives the panel, so a paint that
|
|
1073
|
+
* reads only the value it derives re-renders when that value changes, not on every resize.
|
|
1074
|
+
* {@link getEditOutlineShapes} runs outside it.
|
|
1075
|
+
*/
|
|
1076
|
+
LayerProvider?: (props: GeomLayerProviderProps<G, C>) => ReactNode;
|
|
1043
1077
|
/**
|
|
1044
1078
|
* The geom's paint. A plain function paints with the other geoms; the `{ fn, options: { live: true } }`
|
|
1045
1079
|
* form paints above the central capture layer for a live or drag-driven geom that owns its pointer events
|
|
@@ -1054,8 +1088,10 @@ export declare interface GeomRenderContract<G extends GeomName | string = string
|
|
|
1054
1088
|
* single-width border instead of regrouping into a standalone rounded bar.
|
|
1055
1089
|
*/
|
|
1056
1090
|
renderHighlight?: (input: HighlightRenderInput<G, C>) => ReactNode;
|
|
1057
|
-
|
|
1058
|
-
|
|
1091
|
+
/** Paints the hovered observation. Omit it for a geom with no hover paint. */
|
|
1092
|
+
renderHover?: (input: HoverRenderInput<G, C>) => ReactNode;
|
|
1093
|
+
/** Paints this layer's related observations when another layer is hovered. Omit it for a geom with none. */
|
|
1094
|
+
renderHoverCompanions?: (input: HoverCompanionsRenderInput<G, C>) => ReactNode;
|
|
1059
1095
|
/**
|
|
1060
1096
|
* Editing only: the shapes edit mode outlines for the observations in `layer`, as data in panel pixels.
|
|
1061
1097
|
* A region is what they cover, one path where there are many, with rounded corners traced into it; a line is
|
|
@@ -1067,13 +1103,13 @@ export declare interface GeomRenderContract<G extends GeomName | string = string
|
|
|
1067
1103
|
* Render-side spatial query for a `'renderHitTest'` layer whose geometry is precomputed into the
|
|
1068
1104
|
* scene (sankey ribbons, treemap tiles, voronoi cells). A
|
|
1069
1105
|
* **factory**: given the render input it returns the per-cursor {@link RenderHitTester};
|
|
1070
|
-
* the renderer memoizes the factory on `layer.data` and the panel
|
|
1106
|
+
* the renderer memoizes the factory on `layer.data` and the panel's size, so the read runs once
|
|
1071
1107
|
* per data or panel-size change and the per-move query allocates nothing. The author writes no hook;
|
|
1072
1108
|
* the renderer registers the tester on its behalf. The cursor arrives in panel-local `[0,1]` with a
|
|
1073
1109
|
* top-left origin — the frame the geom paints in. Returns the declared identity key of the observation
|
|
1074
1110
|
* under the cursor, or `null` for a miss.
|
|
1075
1111
|
*/
|
|
1076
|
-
hitTest?: (input:
|
|
1112
|
+
hitTest?: (input: GeomHitTestInput<G, C>) => RenderHitTester;
|
|
1077
1113
|
/** Panel-space anchor for a matched observation; required when the def highlights via overlay-anchor. */
|
|
1078
1114
|
getOverlayAnchor?: (input: OverlayAnchorInput<G, C>) => OverlayAnchor | null;
|
|
1079
1115
|
/**
|
|
@@ -1106,12 +1142,6 @@ declare interface GeomRenderInput<G extends GeomName | string = string, C extend
|
|
|
1106
1142
|
animateTransitions: boolean;
|
|
1107
1143
|
formattingLocale: FormattingLocale;
|
|
1108
1144
|
intro?: LayerIntroPlan | null;
|
|
1109
|
-
/**
|
|
1110
|
-
* The panel's pixel rect — the data rectangle geoms paint into, already inset from axes and chrome.
|
|
1111
|
-
* Same frame hover and highlight receive. Width and height are the paint size; x/y are already
|
|
1112
|
-
* applied by the geom-layers SVG, so marks are placed in local `0…width` / `0…height`.
|
|
1113
|
-
*/
|
|
1114
|
-
panelRect: GraphLayout['panel'];
|
|
1115
1145
|
}
|
|
1116
1146
|
|
|
1117
1147
|
/**
|
|
@@ -1611,7 +1641,6 @@ declare interface HoverRenderInput<G extends GeomName | string = string, C exten
|
|
|
1611
1641
|
primary: HoverHit;
|
|
1612
1642
|
group: HoverHit[];
|
|
1613
1643
|
related: HoverHit[];
|
|
1614
|
-
panelRect: GraphLayout['panel'];
|
|
1615
1644
|
}
|
|
1616
1645
|
|
|
1617
1646
|
declare interface HoverSlice {
|
|
@@ -1880,8 +1909,8 @@ export declare const projectPointCartesian: PointProjection;
|
|
|
1880
1909
|
export declare const pruneSelection: (selection: readonly EditTarget[], spec: ResolvedSpec) => readonly EditTarget[];
|
|
1881
1910
|
|
|
1882
1911
|
/**
|
|
1883
|
-
* A position in pixels along a
|
|
1884
|
-
* already pixels there, a percentage scales by `extent`. `null` for a non-finite number or a string that holds no
|
|
1912
|
+
* A position in pixels along a viewport `extent` pixels long, in the viewport `useGeomViewportSize` gives: a number
|
|
1913
|
+
* is already pixels there, a percentage scales by `extent`. `null` for a non-finite number or a string that holds no
|
|
1885
1914
|
* percentage.
|
|
1886
1915
|
*/
|
|
1887
1916
|
export declare const readPositionPixels: (position: ShapePosition, extent: number) => number | null;
|
|
@@ -2243,7 +2272,7 @@ export declare interface UnitBox {
|
|
|
2243
2272
|
/**
|
|
2244
2273
|
* A nested SVG over a unit-space box, placed in panel percentages, with no viewBox. Children live in the
|
|
2245
2274
|
* box's own unscaled space (`50%` is the center, a pixel radius is a pixel) and are clipped by the viewport.
|
|
2246
|
-
* A theme shape inside reads the box's pixel size from `
|
|
2275
|
+
* A theme shape inside reads the box's pixel size from `useGeomViewportSize`, since its percentages resolve against the box.
|
|
2247
2276
|
*/
|
|
2248
2277
|
export declare const UnitBoxSvg: ({ box, children }: {
|
|
2249
2278
|
box: UnitBox;
|
|
@@ -2311,13 +2340,11 @@ export declare function useGeomHitTest(layerId: string, tester: RenderHitTester)
|
|
|
2311
2340
|
export declare function useGeomHover(layerId: string): GeomHoverPush;
|
|
2312
2341
|
|
|
2313
2342
|
/**
|
|
2314
|
-
* The pixel size of the panel
|
|
2315
|
-
*
|
|
2316
|
-
*
|
|
2317
|
-
* resolve against the nearest `<svg>`. A hand-written `<svg viewBox>` declares no space, so shapes under it still read
|
|
2318
|
-
* as pixels: draw unit coordinates in a `UnitSpaceSvg`.
|
|
2343
|
+
* The pixel size of the layer's panel, for a component that paints a geom layer, which always sits inside one. A
|
|
2344
|
+
* `UnitBoxSvg` or `UnitSpaceSvg` around the component doesn't change it. Call it in the component rather than in a
|
|
2345
|
+
* paint hook, so a resize renders only the paints that read the panel.
|
|
2319
2346
|
*/
|
|
2320
|
-
export declare const useGeomPanelSize: () => BoxSize
|
|
2347
|
+
export declare const useGeomPanelSize: () => BoxSize;
|
|
2321
2348
|
|
|
2322
2349
|
/** The shared `geom` subtree. Changes to `scene.styles` preserve its identity. */
|
|
2323
2350
|
export declare const useGeomReaderTree: () => StyleReaderTree["geom"];
|
|
@@ -2333,6 +2360,15 @@ export declare const useGeomReaderTree: () => StyleReaderTree["geom"];
|
|
|
2333
2360
|
*/
|
|
2334
2361
|
export declare const useGeomStyleReader: <L extends SceneLayer>(layer: L) => StyleReadersForLayer<L>;
|
|
2335
2362
|
|
|
2363
|
+
/**
|
|
2364
|
+
* The pixel size of the viewport a shape is drawn in, for a theme shape whose drawing depends on pixels (chalk strokes a
|
|
2365
|
+
* set distance apart, a grid of typed characters). It is the panel, or the nearest `UnitBoxSvg`, since a shape's
|
|
2366
|
+
* percentages resolve against the nearest `<svg>`. `null` outside a geom layer and inside a `UnitSpaceSvg`, whose unit
|
|
2367
|
+
* coordinates no pixel size scales. A hand-written `<svg viewBox>` declares no space, so shapes under it still read
|
|
2368
|
+
* as pixels: draw unit coordinates in a `UnitSpaceSvg`.
|
|
2369
|
+
*/
|
|
2370
|
+
export declare const useGeomViewportSize: () => BoxSize | null;
|
|
2371
|
+
|
|
2336
2372
|
/**
|
|
2337
2373
|
* Returns the graph's command controls.
|
|
2338
2374
|
*
|