@graphysdk/react-renderer 1.9.0-beta.1793879014563 → 1.9.0-beta.1793882432228
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.css +1 -1
- package/dist/editable.d.ts +365 -4
- package/dist/editable.mjs +2974 -2894
- package/dist/history-chords-BorFTpAl.cjs +2 -0
- package/dist/{history-chords-BPORQs1S.js → history-chords-CimEnXtI.js} +1924 -1905
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +26 -2
- package/dist/index.mjs +504 -471
- package/package.json +4 -4
- package/dist/history-chords-BmN7fYlj.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-BmN7fYlj.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;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const s=require("./history-chords-BorFTpAl.cjs");let m=require("@graphysdk/viz-engine"),d=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 be(e=[],t=[]){return e.length===t.length&&e.every((r,n)=>Object.is(r,t[n]))}var oe=class extends d.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);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)(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,m.resolveDefinition)(e);return t instanceof m.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,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,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,m.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 a of t)a(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(u=>u.geom)]),n=[],o=new Set;for(const u of e){const h=ae(u);h===null||r.has(h.type)||o.has(h.type)||(o.add(h.type),n.push({kind:"userInput",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${h.type}' is registered but has no renderer.`,context:{requested:h.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${h.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const a=new Map;for(const u of t){if("definition"in u)continue;const h=`${u.geom}|${u.coord}`,p=a.get(h);p?p.count+=1:a.set(h,{geom:u.geom,coord:u.coord,count:1})}const l=[];for(const{geom:u,coord:h,count:p}of a.values())p<2||l.push({kind:"userInput",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${h}') (${p} entries); the last in the array wins.`,context:{requested:`${u}@${h}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${h}').`});return l.push(...Me(e)),{errors:n,warnings:l}}function Ne(e,t){const{coordSystem:r,layers:n}=e,o=new Set,a=[];for(const l of n)t(l.geom,r.type)!==null||o.has(l.geom)||(o.add(l.geom),a.push({kind:"userInput",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${l.geom}' under ${r.type} coords; the layer is not painted.`,context:{requested:l.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${l.geom}', '${r.type}') via \`defineGeomRenderer\`.`}));return a}function De(e,t){const{coordSystem:r,layers:n}=e,o=new Set,a=[];for(const l of n){if(l.interactive===!1||l.spatialKind!=="renderHitTest"||o.has(l.geom))continue;const u=t(l.geom,r.type);u===null||u.hitTest||s.isLiveRender(u)||(o.add(l.geom),a.push({kind:"userInput",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${l.geom}' declares spatialKind 'renderHitTest' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:l.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 ('${l.geom}', '${r.type}').`}))}return a}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,a=[];for(const l of n){if(l.interactive===!1||l.spatialKind!=="renderHitTest"||o.has(l.geom))continue;const u=t(l.geom,r.type);u===null||!u.hitTest||!s.isLiveRender(u)||(o.add(l.geom),a.push({kind:"userInput",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${l.geom}' declares both a \`hitTest\` factory and a live render; these are alternatives, so only the live render is used.`,context:{requested:l.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 a}function we(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 ke(e,t){const{coordSystem:r,layers:n}=e,o=new Set,a=[];for(const l of n){if(l.interactive===!1||l.spatialKind==="renderHitTest"||o.has(l.geom))continue;const u=t(l.geom,r.type);u===null||!s.isLiveRender(u)||(o.add(l.geom),a.push({kind:"userInput",severity:"warning",code:"LIVE_RENDER_REQUIRES_RENDER_HIT_TEST",message:`Geom '${l.geom}' declares a live render but its layer's spatialKind is '${l.spatialKind}', not 'renderHitTest'; its push-path hover resolves to nothing.`,context:{requested:l.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 a}function qe(e,t){let r;return e.layers.flatMap((n,o)=>s.isLiveRender(t(n.geom,e.coordSystem.type))?He(n)?(r??=(0,m.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})})),$e=({spec:e,data:t,colorScheme:r,plugins:n,theme:o,resolveRenderer:a,anchorResolver:l,onSpecChange:u,onError:h,onWarnings:p})=>{const b=s.useLatestRef(u),j=s.useLatestRef(h),T=s.useLatestRef(p),[{session:v,compileBus:g,findGeom:G}]=(0,d.useState)(()=>{const c=(0,m.createCompiler)({plugins:n,theme:o});return{session:new m.GraphCompilationSession(c),compileBus:Re(c),findGeom:f=>c.findGeom(f)}}),[S]=(0,d.useState)(()=>{const c=Z(n??[]),f=Z(o?.plugins??[]);return{errors:[...f.errors,...c.errors],warnings:[...f.warnings,...c.warnings]}}),k=(0,d.useRef)(null),[N]=(0,d.useState)(Oe),E=(0,d.useRef)(null),y=(0,d.useCallback)(c=>S.errors.length===0?c:[...S.errors,...c??[]],[S]),_=(0,d.useCallback)(c=>{if(!c.ok)return c.errors;if(E.current)E.current.getState().setScene(c.scene);else{const f=Ae(c.scene);f.subscribe(N.notify),E.current=f,N.notify()}return null},[N]),[$,P]=(0,d.useState)(()=>{const c=v.compile({spec:e,data:t,colorScheme:r});return k.current=c,y(_(c))}),C=(0,d.useCallback)(c=>c.ok?[...c.warnings,...Ne(c.scene,a),...De(c.scene,a),...Le(c.scene),..._e(c.scene,a),...ke(c.scene,a),...qe(c.scene,a),...we(c.scene,l)]:c.warnings,[a,l]),I=(0,d.useCallback)(c=>{c.length!==0&&(s.logDiagnostics(c),j.current?.(c))},[j]),x=(0,d.useCallback)(c=>{c.length!==0&&(s.logDiagnostics(c),T.current?.(c))},[T]);(0,d.useEffect)(()=>{const c=k.current;c&&(I([...S.errors,...c.ok?[]:c.errors]),x([...S.warnings,...C(c)]),c.ok&&g.emit({kind:"init"}))},[g,I,x,S,C]),(0,d.useEffect)(()=>{const c=v.update({spec:e,data:t,colorScheme:r});if(!c)return;c.committedSpec&&b.current?.(c.committedSpec);const f=_(c.result);P(y(f)),f&&I(f),x(C(c.result)),f||g.emit({kind:c.hasSpecChange?"spec":"data"})},[e,t,r,v,g,_,I,x,y,C,b]);const q=(0,d.useCallback)(c=>{P(f=>f===null?f:y(null)),x(C(c))},[y,x,C]),H=(0,d.useCallback)(c=>{c.scene&&E.current?.getState().setScene(c.scene),c.result&&q(c.result),c.command&&g.emit({kind:"command",command:c.command}),c.spec&&b.current?.(c.spec),c.errors&&I([...c.errors])},[q,g,b,I]),R=(0,d.useCallback)(c=>{for(const f of c)H(f);return c.some(f=>!!f.scene)},[H]),K=(0,d.useCallback)((c,f)=>{R(v.applyCommand(c,f))},[v,R]),O=(0,d.useCallback)(()=>{R(v.commit())},[v,R]),L=(0,d.useCallback)(()=>R(v.undo()),[v,R]),M=(0,d.useCallback)(()=>R(v.redo()),[v,R]),D=(0,d.useMemo)(()=>({stack:v.history,undo:L,redo:M}),[v,L,M]),z=(0,d.useCallback)(()=>E.current?.getState().scene??null,[]);return{store:E.current,dispatch:K,commit:O,history:D,subscribe:N.subscribe,getScene:z,compileBus:g,compileErrors:$,findGeom:G}},Oe=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},Be=["cartesian","polar"],ce=({data:e,spec:t,plugins:r=[],theme:n,glyphs:o,formattingLocale:a,handleRef:l,onSpecChange:u,onError:h,onWarnings:p,colorScheme:b="light",children:j})=>{const T=ze(a,p),[v]=(0,d.useState)(()=>n),[g]=(0,d.useState)(()=>s.mergeGlyphs(n?.glyphs,o)),G=v?.colorScheme??b,[S]=(0,d.useState)(()=>s.createGeomRendererResolver([...v?.plugins??[],...r].filter(ie)));Ke(S,g);const k=(0,d.useId)(),[N]=(0,d.useState)(()=>(0,m.createAnchorResolver)(r)),[E]=(0,d.useState)(()=>(0,m.createDataLabelPlacementResolver)(r)),[y]=(0,d.useState)(()=>Te()),[_]=(0,d.useState)(()=>s.createTargetBoundaryStore()),$=(0,d.useMemo)(()=>(0,m.createStyleResolver)({colorScheme:G}),[G]),{store:P,dispatch:C,commit:I,history:x,subscribe:q,getScene:H,compileBus:R,compileErrors:K,findGeom:O}=$e({spec:t,data:e,colorScheme:G,plugins:r,theme:v,resolveRenderer:S,anchorResolver:N,onSpecChange:u,onError:h,onWarnings:p});(0,d.useEffect)(()=>{if(P)return P.subscribe((D,z)=>{if(D.scene.spec===z.scene.spec)return;const{selection:c,setSelection:f}=y.getState();c.length!==0&&f(le(c,D.scene.spec))})},[P,y]);const L=(0,d.useMemo)(()=>({dispatch:C,commit:I}),[C,I]);(0,d.useImperativeHandle)(l,()=>({commands:L,undo:x.undo,redo:x.redo,subscribe:q,getScene:H,formattingLocale:T,getSelection:()=>y.getState().selection,setSelection:D=>y.getState().setSelection(D),subscribeSelection:y.subscribe,canPlaceDataLabels:E.hasCapability,canFormatDataLabelsAsPercentages:E.hasPercentageFormat,getGlyphs:()=>g,getPointSymbols:D=>S("point",D)?.symbols}),[L,x,q,H,T,y,E,g,S]);const M=(0,d.useMemo)(()=>P?{chartId:k,store:P,selectionStore:y,targetBoundaryStore:_,commands:L,history:x,formattingLocale:T,compileBus:R,colorScheme:G,styleResolver:$,anchorResolver:N,findGeom:O}:null,[k,P,y,_,L,x,T,R,G,$,N,O]);return(0,i.jsx)(oe,{forcedErrors:K,onError:h,resetKeys:[t,e],children:M?(0,i.jsx)(s.GraphContext.Provider,{value:M,children:(0,i.jsx)(s.GeomRendererResolverProvider,{value:S,children:(0,i.jsx)(s.DataLabelPlacementResolverProvider,{value:E,children:(0,i.jsx)(s.GeomShapesProvider,{shapes:v?.shapes,children:(0,i.jsx)(s.GlyphRegistryProvider,{glyphs:g,children:j})})})})}):null})},Fe=(e,t)=>(e??[]).filter(r=>!(0,m.isGeometricSymbol)(r)&&!t.has(r)),Ke=(e,t)=>{(0,d.useEffect)(()=>{if(!s.IS_DEV)return;const r=new Set(t.map(({name:n})=>n));for(const n of Be)for(const o of Fe(e("point",n)?.symbols,r))console.warn(`[graphy] The ${n} point renderer lists "${o}", but no glyph has that name. The shape menu offers it, and SymbolFigure draws the first listed symbol in its place.`)},[e,t])},ze=(e,t)=>{const r=s.useLatestRef(t);return(0,d.useEffect)(()=>{if(e===void 0||(0,m.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 ${m.DEFAULT_LOCALE}.`}];s.logDiagnostics(n),r.current?.(n)},[e,r]),e===void 0?void 0:(0,m.canonicalizeLocale)(e)};function Ue({theme:e,glyphs:t,...r}={}){const n=(0,m.createSpecBuilder)(r);return{...n,GraphProvider:a=>(0,i.jsx)(ce,{...a,plugins:n.plugins,theme:e,glyphs:t})}}var w=(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},Ve=({x:e,y:t,width:r,height:n},o)=>{const a=w(e,o.width),l=w(t,o.height),u=w(r,o.width),h=w(n,o.height);return a===null||l===null||u===null||h===null?null:{x:a,y:l,width:u,height:h}},ue=({animateTransitions:e,cx:t,cy:r,r:n,effects:o,...a})=>{const l=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:l,...a}):(0,i.jsx)("circle",{cx:t,cy:r,r:n,style:l,...a})},de=({animateTransitions:e,x1:t,y1:r,x2:n,y2:o,effects:a,...l})=>{const u=s.toGeomEffectsStyle(a);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:u,...l}):(0,i.jsx)("line",{x1:t,y1:r,x2:n,y2:o,style:u,...l})},me=({animateTransitions:e,x:t,y:r,width:n,height:o,rx:a,ry:l,effects:u,...h})=>{const p=s.toGeomEffectsStyle(u);return e?(0,i.jsx)(F.motion.rect,{initial:!1,animate:{attrX:t,attrY:r,width:n,height:o,...a!==void 0&&l!==void 0?{rx:a,ry:l}:{}},transition:s.DEFAULT_SPRING_TRANSITION,style:p,...h}):(0,i.jsx)("rect",{x:t,y:r,width:n,height:o,rx:a,ry:l,style:p,...h})},he=({animateTransitions:e,d:t,source:r,effects:n,...o})=>{const a=s.toGeomEffectsStyle(n);return e?(0,i.jsx)(Je,{d:t,source:r,style:a,...o}):(0,i.jsx)("path",{d:t,style:a,...o})},We=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})})},Ye=e=>{const{Line:t}=s.useGeomShapes();return t===void 0?de(e):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(t,{...e})})},Xe=({cornerRadius:e,...t})=>{const{Rect:r}=s.useGeomShapes(),n=s.useGeomViewport()?.size??null,o=s.useGeomPixelsPerUnit(),a={...t,...Ze(e,t,n,o)};return r===void 0?me(a):(0,i.jsx)(s.GeomShapesProvider,{children:(0,i.jsx)(r,{...a})})},Qe=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,Je=({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})},Ze=(e,t,r,n)=>{if(e===void 0)return{};const o=(0,m.foldGeomCornerRadii)(e);if(o===void 0)return{};const a=et(t,r,n);if(a===null)return o==="full"?{}:re((0,m.resolveGeomCornerRadiusPx)({cornerRadius:o}),n);const l=Math.min((0,m.resolveGeomCornerRadiusPx)({cornerRadius:o,box:a}),Math.min(a.width,a.height)/2);return re(l,n)},et=(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=w(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},tt=({symbol:e,size:t,fill:r,fillOpacity:n,stroke:o,strokeOpacity:a,strokeWidth:l})=>{const u=s.useGlyphRegistry(),h=s.useGeomRendererResolver(),p=s.useSceneSelector(T=>T.coordSystem.type),b=rt(e,h("point",p)?.symbols??[],u),j={size:t,fill:r,fillOpacity:n,stroke:o,strokeOpacity:a,strokeWidth:l};return(0,m.isGeometricSymbol)(b)?(0,i.jsx)("path",{d:(0,m.buildPointSymbolPath)(b,t),fill:r,fillOpacity:n,stroke:o,strokeOpacity:a,strokeWidth:l,strokeLinejoin:"round"}):(0,i.jsx)(s.GlyphMark,{symbol:b,glyphs:u,...j})},rt=(e,t,r)=>(0,m.isImageSymbol)(e)||t.includes(e)||!(0,m.isGeometricSymbol)(e)&&r.has(e)?e:t[0]??"circle",nt=({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})})},st=({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),a=(0,d.useMemo)(()=>n===null||o===null?null:{width:n,height:o},[n,o]);return(0,i.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:(0,i.jsx)(s.GeomViewportProvider,{size:a,children:t})})},ot="drqe3u0",it="drqe3u1",at="drqe3u2",lt="drqe3u3",A="drqe3u4",ct="drqe3u5",ut="drqe3u6",dt="drqe3u7",B="drqe3u8",mt="drqe3u9",ht="drqe3ua";var gt="drqe3uc",ft="drqe3ud",pt="drqe3ue",vt="drqe3uf";var St="drqe3uh",yt="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"},bt=({width:e=440,style:t,className:r}={})=>{const{compileBus:n}=s.useGraphContext(),[o]=(0,d.useState)(()=>Pe()),[a,l]=(0,d.useState)(!1),[u,h]=(0,d.useState)(m.isCompilerCachingEnabled);(0,d.useEffect)(()=>{const{recordCompile:g}=o.getState(),G=n.getLastTrigger(),S=n.getLastCompile();return G&&S&&g(G,S),n.subscribe(g)},[o,n]);const p=(0,U.useStore)(o,g=>g.lastCompile),b=(0,U.useStore)(o,g=>g.history),j=n.getCacheStats(),T=p===null&&b.length===0,v=()=>{h(g=>{const G=!g;return(0,m.setCompilerCachingEnabled)(G),G})};return(0,i.jsxs)("div",{className:(0,V.default)(ht,r),style:{width:e,...t},children:[(0,i.jsxs)("div",{className:ot,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:it,children:"compile cache"}),(0,i.jsx)("div",{className:pt,children:T?"production: stats disabled":p?`last: ${p.label} · ${X(p.durationMs)}`:"awaiting first compile…"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>l(g=>!g),className:vt,children:a?"▾":"▴"})]}),!a&&(0,i.jsxs)("div",{className:"drqe3ub",children:[(0,i.jsxs)("button",{type:"button",onClick:v,className:u?ne.enabled:ne.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,i.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!a&&!T&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Gt,{delta:p?.stages,durations:p?.stageDurationsMs,cumulative:j}),(0,i.jsx)(Tt,{entries:b})]})]})},Gt=({delta:e,durations:t,cumulative:r})=>(0,i.jsxs)("table",{className:at,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:St,children:[(0,i.jsx)("th",{className:lt,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:m.COMPILER_STAGE_KEYS.map(n=>{const o=e?.[n],a=xt(o);return(0,i.jsxs)("tr",{className:gt,children:[(0,i.jsxs)("td",{className:ct,children:[(0,i.jsx)("span",{className:ge[a],"aria-hidden":!0})," ",n]}),(0,i.jsx)("td",{className:B,children:t===void 0||a==="untouched"?"—":X(t[n])}),(0,i.jsx)("td",{className:a==="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)})})]}),Tt=({entries:e})=>e.length===0?null:(0,i.jsxs)("div",{className:ft,children:[(0,i.jsx)("div",{className:yt,children:"recent compiles"}),e.map(t=>{const r=Et(t.stages,a=>a.misses>0),n=m.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,i.jsxs)("div",{className:ut,children:[(0,i.jsx)("span",{className:ge[o],"aria-hidden":!0}),(0,i.jsx)("span",{className:dt,title:t.label,children:t.label}),(0,i.jsxs)("span",{className:mt,children:[r,"/",n," ran · ",X(t.durationMs)]})]},t.id)})]}),xt=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",Et=(e,t)=>{let r=0;for(const n of m.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`,Rt=()=>{const{history:e}=s.useGraphContext(),{stack:t,undo:r,redo:n}=e,o=(0,d.useCallback)(u=>t.subscribe(u),[t]),a=(0,d.useCallback)(()=>t.getSnapshot(),[t]),l=(0,d.useSyncExternalStore)(o,a,a);return(0,d.useMemo)(()=>({...l,undo:r,redo:n}),[l,r,n])},Pt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),Ct=(e,t={})=>{const{target:r,enabled:n=!0}=t;(0,d.useEffect)(()=>{const o=It(r);if(!n||!o)return;const a=l=>{if(!jt(l)||l.defaultPrevented||Nt(l.target))return;const u=s.resolveHistoryStep(l);if(!u)return;const h=e.current;h&&(u==="undo"?h.undo():h.redo())&&l.preventDefault()};return o.addEventListener("keydown",a),()=>o.removeEventListener("keydown",a)},[e,r,n])},It=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,jt=e=>"key"in e,Nt=e=>e instanceof HTMLInputElement?!Pt.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1,Dt=()=>{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=bt;exports.GRAPH_MODES=s.GRAPH_MODES;exports.GeomCircle=We;exports.GeomLine=Ye;exports.GeomOverpaint=s.GeomOverpaint;exports.GeomPanelSizeProvider=s.GeomPanelSizeProvider;exports.GeomPath=Qe;exports.GeomRect=Xe;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.SymbolFigure=tt;exports.TextMeasurerProvider=s.TextMeasurerProvider;exports.ThemeProvider=s.ThemeProvider;exports.UnitBoxSvg=st;exports.UnitSpaceSvg=nt;exports.buildDotsEditOutlineShapes=s.buildDotsEditOutlineShapes;exports.createGraphyKit=Ue;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=w;exports.readRectPixels=Ve;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=Rt;exports.useGraphHistoryShortcuts=Ct;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=Dt;exports.useTextMeasurer=s.useTextMeasurer;exports.vars=s.vars;
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ import { SourceContent } from '@graphysdk/viz-engine';
|
|
|
63
63
|
import { Spec } from '@graphysdk/viz-engine';
|
|
64
64
|
import { SpecBuilder } from '@graphysdk/viz-engine';
|
|
65
65
|
import { StoreApi } from 'zustand';
|
|
66
|
+
import { StyleImageSymbol } from '@graphysdk/viz-engine';
|
|
66
67
|
import { StyleLineCap } from '@graphysdk/viz-engine';
|
|
67
68
|
import { StylePointSymbol } from '@graphysdk/viz-engine';
|
|
68
69
|
import { StyleReadersForLayer } from '@graphysdk/viz-engine';
|
|
@@ -695,6 +696,8 @@ declare interface EditOutlineShapesInput<G extends GeomName | string = string, C
|
|
|
695
696
|
styleReaders: StyleReadersOf<G>;
|
|
696
697
|
/** Whether the chart animates transitions, for a shape to copy where the geom's paint springs. */
|
|
697
698
|
animateTransitions: boolean;
|
|
699
|
+
/** The outlined layer's renderer's {@link GeomRenderContract.symbols}, so a point outline traces only what it draws. */
|
|
700
|
+
symbols?: readonly PointSymbolName[];
|
|
698
701
|
}
|
|
699
702
|
|
|
700
703
|
/** A stroke, which the outline grows from either side of its thickness. */
|
|
@@ -1067,6 +1070,13 @@ export declare interface GeomRenderContract<G extends GeomName | string = string
|
|
|
1067
1070
|
* no overpaint.
|
|
1068
1071
|
*/
|
|
1069
1072
|
overpaintPlacement?: OverpaintPlacement;
|
|
1073
|
+
/**
|
|
1074
|
+
* Every point symbol the paint draws, built-in shapes and glyph names, in the order Point shape offers them. A list
|
|
1075
|
+
* also says the paint draws the host's glyphs and uploaded images, as `SymbolFigure` does; any other symbol is drawn
|
|
1076
|
+
* as the first listed. The edit outline traces the listed built-in shapes. Omit it or leave it empty for a circle
|
|
1077
|
+
* alone.
|
|
1078
|
+
*/
|
|
1079
|
+
symbols?: readonly PointSymbolName[];
|
|
1070
1080
|
/**
|
|
1071
1081
|
* Wraps a layer's {@link render}, {@link renderHighlight} and {@link renderHover} in one component, so a value they
|
|
1072
1082
|
* share is computed once a layer and reaches them through its own context. It receives the panel, so a paint that
|
|
@@ -1355,6 +1365,8 @@ export declare interface GraphHandle {
|
|
|
1355
1365
|
canFormatDataLabelsAsPercentages: (layer: SceneLayer, coordType: CoordSystem['type']) => boolean;
|
|
1356
1366
|
/** Glyphs mounted with this graph. A panel reads these from the handle it targets. */
|
|
1357
1367
|
getGlyphs: () => readonly GlyphDefinition[];
|
|
1368
|
+
/** What the point renderer under these coords draws, per the plugins the graph was built with. */
|
|
1369
|
+
getPointSymbols: (coordType: CoordSystem['type']) => GeomRenderContract['symbols'];
|
|
1358
1370
|
}
|
|
1359
1371
|
|
|
1360
1372
|
/** Undo/redo controls plus the command stack's own snapshot, which a history UI reads. */
|
|
@@ -1412,8 +1424,8 @@ export declare interface GraphProviderProps {
|
|
|
1412
1424
|
*/
|
|
1413
1425
|
glyphs?: readonly GlyphDefinition[];
|
|
1414
1426
|
/**
|
|
1415
|
-
* Formats numbers and dates for display: any BCP-47 tag (`it-IT`). A tag `Intl` cannot read formats as `en-
|
|
1416
|
-
* reports `INVALID_FORMATTING_LOCALE`. Graphy's own texts use the built-in dictionary for its language, else `en-
|
|
1427
|
+
* Formats numbers and dates for display: any BCP-47 tag (`it-IT`). A tag `Intl` cannot read formats as `en-US` and
|
|
1428
|
+
* reports `INVALID_FORMATTING_LOCALE`. Graphy's own texts use the built-in dictionary for its language, else `en-US`.
|
|
1417
1429
|
*/
|
|
1418
1430
|
formattingLocale?: FormattingLocale;
|
|
1419
1431
|
/**
|
|
@@ -1895,6 +1907,9 @@ declare type PhraseSource = Partial<Record<I18nLocale, object>>;
|
|
|
1895
1907
|
*/
|
|
1896
1908
|
declare type PointProjection = (x: number, y: number) => XYPoint;
|
|
1897
1909
|
|
|
1910
|
+
/** A point symbol a renderer can list by name: a built-in shape or a registered glyph's name. */
|
|
1911
|
+
export declare type PointSymbolName = Exclude<StylePointSymbol, StyleImageSymbol>;
|
|
1912
|
+
|
|
1898
1913
|
/** Cartesian: normalized data-space `[0,1]` into panel view-box coords (formatted to percent at paint). */
|
|
1899
1914
|
export declare const projectPointCartesian: PointProjection;
|
|
1900
1915
|
|
|
@@ -2133,6 +2148,15 @@ export declare interface SwatchSlotProps {
|
|
|
2133
2148
|
/** The UI surface a swatch is painted on. Lets a Swatch slot restyle one surface and delegate the rest. */
|
|
2134
2149
|
export declare type SwatchSurface = 'legend' | 'tooltip' | 'headline' | 'callout' | 'ruleLabel';
|
|
2135
2150
|
|
|
2151
|
+
/**
|
|
2152
|
+
* Any point symbol centered on the origin: a built-in shape, a registered glyph or an image. A symbol the chart's
|
|
2153
|
+
* point renderer does not list, and that is neither a registered glyph nor an image, is drawn as the first listed, as
|
|
2154
|
+
* the editor offers it.
|
|
2155
|
+
*/
|
|
2156
|
+
export declare const SymbolFigure: ({ symbol, size, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, }: GlyphPaint & {
|
|
2157
|
+
symbol: StylePointSymbol;
|
|
2158
|
+
}) => JSX.Element;
|
|
2159
|
+
|
|
2136
2160
|
/** The target boundary: the one box round the selected target, which a menu is placed beside. */
|
|
2137
2161
|
export declare interface TargetBoundary {
|
|
2138
2162
|
/** The box in pixels from the chart frame's top left, at the chart's own layout scale. */
|