@lincyaw/aegis-ui 0.9.1 → 0.9.2

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"),I=require("react"),O=require("../../hooks/useElementWidth.cjs"),p=require("../../lib/chart.cjs");;/* empty css */const F=require("../../locale/useStrings.cjs"),x=240,G=32,K=8,V=20,U=28,g=8,R=16,W=4;function z({series:N,label:T,xLabel:v,yTicks:C,formatX:j=String,formatY:w=String,playhead:a,onSeek:l,markers:B=[],progress:b,className:S}){const q=F.useStrings(),f=I.useRef(null),A=O.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",S??""].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=C??p.niceTicks(0,Math.max(...D,1)),H=Math.max(...L,...D),r=G,o=A-K,y=V,m=x-U,u=t=>r+(d>n?(t-n)/(d-n):0)*(o-r),_=t=>m-t/H*(m-y),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),$=t=>{const e=t.currentTarget.getBoundingClientRect(),c=(t.clientX-e.left)/e.width;l?.(P(n+c*(d-n)))},k=t=>{const e=i.indexOf(P(a??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:r,x2:o,y1:_(t),y2:_(t)}),s.jsx("text",{className:"aegis-line-chart__tick",x:r-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=>`${u(e.x).toString()},${_(e.y).toString()}`).join(" "),style:{stroke:p.chartColorValue(t.color),...b===void 0?{}:{"--aegis-line-chart-progress":b}}},t.key)),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)),a!==void 0&&s.jsxs("g",{children:[s.jsx("line",{className:"aegis-line-chart__playhead",x1:u(a),x2:u(a),y1:y,y2:m}),s.jsx("text",{className:"aegis-line-chart__playhead-label",x:u(a),y:y-g/2,textAnchor:"middle",children:j(a)})]}),s.jsx("text",{className:"aegis-line-chart__tick",x:r,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:(r+o)/2,y:x-g,textAnchor:"middle",children:v}),l&&s.jsx("rect",{className:"aegis-line-chart__seek",x:r,y,width:o-r,height:m-y,role:"slider",tabIndex:0,"aria-label":q.replayPosition,"aria-valuemin":n,"aria-valuemax":d,"aria-valuenow":a??n,"aria-valuetext":j(a??n),onClick:$,onKeyDown:k}),B.map(t=>s.jsx("circle",{className:"aegis-line-chart__marker",cx:u(t.x),cy:m,r:W,style:{fill:p.chartColorValue(t.color)},onClick:l?()=>{l(t.x)}:void 0,children:s.jsx("title",{children:t.label})},t.key))]})})}exports.LineChart=z;
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;
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 /** 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 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 {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","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":"oSA2DMA,EAAS,IACTC,EAAW,GACXC,EAAY,EACZC,EAAU,GACVC,EAAa,GACbC,EAAgB,EAChBC,EAAiB,GACjBC,EAAgB,EAMf,SAASC,EAAU,CACxB,OAAAC,EACA,MAAAC,EACA,OAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,OACV,QAAAC,EAAU,OACV,SAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,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zB,WAAW,SAEV,WAAQU,CAAQ,CAAA,CAAA,CACnB,EACF,EAEFkB,EAAAA,IAAC,OAAA,CACC,UAAU,yBACV,EAAGO,EACH,EAAGxC,EAASK,EACZ,WAAW,QAEV,WAAQ6B,CAAG,CAAA,CAAA,EAEdD,EAAAA,IAAC,OAAA,CACC,UAAU,yBACV,EAAGQ,EACH,EAAGzC,EAASK,EACZ,WAAW,MAEV,WAAQ8B,CAAG,CAAA,CAAA,EAEbxB,IAAW,QACVsB,EAAAA,IAAC,OAAA,CACC,UAAU,yBACV,GAAIO,EAAOC,GAAS,EACpB,EAAGzC,EAASK,EACZ,WAAW,SAEV,SAAAM,CAAA,CAAA,EAGJK,GACCiB,EAAAA,IAAC,OAAA,CACC,UAAU,yBACV,EAAGO,EACHE,EACA,MAAOD,EAAQD,EACf,OAAQG,EAASD,EACjB,KAAK,SACL,SAAU,EACV,aAAYtB,EAAQ,eACpB,gBAAec,EACf,gBAAeC,EACf,gBAAepB,GAAYmB,EAC3B,iBAAgBrB,EAAQE,GAAYmB,CAAG,EACvC,QAASoB,EACT,UAAWI,CAAA,CAAA,EAGdzC,EAAQ,IAAK+C,GACZ/B,EAAAA,IAAC,SAAA,CAEC,UAAU,2BACV,GAAIW,EAAGoB,EAAO,CAAC,EACf,GAAIrB,EACJ,EAAGpC,EACH,MAAO,CAAE,KAAMwD,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 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,E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G2B,EAAMtC,EAAgB,EACzB,WAAW,SAEV,WAAQW,CAAQ,CAAA,CAAA,CACnB,EACF,EAEFkB,EAAAA,IAAC,OAAA,CACC,UAAU,yBACV,EAAGO,EACH,EAAGzC,EAASK,EACZ,WAAW,QAEV,WAAQ8B,CAAG,CAAA,CAAA,EAEdD,EAAAA,IAAC,OAAA,CACC,UAAU,yBACV,EAAGQ,EACH,EAAG1C,EAASK,EACZ,WAAW,MAEV,WAAQ+B,CAAG,CAAA,CAAA,EAEbxB,IAAW,QACVsB,EAAAA,IAAC,OAAA,CACC,UAAU,yBACV,GAAIO,EAAOC,GAAS,EACpB,EAAG1C,EAASK,EACZ,WAAW,SAEV,SAAAO,CAAA,CAAA,EAGJK,GACCiB,EAAAA,IAAC,OAAA,CACC,UAAU,yBACV,EAAGO,EACH,EAAGE,EACH,MAAOD,EAAQD,EACf,OAAQG,EAASD,EACjB,KAAK,SACL,SAAU,EACV,aAAYtB,EAAQ,eACpB,gBAAec,EACf,gBAAeC,EACf,gBAAepB,GAAYmB,EAC3B,iBAAgBrB,EAAQE,GAAYmB,CAAG,EACvC,QAASoB,EACT,UAAWI,CAAA,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"}
@@ -22,6 +22,8 @@ export interface LineChartProps {
22
22
  series: LineChartSeries[];
23
23
  /** Names the chart for a screen reader. */
24
24
  label: string;
25
+ /** False when the host supplies a separate series legend. */
26
+ endLabels?: boolean;
25
27
  /** Names the horizontal axis, e.g. "回合". */
26
28
  xLabel?: string;
27
29
  /** The gridlines. Defaults to about five round values. */
@@ -45,4 +47,4 @@ export interface LineChartProps {
45
47
  * Lines over a shared horizontal axis, labelled at their ends instead of
46
48
  * in a legend, with an optional playhead the reader can move.
47
49
  */
48
- export declare function LineChart({ series, label, xLabel, yTicks, formatX, formatY, playhead, onSeek, markers, progress, className, }: LineChartProps): ReactElement;
50
+ export declare function LineChart({ series, label, endLabels, xLabel, yTicks, formatX, formatY, playhead, onSeek, markers, progress, className, }: LineChartProps): ReactElement;
@@ -1,27 +1,28 @@
1
1
  import { jsx as n, jsxs as v } from "react/jsx-runtime";
2
- import { useRef as F } from "react";
3
- import { useElementWidth as G } from "../../hooks/useElementWidth.js";
4
- import { niceTicks as K, chartColorValue as w } from "../../lib/chart.js";
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";
5
5
  /* empty css */
6
- import { useStrings as U } from "../../locale/useStrings.js";
7
- const g = 240, V = 32, W = 8, q = 20, z = 28, x = 8, B = 16, J = 4;
8
- function nt({
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
9
  series: A,
10
10
  label: H,
11
+ endLabels: $ = !0,
11
12
  xLabel: D,
12
- yTicks: $,
13
+ yTicks: k,
13
14
  formatX: f = String,
14
15
  formatY: E = String,
15
16
  playhead: a,
16
17
  onSeek: r,
17
- markers: k = [],
18
+ markers: C = [],
18
19
  progress: M,
19
- className: C
20
+ className: I
20
21
  }) {
21
- const I = U(), N = F(null), u = G(N), b = A.flatMap((t) => t.points), s = [...new Set(b.map((t) => t.x))].sort((t, e) => t - e), L = ["aegis-line-chart", C ?? ""].filter(Boolean).join(" ");
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(" ");
22
23
  if (u === 0 || s.length === 0)
23
24
  return /* @__PURE__ */ n("div", { ref: N, className: L });
24
- const i = s[0], m = s[s.length - 1], P = b.map((t) => t.y), R = $ ?? K(0, Math.max(...P, 1)), j = Math.max(...R, ...P), c = V, l = u - W, d = q, _ = g - z, y = (t) => c + (m > i ? (t - i) / (m - i) : 0) * (l - c), p = (t) => _ - t / j * (_ - d), h = A.flatMap((t) => {
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) => {
25
26
  const e = t.points[t.points.length - 1];
26
27
  return e === void 0 ? [] : [{ line: t, last: e, y: p(e.y) }];
27
28
  }).sort((t, e) => e.y - t.y);
@@ -29,10 +30,10 @@ function nt({
29
30
  h[t - 1].y - h[t].y < B && (h[t].y = h[t - 1].y - B);
30
31
  const T = (t) => s.reduce(
31
32
  (e, o) => Math.abs(o - t) < Math.abs(e - t) ? o : e
32
- ), O = (t) => {
33
+ ), S = (t) => {
33
34
  const e = t.currentTarget.getBoundingClientRect(), o = (t.clientX - e.left) / e.width;
34
35
  r?.(T(i + o * (m - i)));
35
- }, S = (t) => {
36
+ }, F = (t) => {
36
37
  const e = s.indexOf(T(a ?? i)), o = {
37
38
  ArrowLeft: e - 1,
38
39
  ArrowDown: e - 1,
@@ -91,7 +92,7 @@ function nt({
91
92
  },
92
93
  t.key
93
94
  )),
94
- h.map(({ line: t, last: e, y: o }) => /* @__PURE__ */ n(
95
+ $ && h.map(({ line: t, last: e, y: o }) => /* @__PURE__ */ n(
95
96
  "text",
96
97
  {
97
98
  className: "aegis-line-chart__end-label",
@@ -165,22 +166,22 @@ function nt({
165
166
  height: _ - d,
166
167
  role: "slider",
167
168
  tabIndex: 0,
168
- "aria-label": I.replayPosition,
169
+ "aria-label": j.replayPosition,
169
170
  "aria-valuemin": i,
170
171
  "aria-valuemax": m,
171
172
  "aria-valuenow": a ?? i,
172
173
  "aria-valuetext": f(a ?? i),
173
- onClick: O,
174
- onKeyDown: S
174
+ onClick: S,
175
+ onKeyDown: F
175
176
  }
176
177
  ),
177
- k.map((t) => /* @__PURE__ */ n(
178
+ C.map((t) => /* @__PURE__ */ n(
178
179
  "circle",
179
180
  {
180
181
  className: "aegis-line-chart__marker",
181
182
  cx: y(t.x),
182
183
  cy: _,
183
- r: J,
184
+ r: Q,
184
185
  style: { fill: w(t.color) },
185
186
  onClick: r ? () => {
186
187
  r(t.x);
@@ -194,6 +195,6 @@ function nt({
194
195
  ) });
195
196
  }
196
197
  export {
197
- nt as LineChart
198
+ it as LineChart
198
199
  };
199
200
  //# 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 /** 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 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 {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","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":";;;;;;AA2DA,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,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,IAASjB,EAAO,QAAQ,CAACkB,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,WAAO,gBAAAK,EAAC,OAAA,EAAI,KAAKX,G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A,YACf,IAAIrB;AAAA,YACJ,GAAGpC;AAAA,YACH,OAAO,EAAE,MAAMwD,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 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,WAAO,gBAAAK,EAAC,OAAA,EAAI,KAAKX,GAAS,WAAWU,GAAK;AAG5C,QAAME,IAAMN,EAAG,CAAC,GACVO,IAAMP,EAAGA,EAAG,SAAS,CAAC,GACtBQ,IAASV,EAAO,IAAI,CAACG,MAAUA,EAAM,CAAC,GACt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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;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/aegis-ui",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "AegisLab shared design system: tokens, primitives, layout, AntD theme.",
5
5
  "repository": {
6
6
  "type": "git",