@lincyaw/aegis-ui 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/AgentHud.cjs +2 -0
- package/dist/components/ui/AgentHud.cjs.map +1 -0
- package/dist/components/ui/AgentHud.d.ts +23 -0
- package/dist/components/ui/AgentHud.js +45 -0
- package/dist/components/ui/AgentHud.js.map +1 -0
- package/dist/components/ui/ChartLegend.cjs +1 -1
- package/dist/components/ui/ChartLegend.cjs.map +1 -1
- package/dist/components/ui/ChartLegend.d.ts +2 -0
- package/dist/components/ui/ChartLegend.js +11 -10
- package/dist/components/ui/ChartLegend.js.map +1 -1
- package/dist/components/ui/ColumnChart.cjs +2 -0
- package/dist/components/ui/ColumnChart.cjs.map +1 -0
- package/dist/components/ui/ColumnChart.d.ts +46 -0
- package/dist/components/ui/ColumnChart.js +154 -0
- package/dist/components/ui/ColumnChart.js.map +1 -0
- package/dist/components/ui/DotRangeChart.cjs +2 -0
- package/dist/components/ui/DotRangeChart.cjs.map +1 -0
- package/dist/components/ui/DotRangeChart.d.ts +44 -0
- package/dist/components/ui/DotRangeChart.js +80 -0
- package/dist/components/ui/DotRangeChart.js.map +1 -0
- package/dist/components/ui/HeadlineStat.cjs +2 -0
- package/dist/components/ui/HeadlineStat.cjs.map +1 -0
- package/dist/components/ui/HeadlineStat.d.ts +10 -0
- package/dist/components/ui/HeadlineStat.js +22 -0
- package/dist/components/ui/HeadlineStat.js.map +1 -0
- package/dist/components/ui/Heatmap.cjs +2 -0
- package/dist/components/ui/Heatmap.cjs.map +1 -0
- package/dist/components/ui/Heatmap.d.ts +52 -0
- package/dist/components/ui/Heatmap.js +82 -0
- package/dist/components/ui/Heatmap.js.map +1 -0
- package/dist/components/ui/KeyMomentCard.cjs +2 -0
- package/dist/components/ui/KeyMomentCard.cjs.map +1 -0
- package/dist/components/ui/KeyMomentCard.d.ts +19 -0
- package/dist/components/ui/KeyMomentCard.js +45 -0
- package/dist/components/ui/KeyMomentCard.js.map +1 -0
- package/dist/components/ui/LineChart.cjs +2 -0
- package/dist/components/ui/LineChart.cjs.map +1 -0
- package/dist/components/ui/LineChart.d.ts +48 -0
- package/dist/components/ui/LineChart.js +199 -0
- package/dist/components/ui/LineChart.js.map +1 -0
- package/dist/components/ui/ParetoChart.cjs +1 -1
- package/dist/components/ui/ParetoChart.cjs.map +1 -1
- package/dist/components/ui/ParetoChart.d.ts +34 -2
- package/dist/components/ui/ParetoChart.js +250 -173
- package/dist/components/ui/ParetoChart.js.map +1 -1
- package/dist/components/ui/RankBar.cjs +1 -1
- package/dist/components/ui/RankBar.cjs.map +1 -1
- package/dist/components/ui/RankBar.d.ts +7 -3
- package/dist/components/ui/RankBar.js +64 -45
- package/dist/components/ui/RankBar.js.map +1 -1
- package/dist/components/ui/ReplayStepStrip.cjs +1 -1
- package/dist/components/ui/ReplayStepStrip.cjs.map +1 -1
- package/dist/components/ui/ReplayStepStrip.d.ts +13 -1
- package/dist/components/ui/ReplayStepStrip.js +99 -76
- package/dist/components/ui/ReplayStepStrip.js.map +1 -1
- package/dist/components/ui/ResultMatrix.cjs +2 -0
- package/dist/components/ui/ResultMatrix.cjs.map +1 -0
- package/dist/components/ui/ResultMatrix.d.ts +23 -0
- package/dist/components/ui/ResultMatrix.js +53 -0
- package/dist/components/ui/ResultMatrix.js.map +1 -0
- package/dist/components/ui/ScrollStory.cjs +2 -2
- package/dist/components/ui/ScrollStory.cjs.map +1 -1
- package/dist/components/ui/ScrollStory.d.ts +3 -1
- package/dist/components/ui/ScrollStory.js +34 -32
- package/dist/components/ui/ScrollStory.js.map +1 -1
- package/dist/components/ui/SeriesLabel.cjs +2 -0
- package/dist/components/ui/SeriesLabel.cjs.map +1 -0
- package/dist/components/ui/SeriesLabel.d.ts +21 -0
- package/dist/components/ui/SeriesLabel.js +38 -0
- package/dist/components/ui/SeriesLabel.js.map +1 -0
- package/dist/components/ui/StackedBar.cjs +1 -1
- package/dist/components/ui/StackedBar.cjs.map +1 -1
- package/dist/components/ui/StackedBar.d.ts +13 -1
- package/dist/components/ui/StackedBar.js +95 -74
- package/dist/components/ui/StackedBar.js.map +1 -1
- package/dist/components/ui/TableOfContents.cjs +1 -1
- package/dist/components/ui/TableOfContents.cjs.map +1 -1
- package/dist/components/ui/TableOfContents.js +31 -89
- package/dist/components/ui/TableOfContents.js.map +1 -1
- package/dist/components/ui/ThoughtCard.cjs +2 -0
- package/dist/components/ui/ThoughtCard.cjs.map +1 -0
- package/dist/components/ui/ThoughtCard.d.ts +23 -0
- package/dist/components/ui/ThoughtCard.js +55 -0
- package/dist/components/ui/ThoughtCard.js.map +1 -0
- package/dist/components/ui/index.d.ts +20 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useSectionSpy.cjs +2 -0
- package/dist/hooks/useSectionSpy.cjs.map +1 -0
- package/dist/hooks/useSectionSpy.d.ts +23 -0
- package/dist/hooks/useSectionSpy.js +78 -0
- package/dist/hooks/useSectionSpy.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +337 -310
- package/dist/index.js.map +1 -1
- package/dist/layouts/site/SiteAnchorNav.cjs +2 -0
- package/dist/layouts/site/SiteAnchorNav.cjs.map +1 -0
- package/dist/layouts/site/SiteAnchorNav.d.ts +22 -0
- package/dist/layouts/site/SiteAnchorNav.js +51 -0
- package/dist/layouts/site/SiteAnchorNav.js.map +1 -0
- package/dist/layouts/site/SiteSectionHeader.cjs +2 -0
- package/dist/layouts/site/SiteSectionHeader.cjs.map +1 -0
- package/dist/layouts/site/SiteSectionHeader.d.ts +20 -0
- package/dist/layouts/site/SiteSectionHeader.js +30 -0
- package/dist/layouts/site/SiteSectionHeader.js.map +1 -0
- package/dist/layouts/site/index.d.ts +4 -0
- package/dist/lib/chart.cjs +1 -1
- package/dist/lib/chart.cjs.map +1 -1
- package/dist/lib/chart.d.ts +8 -2
- package/dist/lib/chart.js +20 -16
- package/dist/lib/chart.js.map +1 -1
- package/dist/locale/strings.cjs +1 -1
- package/dist/locale/strings.cjs.map +1 -1
- package/dist/locale/strings.d.ts +2 -0
- package/dist/locale/strings.js +2 -0
- package/dist/locale/strings.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DotRangeChart.js","sources":["../../../src/components/ui/DotRangeChart.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport {\n type ChartColor,\n chartColorValue,\n stageProgress,\n staggeredProgress,\n} from '../../lib/chart';\nimport './DotRangeChart.css';\n\nexport interface DotRangeChartDot {\n value: number;\n /** An outlined dot, e.g. the baseline a row is measured against. */\n hollow?: boolean;\n}\n\nexport interface DotRangeChartItem {\n key: string;\n label: ReactNode;\n /** The line's two ends. */\n range: [number, number];\n /** The row's dots; `extend` grows the line from the first towards the last. */\n dots: DotRangeChartDot[];\n /** The row's colour, e.g. its vendor's series token. */\n color: ChartColor;\n /** The row's reading, at its end, e.g. \"1,412\" or \"+18.3\". */\n value: ReactNode;\n}\n\nexport interface DotRangeChartProps {\n items: DotRangeChartItem[];\n /** The scale's two ends. */\n domain: [number, number];\n /**\n * How `progress` draws a row. `extend` grows the line out of the first\n * dot to the last, as for a before and after. `slide` moves the dots in\n * from the start of the scale and then unfolds the line, as for a\n * reading and its interval. Defaults to `extend`.\n */\n motion?: 'extend' | 'slide';\n /** Names the chart for a screen reader. */\n label: string;\n /**\n * How far the chart is drawn, 0 to 1, for one that draws as its section\n * scrolls in (`useScrollProgress`). Omitted, it shows its final state.\n */\n progress?: number;\n className?: string;\n}\n\n/**\n * Rows of dots joined by a line on one scale: a reading with its interval,\n * or the same thing before and after a change.\n */\nexport function DotRangeChart({\n items,\n domain,\n motion = 'extend',\n label,\n progress,\n className,\n}: DotRangeChartProps): ReactElement {\n const [lo, hi] = domain;\n const share = (value: number): number =>\n Math.min(Math.max((value - lo) / (hi - lo), 0), 1);\n return (\n <div\n role=\"group\"\n aria-label={label}\n className={[\n 'aegis-dot-range',\n `aegis-dot-range--${motion}`,\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {items.map((item, index) => {\n const drawn =\n progress === undefined\n ? 1\n : staggeredProgress(progress, index, items.length);\n const start = share(Math.min(...item.range));\n const end = share(Math.max(...item.range));\n const anchor = share(item.dots[0]?.value ?? item.range[0]);\n const lineDrawn =\n motion === 'extend'\n ? stageProgress(drawn, 0, 0.85)\n : stageProgress(drawn, 0.6, 1);\n const dotsDrawn =\n motion === 'extend' ? 1 : stageProgress(drawn, 0, 0.6);\n return (\n <div key={item.key} className=\"aegis-dot-range__row\">\n <div className=\"aegis-dot-range__label\">{item.label}</div>\n <div\n className=\"aegis-dot-range__plot\"\n style={\n {\n '--aegis-dot-range-color': chartColorValue(item.color),\n } as CSSProperties\n }\n >\n <span className=\"aegis-dot-range__track\" />\n <span\n className=\"aegis-dot-range__line\"\n style={{\n left: `${(start * 100).toString()}%`,\n width: `${((end - start) * 100).toString()}%`,\n transform: `scaleX(${lineDrawn.toString()})`,\n transformOrigin:\n motion === 'slide' || anchor <= start ? 'left' : 'right',\n }}\n />\n {item.dots.map((dot, dotIndex) => (\n <span\n key={dotIndex}\n className=\"aegis-dot-range__mover\"\n style={{\n transform: `translateX(${(share(dot.value) * dotsDrawn * 100).toString()}cqi)`,\n opacity:\n motion === 'extend' && dotIndex > 0\n ? stageProgress(drawn, 0.85, 1)\n : stageProgress(drawn, 0, 0.1),\n }}\n >\n <span\n className={[\n 'aegis-dot-range__dot',\n dot.hollow ? 'aegis-dot-range__dot--hollow' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n />\n </span>\n ))}\n </div>\n <span className=\"aegis-dot-range__value\">{item.value}</span>\n </div>\n );\n })}\n </div>\n );\n}\n"],"names":["DotRangeChart","items","domain","motion","label","progress","className","lo","hi","share","value","jsx","item","index","drawn","staggeredProgress","start","end","anchor","lineDrawn","stageProgress","dotsDraw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object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");;/* empty css */function t({value:a,caption:i,className:s}){return e.jsxs("div",{className:["aegis-headline-stat",s??""].filter(Boolean).join(" "),children:[e.jsx("span",{className:"aegis-headline-stat__value",children:a}),e.jsx("span",{className:"aegis-headline-stat__caption",children:i})]})}exports.HeadlineStat=t;
|
|
2
|
+
//# sourceMappingURL=HeadlineStat.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeadlineStat.cjs","sources":["../../../src/components/ui/HeadlineStat.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react';\n\nimport './HeadlineStat.css';\n\nexport interface HeadlineStatProps {\n /** The figure, e.g. \"97.6%\" or \"46 / 47\". */\n value: ReactNode;\n /** The sentence that reads the figure. */\n caption: ReactNode;\n className?: string;\n}\n\n/** The figure behind a finding: one large number over the sentence that reads it. */\nexport function HeadlineStat({\n value,\n caption,\n className,\n}: HeadlineStatProps): ReactElement {\n return (\n <div\n className={['aegis-headline-stat', className ?? '']\n .filter(Boolean)\n .join(' ')}\n >\n <span className=\"aegis-headline-stat__value\">{value}</span>\n <span className=\"aegis-headline-stat__caption\">{caption}</span>\n </div>\n );\n}\n"],"names":["HeadlineStat","value","caption","className","jsxs","jsx"],"mappings":"uJAaO,SAASA,EAAa,CAC3B,MAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAoC,CAClC,OACEC,EAAAA,KAAC,MAAA,CACC,UAAW,CAAC,sBAAuBD,GAAa,EAAE,EAC/C,OAAO,OAAO,EACd,KAAK,GAAG,EAEX,SAAA,CAAAE,EAAAA,IAAC,OAAA,CAAK,UAAU,6BAA8B,SAAAJ,EAAM,EACpDI,EAAAA,IAAC,OAAA,CAAK,UAAU,+BAAgC,SAAAH,CAAA,CAAQ,CAAA,CAAA,CAAA,CAG9D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export interface HeadlineStatProps {
|
|
3
|
+
/** The figure, e.g. "97.6%" or "46 / 47". */
|
|
4
|
+
value: ReactNode;
|
|
5
|
+
/** The sentence that reads the figure. */
|
|
6
|
+
caption: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
/** The figure behind a finding: one large number over the sentence that reads it. */
|
|
10
|
+
export declare function HeadlineStat({ value, caption, className, }: HeadlineStatProps): ReactElement;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsxs as n, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
/* empty css */
|
|
3
|
+
function r({
|
|
4
|
+
value: e,
|
|
5
|
+
caption: i,
|
|
6
|
+
className: s
|
|
7
|
+
}) {
|
|
8
|
+
return /* @__PURE__ */ n(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: ["aegis-headline-stat", s ?? ""].filter(Boolean).join(" "),
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ a("span", { className: "aegis-headline-stat__value", children: e }),
|
|
14
|
+
/* @__PURE__ */ a("span", { className: "aegis-headline-stat__caption", children: i })
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
r as HeadlineStat
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=HeadlineStat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeadlineStat.js","sources":["../../../src/components/ui/HeadlineStat.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react';\n\nimport './HeadlineStat.css';\n\nexport interface HeadlineStatProps {\n /** The figure, e.g. \"97.6%\" or \"46 / 47\". */\n value: ReactNode;\n /** The sentence that reads the figure. */\n caption: ReactNode;\n className?: string;\n}\n\n/** The figure behind a finding: one large number over the sentence that reads it. */\nexport function HeadlineStat({\n value,\n caption,\n className,\n}: HeadlineStatProps): ReactElement {\n return (\n <div\n className={['aegis-headline-stat', className ?? '']\n .filter(Boolean)\n .join(' ')}\n >\n <span className=\"aegis-headline-stat__value\">{value}</span>\n <span className=\"aegis-headline-stat__caption\">{caption}</span>\n </div>\n );\n}\n"],"names":["HeadlineStat","value","caption","className","jsxs","jsx"],"mappings":";;AAaO,SAASA,EAAa;AAAA,EAC3B,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AACF,GAAoC;AAClC,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,CAAC,uBAAuBD,KAAa,EAAE,EAC/C,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,MAEX,UAAA;AAAA,QAAA,gBAAAE,EAAC,QAAA,EAAK,WAAU,8BAA8B,UAAAJ,GAAM;AAAA,QACpD,gBAAAI,EAAC,QAAA,EAAK,WAAU,gCAAgC,UAAAH,EAAA,CAAQ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG9D;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("../../lib/chart.cjs");;/* empty css */const j=require("./linkComponent.cjs");function x({columns:l,rows:c,corner:h,color:p="seq",label:d,progress:t,linkComponent:_=j.DefaultLink,className:g}){return e.jsxs("div",{role:"table","aria-label":d,className:["aegis-heatmap",g??""].filter(Boolean).join(" "),style:{"--aegis-heatmap-columns":l.length},children:[e.jsx("div",{role:"rowgroup",className:"aegis-heatmap__head",children:e.jsxs("div",{role:"row",className:"aegis-heatmap__row",children:[e.jsx("div",{role:"columnheader",className:"aegis-heatmap__corner",children:h}),l.map(a=>e.jsxs("div",{role:"columnheader",className:"aegis-heatmap__column",children:[e.jsx("span",{className:"aegis-heatmap__column-label",children:a.label}),a.detail!==void 0&&e.jsx("span",{className:"aegis-heatmap__column-detail",children:a.detail})]},a.key))]})}),e.jsx("div",{role:"rowgroup",className:"aegis-heatmap__body",children:c.map(a=>e.jsxs("div",{role:"row",className:"aegis-heatmap__row",children:[e.jsx("div",{role:"rowheader",className:"aegis-heatmap__row-label",children:a.label}),a.cells.map((s,r)=>{const i=l[r],n=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"aegis-heatmap__tint","aria-hidden":"true"}),e.jsx("span",{className:"aegis-heatmap__cell-label",children:i.label}),e.jsx("span",{className:"aegis-heatmap__text",children:s.text})]}),o=["aegis-heatmap__cell",s.level===null?"aegis-heatmap__cell--empty":"",s.emphasis?"aegis-heatmap__cell--emphasis":""].filter(Boolean).join(" ");return e.jsx("div",{role:"cell",className:"aegis-heatmap__slot",style:{"--aegis-heatmap-color":m.chartColorValue(i.color??p),"--aegis-heatmap-level":s.level??0,"--aegis-heatmap-progress":t===void 0?1:m.staggeredProgress(t,r,l.length)},children:s.to===void 0?e.jsx("span",{className:o,children:n}):e.jsx(_,{to:s.to,className:`${o} aegis-heatmap__cell--link`,children:n})},i.key)})]},a.key))})]})}exports.Heatmap=x;
|
|
2
|
+
//# sourceMappingURL=Heatmap.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Heatmap.cjs","sources":["../../../src/components/ui/Heatmap.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport {\n type ChartColor,\n chartColorValue,\n staggeredProgress,\n} from '../../lib/chart';\nimport './Heatmap.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface HeatmapColumn {\n key: string;\n label: ReactNode;\n /** A second line, e.g. the metric of the column. */\n detail?: ReactNode;\n /** The column's tint, when it differs from the chart's, e.g. a cost column. */\n color?: ChartColor;\n}\n\nexport interface HeatmapCell {\n /** The cell's reading, e.g. \"97.6%\", or why it has none, e.g. \"样本不足\". */\n text: ReactNode;\n /** How strongly the cell is tinted, 0 to 1; null leaves it unfilled. */\n level: number | null;\n /** The best of its column: its text reads heavier. */\n emphasis?: boolean;\n /** Makes the cell a link. */\n to?: string;\n}\n\nexport interface HeatmapRow {\n key: string;\n label: ReactNode;\n /** One cell per column, in the columns' order. */\n cells: HeatmapCell[];\n}\n\nexport interface HeatmapProps {\n columns: HeatmapColumn[];\n rows: HeatmapRow[];\n /** Names the row labels' column, e.g. \"模型 × harness\". */\n corner?: ReactNode;\n /** The tint of every column without its own. Defaults to `seq`. */\n color?: ChartColor;\n /** Names the table for a screen reader. */\n label: string;\n /**\n * How far the cells are tinted, 0 to 1, column after column, for a table\n * that fills as its section scrolls in (`useScrollProgress`).\n */\n progress?: number;\n /** Renders the cells' links. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n}\n\n/**\n * A table whose cells are tinted by how strong their reading is. Host code\n * sets each cell's level, usually normalised within its column. On a phone\n * every row folds into its label over a grid of labelled cells, so it is\n * built from ARIA table roles, which keep their meaning through that.\n */\nexport function Heatmap({\n columns,\n rows,\n corner,\n color = 'seq',\n label,\n progress,\n linkComponent: Link = DefaultLink,\n className,\n}: HeatmapProps): ReactElement {\n return (\n <div\n role=\"table\"\n aria-label={label}\n className={['aegis-heatmap', className ?? ''].filter(Boolean).join(' ')}\n style={{ '--aegis-heatmap-columns': columns.length } as CSSProperties}\n >\n <div role=\"rowgroup\" className=\"aegis-heatmap__head\">\n <div role=\"row\" className=\"aegis-heatmap__row\">\n <div role=\"columnheader\" className=\"aegis-heatmap__corner\">\n {corner}\n </div>\n {columns.map((column) => (\n <div\n key={column.key}\n role=\"columnheader\"\n className=\"aegis-heatmap__column\"\n >\n <span className=\"aegis-heatmap__column-label\">\n {column.label}\n </span>\n {column.detail !== undefined && (\n <span className=\"aegis-heatmap__column-detail\">\n {column.detail}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n <div role=\"rowgroup\" className=\"aegis-heatmap__body\">\n {rows.map((row) => (\n <div key={row.key} role=\"row\" className=\"aegis-heatmap__row\">\n <div role=\"rowheader\" className=\"aegis-heatmap__row-label\">\n {row.label}\n </div>\n {row.cells.map((cell, index) => {\n const column = columns[index];\n const content = (\n <>\n <span className=\"aegis-heatmap__tint\" aria-hidden=\"true\" />\n <span className=\"aegis-heatmap__cell-label\">\n {column.label}\n </span>\n <span className=\"aegis-heatmap__text\">{cell.text}</span>\n </>\n );\n const cellClass = [\n 'aegis-heatmap__cell',\n cell.level === null ? 'aegis-heatmap__cell--empty' : '',\n cell.emphasis ? 'aegis-heatmap__cell--emphasis' : '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div\n key={column.key}\n role=\"cell\"\n className=\"aegis-heatmap__slot\"\n style={\n {\n '--aegis-heatmap-color': chartColorValue(\n column.color ?? color,\n ),\n '--aegis-heatmap-level': cell.level ?? 0,\n '--aegis-heatmap-progress':\n progress === undefined\n ? 1\n : staggeredProgress(progress, index, columns.length),\n } as CSSProperties\n }\n >\n {cell.to === undefined ? (\n <span className={cellClass}>{content}</span>\n ) : (\n <Link\n to={cell.to}\n className={`${cellClass} aegis-heatmap__cell--link`}\n >\n {content}\n </Link>\n )}\n </div>\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n}\n"],"names":["Heatmap","columns","rows","corner","color","label","progress","Link","DefaultLink","className","jsxs","jsx","column","row","cell","index","content","Fragment","cellClass","chartColorValue","staggeredProgress"],"mappings":"0NA8DO,SAASA,EAAQ,CACtB,QAAAC,EACA,KAAAC,EACA,OAAAC,EACA,MAAAC,EAAQ,MACR,MAAAC,EACA,SAAAC,EACA,cAAeC,EAAOC,EAAAA,YACtB,UAAAC,CACF,EAA+B,CAC7B,OACEC,EAAAA,KAAC,MAAA,CACC,KAAK,QACL,aAAYL,EACZ,UAAW,CAAC,gBAAiBI,GAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EACtE,MAAO,CAAE,0BAA2BR,EAAQ,MAAA,EAE5C,SAAA,CAAAU,EAAAA,IAAC,MAAA,CAAI,KAAK,WAAW,UAAU,sBAC7B,gBAAC,MAAA,CAAI,KAAK,MAAM,UAAU,qBACxB,SAAA,CAAAA,MAAC,MAAA,CAAI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O,EAAY,WAAQ,EAErCP,EAAAA,IAACJ,EAAA,CACC,GAAIO,EAAK,GACT,UAAW,GAAGI,CAAS,6BAEtB,SAAAF,CAAA,CAAA,CACH,EAxBGJ,EAAO,GAAA,CA4BlB,CAAC,CAAA,GApDOC,EAAI,GAqDd,CACD,CAAA,CACH,CAAA,CAAA,CAAA,CAGN"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ChartColor } from '../../lib/chart';
|
|
3
|
+
import { LinkComponent } from './linkComponent';
|
|
4
|
+
export interface HeatmapColumn {
|
|
5
|
+
key: string;
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
/** A second line, e.g. the metric of the column. */
|
|
8
|
+
detail?: ReactNode;
|
|
9
|
+
/** The column's tint, when it differs from the chart's, e.g. a cost column. */
|
|
10
|
+
color?: ChartColor;
|
|
11
|
+
}
|
|
12
|
+
export interface HeatmapCell {
|
|
13
|
+
/** The cell's reading, e.g. "97.6%", or why it has none, e.g. "样本不足". */
|
|
14
|
+
text: ReactNode;
|
|
15
|
+
/** How strongly the cell is tinted, 0 to 1; null leaves it unfilled. */
|
|
16
|
+
level: number | null;
|
|
17
|
+
/** The best of its column: its text reads heavier. */
|
|
18
|
+
emphasis?: boolean;
|
|
19
|
+
/** Makes the cell a link. */
|
|
20
|
+
to?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface HeatmapRow {
|
|
23
|
+
key: string;
|
|
24
|
+
label: ReactNode;
|
|
25
|
+
/** One cell per column, in the columns' order. */
|
|
26
|
+
cells: HeatmapCell[];
|
|
27
|
+
}
|
|
28
|
+
export interface HeatmapProps {
|
|
29
|
+
columns: HeatmapColumn[];
|
|
30
|
+
rows: HeatmapRow[];
|
|
31
|
+
/** Names the row labels' column, e.g. "模型 × harness". */
|
|
32
|
+
corner?: ReactNode;
|
|
33
|
+
/** The tint of every column without its own. Defaults to `seq`. */
|
|
34
|
+
color?: ChartColor;
|
|
35
|
+
/** Names the table for a screen reader. */
|
|
36
|
+
label: string;
|
|
37
|
+
/**
|
|
38
|
+
* How far the cells are tinted, 0 to 1, column after column, for a table
|
|
39
|
+
* that fills as its section scrolls in (`useScrollProgress`).
|
|
40
|
+
*/
|
|
41
|
+
progress?: number;
|
|
42
|
+
/** Renders the cells' links. Defaults to an `<a href>`; routed apps pass their Link adapter. */
|
|
43
|
+
linkComponent?: LinkComponent;
|
|
44
|
+
className?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A table whose cells are tinted by how strong their reading is. Host code
|
|
48
|
+
* sets each cell's level, usually normalised within its column. On a phone
|
|
49
|
+
* every row folds into its label over a grid of labelled cells, so it is
|
|
50
|
+
* built from ARIA table roles, which keep their meaning through that.
|
|
51
|
+
*/
|
|
52
|
+
export declare function Heatmap({ columns, rows, corner, color, label, progress, linkComponent: Link, className, }: HeatmapProps): ReactElement;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsxs as s, jsx as e, Fragment as N } from "react/jsx-runtime";
|
|
2
|
+
import { staggeredProgress as v, chartColorValue as u } from "../../lib/chart.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { DefaultLink as b } from "./linkComponent.js";
|
|
5
|
+
function j({
|
|
6
|
+
columns: i,
|
|
7
|
+
rows: n,
|
|
8
|
+
corner: c,
|
|
9
|
+
color: p = "seq",
|
|
10
|
+
label: d,
|
|
11
|
+
progress: t,
|
|
12
|
+
linkComponent: _ = b,
|
|
13
|
+
className: g
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ s(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
role: "table",
|
|
19
|
+
"aria-label": d,
|
|
20
|
+
className: ["aegis-heatmap", g ?? ""].filter(Boolean).join(" "),
|
|
21
|
+
style: { "--aegis-heatmap-columns": i.length },
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ e("div", { role: "rowgroup", className: "aegis-heatmap__head", children: /* @__PURE__ */ s("div", { role: "row", className: "aegis-heatmap__row", children: [
|
|
24
|
+
/* @__PURE__ */ e("div", { role: "columnheader", className: "aegis-heatmap__corner", children: c }),
|
|
25
|
+
i.map((a) => /* @__PURE__ */ s(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
role: "columnheader",
|
|
29
|
+
className: "aegis-heatmap__column",
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ e("span", { className: "aegis-heatmap__column-label", children: a.label }),
|
|
32
|
+
a.detail !== void 0 && /* @__PURE__ */ e("span", { className: "aegis-heatmap__column-detail", children: a.detail })
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
a.key
|
|
36
|
+
))
|
|
37
|
+
] }) }),
|
|
38
|
+
/* @__PURE__ */ e("div", { role: "rowgroup", className: "aegis-heatmap__body", children: n.map((a) => /* @__PURE__ */ s("div", { role: "row", className: "aegis-heatmap__row", children: [
|
|
39
|
+
/* @__PURE__ */ e("div", { role: "rowheader", className: "aegis-heatmap__row-label", children: a.label }),
|
|
40
|
+
a.cells.map((l, m) => {
|
|
41
|
+
const r = i[m], o = /* @__PURE__ */ s(N, { children: [
|
|
42
|
+
/* @__PURE__ */ e("span", { className: "aegis-heatmap__tint", "aria-hidden": "true" }),
|
|
43
|
+
/* @__PURE__ */ e("span", { className: "aegis-heatmap__cell-label", children: r.label }),
|
|
44
|
+
/* @__PURE__ */ e("span", { className: "aegis-heatmap__text", children: l.text })
|
|
45
|
+
] }), h = [
|
|
46
|
+
"aegis-heatmap__cell",
|
|
47
|
+
l.level === null ? "aegis-heatmap__cell--empty" : "",
|
|
48
|
+
l.emphasis ? "aegis-heatmap__cell--emphasis" : ""
|
|
49
|
+
].filter(Boolean).join(" ");
|
|
50
|
+
return /* @__PURE__ */ e(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
role: "cell",
|
|
54
|
+
className: "aegis-heatmap__slot",
|
|
55
|
+
style: {
|
|
56
|
+
"--aegis-heatmap-color": u(
|
|
57
|
+
r.color ?? p
|
|
58
|
+
),
|
|
59
|
+
"--aegis-heatmap-level": l.level ?? 0,
|
|
60
|
+
"--aegis-heatmap-progress": t === void 0 ? 1 : v(t, m, i.length)
|
|
61
|
+
},
|
|
62
|
+
children: l.to === void 0 ? /* @__PURE__ */ e("span", { className: h, children: o }) : /* @__PURE__ */ e(
|
|
63
|
+
_,
|
|
64
|
+
{
|
|
65
|
+
to: l.to,
|
|
66
|
+
className: `${h} aegis-heatmap__cell--link`,
|
|
67
|
+
children: o
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
},
|
|
71
|
+
r.key
|
|
72
|
+
);
|
|
73
|
+
})
|
|
74
|
+
] }, a.key)) })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
j as Heatmap
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=Heatmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Heatmap.js","sources":["../../../src/components/ui/Heatmap.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport {\n type ChartColor,\n chartColorValue,\n staggeredProgress,\n} from '../../lib/chart';\nimport './Heatmap.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface HeatmapColumn {\n key: string;\n label: ReactNode;\n /** A second line, e.g. the metric of the column. */\n detail?: ReactNode;\n /** The column's tint, when it differs from the chart's, e.g. a cost column. */\n color?: ChartColor;\n}\n\nexport interface HeatmapCell {\n /** The cell's reading, e.g. \"97.6%\", or why it has none, e.g. \"样本不足\". */\n text: ReactNode;\n /** How strongly the cell is tinted, 0 to 1; null leaves it unfilled. */\n level: number | null;\n /** The best of its column: its text reads heavier. */\n emphasis?: boolean;\n /** Makes the cell a link. */\n to?: string;\n}\n\nexport interface HeatmapRow {\n key: string;\n label: ReactNode;\n /** One cell per column, in the columns' order. */\n cells: HeatmapCell[];\n}\n\nexport interface HeatmapProps {\n columns: HeatmapColumn[];\n rows: HeatmapRow[];\n /** Names the row labels' column, e.g. \"模型 × harness\". */\n corner?: ReactNode;\n /** The tint of every column without its own. Defaults to `seq`. */\n color?: ChartColor;\n /** Names the table for a screen reader. */\n label: string;\n /**\n * How far the cells are tinted, 0 to 1, column after column, for a table\n * that fills as its section scrolls in (`useScrollProgress`).\n */\n progress?: number;\n /** Renders the cells' links. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n}\n\n/**\n * A table whose cells are tinted by how strong their reading is. Host code\n * sets each cell's level, usually normalised within its column. On a phone\n * every row folds into its label over a grid of labelled cells, so it is\n * built from ARIA table roles, which keep their meaning through that.\n */\nexport function Heatmap({\n columns,\n rows,\n corner,\n color = 'seq',\n label,\n progress,\n linkComponent: Link = DefaultLink,\n className,\n}: HeatmapProps): ReactElement {\n return (\n <div\n role=\"table\"\n aria-label={label}\n className={['aegis-heatmap', className ?? ''].filter(Boolean).join(' ')}\n style={{ '--aegis-heatmap-columns': columns.length } as CSSProperties}\n >\n <div role=\"rowgroup\" className=\"aegis-heatmap__head\">\n <div role=\"row\" className=\"aegis-heatmap__row\">\n <div role=\"columnheader\" className=\"aegis-heatmap__corner\">\n {corner}\n </div>\n {columns.map((column) => (\n <div\n key={column.key}\n role=\"columnheader\"\n className=\"aegis-heatmap__column\"\n >\n <span className=\"aegis-heatmap__column-label\">\n {column.label}\n </span>\n {column.detail !== undefined && (\n <span className=\"aegis-heatmap__column-detail\">\n {column.detail}\n </span>\n )}\n </div>\n ))}\n </div>\n </div>\n <div role=\"rowgroup\" className=\"aegis-heatmap__body\">\n {rows.map((row) => (\n <div key={row.key} role=\"row\" className=\"aegis-heatmap__row\">\n <div role=\"rowheader\" className=\"aegis-heatmap__row-label\">\n {row.label}\n </div>\n {row.cells.map((cell, index) => {\n const column = columns[index];\n const content = (\n <>\n <span className=\"aegis-heatmap__tint\" aria-hidden=\"true\" />\n <span className=\"aegis-heatmap__cell-label\">\n {column.label}\n </span>\n <span className=\"aegis-heatmap__text\">{cell.text}</span>\n </>\n );\n const cellClass = [\n 'aegis-heatmap__cell',\n cell.level === null ? 'aegis-heatmap__cell--empty' : '',\n cell.emphasis ? 'aegis-heatmap__cell--emphasis' : '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div\n key={column.key}\n role=\"cell\"\n className=\"aegis-heatmap__slot\"\n style={\n {\n '--aegis-heatmap-color': chartColorValue(\n column.color ?? color,\n ),\n '--aegis-heatmap-level': cell.level ?? 0,\n '--aegis-heatmap-progress':\n progress === undefined\n ? 1\n : staggeredProgress(progress, index, columns.length),\n } as CSSProperties\n }\n >\n {cell.to === undefined ? (\n <span className={cellClass}>{content}</span>\n ) : (\n <Link\n to={cell.to}\n className={`${cellClass} aegis-heatmap__cell--link`}\n >\n {content}\n </Link>\n )}\n </div>\n );\n })}\n </div>\n ))}\n </div>\n </div>\n );\n}\n"],"names":["Heatmap","columns","rows","corner","color","label","progress","Link","DefaultLink","className","jsxs","jsx","column","row","cell","index","content","Fragment","cellClass","chartColorValue","staggeredProgress"],"mappings":";;;;AA8DO,SAASA,EAAQ;AAAA,EACtB,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAeC,IAAOC;AAAA,EACtB,WAAAC;AACF,GAA+B;AAC7B,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAYL;AAAA,MACZ,WAAW,CAAC,iBAAiBI,KAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MACtE,OAAO,EAAE,2BAA2BR,EAAQ,OAAA;AAAA,MAE5C,UAAA;AAAA,QAAA,gBAAAU,EAAC,OAAA,EAAI,MAAK,YAAW,WAAU,uBAC7B,4BAAC,OAAA,EAAI,MAAK,O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gBAEC,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,OACE;AAAA,kBACE,yBAAyBQ;AAAA,oBACvBP,EAAO,SAASR;AAAA,kBAAA;AAAA,kBAElB,yBAAyBU,EAAK,SAAS;AAAA,kBACvC,4BACER,MAAa,SACT,IACAc,EAAkBd,GAAUS,GAAOd,EAAQ,MAAM;AAAA,gBAAA;AAAA,gBAI1D,UAAAa,EAAK,OAAO,SACX,gBAAAH,EAAC,UAAK,WAAWO,GAAY,aAAQ,IAErC,gBAAAP;AAAA,kBAACJ;AAAA,kBAAA;AAAA,oBACC,IAAIO,EAAK;AAAA,oBACT,WAAW,GAAGI,CAAS;AAAA,oBAEtB,UAAAF;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACH;AAAA,cAxBGJ,EAAO;AAAA,YAAA;AAAA,UA4BlB,CAAC;AAAA,QAAA,KApDOC,EAAI,GAqDd,CACD,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),y=require("../../lib/chart.cjs");;/* empty css */function u({step:r,kind:m,color:c,title:l,detail:a,onSelect:s,selected:n=!1,className:d}){const t=["aegis-key-moment",s?"aegis-key-moment--interactive":"",n?"aegis-key-moment--selected":"",d??""].filter(Boolean).join(" "),i={"--aegis-key-moment-color":y.chartColorValue(c)},o=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"aegis-key-moment__head",children:[e.jsx("span",{className:"aegis-key-moment__dot","aria-hidden":"true"}),e.jsx("span",{className:"aegis-key-moment__step",children:r}),e.jsx("span",{className:"aegis-key-moment__kind",children:m})]}),e.jsx("span",{className:"aegis-key-moment__title",children:l}),a!==void 0&&e.jsx("span",{className:"aegis-key-moment__detail",children:a})]});return s?e.jsx("button",{type:"button",className:t,style:i,"aria-current":n?"step":void 0,onClick:s,children:o}):e.jsx("div",{className:t,style:i,children:o})}exports.KeyMomentCard=u;
|
|
2
|
+
//# sourceMappingURL=KeyMomentCard.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyMomentCard.cjs","sources":["../../../src/components/ui/KeyMomentCard.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport './KeyMomentCard.css';\n\nexport interface KeyMomentCardProps {\n /** Where the moment falls, e.g. \"#113\" or \"T31\". */\n step: ReactNode;\n /** What kind of moment it is, e.g. \"执行报错\". */\n kind: ReactNode;\n /** The kind's colour, the same as its steps on the strip. */\n color: ChartColor;\n title: ReactNode;\n detail?: ReactNode;\n /** Makes the card a button, e.g. one that moves the replay to the moment. */\n onSelect?: () => void;\n /** The moment the replay is on. */\n selected?: boolean;\n className?: string;\n}\n\n/** One moment of a replay that changed its course: where, what kind and what happened. */\nexport function KeyMomentCard({\n step,\n kind,\n color,\n title,\n detail,\n onSelect,\n selected = false,\n className,\n}: KeyMomentCardProps): ReactElement {\n const cls = [\n 'aegis-key-moment',\n onSelect ? 'aegis-key-moment--interactive' : '',\n selected ? 'aegis-key-moment--selected' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n const style = {\n '--aegis-key-moment-color': chartColorValue(color),\n } as CSSProperties;\n const body = (\n <>\n <span className=\"aegis-key-moment__head\">\n <span className=\"aegis-key-moment__dot\" aria-hidden=\"true\" />\n <span className=\"aegis-key-moment__step\">{step}</span>\n <span className=\"aegis-key-moment__kind\">{kind}</span>\n </span>\n <span className=\"aegis-key-moment__title\">{title}</span>\n {detail !== undefined && (\n <span className=\"aegis-key-moment__detail\">{detail}</span>\n )}\n </>\n );\n return onSelect ? (\n <button\n type=\"button\"\n className={cls}\n style={style}\n aria-current={selected ? 'step' : undefined}\n onClick={onSelect}\n >\n {body}\n </button>\n ) : (\n <div className={cls} style={style}>\n {body}\n </div>\n );\n}\n"],"names":["KeyMomentCard","step","kind","color","title","detail","onSelect","selected","className","cls","style","chartColorValue","body","jsxs","Fragment","jsx"],"mappings":"yLAsBO,SAASA,EAAc,CAC5B,KAAAC,EACA,KAAAC,EACA,MAAAC,EACA,MAAAC,EACA,OAAAC,EACA,SAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,CACF,EAAqC,CACnC,MAAMC,EAAM,CACV,mBACAH,EAAW,gCAAkC,GAC7CC,EAAW,6BAA+B,GAC1CC,GAAa,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,EACLE,EAAQ,CACZ,2BAA4BC,EAAAA,gBAAgBR,CAAK,CAAA,EAE7CS,EACJC,EAAAA,KAAAC,EAAAA,SAAA,CACE,SAAA,CAAAD,EAAAA,KAAC,OAAA,CAAK,UAAU,yBACd,SAAA,CAAAE,EAAAA,IAAC,OAAA,CAAK,UAAU,wBAAwB,cAAY,OAAO,EAC3DA,EAAAA,IAAC,OAAA,CAAK,UAAU,yBAA0B,SAAAd,EAAK,EAC/Cc,EAAAA,IAAC,OAAA,CAAK,UAAU,yBAA0B,SAAAb,CAAA,CAAK,CAAA,EACjD,EACAa,EAAAA,IAAC,OAAA,CAAK,UAAU,0BAA2B,SAAAX,EAAM,EAChDC,IAAW,QACVU,EAAAA,IAAC,OAAA,CAAK,UAAU,2BAA4B,SAAAV,CAAA,CAAO,CAAA,EAEvD,EAEF,OAAOC,EACLS,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAWN,EACX,MAAAC,EACA,eAAcH,EAAW,OAAS,OAClC,QAASD,EAER,SAAAM,CAAA,CAAA,EAGHG,EAAAA,IAAC,MAAA,CAAI,UAAWN,EAAK,MAAAC,EAClB,SAAAE,EACH,CAEJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ChartColor } from '../../lib/chart';
|
|
3
|
+
export interface KeyMomentCardProps {
|
|
4
|
+
/** Where the moment falls, e.g. "#113" or "T31". */
|
|
5
|
+
step: ReactNode;
|
|
6
|
+
/** What kind of moment it is, e.g. "执行报错". */
|
|
7
|
+
kind: ReactNode;
|
|
8
|
+
/** The kind's colour, the same as its steps on the strip. */
|
|
9
|
+
color: ChartColor;
|
|
10
|
+
title: ReactNode;
|
|
11
|
+
detail?: ReactNode;
|
|
12
|
+
/** Makes the card a button, e.g. one that moves the replay to the moment. */
|
|
13
|
+
onSelect?: () => void;
|
|
14
|
+
/** The moment the replay is on. */
|
|
15
|
+
selected?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
/** One moment of a replay that changed its course: where, what kind and what happened. */
|
|
19
|
+
export declare function KeyMomentCard({ step, kind, color, title, detail, onSelect, selected, className, }: KeyMomentCardProps): ReactElement;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as e, jsxs as o, Fragment as p } from "react/jsx-runtime";
|
|
2
|
+
import { chartColorValue as k } from "../../lib/chart.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
function N({
|
|
5
|
+
step: r,
|
|
6
|
+
kind: c,
|
|
7
|
+
color: l,
|
|
8
|
+
title: d,
|
|
9
|
+
detail: s,
|
|
10
|
+
onSelect: a,
|
|
11
|
+
selected: n = !1,
|
|
12
|
+
className: y
|
|
13
|
+
}) {
|
|
14
|
+
const t = [
|
|
15
|
+
"aegis-key-moment",
|
|
16
|
+
a ? "aegis-key-moment--interactive" : "",
|
|
17
|
+
n ? "aegis-key-moment--selected" : "",
|
|
18
|
+
y ?? ""
|
|
19
|
+
].filter(Boolean).join(" "), i = {
|
|
20
|
+
"--aegis-key-moment-color": k(l)
|
|
21
|
+
}, m = /* @__PURE__ */ o(p, { children: [
|
|
22
|
+
/* @__PURE__ */ o("span", { className: "aegis-key-moment__head", children: [
|
|
23
|
+
/* @__PURE__ */ e("span", { className: "aegis-key-moment__dot", "aria-hidden": "true" }),
|
|
24
|
+
/* @__PURE__ */ e("span", { className: "aegis-key-moment__step", children: r }),
|
|
25
|
+
/* @__PURE__ */ e("span", { className: "aegis-key-moment__kind", children: c })
|
|
26
|
+
] }),
|
|
27
|
+
/* @__PURE__ */ e("span", { className: "aegis-key-moment__title", children: d }),
|
|
28
|
+
s !== void 0 && /* @__PURE__ */ e("span", { className: "aegis-key-moment__detail", children: s })
|
|
29
|
+
] });
|
|
30
|
+
return a ? /* @__PURE__ */ e(
|
|
31
|
+
"button",
|
|
32
|
+
{
|
|
33
|
+
type: "button",
|
|
34
|
+
className: t,
|
|
35
|
+
style: i,
|
|
36
|
+
"aria-current": n ? "step" : void 0,
|
|
37
|
+
onClick: a,
|
|
38
|
+
children: m
|
|
39
|
+
}
|
|
40
|
+
) : /* @__PURE__ */ e("div", { className: t, style: i, children: m });
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
N as KeyMomentCard
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=KeyMomentCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyMomentCard.js","sources":["../../../src/components/ui/KeyMomentCard.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport './KeyMomentCard.css';\n\nexport interface KeyMomentCardProps {\n /** Where the moment falls, e.g. \"#113\" or \"T31\". */\n step: ReactNode;\n /** What kind of moment it is, e.g. \"执行报错\". */\n kind: ReactNode;\n /** The kind's colour, the same as its steps on the strip. */\n color: ChartColor;\n title: ReactNode;\n detail?: ReactNode;\n /** Makes the card a button, e.g. one that moves the replay to the moment. */\n onSelect?: () => void;\n /** The moment the replay is on. */\n selected?: boolean;\n className?: string;\n}\n\n/** One moment of a replay that changed its course: where, what kind and what happened. */\nexport function KeyMomentCard({\n step,\n kind,\n color,\n title,\n detail,\n onSelect,\n selected = false,\n className,\n}: KeyMomentCardProps): ReactElement {\n const cls = [\n 'aegis-key-moment',\n onSelect ? 'aegis-key-moment--interactive' : '',\n selected ? 'aegis-key-moment--selected' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n const style = {\n '--aegis-key-moment-color': chartColorValue(color),\n } as CSSProperties;\n const body = (\n <>\n <span className=\"aegis-key-moment__head\">\n <span className=\"aegis-key-moment__dot\" aria-hidden=\"true\" />\n <span className=\"aegis-key-moment__step\">{step}</span>\n <span className=\"aegis-key-moment__kind\">{kind}</span>\n </span>\n <span className=\"aegis-key-moment__title\">{title}</span>\n {detail !== undefined && (\n <span className=\"aegis-key-moment__detail\">{detail}</span>\n )}\n </>\n );\n return onSelect ? (\n <button\n type=\"button\"\n className={cls}\n style={style}\n aria-current={selected ? 'step' : undefined}\n onClick={onSelect}\n >\n {body}\n </button>\n ) : (\n <div className={cls} style={style}>\n {body}\n </div>\n );\n}\n"],"names":["KeyMomentCard","step","kind","color","title","detail","onSelect","selected","className","cls","style","chartColorValue","body","jsxs","Fragment","jsx"],"mappings":";;;AAsBO,SAASA,EAAc;AAAA,EAC5B,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC;AACF,GAAqC;AACnC,QAAMC,IAAM;AAAA,IACV;AAAA,IACAH,IAAW,kCAAkC;AAAA,IAC7CC,IAAW,+BAA+B;AAAA,IAC1CC,KAAa;AAAA,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,GACLE,IAAQ;AAAA,IACZ,4BAA4BC,EAAgBR,CAAK;AAAA,EAAA,GAE7CS,IACJ,gBAAAC,EAAAC,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAD,EAAC,QAAA,EAAK,WAAU,0BACd,UAAA;AAAA,MAAA,gBAAAE,EAAC,QAAA,EAAK,WAAU,yBAAwB,eAAY,QAAO;AAAA,MAC3D,gBAAAA,EAAC,QAAA,EAAK,WAAU,0BAA0B,UAAAd,GAAK;AAAA,MAC/C,gBAAAc,EAAC,QAAA,EAAK,WAAU,0BAA0B,UAAAb,EAAA,CAAK;AAAA,IAAA,GACjD;AAAA,IACA,gBAAAa,EAAC,QAAA,EAAK,WAAU,2BAA2B,UAAAX,GAAM;AAAA,IAChDC,MAAW,UACV,gBAAAU,EAAC,QAAA,EAAK,WAAU,4BAA4B,UAAAV,EAAA,CAAO;AAAA,EAAA,GAEvD;AAEF,SAAOC,IACL,gBAAAS;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAWN;AAAA,MACX,OAAAC;AAAA,MACA,gBAAcH,IAAW,SAAS;AAAA,MAClC,SAASD;AAAA,MAER,UAAAM;AAAA,IAAA;AAAA,EAAA,IAGH,gBAAAG,EAAC,OAAA,EAAI,WAAWN,GAAK,OAAAC,GAClB,UAAAE,GACH;AAEJ;"}
|
|
@@ -0,0 +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;
|
|
2
|
+
//# sourceMappingURL=LineChart.cjs.map
|
|
@@ -0,0 +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,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,EAASjB,EAAO,QAASkB,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,EA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,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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ChartColor } from '../../lib/chart';
|
|
3
|
+
export interface LineChartPoint {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
export interface LineChartSeries {
|
|
8
|
+
key: string;
|
|
9
|
+
/** Written at the end of the line, with its last value. */
|
|
10
|
+
label: string;
|
|
11
|
+
color: ChartColor;
|
|
12
|
+
points: LineChartPoint[];
|
|
13
|
+
}
|
|
14
|
+
export interface LineChartMarker {
|
|
15
|
+
key: string;
|
|
16
|
+
x: number;
|
|
17
|
+
color: ChartColor;
|
|
18
|
+
/** Names the event in its tooltip. */
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
export interface LineChartProps {
|
|
22
|
+
series: LineChartSeries[];
|
|
23
|
+
/** Names the chart for a screen reader. */
|
|
24
|
+
label: string;
|
|
25
|
+
/** Names the horizontal axis, e.g. "回合". */
|
|
26
|
+
xLabel?: string;
|
|
27
|
+
/** The gridlines. Defaults to about five round values. */
|
|
28
|
+
yTicks?: number[];
|
|
29
|
+
formatX?: (value: number) => string;
|
|
30
|
+
formatY?: (value: number) => string;
|
|
31
|
+
/** Where a replay's playhead is on the horizontal axis. */
|
|
32
|
+
playhead?: number;
|
|
33
|
+
/** Lets the reader click or use the arrow keys to move the playhead. */
|
|
34
|
+
onSeek?: (x: number) => void;
|
|
35
|
+
/** Events on the horizontal axis, e.g. a replay's key moments. */
|
|
36
|
+
markers?: LineChartMarker[];
|
|
37
|
+
/**
|
|
38
|
+
* How far the lines are drawn, 0 to 1, for a chart that draws as its
|
|
39
|
+
* section scrolls in (`useScrollProgress`). Omitted, it shows its final state.
|
|
40
|
+
*/
|
|
41
|
+
progress?: number;
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Lines over a shared horizontal axis, labelled at their ends instead of
|
|
46
|
+
* in a legend, with an optional playhead the reader can move.
|
|
47
|
+
*/
|
|
48
|
+
export declare function LineChart({ series, label, xLabel, yTicks, formatX, formatY, playhead, onSeek, markers, progress, className, }: LineChartProps): ReactElement;
|