@lincyaw/aegis-ui 0.9.2 → 0.9.3

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),O=require("react"),F=require("../../hooks/useElementWidth.cjs"),p=require("../../lib/chart.cjs");;/* empty css */const G=require("../../locale/useStrings.cjs"),x=240,K=32,V=8,U=20,W=28,g=8,R=16,z=4;function J({series:N,label:T,endLabels:C=!0,xLabel:v,yTicks:B,formatX:j=String,formatY:w=String,playhead:r,onSeek:l,markers:S=[],progress:b,className:q}){const H=G.useStrings(),f=O.useRef(null),A=F.useElementWidth(f),E=N.flatMap(t=>t.points),i=[...new Set(E.map(t=>t.x))].sort((t,e)=>t-e),M=["aegis-line-chart",q??""].filter(Boolean).join(" ");if(A===0||i.length===0)return s.jsx("div",{ref:f,className:M});const n=i[0],d=i[i.length-1],D=E.map(t=>t.y),L=B??p.niceTicks(0,Math.max(...D,1)),$=Math.max(...L,...D),a=K,o=A-V,u=U,y=x-W,m=t=>a+(d>n?(t-n)/(d-n):0)*(o-a),_=t=>y-t/$*(y-u),h=N.flatMap(t=>{const e=t.points[t.points.length-1];return e===void 0?[]:[{line:t,last:e,y:_(e.y)}]}).sort((t,e)=>e.y-t.y);for(let t=1;t<h.length;t+=1)h[t-1].y-h[t].y<R&&(h[t].y=h[t-1].y-R);const P=t=>i.reduce((e,c)=>Math.abs(c-t)<Math.abs(e-t)?c:e),k=t=>{const e=t.currentTarget.getBoundingClientRect(),c=(t.clientX-e.left)/e.width;l?.(P(n+c*(d-n)))},I=t=>{const e=i.indexOf(P(r??n)),c={ArrowLeft:e-1,ArrowDown:e-1,ArrowRight:e+1,ArrowUp:e+1,Home:0,End:i.length-1};t.key in c&&(t.preventDefault(),l?.(i[Math.min(Math.max(c[t.key],0),i.length-1)]))};return s.jsx("div",{ref:f,className:M,children:s.jsxs("svg",{className:"aegis-line-chart__svg",width:A,height:x,viewBox:`0 0 ${A.toString()} ${x.toString()}`,role:l?"group":"img","aria-label":T,children:[L.map(t=>s.jsxs("g",{children:[s.jsx("line",{className:"aegis-line-chart__grid",x1:a,x2:o,y1:_(t),y2:_(t)}),s.jsx("text",{className:"aegis-line-chart__tick",x:a-g,y:_(t),textAnchor:"end",dominantBaseline:"middle",children:w(t)})]},t)),N.map(t=>s.jsx("polyline",{className:"aegis-line-chart__line",pathLength:1,points:t.points.map(e=>`${m(e.x).toString()},${_(e.y).toString()}`).join(" "),style:{stroke:p.chartColorValue(t.color),...b===void 0?{}:{"--aegis-line-chart-progress":b}}},t.key)),C&&h.map(({line:t,last:e,y:c})=>s.jsx("text",{className:"aegis-line-chart__end-label",x:o,y:c-g,textAnchor:"end",style:{fill:p.chartColorValue(t.color)},children:`${t.label} ${w(e.y)}`},t.key)),r!==void 0&&s.jsxs("g",{children:[s.jsx("line",{className:"aegis-line-chart__playhead",x1:m(r),x2:m(r),y1:u,y2:y}),s.jsx("text",{className:"aegis-line-chart__playhead-label",x:m(r),y:u-g/2,textAnchor:"middle",children:j(r)})]}),s.jsx("text",{className:"aegis-line-chart__tick",x:a,y:x-g,textAnchor:"start",children:j(n)}),s.jsx("text",{className:"aegis-line-chart__tick",x:o,y:x-g,textAnchor:"end",children:j(d)}),v!==void 0&&s.jsx("text",{className:"aegis-line-chart__tick",x:(a+o)/2,y:x-g,textAnchor:"middle",children:v}),l&&s.jsx("rect",{className:"aegis-line-chart__seek",x:a,y:u,width:o-a,height:y-u,role:"slider",tabIndex:0,"aria-label":H.replayPosition,"aria-valuemin":n,"aria-valuemax":d,"aria-valuenow":r??n,"aria-valuetext":j(r??n),onClick:k,onKeyDown:I}),S.map(t=>s.jsx("circle",{className:"aegis-line-chart__marker",cx:m(t.x),cy:y,r:z,style:{fill:p.chartColorValue(t.color)},onClick:l?()=>{l(t.x)}:void 0,children:s.jsx("title",{children:t.label})},t.key))]})})}exports.LineChart=J;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),M=require("react"),F=require("../../hooks/useElementWidth.cjs"),A=require("../../lib/chart.cjs");;/* empty css */const G=require("../../locale/useStrings.cjs"),r=240,K=32,V=8,W=20,z=28,y=8,P=16,J=4;function Q({series:f,label:R,endLabels:T=!0,xLabel:N,yTicks:C,formatX:S=String,formatY:k=String,playhead:l,onSeek:c,markers:B=[],progress:m,className:I}){const q=G.useStrings(),w=M.useId(),v=M.useRef(null),u=F.useElementWidth(v),D=f.flatMap(t=>t.points),n=[...new Set(D.map(t=>t.x))].sort((t,e)=>t-e),L=["aegis-line-chart",I??""].filter(Boolean).join(" ");if(u===0||n.length===0)return s.jsx("div",{ref:v,className:L});const i=n[0],_=n[n.length-1],$=D.map(t=>t.y),b=C??A.niceTicks(0,Math.max(...$,1)),H=Math.max(...b,...$),o=K,h=u-V,j=W,p=r-z,x=t=>o+(_>i?(t-i)/(_-i):0)*(h-o),d=t=>p-t/H*(p-j),g=f.flatMap(t=>{const e=t.points[t.points.length-1];return e===void 0?[]:[{line:t,last:e,y:d(e.y)}]}).sort((t,e)=>e.y-t.y);for(let t=1;t<g.length;t+=1)g[t-1].y-g[t].y<P&&(g[t].y=g[t-1].y-P);const E=t=>n.reduce((e,a)=>Math.abs(a-t)<Math.abs(e-t)?a:e),O=t=>{const e=t.currentTarget.getBoundingClientRect(),a=(t.clientX-e.left)/e.width;c?.(E(i+a*(_-i)))},U=t=>{const e=n.indexOf(E(l??i)),a={ArrowLeft:e-1,ArrowDown:e-1,ArrowRight:e+1,ArrowUp:e+1,Home:0,End:n.length-1};t.key in a&&(t.preventDefault(),c?.(n[Math.min(Math.max(a[t.key],0),n.length-1)]))};return s.jsx("div",{ref:v,className:L,children:s.jsxs("svg",{className:"aegis-line-chart__svg",width:u,height:r,viewBox:`0 0 ${u.toString()} ${r.toString()}`,role:c?"group":"img","aria-label":R,children:[b.map(t=>s.jsxs("g",{children:[s.jsx("line",{className:"aegis-line-chart__grid",x1:o,x2:h,y1:d(t),y2:d(t)}),s.jsx("text",{className:"aegis-line-chart__tick",x:o-y,y:d(t),textAnchor:"end",dominantBaseline:"middle",children:k(t)})]},t)),f.map(t=>s.jsxs("g",{children:[t.lineStyle&&t.lineStyle!=="solid"&&m!==void 0&&s.jsx("mask",{id:`${w}-${t.key}`,maskUnits:"userSpaceOnUse",x:0,y:0,width:u,height:r,children:s.jsx("polyline",{className:"aegis-line-chart__line",pathLength:1,points:t.points.map(e=>`${x(e.x).toString()},${d(e.y).toString()}`).join(" "),style:{stroke:"white","--aegis-line-chart-progress":m}})}),s.jsx("polyline",{className:"aegis-line-chart__line",pathLength:!t.lineStyle||t.lineStyle==="solid"?1:void 0,mask:t.lineStyle&&t.lineStyle!=="solid"&&m!==void 0?`url(#${w}-${t.key})`:void 0,points:t.points.map(e=>`${x(e.x).toString()},${d(e.y).toString()}`).join(" "),style:{stroke:A.chartColorValue(t.color),...t.lineStyle&&t.lineStyle!=="solid"?{strokeDasharray:A.chartLineDash(t.lineStyle),strokeDashoffset:0}:{},...m===void 0?{}:{"--aegis-line-chart-progress":m}}})]},t.key)),T&&g.map(({line:t,last:e,y:a})=>s.jsx("text",{className:"aegis-line-chart__end-label",x:h,y:a-y,textAnchor:"end",style:{fill:A.chartColorValue(t.color)},children:`${t.label} ${k(e.y)}`},t.key)),l!==void 0&&s.jsxs("g",{children:[s.jsx("line",{className:"aegis-line-chart__playhead",x1:x(l),x2:x(l),y1:j,y2:p}),s.jsx("text",{className:"aegis-line-chart__playhead-label",x:x(l),y:j-y/2,textAnchor:"middle",children:S(l)})]}),s.jsx("text",{className:"aegis-line-chart__tick",x:o,y:r-y,textAnchor:"start",children:S(i)}),s.jsx("text",{className:"aegis-line-chart__tick",x:h,y:r-y,textAnchor:"end",children:S(_)}),N!==void 0&&s.jsx("text",{className:"aegis-line-chart__tick",x:(o+h)/2,y:r-y,textAnchor:"middle",children:N}),c&&s.jsx("rect",{className:"aegis-line-chart__seek",x:o,y:j,width:h-o,height:p-j,role:"slider",tabIndex:0,"aria-label":q.replayPosition,"aria-valuemin":i,"aria-valuemax":_,"aria-valuenow":l??i,"aria-valuetext":S(l??i),onClick:O,onKeyDown:U}),B.map(t=>s.jsx("circle",{className:"aegis-line-chart__marker",cx:x(t.x),cy:p,r:J,style:{fill:A.chartColorValue(t.color)},onClick:c?()=>{c(t.x)}:void 0,children:s.jsx("title",{children:t.label})},t.key))]})})}exports.LineChart=Q;
2
2
  //# sourceMappingURL=LineChart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.cjs","sources":["../../../src/components/ui/LineChart.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n useRef,\n} from 'react';\n\nimport { useElementWidth } from '../../hooks/useElementWidth';\nimport { type ChartColor, chartColorValue, niceTicks } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './LineChart.css';\n\nexport interface LineChartPoint {\n x: number;\n y: number;\n}\n\nexport interface LineChartSeries {\n key: string;\n /** Written at the end of the line, with its last value. */\n label: string;\n color: ChartColor;\n points: LineChartPoint[];\n}\n\nexport interface LineChartMarker {\n key: string;\n x: number;\n color: ChartColor;\n /** Names the event in its tooltip. */\n label: string;\n}\n\nexport interface LineChartProps {\n series: LineChartSeries[];\n /** Names the chart for a screen reader. */\n label: string;\n /** False when the host supplies a separate series legend. */\n endLabels?: boolean;\n /** Names the horizontal axis, e.g. \"回合\". */\n xLabel?: string;\n /** The gridlines. Defaults to about five round values. */\n yTicks?: number[];\n formatX?: (value: number) => string;\n formatY?: (value: number) => string;\n /** Where a replay's playhead is on the horizontal axis. */\n playhead?: number;\n /** Lets the reader click or use the arrow keys to move the playhead. */\n onSeek?: (x: number) => void;\n /** Events on the horizontal axis, e.g. a replay's key moments. */\n markers?: LineChartMarker[];\n /**\n * How far the lines are drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`). Omitted, it shows its final state.\n */\n progress?: number;\n className?: string;\n}\n\n// The SVG is drawn at its measured CSS width, so these are true px.\nconst HEIGHT = 240;\nconst PAD_LEFT = 32;\nconst PAD_RIGHT = 8;\nconst PAD_TOP = 20;\nconst PAD_BOTTOM = 28;\nconst END_LABEL_GAP = 8;\nconst END_LABEL_LINE = 16;\nconst MARKER_RADIUS = 4;\n\n/**\n * Lines over a shared horizontal axis, labelled at their ends instead of\n * in a legend, with an optional playhead the reader can move.\n */\nexport function LineChart({\n series,\n label,\n endLabels = true,\n xLabel,\n yTicks,\n formatX = String,\n formatY = String,\n playhead,\n onSeek,\n markers = [],\n progress,\n className,\n}: LineChartProps): ReactElement {\n const strings = useStrings();\n const wrapRef = useRef<HTMLDivElement>(null);\n const width = useElementWidth(wrapRef);\n const points = series.flatMap((line) => line.points);\n const xs = [...new Set(points.map((point) => point.x))].sort((a, b) => a - b);\n const cls = ['aegis-line-chart', className ?? ''].filter(Boolean).join(' ');\n if (width === 0 || xs.length === 0) {\n return <div ref={wrapRef} className={cls} />;\n }\n\n const xLo = xs[0];\n const xHi = xs[xs.length - 1];\n const values = points.map((point) => point.y);\n const ticks = yTicks ?? niceTicks(0, Math.max(...values, 1));\n const yHi = Math.max(...ticks, ...values);\n const left = PAD_LEFT;\n const right = width - PAD_RIGHT;\n const top = PAD_TOP;\n const bottom = HEIGHT - PAD_BOTTOM;\n const sx = (x: number): number =>\n left + (xHi > xLo ? (x - xLo) / (xHi - xLo) : 0) * (right - left);\n const sy = (y: number): number => bottom - (y / yHi) * (bottom - top);\n\n // The end labels stack upwards when two lines finish close together, so\n // the lowest stays where its line ends and none runs into the x axis.\n const ends = series\n .flatMap((line) => {\n const last = line.points[line.points.length - 1] as\n | LineChartPoint\n | undefined;\n return last === undefined ? [] : [{ line, last, y: sy(last.y) }];\n })\n .sort((a, b) => b.y - a.y);\n for (let i = 1; i < ends.length; i += 1) {\n if (ends[i - 1].y - ends[i].y < END_LABEL_LINE) {\n ends[i].y = ends[i - 1].y - END_LABEL_LINE;\n }\n }\n\n const nearestX = (x: number): number =>\n xs.reduce((best, candidate) =>\n Math.abs(candidate - x) < Math.abs(best - x) ? candidate : best,\n );\n const seekFromPointer = (event: MouseEvent<SVGRectElement>): void => {\n const box = event.currentTarget.getBoundingClientRect();\n const share = (event.clientX - box.left) / box.width;\n onSeek?.(nearestX(xLo + share * (xHi - xLo)));\n };\n const seekFromKey = (event: KeyboardEvent<SVGRectElement>): void => {\n const index = xs.indexOf(nearestX(playhead ?? xLo));\n const target: Record<string, number> = {\n ArrowLeft: index - 1,\n ArrowDown: index - 1,\n ArrowRight: index + 1,\n ArrowUp: index + 1,\n Home: 0,\n End: xs.length - 1,\n };\n if (event.key in target) {\n event.preventDefault();\n onSeek?.(xs[Math.min(Math.max(target[event.key], 0), xs.length - 1)]);\n }\n };\n\n return (\n <div ref={wrapRef} className={cls}>\n <svg\n className=\"aegis-line-chart__svg\"\n width={width}\n height={HEIGHT}\n viewBox={`0 0 ${width.toString()} ${HEIGHT.toString()}`}\n role={onSeek ? 'group' : 'img'}\n aria-label={label}\n >\n {ticks.map((tick) => (\n <g key={tick}>\n <line\n className=\"aegis-line-chart__grid\"\n x1={left}\n x2={right}\n y1={sy(tick)}\n y2={sy(tick)}\n />\n <text\n className=\"aegis-line-chart__tick\"\n x={left - END_LABEL_GAP}\n y={sy(tick)}\n textAnchor=\"end\"\n dominantBaseline=\"middle\"\n >\n {formatY(tick)}\n </text>\n </g>\n ))}\n {series.map((line) => (\n <polyline\n key={line.key}\n className=\"aegis-line-chart__line\"\n pathLength={1}\n points={line.points\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n style={\n {\n stroke: chartColorValue(line.color),\n ...(progress === undefined\n ? {}\n : { '--aegis-line-chart-progress': progress }),\n } as CSSProperties\n }\n />\n ))}\n {endLabels &&\n ends.map(({ line, last, y }) => (\n <text\n key={line.key}\n className=\"aegis-line-chart__end-label\"\n x={right}\n y={y - END_LABEL_GAP}\n textAnchor=\"end\"\n style={{ fill: chartColorValue(line.color) }}\n >\n {`${line.label} ${formatY(last.y)}`}\n </text>\n ))}\n {playhead !== undefined && (\n <g>\n <line\n className=\"aegis-line-chart__playhead\"\n x1={sx(playhead)}\n x2={sx(playhead)}\n y1={top}\n y2={bottom}\n />\n <text\n className=\"aegis-line-chart__playhead-label\"\n x={sx(playhead)}\n y={top - END_LABEL_GAP / 2}\n textAnchor=\"middle\"\n >\n {formatX(playhead)}\n </text>\n </g>\n )}\n <text\n className=\"aegis-line-chart__tick\"\n x={left}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"start\"\n >\n {formatX(xLo)}\n </text>\n <text\n className=\"aegis-line-chart__tick\"\n x={right}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"end\"\n >\n {formatX(xHi)}\n </text>\n {xLabel !== undefined && (\n <text\n className=\"aegis-line-chart__tick\"\n x={(left + right) / 2}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"middle\"\n >\n {xLabel}\n </text>\n )}\n {onSeek && (\n <rect\n className=\"aegis-line-chart__seek\"\n x={left}\n y={top}\n width={right - left}\n height={bottom - top}\n role=\"slider\"\n tabIndex={0}\n aria-label={strings.replayPosition}\n aria-valuemin={xLo}\n aria-valuemax={xHi}\n aria-valuenow={playhead ?? xLo}\n aria-valuetext={formatX(playhead ?? xLo)}\n onClick={seekFromPointer}\n onKeyDown={seekFromKey}\n />\n )}\n {markers.map((marker) => (\n <circle\n key={marker.key}\n className=\"aegis-line-chart__marker\"\n cx={sx(marker.x)}\n cy={bottom}\n r={MARKER_RADIUS}\n style={{ fill: chartColorValue(marker.color) }}\n onClick={\n onSeek\n ? () => {\n onSeek(marker.x);\n }\n : undefined\n }\n >\n <title>{marker.label}</title>\n </circle>\n ))}\n </svg>\n </div>\n );\n}\n"],"names":["HEIGHT","PAD_LEFT","PAD_RIGHT","PAD_TOP","PAD_BOTTOM","END_LABEL_GAP","END_LABEL_LINE","MARKER_RADIUS","LineChart","series","label","endLabels","xLabel","yTicks","formatX","formatY","playhead","onSeek","markers","progress","className","strings","useStrings","wrapRef","useRef","width","useElementWidth","points","line","xs","point","a","b","cls","jsx","xLo","xHi","values","ticks","niceTicks","yHi","left","right","top","bottom","sx","x","sy","y","ends","last","i","nearestX","best","candidate","seekFromPointer","event","box","share","seekFromKey","index","target","jsxs","tick","chartColorValue","marker"],"mappings":"oSA6DMA,EAAS,IACTC,EAAW,GACXC,EAAY,EACZC,EAAU,GACVC,EAAa,GACbC,EAAgB,EAChBC,EAAiB,GACjBC,EAAgB,EAMf,SAASC,EAAU,CACxB,OAAAC,EACA,MAAAC,EACA,UAAAC,EAAY,GACZ,OAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,OACV,QAAAC,EAAU,OACV,SAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,CAAA,EACV,SAAAC,EACA,UAAAC,CACF,EAAiC,CAC/B,MAAMC,EAAUC,EAAAA,WAAA,EACVC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAQC,EAAAA,gBAAgBH,CAAO,EAC/BI,EAASlB,EAAO,QAASmB,GAASA,EAAK,MAAM,EAC7CC,EAAK,CAAC,GAAG,IAAI,IAAIF,EAAO,IAAKG,GAAUA,EAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAACC,EAAGC,IAAMD,EAAIC,CAAC,EACtEC,EAAM,CAAC,mBAAoBb,GAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAC1E,GAAIK,IAAU,GAAKI,EAAG,SAAW,EAC/B,OAAOK,EAAAA,IAAC,MAAA,CAAI,IAAKX,EAAS,UAAWU,EAAK,EAG5C,MAAME,EAAMN,EAAG,CAAC,EACVO,EAAMP,EAAGA,EAAG,OAAS,CAAC,EACtBQ,EAASV,EAAO,IAAKG,GAAUA,EAAM,CAAC,EACtCQ,EAAQzB,GAAU0B,EAAAA,UAAU,EAAG,KAAK,IAAI,GAAGF,EAAQ,C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CAAA,EAGdzC,EAAQ,IAAK+C,GACZ/B,EAAAA,IAAC,SAAA,CAEC,UAAU,2BACV,GAAIW,EAAGoB,EAAO,CAAC,EACf,GAAIrB,EACJ,EAAGrC,EACH,MAAO,CAAE,KAAMyD,EAAAA,gBAAgBC,EAAO,KAAK,CAAA,EAC3C,QACEhD,EACI,IAAM,CACJA,EAAOgD,EAAO,CAAC,CACjB,EACA,OAGN,SAAA/B,EAAAA,IAAC,QAAA,CAAO,SAAA+B,EAAO,KAAA,CAAM,CAAA,EAdhBA,EAAO,GAAA,CAgBf,CAAA,CAAA,CAAA,EAEL,CAEJ"}
1
+ {"version":3,"file":"LineChart.cjs","sources":["../../../src/components/ui/LineChart.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n useId,\n useRef,\n} from 'react';\n\nimport { useElementWidth } from '../../hooks/useElementWidth';\nimport {\n type ChartColor,\n type ChartLineStyle,\n chartColorValue,\n chartLineDash,\n niceTicks,\n} from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './LineChart.css';\n\nexport interface LineChartPoint {\n x: number;\n y: number;\n}\n\nexport interface LineChartSeries {\n key: string;\n /** Written at the end of the line, with its last value. */\n label: string;\n color: ChartColor;\n lineStyle?: ChartLineStyle;\n points: LineChartPoint[];\n}\n\nexport interface LineChartMarker {\n key: string;\n x: number;\n color: ChartColor;\n /** Names the event in its tooltip. */\n label: string;\n}\n\nexport interface LineChartProps {\n series: LineChartSeries[];\n /** Names the chart for a screen reader. */\n label: string;\n /** False when the host supplies a separate series legend. */\n endLabels?: boolean;\n /** Names the horizontal axis, e.g. \"回合\". */\n xLabel?: string;\n /** The gridlines. Defaults to about five round values. */\n yTicks?: number[];\n formatX?: (value: number) => string;\n formatY?: (value: number) => string;\n /** Where a replay's playhead is on the horizontal axis. */\n playhead?: number;\n /** Lets the reader click or use the arrow keys to move the playhead. */\n onSeek?: (x: number) => void;\n /** Events on the horizontal axis, e.g. a replay's key moments. */\n markers?: LineChartMarker[];\n /**\n * How far the lines are drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`). Omitted, it shows its final state.\n */\n progress?: number;\n className?: string;\n}\n\n// The SVG is drawn at its measured CSS width, so these are true px.\nconst HEIGHT = 240;\nconst PAD_LEFT = 32;\nconst PAD_RIGHT = 8;\nconst PAD_TOP = 20;\nconst PAD_BOTTOM = 28;\nconst END_LABEL_GAP = 8;\nconst END_LABEL_LINE = 16;\nconst MARKER_RADIUS = 4;\n\n/**\n * Lines over a shared horizontal axis, labelled at their ends instead of\n * in a legend, with an optional playhead the reader can move.\n */\nexport function LineChart({\n series,\n label,\n endLabels = true,\n xLabel,\n yTicks,\n formatX = String,\n formatY = String,\n playhead,\n onSeek,\n markers = [],\n progress,\n className,\n}: LineChartProps): ReactElement {\n const strings = useStrings();\n const maskId = useId();\n const wrapRef = useRef<HTMLDivElement>(null);\n const width = useElementWidth(wrapRef);\n const points = series.flatMap((line) => line.points);\n const xs = [...new Set(points.map((point) => point.x))].sort((a, b) => a - b);\n const cls = ['aegis-line-chart', className ?? ''].filter(Boolean).join(' ');\n if (width === 0 || xs.length === 0) {\n return <div ref={wrapRef} className={cls} />;\n }\n\n const xLo = xs[0];\n const xHi = xs[xs.length - 1];\n const values = points.map((point) => point.y);\n const ticks = yTicks ?? niceTicks(0, Math.max(...values, 1));\n const yHi = Math.max(...ticks, ...values);\n const left = PAD_LEFT;\n const right = width - PAD_RIGHT;\n const top = PAD_TOP;\n const bottom = HEIGHT - PAD_BOTTOM;\n const sx = (x: number): number =>\n left + (xHi > xLo ? (x - xLo) / (xHi - xLo) : 0) * (right - left);\n const sy = (y: number): number => bottom - (y / yHi) * (bottom - top);\n\n // The end labels stack upwards when two lines finish close together, so\n // the lowest stays where its line ends and none runs into the x axis.\n const ends = series\n .flatMap((line) => {\n const last = line.points[line.points.length - 1] as\n | LineChartPoint\n | undefined;\n return last === undefined ? [] : [{ line, last, y: sy(last.y) }];\n })\n .sort((a, b) => b.y - a.y);\n for (let i = 1; i < ends.length; i += 1) {\n if (ends[i - 1].y - ends[i].y < END_LABEL_LINE) {\n ends[i].y = ends[i - 1].y - END_LABEL_LINE;\n }\n }\n\n const nearestX = (x: number): number =>\n xs.reduce((best, candidate) =>\n Math.abs(candidate - x) < Math.abs(best - x) ? candidate : best,\n );\n const seekFromPointer = (event: MouseEvent<SVGRectElement>): void => {\n const box = event.currentTarget.getBoundingClientRect();\n const share = (event.clientX - box.left) / box.width;\n onSeek?.(nearestX(xLo + share * (xHi - xLo)));\n };\n const seekFromKey = (event: KeyboardEvent<SVGRectElement>): void => {\n const index = xs.indexOf(nearestX(playhead ?? xLo));\n const target: Record<string, number> = {\n ArrowLeft: index - 1,\n ArrowDown: index - 1,\n ArrowRight: index + 1,\n ArrowUp: index + 1,\n Home: 0,\n End: xs.length - 1,\n };\n if (event.key in target) {\n event.preventDefault();\n onSeek?.(xs[Math.min(Math.max(target[event.key], 0), xs.length - 1)]);\n }\n };\n\n return (\n <div ref={wrapRef} className={cls}>\n <svg\n className=\"aegis-line-chart__svg\"\n width={width}\n height={HEIGHT}\n viewBox={`0 0 ${width.toString()} ${HEIGHT.toString()}`}\n role={onSeek ? 'group' : 'img'}\n aria-label={label}\n >\n {ticks.map((tick) => (\n <g key={tick}>\n <line\n className=\"aegis-line-chart__grid\"\n x1={left}\n x2={right}\n y1={sy(tick)}\n y2={sy(tick)}\n />\n <text\n className=\"aegis-line-chart__tick\"\n x={left - END_LABEL_GAP}\n y={sy(tick)}\n textAnchor=\"end\"\n dominantBaseline=\"middle\"\n >\n {formatY(tick)}\n </text>\n </g>\n ))}\n {series.map((line) => (\n <g key={line.key}>\n {line.lineStyle &&\n line.lineStyle !== 'solid' &&\n progress !== undefined && (\n <mask\n id={`${maskId}-${line.key}`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={width}\n height={HEIGHT}\n >\n <polyline\n className=\"aegis-line-chart__line\"\n pathLength={1}\n points={line.points\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n style={\n {\n stroke: 'white',\n '--aegis-line-chart-progress': progress,\n } as CSSProperties\n }\n />\n </mask>\n )}\n <polyline\n className=\"aegis-line-chart__line\"\n pathLength={\n !line.lineStyle || line.lineStyle === 'solid' ? 1 : undefined\n }\n mask={\n line.lineStyle &&\n line.lineStyle !== 'solid' &&\n progress !== undefined\n ? `url(#${maskId}-${line.key})`\n : undefined\n }\n points={line.points\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n style={\n {\n stroke: chartColorValue(line.color),\n ...(line.lineStyle && line.lineStyle !== 'solid'\n ? {\n strokeDasharray: chartLineDash(line.lineStyle),\n strokeDashoffset: 0,\n }\n : {}),\n ...(progress === undefined\n ? {}\n : { '--aegis-line-chart-progress': progress }),\n } as CSSProperties\n }\n />\n </g>\n ))}\n {endLabels &&\n ends.map(({ line, last, y }) => (\n <text\n key={line.key}\n className=\"aegis-line-chart__end-label\"\n x={right}\n y={y - END_LABEL_GAP}\n textAnchor=\"end\"\n style={{ fill: chartColorValue(line.color) }}\n >\n {`${line.label} ${formatY(last.y)}`}\n </text>\n ))}\n {playhead !== undefined && (\n <g>\n <line\n className=\"aegis-line-chart__playhead\"\n x1={sx(playhead)}\n x2={sx(playhead)}\n y1={top}\n y2={bottom}\n />\n <text\n className=\"aegis-line-chart__playhead-label\"\n x={sx(playhead)}\n y={top - END_LABEL_GAP / 2}\n textAnchor=\"middle\"\n >\n {formatX(playhead)}\n </text>\n </g>\n )}\n <text\n className=\"aegis-line-chart__tick\"\n x={left}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"start\"\n >\n {formatX(xLo)}\n </text>\n <text\n className=\"aegis-line-chart__tick\"\n x={right}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"end\"\n >\n {formatX(xHi)}\n </text>\n {xLabel !== undefined && (\n <text\n className=\"aegis-line-chart__tick\"\n x={(left + right) / 2}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"middle\"\n >\n {xLabel}\n </text>\n )}\n {onSeek && (\n <rect\n className=\"aegis-line-chart__seek\"\n x={left}\n y={top}\n width={right - left}\n height={bottom - top}\n role=\"slider\"\n tabIndex={0}\n aria-label={strings.replayPosition}\n aria-valuemin={xLo}\n aria-valuemax={xHi}\n aria-valuenow={playhead ?? xLo}\n aria-valuetext={formatX(playhead ?? xLo)}\n onClick={seekFromPointer}\n onKeyDown={seekFromKey}\n />\n )}\n {markers.map((marker) => (\n <circle\n key={marker.key}\n className=\"aegis-line-chart__marker\"\n cx={sx(marker.x)}\n cy={bottom}\n r={MARKER_RADIUS}\n style={{ fill: chartColorValue(marker.color) }}\n onClick={\n onSeek\n ? () => {\n onSeek(marker.x);\n }\n : undefined\n }\n >\n <title>{marker.label}</title>\n </circle>\n ))}\n </svg>\n </div>\n );\n}\n"],"names":["HEIGHT","PAD_LEFT","PAD_RIGHT","PAD_TOP","PAD_BOTTOM","END_LABEL_GAP","END_LABEL_LINE","MARKER_RADIUS","LineChart","series","label","endLabels","xLabel","yTicks","formatX","formatY","playhead","onSeek","markers","progress","className","strings","useStrings","maskId","useId","wrapRef","useRef","width","useElementWidth","points","line","xs","point","a","b","cls","jsx","xLo","xHi","values","ticks","niceTicks","yHi","left","right","top","bottom","sx","x","sy","y","ends","last","i","nearestX","best","candidate","seekFromPointer","event","box","share","seekFromKey","index","target","jsxs","tick","chartColorValue","chartLineDash","marker"],"mappings":"oSAqEMA,EAAS,IACTC,EAAW,GACXC,EAAY,EACZC,EAAU,GACVC,EAAa,GACbC,EAAgB,EAChBC,EAAiB,GACjBC,EAAgB,EAMf,SAASC,EAAU,CACxB,OAAAC,EACA,MAAAC,EACA,UAAAC,EAAY,GACZ,OAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,OACV,QAAAC,EAAU,OACV,SAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,CAAA,EACV,SAAA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ACH,EAAGE,EACH,MAAOD,EAAQD,EACf,OAAQG,EAASD,EACjB,KAAK,SACL,SAAU,EACV,aAAYxB,EAAQ,eACpB,gBAAegB,EACf,gBAAeC,EACf,gBAAetB,GAAYqB,EAC3B,iBAAgBvB,EAAQE,GAAYqB,CAAG,EACvC,QAASoB,EACT,UAAWI,CAAA,CAAA,EAGd3C,EAAQ,IAAKkD,GACZhC,EAAAA,IAAC,SAAA,CAEC,UAAU,2BACV,GAAIW,EAAGqB,EAAO,CAAC,EACf,GAAItB,EACJ,EAAGvC,EACH,MAAO,CAAE,KAAM2D,EAAAA,gBAAgBE,EAAO,KAAK,CAAA,EAC3C,QACEnD,EACI,IAAM,CACJA,EAAOmD,EAAO,CAAC,CACjB,EACA,OAGN,SAAAhC,EAAAA,IAAC,QAAA,CAAO,SAAAgC,EAAO,KAAA,CAAM,CAAA,EAdhBA,EAAO,GAAA,CAgBf,CAAA,CAAA,CAAA,EAEL,CAEJ"}
@@ -1,5 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { ChartColor } from '../../lib/chart';
2
+ import { ChartColor, ChartLineStyle } from '../../lib/chart';
3
3
  export interface LineChartPoint {
4
4
  x: number;
5
5
  y: number;
@@ -9,6 +9,7 @@ export interface LineChartSeries {
9
9
  /** Written at the end of the line, with its last value. */
10
10
  label: string;
11
11
  color: ChartColor;
12
+ lineStyle?: ChartLineStyle;
12
13
  points: LineChartPoint[];
13
14
  }
14
15
  export interface LineChartMarker {
@@ -1,192 +1,223 @@
1
- import { jsx as n, jsxs as v } from "react/jsx-runtime";
2
- import { useRef as G } from "react";
3
- import { useElementWidth as K } from "../../hooks/useElementWidth.js";
4
- import { niceTicks as U, chartColorValue as w } from "../../lib/chart.js";
1
+ import { jsx as i, jsxs as N } from "react/jsx-runtime";
2
+ import { useId as G, useRef as K } from "react";
3
+ import { useElementWidth as V } from "../../hooks/useElementWidth.js";
4
+ import { niceTicks as W, chartLineDash as q, chartColorValue as k } from "../../lib/chart.js";
5
5
  /* empty css */
6
- import { useStrings as V } from "../../locale/useStrings.js";
7
- const g = 240, W = 32, q = 8, z = 20, J = 28, x = 8, B = 16, Q = 4;
8
- function it({
9
- series: A,
10
- label: H,
11
- endLabels: $ = !0,
12
- xLabel: D,
13
- yTicks: k,
14
- formatX: f = String,
15
- formatY: E = String,
16
- playhead: a,
6
+ import { useStrings as z } from "../../locale/useStrings.js";
7
+ const c = 240, J = 32, Q = 8, Z = 20, X = 28, m = 8, R = 16, Y = 4;
8
+ function ot({
9
+ series: v,
10
+ label: T,
11
+ endLabels: B = !0,
12
+ xLabel: w,
13
+ yTicks: I,
14
+ formatX: A = String,
15
+ formatY: D = String,
16
+ playhead: o,
17
17
  onSeek: r,
18
- markers: C = [],
19
- progress: M,
20
- className: I
18
+ markers: H = [],
19
+ progress: x,
20
+ className: j
21
21
  }) {
22
- const j = V(), N = G(null), u = K(N), b = A.flatMap((t) => t.points), s = [...new Set(b.map((t) => t.x))].sort((t, e) => t - e), L = ["aegis-line-chart", I ?? ""].filter(Boolean).join(" ");
23
- if (u === 0 || s.length === 0)
24
- return /* @__PURE__ */ n("div", { ref: N, className: L });
25
- const i = s[0], m = s[s.length - 1], P = b.map((t) => t.y), R = k ?? U(0, Math.max(...P, 1)), O = Math.max(...R, ...P), c = W, l = u - q, d = z, _ = g - J, y = (t) => c + (m > i ? (t - i) / (m - i) : 0) * (l - c), p = (t) => _ - t / O * (_ - d), h = A.flatMap((t) => {
22
+ const C = z(), $ = G(), S = K(null), _ = V(S), L = v.flatMap((t) => t.points), n = [...new Set(L.map((t) => t.x))].sort((t, e) => t - e), E = ["aegis-line-chart", j ?? ""].filter(Boolean).join(" ");
23
+ if (_ === 0 || n.length === 0)
24
+ return /* @__PURE__ */ i("div", { ref: S, className: E });
25
+ const s = n[0], p = n[n.length - 1], M = L.map((t) => t.y), b = I ?? W(0, Math.max(...M, 1)), O = Math.max(...b, ...M), l = J, h = _ - Q, u = Z, f = c - X, d = (t) => l + (p > s ? (t - s) / (p - s) : 0) * (h - l), g = (t) => f - t / O * (f - u), y = v.flatMap((t) => {
26
26
  const e = t.points[t.points.length - 1];
27
- return e === void 0 ? [] : [{ line: t, last: e, y: p(e.y) }];
27
+ return e === void 0 ? [] : [{ line: t, last: e, y: g(e.y) }];
28
28
  }).sort((t, e) => e.y - t.y);
29
- for (let t = 1; t < h.length; t += 1)
30
- h[t - 1].y - h[t].y < B && (h[t].y = h[t - 1].y - B);
31
- const T = (t) => s.reduce(
32
- (e, o) => Math.abs(o - t) < Math.abs(e - t) ? o : e
33
- ), S = (t) => {
34
- const e = t.currentTarget.getBoundingClientRect(), o = (t.clientX - e.left) / e.width;
35
- r?.(T(i + o * (m - i)));
29
+ for (let t = 1; t < y.length; t += 1)
30
+ y[t - 1].y - y[t].y < R && (y[t].y = y[t - 1].y - R);
31
+ const P = (t) => n.reduce(
32
+ (e, a) => Math.abs(a - t) < Math.abs(e - t) ? a : e
33
+ ), U = (t) => {
34
+ const e = t.currentTarget.getBoundingClientRect(), a = (t.clientX - e.left) / e.width;
35
+ r?.(P(s + a * (p - s)));
36
36
  }, F = (t) => {
37
- const e = s.indexOf(T(a ?? i)), o = {
37
+ const e = n.indexOf(P(o ?? s)), a = {
38
38
  ArrowLeft: e - 1,
39
39
  ArrowDown: e - 1,
40
40
  ArrowRight: e + 1,
41
41
  ArrowUp: e + 1,
42
42
  Home: 0,
43
- End: s.length - 1
43
+ End: n.length - 1
44
44
  };
45
- t.key in o && (t.preventDefault(), r?.(s[Math.min(Math.max(o[t.key], 0), s.length - 1)]));
45
+ t.key in a && (t.preventDefault(), r?.(n[Math.min(Math.max(a[t.key], 0), n.length - 1)]));
46
46
  };
47
- return /* @__PURE__ */ n("div", { ref: N, className: L, children: /* @__PURE__ */ v(
47
+ return /* @__PURE__ */ i("div", { ref: S, className: E, children: /* @__PURE__ */ N(
48
48
  "svg",
49
49
  {
50
50
  className: "aegis-line-chart__svg",
51
- width: u,
52
- height: g,
53
- viewBox: `0 0 ${u.toString()} ${g.toString()}`,
51
+ width: _,
52
+ height: c,
53
+ viewBox: `0 0 ${_.toString()} ${c.toString()}`,
54
54
  role: r ? "group" : "img",
55
- "aria-label": H,
55
+ "aria-label": T,
56
56
  children: [
57
- R.map((t) => /* @__PURE__ */ v("g", { children: [
58
- /* @__PURE__ */ n(
57
+ b.map((t) => /* @__PURE__ */ N("g", { children: [
58
+ /* @__PURE__ */ i(
59
59
  "line",
60
60
  {
61
61
  className: "aegis-line-chart__grid",
62
- x1: c,
63
- x2: l,
64
- y1: p(t),
65
- y2: p(t)
62
+ x1: l,
63
+ x2: h,
64
+ y1: g(t),
65
+ y2: g(t)
66
66
  }
67
67
  ),
68
- /* @__PURE__ */ n(
68
+ /* @__PURE__ */ i(
69
69
  "text",
70
70
  {
71
71
  className: "aegis-line-chart__tick",
72
- x: c - x,
73
- y: p(t),
72
+ x: l - m,
73
+ y: g(t),
74
74
  textAnchor: "end",
75
75
  dominantBaseline: "middle",
76
- children: E(t)
76
+ children: D(t)
77
77
  }
78
78
  )
79
79
  ] }, t)),
80
- A.map((t) => /* @__PURE__ */ n(
81
- "polyline",
82
- {
83
- className: "aegis-line-chart__line",
84
- pathLength: 1,
85
- points: t.points.map(
86
- (e) => `${y(e.x).toString()},${p(e.y).toString()}`
87
- ).join(" "),
88
- style: {
89
- stroke: w(t.color),
90
- ...M === void 0 ? {} : { "--aegis-line-chart-progress": M }
80
+ v.map((t) => /* @__PURE__ */ N("g", { children: [
81
+ t.lineStyle && t.lineStyle !== "solid" && x !== void 0 && /* @__PURE__ */ i(
82
+ "mask",
83
+ {
84
+ id: `${$}-${t.key}`,
85
+ maskUnits: "userSpaceOnUse",
86
+ x: 0,
87
+ y: 0,
88
+ width: _,
89
+ height: c,
90
+ children: /* @__PURE__ */ i(
91
+ "polyline",
92
+ {
93
+ className: "aegis-line-chart__line",
94
+ pathLength: 1,
95
+ points: t.points.map(
96
+ (e) => `${d(e.x).toString()},${g(e.y).toString()}`
97
+ ).join(" "),
98
+ style: {
99
+ stroke: "white",
100
+ "--aegis-line-chart-progress": x
101
+ }
102
+ }
103
+ )
91
104
  }
92
- },
93
- t.key
94
- )),
95
- $ && h.map(({ line: t, last: e, y: o }) => /* @__PURE__ */ n(
105
+ ),
106
+ /* @__PURE__ */ i(
107
+ "polyline",
108
+ {
109
+ className: "aegis-line-chart__line",
110
+ pathLength: !t.lineStyle || t.lineStyle === "solid" ? 1 : void 0,
111
+ mask: t.lineStyle && t.lineStyle !== "solid" && x !== void 0 ? `url(#${$}-${t.key})` : void 0,
112
+ points: t.points.map(
113
+ (e) => `${d(e.x).toString()},${g(e.y).toString()}`
114
+ ).join(" "),
115
+ style: {
116
+ stroke: k(t.color),
117
+ ...t.lineStyle && t.lineStyle !== "solid" ? {
118
+ strokeDasharray: q(t.lineStyle),
119
+ strokeDashoffset: 0
120
+ } : {},
121
+ ...x === void 0 ? {} : { "--aegis-line-chart-progress": x }
122
+ }
123
+ }
124
+ )
125
+ ] }, t.key)),
126
+ B && y.map(({ line: t, last: e, y: a }) => /* @__PURE__ */ i(
96
127
  "text",
97
128
  {
98
129
  className: "aegis-line-chart__end-label",
99
- x: l,
100
- y: o - x,
130
+ x: h,
131
+ y: a - m,
101
132
  textAnchor: "end",
102
- style: { fill: w(t.color) },
103
- children: `${t.label} ${E(e.y)}`
133
+ style: { fill: k(t.color) },
134
+ children: `${t.label} ${D(e.y)}`
104
135
  },
105
136
  t.key
106
137
  )),
107
- a !== void 0 && /* @__PURE__ */ v("g", { children: [
108
- /* @__PURE__ */ n(
138
+ o !== void 0 && /* @__PURE__ */ N("g", { children: [
139
+ /* @__PURE__ */ i(
109
140
  "line",
110
141
  {
111
142
  className: "aegis-line-chart__playhead",
112
- x1: y(a),
113
- x2: y(a),
114
- y1: d,
115
- y2: _
143
+ x1: d(o),
144
+ x2: d(o),
145
+ y1: u,
146
+ y2: f
116
147
  }
117
148
  ),
118
- /* @__PURE__ */ n(
149
+ /* @__PURE__ */ i(
119
150
  "text",
120
151
  {
121
152
  className: "aegis-line-chart__playhead-label",
122
- x: y(a),
123
- y: d - x / 2,
153
+ x: d(o),
154
+ y: u - m / 2,
124
155
  textAnchor: "middle",
125
- children: f(a)
156
+ children: A(o)
126
157
  }
127
158
  )
128
159
  ] }),
129
- /* @__PURE__ */ n(
160
+ /* @__PURE__ */ i(
130
161
  "text",
131
162
  {
132
163
  className: "aegis-line-chart__tick",
133
- x: c,
134
- y: g - x,
164
+ x: l,
165
+ y: c - m,
135
166
  textAnchor: "start",
136
- children: f(i)
167
+ children: A(s)
137
168
  }
138
169
  ),
139
- /* @__PURE__ */ n(
170
+ /* @__PURE__ */ i(
140
171
  "text",
141
172
  {
142
173
  className: "aegis-line-chart__tick",
143
- x: l,
144
- y: g - x,
174
+ x: h,
175
+ y: c - m,
145
176
  textAnchor: "end",
146
- children: f(m)
177
+ children: A(p)
147
178
  }
148
179
  ),
149
- D !== void 0 && /* @__PURE__ */ n(
180
+ w !== void 0 && /* @__PURE__ */ i(
150
181
  "text",
151
182
  {
152
183
  className: "aegis-line-chart__tick",
153
- x: (c + l) / 2,
154
- y: g - x,
184
+ x: (l + h) / 2,
185
+ y: c - m,
155
186
  textAnchor: "middle",
156
- children: D
187
+ children: w
157
188
  }
158
189
  ),
159
- r && /* @__PURE__ */ n(
190
+ r && /* @__PURE__ */ i(
160
191
  "rect",
161
192
  {
162
193
  className: "aegis-line-chart__seek",
163
- x: c,
164
- y: d,
165
- width: l - c,
166
- height: _ - d,
194
+ x: l,
195
+ y: u,
196
+ width: h - l,
197
+ height: f - u,
167
198
  role: "slider",
168
199
  tabIndex: 0,
169
- "aria-label": j.replayPosition,
170
- "aria-valuemin": i,
171
- "aria-valuemax": m,
172
- "aria-valuenow": a ?? i,
173
- "aria-valuetext": f(a ?? i),
174
- onClick: S,
200
+ "aria-label": C.replayPosition,
201
+ "aria-valuemin": s,
202
+ "aria-valuemax": p,
203
+ "aria-valuenow": o ?? s,
204
+ "aria-valuetext": A(o ?? s),
205
+ onClick: U,
175
206
  onKeyDown: F
176
207
  }
177
208
  ),
178
- C.map((t) => /* @__PURE__ */ n(
209
+ H.map((t) => /* @__PURE__ */ i(
179
210
  "circle",
180
211
  {
181
212
  className: "aegis-line-chart__marker",
182
- cx: y(t.x),
183
- cy: _,
184
- r: Q,
185
- style: { fill: w(t.color) },
213
+ cx: d(t.x),
214
+ cy: f,
215
+ r: Y,
216
+ style: { fill: k(t.color) },
186
217
  onClick: r ? () => {
187
218
  r(t.x);
188
219
  } : void 0,
189
- children: /* @__PURE__ */ n("title", { children: t.label })
220
+ children: /* @__PURE__ */ i("title", { children: t.label })
190
221
  },
191
222
  t.key
192
223
  ))
@@ -195,6 +226,6 @@ function it({
195
226
  ) });
196
227
  }
197
228
  export {
198
- it as LineChart
229
+ ot as LineChart
199
230
  };
200
231
  //# sourceMappingURL=LineChart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.js","sources":["../../../src/components/ui/LineChart.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n useRef,\n} from 'react';\n\nimport { useElementWidth } from '../../hooks/useElementWidth';\nimport { type ChartColor, chartColorValue, niceTicks } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './LineChart.css';\n\nexport interface LineChartPoint {\n x: number;\n y: number;\n}\n\nexport interface LineChartSeries {\n key: string;\n /** Written at the end of the line, with its last value. */\n label: string;\n color: ChartColor;\n points: LineChartPoint[];\n}\n\nexport interface LineChartMarker {\n key: string;\n x: number;\n color: ChartColor;\n /** Names the event in its tooltip. */\n label: string;\n}\n\nexport interface LineChartProps {\n series: LineChartSeries[];\n /** Names the chart for a screen reader. */\n label: string;\n /** False when the host supplies a separate series legend. */\n endLabels?: boolean;\n /** Names the horizontal axis, e.g. \"回合\". */\n xLabel?: string;\n /** The gridlines. Defaults to about five round values. */\n yTicks?: number[];\n formatX?: (value: number) => string;\n formatY?: (value: number) => string;\n /** Where a replay's playhead is on the horizontal axis. */\n playhead?: number;\n /** Lets the reader click or use the arrow keys to move the playhead. */\n onSeek?: (x: number) => void;\n /** Events on the horizontal axis, e.g. a replay's key moments. */\n markers?: LineChartMarker[];\n /**\n * How far the lines are drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`). Omitted, it shows its final state.\n */\n progress?: number;\n className?: string;\n}\n\n// The SVG is drawn at its measured CSS width, so these are true px.\nconst HEIGHT = 240;\nconst PAD_LEFT = 32;\nconst PAD_RIGHT = 8;\nconst PAD_TOP = 20;\nconst PAD_BOTTOM = 28;\nconst END_LABEL_GAP = 8;\nconst END_LABEL_LINE = 16;\nconst MARKER_RADIUS = 4;\n\n/**\n * Lines over a shared horizontal axis, labelled at their ends instead of\n * in a legend, with an optional playhead the reader can move.\n */\nexport function LineChart({\n series,\n label,\n endLabels = true,\n xLabel,\n yTicks,\n formatX = String,\n formatY = String,\n playhead,\n onSeek,\n markers = [],\n progress,\n className,\n}: LineChartProps): ReactElement {\n const strings = useStrings();\n const wrapRef = useRef<HTMLDivElement>(null);\n const width = useElementWidth(wrapRef);\n const points = series.flatMap((line) => line.points);\n const xs = [...new Set(points.map((point) => point.x))].sort((a, b) => a - b);\n const cls = ['aegis-line-chart', className ?? ''].filter(Boolean).join(' ');\n if (width === 0 || xs.length === 0) {\n return <div ref={wrapRef} className={cls} />;\n }\n\n const xLo = xs[0];\n const xHi = xs[xs.length - 1];\n const values = points.map((point) => point.y);\n const ticks = yTicks ?? niceTicks(0, Math.max(...values, 1));\n const yHi = Math.max(...ticks, ...values);\n const left = PAD_LEFT;\n const right = width - PAD_RIGHT;\n const top = PAD_TOP;\n const bottom = HEIGHT - PAD_BOTTOM;\n const sx = (x: number): number =>\n left + (xHi > xLo ? (x - xLo) / (xHi - xLo) : 0) * (right - left);\n const sy = (y: number): number => bottom - (y / yHi) * (bottom - top);\n\n // The end labels stack upwards when two lines finish close together, so\n // the lowest stays where its line ends and none runs into the x axis.\n const ends = series\n .flatMap((line) => {\n const last = line.points[line.points.length - 1] as\n | LineChartPoint\n | undefined;\n return last === undefined ? [] : [{ line, last, y: sy(last.y) }];\n })\n .sort((a, b) => b.y - a.y);\n for (let i = 1; i < ends.length; i += 1) {\n if (ends[i - 1].y - ends[i].y < END_LABEL_LINE) {\n ends[i].y = ends[i - 1].y - END_LABEL_LINE;\n }\n }\n\n const nearestX = (x: number): number =>\n xs.reduce((best, candidate) =>\n Math.abs(candidate - x) < Math.abs(best - x) ? candidate : best,\n );\n const seekFromPointer = (event: MouseEvent<SVGRectElement>): void => {\n const box = event.currentTarget.getBoundingClientRect();\n const share = (event.clientX - box.left) / box.width;\n onSeek?.(nearestX(xLo + share * (xHi - xLo)));\n };\n const seekFromKey = (event: KeyboardEvent<SVGRectElement>): void => {\n const index = xs.indexOf(nearestX(playhead ?? xLo));\n const target: Record<string, number> = {\n ArrowLeft: index - 1,\n ArrowDown: index - 1,\n ArrowRight: index + 1,\n ArrowUp: index + 1,\n Home: 0,\n End: xs.length - 1,\n };\n if (event.key in target) {\n event.preventDefault();\n onSeek?.(xs[Math.min(Math.max(target[event.key], 0), xs.length - 1)]);\n }\n };\n\n return (\n <div ref={wrapRef} className={cls}>\n <svg\n className=\"aegis-line-chart__svg\"\n width={width}\n height={HEIGHT}\n viewBox={`0 0 ${width.toString()} ${HEIGHT.toString()}`}\n role={onSeek ? 'group' : 'img'}\n aria-label={label}\n >\n {ticks.map((tick) => (\n <g key={tick}>\n <line\n className=\"aegis-line-chart__grid\"\n x1={left}\n x2={right}\n y1={sy(tick)}\n y2={sy(tick)}\n />\n <text\n className=\"aegis-line-chart__tick\"\n x={left - END_LABEL_GAP}\n y={sy(tick)}\n textAnchor=\"end\"\n dominantBaseline=\"middle\"\n >\n {formatY(tick)}\n </text>\n </g>\n ))}\n {series.map((line) => (\n <polyline\n key={line.key}\n className=\"aegis-line-chart__line\"\n pathLength={1}\n points={line.points\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n style={\n {\n stroke: chartColorValue(line.color),\n ...(progress === undefined\n ? {}\n : { '--aegis-line-chart-progress': progress }),\n } as CSSProperties\n }\n />\n ))}\n {endLabels &&\n ends.map(({ line, last, y }) => (\n <text\n key={line.key}\n className=\"aegis-line-chart__end-label\"\n x={right}\n y={y - END_LABEL_GAP}\n textAnchor=\"end\"\n style={{ fill: chartColorValue(line.color) }}\n >\n {`${line.label} ${formatY(last.y)}`}\n </text>\n ))}\n {playhead !== undefined && (\n <g>\n <line\n className=\"aegis-line-chart__playhead\"\n x1={sx(playhead)}\n x2={sx(playhead)}\n y1={top}\n y2={bottom}\n />\n <text\n className=\"aegis-line-chart__playhead-label\"\n x={sx(playhead)}\n y={top - END_LABEL_GAP / 2}\n textAnchor=\"middle\"\n >\n {formatX(playhead)}\n </text>\n </g>\n )}\n <text\n className=\"aegis-line-chart__tick\"\n x={left}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"start\"\n >\n {formatX(xLo)}\n </text>\n <text\n className=\"aegis-line-chart__tick\"\n x={right}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"end\"\n >\n {formatX(xHi)}\n </text>\n {xLabel !== undefined && (\n <text\n className=\"aegis-line-chart__tick\"\n x={(left + right) / 2}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"middle\"\n >\n {xLabel}\n </text>\n )}\n {onSeek && (\n <rect\n className=\"aegis-line-chart__seek\"\n x={left}\n y={top}\n width={right - left}\n height={bottom - top}\n role=\"slider\"\n tabIndex={0}\n aria-label={strings.replayPosition}\n aria-valuemin={xLo}\n aria-valuemax={xHi}\n aria-valuenow={playhead ?? xLo}\n aria-valuetext={formatX(playhead ?? xLo)}\n onClick={seekFromPointer}\n onKeyDown={seekFromKey}\n />\n )}\n {markers.map((marker) => (\n <circle\n key={marker.key}\n className=\"aegis-line-chart__marker\"\n cx={sx(marker.x)}\n cy={bottom}\n r={MARKER_RADIUS}\n style={{ fill: chartColorValue(marker.color) }}\n onClick={\n onSeek\n ? () => {\n onSeek(marker.x);\n }\n : undefined\n }\n >\n <title>{marker.label}</title>\n </circle>\n ))}\n </svg>\n </div>\n );\n}\n"],"names":["HEIGHT","PAD_LEFT","PAD_RIGHT","PAD_TOP","PAD_BOTTOM","END_LABEL_GAP","END_LABEL_LINE","MARKER_RADIUS","LineChart","series","label","endLabels","xLabel","yTicks","formatX","formatY","playhead","onSeek","markers","progress","className","strings","useStrings","wrapRef","useRef","width","useElementWidth","points","line","xs","point","a","b","cls","jsx","xLo","xHi","values","ticks","niceTicks","yHi","left","right","top","bottom","sx","x","sy","y","ends","last","i","nearestX","best","candidate","seekFromPointer","event","box","share","seekFromKey","index","target","jsxs","tick","chartColorValue","marker"],"mappings":";;;;;;AA6DA,MAAMA,IAAS,KACTC,IAAW,IACXC,IAAY,GACZC,IAAU,IACVC,IAAa,IACbC,IAAgB,GAChBC,IAAiB,IACjBC,IAAgB;AAMf,SAASC,GAAU;AAAA,EACxB,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,SAAAC,IAAU;AAAA,EACV,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU,CAAA;AAAA,EACV,UAAAC;AAAA,EACA,WAAAC;AACF,GAAiC;AAC/B,QAAMC,IAAUC,EAAA,GACVC,IAAUC,EAAuB,IAAI,GACrCC,IAAQC,EAAgBH,CAAO,GAC/BI,IAASlB,EAAO,QAAQ,CAACmB,MAASA,EAAK,MAAM,GAC7CC,IAAK,CAAC,GAAG,IAAI,IAAIF,EAAO,IAAI,CAACG,MAAUA,EAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAACC,GAAGC,MAAMD,IAAIC,CAAC,GACtEC,IAAM,CAAC,oBAAoBb,KAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAC1E,MAAIK,MAAU,KAAKI,EAAG,WAAW;AAC/B,WAA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;AAAA,YACV,IAAIW,EAAGoB,EAAO,CAAC;AAAA,YACf,IAAIrB;AAAA,YACJ,GAAGrC;AAAA,YACH,OAAO,EAAE,MAAMyD,EAAgBC,EAAO,KAAK,EAAA;AAAA,YAC3C,SACEhD,IACI,MAAM;AACJ,cAAAA,EAAOgD,EAAO,CAAC;AAAA,YACjB,IACA;AAAA,YAGN,UAAA,gBAAA/B,EAAC,SAAA,EAAO,UAAA+B,EAAO,MAAA,CAAM;AAAA,UAAA;AAAA,UAdhBA,EAAO;AAAA,QAAA,CAgBf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEL;AAEJ;"}
1
+ {"version":3,"file":"LineChart.js","sources":["../../../src/components/ui/LineChart.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n useId,\n useRef,\n} from 'react';\n\nimport { useElementWidth } from '../../hooks/useElementWidth';\nimport {\n type ChartColor,\n type ChartLineStyle,\n chartColorValue,\n chartLineDash,\n niceTicks,\n} from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './LineChart.css';\n\nexport interface LineChartPoint {\n x: number;\n y: number;\n}\n\nexport interface LineChartSeries {\n key: string;\n /** Written at the end of the line, with its last value. */\n label: string;\n color: ChartColor;\n lineStyle?: ChartLineStyle;\n points: LineChartPoint[];\n}\n\nexport interface LineChartMarker {\n key: string;\n x: number;\n color: ChartColor;\n /** Names the event in its tooltip. */\n label: string;\n}\n\nexport interface LineChartProps {\n series: LineChartSeries[];\n /** Names the chart for a screen reader. */\n label: string;\n /** False when the host supplies a separate series legend. */\n endLabels?: boolean;\n /** Names the horizontal axis, e.g. \"回合\". */\n xLabel?: string;\n /** The gridlines. Defaults to about five round values. */\n yTicks?: number[];\n formatX?: (value: number) => string;\n formatY?: (value: number) => string;\n /** Where a replay's playhead is on the horizontal axis. */\n playhead?: number;\n /** Lets the reader click or use the arrow keys to move the playhead. */\n onSeek?: (x: number) => void;\n /** Events on the horizontal axis, e.g. a replay's key moments. */\n markers?: LineChartMarker[];\n /**\n * How far the lines are drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`). Omitted, it shows its final state.\n */\n progress?: number;\n className?: string;\n}\n\n// The SVG is drawn at its measured CSS width, so these are true px.\nconst HEIGHT = 240;\nconst PAD_LEFT = 32;\nconst PAD_RIGHT = 8;\nconst PAD_TOP = 20;\nconst PAD_BOTTOM = 28;\nconst END_LABEL_GAP = 8;\nconst END_LABEL_LINE = 16;\nconst MARKER_RADIUS = 4;\n\n/**\n * Lines over a shared horizontal axis, labelled at their ends instead of\n * in a legend, with an optional playhead the reader can move.\n */\nexport function LineChart({\n series,\n label,\n endLabels = true,\n xLabel,\n yTicks,\n formatX = String,\n formatY = String,\n playhead,\n onSeek,\n markers = [],\n progress,\n className,\n}: LineChartProps): ReactElement {\n const strings = useStrings();\n const maskId = useId();\n const wrapRef = useRef<HTMLDivElement>(null);\n const width = useElementWidth(wrapRef);\n const points = series.flatMap((line) => line.points);\n const xs = [...new Set(points.map((point) => point.x))].sort((a, b) => a - b);\n const cls = ['aegis-line-chart', className ?? ''].filter(Boolean).join(' ');\n if (width === 0 || xs.length === 0) {\n return <div ref={wrapRef} className={cls} />;\n }\n\n const xLo = xs[0];\n const xHi = xs[xs.length - 1];\n const values = points.map((point) => point.y);\n const ticks = yTicks ?? niceTicks(0, Math.max(...values, 1));\n const yHi = Math.max(...ticks, ...values);\n const left = PAD_LEFT;\n const right = width - PAD_RIGHT;\n const top = PAD_TOP;\n const bottom = HEIGHT - PAD_BOTTOM;\n const sx = (x: number): number =>\n left + (xHi > xLo ? (x - xLo) / (xHi - xLo) : 0) * (right - left);\n const sy = (y: number): number => bottom - (y / yHi) * (bottom - top);\n\n // The end labels stack upwards when two lines finish close together, so\n // the lowest stays where its line ends and none runs into the x axis.\n const ends = series\n .flatMap((line) => {\n const last = line.points[line.points.length - 1] as\n | LineChartPoint\n | undefined;\n return last === undefined ? [] : [{ line, last, y: sy(last.y) }];\n })\n .sort((a, b) => b.y - a.y);\n for (let i = 1; i < ends.length; i += 1) {\n if (ends[i - 1].y - ends[i].y < END_LABEL_LINE) {\n ends[i].y = ends[i - 1].y - END_LABEL_LINE;\n }\n }\n\n const nearestX = (x: number): number =>\n xs.reduce((best, candidate) =>\n Math.abs(candidate - x) < Math.abs(best - x) ? candidate : best,\n );\n const seekFromPointer = (event: MouseEvent<SVGRectElement>): void => {\n const box = event.currentTarget.getBoundingClientRect();\n const share = (event.clientX - box.left) / box.width;\n onSeek?.(nearestX(xLo + share * (xHi - xLo)));\n };\n const seekFromKey = (event: KeyboardEvent<SVGRectElement>): void => {\n const index = xs.indexOf(nearestX(playhead ?? xLo));\n const target: Record<string, number> = {\n ArrowLeft: index - 1,\n ArrowDown: index - 1,\n ArrowRight: index + 1,\n ArrowUp: index + 1,\n Home: 0,\n End: xs.length - 1,\n };\n if (event.key in target) {\n event.preventDefault();\n onSeek?.(xs[Math.min(Math.max(target[event.key], 0), xs.length - 1)]);\n }\n };\n\n return (\n <div ref={wrapRef} className={cls}>\n <svg\n className=\"aegis-line-chart__svg\"\n width={width}\n height={HEIGHT}\n viewBox={`0 0 ${width.toString()} ${HEIGHT.toString()}`}\n role={onSeek ? 'group' : 'img'}\n aria-label={label}\n >\n {ticks.map((tick) => (\n <g key={tick}>\n <line\n className=\"aegis-line-chart__grid\"\n x1={left}\n x2={right}\n y1={sy(tick)}\n y2={sy(tick)}\n />\n <text\n className=\"aegis-line-chart__tick\"\n x={left - END_LABEL_GAP}\n y={sy(tick)}\n textAnchor=\"end\"\n dominantBaseline=\"middle\"\n >\n {formatY(tick)}\n </text>\n </g>\n ))}\n {series.map((line) => (\n <g key={line.key}>\n {line.lineStyle &&\n line.lineStyle !== 'solid' &&\n progress !== undefined && (\n <mask\n id={`${maskId}-${line.key}`}\n maskUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={width}\n height={HEIGHT}\n >\n <polyline\n className=\"aegis-line-chart__line\"\n pathLength={1}\n points={line.points\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n style={\n {\n stroke: 'white',\n '--aegis-line-chart-progress': progress,\n } as CSSProperties\n }\n />\n </mask>\n )}\n <polyline\n className=\"aegis-line-chart__line\"\n pathLength={\n !line.lineStyle || line.lineStyle === 'solid' ? 1 : undefined\n }\n mask={\n line.lineStyle &&\n line.lineStyle !== 'solid' &&\n progress !== undefined\n ? `url(#${maskId}-${line.key})`\n : undefined\n }\n points={line.points\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n style={\n {\n stroke: chartColorValue(line.color),\n ...(line.lineStyle && line.lineStyle !== 'solid'\n ? {\n strokeDasharray: chartLineDash(line.lineStyle),\n strokeDashoffset: 0,\n }\n : {}),\n ...(progress === undefined\n ? {}\n : { '--aegis-line-chart-progress': progress }),\n } as CSSProperties\n }\n />\n </g>\n ))}\n {endLabels &&\n ends.map(({ line, last, y }) => (\n <text\n key={line.key}\n className=\"aegis-line-chart__end-label\"\n x={right}\n y={y - END_LABEL_GAP}\n textAnchor=\"end\"\n style={{ fill: chartColorValue(line.color) }}\n >\n {`${line.label} ${formatY(last.y)}`}\n </text>\n ))}\n {playhead !== undefined && (\n <g>\n <line\n className=\"aegis-line-chart__playhead\"\n x1={sx(playhead)}\n x2={sx(playhead)}\n y1={top}\n y2={bottom}\n />\n <text\n className=\"aegis-line-chart__playhead-label\"\n x={sx(playhead)}\n y={top - END_LABEL_GAP / 2}\n textAnchor=\"middle\"\n >\n {formatX(playhead)}\n </text>\n </g>\n )}\n <text\n className=\"aegis-line-chart__tick\"\n x={left}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"start\"\n >\n {formatX(xLo)}\n </text>\n <text\n className=\"aegis-line-chart__tick\"\n x={right}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"end\"\n >\n {formatX(xHi)}\n </text>\n {xLabel !== undefined && (\n <text\n className=\"aegis-line-chart__tick\"\n x={(left + right) / 2}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"middle\"\n >\n {xLabel}\n </text>\n )}\n {onSeek && (\n <rect\n className=\"aegis-line-chart__seek\"\n x={left}\n y={top}\n width={right - left}\n height={bottom - top}\n role=\"slider\"\n tabIndex={0}\n aria-label={strings.replayPosition}\n aria-valuemin={xLo}\n aria-valuemax={xHi}\n aria-valuenow={playhead ?? xLo}\n aria-valuetext={formatX(playhead ?? xLo)}\n onClick={seekFromPointer}\n onKeyDown={seekFromKey}\n />\n )}\n {markers.map((marker) => (\n <circle\n key={marker.key}\n className=\"aegis-line-chart__marker\"\n cx={sx(marker.x)}\n cy={bottom}\n r={MARKER_RADIUS}\n style={{ fill: chartColorValue(marker.color) }}\n onClick={\n onSeek\n ? () => {\n onSeek(marker.x);\n }\n : undefined\n }\n >\n <title>{marker.label}</title>\n </circle>\n ))}\n </svg>\n </div>\n );\n}\n"],"names":["HEIGHT","PAD_LEFT","PAD_RIGHT","PAD_TOP","PAD_BOTTOM","END_LABEL_GAP","END_LABEL_LINE","MARKER_RADIUS","LineChart","series","label","endLabels","xLabel","yTicks","formatX","formatY","playhead","onSeek","markers","progress","className","strings","useStrings","maskId","useId","wrapRef","useRef","width","useElementWidth","points","line","xs","point","a","b","cls","jsx","xLo","xHi","values","ticks","niceTicks","yHi","left","right","top","bottom","sx","x","sy","y","ends","last","i","nearestX","best","candidate","seekFromPointer","event","box","share","seekFromKey","index","target","jsxs","tick","chartColorValue","chartLineDash","marker"],"mappings":";;;;;;AAqEA,MAAMA,IAAS,KACTC,IAAW,IACXC,IAAY,GACZC,IAAU,IACVC,IAAa,IACbC,IAAgB,GAChBC,IAAiB,IACjBC,IAAgB;AAMf,SAASC,GAAU;AAAA,EACxB,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,SAAAC,IAAU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AA,YACf,iBAAeC;AAAA,YACf,iBAAetB,KAAYqB;AAAA,YAC3B,kBAAgBvB,EAAQE,KAAYqB,CAAG;AAAA,YACvC,SAASoB;AAAA,YACT,WAAWI;AAAA,UAAA;AAAA,QAAA;AAAA,QAGd3C,EAAQ,IAAI,CAACkD,MACZ,gBAAAhC;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,WAAU;AAAA,YACV,IAAIW,EAAGqB,EAAO,CAAC;AAAA,YACf,IAAItB;AAAA,YACJ,GAAGvC;AAAA,YACH,OAAO,EAAE,MAAM2D,EAAgBE,EAAO,KAAK,EAAA;AAAA,YAC3C,SACEnD,IACI,MAAM;AACJ,cAAAA,EAAOmD,EAAO,CAAC;AAAA,YACjB,IACA;AAAA,YAGN,UAAA,gBAAAhC,EAAC,SAAA,EAAO,UAAAgC,EAAO,MAAA,CAAM;AAAA,UAAA;AAAA,UAdhBA,EAAO;AAAA,QAAA,CAgBf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEL;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("../../lib/chart.cjs");;/* empty css */const t=require("./linkComponent.cjs");function c({name:s,detail:a,color:l,to:i,linkComponent:r=t.DefaultLink,className:n}){return e.jsxs("span",{className:["aegis-series-label",n??""].filter(Boolean).join(" "),style:{"--aegis-series-label-color":o.chartColorValue(l)},children:[e.jsx("span",{className:"aegis-series-label__dot","aria-hidden":"true"}),i===void 0?e.jsx("span",{className:"aegis-series-label__name",children:s}):e.jsx(r,{to:i,className:"aegis-series-label__name aegis-series-label__name--link",children:s}),a!==void 0&&e.jsx("span",{className:"aegis-series-label__detail",children:a})]})}exports.SeriesLabel=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("../../lib/chart.cjs");;/* empty css */const c=require("./linkComponent.cjs");function d({name:s,detail:a,color:n,lineStyle:i,to:l,linkComponent:o=c.DefaultLink,className:t}){return e.jsxs("span",{className:["aegis-series-label",t??""].filter(Boolean).join(" "),style:{"--aegis-series-label-color":r.chartColorValue(n)},children:[i===void 0?e.jsx("span",{className:"aegis-series-label__dot","aria-hidden":"true"}):e.jsx("svg",{className:"aegis-series-label__line","aria-hidden":"true",viewBox:"0 0 32 10",children:e.jsx("line",{x1:0,x2:32,y1:5,y2:5,style:{strokeDasharray:r.chartLineDash(i)}})}),l===void 0?e.jsx("span",{className:"aegis-series-label__name",children:s}):e.jsx(o,{to:l,className:"aegis-series-label__name aegis-series-label__name--link",children:s}),a!==void 0&&e.jsx("span",{className:"aegis-series-label__detail",children:a})]})}exports.SeriesLabel=d;
2
2
  //# sourceMappingURL=SeriesLabel.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SeriesLabel.cjs","sources":["../../../src/components/ui/SeriesLabel.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport './SeriesLabel.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface SeriesLabelProps {\n /** The series, e.g. a model's name. */\n name: ReactNode;\n /** A muted second part, e.g. the harness it ran with. */\n detail?: ReactNode;\n /** The series' colour, the same as its marks on the page's charts. */\n color: ChartColor;\n /** Makes the name a link. */\n to?: string;\n /** Renders the link. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n}\n\n/**\n * A series named in its colour, for charts that label their marks directly\n * instead of using a legend, and for the lists and tables around them.\n */\nexport function SeriesLabel({\n name,\n detail,\n color,\n to,\n linkComponent: Link = DefaultLink,\n className,\n}: SeriesLabelProps): ReactElement {\n return (\n <span\n className={['aegis-series-label', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={\n {\n '--aegis-series-label-color': chartColorValue(color),\n } as CSSProperties\n }\n >\n <span className=\"aegis-series-label__dot\" aria-hidden=\"true\" />\n {to === undefined ? (\n <span className=\"aegis-series-label__name\">{name}</span>\n ) : (\n <Link\n to={to}\n className=\"aegis-series-label__name aegis-series-label__name--link\"\n >\n {name}\n </Link>\n )}\n {detail !== undefined && (\n <span className=\"aegis-series-label__detail\">{detail}</span>\n )}\n </span>\n );\n}\n"],"names":["SeriesLabel","name","detail","color","to","Link","DefaultLink","className","jsxs","chartColorValue","jsx"],"mappings":"8NAwBO,SAASA,EAAY,CAC1B,KAAAC,EACA,OAAAC,EACA,MAAAC,EACA,GAAAC,EACA,cAAeC,EAAOC,EAAAA,YACtB,UAAAC,CACF,EAAmC,CACjC,OACEC,EAAAA,KAAC,OAAA,CACC,UAAW,CAAC,qBAAsBD,GAAa,EAAE,EAC9C,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MACE,CACE,6BAA8BE,EAAAA,gBAAgBN,CAAK,CAAA,EAIvD,SAAA,CAAAO,EAAAA,IAAC,OAAA,CAAK,UAAU,0BAA0B,cAAY,OAAO,EAC5DN,IAAO,OACNM,EAAAA,IAAC,QAAK,UAAU,2BAA4B,WAAK,EAEjDA,EAAAA,IAACL,EAAA,CACC,GAAAD,EACA,UAAU,0DAET,SAAAH,CAAA,CAAA,EAGJC,IAAW,QACVQ,EAAAA,IAAC,OAAA,CAAK,UAAU,6BAA8B,SAAAR,CAAA,CAAO,CAAA,CAAA,CAAA,CAI7D"}
1
+ {"version":3,"file":"SeriesLabel.cjs","sources":["../../../src/components/ui/SeriesLabel.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport {\n type ChartColor,\n type ChartLineStyle,\n chartColorValue,\n chartLineDash,\n} from '../../lib/chart';\nimport './SeriesLabel.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface SeriesLabelProps {\n /** The series, e.g. a model's name. */\n name: ReactNode;\n /** A muted second part, e.g. the harness it ran with. */\n detail?: ReactNode;\n /** The series' colour, the same as its marks on the page's charts. */\n color: ChartColor;\n lineStyle?: ChartLineStyle;\n /** Makes the name a link. */\n to?: string;\n /** Renders the link. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n}\n\n/**\n * A series named in its colour, for charts that label their marks directly\n * instead of using a legend, and for the lists and tables around them.\n */\nexport function SeriesLabel({\n name,\n detail,\n color,\n lineStyle,\n to,\n linkComponent: Link = DefaultLink,\n className,\n}: SeriesLabelProps): ReactElement {\n return (\n <span\n className={['aegis-series-label', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={\n {\n '--aegis-series-label-color': chartColorValue(color),\n } as CSSProperties\n }\n >\n {lineStyle === undefined ? (\n <span className=\"aegis-series-label__dot\" aria-hidden=\"true\" />\n ) : (\n <svg\n className=\"aegis-series-label__line\"\n aria-hidden=\"true\"\n viewBox=\"0 0 32 10\"\n >\n <line\n x1={0}\n x2={32}\n y1={5}\n y2={5}\n style={{ strokeDasharray: chartLineDash(lineStyle) }}\n />\n </svg>\n )}\n {to === undefined ? (\n <span className=\"aegis-series-label__name\">{name}</span>\n ) : (\n <Link\n to={to}\n className=\"aegis-series-label__name aegis-series-label__name--link\"\n >\n {name}\n </Link>\n )}\n {detail !== undefined && (\n <span className=\"aegis-series-label__detail\">{detail}</span>\n )}\n </span>\n );\n}\n"],"names":["SeriesLabel","name","detail","color","lineStyle","to","Link","DefaultLink","className","jsxs","chartColorValue","jsx","chartLineDash"],"mappings":"8NA8BO,SAASA,EAAY,CAC1B,KAAAC,EACA,OAAAC,EACA,MAAAC,EACA,UAAAC,EACA,GAAAC,EACA,cAAeC,EAAOC,EAAAA,YACtB,UAAAC,CACF,EAAmC,CACjC,OACEC,EAAAA,KAAC,OAAA,CACC,UAAW,CAAC,qBAAsBD,GAAa,EAAE,EAC9C,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MACE,CACE,6BAA8BE,EAAAA,gBAAgBP,CAAK,CAAA,EAItD,SAAA,CAAAC,IAAc,OACbO,EAAAA,IAAC,OAAA,CAAK,UAAU,0BAA0B,cAAY,OAAO,EAE7DA,EAAAA,IAAC,MAAA,CACC,UAAU,2BACV,cAAY,OACZ,QAAQ,YAER,SAAAA,EAAAA,IAAC,OAAA,CACC,GAAI,EACJ,GAAI,GACJ,GAAI,EACJ,GAAI,EACJ,MAAO,CAAE,gBAAiBC,EAAAA,cAAcR,CAAS,CAAA,CAAE,CAAA,CACrD,CAAA,EAGHC,IAAO,OACNM,EAAAA,IAAC,QAAK,UAAU,2BAA4B,WAAK,EAEjDA,EAAAA,IAACL,EAAA,CACC,GAAAD,EACA,UAAU,0DAET,SAAAJ,CAAA,CAAA,EAGJC,IAAW,QACVS,EAAAA,IAAC,OAAA,CAAK,UAAU,6BAA8B,SAAAT,CAAA,CAAO,CAAA,CAAA,CAAA,CAI7D"}
@@ -1,5 +1,5 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
- import { ChartColor } from '../../lib/chart';
2
+ import { ChartColor, ChartLineStyle } from '../../lib/chart';
3
3
  import { LinkComponent } from './linkComponent';
4
4
  export interface SeriesLabelProps {
5
5
  /** The series, e.g. a model's name. */
@@ -8,6 +8,7 @@ export interface SeriesLabelProps {
8
8
  detail?: ReactNode;
9
9
  /** The series' colour, the same as its marks on the page's charts. */
10
10
  color: ChartColor;
11
+ lineStyle?: ChartLineStyle;
11
12
  /** Makes the name a link. */
12
13
  to?: string;
13
14
  /** Renders the link. Defaults to an `<a href>`; routed apps pass their Link adapter. */
@@ -18,4 +19,4 @@ export interface SeriesLabelProps {
18
19
  * A series named in its colour, for charts that label their marks directly
19
20
  * instead of using a legend, and for the lists and tables around them.
20
21
  */
21
- export declare function SeriesLabel({ name, detail, color, to, linkComponent: Link, className, }: SeriesLabelProps): ReactElement;
22
+ export declare function SeriesLabel({ name, detail, color, lineStyle, to, linkComponent: Link, className, }: SeriesLabelProps): ReactElement;