@graphysdk/react 0.0.1
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/README.md +0 -0
- package/dist/index.cjs +2 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +243 -0
- package/dist/index.mjs +836 -0
- package/package.json +75 -0
package/README.md
ADDED
|
File without changes
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require('./index.css');
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),v=require("motion/react"),h=require("react"),l=require("@graphysdk/viz-engine"),N=require("clsx"),A=require("d3-shape"),Z=require("d3-interpolate-path"),J=require("@vanilla-extract/dynamic");typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.reactRenderer="0.0.1");const Q=/\p{Emoji_Presentation}|\p{Emoji}\uFE0F/gu,G="😀";class C{constructor(){this.emojiCorrections=new Map,this.currentFont="";const r=new OffscreenCanvas(1,1).getContext("2d");if(!r)throw new Error("Failed to create OffscreenCanvas 2D context");this.ctx=r}static async create(){return typeof document<"u"&&document.fonts&&await document.fonts.ready,new C}measureText(t,r){const o=rt(r);this.setFont(o);const{width:n,fontBoundingBoxAscent:a,fontBoundingBoxDescent:s}=this.ctx.measureText(t);let c=n;const u=tt(t);if(u>0){const d=this.getEmojiCorrection(o);c-=d*u}return{width:c,height:a+s,ascent:a,descent:s}}setFont(t){this.currentFont!==t&&(this.ctx.font=t,this.currentFont=t)}getEmojiCorrection(t){const r=this.emojiCorrections.get(t);if(r!==void 0)return r;this.setFont(t);const o=this.ctx.measureText(G).width,n=et(t);let a=0;if(n!==null){const s=o-n;a=s>.5?s:0}return this.emojiCorrections.set(t,a),a}}const tt=e=>{const t=e.match(Q);return t?t.length:0},et=e=>{const t=nt();return t?(t.style.font=e,t.getBoundingClientRect().width):null};function rt(e){const t=e.style??l.DEFAULT_FONT_STYLE,r=e.weight??l.DEFAULT_FONT_WEIGHT;return`${t} ${r} ${e.size}px '${e.family}'`}let T=null;const nt=()=>typeof document>"u"?null:(T||(T=document.createElement("span"),T.style.position="absolute",T.style.visibility="hidden",T.style.whiteSpace="nowrap",T.style.left="-9999px",T.textContent=G,document.body.appendChild(T)),T),z=()=>{const[e,t]=h.useState(null);return h.useEffect(()=>{let r=!1;const o=()=>{r||t(ot())};return(async()=>{typeof document<"u"&&document.fonts&&await document.fonts.ready,o()})(),typeof document<"u"&&document.fonts&&document.fonts.addEventListener("loadingdone",o),()=>{r=!0,typeof document<"u"&&document.fonts&&document.fonts.removeEventListener("loadingdone",o)}},[]),e},ot=()=>{try{return new l.CachedTextMeasurer(new C)}catch{return new l.CachedTextMeasurer(new l.HeuristicTextMeasurer)}},at=12,it="sans-serif",st={family:it,size:at},lt=e=>t=>{if(!t.isVisible||t.ticks.length===0)return 0;const r=t.position==="top"||t.position==="bottom",o=t.ticks.map(n=>e.measureText(String(n.value),st));return Math.max(...r?o.map(n=>n.height):o.map(n=>n.width))},ct=20,ut=()=>()=>ct,dt=12,gt=8,ht=12,pt="Inter",ft={family:pt,size:ht},yt=gt+dt,mt=e=>t=>{if(t.items.length===0)return 0;const r=t.position==="top"||t.position==="bottom",o=t.items.map(n=>e.measureText(String(n.value),ft));return r?Math.max(...o.map(n=>n.height)):Math.max(...o.map(n=>n.width))+yt},vt=({spec:e,containerSize:t,externalMeasurements:r})=>{const o=z(),n=h.useMemo(()=>o?{measureAxis:lt(o),measureAxisLabel:ut(),measureLegend:mt(o)}:null,[o]);return h.useMemo(()=>n?new l.LayoutCompiler(n).compile({guides:e.guides,containerSize:t,externalMeasurements:r}):null,[e,t,r,n])},U=!1,w=e=>e.text!==void 0?e.text:e.content?e.content.map(w).join(""):"";var xt="_12eci1n0",R="_1mf2q6u0";const bt=({ref:e,compiled:t,captionRect:r})=>{const{caption:o}=t.config.content;return o===null?null:i.jsx("div",{ref:e,className:xt,style:{width:r.width},children:i.jsx("p",{className:R,children:typeof o=="string"?o:w(o)})})};var Tt="_1q25vjj0";const Et=({ref:e,compiled:t,titleRect:r})=>{const{title:o,subtitle:n}=t.config.content;if(o===null&&n===null)return null;const a=typeof o=="string"?o:o!==null?w(o):"",s=typeof n=="string"?n:n!==null?w(n):"";return i.jsxs("div",{ref:e,className:Tt,style:{width:r.width},children:[o!==null&&i.jsx("h1",{className:R,children:a}),n!==null&&i.jsx("p",{className:R,children:s})]})},y=e=>`${e*100}%`;function _(e){return 1-e}var Lt="pr8m7u0",At="pr8m7u1";const _t=8,kt=({legends:e})=>{const t=h.useMemo(()=>{const r=[];for(const o of e)for(const n of o.items){if(n.normalizedY===null)continue;const a=typeof n.visual.color=="string"?n.visual.color:void 0;r.push({key:`${String(n.value)}${a?`-${a}`:""}`,label:String(n.value),color:a,x:_t,y:y(_(n.normalizedY))})}return r},[e]);return t.length===0?null:i.jsx("div",{className:Lt,children:t.map(r=>i.jsx("span",{className:At,style:{left:r.x,top:r.y,color:r.color},children:r.label},r.key))})};var St="_2hq2f70",jt="x9xdzb0",wt="x9xdzb1",Ct="x9xdzb2",Mt="x9xdzb3",W="x9xdzb4",Rt="x9xdzb5",It="x9xdzb6";const Ft="#9ca3af",Pt=({legends:e})=>e.length===0?null:i.jsx("div",{className:jt,children:e.map((t,r)=>{const o=t.position==="left"||t.position==="right",n=t.aesthetics.includes("size");return i.jsx("div",{className:N.clsx(wt,{[Mt]:o,[Ct]:!o}),children:n?i.jsx(Ot,{legend:t}):i.jsx(Dt,{legend:t})},r)})}),Dt=({legend:e})=>e.items.map(t=>i.jsxs("div",{className:W,children:[i.jsx("span",{className:Rt,style:{backgroundColor:t.visual.color}}),i.jsx("span",{children:String(t.value)})]},`${String(t.value)}${t.visual.color?`-${t.visual.color}`:""}`)),Ot=({legend:e})=>{const t=e.items.map(r=>{const o=Number(r.visual.size);return{key:`${String(r.value)}-${o}`,label:String(r.value),color:typeof r.visual.color=="string"?r.visual.color:void 0,sizeValue:o}}).filter(r=>Number.isFinite(r.sizeValue)&&r.sizeValue>0);return t.length===0?null:t.map(r=>i.jsxs("div",{className:W,children:[i.jsx("span",{className:It,style:{width:r.sizeValue,height:r.sizeValue,backgroundColor:r.color??Ft}}),i.jsx("span",{children:r.label})]},r.key))},Bt=h.memo(function({legends:t,rects:r}){const o=h.useMemo(()=>{const n=new Map;for(const a of t){const s=n.get(a.position);s?s.push(a):n.set(a.position,[a])}return n},[t]);return i.jsx(i.Fragment,{children:Array.from(o,([n,a])=>{const s=r[n];if(s==null)return null;const c=a.filter(d=>d.display==="pill"),u=a.filter(d=>d.display==="direct");return i.jsxs("div",{className:St,style:{left:s.x,top:s.y,width:s.width,height:s.height},children:[i.jsx(Pt,{legends:c}),i.jsx(kt,{legends:u})]},n)})})});var H="wyi2w10";const Nt=({axisRects:e})=>i.jsxs(i.Fragment,{children:[S("top",e.top),S("right",e.right),S("bottom",e.bottom),S("left",e.left)]}),S=(e,t)=>t?i.jsxs("g",{transform:`translate(${t.x}, ${t.y})`,children:[U,i.jsxs("text",{className:H,x:t.width/2,y:t.height/2,textAnchor:"middle",dominantBaseline:"middle",children:[e," axis"]})]},`axis-${e}`):null,Gt=({axisLabelRects:e})=>i.jsxs(i.Fragment,{children:[j("top",e.top),j("right",e.right),j("bottom",e.bottom),j("left",e.left)]}),j=(e,t)=>{if(!t)return null;const r=zt(e,t);return i.jsxs("g",{transform:`translate(${t.x}, ${t.y})`,children:[U,i.jsxs("text",{className:H,...r,children:[e," axis label"]})]},`axis-label-${e}`)},zt=(e,t)=>{const r={x:t.width/2,y:t.height/2,textAnchor:"middle",dominantBaseline:"middle"};return e==="left"?(r.x=0,r.textAnchor="start"):e==="right"&&(r.x=t.width,r.textAnchor="end"),r},Ut=l.DEFAULT_COLOR_PALETTE[0],Wt=.3,Ht=1,E={type:"spring",stiffness:500,damping:60,mass:1},Yt=l.DEFAULT_COLOR_PALETTE[0],Vt=1,$t=2,Y=e=>e==="catmull-rom"?A.curveCatmullRom:A.curveLinear,V=e=>{switch(e){case"dashed":return"8 4";case"dotted":return"2 2";case"solid":return}},$=(e,t)=>t.lineWidth!=="auto"?t.lineWidth:l.getStrokeWidth(e)??$t,k=(e,t,r)=>{const o=l.createXValueReader(e,t);return n=>{const a=l.getGroup(n)??"default",s=o(n);return`${r}-${a}${s!==null&&s!==""?`-${s}`:""}`}},I=(e,t)=>{const r=v.useMotionValue(e);return h.useEffect(()=>{const o=Z.interpolatePath(r.get(),e);v.animate(0,1,{...t,onUpdate:n=>{const a=o(n);return r.set(a)}})},[t,e,r]),r};var M="_1wf5x370";const Xt=h.memo(function({layer:t,isAnimated:r}){const o=t.params,n=V(o.lineType),[a,s]=h.useMemo(()=>{const u=Y(o.interpolate),d=g=>_(l.getYMax(g)??l.getY(g)??0),p=A.area().x(g=>l.getX(g)??0).y0(g=>_(l.getYMin(g)??0)).y1(d).curve(u),f=A.line().x(g=>l.getX(g)??0).y(d).curve(u);if(o.missingValues==="gap"){const g=x=>l.getX(x)!==null&&l.getY(x)!==null;p.defined(g),f.defined(g)}return[f,p]},[o.interpolate,o.missingValues]),c=h.useMemo(()=>{const u=k(t.data,t.mapping,t.index),d=[];return t.data.groupBy(l.GROUP_VARIABLES.group).forEach(p=>{let f=[...p];o.missingValues==="connect"&&(f=f.filter(P=>l.getX(P)!==null&&l.getY(P)!==null));const g=s(f),x=a(f);if(!g||!x)return;const m=f[0];if(!m)return;const b=l.getColor(m)??Ut,L=l.getAlpha(m),q=$(m,o);d.push({key:u(m),areaPath:g,linePath:x,color:b,fillOpacity:L??Wt,strokeWidth:q,strokeOpacity:Ht,strokeDasharray:n})}),d},[s,a,t.data,t.index,t.mapping,o,n]);return i.jsx("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%","data-geom":"area",className:M,children:c.map(u=>i.jsx(Kt,{areaPath:u.areaPath,linePath:u.linePath,color:u.color,fillOpacity:u.fillOpacity,strokeWidth:u.strokeWidth,strokeOpacity:u.strokeOpacity,strokeDasharray:u.strokeDasharray,isAnimated:r},u.key))})}),Kt=({areaPath:e,linePath:t,color:r,fillOpacity:o,strokeWidth:n,strokeOpacity:a,strokeDasharray:s,isAnimated:c})=>c?i.jsx(qt,{areaPath:e,linePath:t,color:r,fillOpacity:o,strokeWidth:n,strokeOpacity:a,strokeDasharray:s}):i.jsxs("g",{children:[i.jsx("path",{d:e,fill:r,fillOpacity:o,stroke:"none"}),i.jsx("path",{d:t,fill:"none",stroke:r,strokeWidth:n,strokeOpacity:a,strokeDasharray:s,vectorEffect:"non-scaling-stroke"})]}),qt=({areaPath:e,linePath:t,color:r,fillOpacity:o,strokeWidth:n,strokeOpacity:a,strokeDasharray:s})=>{const c=I(e,E),u=I(t,E);return i.jsxs("g",{children:[i.jsx(v.motion.path,{d:c,fill:r,fillOpacity:o,stroke:"none"}),i.jsx(v.motion.path,{d:u,fill:"none",stroke:r,strokeWidth:n,strokeOpacity:a,strokeDasharray:s,vectorEffect:"non-scaling-stroke"})]})},Zt=l.DEFAULT_COLOR_PALETTE[0],Jt=1,D=4,Qt=h.memo(function({layer:t,isAnimated:r}){const o=h.useMemo(()=>{const n=k(t.data,t.mapping,t.index),a=[];for(const s of t.data){const c=n(s),u=l.getXMin(s),d=l.getXMax(s),p=l.getYMin(s),f=l.getYMax(s)??l.getY(s);if(u===null||d===null||p===null||f===null)continue;const g=l.getColor(s),x=l.getAlpha(s);let m=1-f,b=f-p;b<0&&(m+=b,b=-b),a.push({key:c,x:u,y:m,width:d-u,height:b,fill:g??Zt,opacity:x??Jt})}return a},[t.data,t.index,t.mapping]);return i.jsx(i.Fragment,{children:o.map(n=>{const{key:a,...s}=n;return i.jsx(te,{...s,isAnimated:r},a)})})}),te=({isAnimated:e,...t})=>e?i.jsx(v.motion.rect,{initial:!1,style:{transformBox:"view-box"},transition:E,fill:t.fill,opacity:t.opacity,rx:D,animate:{x:y(t.x),y:y(t.y),width:y(t.width),height:y(t.height),opacity:t.opacity}}):i.jsx("rect",{style:{transformBox:"view-box"},x:y(t.x),y:y(t.y),width:y(t.width),height:y(t.height),fill:t.fill,opacity:t.opacity,rx:D}),ee=h.memo(function({layer:t,isAnimated:r}){const o=t.params,n=V(o.lineType),a=h.useMemo(()=>{const c=A.line().x(u=>l.getX(u)??0).y(u=>_(l.getY(u)??0)).curve(Y(o.interpolate));return o.missingValues==="gap"&&c.defined(u=>l.getX(u)!==null&&l.getY(u)!==null),c},[o.interpolate,o.missingValues]),s=h.useMemo(()=>{const c=k(t.data,t.mapping,t.index),u=[];return t.data.groupBy(l.GROUP_VARIABLES.group).forEach(d=>{let p=[...d];o.missingValues==="connect"&&(p=p.filter(L=>l.getX(L)!==null&&l.getY(L)!==null));const f=a(p);if(!f)return;const g=p[0];if(!g)return;const x=l.getColor(g)??Yt,m=l.getAlpha(g),b=$(g,o);u.push({key:c(g),pathData:f,color:x,opacity:m??Vt,strokeWidth:b,strokeDasharray:n})}),u},[a,t.data,t.index,t.mapping,o,n]);return i.jsx("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%","data-geom":"line",className:M,children:s.map(c=>i.jsx(re,{pathData:c.pathData,color:c.color,strokeWidth:c.strokeWidth,opacity:c.opacity,strokeDasharray:c.strokeDasharray,isAnimated:r},c.key))})}),re=({pathData:e,color:t,strokeWidth:r,opacity:o,strokeDasharray:n,isAnimated:a})=>a?i.jsx(ne,{pathData:e,color:t,strokeWidth:r,opacity:o,strokeDasharray:n}):i.jsx("path",{d:e,fill:"none",stroke:t,strokeWidth:r,opacity:o,strokeDasharray:n,vectorEffect:"non-scaling-stroke"}),ne=({pathData:e,color:t,strokeWidth:r,opacity:o,strokeDasharray:n})=>{const a=I(e,E);return i.jsx(v.motion.path,{d:a,fill:"none",stroke:t,strokeWidth:r,opacity:o,strokeDasharray:n,vectorEffect:"non-scaling-stroke"})},oe=l.DEFAULT_COLOR_PALETTE[0],ae=1,ie=8,se="#000000",le=1,ce=h.memo(function({layer:t,isAnimated:r}){const o=h.useMemo(()=>{const n=k(t.data,t.mapping,t.index),a=[];for(const s of t.data){const c=l.getX(s),u=l.getY(s);if(c===null||u===null)continue;const d=l.getColor(s),p=l.getAlpha(s),f=l.getSize(s),g=l.getStrokeWidth(s);a.push({key:n(s),cx:c,cy:_(u),radius:(f??ie)/2,fill:d??oe,stroke:se,opacity:p??ae,strokeWidth:g??le})}return a},[t.data,t.index,t.mapping]);return i.jsx(i.Fragment,{children:o.map(n=>r?i.jsx(v.motion.circle,{initial:!1,transition:E,fill:n.fill,stroke:n.stroke,strokeWidth:n.strokeWidth,animate:{cx:y(n.cx),cy:y(n.cy),r:n.radius,opacity:n.opacity}},n.key):i.jsx("circle",{cx:y(n.cx),cy:y(n.cy),r:n.radius,fill:n.fill,opacity:n.opacity,stroke:n.stroke,strokeWidth:n.strokeWidth},n.key))})}),ue=l.DEFAULT_COLOR_PALETTE[0],de=1,F=A.arc(),O=Math.PI*2,ge=h.memo(function({layer:t,isAnimated:r}){const o=h.useRef(!1);h.useEffect(()=>{o.current=!0},[]);const n=h.useMemo(()=>{const a=k(t.data,t.mapping,t.index),s=[];for(const c of t.data){const u=a(c),d=l.getStartAngle(c),p=l.getEndAngle(c),f=l.getInnerRadius(c),g=l.getOuterRadius(c);d===null||p===null||f===null||g===null||s.push({key:u,startAngle:d,endAngle:p,innerRadius:f,outerRadius:g,fill:l.getColor(c)??ue,opacity:l.getAlpha(c)??de})}return s},[t.data,t.index,t.mapping]);return i.jsx("svg",{viewBox:"-1 -1 2 2",preserveAspectRatio:"xMidYMid meet",width:"100%",height:"100%","data-geom":"bar",className:M,children:n.map(a=>{if(r){const{key:s,...c}=a;return i.jsx(he,{isInitialRender:!o.current,...c},s)}return i.jsx("path",{d:F({startAngle:a.startAngle,endAngle:a.endAngle,innerRadius:a.innerRadius,outerRadius:a.outerRadius})??void 0,fill:a.fill,opacity:a.opacity},a.key)})})}),he=({startAngle:e,endAngle:t,innerRadius:r,outerRadius:o,fill:n,opacity:a,isInitialRender:s})=>{const c=s?e:O,u=s?t:O,d=v.useSpring(c,E),p=v.useSpring(u,E),f=v.useMotionValue(F({startAngle:c,endAngle:u,innerRadius:r,outerRadius:o})??"");return h.useEffect(()=>{d.set(e),p.set(t)},[d,p,e,t]),h.useEffect(()=>{const g=()=>{const b=d.get(),L=p.get();f.set(F({startAngle:b,endAngle:L,innerRadius:r,outerRadius:o})??"")},x=d.on("change",g),m=p.on("change",g);return()=>{x(),m()}},[d,p,r,o,f]),i.jsx(v.motion.path,{d:f,fill:n,opacity:a,transition:E})},pe=({compiled:e,shouldAnimate:t,panelRect:r})=>i.jsx("svg",{x:r.x,y:r.y,width:r.width,height:r.height,className:M,children:e.layers.map((o,n)=>{const a=`layer-${n}`;switch(o.geom){case"bar":return e.coordSystem.type==="polar"?i.jsx(ge,{layer:o,isAnimated:t},a):i.jsx(Qt,{layer:o,isAnimated:t},a);case"line":return i.jsx(ee,{layer:o,isAnimated:t},a);case"area":return i.jsx(Xt,{layer:o,isAnimated:t},a);case"point":return i.jsx(ce,{layer:o,isAnimated:t},a);default:return i.jsxs("text",{children:[o.geom," not implemented"]},a)}})});var fe="_1ymbsoj0";const X=(e,t)=>({x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}),B=(e,t)=>{const r={};for(const[o,n]of Object.entries(e))r[o]=X(n,t);return r},ye=({compiled:e,plotRect:t,panelRect:r,axisRects:o,axisLabelRects:n,shouldAnimate:a})=>{const s=X(r,t),c=B(o,t),u=B(n,t);return i.jsxs("svg",{className:fe,width:t.width,height:t.height,style:{transform:`translate(${t.x}px, ${t.y}px)`},children:[i.jsx(Nt,{axisRects:c}),i.jsx(pe,{compiled:e,shouldAnimate:a,panelRect:s}),i.jsx(Gt,{axisLabelRects:u})]})},me={titleSize:{width:0,height:0},captionSize:{width:0,height:0}},ve=()=>{const e=h.useRef(null),t=h.useRef(null),[r,o]=h.useState(me);return h.useLayoutEffect(()=>{const n=()=>{const s=e.current?.offsetHeight??0,c=t.current?.offsetHeight??0,u=e.current?.offsetWidth??0,d=t.current?.offsetWidth??0;o(p=>p.titleSize.height===s&&p.captionSize.height===c&&p.titleSize.width===u&&p.captionSize.width===d?p:{titleSize:{width:u,height:s},captionSize:{width:d,height:c}})};n();const a=new ResizeObserver(n);return e.current&&a.observe(e.current),t.current&&a.observe(t.current),()=>a.disconnect()},[]),{titleRef:e,captionRef:t,measurements:r}};var xe="znp3wr0";const be=({spec:e,width:t,height:r,isAnimated:o})=>{const n=v.useReducedMotion(),a=h.useMemo(()=>l.compile(e),[e]),{titleRef:s,captionRef:c,measurements:u}=ve(),d=vt({spec:a,containerSize:{width:t,height:r},externalMeasurements:u});return d?i.jsxs("div",{className:xe,style:{width:t,height:r},children:[i.jsx(Et,{ref:s,compiled:a,titleRect:d.title}),i.jsx(ye,{compiled:a,plotRect:d.plot,panelRect:d.panel,axisRects:d.axes,axisLabelRects:d.axisLabels,shouldAnimate:o??!n}),i.jsx(bt,{ref:c,compiled:a,captionRect:d.caption}),i.jsx(Bt,{legends:a.guides.legends,rects:d.legends})]}):null};var K={white:"var(--graphy-white)",black:"var(--graphy-black)",transparent:"var(--graphy-transparent)",grey100:"var(--graphy-grey-100)",grey95:"var(--graphy-grey-95)",grey90:"var(--graphy-grey-90)",grey85:"var(--graphy-grey-85)",grey80:"var(--graphy-grey-80)",grey75:"var(--graphy-grey-75)",grey70:"var(--graphy-grey-70)",grey60:"var(--graphy-grey-60)",grey50:"var(--graphy-grey-50)",grey0:"var(--graphy-grey-0)",greyGradient80:"var(--graphy-grey-gradient-80)",green60:"var(--graphy-green-60)",green50:"var(--graphy-green-50)",red60:"var(--graphy-red-60)",red50:"var(--graphy-red-50)",amber70:"var(--graphy-amber-70)",amber50:"var(--graphy-amber-50)",amber40:"var(--graphy-amber-40)",amber30:"var(--graphy-amber-30)",blue80:"var(--graphy-blue-80)",blue60:"var(--graphy-blue-60)",purple50:"var(--graphy-purple-50)",purple30:"var(--graphy-purple-30)",brand:"var(--graphy-brand)",success:"var(--graphy-success)",warning:"var(--graphy-warning)",alert:"var(--graphy-alert)",textPrimary:"var(--graphy-text-primary)",textSecondary:"var(--graphy-text-secondary)",textDisabled:"var(--graphy-text-disabled)",iconPrimary:"var(--graphy-icon-primary)",iconSecondary:"var(--graphy-icon-secondary)",iconStickerBackground:"var(--graphy-icon-sticker-background)",border100:"var(--graphy-border-100)",border10:"var(--graphy-border-10)",sunkenBackground:"var(--graphy-sunken-background)",defaultBackground:"var(--graphy-default-background)",raisedBackground:"var(--graphy-raised-background)",overlayBackground:"var(--graphy-overlay-background)",overlayBorderGradient:"var(--graphy-overlay-border-gradient)",graphBackground:"var(--graphy-graph-background)",gridLineColor:"var(--graphy-grid-line-color)",hoverGuideLineColor:"var(--graphy-hover-guide-line-color)",originLineColor:"var(--graphy-origin-line-color)",targetLineColor:"var(--graphy-target-line-color)",targetLineMarkerColor:"var(--graphy-target-line-marker-color)",legendBackground:"var(--graphy-legend-background)",legendBorderColor:"var(--graphy-legend-border-color)",legendTextColor:"var(--graphy-legend-text-color)",dimmedSeriesLabelTextColor:"var(--graphy-dimmed-series-label-text-color)",dimmedSeriesLabelLineColor:"var(--graphy-dimmed-series-label-line-color)",trendNegativeColor:"var(--graphy-trend-negative-color)",trendPositiveColor:"var(--graphy-trend-positive-color)",tooltipBackground:"var(--graphy-tooltip-background)",tooltipBorderColor:"var(--graphy-tooltip-border-color)",tooltipHeadingTextColor:"var(--graphy-tooltip-heading-text-color)",tooltipLabelTextColor:"var(--graphy-tooltip-label-text-color)",tooltipValueTextColor:"var(--graphy-tooltip-value-text-color)",heatmapEmptyTileBackground:"var(--graphy-heatmap-empty-tile-background)",stackedBarHoverBorderColor:"var(--graphy-stacked-bar-hover-border-color)",defaultArrowAnnotationColor:"var(--graphy-default-arrow-annotation-color)",annotationFrameBorderColor:"var(--graphy-annotation-frame-border-color)",annotationMenuTriggerIconColor:"var(--graphy-annotation-menu-trigger-icon-color)",fontFamilyDefault:"var(--graphy-font-family-default)",fontFamilyHeading:"var(--graphy-font-family-heading)",fontWeightRegular:"var(--graphy-font-weight-regular)",fontWeightMedium:"var(--graphy-font-weight-medium)",fontWeightSemibold:"var(--graphy-font-weight-semibold)",fontWeightBold:"var(--graphy-font-weight-bold)",fontXxs:"var(--graphy-font-xxs)",fontXs:"var(--graphy-font-xs)",fontSm:"var(--graphy-font-sm)",fontMd:"var(--graphy-font-md)",fontLg:"var(--graphy-font-lg)",fontXl:"var(--graphy-font-xl)",fontEditorBody:"var(--graphy-font-editor-body)",fontHeadingSm:"var(--graphy-font-heading-sm)",fontHeadingMd:"var(--graphy-font-heading-md)",fontHeadingLg:"var(--graphy-font-heading-lg)",fontTickLabel:"var(--graphy-font-tick-label)",fontAxisLabel:"var(--graphy-font-axis-label)",fontDataLabel:"var(--graphy-font-data-label)",fontStackTotal:"var(--graphy-font-stack-total)",fontLegendLabel:"var(--graphy-font-legend-label)",fontSeriesLabel:"var(--graphy-font-series-label)",fontTooltipLabel:"var(--graphy-font-tooltip-label)",fontTooltipHeading:"var(--graphy-font-tooltip-heading)",fontTooltipFooter:"var(--graphy-font-tooltip-footer)",fontJumboTooltipLabel:"var(--graphy-font-jumbo-tooltip-label)",fontJumboTooltip:"var(--graphy-font-jumbo-tooltip)",fontMiniTooltipLabel:"var(--graphy-font-mini-tooltip-label)",fontMiniTooltipFooter:"var(--graphy-font-mini-tooltip-footer)",fontTooltipCaption:"var(--graphy-font-tooltip-caption)",fontTooltipCaptionSmall:"var(--graphy-font-tooltip-caption-small)",fontTrendTag:"var(--graphy-font-trend-tag)",fontTrendTagSmall:"var(--graphy-font-trend-tag-small)",fontGoalLineLabel:"var(--graphy-font-goal-line-label)",fontPieLabel:"var(--graphy-font-pie-label)",fontPieChartTotal:"var(--graphy-font-pie-chart-total)",fontDifferenceArrowSmall:"var(--graphy-font-difference-arrow-small)",fontDifferenceArrowMedium:"var(--graphy-font-difference-arrow-medium)",fontDifferenceArrowLarge:"var(--graphy-font-difference-arrow-large)",fontButton:"var(--graphy-font-button)",fontInput:"var(--graphy-font-input)",fontInputLabel:"var(--graphy-font-input-label)",fontSelectLabel:"var(--graphy-font-select-label)",fontSelectDescription:"var(--graphy-font-select-description)",fontColorSelectLabel:"var(--graphy-font-color-select-label)",fontMenuTitle:"var(--graphy-font-menu-title)",fontMenuGroupTitle:"var(--graphy-font-menu-group-title)",fontMenuItemLabel:"var(--graphy-font-menu-item-label)",fontMenuItemLabelSecondary:"var(--graphy-font-menu-item-label-secondary)",fontUITooltip:"var(--graphy-font-uitooltip)",fontUITooltipSecondary:"var(--graphy-font-uitooltip-secondary)",fontErrorBoundaryTitle:"var(--graphy-font-error-boundary-title)",fontErrorBoundaryMessage:"var(--graphy-font-error-boundary-message)",fontTableCell:"var(--graphy-font-table-cell)",fontTableHeaderCell:"var(--graphy-font-table-header-cell)",fontSourceLabel:"var(--graphy-font-source-label)",fontSourceLink:"var(--graphy-font-source-link)",fontTextEditorH1:"var(--graphy-font-text-editor-h1)",fontTextEditorH2:"var(--graphy-font-text-editor-h2)",fontTextEditorH3:"var(--graphy-font-text-editor-h3)",fontTextEditorH6:"var(--graphy-font-text-editor-h6)",fontTextEditorBody:"var(--graphy-font-text-editor-body)",fontTextEditorLink:"var(--graphy-font-text-editor-link)",fontHighlightModeTitle:"var(--graphy-font-highlight-mode-title)",fontHighlightModeSubtitle:"var(--graphy-font-highlight-mode-subtitle)"},Te="_1rkj4kp0",Ee="_1rkj4kp1";const Le=({theme:e,children:t,className:r,style:o})=>{const n=h.useMemo(()=>{if(!e)return o;const a={};for(const[s,c]of Object.entries(e))c!==void 0&&(a[K[s]]=c);return{...o,...J.assignInlineVars(a)}},[e,o]);return i.jsx("div",{className:N(Te,r),style:n,children:t})};exports.CanvasTextMeasurer=C;exports.GraphRenderer=be;exports.ThemeProvider=Le;exports.darkTheme=Ee;exports.useTextMeasurer=z;exports.vars=K;
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._12eci1n0{position:absolute;bottom:0;left:0}._1mf2q6u0{margin:0}._1q25vjj0{position:absolute;top:0;left:0}.pr8m7u0{position:relative;pointer-events:none;height:100%}.pr8m7u1{position:absolute;transform:translateY(-50%);font:var(--graphy-font-legend-label);color:var(--graphy-legend-text-color);white-space:nowrap}._2hq2f70{position:absolute;pointer-events:none}.x9xdzb0{display:flex;flex-direction:column;gap:8px;pointer-events:none;font:var(--graphy-font-legend-label);color:var(--graphy-legend-text-color)}.x9xdzb1{display:flex;flex-wrap:nowrap;justify-content:center;align-items:center}.x9xdzb2{flex-direction:row;gap:16px}.x9xdzb3{flex-direction:column;gap:8px;height:100%}.x9xdzb4{display:flex;align-items:center;gap:8px;white-space:nowrap}.x9xdzb5{display:inline-block;width:12px;height:12px;border-radius:2px}.x9xdzb6{border-radius:50%;opacity:.7}.wyi2w10{fill:var(--graphy-text-primary)}._1wf5x370{overflow:visible}._1ymbsoj0{position:absolute;top:0;left:0;overflow:visible}.znp3wr0{position:relative;background:var(--graphy-graph-background);color:var(--graphy-text-primary)}._1rkj4kp0{--graphy-transparent: transparent;--graphy-white: #ffffff;--graphy-black: #000000;--graphy-grey-100: #FFFFFF;--graphy-grey-95: #FCFCFC;--graphy-grey-90: #FAFAFA;--graphy-grey-85: #F5F5F5;--graphy-grey-80: #F0F0F0;--graphy-grey-75: #e8e8e8;--graphy-grey-70: #E5E5E5;--graphy-grey-60: #CCCCCC;--graphy-grey-50: #C4C4C4;--graphy-grey-0: #1D2129;--graphy-red-60: #E14B49;--graphy-red-50: #F93939;--graphy-amber-70: #FFBA8C;--graphy-amber-50: #FFC849;--graphy-amber-40: #FEAE47;--graphy-amber-30: #e7a816;--graphy-green-60: #06B299;--graphy-green-50: #42CD69;--graphy-blue-80: #2E62FF;--graphy-blue-60: #3D70FF;--graphy-purple-50: #7B56EA;--graphy-purple-30: #E093FE;--graphy-grey-gradient-80: linear-gradient(to top, #F0F0F1, #F9F9FF);--graphy-text-primary: var(--graphy-black);--graphy-text-secondary: color-mix(in srgb, transparent, var(--graphy-text-primary) 60%);--graphy-text-disabled: color-mix(in srgb, transparent, var(--graphy-text-primary) 50%);--graphy-icon-primary: currentColor;--graphy-icon-secondary: color-mix(in srgb, transparent, var(--graphy-text-primary) 60%);--graphy-icon-sticker-background: var(--graphy-grey-100);--graphy-brand: var(--graphy-purple-50);--graphy-success: var(--graphy-green-50);--graphy-warning: var(--graphy-amber-50);--graphy-alert: var(--graphy-red-50);--graphy-border-100: var(--graphy-grey-0);--graphy-border-10: color-mix(in srgb, transparent, var(--graphy-grey-0) 10%);--graphy-sunken-background: var(--graphy-grey-90);--graphy-default-background: var(--graphy-grey-100);--graphy-raised-background: var(--graphy-grey-85);--graphy-overlay-background: var(--graphy-grey-100);--graphy-overlay-border-gradient: none;--graphy-graph-background: var(--graphy-grey-100);--graphy-grid-line-color: var(--graphy-border-10);--graphy-hover-guide-line-color: var(--graphy-grey-0);--graphy-origin-line-color: var(--graphy-grey-0);--graphy-target-line-color: var(--graphy-border-100);--graphy-target-line-marker-color: #A0A6C5;--graphy-legend-background: var(--graphy-default-background);--graphy-legend-border-color: var(--graphy-border-10);--graphy-legend-text-color: var(--graphy-text-primary);--graphy-dimmed-series-label-text-color: var(--graphy-text-disabled);--graphy-dimmed-series-label-line-color: var(--graphy-grey-60);--graphy-trend-negative-color: var(--graphy-red-60);--graphy-trend-positive-color: var(--graphy-green-60);--graphy-tooltip-background: #333;--graphy-tooltip-border-color: #47474B;--graphy-tooltip-heading-text-color: #fff;--graphy-tooltip-label-text-color: #d5d6d9;--graphy-tooltip-value-text-color: #fff;--graphy-heatmap-empty-tile-background: var(--graphy-grey-80);--graphy-stacked-bar-hover-border-color: var(--graphy-grey-0);--graphy-default-arrow-annotation-color: var(--graphy-black);--graphy-annotation-frame-border-color: var(--graphy-blue-60);--graphy-annotation-menu-trigger-icon-color: #3d414c;--graphy-font-family-default: "Inter", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", "NotoSansArabic", "NotoSansJP", "NotoSansSC", "NotoSansKR", "NotoSerifKR", sans-serif, "Apple Color Emoji", "NotoColorEmoji";--graphy-font-family-heading: "Inter", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", "NotoSansArabic", "NotoSansJP", "NotoSansSC", "NotoSansKR", "NotoSerifKR", sans-serif, "Apple Color Emoji", "NotoColorEmoji";--graphy-font-weight-regular: 400;--graphy-font-weight-medium: 500;--graphy-font-weight-semibold: 600;--graphy-font-weight-bold: 700;--graphy-font-xxs: 1em/1;--graphy-font-xs: 1.1em/1;--graphy-font-sm: 1.2em/1.3 ;--graphy-font-md: 1.4em/1.43;--graphy-font-lg: 1.6em/1 ;--graphy-font-xl: 2em/1;--graphy-font-editor-body: 1.5em/1.47;--graphy-font-heading-sm: 1.8em/1.25;--graphy-font-heading-md: 2.2em/1.41;--graphy-font-heading-lg: 2.8em/1.29;--graphy-font-tick-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-axis-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-data-label: var(--graphy-font-weight-medium) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-stack-total: var(--graphy-font-weight-semibold) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-legend-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-series-label: var(--graphy-font-weight-semibold) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-label: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-heading: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-footer: var(--graphy-font-weight-regular) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-jumbo-tooltip-label: var(--graphy-font-weight-regular) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-jumbo-tooltip: var(--graphy-font-weight-medium) var(--graphy-font-heading-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-mini-tooltip-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-mini-tooltip-footer: var(--graphy-font-weight-regular) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-caption: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-caption-small: var(--graphy-font-weight-medium) var(--graphy-font-xxs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-uitooltip: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-uitooltip-secondary: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-trend-tag: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-trend-tag-small: var(--graphy-font-weight-medium) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-goal-line-label: var(--graphy-font-weight-medium) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-pie-label: var(--graphy-font-weight-medium) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-pie-chart-total: var(--graphy-font-weight-bold) var(--graphy-font-heading-lg) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-difference-arrow-small: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-difference-arrow-medium: var(--graphy-font-weight-medium) var(--graphy-font-lg) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-difference-arrow-large: var(--graphy-font-weight-semibold) var(--graphy-font-xl) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-button: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-input: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-input-label: var(--graphy-font-weight-medium) var(--graphy-font-xxs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-select-label: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-select-description: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-color-select-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-menu-title: var(--graphy-font-weight-semibold) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-menu-group-title: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-menu-item-label: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-menu-item-label-secondary: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-error-boundary-title: var(--graphy-font-weight-semibold) var(--graphy-font-heading-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-error-boundary-message: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-table-cell: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-table-header-cell: var(--graphy-font-weight-semibold) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-source-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-source-link: var(--graphy-font-weight-regular) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-text-editor-h1: var(--graphy-font-weight-bold) var(--graphy-font-heading-lg) var(--typography-chart-heading-font-family, var(--graphy-font-family-heading));--graphy-font-text-editor-h2: var(--graphy-font-weight-bold) var(--graphy-font-heading-md) var(--typography-chart-heading-font-family, var(--graphy-font-family-heading));--graphy-font-text-editor-h3: var(--graphy-font-weight-semibold) var(--graphy-font-heading-sm) var(--typography-chart-heading-font-family, var(--graphy-font-family-heading));--graphy-font-text-editor-h6: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-text-editor-body: var(--graphy-font-weight-medium) var(--graphy-font-editor-body) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-text-editor-link: var(--graphy-font-weight-regular) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-highlight-mode-title: var(--graphy-font-weight-bold) var(--graphy-font-md) var(--graphy-font-family-default);--graphy-font-highlight-mode-subtitle: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--graphy-font-family-default)}._1rkj4kp1{--graphy-transparent: transparent;--graphy-white: #ffffff;--graphy-black: #000000;--graphy-grey-100: #000000;--graphy-grey-95: #0D0D0D;--graphy-grey-90: #1A1A1A;--graphy-grey-85: #1F1F1F;--graphy-grey-80: #2A2A2A;--graphy-grey-75: #2e2e2e;--graphy-grey-70: #353535;--graphy-grey-60: #494949;--graphy-grey-50: #6F6F6F;--graphy-grey-0: #ffffff;--graphy-red-60: #CB3333;--graphy-red-50: #F93939;--graphy-amber-70: #f48135;--graphy-amber-50: #FEAE47;--graphy-amber-40: #FFC849;--graphy-amber-30: #ffd061;--graphy-green-60: #0AC600;--graphy-green-50: #42CD69;--graphy-blue-80: #2E62FF;--graphy-blue-60: #3D70FF;--graphy-purple-50: #7B56EA;--graphy-purple-30: #E093FE;--graphy-grey-gradient-80: linear-gradient(to top, #222429, #31353f);--graphy-text-primary: var(--graphy-grey-0);--graphy-text-secondary: color-mix(in srgb, transparent, var(--graphy-text-primary) 80%);--graphy-text-disabled: color-mix(in srgb, transparent, var(--graphy-text-primary) 50%);--graphy-icon-primary: currentColor;--graphy-icon-secondary: color-mix(in srgb, transparent, var(--graphy-text-primary) 60%);--graphy-icon-sticker-background: var(--graphy-grey-70);--graphy-border-100: var(--graphy-grey-0);--graphy-border-10: color-mix(in srgb, transparent, var(--graphy-grey-0) 10%);--graphy-brand: var(--graphy-purple-50);--graphy-success: var(--graphy-green-50);--graphy-warning: var(--graphy-amber-50);--graphy-alert: var(--graphy-red-50);--graphy-sunken-background: var(--graphy-grey-100);--graphy-default-background: var(--graphy-grey-90);--graphy-raised-background: var(--graphy-grey-80);--graphy-overlay-background: var(--graphy-grey-90);--graphy-overlay-border-gradient: var(--graphy-grey-gradient-80);--graphy-graph-background: var(--graphy-grey-100);--graphy-grid-line-color: var(--graphy-border-10);--graphy-hover-guide-line-color: var(--graphy-grey-0);--graphy-origin-line-color: var(--graphy-grey-0);--graphy-target-line-color: var(--graphy-border-100);--graphy-target-line-marker-color: var(--graphy-border-100);--graphy-legend-background: var(--graphy-default-background);--graphy-legend-border-color: color-mix(in srgb, transparent, var(--graphy-grey-0) 10%);--graphy-legend-text-color: var(--graphy-text-primary);--graphy-dimmed-series-label-text-color: var(--graphy-text-disabled);--graphy-dimmed-series-label-line-color: var(--graphy-grey-60);--graphy-trend-negative-color: var(--graphy-red-60);--graphy-trend-positive-color: var(--graphy-green-60);--graphy-tooltip-background: var(--graphy-grey-70);--graphy-tooltip-border-color: var(--graphy-grey-60);--graphy-tooltip-heading-text-color: var(--graphy-text-primary);--graphy-tooltip-label-text-color: var(--graphy-text-secondary);--graphy-tooltip-value-text-color: var(--graphy-text-primary);--graphy-heatmap-empty-tile-background: var(--graphy-grey-80);--graphy-stacked-bar-hover-border-color: var(--graphy-grey-0);--graphy-default-arrow-annotation-color: var(--graphy-white);--graphy-annotation-frame-border-color: var(--graphy-blue-60);--graphy-annotation-menu-trigger-icon-color: var(--graphy-white);--graphy-font-family-default: "Inter", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", "NotoSansArabic", "NotoSansJP", "NotoSansSC", "NotoSansKR", "NotoSerifKR", sans-serif, "Apple Color Emoji", "NotoColorEmoji";--graphy-font-family-heading: "Inter", -apple-system, BlinkMacSystemFont, "Open Sans", "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", "NotoSansArabic", "NotoSansJP", "NotoSansSC", "NotoSansKR", "NotoSerifKR", sans-serif, "Apple Color Emoji", "NotoColorEmoji";--graphy-font-weight-regular: 400;--graphy-font-weight-medium: 500;--graphy-font-weight-semibold: 600;--graphy-font-weight-bold: 700;--graphy-font-xxs: 1em/1;--graphy-font-xs: 1.1em/1;--graphy-font-sm: 1.2em/1.3 ;--graphy-font-md: 1.4em/1.43;--graphy-font-lg: 1.6em/1 ;--graphy-font-xl: 2em/1;--graphy-font-editor-body: 1.5em/1.47;--graphy-font-heading-sm: 1.8em/1.25;--graphy-font-heading-md: 2.2em/1.41;--graphy-font-heading-lg: 2.8em/1.29;--graphy-font-tick-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-axis-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-data-label: var(--graphy-font-weight-medium) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-stack-total: var(--graphy-font-weight-semibold) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-legend-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-series-label: var(--graphy-font-weight-semibold) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-label: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-heading: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-footer: var(--graphy-font-weight-regular) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-jumbo-tooltip-label: var(--graphy-font-weight-regular) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-jumbo-tooltip: var(--graphy-font-weight-medium) var(--graphy-font-heading-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-mini-tooltip-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-mini-tooltip-footer: var(--graphy-font-weight-regular) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-caption: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-tooltip-caption-small: var(--graphy-font-weight-medium) var(--graphy-font-xxs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-uitooltip: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-uitooltip-secondary: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-trend-tag: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-trend-tag-small: var(--graphy-font-weight-medium) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-goal-line-label: var(--graphy-font-weight-medium) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-pie-label: var(--graphy-font-weight-medium) var(--graphy-font-xs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-pie-chart-total: var(--graphy-font-weight-bold) var(--graphy-font-heading-lg) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-difference-arrow-small: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-difference-arrow-medium: var(--graphy-font-weight-medium) var(--graphy-font-lg) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-difference-arrow-large: var(--graphy-font-weight-semibold) var(--graphy-font-xl) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-button: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-input: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-input-label: var(--graphy-font-weight-medium) var(--graphy-font-xxs) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-select-label: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-select-description: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-color-select-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-menu-title: var(--graphy-font-weight-semibold) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-menu-group-title: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-menu-item-label: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-menu-item-label-secondary: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-error-boundary-title: var(--graphy-font-weight-semibold) var(--graphy-font-heading-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-error-boundary-message: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-table-cell: var(--graphy-font-weight-medium) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-table-header-cell: var(--graphy-font-weight-semibold) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-source-label: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-source-link: var(--graphy-font-weight-regular) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-text-editor-h1: var(--graphy-font-weight-bold) var(--graphy-font-heading-lg) var(--typography-chart-heading-font-family, var(--graphy-font-family-heading));--graphy-font-text-editor-h2: var(--graphy-font-weight-bold) var(--graphy-font-heading-md) var(--typography-chart-heading-font-family, var(--graphy-font-family-heading));--graphy-font-text-editor-h3: var(--graphy-font-weight-semibold) var(--graphy-font-heading-sm) var(--typography-chart-heading-font-family, var(--graphy-font-family-heading));--graphy-font-text-editor-h6: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-text-editor-body: var(--graphy-font-weight-medium) var(--graphy-font-editor-body) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-text-editor-link: var(--graphy-font-weight-regular) var(--graphy-font-md) var(--typography-chart-font-family, var(--graphy-font-family-default));--graphy-font-highlight-mode-title: var(--graphy-font-weight-bold) var(--graphy-font-md) var(--graphy-font-family-default);--graphy-font-highlight-mode-subtitle: var(--graphy-font-weight-medium) var(--graphy-font-sm) var(--graphy-font-family-default)}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { FontSpec } from '@graphysdk/viz-engine';
|
|
3
|
+
import { JSX } from 'react/jsx-runtime';
|
|
4
|
+
import { MeasuredText } from '@graphysdk/viz-engine';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { SpecInput } from '@graphysdk/viz-engine';
|
|
7
|
+
import { TextMeasurer } from '@graphysdk/viz-engine';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Browser text measurer backed by OffscreenCanvas.
|
|
11
|
+
*
|
|
12
|
+
* Uses the same Canvas `measureText()` API that the rendering engine uses,
|
|
13
|
+
* ensuring measurement/rendering consistency.
|
|
14
|
+
*
|
|
15
|
+
* **Font loading:** Use the async `create()` factory to ensure all declared
|
|
16
|
+
* `@font-face` fonts are loaded before any measurements. This avoids
|
|
17
|
+
* measuring against fallback fonts and caching incorrect widths.
|
|
18
|
+
* The sync constructor is available for controlled environments where font
|
|
19
|
+
* readiness is managed externally (e.g. backend with pre-registered fonts).
|
|
20
|
+
*
|
|
21
|
+
* Includes an emoji correction that compensates for the known discrepancy
|
|
22
|
+
* where Canvas `measureText()` reports wider widths for emoji than the DOM
|
|
23
|
+
* actually renders (Chrome/Firefox at font sizes < ~24px). The correction
|
|
24
|
+
* is computed once per font by comparing Canvas vs DOM measurement of a
|
|
25
|
+
* reference emoji, then cached.
|
|
26
|
+
*/
|
|
27
|
+
export declare class CanvasTextMeasurer implements TextMeasurer {
|
|
28
|
+
private readonly ctx;
|
|
29
|
+
/**
|
|
30
|
+
* Caches the per-font emoji correction factor.
|
|
31
|
+
*/
|
|
32
|
+
private readonly emojiCorrections;
|
|
33
|
+
/**
|
|
34
|
+
* Tracks the last font string set on the context.
|
|
35
|
+
*/
|
|
36
|
+
private currentFont;
|
|
37
|
+
constructor();
|
|
38
|
+
/**
|
|
39
|
+
* Creates a CanvasTextMeasurer after all declared `@font-face` fonts
|
|
40
|
+
* have finished loading. This ensures measurements use the correct font
|
|
41
|
+
* glyphs from the first call, avoiding stale cache entries.
|
|
42
|
+
*
|
|
43
|
+
* Falls back to immediate construction if `document.fonts` is unavailable
|
|
44
|
+
* (e.g. non-browser environment).
|
|
45
|
+
*
|
|
46
|
+
* Note: document.fonts.ready still resolves even if some fonts fail to load.
|
|
47
|
+
*/
|
|
48
|
+
static create(): Promise<CanvasTextMeasurer>;
|
|
49
|
+
measureText(text: string, font: FontSpec): MeasuredText;
|
|
50
|
+
/**
|
|
51
|
+
* Skip redundant `ctx.font` assignments
|
|
52
|
+
* Setting the property triggers CSS font string parsing and font resolution.
|
|
53
|
+
*/
|
|
54
|
+
private setFont;
|
|
55
|
+
/**
|
|
56
|
+
* Computes the per-emoji width correction for a given font.
|
|
57
|
+
* Measures the reference emoji in both Canvas and DOM, caches the difference.
|
|
58
|
+
* Returns 0 if DOM is unavailable or the difference is negligible (< 0.5px).
|
|
59
|
+
*/
|
|
60
|
+
private getEmojiCorrection;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export declare const darkTheme: string;
|
|
64
|
+
|
|
65
|
+
export declare const GraphRenderer: ({ spec, width, height, isAnimated }: GraphRendererProps) => JSX.Element | null;
|
|
66
|
+
|
|
67
|
+
declare interface GraphRendererProps {
|
|
68
|
+
spec: SpecInput;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
isAnimated?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export declare type ThemeKey = keyof ThemeValues;
|
|
75
|
+
|
|
76
|
+
export declare type ThemeOverrides = Partial<ThemeValues>;
|
|
77
|
+
|
|
78
|
+
export declare const ThemeProvider: ({ theme, children, className, style }: ThemeProviderProps) => JSX.Element;
|
|
79
|
+
|
|
80
|
+
declare interface ThemeProviderProps {
|
|
81
|
+
theme?: ThemeOverrides;
|
|
82
|
+
children: ReactNode;
|
|
83
|
+
className?: string;
|
|
84
|
+
style?: CSSProperties;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare type ThemeValues = Record<keyof typeof vars, string>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* React hook that returns a font-ready, cached CanvasTextMeasurer.
|
|
91
|
+
*
|
|
92
|
+
* Returns `null` until `document.fonts.ready` resolves and the measurer
|
|
93
|
+
* is constructed. Consumers should gate rendering on a non-null value:
|
|
94
|
+
*
|
|
95
|
+
* ```tsx
|
|
96
|
+
* const measurer = useTextMeasurer();
|
|
97
|
+
* if (!measurer) return null; // fonts still loading
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* Re-creates the measurer when additional fonts finish loading (e.g. in
|
|
101
|
+
* iframes where `document.fonts.ready` resolves before stylesheets inject
|
|
102
|
+
* their `@font-face` rules). The new instance gets a fresh cache so stale
|
|
103
|
+
* measurements from fallback fonts are discarded.
|
|
104
|
+
*
|
|
105
|
+
* Falls back to HeuristicTextMeasurer if OffscreenCanvas is unavailable.
|
|
106
|
+
*/
|
|
107
|
+
export declare const useTextMeasurer: () => TextMeasurer | null;
|
|
108
|
+
|
|
109
|
+
export declare const vars: {
|
|
110
|
+
white: `var(--${string})`;
|
|
111
|
+
black: `var(--${string})`;
|
|
112
|
+
transparent: `var(--${string})`;
|
|
113
|
+
grey100: `var(--${string})`;
|
|
114
|
+
grey95: `var(--${string})`;
|
|
115
|
+
grey90: `var(--${string})`;
|
|
116
|
+
grey85: `var(--${string})`;
|
|
117
|
+
grey80: `var(--${string})`;
|
|
118
|
+
grey75: `var(--${string})`;
|
|
119
|
+
grey70: `var(--${string})`;
|
|
120
|
+
grey60: `var(--${string})`;
|
|
121
|
+
grey50: `var(--${string})`;
|
|
122
|
+
grey0: `var(--${string})`;
|
|
123
|
+
greyGradient80: `var(--${string})`;
|
|
124
|
+
green60: `var(--${string})`;
|
|
125
|
+
green50: `var(--${string})`;
|
|
126
|
+
red60: `var(--${string})`;
|
|
127
|
+
red50: `var(--${string})`;
|
|
128
|
+
amber70: `var(--${string})`;
|
|
129
|
+
amber50: `var(--${string})`;
|
|
130
|
+
amber40: `var(--${string})`;
|
|
131
|
+
amber30: `var(--${string})`;
|
|
132
|
+
blue80: `var(--${string})`;
|
|
133
|
+
blue60: `var(--${string})`;
|
|
134
|
+
purple50: `var(--${string})`;
|
|
135
|
+
purple30: `var(--${string})`;
|
|
136
|
+
brand: `var(--${string})`;
|
|
137
|
+
success: `var(--${string})`;
|
|
138
|
+
warning: `var(--${string})`;
|
|
139
|
+
alert: `var(--${string})`;
|
|
140
|
+
textPrimary: `var(--${string})`;
|
|
141
|
+
textSecondary: `var(--${string})`;
|
|
142
|
+
textDisabled: `var(--${string})`;
|
|
143
|
+
iconPrimary: `var(--${string})`;
|
|
144
|
+
iconSecondary: `var(--${string})`;
|
|
145
|
+
iconStickerBackground: `var(--${string})`;
|
|
146
|
+
border100: `var(--${string})`;
|
|
147
|
+
border10: `var(--${string})`;
|
|
148
|
+
sunkenBackground: `var(--${string})`;
|
|
149
|
+
defaultBackground: `var(--${string})`;
|
|
150
|
+
raisedBackground: `var(--${string})`;
|
|
151
|
+
overlayBackground: `var(--${string})`;
|
|
152
|
+
overlayBorderGradient: `var(--${string})`;
|
|
153
|
+
graphBackground: `var(--${string})`;
|
|
154
|
+
gridLineColor: `var(--${string})`;
|
|
155
|
+
hoverGuideLineColor: `var(--${string})`;
|
|
156
|
+
originLineColor: `var(--${string})`;
|
|
157
|
+
targetLineColor: `var(--${string})`;
|
|
158
|
+
targetLineMarkerColor: `var(--${string})`;
|
|
159
|
+
legendBackground: `var(--${string})`;
|
|
160
|
+
legendBorderColor: `var(--${string})`;
|
|
161
|
+
legendTextColor: `var(--${string})`;
|
|
162
|
+
dimmedSeriesLabelTextColor: `var(--${string})`;
|
|
163
|
+
dimmedSeriesLabelLineColor: `var(--${string})`;
|
|
164
|
+
trendNegativeColor: `var(--${string})`;
|
|
165
|
+
trendPositiveColor: `var(--${string})`;
|
|
166
|
+
tooltipBackground: `var(--${string})`;
|
|
167
|
+
tooltipBorderColor: `var(--${string})`;
|
|
168
|
+
tooltipHeadingTextColor: `var(--${string})`;
|
|
169
|
+
tooltipLabelTextColor: `var(--${string})`;
|
|
170
|
+
tooltipValueTextColor: `var(--${string})`;
|
|
171
|
+
heatmapEmptyTileBackground: `var(--${string})`;
|
|
172
|
+
stackedBarHoverBorderColor: `var(--${string})`;
|
|
173
|
+
defaultArrowAnnotationColor: `var(--${string})`;
|
|
174
|
+
annotationFrameBorderColor: `var(--${string})`;
|
|
175
|
+
annotationMenuTriggerIconColor: `var(--${string})`;
|
|
176
|
+
fontFamilyDefault: `var(--${string})`;
|
|
177
|
+
fontFamilyHeading: `var(--${string})`;
|
|
178
|
+
fontWeightRegular: `var(--${string})`;
|
|
179
|
+
fontWeightMedium: `var(--${string})`;
|
|
180
|
+
fontWeightSemibold: `var(--${string})`;
|
|
181
|
+
fontWeightBold: `var(--${string})`;
|
|
182
|
+
fontXxs: `var(--${string})`;
|
|
183
|
+
fontXs: `var(--${string})`;
|
|
184
|
+
fontSm: `var(--${string})`;
|
|
185
|
+
fontMd: `var(--${string})`;
|
|
186
|
+
fontLg: `var(--${string})`;
|
|
187
|
+
fontXl: `var(--${string})`;
|
|
188
|
+
fontEditorBody: `var(--${string})`;
|
|
189
|
+
fontHeadingSm: `var(--${string})`;
|
|
190
|
+
fontHeadingMd: `var(--${string})`;
|
|
191
|
+
fontHeadingLg: `var(--${string})`;
|
|
192
|
+
fontTickLabel: `var(--${string})`;
|
|
193
|
+
fontAxisLabel: `var(--${string})`;
|
|
194
|
+
fontDataLabel: `var(--${string})`;
|
|
195
|
+
fontStackTotal: `var(--${string})`;
|
|
196
|
+
fontLegendLabel: `var(--${string})`;
|
|
197
|
+
fontSeriesLabel: `var(--${string})`;
|
|
198
|
+
fontTooltipLabel: `var(--${string})`;
|
|
199
|
+
fontTooltipHeading: `var(--${string})`;
|
|
200
|
+
fontTooltipFooter: `var(--${string})`;
|
|
201
|
+
fontJumboTooltipLabel: `var(--${string})`;
|
|
202
|
+
fontJumboTooltip: `var(--${string})`;
|
|
203
|
+
fontMiniTooltipLabel: `var(--${string})`;
|
|
204
|
+
fontMiniTooltipFooter: `var(--${string})`;
|
|
205
|
+
fontTooltipCaption: `var(--${string})`;
|
|
206
|
+
fontTooltipCaptionSmall: `var(--${string})`;
|
|
207
|
+
fontTrendTag: `var(--${string})`;
|
|
208
|
+
fontTrendTagSmall: `var(--${string})`;
|
|
209
|
+
fontGoalLineLabel: `var(--${string})`;
|
|
210
|
+
fontPieLabel: `var(--${string})`;
|
|
211
|
+
fontPieChartTotal: `var(--${string})`;
|
|
212
|
+
fontDifferenceArrowSmall: `var(--${string})`;
|
|
213
|
+
fontDifferenceArrowMedium: `var(--${string})`;
|
|
214
|
+
fontDifferenceArrowLarge: `var(--${string})`;
|
|
215
|
+
fontButton: `var(--${string})`;
|
|
216
|
+
fontInput: `var(--${string})`;
|
|
217
|
+
fontInputLabel: `var(--${string})`;
|
|
218
|
+
fontSelectLabel: `var(--${string})`;
|
|
219
|
+
fontSelectDescription: `var(--${string})`;
|
|
220
|
+
fontColorSelectLabel: `var(--${string})`;
|
|
221
|
+
fontMenuTitle: `var(--${string})`;
|
|
222
|
+
fontMenuGroupTitle: `var(--${string})`;
|
|
223
|
+
fontMenuItemLabel: `var(--${string})`;
|
|
224
|
+
fontMenuItemLabelSecondary: `var(--${string})`;
|
|
225
|
+
fontUITooltip: `var(--${string})`;
|
|
226
|
+
fontUITooltipSecondary: `var(--${string})`;
|
|
227
|
+
fontErrorBoundaryTitle: `var(--${string})`;
|
|
228
|
+
fontErrorBoundaryMessage: `var(--${string})`;
|
|
229
|
+
fontTableCell: `var(--${string})`;
|
|
230
|
+
fontTableHeaderCell: `var(--${string})`;
|
|
231
|
+
fontSourceLabel: `var(--${string})`;
|
|
232
|
+
fontSourceLink: `var(--${string})`;
|
|
233
|
+
fontTextEditorH1: `var(--${string})`;
|
|
234
|
+
fontTextEditorH2: `var(--${string})`;
|
|
235
|
+
fontTextEditorH3: `var(--${string})`;
|
|
236
|
+
fontTextEditorH6: `var(--${string})`;
|
|
237
|
+
fontTextEditorBody: `var(--${string})`;
|
|
238
|
+
fontTextEditorLink: `var(--${string})`;
|
|
239
|
+
fontHighlightModeTitle: `var(--${string})`;
|
|
240
|
+
fontHighlightModeSubtitle: `var(--${string})`;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,836 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsx as s, jsxs as p, Fragment as C } from "react/jsx-runtime";
|
|
3
|
+
import { useMotionValue as X, animate as ut, motion as _, useSpring as $, useReducedMotion as gt } from "motion/react";
|
|
4
|
+
import { useState as Z, useEffect as w, useMemo as y, memo as k, useRef as O, useLayoutEffect as ht } from "react";
|
|
5
|
+
import { DEFAULT_FONT_STYLE as pt, DEFAULT_FONT_WEIGHT as ft, CachedTextMeasurer as V, HeuristicTextMeasurer as yt, LayoutCompiler as mt, DEFAULT_COLOR_PALETTE as I, getStrokeWidth as J, createXValueReader as vt, getGroup as xt, getX as L, getYMin as q, GROUP_VARIABLES as Q, getY as T, getColor as R, getAlpha as F, getYMax as tt, getXMin as bt, getXMax as Lt, getSize as Tt, getStartAngle as Et, getEndAngle as At, getInnerRadius as _t, getOuterRadius as kt, compile as wt } from "@graphysdk/viz-engine";
|
|
6
|
+
import St, { clsx as Ct } from "clsx";
|
|
7
|
+
import { curveCatmullRom as It, curveLinear as Rt, area as Ft, line as et, arc as Dt } from "d3-shape";
|
|
8
|
+
import { interpolatePath as Nt } from "d3-interpolate-path";
|
|
9
|
+
import { assignInlineVars as Bt } from "@vanilla-extract/dynamic";
|
|
10
|
+
typeof window < "u" && (window.__GRAPHY_SDK__ ??= {}, window.__GRAPHY_SDK__.reactRenderer = "0.0.1");
|
|
11
|
+
const Pt = /\p{Emoji_Presentation}|\p{Emoji}\uFE0F/gu, rt = "😀";
|
|
12
|
+
class H {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.emojiCorrections = /* @__PURE__ */ new Map(), this.currentFont = "";
|
|
15
|
+
const r = new OffscreenCanvas(1, 1).getContext("2d");
|
|
16
|
+
if (!r)
|
|
17
|
+
throw new Error("Failed to create OffscreenCanvas 2D context");
|
|
18
|
+
this.ctx = r;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a CanvasTextMeasurer after all declared `@font-face` fonts
|
|
22
|
+
* have finished loading. This ensures measurements use the correct font
|
|
23
|
+
* glyphs from the first call, avoiding stale cache entries.
|
|
24
|
+
*
|
|
25
|
+
* Falls back to immediate construction if `document.fonts` is unavailable
|
|
26
|
+
* (e.g. non-browser environment).
|
|
27
|
+
*
|
|
28
|
+
* Note: document.fonts.ready still resolves even if some fonts fail to load.
|
|
29
|
+
*/
|
|
30
|
+
static async create() {
|
|
31
|
+
return typeof document < "u" && document.fonts && await document.fonts.ready, new H();
|
|
32
|
+
}
|
|
33
|
+
measureText(t, r) {
|
|
34
|
+
const o = Gt(r);
|
|
35
|
+
this.setFont(o);
|
|
36
|
+
const { width: n, fontBoundingBoxAscent: a, fontBoundingBoxDescent: i } = this.ctx.measureText(t);
|
|
37
|
+
let l = n;
|
|
38
|
+
const c = Mt(t);
|
|
39
|
+
if (c > 0) {
|
|
40
|
+
const d = this.getEmojiCorrection(o);
|
|
41
|
+
l -= d * c;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
width: l,
|
|
45
|
+
height: a + i,
|
|
46
|
+
ascent: a,
|
|
47
|
+
descent: i
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Skip redundant `ctx.font` assignments
|
|
52
|
+
* Setting the property triggers CSS font string parsing and font resolution.
|
|
53
|
+
*/
|
|
54
|
+
setFont(t) {
|
|
55
|
+
this.currentFont !== t && (this.ctx.font = t, this.currentFont = t);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Computes the per-emoji width correction for a given font.
|
|
59
|
+
* Measures the reference emoji in both Canvas and DOM, caches the difference.
|
|
60
|
+
* Returns 0 if DOM is unavailable or the difference is negligible (< 0.5px).
|
|
61
|
+
*/
|
|
62
|
+
getEmojiCorrection(t) {
|
|
63
|
+
const r = this.emojiCorrections.get(t);
|
|
64
|
+
if (r !== void 0) return r;
|
|
65
|
+
this.setFont(t);
|
|
66
|
+
const o = this.ctx.measureText(rt).width, n = Ot(t);
|
|
67
|
+
let a = 0;
|
|
68
|
+
if (n !== null) {
|
|
69
|
+
const i = o - n;
|
|
70
|
+
a = i > 0.5 ? i : 0;
|
|
71
|
+
}
|
|
72
|
+
return this.emojiCorrections.set(t, a), a;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const Mt = (e) => {
|
|
76
|
+
const t = e.match(Pt);
|
|
77
|
+
return t ? t.length : 0;
|
|
78
|
+
}, Ot = (e) => {
|
|
79
|
+
const t = zt();
|
|
80
|
+
return t ? (t.style.font = e, t.getBoundingClientRect().width) : null;
|
|
81
|
+
};
|
|
82
|
+
function Gt(e) {
|
|
83
|
+
const t = e.style ?? pt, r = e.weight ?? ft;
|
|
84
|
+
return `${t} ${r} ${e.size}px '${e.family}'`;
|
|
85
|
+
}
|
|
86
|
+
let b = null;
|
|
87
|
+
const zt = () => typeof document > "u" ? null : (b || (b = document.createElement("span"), b.style.position = "absolute", b.style.visibility = "hidden", b.style.whiteSpace = "nowrap", b.style.left = "-9999px", b.textContent = rt, document.body.appendChild(b)), b), Wt = () => {
|
|
88
|
+
const [e, t] = Z(null);
|
|
89
|
+
return w(() => {
|
|
90
|
+
let r = !1;
|
|
91
|
+
const o = () => {
|
|
92
|
+
r || t(Ht());
|
|
93
|
+
};
|
|
94
|
+
return (async () => {
|
|
95
|
+
typeof document < "u" && document.fonts && await document.fonts.ready, o();
|
|
96
|
+
})(), typeof document < "u" && document.fonts && document.fonts.addEventListener("loadingdone", o), () => {
|
|
97
|
+
r = !0, typeof document < "u" && document.fonts && document.fonts.removeEventListener("loadingdone", o);
|
|
98
|
+
};
|
|
99
|
+
}, []), e;
|
|
100
|
+
}, Ht = () => {
|
|
101
|
+
try {
|
|
102
|
+
return new V(new H());
|
|
103
|
+
} catch {
|
|
104
|
+
return new V(new yt());
|
|
105
|
+
}
|
|
106
|
+
}, Ut = 12, $t = "sans-serif", Vt = {
|
|
107
|
+
family: $t,
|
|
108
|
+
size: Ut
|
|
109
|
+
}, jt = (e) => (t) => {
|
|
110
|
+
if (!t.isVisible || t.ticks.length === 0) return 0;
|
|
111
|
+
const r = t.position === "top" || t.position === "bottom", o = t.ticks.map((n) => e.measureText(String(n.value), Vt));
|
|
112
|
+
return Math.max(...r ? o.map((n) => n.height) : o.map((n) => n.width));
|
|
113
|
+
}, Yt = 20, Kt = () => () => Yt, Xt = 12, Zt = 8, Jt = 12, qt = "Inter", Qt = {
|
|
114
|
+
family: qt,
|
|
115
|
+
size: Jt
|
|
116
|
+
}, te = Zt + Xt, ee = (e) => (t) => {
|
|
117
|
+
if (t.items.length === 0) return 0;
|
|
118
|
+
const r = t.position === "top" || t.position === "bottom", o = t.items.map((n) => e.measureText(String(n.value), Qt));
|
|
119
|
+
return r ? Math.max(...o.map((n) => n.height)) : Math.max(...o.map((n) => n.width)) + te;
|
|
120
|
+
}, re = ({ spec: e, containerSize: t, externalMeasurements: r }) => {
|
|
121
|
+
const o = Wt(), n = y(() => o ? {
|
|
122
|
+
measureAxis: jt(o),
|
|
123
|
+
measureAxisLabel: Kt(),
|
|
124
|
+
measureLegend: ee(o)
|
|
125
|
+
} : null, [o]);
|
|
126
|
+
return y(() => n ? new mt(n).compile({ guides: e.guides, containerSize: t, externalMeasurements: r }) : null, [e, t, r, n]);
|
|
127
|
+
}, nt = !1, P = (e) => e.text !== void 0 ? e.text : e.content ? e.content.map(P).join("") : "";
|
|
128
|
+
var ne = "_12eci1n0", G = "_1mf2q6u0";
|
|
129
|
+
const oe = ({ ref: e, compiled: t, captionRect: r }) => {
|
|
130
|
+
const { caption: o } = t.config.content;
|
|
131
|
+
return o === null ? null : /* @__PURE__ */ s(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
ref: e,
|
|
135
|
+
className: ne,
|
|
136
|
+
style: {
|
|
137
|
+
width: r.width
|
|
138
|
+
},
|
|
139
|
+
children: /* @__PURE__ */ s("p", { className: G, children: typeof o == "string" ? o : P(o) })
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
var ae = "_1q25vjj0";
|
|
144
|
+
const ie = ({ ref: e, compiled: t, titleRect: r }) => {
|
|
145
|
+
const { title: o, subtitle: n } = t.config.content;
|
|
146
|
+
if (o === null && n === null) return null;
|
|
147
|
+
const a = typeof o == "string" ? o : o !== null ? P(o) : "", i = typeof n == "string" ? n : n !== null ? P(n) : "";
|
|
148
|
+
return /* @__PURE__ */ p(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
ref: e,
|
|
152
|
+
className: ae,
|
|
153
|
+
style: {
|
|
154
|
+
width: r.width
|
|
155
|
+
},
|
|
156
|
+
children: [
|
|
157
|
+
o !== null && /* @__PURE__ */ s("h1", { className: G, children: a }),
|
|
158
|
+
n !== null && /* @__PURE__ */ s("p", { className: G, children: i })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}, f = (e) => `${e * 100}%`;
|
|
163
|
+
function S(e) {
|
|
164
|
+
return 1 - e;
|
|
165
|
+
}
|
|
166
|
+
var se = "pr8m7u0", le = "pr8m7u1";
|
|
167
|
+
const ce = 8, de = ({ legends: e }) => {
|
|
168
|
+
const t = y(() => {
|
|
169
|
+
const r = [];
|
|
170
|
+
for (const o of e)
|
|
171
|
+
for (const n of o.items) {
|
|
172
|
+
if (n.normalizedY === null) continue;
|
|
173
|
+
const a = typeof n.visual.color == "string" ? n.visual.color : void 0;
|
|
174
|
+
r.push({
|
|
175
|
+
key: `${String(n.value)}${a ? `-${a}` : ""}`,
|
|
176
|
+
label: String(n.value),
|
|
177
|
+
color: a,
|
|
178
|
+
x: ce,
|
|
179
|
+
y: f(S(n.normalizedY))
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return r;
|
|
183
|
+
}, [e]);
|
|
184
|
+
return t.length === 0 ? null : /* @__PURE__ */ s("div", { className: se, children: t.map((r) => /* @__PURE__ */ s("span", { className: le, style: { left: r.x, top: r.y, color: r.color }, children: r.label }, r.key)) });
|
|
185
|
+
};
|
|
186
|
+
var ue = "_2hq2f70", ge = "x9xdzb0", he = "x9xdzb1", pe = "x9xdzb2", fe = "x9xdzb3", ot = "x9xdzb4", ye = "x9xdzb5", me = "x9xdzb6";
|
|
187
|
+
const ve = "#9ca3af", xe = ({ legends: e }) => e.length === 0 ? null : /* @__PURE__ */ s("div", { className: ge, children: e.map((t, r) => {
|
|
188
|
+
const o = t.position === "left" || t.position === "right", n = t.aesthetics.includes("size");
|
|
189
|
+
return /* @__PURE__ */ s(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
className: Ct(he, { [fe]: o, [pe]: !o }),
|
|
193
|
+
children: n ? /* @__PURE__ */ s(Le, { legend: t }) : /* @__PURE__ */ s(be, { legend: t })
|
|
194
|
+
},
|
|
195
|
+
r
|
|
196
|
+
);
|
|
197
|
+
}) }), be = ({ legend: e }) => e.items.map((t) => /* @__PURE__ */ p("div", { className: ot, children: [
|
|
198
|
+
/* @__PURE__ */ s("span", { className: ye, style: { backgroundColor: t.visual.color } }),
|
|
199
|
+
/* @__PURE__ */ s("span", { children: String(t.value) })
|
|
200
|
+
] }, `${String(t.value)}${t.visual.color ? `-${t.visual.color}` : ""}`)), Le = ({ legend: e }) => {
|
|
201
|
+
const t = e.items.map((r) => {
|
|
202
|
+
const o = Number(r.visual.size);
|
|
203
|
+
return {
|
|
204
|
+
key: `${String(r.value)}-${o}`,
|
|
205
|
+
label: String(r.value),
|
|
206
|
+
color: typeof r.visual.color == "string" ? r.visual.color : void 0,
|
|
207
|
+
sizeValue: o
|
|
208
|
+
};
|
|
209
|
+
}).filter((r) => Number.isFinite(r.sizeValue) && r.sizeValue > 0);
|
|
210
|
+
return t.length === 0 ? null : t.map((r) => /* @__PURE__ */ p("div", { className: ot, children: [
|
|
211
|
+
/* @__PURE__ */ s(
|
|
212
|
+
"span",
|
|
213
|
+
{
|
|
214
|
+
className: me,
|
|
215
|
+
style: {
|
|
216
|
+
width: r.sizeValue,
|
|
217
|
+
height: r.sizeValue,
|
|
218
|
+
backgroundColor: r.color ?? ve
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
/* @__PURE__ */ s("span", { children: r.label })
|
|
223
|
+
] }, r.key));
|
|
224
|
+
}, Te = k(function({ legends: t, rects: r }) {
|
|
225
|
+
const o = y(() => {
|
|
226
|
+
const n = /* @__PURE__ */ new Map();
|
|
227
|
+
for (const a of t) {
|
|
228
|
+
const i = n.get(a.position);
|
|
229
|
+
i ? i.push(a) : n.set(a.position, [a]);
|
|
230
|
+
}
|
|
231
|
+
return n;
|
|
232
|
+
}, [t]);
|
|
233
|
+
return /* @__PURE__ */ s(C, { children: Array.from(o, ([n, a]) => {
|
|
234
|
+
const i = r[n];
|
|
235
|
+
if (i == null) return null;
|
|
236
|
+
const l = a.filter((d) => d.display === "pill"), c = a.filter((d) => d.display === "direct");
|
|
237
|
+
return /* @__PURE__ */ p(
|
|
238
|
+
"div",
|
|
239
|
+
{
|
|
240
|
+
className: ue,
|
|
241
|
+
style: {
|
|
242
|
+
left: i.x,
|
|
243
|
+
top: i.y,
|
|
244
|
+
width: i.width,
|
|
245
|
+
height: i.height
|
|
246
|
+
},
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ s(xe, { legends: l }),
|
|
249
|
+
/* @__PURE__ */ s(de, { legends: c })
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
n
|
|
253
|
+
);
|
|
254
|
+
}) });
|
|
255
|
+
});
|
|
256
|
+
var at = "wyi2w10";
|
|
257
|
+
const Ee = ({ axisRects: e }) => /* @__PURE__ */ p(C, { children: [
|
|
258
|
+
N("top", e.top),
|
|
259
|
+
N("right", e.right),
|
|
260
|
+
N("bottom", e.bottom),
|
|
261
|
+
N("left", e.left)
|
|
262
|
+
] }), N = (e, t) => t ? /* @__PURE__ */ p("g", { transform: `translate(${t.x}, ${t.y})`, children: [
|
|
263
|
+
nt,
|
|
264
|
+
/* @__PURE__ */ p(
|
|
265
|
+
"text",
|
|
266
|
+
{
|
|
267
|
+
className: at,
|
|
268
|
+
x: t.width / 2,
|
|
269
|
+
y: t.height / 2,
|
|
270
|
+
textAnchor: "middle",
|
|
271
|
+
dominantBaseline: "middle",
|
|
272
|
+
children: [
|
|
273
|
+
e,
|
|
274
|
+
" axis"
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
] }, `axis-${e}`) : null, Ae = ({ axisLabelRects: e }) => /* @__PURE__ */ p(C, { children: [
|
|
279
|
+
B("top", e.top),
|
|
280
|
+
B("right", e.right),
|
|
281
|
+
B("bottom", e.bottom),
|
|
282
|
+
B("left", e.left)
|
|
283
|
+
] }), B = (e, t) => {
|
|
284
|
+
if (!t) return null;
|
|
285
|
+
const r = _e(e, t);
|
|
286
|
+
return /* @__PURE__ */ p("g", { transform: `translate(${t.x}, ${t.y})`, children: [
|
|
287
|
+
nt,
|
|
288
|
+
/* @__PURE__ */ p("text", { className: at, ...r, children: [
|
|
289
|
+
e,
|
|
290
|
+
" axis label"
|
|
291
|
+
] })
|
|
292
|
+
] }, `axis-label-${e}`);
|
|
293
|
+
}, _e = (e, t) => {
|
|
294
|
+
const r = {
|
|
295
|
+
x: t.width / 2,
|
|
296
|
+
y: t.height / 2,
|
|
297
|
+
textAnchor: "middle",
|
|
298
|
+
dominantBaseline: "middle"
|
|
299
|
+
};
|
|
300
|
+
return e === "left" ? (r.x = 0, r.textAnchor = "start") : e === "right" && (r.x = t.width, r.textAnchor = "end"), r;
|
|
301
|
+
}, ke = I[0], we = 0.3, Se = 1, E = {
|
|
302
|
+
type: "spring",
|
|
303
|
+
stiffness: 500,
|
|
304
|
+
damping: 60,
|
|
305
|
+
mass: 1
|
|
306
|
+
}, Ce = I[0], Ie = 1, Re = 2, it = (e) => e === "catmull-rom" ? It : Rt, st = (e) => {
|
|
307
|
+
switch (e) {
|
|
308
|
+
case "dashed":
|
|
309
|
+
return "8 4";
|
|
310
|
+
case "dotted":
|
|
311
|
+
return "2 2";
|
|
312
|
+
case "solid":
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
}, lt = (e, t) => t.lineWidth !== "auto" ? t.lineWidth : J(e) ?? Re, D = (e, t, r) => {
|
|
316
|
+
const o = vt(e, t);
|
|
317
|
+
return (n) => {
|
|
318
|
+
const a = xt(n) ?? "default", i = o(n);
|
|
319
|
+
return `${r}-${a}${i !== null && i !== "" ? `-${i}` : ""}`;
|
|
320
|
+
};
|
|
321
|
+
}, z = (e, t) => {
|
|
322
|
+
const r = X(e);
|
|
323
|
+
return w(() => {
|
|
324
|
+
const o = Nt(r.get(), e);
|
|
325
|
+
ut(0, 1, {
|
|
326
|
+
...t,
|
|
327
|
+
onUpdate: (n) => {
|
|
328
|
+
const a = o(n);
|
|
329
|
+
return r.set(a);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}, [t, e, r]), r;
|
|
333
|
+
};
|
|
334
|
+
var M = "_1wf5x370";
|
|
335
|
+
const Fe = k(function({ layer: t, isAnimated: r }) {
|
|
336
|
+
const o = t.params, n = st(o.lineType), [a, i] = y(() => {
|
|
337
|
+
const c = it(o.interpolate), d = (u) => S(tt(u) ?? T(u) ?? 0), g = Ft().x((u) => L(u) ?? 0).y0((u) => S(q(u) ?? 0)).y1(d).curve(c), h = et().x((u) => L(u) ?? 0).y(d).curve(c);
|
|
338
|
+
if (o.missingValues === "gap") {
|
|
339
|
+
const u = (v) => L(v) !== null && T(v) !== null;
|
|
340
|
+
g.defined(u), h.defined(u);
|
|
341
|
+
}
|
|
342
|
+
return [h, g];
|
|
343
|
+
}, [o.interpolate, o.missingValues]), l = y(() => {
|
|
344
|
+
const c = D(t.data, t.mapping, t.index), d = [];
|
|
345
|
+
return t.data.groupBy(Q.group).forEach((g) => {
|
|
346
|
+
let h = [...g];
|
|
347
|
+
o.missingValues === "connect" && (h = h.filter(
|
|
348
|
+
(U) => L(U) !== null && T(U) !== null
|
|
349
|
+
));
|
|
350
|
+
const u = i(h), v = a(h);
|
|
351
|
+
if (!u || !v) return;
|
|
352
|
+
const m = h[0];
|
|
353
|
+
if (!m) return;
|
|
354
|
+
const x = R(m) ?? ke, A = F(m), dt = lt(m, o);
|
|
355
|
+
d.push({
|
|
356
|
+
key: c(m),
|
|
357
|
+
areaPath: u,
|
|
358
|
+
linePath: v,
|
|
359
|
+
color: x,
|
|
360
|
+
fillOpacity: A ?? we,
|
|
361
|
+
strokeWidth: dt,
|
|
362
|
+
strokeOpacity: Se,
|
|
363
|
+
strokeDasharray: n
|
|
364
|
+
});
|
|
365
|
+
}), d;
|
|
366
|
+
}, [i, a, t.data, t.index, t.mapping, o, n]);
|
|
367
|
+
return /* @__PURE__ */ s(
|
|
368
|
+
"svg",
|
|
369
|
+
{
|
|
370
|
+
viewBox: "0 0 1 1",
|
|
371
|
+
preserveAspectRatio: "none",
|
|
372
|
+
width: "100%",
|
|
373
|
+
height: "100%",
|
|
374
|
+
"data-geom": "area",
|
|
375
|
+
className: M,
|
|
376
|
+
children: l.map((c) => /* @__PURE__ */ s(
|
|
377
|
+
De,
|
|
378
|
+
{
|
|
379
|
+
areaPath: c.areaPath,
|
|
380
|
+
linePath: c.linePath,
|
|
381
|
+
color: c.color,
|
|
382
|
+
fillOpacity: c.fillOpacity,
|
|
383
|
+
strokeWidth: c.strokeWidth,
|
|
384
|
+
strokeOpacity: c.strokeOpacity,
|
|
385
|
+
strokeDasharray: c.strokeDasharray,
|
|
386
|
+
isAnimated: r
|
|
387
|
+
},
|
|
388
|
+
c.key
|
|
389
|
+
))
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
}), De = ({
|
|
393
|
+
areaPath: e,
|
|
394
|
+
linePath: t,
|
|
395
|
+
color: r,
|
|
396
|
+
fillOpacity: o,
|
|
397
|
+
strokeWidth: n,
|
|
398
|
+
strokeOpacity: a,
|
|
399
|
+
strokeDasharray: i,
|
|
400
|
+
isAnimated: l
|
|
401
|
+
}) => l ? /* @__PURE__ */ s(
|
|
402
|
+
Ne,
|
|
403
|
+
{
|
|
404
|
+
areaPath: e,
|
|
405
|
+
linePath: t,
|
|
406
|
+
color: r,
|
|
407
|
+
fillOpacity: o,
|
|
408
|
+
strokeWidth: n,
|
|
409
|
+
strokeOpacity: a,
|
|
410
|
+
strokeDasharray: i
|
|
411
|
+
}
|
|
412
|
+
) : /* @__PURE__ */ p("g", { children: [
|
|
413
|
+
/* @__PURE__ */ s("path", { d: e, fill: r, fillOpacity: o, stroke: "none" }),
|
|
414
|
+
/* @__PURE__ */ s(
|
|
415
|
+
"path",
|
|
416
|
+
{
|
|
417
|
+
d: t,
|
|
418
|
+
fill: "none",
|
|
419
|
+
stroke: r,
|
|
420
|
+
strokeWidth: n,
|
|
421
|
+
strokeOpacity: a,
|
|
422
|
+
strokeDasharray: i,
|
|
423
|
+
vectorEffect: "non-scaling-stroke"
|
|
424
|
+
}
|
|
425
|
+
)
|
|
426
|
+
] }), Ne = ({
|
|
427
|
+
areaPath: e,
|
|
428
|
+
linePath: t,
|
|
429
|
+
color: r,
|
|
430
|
+
fillOpacity: o,
|
|
431
|
+
strokeWidth: n,
|
|
432
|
+
strokeOpacity: a,
|
|
433
|
+
strokeDasharray: i
|
|
434
|
+
}) => {
|
|
435
|
+
const l = z(e, E), c = z(t, E);
|
|
436
|
+
return /* @__PURE__ */ p("g", { children: [
|
|
437
|
+
/* @__PURE__ */ s(_.path, { d: l, fill: r, fillOpacity: o, stroke: "none" }),
|
|
438
|
+
/* @__PURE__ */ s(
|
|
439
|
+
_.path,
|
|
440
|
+
{
|
|
441
|
+
d: c,
|
|
442
|
+
fill: "none",
|
|
443
|
+
stroke: r,
|
|
444
|
+
strokeWidth: n,
|
|
445
|
+
strokeOpacity: a,
|
|
446
|
+
strokeDasharray: i,
|
|
447
|
+
vectorEffect: "non-scaling-stroke"
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
] });
|
|
451
|
+
}, Be = I[0], Pe = 1, j = 4, Me = k(function({ layer: t, isAnimated: r }) {
|
|
452
|
+
const o = y(() => {
|
|
453
|
+
const n = D(t.data, t.mapping, t.index), a = [];
|
|
454
|
+
for (const i of t.data) {
|
|
455
|
+
const l = n(i), c = bt(i), d = Lt(i), g = q(i), h = tt(i) ?? T(i);
|
|
456
|
+
if (c === null || d === null || g === null || h === null)
|
|
457
|
+
continue;
|
|
458
|
+
const u = R(i), v = F(i);
|
|
459
|
+
let m = 1 - h, x = h - g;
|
|
460
|
+
x < 0 && (m += x, x = -x), a.push({
|
|
461
|
+
key: l,
|
|
462
|
+
x: c,
|
|
463
|
+
y: m,
|
|
464
|
+
width: d - c,
|
|
465
|
+
height: x,
|
|
466
|
+
fill: u ?? Be,
|
|
467
|
+
opacity: v ?? Pe
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
return a;
|
|
471
|
+
}, [t.data, t.index, t.mapping]);
|
|
472
|
+
return /* @__PURE__ */ s(C, { children: o.map((n) => {
|
|
473
|
+
const { key: a, ...i } = n;
|
|
474
|
+
return /* @__PURE__ */ s(Oe, { ...i, isAnimated: r }, a);
|
|
475
|
+
}) });
|
|
476
|
+
}), Oe = ({ isAnimated: e, ...t }) => e ? /* @__PURE__ */ s(
|
|
477
|
+
_.rect,
|
|
478
|
+
{
|
|
479
|
+
initial: !1,
|
|
480
|
+
style: { transformBox: "view-box" },
|
|
481
|
+
transition: E,
|
|
482
|
+
fill: t.fill,
|
|
483
|
+
opacity: t.opacity,
|
|
484
|
+
rx: j,
|
|
485
|
+
animate: {
|
|
486
|
+
x: f(t.x),
|
|
487
|
+
y: f(t.y),
|
|
488
|
+
width: f(t.width),
|
|
489
|
+
height: f(t.height),
|
|
490
|
+
opacity: t.opacity
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
) : /* @__PURE__ */ s(
|
|
494
|
+
"rect",
|
|
495
|
+
{
|
|
496
|
+
style: { transformBox: "view-box" },
|
|
497
|
+
x: f(t.x),
|
|
498
|
+
y: f(t.y),
|
|
499
|
+
width: f(t.width),
|
|
500
|
+
height: f(t.height),
|
|
501
|
+
fill: t.fill,
|
|
502
|
+
opacity: t.opacity,
|
|
503
|
+
rx: j
|
|
504
|
+
}
|
|
505
|
+
), Ge = k(function({ layer: t, isAnimated: r }) {
|
|
506
|
+
const o = t.params, n = st(o.lineType), a = y(() => {
|
|
507
|
+
const l = et().x((c) => L(c) ?? 0).y((c) => S(T(c) ?? 0)).curve(it(o.interpolate));
|
|
508
|
+
return o.missingValues === "gap" && l.defined((c) => L(c) !== null && T(c) !== null), l;
|
|
509
|
+
}, [o.interpolate, o.missingValues]), i = y(() => {
|
|
510
|
+
const l = D(t.data, t.mapping, t.index), c = [];
|
|
511
|
+
return t.data.groupBy(Q.group).forEach((d) => {
|
|
512
|
+
let g = [...d];
|
|
513
|
+
o.missingValues === "connect" && (g = g.filter(
|
|
514
|
+
(A) => L(A) !== null && T(A) !== null
|
|
515
|
+
));
|
|
516
|
+
const h = a(g);
|
|
517
|
+
if (!h) return;
|
|
518
|
+
const u = g[0];
|
|
519
|
+
if (!u) return;
|
|
520
|
+
const v = R(u) ?? Ce, m = F(u), x = lt(u, o);
|
|
521
|
+
c.push({
|
|
522
|
+
key: l(u),
|
|
523
|
+
pathData: h,
|
|
524
|
+
color: v,
|
|
525
|
+
opacity: m ?? Ie,
|
|
526
|
+
strokeWidth: x,
|
|
527
|
+
strokeDasharray: n
|
|
528
|
+
});
|
|
529
|
+
}), c;
|
|
530
|
+
}, [a, t.data, t.index, t.mapping, o, n]);
|
|
531
|
+
return /* @__PURE__ */ s(
|
|
532
|
+
"svg",
|
|
533
|
+
{
|
|
534
|
+
viewBox: "0 0 1 1",
|
|
535
|
+
preserveAspectRatio: "none",
|
|
536
|
+
width: "100%",
|
|
537
|
+
height: "100%",
|
|
538
|
+
"data-geom": "line",
|
|
539
|
+
className: M,
|
|
540
|
+
children: i.map((l) => /* @__PURE__ */ s(
|
|
541
|
+
ze,
|
|
542
|
+
{
|
|
543
|
+
pathData: l.pathData,
|
|
544
|
+
color: l.color,
|
|
545
|
+
strokeWidth: l.strokeWidth,
|
|
546
|
+
opacity: l.opacity,
|
|
547
|
+
strokeDasharray: l.strokeDasharray,
|
|
548
|
+
isAnimated: r
|
|
549
|
+
},
|
|
550
|
+
l.key
|
|
551
|
+
))
|
|
552
|
+
}
|
|
553
|
+
);
|
|
554
|
+
}), ze = ({ pathData: e, color: t, strokeWidth: r, opacity: o, strokeDasharray: n, isAnimated: a }) => a ? /* @__PURE__ */ s(
|
|
555
|
+
We,
|
|
556
|
+
{
|
|
557
|
+
pathData: e,
|
|
558
|
+
color: t,
|
|
559
|
+
strokeWidth: r,
|
|
560
|
+
opacity: o,
|
|
561
|
+
strokeDasharray: n
|
|
562
|
+
}
|
|
563
|
+
) : /* @__PURE__ */ s(
|
|
564
|
+
"path",
|
|
565
|
+
{
|
|
566
|
+
d: e,
|
|
567
|
+
fill: "none",
|
|
568
|
+
stroke: t,
|
|
569
|
+
strokeWidth: r,
|
|
570
|
+
opacity: o,
|
|
571
|
+
strokeDasharray: n,
|
|
572
|
+
vectorEffect: "non-scaling-stroke"
|
|
573
|
+
}
|
|
574
|
+
), We = ({
|
|
575
|
+
pathData: e,
|
|
576
|
+
color: t,
|
|
577
|
+
strokeWidth: r,
|
|
578
|
+
opacity: o,
|
|
579
|
+
strokeDasharray: n
|
|
580
|
+
}) => {
|
|
581
|
+
const a = z(e, E);
|
|
582
|
+
return /* @__PURE__ */ s(
|
|
583
|
+
_.path,
|
|
584
|
+
{
|
|
585
|
+
d: a,
|
|
586
|
+
fill: "none",
|
|
587
|
+
stroke: t,
|
|
588
|
+
strokeWidth: r,
|
|
589
|
+
opacity: o,
|
|
590
|
+
strokeDasharray: n,
|
|
591
|
+
vectorEffect: "non-scaling-stroke"
|
|
592
|
+
}
|
|
593
|
+
);
|
|
594
|
+
}, He = I[0], Ue = 1, $e = 8, Ve = "#000000", je = 1, Ye = k(function({ layer: t, isAnimated: r }) {
|
|
595
|
+
const o = y(() => {
|
|
596
|
+
const n = D(t.data, t.mapping, t.index), a = [];
|
|
597
|
+
for (const i of t.data) {
|
|
598
|
+
const l = L(i), c = T(i);
|
|
599
|
+
if (l === null || c === null)
|
|
600
|
+
continue;
|
|
601
|
+
const d = R(i), g = F(i), h = Tt(i), u = J(i);
|
|
602
|
+
a.push({
|
|
603
|
+
key: n(i),
|
|
604
|
+
cx: l,
|
|
605
|
+
cy: S(c),
|
|
606
|
+
radius: (h ?? $e) / 2,
|
|
607
|
+
fill: d ?? He,
|
|
608
|
+
stroke: Ve,
|
|
609
|
+
opacity: g ?? Ue,
|
|
610
|
+
strokeWidth: u ?? je
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
return a;
|
|
614
|
+
}, [t.data, t.index, t.mapping]);
|
|
615
|
+
return /* @__PURE__ */ s(C, { children: o.map((n) => r ? /* @__PURE__ */ s(
|
|
616
|
+
_.circle,
|
|
617
|
+
{
|
|
618
|
+
initial: !1,
|
|
619
|
+
transition: E,
|
|
620
|
+
fill: n.fill,
|
|
621
|
+
stroke: n.stroke,
|
|
622
|
+
strokeWidth: n.strokeWidth,
|
|
623
|
+
animate: {
|
|
624
|
+
cx: f(n.cx),
|
|
625
|
+
cy: f(n.cy),
|
|
626
|
+
r: n.radius,
|
|
627
|
+
opacity: n.opacity
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
n.key
|
|
631
|
+
) : /* @__PURE__ */ s(
|
|
632
|
+
"circle",
|
|
633
|
+
{
|
|
634
|
+
cx: f(n.cx),
|
|
635
|
+
cy: f(n.cy),
|
|
636
|
+
r: n.radius,
|
|
637
|
+
fill: n.fill,
|
|
638
|
+
opacity: n.opacity,
|
|
639
|
+
stroke: n.stroke,
|
|
640
|
+
strokeWidth: n.strokeWidth
|
|
641
|
+
},
|
|
642
|
+
n.key
|
|
643
|
+
)) });
|
|
644
|
+
}), Ke = I[0], Xe = 1, W = Dt(), Y = Math.PI * 2, Ze = k(function({
|
|
645
|
+
layer: t,
|
|
646
|
+
isAnimated: r
|
|
647
|
+
}) {
|
|
648
|
+
const o = O(!1);
|
|
649
|
+
w(() => {
|
|
650
|
+
o.current = !0;
|
|
651
|
+
}, []);
|
|
652
|
+
const n = y(() => {
|
|
653
|
+
const a = D(t.data, t.mapping, t.index), i = [];
|
|
654
|
+
for (const l of t.data) {
|
|
655
|
+
const c = a(l), d = Et(l), g = At(l), h = _t(l), u = kt(l);
|
|
656
|
+
d === null || g === null || h === null || u === null || i.push({
|
|
657
|
+
key: c,
|
|
658
|
+
startAngle: d,
|
|
659
|
+
endAngle: g,
|
|
660
|
+
innerRadius: h,
|
|
661
|
+
outerRadius: u,
|
|
662
|
+
fill: R(l) ?? Ke,
|
|
663
|
+
opacity: F(l) ?? Xe
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
return i;
|
|
667
|
+
}, [t.data, t.index, t.mapping]);
|
|
668
|
+
return /* @__PURE__ */ s(
|
|
669
|
+
"svg",
|
|
670
|
+
{
|
|
671
|
+
viewBox: "-1 -1 2 2",
|
|
672
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
673
|
+
width: "100%",
|
|
674
|
+
height: "100%",
|
|
675
|
+
"data-geom": "bar",
|
|
676
|
+
className: M,
|
|
677
|
+
children: n.map((a) => {
|
|
678
|
+
if (r) {
|
|
679
|
+
const { key: i, ...l } = a;
|
|
680
|
+
return /* @__PURE__ */ s(Je, { isInitialRender: !o.current, ...l }, i);
|
|
681
|
+
}
|
|
682
|
+
return /* @__PURE__ */ s(
|
|
683
|
+
"path",
|
|
684
|
+
{
|
|
685
|
+
d: W({
|
|
686
|
+
startAngle: a.startAngle,
|
|
687
|
+
endAngle: a.endAngle,
|
|
688
|
+
innerRadius: a.innerRadius,
|
|
689
|
+
outerRadius: a.outerRadius
|
|
690
|
+
}) ?? void 0,
|
|
691
|
+
fill: a.fill,
|
|
692
|
+
opacity: a.opacity
|
|
693
|
+
},
|
|
694
|
+
a.key
|
|
695
|
+
);
|
|
696
|
+
})
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
}), Je = ({
|
|
700
|
+
startAngle: e,
|
|
701
|
+
endAngle: t,
|
|
702
|
+
innerRadius: r,
|
|
703
|
+
outerRadius: o,
|
|
704
|
+
fill: n,
|
|
705
|
+
opacity: a,
|
|
706
|
+
isInitialRender: i
|
|
707
|
+
}) => {
|
|
708
|
+
const l = i ? e : Y, c = i ? t : Y, d = $(l, E), g = $(c, E), h = X(
|
|
709
|
+
W({ startAngle: l, endAngle: c, innerRadius: r, outerRadius: o }) ?? ""
|
|
710
|
+
);
|
|
711
|
+
return w(() => {
|
|
712
|
+
d.set(e), g.set(t);
|
|
713
|
+
}, [d, g, e, t]), w(() => {
|
|
714
|
+
const u = () => {
|
|
715
|
+
const x = d.get(), A = g.get();
|
|
716
|
+
h.set(
|
|
717
|
+
W({ startAngle: x, endAngle: A, innerRadius: r, outerRadius: o }) ?? ""
|
|
718
|
+
);
|
|
719
|
+
}, v = d.on("change", u), m = g.on("change", u);
|
|
720
|
+
return () => {
|
|
721
|
+
v(), m();
|
|
722
|
+
};
|
|
723
|
+
}, [d, g, r, o, h]), /* @__PURE__ */ s(_.path, { d: h, fill: n, opacity: a, transition: E });
|
|
724
|
+
}, qe = ({ compiled: e, shouldAnimate: t, panelRect: r }) => /* @__PURE__ */ s("svg", { x: r.x, y: r.y, width: r.width, height: r.height, className: M, children: e.layers.map((o, n) => {
|
|
725
|
+
const a = `layer-${n}`;
|
|
726
|
+
switch (o.geom) {
|
|
727
|
+
case "bar":
|
|
728
|
+
return e.coordSystem.type === "polar" ? /* @__PURE__ */ s(Ze, { layer: o, isAnimated: t }, a) : /* @__PURE__ */ s(Me, { layer: o, isAnimated: t }, a);
|
|
729
|
+
case "line":
|
|
730
|
+
return /* @__PURE__ */ s(Ge, { layer: o, isAnimated: t }, a);
|
|
731
|
+
case "area":
|
|
732
|
+
return /* @__PURE__ */ s(Fe, { layer: o, isAnimated: t }, a);
|
|
733
|
+
case "point":
|
|
734
|
+
return /* @__PURE__ */ s(Ye, { layer: o, isAnimated: t }, a);
|
|
735
|
+
default:
|
|
736
|
+
return /* @__PURE__ */ p("text", { children: [
|
|
737
|
+
o.geom,
|
|
738
|
+
" not implemented"
|
|
739
|
+
] }, a);
|
|
740
|
+
}
|
|
741
|
+
}) });
|
|
742
|
+
var Qe = "_1ymbsoj0";
|
|
743
|
+
const ct = (e, t) => ({
|
|
744
|
+
x: e.x - t.x,
|
|
745
|
+
y: e.y - t.y,
|
|
746
|
+
width: e.width,
|
|
747
|
+
height: e.height
|
|
748
|
+
}), K = (e, t) => {
|
|
749
|
+
const r = {};
|
|
750
|
+
for (const [o, n] of Object.entries(e))
|
|
751
|
+
r[o] = ct(n, t);
|
|
752
|
+
return r;
|
|
753
|
+
}, tr = ({
|
|
754
|
+
compiled: e,
|
|
755
|
+
plotRect: t,
|
|
756
|
+
panelRect: r,
|
|
757
|
+
axisRects: o,
|
|
758
|
+
axisLabelRects: n,
|
|
759
|
+
shouldAnimate: a
|
|
760
|
+
}) => {
|
|
761
|
+
const i = ct(r, t), l = K(o, t), c = K(n, t);
|
|
762
|
+
return /* @__PURE__ */ p(
|
|
763
|
+
"svg",
|
|
764
|
+
{
|
|
765
|
+
className: Qe,
|
|
766
|
+
width: t.width,
|
|
767
|
+
height: t.height,
|
|
768
|
+
style: { transform: `translate(${t.x}px, ${t.y}px)` },
|
|
769
|
+
children: [
|
|
770
|
+
/* @__PURE__ */ s(Ee, { axisRects: l }),
|
|
771
|
+
/* @__PURE__ */ s(qe, { compiled: e, shouldAnimate: a, panelRect: i }),
|
|
772
|
+
/* @__PURE__ */ s(Ae, { axisLabelRects: c })
|
|
773
|
+
]
|
|
774
|
+
}
|
|
775
|
+
);
|
|
776
|
+
}, er = {
|
|
777
|
+
titleSize: { width: 0, height: 0 },
|
|
778
|
+
captionSize: { width: 0, height: 0 }
|
|
779
|
+
}, rr = () => {
|
|
780
|
+
const e = O(null), t = O(null), [r, o] = Z(er);
|
|
781
|
+
return ht(() => {
|
|
782
|
+
const n = () => {
|
|
783
|
+
const i = e.current?.offsetHeight ?? 0, l = t.current?.offsetHeight ?? 0, c = e.current?.offsetWidth ?? 0, d = t.current?.offsetWidth ?? 0;
|
|
784
|
+
o((g) => g.titleSize.height === i && g.captionSize.height === l && g.titleSize.width === c && g.captionSize.width === d ? g : {
|
|
785
|
+
titleSize: { width: c, height: i },
|
|
786
|
+
captionSize: { width: d, height: l }
|
|
787
|
+
});
|
|
788
|
+
};
|
|
789
|
+
n();
|
|
790
|
+
const a = new ResizeObserver(n);
|
|
791
|
+
return e.current && a.observe(e.current), t.current && a.observe(t.current), () => a.disconnect();
|
|
792
|
+
}, []), { titleRef: e, captionRef: t, measurements: r };
|
|
793
|
+
};
|
|
794
|
+
var nr = "znp3wr0";
|
|
795
|
+
const pr = ({ spec: e, width: t, height: r, isAnimated: o }) => {
|
|
796
|
+
const n = gt(), a = y(() => wt(e), [e]), { titleRef: i, captionRef: l, measurements: c } = rr(), d = re({
|
|
797
|
+
spec: a,
|
|
798
|
+
containerSize: { width: t, height: r },
|
|
799
|
+
externalMeasurements: c
|
|
800
|
+
});
|
|
801
|
+
return d ? /* @__PURE__ */ p("div", { className: nr, style: { width: t, height: r }, children: [
|
|
802
|
+
/* @__PURE__ */ s(ie, { ref: i, compiled: a, titleRect: d.title }),
|
|
803
|
+
/* @__PURE__ */ s(
|
|
804
|
+
tr,
|
|
805
|
+
{
|
|
806
|
+
compiled: a,
|
|
807
|
+
plotRect: d.plot,
|
|
808
|
+
panelRect: d.panel,
|
|
809
|
+
axisRects: d.axes,
|
|
810
|
+
axisLabelRects: d.axisLabels,
|
|
811
|
+
shouldAnimate: o ?? !n
|
|
812
|
+
}
|
|
813
|
+
),
|
|
814
|
+
/* @__PURE__ */ s(oe, { ref: l, compiled: a, captionRect: d.caption }),
|
|
815
|
+
/* @__PURE__ */ s(Te, { legends: a.guides.legends, rects: d.legends })
|
|
816
|
+
] }) : null;
|
|
817
|
+
};
|
|
818
|
+
var or = { white: "var(--graphy-white)", black: "var(--graphy-black)", transparent: "var(--graphy-transparent)", grey100: "var(--graphy-grey-100)", grey95: "var(--graphy-grey-95)", grey90: "var(--graphy-grey-90)", grey85: "var(--graphy-grey-85)", grey80: "var(--graphy-grey-80)", grey75: "var(--graphy-grey-75)", grey70: "var(--graphy-grey-70)", grey60: "var(--graphy-grey-60)", grey50: "var(--graphy-grey-50)", grey0: "var(--graphy-grey-0)", greyGradient80: "var(--graphy-grey-gradient-80)", green60: "var(--graphy-green-60)", green50: "var(--graphy-green-50)", red60: "var(--graphy-red-60)", red50: "var(--graphy-red-50)", amber70: "var(--graphy-amber-70)", amber50: "var(--graphy-amber-50)", amber40: "var(--graphy-amber-40)", amber30: "var(--graphy-amber-30)", blue80: "var(--graphy-blue-80)", blue60: "var(--graphy-blue-60)", purple50: "var(--graphy-purple-50)", purple30: "var(--graphy-purple-30)", brand: "var(--graphy-brand)", success: "var(--graphy-success)", warning: "var(--graphy-warning)", alert: "var(--graphy-alert)", textPrimary: "var(--graphy-text-primary)", textSecondary: "var(--graphy-text-secondary)", textDisabled: "var(--graphy-text-disabled)", iconPrimary: "var(--graphy-icon-primary)", iconSecondary: "var(--graphy-icon-secondary)", iconStickerBackground: "var(--graphy-icon-sticker-background)", border100: "var(--graphy-border-100)", border10: "var(--graphy-border-10)", sunkenBackground: "var(--graphy-sunken-background)", defaultBackground: "var(--graphy-default-background)", raisedBackground: "var(--graphy-raised-background)", overlayBackground: "var(--graphy-overlay-background)", overlayBorderGradient: "var(--graphy-overlay-border-gradient)", graphBackground: "var(--graphy-graph-background)", gridLineColor: "var(--graphy-grid-line-color)", hoverGuideLineColor: "var(--graphy-hover-guide-line-color)", originLineColor: "var(--graphy-origin-line-color)", targetLineColor: "var(--graphy-target-line-color)", targetLineMarkerColor: "var(--graphy-target-line-marker-color)", legendBackground: "var(--graphy-legend-background)", legendBorderColor: "var(--graphy-legend-border-color)", legendTextColor: "var(--graphy-legend-text-color)", dimmedSeriesLabelTextColor: "var(--graphy-dimmed-series-label-text-color)", dimmedSeriesLabelLineColor: "var(--graphy-dimmed-series-label-line-color)", trendNegativeColor: "var(--graphy-trend-negative-color)", trendPositiveColor: "var(--graphy-trend-positive-color)", tooltipBackground: "var(--graphy-tooltip-background)", tooltipBorderColor: "var(--graphy-tooltip-border-color)", tooltipHeadingTextColor: "var(--graphy-tooltip-heading-text-color)", tooltipLabelTextColor: "var(--graphy-tooltip-label-text-color)", tooltipValueTextColor: "var(--graphy-tooltip-value-text-color)", heatmapEmptyTileBackground: "var(--graphy-heatmap-empty-tile-background)", stackedBarHoverBorderColor: "var(--graphy-stacked-bar-hover-border-color)", defaultArrowAnnotationColor: "var(--graphy-default-arrow-annotation-color)", annotationFrameBorderColor: "var(--graphy-annotation-frame-border-color)", annotationMenuTriggerIconColor: "var(--graphy-annotation-menu-trigger-icon-color)", fontFamilyDefault: "var(--graphy-font-family-default)", fontFamilyHeading: "var(--graphy-font-family-heading)", fontWeightRegular: "var(--graphy-font-weight-regular)", fontWeightMedium: "var(--graphy-font-weight-medium)", fontWeightSemibold: "var(--graphy-font-weight-semibold)", fontWeightBold: "var(--graphy-font-weight-bold)", fontXxs: "var(--graphy-font-xxs)", fontXs: "var(--graphy-font-xs)", fontSm: "var(--graphy-font-sm)", fontMd: "var(--graphy-font-md)", fontLg: "var(--graphy-font-lg)", fontXl: "var(--graphy-font-xl)", fontEditorBody: "var(--graphy-font-editor-body)", fontHeadingSm: "var(--graphy-font-heading-sm)", fontHeadingMd: "var(--graphy-font-heading-md)", fontHeadingLg: "var(--graphy-font-heading-lg)", fontTickLabel: "var(--graphy-font-tick-label)", fontAxisLabel: "var(--graphy-font-axis-label)", fontDataLabel: "var(--graphy-font-data-label)", fontStackTotal: "var(--graphy-font-stack-total)", fontLegendLabel: "var(--graphy-font-legend-label)", fontSeriesLabel: "var(--graphy-font-series-label)", fontTooltipLabel: "var(--graphy-font-tooltip-label)", fontTooltipHeading: "var(--graphy-font-tooltip-heading)", fontTooltipFooter: "var(--graphy-font-tooltip-footer)", fontJumboTooltipLabel: "var(--graphy-font-jumbo-tooltip-label)", fontJumboTooltip: "var(--graphy-font-jumbo-tooltip)", fontMiniTooltipLabel: "var(--graphy-font-mini-tooltip-label)", fontMiniTooltipFooter: "var(--graphy-font-mini-tooltip-footer)", fontTooltipCaption: "var(--graphy-font-tooltip-caption)", fontTooltipCaptionSmall: "var(--graphy-font-tooltip-caption-small)", fontTrendTag: "var(--graphy-font-trend-tag)", fontTrendTagSmall: "var(--graphy-font-trend-tag-small)", fontGoalLineLabel: "var(--graphy-font-goal-line-label)", fontPieLabel: "var(--graphy-font-pie-label)", fontPieChartTotal: "var(--graphy-font-pie-chart-total)", fontDifferenceArrowSmall: "var(--graphy-font-difference-arrow-small)", fontDifferenceArrowMedium: "var(--graphy-font-difference-arrow-medium)", fontDifferenceArrowLarge: "var(--graphy-font-difference-arrow-large)", fontButton: "var(--graphy-font-button)", fontInput: "var(--graphy-font-input)", fontInputLabel: "var(--graphy-font-input-label)", fontSelectLabel: "var(--graphy-font-select-label)", fontSelectDescription: "var(--graphy-font-select-description)", fontColorSelectLabel: "var(--graphy-font-color-select-label)", fontMenuTitle: "var(--graphy-font-menu-title)", fontMenuGroupTitle: "var(--graphy-font-menu-group-title)", fontMenuItemLabel: "var(--graphy-font-menu-item-label)", fontMenuItemLabelSecondary: "var(--graphy-font-menu-item-label-secondary)", fontUITooltip: "var(--graphy-font-uitooltip)", fontUITooltipSecondary: "var(--graphy-font-uitooltip-secondary)", fontErrorBoundaryTitle: "var(--graphy-font-error-boundary-title)", fontErrorBoundaryMessage: "var(--graphy-font-error-boundary-message)", fontTableCell: "var(--graphy-font-table-cell)", fontTableHeaderCell: "var(--graphy-font-table-header-cell)", fontSourceLabel: "var(--graphy-font-source-label)", fontSourceLink: "var(--graphy-font-source-link)", fontTextEditorH1: "var(--graphy-font-text-editor-h1)", fontTextEditorH2: "var(--graphy-font-text-editor-h2)", fontTextEditorH3: "var(--graphy-font-text-editor-h3)", fontTextEditorH6: "var(--graphy-font-text-editor-h6)", fontTextEditorBody: "var(--graphy-font-text-editor-body)", fontTextEditorLink: "var(--graphy-font-text-editor-link)", fontHighlightModeTitle: "var(--graphy-font-highlight-mode-title)", fontHighlightModeSubtitle: "var(--graphy-font-highlight-mode-subtitle)" }, ar = "_1rkj4kp0", fr = "_1rkj4kp1";
|
|
819
|
+
const yr = ({ theme: e, children: t, className: r, style: o }) => {
|
|
820
|
+
const n = y(() => {
|
|
821
|
+
if (!e) return o;
|
|
822
|
+
const a = {};
|
|
823
|
+
for (const [i, l] of Object.entries(e))
|
|
824
|
+
l !== void 0 && (a[or[i]] = l);
|
|
825
|
+
return { ...o, ...Bt(a) };
|
|
826
|
+
}, [e, o]);
|
|
827
|
+
return /* @__PURE__ */ s("div", { className: St(ar, r), style: n, children: t });
|
|
828
|
+
};
|
|
829
|
+
export {
|
|
830
|
+
H as CanvasTextMeasurer,
|
|
831
|
+
pr as GraphRenderer,
|
|
832
|
+
yr as ThemeProvider,
|
|
833
|
+
fr as darkTheme,
|
|
834
|
+
Wt as useTextMeasurer,
|
|
835
|
+
or as vars
|
|
836
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphysdk/react",
|
|
3
|
+
"author": "Graphy",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.css.ts",
|
|
8
|
+
"**/*.css",
|
|
9
|
+
"**/version.ts"
|
|
10
|
+
],
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./styles.css": "./dist/index.css"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@vanilla-extract/css": "^1.17.0",
|
|
26
|
+
"@vanilla-extract/dynamic": "^2.1.2",
|
|
27
|
+
"clsx": "^2.1.1",
|
|
28
|
+
"d3-interpolate-path": "^2.3.0",
|
|
29
|
+
"d3-shape": "^3.2.0",
|
|
30
|
+
"motion": "^12.23.12",
|
|
31
|
+
"@graphysdk/viz-engine": "0.0.1"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^19.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@rollup/plugin-replace": "^6.0.3",
|
|
38
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
39
|
+
"@testing-library/react": "^16.3.1",
|
|
40
|
+
"@testing-library/user-event": "^13.5.0",
|
|
41
|
+
"@types/d3-interpolate-path": "^2.0.3",
|
|
42
|
+
"@types/d3-shape": "^3.1.0",
|
|
43
|
+
"@types/react": "^19.2.3",
|
|
44
|
+
"@types/react-dom": "^19.2.3",
|
|
45
|
+
"@vanilla-extract/vite-plugin": "^5.0.0",
|
|
46
|
+
"react": "^19.2.4",
|
|
47
|
+
"react-dom": "^19.2.4",
|
|
48
|
+
"rollup-plugin-node-externals": "^8.1.1",
|
|
49
|
+
"tslib": "^2.8.1",
|
|
50
|
+
"vite": "^6.4.2",
|
|
51
|
+
"vite-plugin-dts": "^4.5.4",
|
|
52
|
+
"vitest": "^4.1.0",
|
|
53
|
+
"@graphytools/typescript-config": "0.0.1",
|
|
54
|
+
"@graphytools/eslint-config": "0.0.1",
|
|
55
|
+
"@graphytools/vitest-config": "1.0.0"
|
|
56
|
+
},
|
|
57
|
+
"lint-staged": {
|
|
58
|
+
"*.{ts,tsx,js,jsx,json,css,md}": [
|
|
59
|
+
"prettier --write"
|
|
60
|
+
],
|
|
61
|
+
"*.{ts,tsx}": [
|
|
62
|
+
"eslint --max-warnings=0 --fix"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "vite build",
|
|
67
|
+
"test": "vitest run",
|
|
68
|
+
"test:watch": "TZ=utc vitest",
|
|
69
|
+
"lint": "eslint . --max-warnings 0",
|
|
70
|
+
"lint:fix": "eslint . --fix",
|
|
71
|
+
"format": "prettier --write .",
|
|
72
|
+
"format:check": "prettier --check .",
|
|
73
|
+
"typecheck": "tsc --noEmit"
|
|
74
|
+
}
|
|
75
|
+
}
|