@lincyaw/aegis-ui 0.7.0 → 0.8.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/ChartLegend.cjs +2 -0
- package/dist/components/ui/ChartLegend.cjs.map +1 -0
- package/dist/components/ui/ChartLegend.d.ts +15 -0
- package/dist/components/ui/ChartLegend.js +36 -0
- package/dist/components/ui/ChartLegend.js.map +1 -0
- package/dist/components/ui/DataTable.cjs +1 -1
- package/dist/components/ui/DataTable.cjs.map +1 -1
- package/dist/components/ui/DataTable.d.ts +25 -1
- package/dist/components/ui/DataTable.js +305 -231
- package/dist/components/ui/DataTable.js.map +1 -1
- package/dist/components/ui/ParetoChart.cjs +1 -1
- package/dist/components/ui/ParetoChart.cjs.map +1 -1
- package/dist/components/ui/ParetoChart.d.ts +11 -4
- package/dist/components/ui/ParetoChart.js +150 -136
- 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 +17 -2
- package/dist/components/ui/RankBar.js +46 -31
- package/dist/components/ui/RankBar.js.map +1 -1
- package/dist/components/ui/ReplayScrubber.cjs +2 -0
- package/dist/components/ui/ReplayScrubber.cjs.map +1 -0
- package/dist/components/ui/ReplayScrubber.d.ts +35 -0
- package/dist/components/ui/ReplayScrubber.js +119 -0
- package/dist/components/ui/ReplayScrubber.js.map +1 -0
- package/dist/components/ui/ReplayStepStrip.cjs +2 -0
- package/dist/components/ui/ReplayStepStrip.cjs.map +1 -0
- package/dist/components/ui/ReplayStepStrip.d.ts +33 -0
- package/dist/components/ui/ReplayStepStrip.js +119 -0
- package/dist/components/ui/ReplayStepStrip.js.map +1 -0
- package/dist/components/ui/ReplayTransport.cjs +2 -0
- package/dist/components/ui/ReplayTransport.cjs.map +1 -0
- package/dist/components/ui/ReplayTransport.d.ts +25 -0
- package/dist/components/ui/ReplayTransport.js +103 -0
- package/dist/components/ui/ReplayTransport.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 +9 -8
- package/dist/components/ui/StackedBar.js +69 -54
- package/dist/components/ui/StackedBar.js.map +1 -1
- package/dist/components/ui/TimelineChart.cjs +1 -1
- package/dist/components/ui/TimelineChart.cjs.map +1 -1
- package/dist/components/ui/TimelineChart.d.ts +12 -15
- package/dist/components/ui/TimelineChart.js +160 -150
- package/dist/components/ui/TimelineChart.js.map +1 -1
- package/dist/components/ui/TraceSpanInspector.cjs +1 -1
- package/dist/components/ui/TraceSpanInspector.cjs.map +1 -1
- package/dist/components/ui/TraceSpanInspector.js +25 -25
- package/dist/components/ui/TraceSpanInspector.js.map +1 -1
- package/dist/components/ui/TraceTree.cjs +1 -1
- package/dist/components/ui/TraceTree.cjs.map +1 -1
- package/dist/components/ui/TraceTree.d.ts +13 -2
- package/dist/components/ui/TraceTree.js +22 -22
- package/dist/components/ui/TraceTree.js.map +1 -1
- package/dist/components/ui/index.d.ts +11 -5
- package/dist/components/ui/traceFormat.cjs +1 -1
- package/dist/components/ui/traceFormat.cjs.map +1 -1
- package/dist/components/ui/traceFormat.d.ts +0 -2
- package/dist/components/ui/traceFormat.js +2 -6
- package/dist/components/ui/traceFormat.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useReplayPlayback.cjs +2 -0
- package/dist/hooks/useReplayPlayback.cjs.map +1 -0
- package/dist/hooks/useReplayPlayback.d.ts +44 -0
- package/dist/hooks/useReplayPlayback.js +73 -0
- package/dist/hooks/useReplayPlayback.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +312 -300
- package/dist/index.js.map +1 -1
- package/dist/layouts/SkipLink.cjs +2 -0
- package/dist/layouts/SkipLink.cjs.map +1 -0
- package/dist/layouts/SkipLink.d.ts +13 -0
- package/dist/layouts/SkipLink.js +21 -0
- package/dist/layouts/SkipLink.js.map +1 -0
- package/dist/layouts/shell/AegisShell.cjs +1 -1
- package/dist/layouts/shell/AegisShell.cjs.map +1 -1
- package/dist/layouts/shell/AegisShell.js +174 -193
- package/dist/layouts/shell/AegisShell.js.map +1 -1
- package/dist/layouts/site/SiteLayout.cjs +1 -1
- package/dist/layouts/site/SiteLayout.cjs.map +1 -1
- package/dist/layouts/site/SiteLayout.js +18 -28
- package/dist/layouts/site/SiteLayout.js.map +1 -1
- package/dist/layouts/site/SiteNav.cjs +1 -1
- package/dist/layouts/site/SiteNav.cjs.map +1 -1
- package/dist/layouts/site/SiteNav.js +50 -48
- package/dist/layouts/site/SiteNav.js.map +1 -1
- package/dist/lib/chart.cjs +2 -0
- package/dist/lib/chart.cjs.map +1 -0
- package/dist/lib/chart.d.ts +33 -0
- package/dist/lib/chart.js +47 -0
- package/dist/lib/chart.js.map +1 -0
- package/dist/locale/strings.cjs +1 -1
- package/dist/locale/strings.cjs.map +1 -1
- package/dist/locale/strings.d.ts +9 -8
- package/dist/locale/strings.js +36 -34
- package/dist/locale/strings.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/components/ui/SessionRunView.cjs +0 -4
- package/dist/components/ui/SessionRunView.cjs.map +0 -1
- package/dist/components/ui/SessionRunView.d.ts +0 -50
- package/dist/components/ui/SessionRunView.js +0 -379
- package/dist/components/ui/SessionRunView.js.map +0 -1
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import { jsxs as c, jsx as
|
|
1
|
+
import { jsxs as c, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { zeroAnchoredDomain as h, staggeredProgress as v, chartColorValue as N } from "../../lib/chart.js";
|
|
2
3
|
/* empty css */
|
|
3
|
-
import { useStrings as
|
|
4
|
-
function
|
|
5
|
-
items:
|
|
6
|
-
max:
|
|
7
|
-
direction:
|
|
4
|
+
import { useStrings as m } from "../../locale/useStrings.js";
|
|
5
|
+
function B({
|
|
6
|
+
items: o,
|
|
7
|
+
max: g,
|
|
8
|
+
direction: _,
|
|
8
9
|
format: n = (s) => s.toFixed(2),
|
|
9
10
|
onSelect: e,
|
|
11
|
+
progress: k,
|
|
10
12
|
className: t
|
|
11
13
|
}) {
|
|
12
|
-
const s =
|
|
13
|
-
(
|
|
14
|
-
), i =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const s = m(), u = o.flatMap(
|
|
15
|
+
(a) => a.value === null ? [] : [a.value]
|
|
16
|
+
), [, i] = h(u, g), p = [
|
|
17
|
+
"aegis-rank-bar",
|
|
18
|
+
k === void 0 ? "" : "aegis-rank-bar--scroll",
|
|
19
|
+
t ?? ""
|
|
20
|
+
].filter(Boolean).join(" ");
|
|
21
|
+
return /* @__PURE__ */ c("div", { className: p, children: [
|
|
22
|
+
o.map((a, b) => {
|
|
23
|
+
const { value: l } = a, d = l === null ? null : /* @__PURE__ */ r(
|
|
18
24
|
"div",
|
|
19
25
|
{
|
|
20
26
|
className: [
|
|
@@ -23,26 +29,35 @@ function m({
|
|
|
23
29
|
].filter(Boolean).join(" "),
|
|
24
30
|
style: {
|
|
25
31
|
width: `${(i > 0 ? l / i * 100 : 0).toString()}%`,
|
|
26
|
-
"--aegis-rank-bar-index":
|
|
27
|
-
|
|
32
|
+
"--aegis-rank-bar-index": b,
|
|
33
|
+
...a.color === void 0 || l === 0 ? {} : { background: N(a.color) },
|
|
34
|
+
...k === void 0 ? {} : {
|
|
35
|
+
"--aegis-rank-bar-progress": v(
|
|
36
|
+
k,
|
|
37
|
+
b,
|
|
38
|
+
o.length
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
children: /* @__PURE__ */ r("span", { className: "aegis-rank-bar__ink" })
|
|
28
43
|
}
|
|
29
44
|
);
|
|
30
45
|
return /* @__PURE__ */ c("div", { className: "aegis-rank-bar__row", children: [
|
|
31
|
-
e ? /* @__PURE__ */
|
|
46
|
+
e ? /* @__PURE__ */ r(
|
|
32
47
|
"button",
|
|
33
48
|
{
|
|
34
49
|
type: "button",
|
|
35
50
|
className: "aegis-rank-bar__label aegis-rank-bar__label--link",
|
|
36
51
|
onClick: () => {
|
|
37
|
-
e(
|
|
52
|
+
e(a.key);
|
|
38
53
|
},
|
|
39
|
-
children:
|
|
54
|
+
children: a.label
|
|
40
55
|
}
|
|
41
|
-
) : /* @__PURE__ */
|
|
56
|
+
) : /* @__PURE__ */ r("span", { className: "aegis-rank-bar__label", children: a.label }),
|
|
42
57
|
e ? (
|
|
43
58
|
// The label button is the keyboard and screen-reader target;
|
|
44
59
|
// the track only widens the pointer target.
|
|
45
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ r(
|
|
46
61
|
"button",
|
|
47
62
|
{
|
|
48
63
|
type: "button",
|
|
@@ -50,41 +65,41 @@ function m({
|
|
|
50
65
|
"aria-hidden": "true",
|
|
51
66
|
className: "aegis-rank-bar__track aegis-rank-bar__track--link",
|
|
52
67
|
onClick: () => {
|
|
53
|
-
e(
|
|
68
|
+
e(a.key);
|
|
54
69
|
},
|
|
55
|
-
children:
|
|
70
|
+
children: d
|
|
56
71
|
}
|
|
57
72
|
)
|
|
58
|
-
) : /* @__PURE__ */
|
|
73
|
+
) : /* @__PURE__ */ r(
|
|
59
74
|
"div",
|
|
60
75
|
{
|
|
61
76
|
className: "aegis-rank-bar__track",
|
|
62
77
|
role: "img",
|
|
63
78
|
"aria-label": l === null ? s.noValue : s.barValue(n(l), n(i)),
|
|
64
|
-
children:
|
|
79
|
+
children: d
|
|
65
80
|
}
|
|
66
81
|
),
|
|
67
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ r(
|
|
68
83
|
"span",
|
|
69
84
|
{
|
|
70
85
|
className: l === null ? "aegis-rank-bar__value aegis-rank-bar__value--empty" : "aegis-rank-bar__value",
|
|
71
86
|
children: l === null ? "—" : n(l)
|
|
72
87
|
}
|
|
73
88
|
),
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
] },
|
|
89
|
+
/* @__PURE__ */ r("span", { className: "aegis-rank-bar__action", children: a.action })
|
|
90
|
+
] }, a.key);
|
|
76
91
|
}),
|
|
77
92
|
/* @__PURE__ */ c("div", { className: "aegis-rank-bar__scale", children: [
|
|
78
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ r("span", { className: "aegis-rank-bar__spacer" }),
|
|
79
94
|
/* @__PURE__ */ c("div", { className: "aegis-rank-bar__ticks", children: [
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
82
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ r("span", { children: "0" }),
|
|
96
|
+
_ !== void 0 && /* @__PURE__ */ r("span", { className: "aegis-rank-bar__direction", children: _ }),
|
|
97
|
+
/* @__PURE__ */ r("span", { children: n(i) })
|
|
83
98
|
] })
|
|
84
99
|
] })
|
|
85
100
|
] });
|
|
86
101
|
}
|
|
87
102
|
export {
|
|
88
|
-
|
|
103
|
+
B as RankBar
|
|
89
104
|
};
|
|
90
105
|
//# sourceMappingURL=RankBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RankBar.js","sources":["../../../src/components/ui/RankBar.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode } from 'react';\n\nimport { useStrings } from '../../locale';\nimport './RankBar.css';\n\nexport interface RankBarItem {\n key: string;\n label: ReactNode;\n /**\n * `null` is a missing value: an em dash over an empty track, distinct\n * from a real 0, which keeps a visible endpoint.\n */\n value: number | null;\n /** Trailing slot for a per-row link, e.g. \"逐题表现\". */\n action?: ReactNode;\n}\n\ninterface RankBarProps {\n items: RankBarItem[];\n
|
|
1
|
+
{"version":3,"file":"RankBar.js","sources":["../../../src/components/ui/RankBar.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode } from 'react';\n\nimport {\n type ChartColor,\n chartColorValue,\n staggeredProgress,\n zeroAnchoredDomain,\n} from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './RankBar.css';\n\nexport interface RankBarItem {\n key: string;\n label: ReactNode;\n /**\n * `null` is a missing value: an em dash over an empty track, distinct\n * from a real 0, which keeps a visible endpoint.\n */\n value: number | null;\n /** Trailing slot for a per-row link, e.g. \"逐题表现\". */\n action?: ReactNode;\n /**\n * The bar's colour, e.g. the series colour of the model's vendor.\n * Defaults to `--rank-bar-fill`.\n */\n color?: ChartColor;\n}\n\ninterface RankBarProps {\n items: RankBarItem[];\n /**\n * Upper bound of the scale. Defaults to the largest value, or 1 when all\n * are 0; pass `1` for a share or a 0–1 score.\n */\n max?: number;\n /** Scale hint rendered at the bottom, e.g. \"越高越好\". */\n direction?: ReactNode;\n format?: (value: number) => string;\n /** Makes each row's label and bar track select that row. */\n onSelect?: (key: string) => void;\n /**\n * How far the bars are drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`). Omitted, the bars draw in\n * once when they mount.\n */\n progress?: number;\n className?: string;\n}\n\nexport function RankBar({\n items,\n max,\n direction,\n format = (value) => value.toFixed(2),\n onSelect,\n progress,\n className,\n}: RankBarProps) {\n const strings = useStrings();\n const values = items.flatMap((item) =>\n item.value === null ? [] : [item.value],\n );\n const [, upperBound] = zeroAnchoredDomain(values, max);\n const cls = [\n 'aegis-rank-bar',\n progress === undefined ? '' : 'aegis-rank-bar--scroll',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div className={cls}>\n {items.map((item, index) => {\n const { value } = item;\n const fill =\n value === null ? null : (\n <div\n className={[\n 'aegis-rank-bar__fill',\n value === 0 ? 'aegis-rank-bar__fill--zero' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={\n {\n width: `${(upperBound > 0 ? (value / upperBound) * 100 : 0).toString()}%`,\n '--aegis-rank-bar-index': index,\n ...(item.color === undefined || value === 0\n ? {}\n : { background: chartColorValue(item.color) }),\n ...(progress === undefined\n ? {}\n : {\n '--aegis-rank-bar-progress': staggeredProgress(\n progress,\n index,\n items.length,\n ),\n }),\n } as CSSProperties\n }\n >\n <span className=\"aegis-rank-bar__ink\" />\n </div>\n );\n return (\n <div className=\"aegis-rank-bar__row\" key={item.key}>\n {onSelect ? (\n <button\n type=\"button\"\n className=\"aegis-rank-bar__label aegis-rank-bar__label--link\"\n onClick={() => {\n onSelect(item.key);\n }}\n >\n {item.label}\n </button>\n ) : (\n <span className=\"aegis-rank-bar__label\">{item.label}</span>\n )}\n {onSelect ? (\n // The label button is the keyboard and screen-reader target;\n // the track only widens the pointer target.\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className=\"aegis-rank-bar__track aegis-rank-bar__track--link\"\n onClick={() => {\n onSelect(item.key);\n }}\n >\n {fill}\n </button>\n ) : (\n <div\n className=\"aegis-rank-bar__track\"\n role=\"img\"\n aria-label={\n value === null\n ? strings.noValue\n : strings.barValue(format(value), format(upperBound))\n }\n >\n {fill}\n </div>\n )}\n <span\n className={\n value === null\n ? 'aegis-rank-bar__value aegis-rank-bar__value--empty'\n : 'aegis-rank-bar__value'\n }\n >\n {value === null ? '—' : format(value)}\n </span>\n <span className=\"aegis-rank-bar__action\">{item.action}</span>\n </div>\n );\n })}\n <div className=\"aegis-rank-bar__scale\">\n <span className=\"aegis-rank-bar__spacer\" />\n <div className=\"aegis-rank-bar__ticks\">\n <span>0</span>\n {direction !== undefined && (\n <span className=\"aegis-rank-bar__direction\">{direction}</span>\n )}\n <span>{format(upperBound)}</span>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["RankBar","items","max","direction","format","value","onSelect","progress","className","strings","useStrings","values","item","upperBound","zeroAnchoredDomain","cls","jsxs","index","fill","jsx","chartColorValue","staggeredProgress"],"mappings":";;;;AAiDO,SAASA,EAAQ;AAAA,EACtB,OAAAC;AAAA,EACA,KAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC,IAAS,CAACC,MAAUA,EAAM,QAAQ,CAAC;AAAA,EACnC,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AACF,GAA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,EAAM,UAAAf,EAAOS,CAAU,EAAA,CAAE;AAAA,MAAA,EAAA,CAC5B;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),D=require("react"),E=require("../../lib/chart.cjs");;/* empty css */const q=require("../../locale/useStrings.cjs"),y=.08;function v({count:i,index:r,onIndexChange:b,markers:p=[],formatStep:u=o=>o+1,ariaLabel:m,onScrubStart:d,onScrubEnd:f,className:j}){const o=q.useStrings(),g=D.useRef(null),a=Math.max(i-1,0),c=e=>a===0?0:Math.min(Math.max(e/a,0),1),_=e=>{const t=g.current;if(!t)return;const l=t.getBoundingClientRect(),C=(e-l.left)/Math.max(l.width,1);b(Math.round(Math.min(Math.max(C,0),1)*a))},M=e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),d?.(),_(e.clientX))},N=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&_(e.clientX)},h=()=>{f?.()},P=e=>{const t=Math.max(Math.round(i/10),1),l={ArrowLeft:r-1,ArrowDown:r-1,ArrowRight:r+1,ArrowUp:r+1,PageDown:r-t,PageUp:r+t,Home:0,End:a};e.key in l&&(e.preventDefault(),b(Math.min(Math.max(l[e.key],0),a)))},w={"--aegis-replay-scrubber-position":c(r)},n=Math.max(i,0),R=p.filter(e=>e.index===r).map(e=>e.label),S=[o.replayStepOf(n===0?0:r+1,n),...R].join(" · "),k=r>0&&c(r)<y,A=r<a&&c(r)>1-y;return s.jsxs("div",{className:["aegis-replay-scrubber",j??""].filter(Boolean).join(" "),style:w,children:[s.jsx("div",{className:"aegis-replay-scrubber__markers","aria-hidden":"true",children:p.map((e,t)=>s.jsx("span",{className:"aegis-replay-scrubber__marker",title:e.label,style:{left:`${(c(e.index)*100).toString()}%`,background:E.chartColorValue(e.color)}},t))}),s.jsxs("div",{ref:g,className:"aegis-replay-scrubber__track",role:"slider",tabIndex:0,"aria-label":m??o.replayPosition,"aria-valuemin":n===0?0:1,"aria-valuemax":n,"aria-valuenow":n===0?0:r+1,"aria-valuetext":S,onPointerDown:M,onPointerMove:N,onPointerUp:h,onPointerCancel:h,onKeyDown:P,children:[s.jsx("span",{className:"aegis-replay-scrubber__played"}),s.jsx("span",{className:"aegis-replay-scrubber__thumb"})]}),s.jsxs("div",{className:"aegis-replay-scrubber__labels","aria-hidden":"true",children:[s.jsx("span",{className:["aegis-replay-scrubber__end",r===0?"aegis-replay-scrubber__label--current":"",k?"aegis-replay-scrubber__end--hidden":""].filter(Boolean).join(" "),children:n===0?null:u(0)}),r>0&&r<a&&s.jsx("span",{className:"aegis-replay-scrubber__at aegis-replay-scrubber__label--current",children:u(r)}),a>0&&s.jsx("span",{className:["aegis-replay-scrubber__end aegis-replay-scrubber__end--last",r===a?"aegis-replay-scrubber__label--current":"",A?"aegis-replay-scrubber__end--hidden":""].filter(Boolean).join(" "),children:u(a)})]})]})}exports.ReplayScrubber=v;
|
|
2
|
+
//# sourceMappingURL=ReplayScrubber.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplayScrubber.cjs","sources":["../../../src/components/ui/ReplayScrubber.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type PointerEvent,\n type ReactElement,\n type ReactNode,\n useRef,\n} from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './ReplayScrubber.css';\n\nexport interface ReplayScrubberMarker {\n /** The step the marker sits over. */\n index: number;\n color: ChartColor;\n /** Names the event, e.g. \"T17 · 夺取 C4\"; shown as the marker's tooltip. */\n label: string;\n}\n\nexport interface ReplayScrubberProps {\n /** How many steps the replay has. */\n count: number;\n index: number;\n onIndexChange: (index: number) => void;\n /** Events above the track, each a dot in its colour. */\n markers?: ReplayScrubberMarker[];\n /** The label of a step under the track, e.g. `T42`. Defaults to its number. */\n formatStep?: (index: number) => ReactNode;\n /** Names the slider; defaults to \"Replay position\". */\n ariaLabel?: string;\n /**\n * A pointer drag starts and ends: hold playback in between, e.g. with\n * `useReplayPlayback`'s `hold` and `release`.\n */\n onScrubStart?: () => void;\n onScrubEnd?: () => void;\n className?: string;\n}\n\n/** A label within this share of the track from an end hides that end's label. */\nconst END_CLEARANCE = 0.08;\n\n/**\n * The replay's position: a track from the first step to the last with a\n * thumb at the current one and event markers above it. Drag or click to\n * seek; arrow keys step by one, Page Up / Down by a tenth, Home / End to\n * the ends.\n */\nexport function ReplayScrubber({\n count,\n index,\n onIndexChange,\n markers = [],\n formatStep = (step) => step + 1,\n ariaLabel,\n onScrubStart,\n onScrubEnd,\n className,\n}: ReplayScrubberProps): ReactElement {\n const strings = useStrings();\n const trackRef = useRef<HTMLDivElement>(null);\n const last = Math.max(count - 1, 0);\n const share = (step: number): number =>\n last === 0 ? 0 : Math.min(Math.max(step / last, 0), 1);\n\n const seekToPointer = (clientX: number): void => {\n const track = trackRef.current;\n if (!track) {\n return;\n }\n const rect = track.getBoundingClientRect();\n const ratio = (clientX - rect.left) / Math.max(rect.width, 1);\n onIndexChange(Math.round(Math.min(Math.max(ratio, 0), 1) * last));\n };\n\n const onPointerDown = (event: PointerEvent<HTMLDivElement>): void => {\n if (event.button !== 0) {\n return;\n }\n event.currentTarget.setPointerCapture(event.pointerId);\n onScrubStart?.();\n seekToPointer(event.clientX);\n };\n const onPointerMove = (event: PointerEvent<HTMLDivElement>): void => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n seekToPointer(event.clientX);\n }\n };\n const onPointerEnd = (): void => {\n onScrubEnd?.();\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n const page = Math.max(Math.round(count / 10), 1);\n const target: Record<string, number> = {\n ArrowLeft: index - 1,\n ArrowDown: index - 1,\n ArrowRight: index + 1,\n ArrowUp: index + 1,\n PageDown: index - page,\n PageUp: index + page,\n Home: 0,\n End: last,\n };\n if (event.key in target) {\n event.preventDefault();\n onIndexChange(Math.min(Math.max(target[event.key], 0), last));\n }\n };\n\n const position = { '--aegis-replay-scrubber-position': share(index) };\n const total = Math.max(count, 0);\n const here = markers\n .filter((marker) => marker.index === index)\n .map((marker) => marker.label);\n const valueText = [\n strings.replayStepOf(total === 0 ? 0 : index + 1, total),\n ...here,\n ].join(' · ');\n const nearStart = index > 0 && share(index) < END_CLEARANCE;\n const nearEnd = index < last && share(index) > 1 - END_CLEARANCE;\n return (\n <div\n className={['aegis-replay-scrubber', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={position as CSSProperties}\n >\n <div className=\"aegis-replay-scrubber__markers\" aria-hidden=\"true\">\n {markers.map((marker, position) => (\n <span\n key={position}\n className=\"aegis-replay-scrubber__marker\"\n title={marker.label}\n style={\n {\n left: `${(share(marker.index) * 100).toString()}%`,\n background: chartColorValue(marker.color),\n } as CSSProperties\n }\n />\n ))}\n </div>\n <div\n ref={trackRef}\n className=\"aegis-replay-scrubber__track\"\n role=\"slider\"\n tabIndex={0}\n aria-label={ariaLabel ?? strings.replayPosition}\n aria-valuemin={total === 0 ? 0 : 1}\n aria-valuemax={total}\n aria-valuenow={total === 0 ? 0 : index + 1}\n aria-valuetext={valueText}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerEnd}\n onPointerCancel={onPointerEnd}\n onKeyDown={onKeyDown}\n >\n <span className=\"aegis-replay-scrubber__played\" />\n <span className=\"aegis-replay-scrubber__thumb\" />\n </div>\n <div className=\"aegis-replay-scrubber__labels\" aria-hidden=\"true\">\n <span\n className={[\n 'aegis-replay-scrubber__end',\n index === 0 ? 'aegis-replay-scrubber__label--current' : '',\n nearStart ? 'aegis-replay-scrubber__end--hidden' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {total === 0 ? null : formatStep(0)}\n </span>\n {index > 0 && index < last && (\n <span className=\"aegis-replay-scrubber__at aegis-replay-scrubber__label--current\">\n {formatStep(index)}\n </span>\n )}\n {last > 0 && (\n <span\n className={[\n 'aegis-replay-scrubber__end aegis-replay-scrubber__end--last',\n index === last ? 'aegis-replay-scrubber__label--current' : '',\n nearEnd ? 'aegis-replay-scrubber__end--hidden' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {formatStep(last)}\n </span>\n )}\n </div>\n </div>\n );\n}\n"],"names":["END_CLEARANCE","ReplayScrubber","count","index","onIndexChange","markers","formatStep","step","ariaLabel","onScrubStart","onScrubEnd","className","strings","useStrings","trackRef","useRef","last","share","seekToPointer","clientX","track","rect","ratio","onPointerDown","event","onPointerMove","onPointerEnd","onKeyDown","page","target","position","total","here","marker","valueText","nearStart","nearEnd","jsxs","jsx","chartColorValue"],"mappings":"4PA0CMA,EAAgB,IAQf,SAASC,EAAe,CAC7B,MAAAC,EACA,MAAAC,EACA,cAAAC,EACA,QAAAC,EAAU,CAAA,EACV,WAAAC,EAAcC,GAASA,EAAO,EAC9B,UAAAC,EACA,aAAAC,EACA,WAAAC,EACA,UAAAC,CACF,EAAsC,CACpC,MAAMC,EAAUC,EAAAA,WAAA,EACVC,EAAWC,EAAAA,OAAuB,IAAI,EACtCC,EAAO,KAAK,IAAId,EAAQ,EAAG,CAAC,EAC5Be,EAASV,GACbS,IAAS,EAAI,EAAI,KAAK,IAAI,KAAK,IAAIT,EAAOS,EAAM,CAAC,EAAG,CAAC,EAEjDE,EAAiBC,GAA0B,CAC/C,MAAMC,EAAQN,EAAS,QACvB,GAAI,CAACM,EACH,OAEF,MAAMC,EAAOD,EAAM,sBAAA,EACbE,GAASH,EAAUE,EAAK,MAAQ,KAAK,IAAIA,EAAK,MAAO,CAAC,EAC5DjB,EAAc,KAAK,MAAM,KAAK,IAAI,KAAK,IAAIkB,EAAO,CAAC,EAAG,CAAC,EAAIN,CAAI,CAAC,CAClE,EAEMO,EAAiBC,GAA8C,CAC/DA,EAAM,SAAW,IAGrBA,EAAM,cAAc,kBAAkBA,EAAM,SAAS,EACrDf,IAAA,EACA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 'react';
|
|
2
|
+
import { ChartColor } from '../../lib/chart';
|
|
3
|
+
export interface ReplayScrubberMarker {
|
|
4
|
+
/** The step the marker sits over. */
|
|
5
|
+
index: number;
|
|
6
|
+
color: ChartColor;
|
|
7
|
+
/** Names the event, e.g. "T17 · 夺取 C4"; shown as the marker's tooltip. */
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ReplayScrubberProps {
|
|
11
|
+
/** How many steps the replay has. */
|
|
12
|
+
count: number;
|
|
13
|
+
index: number;
|
|
14
|
+
onIndexChange: (index: number) => void;
|
|
15
|
+
/** Events above the track, each a dot in its colour. */
|
|
16
|
+
markers?: ReplayScrubberMarker[];
|
|
17
|
+
/** The label of a step under the track, e.g. `T42`. Defaults to its number. */
|
|
18
|
+
formatStep?: (index: number) => ReactNode;
|
|
19
|
+
/** Names the slider; defaults to "Replay position". */
|
|
20
|
+
ariaLabel?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A pointer drag starts and ends: hold playback in between, e.g. with
|
|
23
|
+
* `useReplayPlayback`'s `hold` and `release`.
|
|
24
|
+
*/
|
|
25
|
+
onScrubStart?: () => void;
|
|
26
|
+
onScrubEnd?: () => void;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The replay's position: a track from the first step to the last with a
|
|
31
|
+
* thumb at the current one and event markers above it. Drag or click to
|
|
32
|
+
* seek; arrow keys step by one, Page Up / Down by a tenth, Home / End to
|
|
33
|
+
* the ends.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ReplayScrubber({ count, index, onIndexChange, markers, formatStep, ariaLabel, onScrubStart, onScrubEnd, className, }: ReplayScrubberProps): ReactElement;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsxs as u, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as v } from "react";
|
|
3
|
+
import { chartColorValue as B } from "../../lib/chart.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { useStrings as T } from "../../locale/useStrings.js";
|
|
6
|
+
const y = 0.08;
|
|
7
|
+
function H({
|
|
8
|
+
count: c,
|
|
9
|
+
index: a,
|
|
10
|
+
onIndexChange: p,
|
|
11
|
+
markers: m = [],
|
|
12
|
+
formatStep: b = (o) => o + 1,
|
|
13
|
+
ariaLabel: d,
|
|
14
|
+
onScrubStart: f,
|
|
15
|
+
onScrubEnd: M,
|
|
16
|
+
className: N
|
|
17
|
+
}) {
|
|
18
|
+
const o = T(), _ = v(null), e = Math.max(c - 1, 0), i = (r) => e === 0 ? 0 : Math.min(Math.max(r / e, 0), 1), g = (r) => {
|
|
19
|
+
const t = _.current;
|
|
20
|
+
if (!t)
|
|
21
|
+
return;
|
|
22
|
+
const n = t.getBoundingClientRect(), R = (r - n.left) / Math.max(n.width, 1);
|
|
23
|
+
p(Math.round(Math.min(Math.max(R, 0), 1) * e));
|
|
24
|
+
}, P = (r) => {
|
|
25
|
+
r.button === 0 && (r.currentTarget.setPointerCapture(r.pointerId), f?.(), g(r.clientX));
|
|
26
|
+
}, w = (r) => {
|
|
27
|
+
r.currentTarget.hasPointerCapture(r.pointerId) && g(r.clientX);
|
|
28
|
+
}, h = () => {
|
|
29
|
+
M?.();
|
|
30
|
+
}, j = (r) => {
|
|
31
|
+
const t = Math.max(Math.round(c / 10), 1), n = {
|
|
32
|
+
ArrowLeft: a - 1,
|
|
33
|
+
ArrowDown: a - 1,
|
|
34
|
+
ArrowRight: a + 1,
|
|
35
|
+
ArrowUp: a + 1,
|
|
36
|
+
PageDown: a - t,
|
|
37
|
+
PageUp: a + t,
|
|
38
|
+
Home: 0,
|
|
39
|
+
End: e
|
|
40
|
+
};
|
|
41
|
+
r.key in n && (r.preventDefault(), p(Math.min(Math.max(n[r.key], 0), e)));
|
|
42
|
+
}, k = { "--aegis-replay-scrubber-position": i(a) }, l = Math.max(c, 0), A = m.filter((r) => r.index === a).map((r) => r.label), C = [
|
|
43
|
+
o.replayStepOf(l === 0 ? 0 : a + 1, l),
|
|
44
|
+
...A
|
|
45
|
+
].join(" · "), D = a > 0 && i(a) < y, E = a < e && i(a) > 1 - y;
|
|
46
|
+
return /* @__PURE__ */ u(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: ["aegis-replay-scrubber", N ?? ""].filter(Boolean).join(" "),
|
|
50
|
+
style: k,
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ s("div", { className: "aegis-replay-scrubber__markers", "aria-hidden": "true", children: m.map((r, t) => /* @__PURE__ */ s(
|
|
53
|
+
"span",
|
|
54
|
+
{
|
|
55
|
+
className: "aegis-replay-scrubber__marker",
|
|
56
|
+
title: r.label,
|
|
57
|
+
style: {
|
|
58
|
+
left: `${(i(r.index) * 100).toString()}%`,
|
|
59
|
+
background: B(r.color)
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
t
|
|
63
|
+
)) }),
|
|
64
|
+
/* @__PURE__ */ u(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
ref: _,
|
|
68
|
+
className: "aegis-replay-scrubber__track",
|
|
69
|
+
role: "slider",
|
|
70
|
+
tabIndex: 0,
|
|
71
|
+
"aria-label": d ?? o.replayPosition,
|
|
72
|
+
"aria-valuemin": l === 0 ? 0 : 1,
|
|
73
|
+
"aria-valuemax": l,
|
|
74
|
+
"aria-valuenow": l === 0 ? 0 : a + 1,
|
|
75
|
+
"aria-valuetext": C,
|
|
76
|
+
onPointerDown: P,
|
|
77
|
+
onPointerMove: w,
|
|
78
|
+
onPointerUp: h,
|
|
79
|
+
onPointerCancel: h,
|
|
80
|
+
onKeyDown: j,
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ s("span", { className: "aegis-replay-scrubber__played" }),
|
|
83
|
+
/* @__PURE__ */ s("span", { className: "aegis-replay-scrubber__thumb" })
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ u("div", { className: "aegis-replay-scrubber__labels", "aria-hidden": "true", children: [
|
|
88
|
+
/* @__PURE__ */ s(
|
|
89
|
+
"span",
|
|
90
|
+
{
|
|
91
|
+
className: [
|
|
92
|
+
"aegis-replay-scrubber__end",
|
|
93
|
+
a === 0 ? "aegis-replay-scrubber__label--current" : "",
|
|
94
|
+
D ? "aegis-replay-scrubber__end--hidden" : ""
|
|
95
|
+
].filter(Boolean).join(" "),
|
|
96
|
+
children: l === 0 ? null : b(0)
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
a > 0 && a < e && /* @__PURE__ */ s("span", { className: "aegis-replay-scrubber__at aegis-replay-scrubber__label--current", children: b(a) }),
|
|
100
|
+
e > 0 && /* @__PURE__ */ s(
|
|
101
|
+
"span",
|
|
102
|
+
{
|
|
103
|
+
className: [
|
|
104
|
+
"aegis-replay-scrubber__end aegis-replay-scrubber__end--last",
|
|
105
|
+
a === e ? "aegis-replay-scrubber__label--current" : "",
|
|
106
|
+
E ? "aegis-replay-scrubber__end--hidden" : ""
|
|
107
|
+
].filter(Boolean).join(" "),
|
|
108
|
+
children: b(e)
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
] })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
H as ReplayScrubber
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=ReplayScrubber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplayScrubber.js","sources":["../../../src/components/ui/ReplayScrubber.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type PointerEvent,\n type ReactElement,\n type ReactNode,\n useRef,\n} from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './ReplayScrubber.css';\n\nexport interface ReplayScrubberMarker {\n /** The step the marker sits over. */\n index: number;\n color: ChartColor;\n /** Names the event, e.g. \"T17 · 夺取 C4\"; shown as the marker's tooltip. */\n label: string;\n}\n\nexport interface ReplayScrubberProps {\n /** How many steps the replay has. */\n count: number;\n index: number;\n onIndexChange: (index: number) => void;\n /** Events above the track, each a dot in its colour. */\n markers?: ReplayScrubberMarker[];\n /** The label of a step under the track, e.g. `T42`. Defaults to its number. */\n formatStep?: (index: number) => ReactNode;\n /** Names the slider; defaults to \"Replay position\". */\n ariaLabel?: string;\n /**\n * A pointer drag starts and ends: hold playback in between, e.g. with\n * `useReplayPlayback`'s `hold` and `release`.\n */\n onScrubStart?: () => void;\n onScrubEnd?: () => void;\n className?: string;\n}\n\n/** A label within this share of the track from an end hides that end's label. */\nconst END_CLEARANCE = 0.08;\n\n/**\n * The replay's position: a track from the first step to the last with a\n * thumb at the current one and event markers above it. Drag or click to\n * seek; arrow keys step by one, Page Up / Down by a tenth, Home / End to\n * the ends.\n */\nexport function ReplayScrubber({\n count,\n index,\n onIndexChange,\n markers = [],\n formatStep = (step) => step + 1,\n ariaLabel,\n onScrubStart,\n onScrubEnd,\n className,\n}: ReplayScrubberProps): ReactElement {\n const strings = useStrings();\n const trackRef = useRef<HTMLDivElement>(null);\n const last = Math.max(count - 1, 0);\n const share = (step: number): number =>\n last === 0 ? 0 : Math.min(Math.max(step / last, 0), 1);\n\n const seekToPointer = (clientX: number): void => {\n const track = trackRef.current;\n if (!track) {\n return;\n }\n const rect = track.getBoundingClientRect();\n const ratio = (clientX - rect.left) / Math.max(rect.width, 1);\n onIndexChange(Math.round(Math.min(Math.max(ratio, 0), 1) * last));\n };\n\n const onPointerDown = (event: PointerEvent<HTMLDivElement>): void => {\n if (event.button !== 0) {\n return;\n }\n event.currentTarget.setPointerCapture(event.pointerId);\n onScrubStart?.();\n seekToPointer(event.clientX);\n };\n const onPointerMove = (event: PointerEvent<HTMLDivElement>): void => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n seekToPointer(event.clientX);\n }\n };\n const onPointerEnd = (): void => {\n onScrubEnd?.();\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n const page = Math.max(Math.round(count / 10), 1);\n const target: Record<string, number> = {\n ArrowLeft: index - 1,\n ArrowDown: index - 1,\n ArrowRight: index + 1,\n ArrowUp: index + 1,\n PageDown: index - page,\n PageUp: index + page,\n Home: 0,\n End: last,\n };\n if (event.key in target) {\n event.preventDefault();\n onIndexChange(Math.min(Math.max(target[event.key], 0), last));\n }\n };\n\n const position = { '--aegis-replay-scrubber-position': share(index) };\n const total = Math.max(count, 0);\n const here = markers\n .filter((marker) => marker.index === index)\n .map((marker) => marker.label);\n const valueText = [\n strings.replayStepOf(total === 0 ? 0 : index + 1, total),\n ...here,\n ].join(' · ');\n const nearStart = index > 0 && share(index) < END_CLEARANCE;\n const nearEnd = index < last && share(index) > 1 - END_CLEARANCE;\n return (\n <div\n className={['aegis-replay-scrubber', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={position as CSSProperties}\n >\n <div className=\"aegis-replay-scrubber__markers\" aria-hidden=\"true\">\n {markers.map((marker, position) => (\n <span\n key={position}\n className=\"aegis-replay-scrubber__marker\"\n title={marker.label}\n style={\n {\n left: `${(share(marker.index) * 100).toString()}%`,\n background: chartColorValue(marker.color),\n } as CSSProperties\n }\n />\n ))}\n </div>\n <div\n ref={trackRef}\n className=\"aegis-replay-scrubber__track\"\n role=\"slider\"\n tabIndex={0}\n aria-label={ariaLabel ?? strings.replayPosition}\n aria-valuemin={total === 0 ? 0 : 1}\n aria-valuemax={total}\n aria-valuenow={total === 0 ? 0 : index + 1}\n aria-valuetext={valueText}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerEnd}\n onPointerCancel={onPointerEnd}\n onKeyDown={onKeyDown}\n >\n <span className=\"aegis-replay-scrubber__played\" />\n <span className=\"aegis-replay-scrubber__thumb\" />\n </div>\n <div className=\"aegis-replay-scrubber__labels\" aria-hidden=\"true\">\n <span\n className={[\n 'aegis-replay-scrubber__end',\n index === 0 ? 'aegis-replay-scrubber__label--current' : '',\n nearStart ? 'aegis-replay-scrubber__end--hidden' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {total === 0 ? null : formatStep(0)}\n </span>\n {index > 0 && index < last && (\n <span className=\"aegis-replay-scrubber__at aegis-replay-scrubber__label--current\">\n {formatStep(index)}\n </span>\n )}\n {last > 0 && (\n <span\n className={[\n 'aegis-replay-scrubber__end aegis-replay-scrubber__end--last',\n index === last ? 'aegis-replay-scrubber__label--current' : '',\n nearEnd ? 'aegis-replay-scrubber__end--hidden' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {formatStep(last)}\n </span>\n )}\n </div>\n </div>\n );\n}\n"],"names":["END_CLEARANCE","ReplayScrubber","count","index","onIndexChange","markers","formatStep","step","ariaLabel","onScrubStart","onScrubEnd","className","strings","useStrings","trackRef","useRef","last","share","seekToPointer","clientX","track","rect","ratio","onPointerDown","event","onPointerMove","onPointerEnd","onKeyDown","page","target","position","total","here","marker","valueText","nearStart","nearEnd","jsxs","jsx","chartColorValue"],"mappings":";;;;;AA0CA,MAAMA,IAAgB;AAQf,SAASC,EAAe;AAAA,EAC7B,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,eAAAC;AAAA,EACA,SAAAC,IAAU,CAAA;AAAA,EACV,YAAAC,IAAa,CAACC,MAASA,IAAO;AAAA,EAC9B,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AACF,GAAsC;AACpC,QAAMC,IAAUC,EAAA,GACVC,IAAWC,EAAuB,IAAI,GACtCC,IAAO,KAAK,IAAId,IAAQ,GAAG,CAAC,GAC5Be,IAAQ,CAACV,MACbS,MAAS,IAAI,IAAI,KAAK,IAAI,KAAK,IAAIT,IAAOS,GAAM,CAAC,GAAG,CAAC,GAEjDE,IAAgB,CAACC,MAA0B;AAC/C,UAAMC,IAAQN,EAAS;AACvB,QAAI,CAACM;AACH;AAEF,UAAMC,IAAOD,EAAM,sBAAA,GACbE,KAASH,IAAUE,EAAK,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D,EAAC,OAAA,EAAI,WAAU,iCAAgC,eAAY,QACzD,UAAA;AAAA,UAAA,gBAAAC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACAnC,MAAU,IAAI,0CAA0C;AAAA,gBACxDgC,IAAY,uCAAuC;AAAA,cAAA,EAElD,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,cAEV,UAAAJ,MAAU,IAAI,OAAOzB,EAAW,CAAC;AAAA,YAAA;AAAA,UAAA;AAAA,UAEnCH,IAAQ,KAAKA,IAAQa,KACpB,gBAAAsB,EAAC,UAAK,WAAU,mEACb,UAAAhC,EAAWH,CAAK,EAAA,CACnB;AAAA,UAEDa,IAAO,KACN,gBAAAsB;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACAnC,MAAUa,IAAO,0CAA0C;AAAA,gBAC3DoB,IAAU,uCAAuC;AAAA,cAAA,EAEhD,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,cAEV,YAAWpB,CAAI;AAAA,YAAA;AAAA,UAAA;AAAA,QAClB,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),b=require("react"),w=require("../../lib/chart.cjs");;/* empty css */const q=require("../../locale/useStrings.cjs");function R(n,s){const a=n-1,p=new Set(n>0?[0,a]:[]);for(let o=s-1;o<a;o+=s)a-o>=s/2&&p.add(o);return p}function x({steps:n,currentIndex:s,onSelect:a,keyMoments:p=[],formatStep:o=c=>`#${String(c+1)}`,tickEvery:k,className:d}){const c=q.useStrings(),y=b.useRef(null),r=n.length,j=k??Math.max(1,Math.ceil(r/20)*5),S=R(r,j),g=new Map(p.map((t,e)=>[t,e+1])),[M,_]=b.useState(0),m=Math.min(s??M,Math.max(r-1,0)),N=t=>{if(!a||r===0)return;const e={ArrowLeft:m-1,ArrowRight:m+1,Home:0,End:r-1};if(!(t.key in e))return;t.preventDefault();const i=Math.min(Math.max(e[t.key],0),r-1);_(i),a(i),y.current?.querySelectorAll(".aegis-replay-step-strip__step").item(i).focus()},v={"--aegis-replay-step-strip-count":Math.max(r,1)};return l.jsxs("div",{className:["aegis-replay-step-strip",d??""].filter(Boolean).join(" "),style:v,children:[l.jsx("div",{className:"aegis-replay-step-strip__moments","aria-hidden":"true",children:n.map((t,e)=>{const i=g.get(e);return i===void 0?l.jsx("span",{},t.key):l.jsx("span",{className:["aegis-replay-step-strip__moment",e===s?"aegis-replay-step-strip__moment--current":""].filter(Boolean).join(" "),children:i},t.key)})}),l.jsx("div",{ref:y,className:"aegis-replay-step-strip__bars",role:a?"toolbar":"list","aria-label":c.replaySteps,onKeyDown:N,children:n.map((t,e)=>{const i=g.get(e),u=i===void 0?t.label:`${t.label} · ${c.replayKeyMoment(i)}`,h={"--aegis-replay-step-strip-color":w.chartColorValue(t.color)},f=["aegis-replay-step-strip__step",t.emphasis?"aegis-replay-step-strip__step--emphasis":"",e===s?"aegis-replay-step-strip__step--current":""].filter(Boolean).join(" ");return a?l.jsx("button",{type:"button",className:f,style:h,title:u,"aria-label":u,"aria-current":e===s?"step":void 0,tabIndex:e===m?0:-1,onClick:()=>{_(e),a(e)}},t.key):l.jsx("span",{role:"listitem",className:f,style:h,title:u,"aria-label":u,"aria-current":e===s?"step":void 0},t.key)})}),l.jsx("div",{className:"aegis-replay-step-strip__ticks","aria-hidden":"true",children:n.map((t,e)=>l.jsx("span",{className:e===r-1&&r>1?"aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last":"aegis-replay-step-strip__tick",children:S.has(e)?o(e):null},t.key))})]})}exports.ReplayStepStrip=x;
|
|
2
|
+
//# sourceMappingURL=ReplayStepStrip.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplayStepStrip.cjs","sources":["../../../src/components/ui/ReplayStepStrip.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n useRef,\n useState,\n} from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './ReplayStepStrip.css';\n\nexport interface ReplayStepStripItem {\n key: string;\n /** The step kind's colour, e.g. thinking, tool call, failure. */\n color: ChartColor;\n /** Names the step for screen readers and its tooltip, e.g. \"#12 · 验证\". */\n label: string;\n /** A step that changes the course (a check, a failure, the goal): taller. */\n emphasis?: boolean;\n}\n\nexport interface ReplayStepStripProps {\n steps: ReplayStepStripItem[];\n /** The step shown elsewhere on the page; outlined. */\n currentIndex?: number;\n /** Makes each step a button that selects it. */\n onSelect?: (index: number) => void;\n /** Step indices of the key moments, numbered above the strip in order. */\n keyMoments?: number[];\n /** The tick label of a step under the strip. Defaults to `#n`. */\n formatStep?: (index: number) => ReactNode;\n /** A tick every this many steps; defaults to about five ticks. */\n tickEvery?: number;\n className?: string;\n}\n\n/**\n * The steps that get a tick: the first, the last, and every `every`\n * steps between, leaving out one that would crowd the last.\n */\nfunction tickedSteps(count: number, every: number): Set<number> {\n const last = count - 1;\n const ticks = new Set<number>(count > 0 ? [0, last] : []);\n for (let index = every - 1; index < last; index += every) {\n if (last - index >= every / 2) {\n ticks.add(index);\n }\n }\n return ticks;\n}\n\n/**\n * Every step of a run as a bar coloured by its kind, with the key\n * moments numbered above it and step ticks below. With `onSelect`, a bar\n * selects its step; arrow keys move between steps with one tab stop.\n * The gap between bars narrows as steps are added, so a long run still\n * draws every step.\n */\nexport function ReplayStepStrip({\n steps,\n currentIndex,\n onSelect,\n keyMoments = [],\n formatStep = (index) => `#${String(index + 1)}`,\n tickEvery,\n className,\n}: ReplayStepStripProps): ReactElement {\n const strings = useStrings();\n const barsRef = useRef<HTMLDivElement>(null);\n const count = steps.length;\n const every = tickEvery ?? Math.max(1, Math.ceil(count / 20) * 5);\n const ticks = tickedSteps(count, every);\n const momentNumber = new Map(keyMoments.map((step, n) => [step, n + 1]));\n\n // The roving tab stop follows the current step, or the last step the\n // keyboard reached when the host does not mark one.\n const [ownFocus, setOwnFocus] = useState(0);\n const focusIndex = Math.min(currentIndex ?? ownFocus, Math.max(count - 1, 0));\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (!onSelect || count === 0) {\n return;\n }\n const target: Record<string, number> = {\n ArrowLeft: focusIndex - 1,\n ArrowRight: focusIndex + 1,\n Home: 0,\n End: count - 1,\n };\n if (!(event.key in target)) {\n return;\n }\n event.preventDefault();\n const next = Math.min(Math.max(target[event.key], 0), count - 1);\n setOwnFocus(next);\n onSelect(next);\n barsRef.current\n ?.querySelectorAll<HTMLButtonElement>('.aegis-replay-step-strip__step')\n .item(next)\n .focus();\n };\n\n const style = {\n '--aegis-replay-step-strip-count': Math.max(count, 1),\n } as CSSProperties;\n return (\n <div\n className={['aegis-replay-step-strip', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n <div className=\"aegis-replay-step-strip__moments\" aria-hidden=\"true\">\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n return n === undefined ? (\n <span key={step.key} />\n ) : (\n <span\n key={step.key}\n className={[\n 'aegis-replay-step-strip__moment',\n index === currentIndex\n ? 'aegis-replay-step-strip__moment--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {n}\n </span>\n );\n })}\n </div>\n <div\n ref={barsRef}\n className=\"aegis-replay-step-strip__bars\"\n role={onSelect ? 'toolbar' : 'list'}\n aria-label={strings.replaySteps}\n onKeyDown={onKeyDown}\n >\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n const label =\n n === undefined\n ? step.label\n : `${step.label} · ${strings.replayKeyMoment(n)}`;\n const barStyle = {\n '--aegis-replay-step-strip-color': chartColorValue(step.color),\n } as CSSProperties;\n const cls = [\n 'aegis-replay-step-strip__step',\n step.emphasis ? 'aegis-replay-step-strip__step--emphasis' : '',\n index === currentIndex\n ? 'aegis-replay-step-strip__step--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n return onSelect ? (\n <button\n key={step.key}\n type=\"button\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n tabIndex={index === focusIndex ? 0 : -1}\n onClick={() => {\n setOwnFocus(index);\n onSelect(index);\n }}\n />\n ) : (\n <span\n key={step.key}\n role=\"listitem\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n />\n );\n })}\n </div>\n <div className=\"aegis-replay-step-strip__ticks\" aria-hidden=\"true\">\n {steps.map((step, index) => (\n <span\n key={step.key}\n className={\n index === count - 1 && count > 1\n ? 'aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last'\n : 'aegis-replay-step-strip__tick'\n }\n >\n {ticks.has(index) ? formatStep(index) : null}\n </span>\n ))}\n </div>\n </div>\n );\n}\n"],"names":["tickedSteps","count","every","last","ticks","index","ReplayStepStrip","steps","currentIndex","onSelect","keyMoments","formatStep","tickEvery","className","strings","useStrings","barsRef","useRef","momentNumber","step","n","ownFocus","setOwnFocus","useState","focusIndex","onKeyDown","event","target","next","style","jsxs","jsx","label","barStyle","chartColorValue","cls"],"mappings":"6PA0CA,SAASA,EAAYC,EAAeC,EAA4B,CAC9D,MAAMC,EAAOF,EAAQ,EACfG,EAAQ,IAAI,IAAYH,EAAQ,EAAI,CAAC,EAAGE,CAAI,EAAI,EAAE,EACxD,QAASE,EAAQH,EAAQ,EAAGG,EAAQF,EAAME,GAASH,EAC7CC,EAAOE,GAASH,EAAQ,GAC1BE,EAAM,IAAIC,CAAK,EAGnB,OAAOD,CACT,CASO,SAASE,EAAgB,CAC9B,MAAAC,EACA,aAAAC,EACA,SAAAC,EACA,WAAAC,EAAa,CAAA,EACb,WAAAC,EAAcN,GAAU,IAAI,OAAOA,EAAQ,CAAC,CAAC,GAC7C,UAAAO,EACA,UAAAC,CACF,EAAuC,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,IAAUJ,EAAQ,GAAKA,EAAQ,EAC3B,oEACA,gCAGL,WAAM,IAAII,CAAK,EAAIM,EAAWN,CAAK,EAAI,IAAA,EAPnCc,EAAK,GAAA,CASb,CAAA,CACH,CAAA,CAAA,CAAA,CAGN"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ChartColor } from '../../lib/chart';
|
|
3
|
+
export interface ReplayStepStripItem {
|
|
4
|
+
key: string;
|
|
5
|
+
/** The step kind's colour, e.g. thinking, tool call, failure. */
|
|
6
|
+
color: ChartColor;
|
|
7
|
+
/** Names the step for screen readers and its tooltip, e.g. "#12 · 验证". */
|
|
8
|
+
label: string;
|
|
9
|
+
/** A step that changes the course (a check, a failure, the goal): taller. */
|
|
10
|
+
emphasis?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ReplayStepStripProps {
|
|
13
|
+
steps: ReplayStepStripItem[];
|
|
14
|
+
/** The step shown elsewhere on the page; outlined. */
|
|
15
|
+
currentIndex?: number;
|
|
16
|
+
/** Makes each step a button that selects it. */
|
|
17
|
+
onSelect?: (index: number) => void;
|
|
18
|
+
/** Step indices of the key moments, numbered above the strip in order. */
|
|
19
|
+
keyMoments?: number[];
|
|
20
|
+
/** The tick label of a step under the strip. Defaults to `#n`. */
|
|
21
|
+
formatStep?: (index: number) => ReactNode;
|
|
22
|
+
/** A tick every this many steps; defaults to about five ticks. */
|
|
23
|
+
tickEvery?: number;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every step of a run as a bar coloured by its kind, with the key
|
|
28
|
+
* moments numbered above it and step ticks below. With `onSelect`, a bar
|
|
29
|
+
* selects its step; arrow keys move between steps with one tab stop.
|
|
30
|
+
* The gap between bars narrows as steps are added, so a long run still
|
|
31
|
+
* draws every step.
|
|
32
|
+
*/
|
|
33
|
+
export declare function ReplayStepStrip({ steps, currentIndex, onSelect, keyMoments, formatStep, tickEvery, className, }: ReplayStepStripProps): ReactElement;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsxs as S, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as j, useState as R } from "react";
|
|
3
|
+
import { chartColorValue as A } from "../../lib/chart.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { useStrings as B } from "../../locale/useStrings.js";
|
|
6
|
+
function $(o, s) {
|
|
7
|
+
const a = o - 1, n = new Set(o > 0 ? [0, a] : []);
|
|
8
|
+
for (let p = s - 1; p < a; p += s)
|
|
9
|
+
a - p >= s / 2 && n.add(p);
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
function E({
|
|
13
|
+
steps: o,
|
|
14
|
+
currentIndex: s,
|
|
15
|
+
onSelect: a,
|
|
16
|
+
keyMoments: n = [],
|
|
17
|
+
formatStep: p = (c) => `#${String(c + 1)}`,
|
|
18
|
+
tickEvery: k,
|
|
19
|
+
className: b
|
|
20
|
+
}) {
|
|
21
|
+
const c = B(), u = j(null), r = o.length, d = k ?? Math.max(1, Math.ceil(r / 20) * 5), M = $(r, d), _ = new Map(n.map((e, t) => [e, t + 1])), [N, g] = R(0), y = Math.min(s ?? N, Math.max(r - 1, 0)), w = (e) => {
|
|
22
|
+
if (!a || r === 0)
|
|
23
|
+
return;
|
|
24
|
+
const t = {
|
|
25
|
+
ArrowLeft: y - 1,
|
|
26
|
+
ArrowRight: y + 1,
|
|
27
|
+
Home: 0,
|
|
28
|
+
End: r - 1
|
|
29
|
+
};
|
|
30
|
+
if (!(e.key in t))
|
|
31
|
+
return;
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
const i = Math.min(Math.max(t[e.key], 0), r - 1);
|
|
34
|
+
g(i), a(i), u.current?.querySelectorAll(".aegis-replay-step-strip__step").item(i).focus();
|
|
35
|
+
}, v = {
|
|
36
|
+
"--aegis-replay-step-strip-count": Math.max(r, 1)
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ S(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
className: ["aegis-replay-step-strip", b ?? ""].filter(Boolean).join(" "),
|
|
42
|
+
style: v,
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ l("div", { className: "aegis-replay-step-strip__moments", "aria-hidden": "true", children: o.map((e, t) => {
|
|
45
|
+
const i = _.get(t);
|
|
46
|
+
return i === void 0 ? /* @__PURE__ */ l("span", {}, e.key) : /* @__PURE__ */ l(
|
|
47
|
+
"span",
|
|
48
|
+
{
|
|
49
|
+
className: [
|
|
50
|
+
"aegis-replay-step-strip__moment",
|
|
51
|
+
t === s ? "aegis-replay-step-strip__moment--current" : ""
|
|
52
|
+
].filter(Boolean).join(" "),
|
|
53
|
+
children: i
|
|
54
|
+
},
|
|
55
|
+
e.key
|
|
56
|
+
);
|
|
57
|
+
}) }),
|
|
58
|
+
/* @__PURE__ */ l(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
ref: u,
|
|
62
|
+
className: "aegis-replay-step-strip__bars",
|
|
63
|
+
role: a ? "toolbar" : "list",
|
|
64
|
+
"aria-label": c.replaySteps,
|
|
65
|
+
onKeyDown: w,
|
|
66
|
+
children: o.map((e, t) => {
|
|
67
|
+
const i = _.get(t), m = i === void 0 ? e.label : `${e.label} · ${c.replayKeyMoment(i)}`, h = {
|
|
68
|
+
"--aegis-replay-step-strip-color": A(e.color)
|
|
69
|
+
}, f = [
|
|
70
|
+
"aegis-replay-step-strip__step",
|
|
71
|
+
e.emphasis ? "aegis-replay-step-strip__step--emphasis" : "",
|
|
72
|
+
t === s ? "aegis-replay-step-strip__step--current" : ""
|
|
73
|
+
].filter(Boolean).join(" ");
|
|
74
|
+
return a ? /* @__PURE__ */ l(
|
|
75
|
+
"button",
|
|
76
|
+
{
|
|
77
|
+
type: "button",
|
|
78
|
+
className: f,
|
|
79
|
+
style: h,
|
|
80
|
+
title: m,
|
|
81
|
+
"aria-label": m,
|
|
82
|
+
"aria-current": t === s ? "step" : void 0,
|
|
83
|
+
tabIndex: t === y ? 0 : -1,
|
|
84
|
+
onClick: () => {
|
|
85
|
+
g(t), a(t);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
e.key
|
|
89
|
+
) : /* @__PURE__ */ l(
|
|
90
|
+
"span",
|
|
91
|
+
{
|
|
92
|
+
role: "listitem",
|
|
93
|
+
className: f,
|
|
94
|
+
style: h,
|
|
95
|
+
title: m,
|
|
96
|
+
"aria-label": m,
|
|
97
|
+
"aria-current": t === s ? "step" : void 0
|
|
98
|
+
},
|
|
99
|
+
e.key
|
|
100
|
+
);
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
/* @__PURE__ */ l("div", { className: "aegis-replay-step-strip__ticks", "aria-hidden": "true", children: o.map((e, t) => /* @__PURE__ */ l(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
className: t === r - 1 && r > 1 ? "aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last" : "aegis-replay-step-strip__tick",
|
|
108
|
+
children: M.has(t) ? p(t) : null
|
|
109
|
+
},
|
|
110
|
+
e.key
|
|
111
|
+
)) })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
E as ReplayStepStrip
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=ReplayStepStrip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplayStepStrip.js","sources":["../../../src/components/ui/ReplayStepStrip.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n useRef,\n useState,\n} from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './ReplayStepStrip.css';\n\nexport interface ReplayStepStripItem {\n key: string;\n /** The step kind's colour, e.g. thinking, tool call, failure. */\n color: ChartColor;\n /** Names the step for screen readers and its tooltip, e.g. \"#12 · 验证\". */\n label: string;\n /** A step that changes the course (a check, a failure, the goal): taller. */\n emphasis?: boolean;\n}\n\nexport interface ReplayStepStripProps {\n steps: ReplayStepStripItem[];\n /** The step shown elsewhere on the page; outlined. */\n currentIndex?: number;\n /** Makes each step a button that selects it. */\n onSelect?: (index: number) => void;\n /** Step indices of the key moments, numbered above the strip in order. */\n keyMoments?: number[];\n /** The tick label of a step under the strip. Defaults to `#n`. */\n formatStep?: (index: number) => ReactNode;\n /** A tick every this many steps; defaults to about five ticks. */\n tickEvery?: number;\n className?: string;\n}\n\n/**\n * The steps that get a tick: the first, the last, and every `every`\n * steps between, leaving out one that would crowd the last.\n */\nfunction tickedSteps(count: number, every: number): Set<number> {\n const last = count - 1;\n const ticks = new Set<number>(count > 0 ? [0, last] : []);\n for (let index = every - 1; index < last; index += every) {\n if (last - index >= every / 2) {\n ticks.add(index);\n }\n }\n return ticks;\n}\n\n/**\n * Every step of a run as a bar coloured by its kind, with the key\n * moments numbered above it and step ticks below. With `onSelect`, a bar\n * selects its step; arrow keys move between steps with one tab stop.\n * The gap between bars narrows as steps are added, so a long run still\n * draws every step.\n */\nexport function ReplayStepStrip({\n steps,\n currentIndex,\n onSelect,\n keyMoments = [],\n formatStep = (index) => `#${String(index + 1)}`,\n tickEvery,\n className,\n}: ReplayStepStripProps): ReactElement {\n const strings = useStrings();\n const barsRef = useRef<HTMLDivElement>(null);\n const count = steps.length;\n const every = tickEvery ?? Math.max(1, Math.ceil(count / 20) * 5);\n const ticks = tickedSteps(count, every);\n const momentNumber = new Map(keyMoments.map((step, n) => [step, n + 1]));\n\n // The roving tab stop follows the current step, or the last step the\n // keyboard reached when the host does not mark one.\n const [ownFocus, setOwnFocus] = useState(0);\n const focusIndex = Math.min(currentIndex ?? ownFocus, Math.max(count - 1, 0));\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (!onSelect || count === 0) {\n return;\n }\n const target: Record<string, number> = {\n ArrowLeft: focusIndex - 1,\n ArrowRight: focusIndex + 1,\n Home: 0,\n End: count - 1,\n };\n if (!(event.key in target)) {\n return;\n }\n event.preventDefault();\n const next = Math.min(Math.max(target[event.key], 0), count - 1);\n setOwnFocus(next);\n onSelect(next);\n barsRef.current\n ?.querySelectorAll<HTMLButtonElement>('.aegis-replay-step-strip__step')\n .item(next)\n .focus();\n };\n\n const style = {\n '--aegis-replay-step-strip-count': Math.max(count, 1),\n } as CSSProperties;\n return (\n <div\n className={['aegis-replay-step-strip', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n <div className=\"aegis-replay-step-strip__moments\" aria-hidden=\"true\">\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n return n === undefined ? (\n <span key={step.key} />\n ) : (\n <span\n key={step.key}\n className={[\n 'aegis-replay-step-strip__moment',\n index === currentIndex\n ? 'aegis-replay-step-strip__moment--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {n}\n </span>\n );\n })}\n </div>\n <div\n ref={barsRef}\n className=\"aegis-replay-step-strip__bars\"\n role={onSelect ? 'toolbar' : 'list'}\n aria-label={strings.replaySteps}\n onKeyDown={onKeyDown}\n >\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n const label =\n n === undefined\n ? step.label\n : `${step.label} · ${strings.replayKeyMoment(n)}`;\n const barStyle = {\n '--aegis-replay-step-strip-color': chartColorValue(step.color),\n } as CSSProperties;\n const cls = [\n 'aegis-replay-step-strip__step',\n step.emphasis ? 'aegis-replay-step-strip__step--emphasis' : '',\n index === currentIndex\n ? 'aegis-replay-step-strip__step--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n return onSelect ? (\n <button\n key={step.key}\n type=\"button\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n tabIndex={index === focusIndex ? 0 : -1}\n onClick={() => {\n setOwnFocus(index);\n onSelect(index);\n }}\n />\n ) : (\n <span\n key={step.key}\n role=\"listitem\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n />\n );\n })}\n </div>\n <div className=\"aegis-replay-step-strip__ticks\" aria-hidden=\"true\">\n {steps.map((step, index) => (\n <span\n key={step.key}\n className={\n index === count - 1 && count > 1\n ? 'aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last'\n : 'aegis-replay-step-strip__tick'\n }\n >\n {ticks.has(index) ? formatStep(index) : null}\n </span>\n ))}\n </div>\n </div>\n );\n}\n"],"names":["tickedSteps","count","every","last","ticks","index","ReplayStepStrip","steps","currentIndex","onSelect","keyMoments","formatStep","tickEvery","className","strings","useStrings","barsRef","useRef","momentNumber","step","n","ownFocus","setOwnFocus","useState","focusIndex","onKeyDown","event","target","next","style","jsxs","jsx","label","barStyle","chartColorValue","cls"],"mappings":";;;;;AA0CA,SAASA,EAAYC,GAAeC,GAA4B;AAC9D,QAAMC,IAAOF,IAAQ,GACfG,IAAQ,IAAI,IAAYH,IAAQ,IAAI,CAAC,GAAGE,CAAI,IAAI,EAAE;AACxD,WAASE,IAAQH,IAAQ,GAAGG,IAAQF,GAAME,KAASH;AACjD,IAAIC,IAAOE,KAASH,IAAQ,KAC1BE,EAAM,IAAIC,CAAK;AAGnB,SAAOD;AACT;AASO,SAASE,EAAgB;AAAA,EAC9B,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC,IAAa,CAAA;AAAA,EACb,YAAAC,IAAa,CAACN,MAAU,IAAI,OAAOA,IAAQ,CAAC,CAAC;AAAA,EAC7C,WAAAO;AAAA,EACA,WAAAC;AACF,GAAuC;AACrC,QAAMC,IAAUC,EAAA,GACVC,IAAUC,EAAuB,IAAI,GACrChB,IAAQM,EAAM,QACdL,IAAQU,KAAa,KAAK,IAAI,GAAG,KAAK,KAAKX,IAAQ,EAAE,IAAI,CAAC,GAC1DG,IAAQJ,EAAYC,GAAOC,CAAK,GAChCgB,IAAe,IAAI,IAA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AAUG,IAAe,SAAS;AAAA,gBAAA;AAAA,gBAN3CW,EAAK;AAAA,cAAA;AAAA,YAShB,CAAC;AAAA,UAAA;AAAA,QAAA;AAAA,QAEH,gBAAAY,EAAC,OAAA,EAAI,WAAU,kCAAiC,eAAY,QACzD,UAAAxB,EAAM,IAAI,CAACY,GAAMd,MAChB,gBAAA0B;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,WACE1B,MAAUJ,IAAQ,KAAKA,IAAQ,IAC3B,sEACA;AAAA,YAGL,YAAM,IAAII,CAAK,IAAIM,EAAWN,CAAK,IAAI;AAAA,UAAA;AAAA,UAPnCc,EAAK;AAAA,QAAA,CASb,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("@ant-design/icons");;/* empty css */const f=require("../../locale/useStrings.cjs");function S({playing:l,onPlayToggle:g,onPrevious:_,onNext:x,canPrevious:d=!0,canNext:u=!0,position:c,speed:i,speeds:e,onSpeedChange:s,extra:p,className:h}){const a=f.useStrings(),o=i!==void 0&&e!==void 0&&s!==void 0,j=t=>{if(!o)return;const y={ArrowLeft:-1,ArrowUp:-1,ArrowRight:1,ArrowDown:1}[t.key];if(y===void 0)return;t.preventDefault();const m=e.indexOf(i),b=e[(m+y+e.length)%e.length];s(b),t.currentTarget.parentElement?.querySelectorAll('[role="radio"]').item(e.indexOf(b)).focus()};return r.jsxs("div",{className:["aegis-replay-transport",h??""].filter(Boolean).join(" "),children:[r.jsxs("div",{className:"aegis-replay-transport__buttons",children:[r.jsx("button",{type:"button",className:"aegis-replay-transport__button","aria-label":a.replayPreviousStep,"aria-disabled":!d,onClick:d?_:void 0,children:r.jsx(n.StepBackwardOutlined,{"aria-hidden":!0})}),r.jsx("button",{type:"button",className:"aegis-replay-transport__button aegis-replay-transport__button--play","aria-label":l?a.replayPause:a.replayPlay,onClick:g,children:l?r.jsx(n.PauseOutlined,{"aria-hidden":!0}):r.jsx(n.CaretRightOutlined,{"aria-hidden":!0})}),r.jsx("button",{type:"button",className:"aegis-replay-transport__button","aria-label":a.replayNextStep,"aria-disabled":!u,onClick:u?x:void 0,children:r.jsx(n.StepForwardOutlined,{"aria-hidden":!0})}),c!==void 0&&r.jsx("span",{className:"aegis-replay-transport__position",children:c})]}),(o||p!==void 0)&&r.jsxs("div",{className:"aegis-replay-transport__end",children:[o&&r.jsx("div",{className:"aegis-replay-transport__speeds",role:"radiogroup","aria-label":a.replaySpeed,children:e.map(t=>r.jsx("button",{type:"button",role:"radio","aria-checked":t===i,tabIndex:t===i?0:-1,onKeyDown:j,className:"aegis-replay-transport__speed",onClick:()=>{s(t)},children:`${String(t)}×`},t))}),p]})]})}exports.ReplayTransport=S;
|
|
2
|
+
//# sourceMappingURL=ReplayTransport.cjs.map
|