@graphysdk/react-renderer 1.9.0-beta.1790343746744 → 1.9.0-beta.1790362479393
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 +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{use-target-boundary-BGoL081C.js → use-target-boundary-AyGM1lRB.js} +2695 -2652
- package/dist/use-target-boundary-Db66YmHM.cjs +2 -0
- package/dist/use-target-boundary.css +1 -1
- package/package.json +2 -2
- package/dist/use-target-boundary-Cg1rAeMM.cjs +0 -2
package/dist/editable.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as ct, A as dt, Bt as Yo, C as Jo, Ct as de, D as Qo, Dt as j, E as Ce, Et as Ge, F as ei, G as $, Gt as ti, H as ni, I as k, It as ri, J as V, Jt as ai, K as oi, Kt as ii, Lt as Ir, O as li, Ot as si, P as ci, Q as Zt, Qt as Ne, S as di, St as ui, U as hi, W as X, Wt as pi, X as jt, Xt as Er, Y as Yt, Z as Or, Zt as Jt, _ as Mr, a as mi, at as gi, b as vi, bt as fi, cn as Q, ct as re, d as bi, en as yi, et as Si, f as Ci, fn as F, g as Qt, gt as xi, h as wi, ht as E, i as W, it as Ai, k as Nr, kt as Ti, l as Rr, m as Dr, mt as ki, n as Li, nt as Pi, on as _r, ot as An, p as Ii, pt as Ei, q as Tn, qt as Oi, r as ue, rn as Mi, s as Ni, st as Ri, t as Di, tn as _i, tt as zr, u as zi, un as _, ut as en, v as Le, vt as Pe, w as Fi, x as Fr, xt as Bi, y as Hi, z as Gi } from "./use-target-boundary-
|
|
1
|
+
import { $ as ct, A as dt, Bt as Yo, C as Jo, Ct as de, D as Qo, Dt as j, E as Ce, Et as Ge, F as ei, G as $, Gt as ti, H as ni, I as k, It as ri, J as V, Jt as ai, K as oi, Kt as ii, Lt as Ir, O as li, Ot as si, P as ci, Q as Zt, Qt as Ne, S as di, St as ui, U as hi, W as X, Wt as pi, X as jt, Xt as Er, Y as Yt, Z as Or, Zt as Jt, _ as Mr, a as mi, at as gi, b as vi, bt as fi, cn as Q, ct as re, d as bi, en as yi, et as Si, f as Ci, fn as F, g as Qt, gt as xi, h as wi, ht as E, i as W, it as Ai, k as Nr, kt as Ti, l as Rr, m as Dr, mt as ki, n as Li, nt as Pi, on as _r, ot as An, p as Ii, pt as Ei, q as Tn, qt as Oi, r as ue, rn as Mi, s as Ni, st as Ri, t as Di, tn as _i, tt as zr, u as zi, un as _, ut as en, v as Le, vt as Pe, w as Fi, x as Fr, xt as Bi, y as Hi, z as Gi } from "./use-target-boundary-AyGM1lRB.js";
|
|
2
2
|
import { n as pe, t as Br } from "./theme.contract.css-AyXDNf0F.js";
|
|
3
3
|
import { ARROW_DEFAULTS as Vi, ARROW_STICKER_DECLARATIONS as $i, ARROW_STROKE_WIDTHS_PX as Tt, AddAnnotationCommand as fe, AddHighlightCommand as Wi, BORDER_RADIUS_TOKENS as kn, COMBO_TYPES as Ln, CONSTANT_VARIABLES as Ui, DASH_PRESETS as Ki, DEFAULT_BAR_CORNER_RADIUS as qi, DEFAULT_GEOM_COLOR as Xi, DEFAULT_POINT_SIZE_PX as Zi, DEFAULT_STROKE_WIDTH_PX as ji, DIFFERENCE_ARROW_DEFAULTS as Hr, DIFFERENCE_ARROW_SIZE_DECLARATIONS as Pn, InternalError as Yi, MAX_BAR_WIDTH_FRACTION as Ji, MIN_BAR_WIDTH_FRACTION as Qi, MoveAnnotationCommand as el, RESTING_HOVER_STATE as tn, RemoveAnnotationCommand as _e, RemoveHighlightCommand as tl, SHAPE_DEFAULTS as nl, SetAxisLabelCommand as rl, SetAxisPositionCommand as al, SetAxisTickModeCommand as ol, SetAxisTicksVisibilityCommand as il, SetAxisVisibilityCommand as ll, SetBarCornerRadiusCommand as sl, SetBarWidthCommand as cl, SetChartTypeCommand as Gr, SetContentCaptionCommand as Vr, SetContentSourceCommand as dl, SetContentSubtitleCommand as $r, SetContentTitleCommand as Wr, SetDataLabelsFormatCommand as ul, SetDifferenceArrowStyleCommand as hl, SetGridLineStyleCommand as pl, SetGridLineWidthCommand as ml, SetGridVisibilityCommand as gl, SetHeadlineCompareWithCommand as vl, SetHeadlinePositionCommand as fl, SetHeadlineShowCommand as In, SetHeadlineSizeCommand as bl, SetHighlightDimStyleCommand as yl, SetLayerYScaleTypeCommand as Sl, SetLegendAlignCommand as Cl, SetLegendDisplayCommand as xl, SetLegendPositionCommand as wl, SetLineCurveCommand as Al, SetLineMissingValuesCommand as Tl, SetLineWidthCommand as En, SetMappingCommand as kl, SetNumberFormatAbbreviationCommand as Ll, SetNumberFormatDecimalsCommand as On, SetPointSizeCommand as Pl, SetPolarInnerRadiusCommand as Il, SetPolarStartAngleCommand as El, SetRuleLabelCommand as Ol, SetRuleValueCommand as Ml, SetScaleDomainCommand as kt, SetScaleReverseCommand as Nl, SetScaleTransformCommand as Rl, SetStatLineCommand as Dl, SetStyleRuleCommand as Ae, TEXT_ANNOTATION_DEFAULTS as _l, TEXT_ANNOTATION_FADE_ALPHA as zl, ToggleCategoryLabelsCommand as Fl, ToggleContentVisibilityCommand as ut, ToggleDataLabelsCommand as Bl, ToggleGoalLineCommand as Hl, ToggleLineFillCommand as Gl, ToggleLinePointsCommand as Vl, ToggleStackTotalsCommand as $l, UpdateAnnotationCommand as ie, alignUnitFractions as Wl, areAnchorsEqual as Ur, areEditTargetsEqual as Ul, areEndpointsComparable as Kl, buildEditMenuTriggerRegion as ql, buildLayerStyleAddress as Xl, buildObservationPredicate as Zl, buildObservationsTarget as nn, buildObservationsTargetAtValue as Kr, canAnchorDirectLabels as jl, canBecomeCombo as Yl, canBecomeHeatmap as Jl, clampAnnotationTranslation as Ql, computeArrow as qr, createObservationAnchorBuilder as es, createObservationAnchorParser as ts, createStyleResolver as ns, createValueFormatter as rs, filterLayersByGeoms as Mt, findAnnotation as as, findAverageLineLayer as os, findCompanionLayers as Xr, findGoalLineLayer as is, findHighlightsAtObservation as ls, findKindStyleDeclarations as ss, findLayerByGeom as Zr, findLayerById as ye, findObservationAttachment as cs, findStyleRule as Se, findTrendLineLayer as ds, formatDifferenceLabel as us, getBoundingRect as Nt, getX as hs, getY as ps, hasMultipleGroups as ms, inferDefaultDifferenceArrowEndpoints as gs, inferDifferenceArrowEndpoints as vs, isComboChartType as we, isCompanionLayer as jr, isObservationAttachmentKind as fs, isPointWithinEditMenuTrigger as rn, isSafeUrl as bs, isZeroAnchoredAxis as ys, measureObservationsBoxes as Yr, projectAnchorToPanel as et, readBroadestObservationsScope as Ss, readChartType as Jr, readComboLineLayerId as Cs, readCompanionRowsAtScopeKey as xs, readConstantValue as ws, readEditTargetKey as an, readGeomColor as As, readHighlightDimStyle as Ts, readMainAxis as ks, readMappableAesthetics as Ls, readMappedVariable as Ps, readObservationIndex as Qr, readRowScopeKey as Is, readRowsAtScopeKey as Es, readScopeXVariable as Os, readVariableName as ea, resolveArrowAnnotationStyle as on, resolveBarBandFraction as Ms, resolveComparisonBasis as Ns, resolveDifferenceArrowAnnotationStyle as Rs, resolveEditOutlineStyle as Ds, resolveObservationPoint as ta, resolveObservationsTarget as Mn, stepDifferenceArrowEndpoint as _s, toDashPreset as Rt, toPaintColor as tt, toPanelCursor as ht } from "@graphysdk/viz-engine";
|
|
4
4
|
import { createContext as Ve, memo as na, useCallback as ae, useContext as ze, useEffect as z, useId as Te, useLayoutEffect as ke, useMemo as I, useRef as ne, useState as ee } from "react";
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const o=require("./use-target-boundary-Cg1rAeMM.cjs"),oe=require("./theme.contract.css-DKDKSByt.cjs");let h=require("@graphysdk/viz-engine"),d=require("react"),i=require("react/jsx-runtime"),U=require("zustand"),X=require("motion/react"),O=require("zustand/vanilla"),A=require("clsx");A=o.__toESM(A,1);var ae="_1a5iqpb0",ie="_1a5iqpb1";var ce="_1a5iqpb3",le="_1a5iqpb4",de="_1a5iqpb5";var B=({errors:e})=>{const[t,...s]=e;return(0,i.jsxs)("div",{role:"alert",className:ae,children:[(0,i.jsx)("strong",{className:ie,children:"This chart could not be rendered."}),t&&(0,i.jsx)(Y,{diagnostic:t}),s.length>0&&(0,i.jsx)("ul",{className:"_1a5iqpb2",children:s.map((r,n)=>(0,i.jsx)("li",{children:(0,i.jsx)(Y,{diagnostic:r})},`${r.code}-${n}`))})]})},Y=({diagnostic:e})=>(0,i.jsxs)("div",{className:ce,children:[(0,i.jsx)("span",{className:le,children:e.code}),(0,i.jsx)("p",{className:de,children:e.message}),e.suggestion&&(0,i.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function ue(e=[],t=[]){return e.length===t.length&&e.every((s,r)=>Object.is(s,t[r]))}var Q=class extends d.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,h.buildDiagnostic)(e)}}componentDidCatch(e,t){const s=(0,h.buildDiagnostic)(e);o.logDiagnostics([s]),this.props.onError?.([s]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!ue(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,i.jsx)(B,{errors:[e]});const{forcedErrors:t,children:s}=this.props;return t&&t.length>0?(0,i.jsx)(B,{errors:t}):s}},J=e=>typeof e=="object"&&"geom"in e&&"render"in e,Z=e=>{const t=(0,h.resolveDefinition)(e);return t instanceof h.Geom?t:null},ee=(e,t)=>{const s=e.filter(r=>me(r,t));return s.length===e.length?e:s},me=(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,W=[],ge=()=>(0,O.createStore)(e=>({selection:W,setSelection:t=>e(s=>he(s.selection,t)?s:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:W})})),he=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((s,r)=>{const n=t[r];return n!==void 0&&(0,h.areEditTargetsEqual)(s,n)}),pe=process.env.NODE_ENV!=="production",fe=5,ve=e=>{if(!pe)return{emit:()=>{},subscribe:()=>Se,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let s=null;return{emit:r=>{const n=e.getLastCompile();if(n){s=r;for(const l of t)l(r,n)}},subscribe:r=>(t.add(r),()=>{t.delete(r)}),getLastTrigger:()=>s,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},ye=()=>(0,O.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,s)=>e(r=>{if(r.lastSnapshot===s)return r;const n={id:r.nextId,label:be(t),stages:s.stages,stageDurationsMs:s.stageDurationsMs,durationMs:s.durationMs};return{lastCompile:n,history:Ee(r.history,n,fe),nextId:r.nextId+1,lastSnapshot:s}})})),Se=()=>{},be=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}},Ee=(e,t,s)=>{const r=e.length>=s?e.length-(s-1):0;return[...e.slice(r),t]};function Te(e){const t=e.filter(J),s=new Set([...Object.keys(o.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),r=[],n=new Set;for(const u of e){const m=Z(u);m===null||s.has(m.type)||n.has(m.type)||(n.add(m.type),r.push({kind:"user-input",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 u of t){if("definition"in u)continue;const m=`${u.geom}|${u.coord}`,f=l.get(m);f?f.count+=1:l.set(m,{geom:u.geom,coord:u.coord,count:1})}const c=[];for(const{geom:u,coord:m,count:f}of l.values())f<2||c.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${m}') (${f} entries); the last in the array wins.`,context:{requested:`${u}@${m}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${m}').`});return c.push(...je(e)),{errors:r,warnings:c}}function xe(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r)t(c.geom,s.type)!==null||n.has(c.geom)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${c.geom}' under ${s.type} coords; the layer is not painted.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${c.geom}', '${s.type}') via \`defineGeomRenderer\`.`}));return l}function Ce(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||u.hitTest||o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Add a \`hitTest\` factory (precomputed geometry) or an overlay render (\`{ fn, options: { overlay: true } }\`, live simulation) to the renderer for ('${c.geom}', '${s.type}').`}))}return l}function Re(e){const t=new Set,s=[];for(const r of e.layers){const n=r.identityKey;r.interactive!==!1&&(r.spatialKind!=="render-hit-test"||typeof n!="object"||t.has(r.geom)||r.data.hasVariable(n.variable)||(t.add(r.geom),s.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${r.geom}' keys its identity on '${n.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:r.geom,kind:"geom-renderer"},suggestion:`Emit the '${n.variable}' column from the geom's \`compile()\`, or point \`identityKey\` at a column it does emit.`})))}return s}function Ge(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!u.hitTest||!o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR an overlay render (`{ fn, options: { overlay: true } }`) for a live simulation."}))}return l}function Ne(e,t){const s=new Set,r=[];for(const n of e.layers)n.interactive!==!1&&(n.spatialKind!=="render-hit-test"||s.has(n.geom)||t.hasCapability(n.geom)||(s.add(n.geom),r.push({kind:"user-input",severity:"warning",code:"MISSING_ANCHOR_CAPABILITY",message:`Geom '${n.geom}' declares no \`resolveAnchorPosition\`; its observations cannot be annotated, so the editor overlay paints no creation trigger on them.`,context:{requested:n.geom,kind:"geom-renderer"},suggestion:"Implement `resolveAnchorPosition(observation, context)` on the geom, returning the normalised panel position an annotation on that observation belongs at."})));return r}function _e(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind==="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares an overlay render but its layer's spatialKind is '${c.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the scene layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return l}function je(e){const t=new Set,s=[];for(const r of e){const n=Z(r);n===null||t.has(n.type)||n.dataLabelCoordTypes.length===0||n.getDataLabelPlacements!==void 0||(t.add(n.type),s.push({kind:"user-input",severity:"warning",code:"MISSING_DATA_LABEL_PLACEMENT",message:`Geom '${n.type}' declares \`dataLabelCoordTypes\` but implements no \`getDataLabelPlacements\`; its layers paint no data labels.`,context:{requested:n.type,kind:"geom-renderer"},suggestion:"Implement `getDataLabelPlacements(context)` on the geom, or drop `dataLabelCoordTypes` so the compiler warns the author off the flag."}))}return s}var qe=e=>(0,O.createStore)(t=>({scene:e,setScene:s=>t(r=>r.scene===s?r:{scene:s})})),ke=({spec:e,data:t,customPalettes:s,colorScheme:r,plugins:n,resolveRenderer:l,anchorResolver:c,onSpecChange:u,onError:m,onWarnings:f})=>{const E=o.useLatestRef(u),_=o.useLatestRef(m),C=o.useLatestRef(f),[{session:v,compileBus:g}]=(0,d.useState)(()=>{const a=(0,h.createCompiler)({plugins:n});return{session:new h.GraphCompilationSession(a),compileBus:ve(a)}}),[p]=(0,d.useState)(()=>Te(n??[])),R=(0,d.useRef)(null),[j]=(0,d.useState)(De),S=(0,d.useRef)(null),G=(0,d.useCallback)(a=>p.errors.length===0?a:[...p.errors,...a??[]],[p]),D=(0,d.useCallback)(a=>{if(!a.ok)return a.errors;if(S.current)S.current.getState().setScene(a.scene);else{const y=qe(a.scene);y.subscribe(j.notify),S.current=y,j.notify()}return null},[j]),[q,I]=(0,d.useState)(()=>{const a=v.compile({spec:e,data:t,customPalettes:s,colorScheme:r});return R.current=a,G(D(a))}),T=(0,d.useCallback)(a=>a.ok?[...a.warnings,...xe(a.scene,l),...Ce(a.scene,l),...Re(a.scene),...Ge(a.scene,l),..._e(a.scene,l),...Ne(a.scene,c)]:a.warnings,[l,c]),x=(0,d.useCallback)(a=>{a.length!==0&&(o.logDiagnostics(a),_.current?.(a))},[_]),N=(0,d.useCallback)(a=>{a.length!==0&&(o.logDiagnostics(a),C.current?.(a))},[C]);(0,d.useEffect)(()=>{const a=R.current;a&&(x([...p.errors,...a.ok?[]:a.errors]),N([...p.warnings,...T(a)]),a.ok&&g.emit({kind:"init"}))},[g,x,N,p,T]),(0,d.useEffect)(()=>{const a=v.update({spec:e,data:t,customPalettes:s,colorScheme:r});if(!a)return;a.committedSpec&&E.current?.(a.committedSpec);const y=D(a.result);I(G(y)),y&&x(y),N(T(a.result)),y||g.emit({kind:a.specChanged?"spec":"data"})},[e,t,s,r,v,g,D,x,N,G,T,E]);const k=(0,d.useCallback)(a=>{I(y=>y===null?y:G(null)),N(T(a))},[G,N,T]),P=(0,d.useCallback)(a=>{a.scene&&S.current?.getState().setScene(a.scene),a.result&&k(a.result),a.command&&g.emit({kind:"command",command:a.command}),a.spec&&E.current?.(a.spec),a.errors&&x([...a.errors])},[k,g,E,x]),b=(0,d.useCallback)(a=>{for(const y of a)P(y);return a.some(y=>!!y.scene)},[P]),$=(0,d.useCallback)((a,y)=>{b(v.applyCommand(a,y))},[v,b]),L=(0,d.useCallback)(()=>{b(v.commit())},[v,b]),M=(0,d.useCallback)(()=>b(v.undo()),[v,b]),F=(0,d.useCallback)(()=>b(v.redo()),[v,b]),se=(0,d.useMemo)(()=>({stack:v.history,undo:M,redo:F}),[v,M,F]),ne=(0,d.useCallback)(()=>S.current?.getState().scene??null,[]);return{store:S.current,dispatch:$,commit:L,history:se,subscribe:j.subscribe,getScene:ne,compileBus:g,compileErrors:q}},De=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},te=({data:e,spec:t,plugins:s=[],formattingLocale:r,handleRef:n,onSpecChange:l,onError:c,onWarnings:u,customPalettes:m,colorScheme:f="light",children:E})=>{const[_]=(0,d.useState)(()=>o.createGeomRendererResolver(s.filter(J))),C=(0,d.useId)(),[v]=(0,d.useState)(()=>(0,h.createAnchorResolver)(s)),[g]=(0,d.useState)(()=>(0,h.createDataLabelPlacementResolver)(s)),[p]=(0,d.useState)(()=>ge()),[R]=(0,d.useState)(()=>o.createTargetBoundaryStore()),j=(0,d.useMemo)(()=>(0,h.createStyleResolver)({colorScheme:f}),[f]),{store:S,dispatch:G,commit:D,history:q,subscribe:I,getScene:T,compileBus:x,compileErrors:N}=ke({spec:t,data:e,customPalettes:m,colorScheme:f,plugins:s,resolveRenderer:_,anchorResolver:v,onSpecChange:l,onError:c,onWarnings:u});(0,d.useEffect)(()=>{if(S)return S.subscribe((b,$)=>{if(b.scene.spec===$.scene.spec)return;const{selection:L,setSelection:M}=p.getState();L.length!==0&&M(ee(L,b.scene.spec))})},[S,p]);const k=(0,d.useMemo)(()=>({dispatch:G,commit:D}),[G,D]);(0,d.useImperativeHandle)(n,()=>({commands:k,undo:q.undo,redo:q.redo,subscribe:I,getScene:T,getSelection:()=>p.getState().selection,setSelection:b=>p.getState().setSelection(b),subscribeSelection:p.subscribe,canPlaceDataLabels:g.hasCapability,canFormatDataLabelsAsPercentages:g.hasPercentageFormat}),[k,q,I,T,p,g]);const P=(0,d.useMemo)(()=>S?{chartId:C,store:S,selectionStore:p,targetBoundaryStore:R,commands:k,history:q,formattingLocale:r,compileBus:x,colorScheme:f,styleResolver:j,anchorResolver:v}:null,[C,S,p,R,k,q,r,x,f,j,v]);return(0,i.jsx)(Q,{forcedErrors:N,onError:c,resetKeys:[t,e],children:P?(0,i.jsx)(o.GraphContext.Provider,{value:P,children:(0,i.jsx)(o.GeomRendererResolverProvider,{value:_,children:(0,i.jsx)(o.DataLabelPlacementResolverProvider,{value:g,children:E})})}):null})};function Ie(e){const t=(0,h.createSpecBuilder)(e);return{...t,GraphProvider:r=>(0,i.jsx)(te,{...r,plugins:t.plugins})}}var Pe=({shouldAnimateTransitions:e,cx:t,cy:s,r,...n})=>e?(0,i.jsx)(X.motion.circle,{initial:!1,animate:{cx:t,cy:s,r},transition:o.DEFAULT_SPRING_TRANSITION,...n}):(0,i.jsx)("circle",{cx:t,cy:s,r,...n}),we=({shouldAnimateTransitions:e,x1:t,y1:s,x2:r,y2:n,...l})=>e?(0,i.jsx)(X.motion.line,{initial:!1,animate:{x1:t,y1:s,x2:r,y2:n},transition:o.DEFAULT_SPRING_TRANSITION,...l}):(0,i.jsx)("line",{x1:t,y1:s,x2:r,y2:n,...l}),Le=({children:e,...t})=>(0,i.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),Me=({box:e,children:t})=>(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:t}),He="drqe3u0",$e="drqe3u1",Ae="drqe3u2",Be="drqe3u3",w="drqe3u4",Oe="drqe3u5",Ke="drqe3u6",Fe="drqe3u7",H="drqe3u8",Ue="drqe3u9",Ye="drqe3ua";var We="drqe3uc",Ve="drqe3ud",ze="drqe3ue",Xe="drqe3uf";var Qe="drqe3uh",Je="drqe3ui",V={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},z={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},re={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},Ze=({width:e=440,style:t,className:s}={})=>{const{compileBus:r}=o.useGraphContext(),[n]=(0,d.useState)(()=>ye()),[l,c]=(0,d.useState)(!1),[u,m]=(0,d.useState)(h.isCompilerCachingEnabled);(0,d.useEffect)(()=>{const{recordCompile:g}=n.getState(),p=r.getLastTrigger(),R=r.getLastCompile();return p&&R&&g(p,R),r.subscribe(g)},[n,r]);const f=(0,U.useStore)(n,g=>g.lastCompile),E=(0,U.useStore)(n,g=>g.history),_=r.getCacheStats(),C=f===null&&E.length===0,v=()=>{m(g=>{const p=!g;return(0,h.setCompilerCachingEnabled)(p),p})};return(0,i.jsxs)("div",{className:(0,A.default)(Ye,s),style:{width:e,...t},children:[(0,i.jsxs)("div",{className:He,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:$e,children:"compile cache"}),(0,i.jsx)("div",{className:ze,children:C?"production: stats disabled":f?`last: ${f.label} · ${K(f.durationMs)}`:"awaiting first compile…"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>c(g=>!g),className:Xe,children:l?"▾":"▴"})]}),!l&&(0,i.jsxs)("div",{className:"drqe3ub",children:[(0,i.jsxs)("button",{type:"button",onClick:v,className:u?V.enabled:V.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,i.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!l&&!C&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(et,{delta:f?.stages,durations:f?.stageDurationsMs,cumulative:_}),(0,i.jsx)(tt,{entries:E})]})]})},et=({delta:e,durations:t,cumulative:s})=>(0,i.jsxs)("table",{className:Ae,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:Qe,children:[(0,i.jsx)("th",{className:Be,children:"stage"}),(0,i.jsx)("th",{className:w,children:"time"}),(0,i.jsx)("th",{className:w,children:"Δ miss"}),(0,i.jsx)("th",{className:w,children:"Δ hit"}),(0,i.jsx)("th",{className:w,children:"total miss"}),(0,i.jsx)("th",{className:w,children:"total hit"})]})}),(0,i.jsx)("tbody",{children:h.COMPILER_STAGE_KEYS.map(r=>{const n=e?.[r],l=rt(n);return(0,i.jsxs)("tr",{className:We,children:[(0,i.jsxs)("td",{className:Oe,children:[(0,i.jsx)("span",{className:re[l],"aria-hidden":!0})," ",r]}),(0,i.jsx)("td",{className:H,children:t===void 0||l==="untouched"?"—":K(t[r])}),(0,i.jsx)("td",{className:l==="ran"?z.ran:z.dim,children:n?.misses??0}),(0,i.jsx)("td",{className:H,children:n?.hits??0}),(0,i.jsx)("td",{className:H,children:s[r].misses}),(0,i.jsx)("td",{className:H,children:s[r].hits})]},r)})})]}),tt=({entries:e})=>e.length===0?null:(0,i.jsxs)("div",{className:Ve,children:[(0,i.jsx)("div",{className:Je,children:"recent compiles"}),e.map(t=>{const s=st(t.stages,l=>l.misses>0),r=h.COMPILER_STAGE_KEYS.length,n=s===0?"cached":"ran";return(0,i.jsxs)("div",{className:Ke,children:[(0,i.jsx)("span",{className:re[n],"aria-hidden":!0}),(0,i.jsx)("span",{className:Fe,title:t.label,children:t.label}),(0,i.jsxs)("span",{className:Ue,children:[s,"/",r," ran · ",K(t.durationMs)]})]},t.id)})]}),rt=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",st=(e,t)=>{let s=0;for(const r of h.COMPILER_STAGE_KEYS)t(e[r])&&(s+=1);return s},K=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,nt=()=>{const{history:e}=o.useGraphContext(),{stack:t,undo:s,redo:r}=e,n=(0,d.useCallback)(u=>t.subscribe(u),[t]),l=(0,d.useCallback)(()=>t.getSnapshot(),[t]),c=(0,d.useSyncExternalStore)(n,l,l);return(0,d.useMemo)(()=>({...c,undo:s,redo:r}),[c,s,r])},ot=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),at=(e,t={})=>{const{target:s,enabled:r=!0}=t;(0,d.useEffect)(()=>{const n=it(s);if(!r||!n)return;const l=c=>{if(!ct(c)||c.defaultPrevented||lt(c.target))return;const u=o.resolveHistoryStep(c);if(!u)return;const m=e.current;m&&(u==="undo"?m.undo():m.redo())&&c.preventDefault()};return n.addEventListener("keydown",l),()=>n.removeEventListener("keydown",l)},[e,s,r])},it=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,ct=e=>"key"in e,lt=e=>e instanceof HTMLInputElement?!ot.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1;exports.BrandMark=o.BrandMark;exports.CanvasTextMeasurer=o.CanvasTextMeasurer;exports.DefaultFooter=o.DefaultFooter;exports.DefaultGrid=o.DefaultGrid;exports.DefaultHeader=o.DefaultHeader;exports.DefaultSwatch=o.DefaultSwatch;exports.DefaultTooltip=o.DefaultTooltip;exports.DevToolsPanel=Ze;exports.GRAPH_MODES=o.GRAPH_MODES;exports.GeomCircle=Pe;exports.GeomLine=we;exports.GraphErrorBoundary=Q;exports.GraphErrorPanel=B;exports.GraphProvider=te;exports.GraphRenderer=o.GraphRenderer;exports.HoverProvider=o.HoverProvider;exports.IntroFade=o.IntroFade;exports.IntroWipeClip=o.IntroWipeClip;exports.TextMeasurerProvider=o.TextMeasurerProvider;exports.ThemeProvider=o.ThemeProvider;exports.UnitBoxSvg=Me;exports.UnitSpaceSvg=Le;exports.buildDotsEditOutlineShapes=o.buildDotsEditOutlineShapes;exports.createGraphyKit=Ie;exports.darkTheme=o.darkTheme;exports.defineGeomRenderer=o.defineGeomRenderer;exports.lightTheme=o.lightTheme;exports.lightenCss=o.lightenCss;exports.projectPointCartesian=o.projectPointCartesian;exports.pruneSelection=ee;exports.resolveBrandMarkVisual=o.resolveBrandMarkVisual;exports.scalePointToPanel=o.scalePointToPanel;exports.stampAxisEditTarget=o.stampAxisEditTarget;exports.stampGridEditTarget=o.stampGridEditTarget;exports.stampLegendEditTarget=o.stampLegendEditTarget;exports.useElementScreenRect=o.useElementScreenRect;exports.useGeomHitTest=o.useGeomHitTest;exports.useGeomHover=o.useGeomHover;exports.useGeomReaderTree=o.useGeomReaderTree;exports.useGeomStyleReader=o.useGeomStyleReader;exports.useGraphCommands=o.useGraphCommands;exports.useGraphHandle=o.useGraphHandle;exports.useGraphHistory=nt;exports.useGraphHistoryShortcuts=at;exports.useGraphSelection=o.useGraphSelection;exports.useGuidesTakePress=o.useGuidesTakePress;exports.useHandleScene=o.useHandleScene;exports.useHoverState=o.useHoverState;exports.useResolvedStyle=o.useResolvedStyle;exports.useSceneSelector=o.useSceneSelector;exports.useStyleReaderTree=o.useStyleReaderTree;exports.useStyleResolver=o.useStyleResolver;exports.useTargetBoundary=o.useTargetBoundary;exports.useTextMeasurer=o.useTextMeasurer;exports.vars=oe.vars;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const o=require("./use-target-boundary-Db66YmHM.cjs"),oe=require("./theme.contract.css-DKDKSByt.cjs");let h=require("@graphysdk/viz-engine"),d=require("react"),i=require("react/jsx-runtime"),U=require("zustand"),X=require("motion/react"),O=require("zustand/vanilla"),A=require("clsx");A=o.__toESM(A,1);var ae="_1a5iqpb0",ie="_1a5iqpb1";var ce="_1a5iqpb3",le="_1a5iqpb4",de="_1a5iqpb5";var B=({errors:e})=>{const[t,...s]=e;return(0,i.jsxs)("div",{role:"alert",className:ae,children:[(0,i.jsx)("strong",{className:ie,children:"This chart could not be rendered."}),t&&(0,i.jsx)(Y,{diagnostic:t}),s.length>0&&(0,i.jsx)("ul",{className:"_1a5iqpb2",children:s.map((r,n)=>(0,i.jsx)("li",{children:(0,i.jsx)(Y,{diagnostic:r})},`${r.code}-${n}`))})]})},Y=({diagnostic:e})=>(0,i.jsxs)("div",{className:ce,children:[(0,i.jsx)("span",{className:le,children:e.code}),(0,i.jsx)("p",{className:de,children:e.message}),e.suggestion&&(0,i.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function ue(e=[],t=[]){return e.length===t.length&&e.every((s,r)=>Object.is(s,t[r]))}var Q=class extends d.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,h.buildDiagnostic)(e)}}componentDidCatch(e,t){const s=(0,h.buildDiagnostic)(e);o.logDiagnostics([s]),this.props.onError?.([s]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!ue(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,i.jsx)(B,{errors:[e]});const{forcedErrors:t,children:s}=this.props;return t&&t.length>0?(0,i.jsx)(B,{errors:t}):s}},J=e=>typeof e=="object"&&"geom"in e&&"render"in e,Z=e=>{const t=(0,h.resolveDefinition)(e);return t instanceof h.Geom?t:null},ee=(e,t)=>{const s=e.filter(r=>me(r,t));return s.length===e.length?e:s},me=(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,W=[],ge=()=>(0,O.createStore)(e=>({selection:W,setSelection:t=>e(s=>he(s.selection,t)?s:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:W})})),he=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((s,r)=>{const n=t[r];return n!==void 0&&(0,h.areEditTargetsEqual)(s,n)}),pe=process.env.NODE_ENV!=="production",fe=5,ve=e=>{if(!pe)return{emit:()=>{},subscribe:()=>Se,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let s=null;return{emit:r=>{const n=e.getLastCompile();if(n){s=r;for(const l of t)l(r,n)}},subscribe:r=>(t.add(r),()=>{t.delete(r)}),getLastTrigger:()=>s,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},ye=()=>(0,O.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,s)=>e(r=>{if(r.lastSnapshot===s)return r;const n={id:r.nextId,label:be(t),stages:s.stages,stageDurationsMs:s.stageDurationsMs,durationMs:s.durationMs};return{lastCompile:n,history:Ee(r.history,n,fe),nextId:r.nextId+1,lastSnapshot:s}})})),Se=()=>{},be=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}},Ee=(e,t,s)=>{const r=e.length>=s?e.length-(s-1):0;return[...e.slice(r),t]};function Te(e){const t=e.filter(J),s=new Set([...Object.keys(o.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),r=[],n=new Set;for(const u of e){const m=Z(u);m===null||s.has(m.type)||n.has(m.type)||(n.add(m.type),r.push({kind:"user-input",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 u of t){if("definition"in u)continue;const m=`${u.geom}|${u.coord}`,f=l.get(m);f?f.count+=1:l.set(m,{geom:u.geom,coord:u.coord,count:1})}const c=[];for(const{geom:u,coord:m,count:f}of l.values())f<2||c.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${m}') (${f} entries); the last in the array wins.`,context:{requested:`${u}@${m}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${m}').`});return c.push(...je(e)),{errors:r,warnings:c}}function xe(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r)t(c.geom,s.type)!==null||n.has(c.geom)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${c.geom}' under ${s.type} coords; the layer is not painted.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${c.geom}', '${s.type}') via \`defineGeomRenderer\`.`}));return l}function Ce(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||u.hitTest||o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:`Add a \`hitTest\` factory (precomputed geometry) or an overlay render (\`{ fn, options: { overlay: true } }\`, live simulation) to the renderer for ('${c.geom}', '${s.type}').`}))}return l}function Re(e){const t=new Set,s=[];for(const r of e.layers){const n=r.identityKey;r.interactive!==!1&&(r.spatialKind!=="render-hit-test"||typeof n!="object"||t.has(r.geom)||r.data.hasVariable(n.variable)||(t.add(r.geom),s.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${r.geom}' keys its identity on '${n.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:r.geom,kind:"geom-renderer"},suggestion:`Emit the '${n.variable}' column from the geom's \`compile()\`, or point \`identityKey\` at a column it does emit.`})))}return s}function Ge(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind!=="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!u.hitTest||!o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR an overlay render (`{ fn, options: { overlay: true } }`) for a live simulation."}))}return l}function Ne(e,t){const s=new Set,r=[];for(const n of e.layers)n.interactive!==!1&&(n.spatialKind!=="render-hit-test"||s.has(n.geom)||t.hasCapability(n.geom)||(s.add(n.geom),r.push({kind:"user-input",severity:"warning",code:"MISSING_ANCHOR_CAPABILITY",message:`Geom '${n.geom}' declares no \`resolveAnchorPosition\`; its observations cannot be annotated, so the editor overlay paints no creation trigger on them.`,context:{requested:n.geom,kind:"geom-renderer"},suggestion:"Implement `resolveAnchorPosition(observation, context)` on the geom, returning the normalised panel position an annotation on that observation belongs at."})));return r}function _e(e,t){const{coordSystem:s,layers:r}=e,n=new Set,l=[];for(const c of r){if(c.interactive===!1||c.spatialKind==="render-hit-test"||n.has(c.geom))continue;const u=t(c.geom,s.type);u===null||!o.isOverlayHosted(u)||(n.add(c.geom),l.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${c.geom}' declares an overlay render but its layer's spatialKind is '${c.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:c.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the scene layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return l}function je(e){const t=new Set,s=[];for(const r of e){const n=Z(r);n===null||t.has(n.type)||n.dataLabelCoordTypes.length===0||n.getDataLabelPlacements!==void 0||(t.add(n.type),s.push({kind:"user-input",severity:"warning",code:"MISSING_DATA_LABEL_PLACEMENT",message:`Geom '${n.type}' declares \`dataLabelCoordTypes\` but implements no \`getDataLabelPlacements\`; its layers paint no data labels.`,context:{requested:n.type,kind:"geom-renderer"},suggestion:"Implement `getDataLabelPlacements(context)` on the geom, or drop `dataLabelCoordTypes` so the compiler warns the author off the flag."}))}return s}var qe=e=>(0,O.createStore)(t=>({scene:e,setScene:s=>t(r=>r.scene===s?r:{scene:s})})),ke=({spec:e,data:t,customPalettes:s,colorScheme:r,plugins:n,resolveRenderer:l,anchorResolver:c,onSpecChange:u,onError:m,onWarnings:f})=>{const E=o.useLatestRef(u),_=o.useLatestRef(m),C=o.useLatestRef(f),[{session:v,compileBus:g}]=(0,d.useState)(()=>{const a=(0,h.createCompiler)({plugins:n});return{session:new h.GraphCompilationSession(a),compileBus:ve(a)}}),[p]=(0,d.useState)(()=>Te(n??[])),R=(0,d.useRef)(null),[j]=(0,d.useState)(De),S=(0,d.useRef)(null),G=(0,d.useCallback)(a=>p.errors.length===0?a:[...p.errors,...a??[]],[p]),D=(0,d.useCallback)(a=>{if(!a.ok)return a.errors;if(S.current)S.current.getState().setScene(a.scene);else{const y=qe(a.scene);y.subscribe(j.notify),S.current=y,j.notify()}return null},[j]),[q,I]=(0,d.useState)(()=>{const a=v.compile({spec:e,data:t,customPalettes:s,colorScheme:r});return R.current=a,G(D(a))}),T=(0,d.useCallback)(a=>a.ok?[...a.warnings,...xe(a.scene,l),...Ce(a.scene,l),...Re(a.scene),...Ge(a.scene,l),..._e(a.scene,l),...Ne(a.scene,c)]:a.warnings,[l,c]),x=(0,d.useCallback)(a=>{a.length!==0&&(o.logDiagnostics(a),_.current?.(a))},[_]),N=(0,d.useCallback)(a=>{a.length!==0&&(o.logDiagnostics(a),C.current?.(a))},[C]);(0,d.useEffect)(()=>{const a=R.current;a&&(x([...p.errors,...a.ok?[]:a.errors]),N([...p.warnings,...T(a)]),a.ok&&g.emit({kind:"init"}))},[g,x,N,p,T]),(0,d.useEffect)(()=>{const a=v.update({spec:e,data:t,customPalettes:s,colorScheme:r});if(!a)return;a.committedSpec&&E.current?.(a.committedSpec);const y=D(a.result);I(G(y)),y&&x(y),N(T(a.result)),y||g.emit({kind:a.specChanged?"spec":"data"})},[e,t,s,r,v,g,D,x,N,G,T,E]);const k=(0,d.useCallback)(a=>{I(y=>y===null?y:G(null)),N(T(a))},[G,N,T]),P=(0,d.useCallback)(a=>{a.scene&&S.current?.getState().setScene(a.scene),a.result&&k(a.result),a.command&&g.emit({kind:"command",command:a.command}),a.spec&&E.current?.(a.spec),a.errors&&x([...a.errors])},[k,g,E,x]),b=(0,d.useCallback)(a=>{for(const y of a)P(y);return a.some(y=>!!y.scene)},[P]),$=(0,d.useCallback)((a,y)=>{b(v.applyCommand(a,y))},[v,b]),L=(0,d.useCallback)(()=>{b(v.commit())},[v,b]),M=(0,d.useCallback)(()=>b(v.undo()),[v,b]),F=(0,d.useCallback)(()=>b(v.redo()),[v,b]),se=(0,d.useMemo)(()=>({stack:v.history,undo:M,redo:F}),[v,M,F]),ne=(0,d.useCallback)(()=>S.current?.getState().scene??null,[]);return{store:S.current,dispatch:$,commit:L,history:se,subscribe:j.subscribe,getScene:ne,compileBus:g,compileErrors:q}},De=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},te=({data:e,spec:t,plugins:s=[],formattingLocale:r,handleRef:n,onSpecChange:l,onError:c,onWarnings:u,customPalettes:m,colorScheme:f="light",children:E})=>{const[_]=(0,d.useState)(()=>o.createGeomRendererResolver(s.filter(J))),C=(0,d.useId)(),[v]=(0,d.useState)(()=>(0,h.createAnchorResolver)(s)),[g]=(0,d.useState)(()=>(0,h.createDataLabelPlacementResolver)(s)),[p]=(0,d.useState)(()=>ge()),[R]=(0,d.useState)(()=>o.createTargetBoundaryStore()),j=(0,d.useMemo)(()=>(0,h.createStyleResolver)({colorScheme:f}),[f]),{store:S,dispatch:G,commit:D,history:q,subscribe:I,getScene:T,compileBus:x,compileErrors:N}=ke({spec:t,data:e,customPalettes:m,colorScheme:f,plugins:s,resolveRenderer:_,anchorResolver:v,onSpecChange:l,onError:c,onWarnings:u});(0,d.useEffect)(()=>{if(S)return S.subscribe((b,$)=>{if(b.scene.spec===$.scene.spec)return;const{selection:L,setSelection:M}=p.getState();L.length!==0&&M(ee(L,b.scene.spec))})},[S,p]);const k=(0,d.useMemo)(()=>({dispatch:G,commit:D}),[G,D]);(0,d.useImperativeHandle)(n,()=>({commands:k,undo:q.undo,redo:q.redo,subscribe:I,getScene:T,getSelection:()=>p.getState().selection,setSelection:b=>p.getState().setSelection(b),subscribeSelection:p.subscribe,canPlaceDataLabels:g.hasCapability,canFormatDataLabelsAsPercentages:g.hasPercentageFormat}),[k,q,I,T,p,g]);const P=(0,d.useMemo)(()=>S?{chartId:C,store:S,selectionStore:p,targetBoundaryStore:R,commands:k,history:q,formattingLocale:r,compileBus:x,colorScheme:f,styleResolver:j,anchorResolver:v}:null,[C,S,p,R,k,q,r,x,f,j,v]);return(0,i.jsx)(Q,{forcedErrors:N,onError:c,resetKeys:[t,e],children:P?(0,i.jsx)(o.GraphContext.Provider,{value:P,children:(0,i.jsx)(o.GeomRendererResolverProvider,{value:_,children:(0,i.jsx)(o.DataLabelPlacementResolverProvider,{value:g,children:E})})}):null})};function Ie(e){const t=(0,h.createSpecBuilder)(e);return{...t,GraphProvider:r=>(0,i.jsx)(te,{...r,plugins:t.plugins})}}var Pe=({shouldAnimateTransitions:e,cx:t,cy:s,r,...n})=>e?(0,i.jsx)(X.motion.circle,{initial:!1,animate:{cx:t,cy:s,r},transition:o.DEFAULT_SPRING_TRANSITION,...n}):(0,i.jsx)("circle",{cx:t,cy:s,r,...n}),we=({shouldAnimateTransitions:e,x1:t,y1:s,x2:r,y2:n,...l})=>e?(0,i.jsx)(X.motion.line,{initial:!1,animate:{x1:t,y1:s,x2:r,y2:n},transition:o.DEFAULT_SPRING_TRANSITION,...l}):(0,i.jsx)("line",{x1:t,y1:s,x2:r,y2:n,...l}),Le=({children:e,...t})=>(0,i.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),Me=({box:e,children:t})=>(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:t}),He="drqe3u0",$e="drqe3u1",Ae="drqe3u2",Be="drqe3u3",w="drqe3u4",Oe="drqe3u5",Ke="drqe3u6",Fe="drqe3u7",H="drqe3u8",Ue="drqe3u9",Ye="drqe3ua";var We="drqe3uc",Ve="drqe3ud",ze="drqe3ue",Xe="drqe3uf";var Qe="drqe3uh",Je="drqe3ui",V={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},z={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},re={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},Ze=({width:e=440,style:t,className:s}={})=>{const{compileBus:r}=o.useGraphContext(),[n]=(0,d.useState)(()=>ye()),[l,c]=(0,d.useState)(!1),[u,m]=(0,d.useState)(h.isCompilerCachingEnabled);(0,d.useEffect)(()=>{const{recordCompile:g}=n.getState(),p=r.getLastTrigger(),R=r.getLastCompile();return p&&R&&g(p,R),r.subscribe(g)},[n,r]);const f=(0,U.useStore)(n,g=>g.lastCompile),E=(0,U.useStore)(n,g=>g.history),_=r.getCacheStats(),C=f===null&&E.length===0,v=()=>{m(g=>{const p=!g;return(0,h.setCompilerCachingEnabled)(p),p})};return(0,i.jsxs)("div",{className:(0,A.default)(Ye,s),style:{width:e,...t},children:[(0,i.jsxs)("div",{className:He,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:$e,children:"compile cache"}),(0,i.jsx)("div",{className:ze,children:C?"production: stats disabled":f?`last: ${f.label} · ${K(f.durationMs)}`:"awaiting first compile…"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>c(g=>!g),className:Xe,children:l?"▾":"▴"})]}),!l&&(0,i.jsxs)("div",{className:"drqe3ub",children:[(0,i.jsxs)("button",{type:"button",onClick:v,className:u?V.enabled:V.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,i.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!l&&!C&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(et,{delta:f?.stages,durations:f?.stageDurationsMs,cumulative:_}),(0,i.jsx)(tt,{entries:E})]})]})},et=({delta:e,durations:t,cumulative:s})=>(0,i.jsxs)("table",{className:Ae,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:Qe,children:[(0,i.jsx)("th",{className:Be,children:"stage"}),(0,i.jsx)("th",{className:w,children:"time"}),(0,i.jsx)("th",{className:w,children:"Δ miss"}),(0,i.jsx)("th",{className:w,children:"Δ hit"}),(0,i.jsx)("th",{className:w,children:"total miss"}),(0,i.jsx)("th",{className:w,children:"total hit"})]})}),(0,i.jsx)("tbody",{children:h.COMPILER_STAGE_KEYS.map(r=>{const n=e?.[r],l=rt(n);return(0,i.jsxs)("tr",{className:We,children:[(0,i.jsxs)("td",{className:Oe,children:[(0,i.jsx)("span",{className:re[l],"aria-hidden":!0})," ",r]}),(0,i.jsx)("td",{className:H,children:t===void 0||l==="untouched"?"—":K(t[r])}),(0,i.jsx)("td",{className:l==="ran"?z.ran:z.dim,children:n?.misses??0}),(0,i.jsx)("td",{className:H,children:n?.hits??0}),(0,i.jsx)("td",{className:H,children:s[r].misses}),(0,i.jsx)("td",{className:H,children:s[r].hits})]},r)})})]}),tt=({entries:e})=>e.length===0?null:(0,i.jsxs)("div",{className:Ve,children:[(0,i.jsx)("div",{className:Je,children:"recent compiles"}),e.map(t=>{const s=st(t.stages,l=>l.misses>0),r=h.COMPILER_STAGE_KEYS.length,n=s===0?"cached":"ran";return(0,i.jsxs)("div",{className:Ke,children:[(0,i.jsx)("span",{className:re[n],"aria-hidden":!0}),(0,i.jsx)("span",{className:Fe,title:t.label,children:t.label}),(0,i.jsxs)("span",{className:Ue,children:[s,"/",r," ran · ",K(t.durationMs)]})]},t.id)})]}),rt=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",st=(e,t)=>{let s=0;for(const r of h.COMPILER_STAGE_KEYS)t(e[r])&&(s+=1);return s},K=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,nt=()=>{const{history:e}=o.useGraphContext(),{stack:t,undo:s,redo:r}=e,n=(0,d.useCallback)(u=>t.subscribe(u),[t]),l=(0,d.useCallback)(()=>t.getSnapshot(),[t]),c=(0,d.useSyncExternalStore)(n,l,l);return(0,d.useMemo)(()=>({...c,undo:s,redo:r}),[c,s,r])},ot=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),at=(e,t={})=>{const{target:s,enabled:r=!0}=t;(0,d.useEffect)(()=>{const n=it(s);if(!r||!n)return;const l=c=>{if(!ct(c)||c.defaultPrevented||lt(c.target))return;const u=o.resolveHistoryStep(c);if(!u)return;const m=e.current;m&&(u==="undo"?m.undo():m.redo())&&c.preventDefault()};return n.addEventListener("keydown",l),()=>n.removeEventListener("keydown",l)},[e,s,r])},it=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,ct=e=>"key"in e,lt=e=>e instanceof HTMLInputElement?!ot.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1;exports.BrandMark=o.BrandMark;exports.CanvasTextMeasurer=o.CanvasTextMeasurer;exports.DefaultFooter=o.DefaultFooter;exports.DefaultGrid=o.DefaultGrid;exports.DefaultHeader=o.DefaultHeader;exports.DefaultSwatch=o.DefaultSwatch;exports.DefaultTooltip=o.DefaultTooltip;exports.DevToolsPanel=Ze;exports.GRAPH_MODES=o.GRAPH_MODES;exports.GeomCircle=Pe;exports.GeomLine=we;exports.GraphErrorBoundary=Q;exports.GraphErrorPanel=B;exports.GraphProvider=te;exports.GraphRenderer=o.GraphRenderer;exports.HoverProvider=o.HoverProvider;exports.IntroFade=o.IntroFade;exports.IntroWipeClip=o.IntroWipeClip;exports.TextMeasurerProvider=o.TextMeasurerProvider;exports.ThemeProvider=o.ThemeProvider;exports.UnitBoxSvg=Me;exports.UnitSpaceSvg=Le;exports.buildDotsEditOutlineShapes=o.buildDotsEditOutlineShapes;exports.createGraphyKit=Ie;exports.darkTheme=o.darkTheme;exports.defineGeomRenderer=o.defineGeomRenderer;exports.lightTheme=o.lightTheme;exports.lightenCss=o.lightenCss;exports.projectPointCartesian=o.projectPointCartesian;exports.pruneSelection=ee;exports.resolveBrandMarkVisual=o.resolveBrandMarkVisual;exports.scalePointToPanel=o.scalePointToPanel;exports.stampAxisEditTarget=o.stampAxisEditTarget;exports.stampGridEditTarget=o.stampGridEditTarget;exports.stampLegendEditTarget=o.stampLegendEditTarget;exports.useElementScreenRect=o.useElementScreenRect;exports.useGeomHitTest=o.useGeomHitTest;exports.useGeomHover=o.useGeomHover;exports.useGeomReaderTree=o.useGeomReaderTree;exports.useGeomStyleReader=o.useGeomStyleReader;exports.useGraphCommands=o.useGraphCommands;exports.useGraphHandle=o.useGraphHandle;exports.useGraphHistory=nt;exports.useGraphHistoryShortcuts=at;exports.useGraphSelection=o.useGraphSelection;exports.useGuidesTakePress=o.useGuidesTakePress;exports.useHandleScene=o.useHandleScene;exports.useHoverState=o.useHoverState;exports.useResolvedStyle=o.useResolvedStyle;exports.useSceneSelector=o.useSceneSelector;exports.useStyleReaderTree=o.useStyleReaderTree;exports.useStyleResolver=o.useStyleResolver;exports.useTargetBoundary=o.useTargetBoundary;exports.useTextMeasurer=o.useTextMeasurer;exports.vars=oe.vars;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as xt, At as ge, B as At, Dt as F, Ft as Bt, Ht as Ot, L as Kt, M as Ft, Mt as jt, N as Ut, Nt as U, Pt as he, R as Yt, Rt as Wt, T as Vt, Tt as Xt, Ut as zt, V as Qt, Vt as Jt, Wt as Zt, Yt as er, _t as tr, a as rr, an as nr, bt as sr, c as or, cn as ar, dn as pe, dt as ir, fn as oe, ft as cr, g as lr, i as dr, in as ur, it as mr, j as gr, jt as fe, ln as hr, lt as pr, mn as j, n as ve, nn as fr, o as vr, on as yr, pn as ye, r as Sr, rt as br, sn as Er, t as Tr, tn as ae, un as Rr, wt as Nr, yt as Cr, zt as Se } from "./use-target-boundary-
|
|
1
|
+
import { $t as xt, At as ge, B as At, Dt as F, Ft as Bt, Ht as Ot, L as Kt, M as Ft, Mt as jt, N as Ut, Nt as U, Pt as he, R as Yt, Rt as Wt, T as Vt, Tt as Xt, Ut as zt, V as Qt, Vt as Jt, Wt as Zt, Yt as er, _t as tr, a as rr, an as nr, bt as sr, c as or, cn as ar, dn as pe, dt as ir, fn as oe, ft as cr, g as lr, i as dr, in as ur, it as mr, j as gr, jt as fe, ln as hr, lt as pr, mn as j, n as ve, nn as fr, o as vr, on as yr, pn as ye, r as Sr, rt as br, sn as Er, t as Tr, tn as ae, un as Rr, wt as Nr, yt as Cr, zt as Se } from "./use-target-boundary-AyGM1lRB.js";
|
|
2
2
|
import { n as Dr } from "./theme.contract.css-AyXDNf0F.js";
|
|
3
3
|
import { COMPILER_STAGE_KEYS as Y, Geom as be, GraphCompilationSession as Ee, areEditTargetsEqual as Te, buildDiagnostic as z, createAnchorResolver as Re, createCompiler as Ne, createDataLabelPlacementResolver as Ce, createSpecBuilder as qe, createStyleResolver as De, findAnnotation as Ge, findLayerById as Q, isCompilerCachingEnabled as Ie, resolveDefinition as we, setCompilerCachingEnabled as _e, toPercent as B } from "@graphysdk/viz-engine";
|
|
4
4
|
import { Component as ke, useCallback as f, useEffect as M, useId as Le, useImperativeHandle as Pe, useMemo as H, useRef as J, useState as b, useSyncExternalStore as $e } from "react";
|