@seanyeh77/ui 0.43.0 → 0.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/bundle.js +19 -19
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/components/DataTable/DataTable.js +5 -3
  4. package/dist/components/DataTable/DataTable.js.map +1 -1
  5. package/dist/components/DataTable/parts.js +4 -4
  6. package/dist/components/DataTable/parts.js.map +1 -1
  7. package/dist/components/LayerGraph/LayerGraph.js +12 -8
  8. package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
  9. package/dist/components/LineChart/LineChart.js +1 -1
  10. package/dist/components/LineChart/LineChart.js.map +1 -1
  11. package/dist/components/Markdown/Markdown.js +4 -4
  12. package/dist/components/Markdown/Markdown.js.map +1 -1
  13. package/dist/components/Section/Section.js +1 -1
  14. package/dist/components/Section/Section.js.map +1 -1
  15. package/dist/components/SegmentedControl/SegmentedControl.js +4 -4
  16. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  17. package/dist/components/SplitPane/SplitPane.js +6 -6
  18. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  19. package/dist/components/Tabs/Tabs.js +5 -5
  20. package/dist/components/Tabs/Tabs.js.map +1 -1
  21. package/dist/components/Tour/Tour.js +3 -3
  22. package/dist/components/Tour/Tour.js.map +1 -1
  23. package/dist/components/Workbench/Workbench.js +7 -7
  24. package/dist/components/Workbench/Workbench.js.map +1 -1
  25. package/dist/internal/scrollHint.js +5 -5
  26. package/dist/internal/scrollHint.js.map +1 -1
  27. package/dist/internal/tableTools.js +1 -1
  28. package/dist/internal/tableTools.js.map +1 -1
  29. package/dist/internal/util.js +5 -1
  30. package/dist/internal/util.js.map +1 -1
  31. package/package.json +4 -2
@@ -148,7 +148,7 @@ function LineChart({ series, labels, label, unit, decimals, max, min = 0, labelE
148
148
  if (e.button !== 0) return;
149
149
  dragging.current = true;
150
150
  try {
151
- e.currentTarget.setPointerCapture(e.pointerId);
151
+ e.currentTarget.setPointerCapture?.(e.pointerId);
152
152
  } catch {}
153
153
  move(at(e));
154
154
  } : void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.js","names":[],"sources":["../../../src/components/LineChart/LineChart.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChartTip, TICKS, chartKey, tickDecimals, niceMax, seriesColor, smoothPath, type Point } from '../../internal/chart';\nimport { cx, digits } from '../../internal/util';\nimport { format } from '../../format';\nimport { tr } from '../../i18n';\nimport { announce } from '../../announce';\nimport { StatusBand, StatusLegend, type StatusBandProps } from '../StatusBand/StatusBand';\n\nexport interface LineSeries {\n name: string;\n /** One value per label; null where there is none (a forecast ahead of the measurements, a gap). */\n values: (number | null)[];\n /** A dashed line, e.g. a forecast or a baseline; the legend shows it dashed too. */\n dashed?: boolean;\n /** Which chart color (chart-1 to chart-4) instead of the series' place, e.g. 3 for a forecast, 4 for a baseline. */\n color?: 1 | 2 | 3 | 4;\n}\n\nexport interface LineBand {\n /** The two series (indexes in series) the band fills between, e.g. [0, 1] for actual and forecast. */\n between: [number, number];\n /** `diverge`: orange where the first is above the second, blue where below (diverge-pos / diverge-neg, 30%).\n * `success`: success at 28%, for what was saved between actual use and a baseline. */\n tone: 'diverge' | 'success';\n /** Its entry in the legend, e.g. 「實際偏高/偏低」 or 「省下的電」. */\n label: string;\n}\n\nexport interface LineThreshold {\n value: number;\n /** Written on the line at the right, e.g. 「上限 29 °C」. */\n label: string;\n /** `warning` for a level to watch, `danger` for a limit. */\n tone: 'warning' | 'danger';\n}\n\nexport interface LineChartProps {\n /** Up to 4 series (chart-1 to chart-4); a legend with each name appears for 2 or more. */\n series: LineSeries[];\n /** One label per point on the x axis. */\n labels: string[];\n /** Describes the chart for screen readers. */\n label: string;\n /** After each value in the tooltip. */\n unit?: string;\n /** Decimals of the values in the tooltip. Default 0. */\n decimals?: number;\n /** Top of the y axis. Default: a round number above the largest value. */\n max?: number;\n /** Bottom of the y axis. Default 0; set it for values far from 0, such as temperatures. */\n min?: number;\n /** Show every nth x label when they would crowd. */\n labelEvery?: number;\n /** Fills between two series: the one exception to lines without fills (actual and forecast, use and baseline). */\n band?: LineBand;\n /** The point that is now: a 「現在」 line, and the part after it striped as forecast. */\n now?: number;\n /** Horizontal dashed lines for levels, e.g. a warning level and a limit. */\n thresholds?: LineThreshold[];\n /** One forecast point ahead, e.g. the next round: a hollow circle with its label. Its color is the series'. */\n marker?: { at: number; value: number; label: string; series?: number };\n /** A playhead at this point, for replaying: an accent line with a round handle on the x axis. Dragging (mouse,\n * touch) or ← → Home End on the chart move it. */\n playhead?: number;\n onPlayheadChange?: (at: number) => void;\n /** A large figure above the chart, e.g. 「省 186 kWh(約 12%)」. */\n headline?: React.ReactNode;\n /** Shown in place of the lines when no series has a value. Default 「這段時間沒有資料」. */\n empty?: string;\n /** Height of the plot in px, axes included (x labels, the status band and the legend come on top). Default 240.\n * Text in the chart stays at its own size however wide the chart is. */\n height?: number;\n /** A status band under the x axis, aligned with the points (StatusBand without its own spacing). */\n status?: Omit<StatusBandProps, 'count' | 'times' | 'legend' | 'className'>;\n className?: string;\n}\n\n/** Plot geometry in px: y labels left of L, the 現在 label above T, the playhead handle below B. */\nconst L = 40;\nconst T = 10;\nconst BELOW = 30;\n\n/** Runs of consecutive points that have values. */\nfunction runs(values: (number | null)[], X: (i: number) => number, Y: (v: number) => number): Point[][] {\n const out: Point[][] = [];\n let cur: Point[] = [];\n values.forEach((v, i) => {\n if (v == null || Number.isNaN(v)) {\n if (cur.length) out.push(cur);\n cur = [];\n } else cur.push([X(i), Y(v)]);\n });\n if (cur.length) out.push(cur);\n return out;\n}\n\n/** A trend over time: smooth lines, 5 grid lines, a guide and tooltip on hover. For monitoring it can also compare a\n * forecast with what happened (band, now, thresholds, marker) and replay with a playhead. */\nconst colorOf = (s: LineSeries | undefined, i: number) => (s?.color ? seriesColor(s.color - 1) : seriesColor(i));\n\nexport function LineChart({\n series,\n labels,\n label,\n unit,\n decimals,\n max,\n min = 0,\n labelEvery = 1,\n band,\n now,\n thresholds,\n marker,\n playhead,\n onPlayheadChange,\n headline,\n status,\n empty,\n height = 240,\n className,\n}: LineChartProps) {\n const [hi, setHi] = React.useState(-1);\n const plot = React.useRef<HTMLDivElement>(null);\n const [W, setW] = React.useState(640);\n React.useLayoutEffect(() => {\n const el = plot.current;\n if (!el) return;\n const fit = () => {\n if (el.clientWidth > 0) setW(el.clientWidth);\n };\n fit();\n if (typeof ResizeObserver !== 'function') return;\n const ro = new ResizeObserver(fit);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const R = W - 10;\n const B = height - BELOW;\n const stripes = 'ui-stripes-' + React.useId().replace(/:/g, '');\n const dragging = React.useRef(false);\n const all = series.flatMap((s) => s.values.filter((v): v is number => v != null));\n const top = max ?? niceMax(Math.max(min + 1, ...all, ...(thresholds ?? []).map((t) => t.value)) - min) + min;\n const n = labels.length || series[0]?.values.length || 0;\n const step = (R - L) / Math.max(1, n - 1);\n const X = (i: number) => L + i * step;\n const Y = (v: number) => B - ((v - min) / (top - min)) * (B - T);\n const ticks = TICKS.map((f) => min + f * (top - min));\n const suffix = unit ? ' ' + unit : '';\n const num = (v: number | null | undefined) => (v == null ? '—' : format.number(v, decimals) + suffix);\n const replay = playhead != null && !!onPlayheadChange;\n const show = (j: number) => {\n setHi(j);\n announce(\n labels[j] +\n tr(':') +\n series\n .filter((s) => s.values[j] != null)\n .map((s) => (series.length > 1 ? s.name + ' ' : '') + num(s.values[j]))\n .join(tr(',')),\n );\n };\n const move = (j: number) => {\n if (replay) onPlayheadChange(j);\n show(j);\n };\n const at = (e: React.PointerEvent<HTMLElement>) => {\n const r = e.currentTarget.getBoundingClientRect();\n const x = ((e.clientX - r.left) / r.width) * W;\n return Math.max(0, Math.min(n - 1, Math.round((x - L) / step)));\n };\n const edge = { left: ((L - step / 2) / W) * 100 + '%', right: ((W - R - step / 2) / W) * 100 + '%' };\n const legend = series.length > 1 || band;\n // Fewer x labels when they would touch: Geist Mono 12 px is about 7.5 px a character, 12 px between labels.\n const widest = Math.max(0, ...labels.map((lb) => lb.length)) * 7.5 + 12;\n const every = Math.max(labelEvery, Math.ceil((n * widest) / Math.max(1, R - L) / labelEvery) * labelEvery);\n // The marker's label goes left of the point when it would run past the right edge (CJK about 14 px a character).\n const markerLeft = marker ? X(marker.at) + 10 + [...marker.label].reduce((w, c) => w + (c.charCodeAt(0) > 0x2e80 ? 14 : 8), 0) > W : false;\n // Band: one quadrilateral per step where both series have values, colored by which one is higher.\n const bandShapes: { d: string; up: boolean }[] = [];\n if (band) {\n const a = series[band.between[0]]?.values ?? [];\n const b = series[band.between[1]]?.values ?? [];\n for (let i = 0; i < n - 1; i++) {\n const a0 = a[i],\n a1 = a[i + 1],\n b0 = b[i],\n b1 = b[i + 1];\n if (a0 == null || a1 == null || b0 == null || b1 == null) continue;\n bandShapes.push({\n d: `M${X(i)},${Y(a0)} L${X(i + 1)},${Y(a1)} L${X(i + 1)},${Y(b1)} L${X(i)},${Y(b0)} Z`,\n up: a0 + a1 >= b0 + b1,\n });\n }\n }\n const tipRows = (j: number) => {\n const rows = series\n .map((s, i) => ({ color: colorOf(series[i], i), name: s.name, value: s.values[j] }))\n .filter((r) => r.value != null)\n .map((r) => ({ ...r, value: num(r.value) }));\n if (band) {\n const a = series[band.between[0]]?.values[j];\n const b = series[band.between[1]]?.values[j];\n if (a != null && b != null) rows.push({ color: '', name: tr('差'), value: (a - b > 0 ? '+' : '') + num(a - b) });\n }\n return rows;\n };\n const shown = hi >= 0 ? hi : -1;\n return (\n <div className={cx('ui-chart', className)}>\n {headline ? <div className=\"ui-chart-headline\">{headline}</div> : null}\n {legend ? (\n <div className=\"ui-chart-legend\">\n {series.map((s, i) => (\n <span key={i}>\n <span\n className={cx('ui-chart-swatch', s.dashed && 'is-dashed')}\n style={{ background: s.dashed ? undefined : colorOf(series[i], i), color: colorOf(series[i], i) }}\n />\n {s.name}\n </span>\n ))}\n {band ? (\n <span>\n <span className={cx('ui-chart-swatch', 'is-band', 'is-' + band.tone)} />\n {band.label}\n </span>\n ) : null}\n </div>\n ) : null}\n <div\n ref={plot}\n className={cx('ui-chart-plot', replay && 'is-replay')}\n tabIndex={n ? 0 : undefined}\n role=\"group\"\n aria-label={label}\n aria-description={replay ? tr('左右方向鍵移動播放頭') : tr('左右方向鍵查看每一個時間點的數值')}\n onMouseLeave={() => !dragging.current && setHi(-1)}\n // The keyboard sees the values too: ← → move between points, each read aloud as it shows.\n onFocus={() => hi < 0 && n && show(replay ? playhead : 0)}\n onBlur={() => setHi(-1)}\n onKeyDown={(e) => {\n const to = chartKey(e, replay ? playhead : hi, n);\n if (to != null) move(to);\n }}\n onPointerDown={\n replay\n ? (e) => {\n if (e.button !== 0) return;\n dragging.current = true;\n try {\n e.currentTarget.setPointerCapture(e.pointerId);\n } catch {\n /* a pointer the browser no longer tracks: dragging still works inside the chart */\n }\n move(at(e));\n }\n : undefined\n }\n onPointerMove={\n replay\n ? (e) => {\n if (dragging.current) move(at(e));\n }\n : undefined\n }\n onPointerUp={() => {\n dragging.current = false;\n }}\n onPointerCancel={() => {\n dragging.current = false;\n }}\n >\n {/* The group around it carries the name and the keys. */}\n <svg viewBox={`0 0 ${W} ${height}`} width=\"100%\" height={height} aria-hidden=\"true\">\n {now != null && now < n - 1 ? (\n <>\n {/* After now everything is forecast: the same 45° stripes as ui-forecast (4 px line, 9 px period). */}\n <defs>\n <pattern id={stripes} width=\"9\" height=\"9\" patternUnits=\"userSpaceOnUse\" patternTransform=\"rotate(45)\">\n <rect width=\"4\" height=\"9\" className=\"ui-chart-stripe\" />\n </pattern>\n </defs>\n <rect x={X(now)} y={T} width={R - X(now)} height={B - T} fill={`url(#${stripes})`} />\n </>\n ) : null}\n {ticks.map((v, i) => (\n <g key={i}>\n <line x1={L} x2={R} y1={Y(v)} y2={Y(v)} className={i ? 'ui-chart-grid' : 'ui-chart-axis'} />\n <text x={L - 8} y={Y(v) + 4} textAnchor=\"end\" className=\"ui-chart-tick\">\n {format.number(v, tickDecimals(top - min))}\n </text>\n </g>\n ))}\n {bandShapes.map((s, i) => (\n <path key={i} d={s.d} className={cx('ui-chart-band', band?.tone === 'success' ? 'is-success' : s.up ? 'is-pos' : 'is-neg')} />\n ))}\n {(thresholds ?? []).map((t, i) => (\n <g key={i} className={'ui-chart-threshold is-' + t.tone}>\n <line x1={L} x2={R} y1={Y(t.value)} y2={Y(t.value)} />\n <text x={R - 2} y={Y(t.value) - 5} textAnchor=\"end\">\n {t.label}\n </text>\n </g>\n ))}\n {series.map((s, i) =>\n runs(s.values, X, Y).map((pts, k) => (\n <path\n key={i + '-' + k}\n d={smoothPath(pts)}\n pathLength={s.dashed ? undefined : 1}\n className={cx('ui-chart-line', s.dashed && 'is-dashed')}\n style={{ stroke: colorOf(series[i], i), animationDelay: i * 150 + 'ms' }}\n />\n )),\n )}\n {now != null ? (\n <g className=\"ui-chart-now\">\n <line x1={X(now)} x2={X(now)} y1={T - 4} y2={B} />\n <text x={X(now)} y={T - 8} textAnchor=\"middle\">\n {tr('現在')}\n </text>\n </g>\n ) : null}\n {marker ? (\n <g className=\"ui-chart-marker\">\n <circle\n cx={X(marker.at)}\n cy={Y(marker.value)}\n r={5.5}\n style={{ stroke: colorOf(series[marker.series ?? series.length - 1], marker.series ?? series.length - 1) }}\n />\n <text x={X(marker.at) + (markerLeft ? -10 : 10)} y={Y(marker.value) + 20} textAnchor={markerLeft ? 'end' : 'start'}>\n {marker.label}\n </text>\n </g>\n ) : null}\n {replay ? (\n <g className=\"ui-chart-playhead\">\n <line x1={X(playhead)} x2={X(playhead)} y1={T} y2={B} />\n <circle cx={X(playhead)} cy={B} r={8} />\n </g>\n ) : null}\n </svg>\n <div className=\"ui-chart-hit\" style={{ ...edge, bottom: BELOW }}>\n {labels.map((_, j) => (\n <div key={j} onMouseEnter={() => !dragging.current && setHi(j)} className=\"ui-chart-col\">\n {shown === j ? (\n <>\n <div className=\"ui-chart-guide\" />\n {series.map((s, i) => {\n const v = s.values[j];\n return v == null ? null : (\n <span key={i} className=\"ui-chart-dot\" style={{ top: (Y(v) / B) * 100 + '%', background: colorOf(series[i], i) }} />\n );\n })}\n </>\n ) : null}\n </div>\n ))}\n </div>\n {!all.length ? <div className=\"ui-chart-empty\">{empty ?? tr('這段時間沒有資料')}</div> : null}\n {shown >= 0 ? (\n <ChartTip\n title={labels[shown]}\n style={{ left: (X(shown) / W) * 100 + '%', transform: shown > n * 0.65 ? 'translateX(calc(-100% - 12px))' : 'translateX(12px)' }}\n rows={tipRows(shown)}\n />\n ) : null}\n </div>\n {status ? (\n <div style={{ marginLeft: edge.left, marginRight: edge.right }}>\n <StatusBand {...status} count={n} times={labels} legend={false} className=\"is-attached\" />\n </div>\n ) : null}\n <div className=\"ui-chart-xlabels\" style={{ marginLeft: edge.left, marginRight: edge.right }}>\n {labels.map((lb, j) => (\n <span key={j}>{every > 1 && j % every ? '' : digits(lb)}</span>\n ))}\n </div>\n {status ? <StatusLegend classes={status.classes} label={status.label} /> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AA8EA,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,QAAQ;;AAGd,SAAS,KAAK,QAA2B,GAA0B,GAAqC;CACtG,MAAM,MAAiB,CAAC;CACxB,IAAI,MAAe,CAAC;CACpB,OAAO,SAAS,GAAG,MAAM;EACvB,IAAI,KAAK,QAAQ,OAAO,MAAM,CAAC,GAAG;GAChC,IAAI,IAAI,QAAQ,IAAI,KAAK,GAAG;GAC5B,MAAM,CAAC;EACT,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;CAC9B,CAAC;CACD,IAAI,IAAI,QAAQ,IAAI,KAAK,GAAG;CAC5B,OAAO;AACT;;;AAIA,MAAM,WAAW,GAA2B,MAAe,GAAG,QAAQ,YAAY,EAAE,QAAQ,CAAC,IAAI,YAAY,CAAC;AAE9G,SAAgB,UAAU,EACxB,QACA,QACA,OACA,MACA,UACA,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AAW,QAAQ,IAAI,MAAO,mCAAmC;MAAmB;MAC/H,MAAM,QAAQ,KAAK;KACpB,CAAA,IACC;IACD;;GACJ,SACC,oBAAC,OAAD;IAAK,OAAO;KAAE,YAAY,KAAK;KAAM,aAAa,KAAK;IAAM;IAC3D,UAAA,oBAAC,YAAD;KAAY,GAAI;KAAQ,OAAO;KAAG,OAAO;KAAQ,QAAQ;KAAO,WAAU;IAAe,CAAA;GACtF,CAAA,IACH;GACJ,oBAAC,OAAD;IAAK,WAAU;IAAmB,OAAO;KAAE,YAAY,KAAK;KAAM,aAAa,KAAK;IAAM;IACvF,UAAA,OAAO,KAAK,IAAI,MACf,oBAAC,QAAD,EAAA,UAAe,QAAQ,KAAK,IAAI,QAAQ,KAAK,OAAO,EAAE,EAAQ,GAAnD,CAAmD,CAC/D;GACE,CAAA;GACJ,SAAS,oBAAC,cAAD;IAAc,SAAS,OAAO;IAAS,OAAO,OAAO;GAAQ,CAAA,IAAI;EACxE;;AAET"}
1
+ {"version":3,"file":"LineChart.js","names":[],"sources":["../../../src/components/LineChart/LineChart.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChartTip, TICKS, chartKey, tickDecimals, niceMax, seriesColor, smoothPath, type Point } from '../../internal/chart';\nimport { cx, digits } from '../../internal/util';\nimport { format } from '../../format';\nimport { tr } from '../../i18n';\nimport { announce } from '../../announce';\nimport { StatusBand, StatusLegend, type StatusBandProps } from '../StatusBand/StatusBand';\n\nexport interface LineSeries {\n name: string;\n /** One value per label; null where there is none (a forecast ahead of the measurements, a gap). */\n values: (number | null)[];\n /** A dashed line, e.g. a forecast or a baseline; the legend shows it dashed too. */\n dashed?: boolean;\n /** Which chart color (chart-1 to chart-4) instead of the series' place, e.g. 3 for a forecast, 4 for a baseline. */\n color?: 1 | 2 | 3 | 4;\n}\n\nexport interface LineBand {\n /** The two series (indexes in series) the band fills between, e.g. [0, 1] for actual and forecast. */\n between: [number, number];\n /** `diverge`: orange where the first is above the second, blue where below (diverge-pos / diverge-neg, 30%).\n * `success`: success at 28%, for what was saved between actual use and a baseline. */\n tone: 'diverge' | 'success';\n /** Its entry in the legend, e.g. 「實際偏高/偏低」 or 「省下的電」. */\n label: string;\n}\n\nexport interface LineThreshold {\n value: number;\n /** Written on the line at the right, e.g. 「上限 29 °C」. */\n label: string;\n /** `warning` for a level to watch, `danger` for a limit. */\n tone: 'warning' | 'danger';\n}\n\nexport interface LineChartProps {\n /** Up to 4 series (chart-1 to chart-4); a legend with each name appears for 2 or more. */\n series: LineSeries[];\n /** One label per point on the x axis. */\n labels: string[];\n /** Describes the chart for screen readers. */\n label: string;\n /** After each value in the tooltip. */\n unit?: string;\n /** Decimals of the values in the tooltip. Default 0. */\n decimals?: number;\n /** Top of the y axis. Default: a round number above the largest value. */\n max?: number;\n /** Bottom of the y axis. Default 0; set it for values far from 0, such as temperatures. */\n min?: number;\n /** Show every nth x label when they would crowd. */\n labelEvery?: number;\n /** Fills between two series: the one exception to lines without fills (actual and forecast, use and baseline). */\n band?: LineBand;\n /** The point that is now: a 「現在」 line, and the part after it striped as forecast. */\n now?: number;\n /** Horizontal dashed lines for levels, e.g. a warning level and a limit. */\n thresholds?: LineThreshold[];\n /** One forecast point ahead, e.g. the next round: a hollow circle with its label. Its color is the series'. */\n marker?: { at: number; value: number; label: string; series?: number };\n /** A playhead at this point, for replaying: an accent line with a round handle on the x axis. Dragging (mouse,\n * touch) or ← → Home End on the chart move it. */\n playhead?: number;\n onPlayheadChange?: (at: number) => void;\n /** A large figure above the chart, e.g. 「省 186 kWh(約 12%)」. */\n headline?: React.ReactNode;\n /** Shown in place of the lines when no series has a value. Default 「這段時間沒有資料」. */\n empty?: string;\n /** Height of the plot in px, axes included (x labels, the status band and the legend come on top). Default 240.\n * Text in the chart stays at its own size however wide the chart is. */\n height?: number;\n /** A status band under the x axis, aligned with the points (StatusBand without its own spacing). */\n status?: Omit<StatusBandProps, 'count' | 'times' | 'legend' | 'className'>;\n className?: string;\n}\n\n/** Plot geometry in px: y labels left of L, the 現在 label above T, the playhead handle below B. */\nconst L = 40;\nconst T = 10;\nconst BELOW = 30;\n\n/** Runs of consecutive points that have values. */\nfunction runs(values: (number | null)[], X: (i: number) => number, Y: (v: number) => number): Point[][] {\n const out: Point[][] = [];\n let cur: Point[] = [];\n values.forEach((v, i) => {\n if (v == null || Number.isNaN(v)) {\n if (cur.length) out.push(cur);\n cur = [];\n } else cur.push([X(i), Y(v)]);\n });\n if (cur.length) out.push(cur);\n return out;\n}\n\n/** A trend over time: smooth lines, 5 grid lines, a guide and tooltip on hover. For monitoring it can also compare a\n * forecast with what happened (band, now, thresholds, marker) and replay with a playhead. */\nconst colorOf = (s: LineSeries | undefined, i: number) => (s?.color ? seriesColor(s.color - 1) : seriesColor(i));\n\nexport function LineChart({\n series,\n labels,\n label,\n unit,\n decimals,\n max,\n min = 0,\n labelEvery = 1,\n band,\n now,\n thresholds,\n marker,\n playhead,\n onPlayheadChange,\n headline,\n status,\n empty,\n height = 240,\n className,\n}: LineChartProps) {\n const [hi, setHi] = React.useState(-1);\n const plot = React.useRef<HTMLDivElement>(null);\n const [W, setW] = React.useState(640);\n React.useLayoutEffect(() => {\n const el = plot.current;\n if (!el) return;\n const fit = () => {\n if (el.clientWidth > 0) setW(el.clientWidth);\n };\n fit();\n if (typeof ResizeObserver !== 'function') return;\n const ro = new ResizeObserver(fit);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const R = W - 10;\n const B = height - BELOW;\n const stripes = 'ui-stripes-' + React.useId().replace(/:/g, '');\n const dragging = React.useRef(false);\n const all = series.flatMap((s) => s.values.filter((v): v is number => v != null));\n const top = max ?? niceMax(Math.max(min + 1, ...all, ...(thresholds ?? []).map((t) => t.value)) - min) + min;\n const n = labels.length || series[0]?.values.length || 0;\n const step = (R - L) / Math.max(1, n - 1);\n const X = (i: number) => L + i * step;\n const Y = (v: number) => B - ((v - min) / (top - min)) * (B - T);\n const ticks = TICKS.map((f) => min + f * (top - min));\n const suffix = unit ? ' ' + unit : '';\n const num = (v: number | null | undefined) => (v == null ? '—' : format.number(v, decimals) + suffix);\n const replay = playhead != null && !!onPlayheadChange;\n const show = (j: number) => {\n setHi(j);\n announce(\n labels[j] +\n tr(':') +\n series\n .filter((s) => s.values[j] != null)\n .map((s) => (series.length > 1 ? s.name + ' ' : '') + num(s.values[j]))\n .join(tr(',')),\n );\n };\n const move = (j: number) => {\n if (replay) onPlayheadChange(j);\n show(j);\n };\n const at = (e: React.PointerEvent<HTMLElement>) => {\n const r = e.currentTarget.getBoundingClientRect();\n const x = ((e.clientX - r.left) / r.width) * W;\n return Math.max(0, Math.min(n - 1, Math.round((x - L) / step)));\n };\n const edge = { left: ((L - step / 2) / W) * 100 + '%', right: ((W - R - step / 2) / W) * 100 + '%' };\n const legend = series.length > 1 || band;\n // Fewer x labels when they would touch: Geist Mono 12 px is about 7.5 px a character, 12 px between labels.\n const widest = Math.max(0, ...labels.map((lb) => lb.length)) * 7.5 + 12;\n const every = Math.max(labelEvery, Math.ceil((n * widest) / Math.max(1, R - L) / labelEvery) * labelEvery);\n // The marker's label goes left of the point when it would run past the right edge (CJK about 14 px a character).\n const markerLeft = marker ? X(marker.at) + 10 + [...marker.label].reduce((w, c) => w + (c.charCodeAt(0) > 0x2e80 ? 14 : 8), 0) > W : false;\n // Band: one quadrilateral per step where both series have values, colored by which one is higher.\n const bandShapes: { d: string; up: boolean }[] = [];\n if (band) {\n const a = series[band.between[0]]?.values ?? [];\n const b = series[band.between[1]]?.values ?? [];\n for (let i = 0; i < n - 1; i++) {\n const a0 = a[i],\n a1 = a[i + 1],\n b0 = b[i],\n b1 = b[i + 1];\n if (a0 == null || a1 == null || b0 == null || b1 == null) continue;\n bandShapes.push({\n d: `M${X(i)},${Y(a0)} L${X(i + 1)},${Y(a1)} L${X(i + 1)},${Y(b1)} L${X(i)},${Y(b0)} Z`,\n up: a0 + a1 >= b0 + b1,\n });\n }\n }\n const tipRows = (j: number) => {\n const rows = series\n .map((s, i) => ({ color: colorOf(series[i], i), name: s.name, value: s.values[j] }))\n .filter((r) => r.value != null)\n .map((r) => ({ ...r, value: num(r.value) }));\n if (band) {\n const a = series[band.between[0]]?.values[j];\n const b = series[band.between[1]]?.values[j];\n if (a != null && b != null) rows.push({ color: '', name: tr('差'), value: (a - b > 0 ? '+' : '') + num(a - b) });\n }\n return rows;\n };\n const shown = hi >= 0 ? hi : -1;\n return (\n <div className={cx('ui-chart', className)}>\n {headline ? <div className=\"ui-chart-headline\">{headline}</div> : null}\n {legend ? (\n <div className=\"ui-chart-legend\">\n {series.map((s, i) => (\n <span key={i}>\n <span\n className={cx('ui-chart-swatch', s.dashed && 'is-dashed')}\n style={{ background: s.dashed ? undefined : colorOf(series[i], i), color: colorOf(series[i], i) }}\n />\n {s.name}\n </span>\n ))}\n {band ? (\n <span>\n <span className={cx('ui-chart-swatch', 'is-band', 'is-' + band.tone)} />\n {band.label}\n </span>\n ) : null}\n </div>\n ) : null}\n <div\n ref={plot}\n className={cx('ui-chart-plot', replay && 'is-replay')}\n tabIndex={n ? 0 : undefined}\n role=\"group\"\n aria-label={label}\n aria-description={replay ? tr('左右方向鍵移動播放頭') : tr('左右方向鍵查看每一個時間點的數值')}\n onMouseLeave={() => !dragging.current && setHi(-1)}\n // The keyboard sees the values too: ← → move between points, each read aloud as it shows.\n onFocus={() => hi < 0 && n && show(replay ? playhead : 0)}\n onBlur={() => setHi(-1)}\n onKeyDown={(e) => {\n const to = chartKey(e, replay ? playhead : hi, n);\n if (to != null) move(to);\n }}\n onPointerDown={\n replay\n ? (e) => {\n if (e.button !== 0) return;\n dragging.current = true;\n try {\n e.currentTarget.setPointerCapture?.(e.pointerId);\n } catch {\n /* a pointer the browser no longer tracks: dragging still works inside the chart */\n }\n move(at(e));\n }\n : undefined\n }\n onPointerMove={\n replay\n ? (e) => {\n if (dragging.current) move(at(e));\n }\n : undefined\n }\n onPointerUp={() => {\n dragging.current = false;\n }}\n onPointerCancel={() => {\n dragging.current = false;\n }}\n >\n {/* The group around it carries the name and the keys. */}\n <svg viewBox={`0 0 ${W} ${height}`} width=\"100%\" height={height} aria-hidden=\"true\">\n {now != null && now < n - 1 ? (\n <>\n {/* After now everything is forecast: the same 45° stripes as ui-forecast (4 px line, 9 px period). */}\n <defs>\n <pattern id={stripes} width=\"9\" height=\"9\" patternUnits=\"userSpaceOnUse\" patternTransform=\"rotate(45)\">\n <rect width=\"4\" height=\"9\" className=\"ui-chart-stripe\" />\n </pattern>\n </defs>\n <rect x={X(now)} y={T} width={R - X(now)} height={B - T} fill={`url(#${stripes})`} />\n </>\n ) : null}\n {ticks.map((v, i) => (\n <g key={i}>\n <line x1={L} x2={R} y1={Y(v)} y2={Y(v)} className={i ? 'ui-chart-grid' : 'ui-chart-axis'} />\n <text x={L - 8} y={Y(v) + 4} textAnchor=\"end\" className=\"ui-chart-tick\">\n {format.number(v, tickDecimals(top - min))}\n </text>\n </g>\n ))}\n {bandShapes.map((s, i) => (\n <path key={i} d={s.d} className={cx('ui-chart-band', band?.tone === 'success' ? 'is-success' : s.up ? 'is-pos' : 'is-neg')} />\n ))}\n {(thresholds ?? []).map((t, i) => (\n <g key={i} className={'ui-chart-threshold is-' + t.tone}>\n <line x1={L} x2={R} y1={Y(t.value)} y2={Y(t.value)} />\n <text x={R - 2} y={Y(t.value) - 5} textAnchor=\"end\">\n {t.label}\n </text>\n </g>\n ))}\n {series.map((s, i) =>\n runs(s.values, X, Y).map((pts, k) => (\n <path\n key={i + '-' + k}\n d={smoothPath(pts)}\n pathLength={s.dashed ? undefined : 1}\n className={cx('ui-chart-line', s.dashed && 'is-dashed')}\n style={{ stroke: colorOf(series[i], i), animationDelay: i * 150 + 'ms' }}\n />\n )),\n )}\n {now != null ? (\n <g className=\"ui-chart-now\">\n <line x1={X(now)} x2={X(now)} y1={T - 4} y2={B} />\n <text x={X(now)} y={T - 8} textAnchor=\"middle\">\n {tr('現在')}\n </text>\n </g>\n ) : null}\n {marker ? (\n <g className=\"ui-chart-marker\">\n <circle\n cx={X(marker.at)}\n cy={Y(marker.value)}\n r={5.5}\n style={{ stroke: colorOf(series[marker.series ?? series.length - 1], marker.series ?? series.length - 1) }}\n />\n <text x={X(marker.at) + (markerLeft ? -10 : 10)} y={Y(marker.value) + 20} textAnchor={markerLeft ? 'end' : 'start'}>\n {marker.label}\n </text>\n </g>\n ) : null}\n {replay ? (\n <g className=\"ui-chart-playhead\">\n <line x1={X(playhead)} x2={X(playhead)} y1={T} y2={B} />\n <circle cx={X(playhead)} cy={B} r={8} />\n </g>\n ) : null}\n </svg>\n <div className=\"ui-chart-hit\" style={{ ...edge, bottom: BELOW }}>\n {labels.map((_, j) => (\n <div key={j} onMouseEnter={() => !dragging.current && setHi(j)} className=\"ui-chart-col\">\n {shown === j ? (\n <>\n <div className=\"ui-chart-guide\" />\n {series.map((s, i) => {\n const v = s.values[j];\n return v == null ? null : (\n <span key={i} className=\"ui-chart-dot\" style={{ top: (Y(v) / B) * 100 + '%', background: colorOf(series[i], i) }} />\n );\n })}\n </>\n ) : null}\n </div>\n ))}\n </div>\n {!all.length ? <div className=\"ui-chart-empty\">{empty ?? tr('這段時間沒有資料')}</div> : null}\n {shown >= 0 ? (\n <ChartTip\n title={labels[shown]}\n style={{ left: (X(shown) / W) * 100 + '%', transform: shown > n * 0.65 ? 'translateX(calc(-100% - 12px))' : 'translateX(12px)' }}\n rows={tipRows(shown)}\n />\n ) : null}\n </div>\n {status ? (\n <div style={{ marginLeft: edge.left, marginRight: edge.right }}>\n <StatusBand {...status} count={n} times={labels} legend={false} className=\"is-attached\" />\n </div>\n ) : null}\n <div className=\"ui-chart-xlabels\" style={{ marginLeft: edge.left, marginRight: edge.right }}>\n {labels.map((lb, j) => (\n <span key={j}>{every > 1 && j % every ? '' : digits(lb)}</span>\n ))}\n </div>\n {status ? <StatusLegend classes={status.classes} label={status.label} /> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AA8EA,MAAM,IAAI;AACV,MAAM,IAAI;AACV,MAAM,QAAQ;;AAGd,SAA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internal/tableTools.js";
5
- import { cx } from "../../internal/util.js";
5
+ import { cx, resizeObserver } from "../../internal/util.js";
6
6
  import { devWarn } from "../../internal/dev.js";
7
7
  import { CodeView } from "../CodeView/CodeView.js";
8
8
  import { languageOf } from "../CodeView/tokens.js";
@@ -649,9 +649,9 @@ function MdTable(p) {
649
649
  setMeasured((old) => old.length === m.length && old.every((v, i) => v === m[i]) ? old : m);
650
650
  };
651
651
  update();
652
- const ro = new ResizeObserver(update);
653
- ro.observe(el);
654
- return () => ro.disconnect();
652
+ const ro = resizeObserver(update);
653
+ ro?.observe(el);
654
+ return () => ro?.disconnect();
655
655
  }, []);
656
656
  const body = (resize) => /* @__PURE__ */ jsxs("table", {
657
657
  ref: resize ? table : void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.js","names":["phCaretRight"],"sources":["../../../src/components/Markdown/Markdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Alert, type AlertTone } from '../Alert/Alert';\nimport { Icon } from '../../icons/Icon';\nimport { ColResize, TableDialog, ZoomButton } from '../../internal/tableTools';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { CodeView } from '../CodeView/CodeView';\nimport { languageOf } from '../CodeView/tokens';\nimport { InlineCode, type OnRef, type RefHref } from '../InlineCode/InlineCode';\nimport { AiMark } from '../AiMark/AiMark';\nimport { findTerms, termNode, termPattern, withTerms, type TermDef, type TermsMark } from '../../internal/terms';\nimport { includeIcons } from '../../icons/store';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phCaretRight);\n\n/* A small Markdown reader for project documents and code comments. It builds React elements only: no HTML from the\n source is ever run. HTML tags are dropped and their text kept (MX). */\n\ntype Block =\n | { t: 'h'; level: number; text: string }\n | { t: 'p'; text: string }\n | { t: 'code'; lang: string; code: string }\n | { t: 'quote'; blocks: Block[] }\n | { t: 'list'; ordered: boolean; start: number; items: Block[][] }\n | { t: 'table'; head: string[]; align: ('left' | 'right' | 'center' | null)[]; rows: string[][] }\n | { t: 'hr' }\n | { t: 'details'; summary: string; blocks: Block[] }\n | { t: 'alert'; tone: AlertTone; blocks: Block[] };\n\n// DA: <details> and <summary> are the only HTML let through, without attributes; they make a closed block.\nconst DETAILS_OPEN = /^\\s*<details\\b[^>]*>/i;\nconst DETAILS_TAG = /<(\\/?)details\\b[^>]*>/gi;\nconst SUMMARY = /<summary\\b[^>]*>([\\s\\S]*?)<\\/summary>/i;\n// NB: GitHub's alerts, > [!NOTE] and the like, shown as the system's Alert.\nconst ALERT = /^\\s*\\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\]\\s*$/i;\nconst ALERT_TONE: Record<string, AlertTone> = { NOTE: 'info', TIP: 'success', IMPORTANT: 'info', WARNING: 'warning', CAUTION: 'danger' };\n\nconst FENCE = /^ {0,3}(`{3,}|~{3,})\\s*([\\w+#.-]*)/;\nconst HEADING = /^ {0,3}(#{1,6})(?:\\s+(.*?))?\\s*#*\\s*$/;\nconst HR = /^ {0,3}([-*_])(?:\\s*\\1){2,}\\s*$/;\nconst ITEM = /^( {0,3})([-*+]|\\d{1,9}[.)])(\\s+|$)(.*)$/;\nconst QUOTE = /^ {0,3}> ?(.*)$/;\nconst TABLE_SEP = /^\\s*\\|?\\s*:?-{1,}:?\\s*(\\|\\s*:?-{1,}:?\\s*)*\\|?\\s*$/;\n\nfunction cells(line: string): string[] {\n let s = line.trim();\n if (s.startsWith('|')) s = s.slice(1);\n if (s.endsWith('|') && !s.endsWith('\\\\|')) s = s.slice(0, -1);\n const out: string[] = [];\n let cur = '';\n let code = false;\n for (let i = 0; i < s.length; i++) {\n const c = s[i];\n if (c === '\\\\' && s[i + 1] === '|') {\n cur += '|';\n i++;\n } else if (c === '`') {\n code = !code;\n cur += c;\n } else if (c === '|' && !code) {\n out.push(cur.trim());\n cur = '';\n } else cur += c;\n }\n out.push(cur.trim());\n return out;\n}\n\nconst blank = (l: string) => !l.trim();\nconst startsBlock = (l: string) => FENCE.test(l) || HEADING.test(l) || HR.test(l) || QUOTE.test(l) || ITEM.test(l);\n\nfunction parse(lines: string[]): Block[] {\n const out: Block[] = [];\n let i = 0;\n while (i < lines.length) {\n const line = lines[i];\n if (blank(line)) {\n i++;\n continue;\n }\n if (DETAILS_OPEN.test(line)) {\n // The matching </details>, counting nested ones; what follows it on the line goes on as more Markdown.\n const rest = lines.slice(i).join('\\n');\n DETAILS_TAG.lastIndex = 0;\n let depth = 0;\n let open = -1;\n let close = rest.length;\n let after = rest.length;\n for (let m = DETAILS_TAG.exec(rest); m; m = DETAILS_TAG.exec(rest)) {\n if (!m[1]) {\n if (depth++ === 0) open = m.index + m[0].length;\n } else if (--depth === 0) {\n close = m.index;\n after = m.index + m[0].length;\n break;\n }\n }\n let inner = rest.slice(open, close);\n const sum = SUMMARY.exec(inner);\n if (sum) inner = inner.slice(0, sum.index) + inner.slice(sum.index + sum[0].length);\n out.push({ t: 'details', summary: (sum?.[1] ?? '').trim(), blocks: parse(inner.split('\\n')) });\n return out.concat(parse(rest.slice(after).split('\\n')));\n }\n const fence = FENCE.exec(line);\n if (fence) {\n const mark = fence[1];\n const body: string[] = [];\n i++;\n while (i < lines.length && !lines[i].trim().startsWith(mark)) body.push(lines[i++]);\n i++;\n out.push({ t: 'code', lang: fence[2].toLowerCase(), code: body.join('\\n') });\n continue;\n }\n const h = HEADING.exec(line);\n if (h) {\n out.push({ t: 'h', level: h[1].length, text: h[2] ?? '' });\n i++;\n continue;\n }\n if (HR.test(line)) {\n out.push({ t: 'hr' });\n i++;\n continue;\n }\n if (QUOTE.test(line)) {\n const body: string[] = [];\n while (i < lines.length && !blank(lines[i]) && (QUOTE.test(lines[i]) || !startsBlock(lines[i]))) {\n body.push(QUOTE.exec(lines[i])?.[1] ?? lines[i]);\n i++;\n }\n const alert = body.length > 0 ? ALERT.exec(body[0]) : null;\n if (alert) out.push({ t: 'alert', tone: ALERT_TONE[alert[1].toUpperCase()], blocks: parse(body.slice(1)) });\n else out.push({ t: 'quote', blocks: parse(body) });\n continue;\n }\n const item = ITEM.exec(line);\n if (item) {\n const ordered = /\\d/.test(item[2]);\n const start = ordered ? parseInt(item[2], 10) : 1;\n const items: Block[][] = [];\n while (i < lines.length) {\n const m = ITEM.exec(lines[i]);\n if (!m || /\\d/.test(m[2]) !== ordered) break;\n const indent = m[1].length + m[2].length + Math.max(1, Math.min(m[3].length, 4));\n const body = [m[4]];\n i++;\n // The item's own lines: indented continuation (nested lists too), and lazy text right after it.\n while (i < lines.length) {\n const l = lines[i];\n if (blank(l)) {\n const next = lines[i + 1];\n if (next !== undefined && /^\\s+/.test(next) && next.search(/\\S/) >= indent) {\n body.push('');\n i++;\n continue;\n }\n break;\n }\n const lead = l.search(/\\S/);\n if (lead >= indent || (lead >= 2 && ITEM.test(l.trimStart()))) body.push(l.slice(Math.min(lead, indent)));\n else if (!startsBlock(l) && !ITEM.test(l)) body.push(l);\n else break;\n i++;\n }\n items.push(parse(body));\n if (i < lines.length && blank(lines[i])) {\n const next = lines[i + 1];\n if (next !== undefined && ITEM.test(next) && /\\d/.test(ITEM.exec(next)?.[2] ?? '') === ordered) {\n i++;\n continue;\n }\n break;\n }\n }\n out.push({ t: 'list', ordered, start, items });\n continue;\n }\n if (line.includes('|') && i + 1 < lines.length && TABLE_SEP.test(lines[i + 1]) && lines[i + 1].includes('-')) {\n const head = cells(line);\n const align = cells(lines[i + 1]).map((c) =>\n c.startsWith(':') && c.endsWith(':') ? 'center' : c.endsWith(':') ? 'right' : c.startsWith(':') ? 'left' : null,\n );\n const rows: string[][] = [];\n i += 2;\n while (i < lines.length && !blank(lines[i]) && lines[i].includes('|')) rows.push(cells(lines[i++]));\n out.push({ t: 'table', head, align, rows });\n continue;\n }\n // A paragraph: lines until a blank line or another block.\n const body = [line];\n i++;\n while (i < lines.length && !blank(lines[i]) && !startsBlock(lines[i])) body.push(lines[i++]);\n out.push({ t: 'p', text: body.join('\\n') });\n }\n return out;\n}\n\n/** Only http, https, mailto and relative addresses are kept; anything else (javascript:, data:) is not a link. */\nexport function safeHref(href: string): string | undefined {\n const h = href.trim();\n if (!h) return undefined;\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(h);\n if (!scheme) return h;\n return ['http', 'https', 'mailto'].includes(scheme[1].toLowerCase()) ? h : undefined;\n}\n\n// A path in inline code: folders and a file with an extension, or a file and line (src/app.c:86, docs/a.md).\nconst PATH = /^(?:\\.{1,2}\\/)?(?:[\\w.-]+\\/)*[\\w.-]+\\.[A-Za-z0-9]+(?::\\d+(?:-\\d+)?)?$/;\nconst isPath = (s: string) => PATH.test(s) && (s.includes('/') || /:\\d/.test(s));\n\n// Never links, even when listed in schemes.\nconst BLOCKED = ['javascript', 'data', 'vbscript'];\n\ninterface Ctx {\n /** Extra schemes (fn, file) handed to linkHref and onLink as they are. */\n schemes?: string[];\n /** The next key: counted from 0 on every render, so the same source gives the same keys. */\n k: () => string;\n linkHref?: (href: string) => string | undefined | null;\n onLink?: (href: string, e: React.MouseEvent<HTMLElement>) => void;\n refHref?: RefHref;\n onRef?: OnRef;\n terms?: readonly TermDef[];\n termsMark: TermsMark;\n /** All the words in one pattern; null without terms. */\n termRe: RegExp | null;\n /** Words already marked in this block (paragraph, list item, table cell). Absent: no words here (headings, link\n * text, a details summary). */\n seen?: Set<string>;\n}\n\n/** A new block: its own count of marked words. */\nconst block = (c: Ctx): Ctx => ({ ...c, seen: new Set() });\n/** No words marked inside (headings, link text, a summary button). */\nconst noTerms = (c: Ctx): Ctx => ({ ...c, seen: undefined });\n\nconst CJK = /[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\u3000-\\u303f\\uff00-\\uffef]/u;\n\n/** Inline Markdown: code spans, links, autolinks, bold, italic, hard breaks; HTML tags dropped, their text kept. */\nfunction inline(src: string, c: Ctx): React.ReactNode[] {\n let aiMark: string | null = null;\n const out: React.ReactNode[] = [];\n let text = '';\n const flush = () => {\n if (text && c.termRe && c.terms && c.seen) out.push(...withTerms(text, findTerms(text, c.terms, c.termRe, c.termsMark, c.seen), c.terms, c.k));\n else if (text) out.push(text);\n text = '';\n };\n let i = 0;\n while (i < src.length) {\n const ch = src[i];\n if (ch === '\\\\' && i + 1 < src.length && /[\\\\`*_{}[\\]()#+\\-.!|<>~]/.test(src[i + 1])) {\n text += src[i + 1];\n i += 2;\n continue;\n }\n if (ch === '\\\\' && src[i + 1] === '\\n') {\n flush();\n out.push(<br key={c.k()} />);\n i += 2;\n continue;\n }\n if (ch === '\\n') {\n // Two spaces before a line break make a break; otherwise it is a space.\n if (/ {2,}$/.test(text)) {\n text = text.replace(/ +$/, '');\n flush();\n out.push(<br key={c.k()} />);\n } else {\n // Lines joined: a space between words, none next to Chinese text or full-width punctuation.\n text = text.replace(/ +$/, '');\n const before = text.at(-1) ?? (typeof out.at(-1) === 'string' ? String(out.at(-1)).at(-1) : '');\n const after = src.slice(i + 1).trimStart()[0] ?? '';\n if (!CJK.test(before ?? '') && !CJK.test(after)) text += ' ';\n while (src[i + 1] === ' ') i++;\n }\n i++;\n continue;\n }\n if (ch === '`') {\n const run = /^`+/.exec(src.slice(i))?.[0] ?? '`';\n const end = src.indexOf(run, i + run.length);\n if (end > 0) {\n flush();\n let v = src.slice(i + run.length, end).replace(/\\n/g, ' ');\n if (/^ .* $/.test(v)) v = v.slice(1, -1);\n out.push(code(v, c));\n i = end + run.length;\n continue;\n }\n }\n if (ch === '<') {\n const auto = /^<((?:https?:|mailto:)[^\\s<>]+)>/i.exec(src.slice(i));\n if (auto) {\n flush();\n out.push(link(auto[1], [auto[1].replace(/^mailto:/i, '')], c));\n i += auto[0].length;\n continue;\n }\n const tag = /^<!--[\\s\\S]*?-->|^<\\/?[A-Za-z][\\w-]*(?:\\s[^<>]*)?\\/?>/.exec(src.slice(i));\n if (tag) {\n // MX: an HTML tag (or comment) is dropped; the text between tags stays.\n i += tag[0].length;\n continue;\n }\n }\n if (ch === '!' && src[i + 1] === '[') {\n // An image shows its alt text; nothing is loaded.\n const m = /^!\\[([^\\]]*)\\]\\([^)]*\\)/.exec(src.slice(i));\n if (m) {\n text += m[1];\n i += m[0].length;\n continue;\n }\n }\n if (ch === '[') {\n const m = matchLink(src, i);\n if (m) {\n // [AI](ai:) marks a paragraph, list item or cell written by AI: an AiMark at its end, wherever it is written.\n // Other words in the brackets, such as [推測](ai:), are shown in the same style.\n if (m.href.trim().toLowerCase() === 'ai:') {\n const words = m.text.trim();\n aiMark = words && words !== 'AI' ? words : '';\n i = m.end;\n if (src[i] === ' ') i++;\n continue;\n }\n flush();\n // [cookie](term:cookie) marks a word explicitly with its entry in terms.\n const termId = /^term:(.*)$/i.exec(m.href.trim())?.[1];\n if (termId !== undefined) {\n let id = termId;\n try {\n id = decodeURIComponent(termId);\n } catch {\n /* kept as written */\n }\n const t = c.terms?.find((x) => x.term === id);\n devWarn(!t, 'Markdown', `[${m.text}](term:${termId}) 找不到 terms 裡 term 為「${id}」的項目,只顯示文字。把它加進 terms,或改 term: 後面的字。`);\n c.seen?.add(id);\n out.push(t ? termNode(t, c.k(), inline(m.text, noTerms(c))) : <React.Fragment key={c.k()}>{inline(m.text, noTerms(c))}</React.Fragment>);\n i = m.end;\n continue;\n }\n // A link whose text is one code span ([`_sync_as`](fn:…)) is a name: accent monospace, no chip.\n const name = /^\\s*`([^`]+)`\\s*$/.exec(m.text)?.[1];\n out.push(link(m.href, inline(m.text, noTerms(c)), c, name));\n i = m.end;\n continue;\n }\n }\n if (ch === '*' || ch === '_') {\n const run = src[i + 1] === ch ? ch + ch : ch;\n // _ inside a word (snake_case) is not emphasis.\n const prev = src[i - 1];\n const intraword = ch === '_' && prev !== undefined && /\\w/.test(prev);\n const next = src[i + run.length];\n if (!intraword && next && !/\\s/.test(next)) {\n const end = findClose(src, i + run.length, run);\n if (end > 0) {\n flush();\n const inner = inline(src.slice(i + run.length, end), c);\n out.push(run.length === 2 ? <strong key={c.k()}>{inner}</strong> : <em key={c.k()}>{inner}</em>);\n i = end + run.length;\n continue;\n }\n }\n }\n text += ch;\n i++;\n }\n flush();\n if (aiMark != null) {\n // A trailing space before the mark is dropped; the mark keeps its own 8 px.\n const last = out[out.length - 1];\n if (typeof last === 'string') out[out.length - 1] = last.replace(/\\s+$/, '');\n out.push(<AiMark key={c.k()} text={aiMark || undefined} />);\n }\n return out;\n\n function code(v: string, ctx: Ctx): React.ReactNode {\n const onRef = ctx.onRef;\n if (isPath(v)) {\n // A file and line that points somewhere is a location: gray, one step smaller.\n const href = ctx.refHref?.(v) || undefined;\n const click = onRef\n ? (e: React.MouseEvent<HTMLElement>) => {\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onRef(v, e);\n }\n : undefined;\n if (href)\n return (\n <InlineCode key={ctx.k()} look=\"location\" href={href} onClick={click}>\n {v}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={ctx.k()} look=\"location\" onClick={click}>\n {v}\n </InlineCode>\n );\n }\n return <InlineCode key={ctx.k()}>{v}</InlineCode>;\n }\n}\n\nfunction matchLink(src: string, i: number): { text: string; href: string; end: number } | null {\n let depth = 0;\n let j = i;\n for (; j < src.length; j++) {\n if (src[j] === '\\\\') {\n j++;\n continue;\n }\n if (src[j] === '[') depth++;\n else if (src[j] === ']' && --depth === 0) break;\n }\n if (j >= src.length || src[j + 1] !== '(') return null;\n // The address may hold balanced parentheses (javascript:alert(1), wiki/Foo_(bar)); an optional \"title\" follows.\n let at = j + 2;\n while (src[at] === ' ') at++;\n let depth2 = 0;\n let href = '';\n for (; at < src.length; at++) {\n const ch = src[at];\n if (/\\s/.test(ch)) break;\n if (ch === '(') depth2++;\n else if (ch === ')') {\n if (depth2 === 0) break;\n depth2--;\n }\n href += ch;\n }\n const rest = /^(?:\\s+(?:\"[^\"]*\"|'[^']*'))?\\s*\\)/.exec(src.slice(at));\n if (!rest) return null;\n return { text: src.slice(i + 1, j), href: href.replace(/^<(.*)>$/, '$1'), end: at + rest[0].length };\n}\n\nfunction findClose(src: string, from: number, run: string): number {\n let j = from;\n while ((j = src.indexOf(run, j)) > 0) {\n const before = src[j - 1];\n const after = src[j + run.length];\n if (before && !/\\s/.test(before) && !(run[0] === '_' && after && /\\w/.test(after)) && !(run.length === 1 && after === run)) return j;\n j += run.length;\n }\n return -1;\n}\n\nfunction link(raw: string, children: React.ReactNode, c: Ctx, name?: string): React.ReactNode {\n // A scheme listed in schemes (fn:, file:) is up to linkHref and onLink: no address of its own.\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(raw.trim())?.[1].toLowerCase();\n const own = !!scheme && !BLOCKED.includes(scheme) && !!c.schemes?.some((x) => x.toLowerCase() === scheme);\n const safe = own ? raw.trim() : safeHref(raw);\n if (safe === undefined) return <React.Fragment key={c.k()}>{children}</React.Fragment>;\n const href = c.linkHref ? c.linkHref(safe) || undefined : own ? undefined : safe;\n if (!href && !c.onLink) return <React.Fragment key={c.k()}>{children}</React.Fragment>;\n const outside = !!href && /^https?:/i.test(href);\n const onLink = c.onLink;\n const click = onLink\n ? (e: React.MouseEvent<HTMLElement>) => {\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onLink(safe, e);\n }\n : undefined;\n if (name !== undefined && !(outside && !c.onLink)) {\n if (href)\n return (\n <InlineCode key={c.k()} look=\"name\" href={href} onClick={click}>\n {name}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={c.k()} look=\"name\" onClick={click}>\n {name}\n </InlineCode>\n );\n }\n if (!href)\n return (\n <button key={c.k()} type=\"button\" className=\"ui-md-link\" onClick={click}>\n {children}\n </button>\n );\n return (\n <a key={c.k()} className=\"ui-md-link\" href={href} onClick={click} {...(outside && !c.onLink ? { target: '_blank', rel: 'noopener noreferrer' } : {})}>\n {children}\n </a>\n );\n}\n\n// A fence's language name as CodeView knows it: ```python is py, ```bash is sh; file extensions work too (```ts).\nconst FENCE_LANG: Record<string, string> = {\n python: 'py',\n javascript: 'js',\n typescript: 'js',\n jsx: 'js',\n tsx: 'js',\n bash: 'sh',\n shell: 'sh',\n zsh: 'sh',\n console: 'sh',\n 'c++': 'c',\n};\nconst fenceLang = (l: string) => FENCE_LANG[l] ?? (languageOf('x.' + l) !== 'plain' ? languageOf('x.' + l) : l || 'plain');\n\n// A number cell's figures and its unit: [all, number, space, unit].\nconst NUM_UNIT = /^([-+]?(?:NT\\$\\s?)?[\\d,]+(?:\\.\\d+)?)(\\s?)(%|[A-Za-z]{1,3}|\\p{Script=Han}{1,2})$/u;\nconst NUM = /^[-+]?(?:NT\\$\\s?)?[\\d,]+(?:\\.\\d+)?\\s?(?:%|[A-Za-z]{1,3}|\\p{Script=Han}{1,2})?$/u;\n\nexport interface MarkdownProps {\n /** The Markdown text. */\n children: string;\n /** Only inline syntax (code, links, bold, italic), no paragraphs: for a one-line summary such as a README's first\n * sentence. Line breaks become spaces. */\n inline?: boolean;\n /** small: 13 px, for notes. Default: the same 16 px as the text around it. */\n size?: 'body' | 'small';\n /** The heading level `#` becomes. Default 4: # is an h4 (20 px), ## an h5, ### and deeper h6 (both 16 px bold). */\n topLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /** Link schemes of your own, such as ['fn', 'file']: [_sync_as](fn:harness/controller.py:VirtualRouter._sync_as)\n * goes to linkHref and onLink as written, which decide what it opens. javascript:, data: and vbscript: never link. */\n schemes?: string[];\n /** The address of a link (after the http, https, mailto or relative check); return undefined for no link. */\n linkHref?: (href: string) => string | undefined | null;\n /** A plain click on a link (the default navigation is prevented; Ctrl, ⌘ or Shift still open linkHref). */\n onLink?: (href: string, e: React.MouseEvent<HTMLElement>) => void;\n /** Inline code that is a path (harness/routing.py:108, docs/a.md) and paths in code blocks: their link. Same as\n * CodeView's refHref. */\n refHref?: RefHref;\n /** A plain click on such a path. Same as CodeView's onRef. */\n onRef?: OnRef;\n /** Words that get an explanation (Term variant=\"inline\"): matched whole and case-sensitive in plain text, not in\n * inline code, link text or headings; fenced code blocks match them in comments and strings. `[cookie](term:cookie)`\n * marks one explicitly, wherever it is. */\n terms?: readonly TermDef[];\n /** 'first' (default): each word only where it first appears in a paragraph, list item or table cell. 'all': everywhere. */\n termsMark?: TermsMark;\n className?: string;\n}\n\n/** Markdown from project documents and code comments, in the system's own type, code and table styles. Never runs HTML:\n * tags are dropped and their text kept; links only to http, https, mailto and relative addresses. */\nexport function Markdown(p: MarkdownProps) {\n // Keys count from 0 on every render, so the same source gives the same keys and nothing remounts.\n let n = 0;\n const termsMark = p.termsMark ?? 'first';\n const termRe = React.useMemo(() => termPattern(p.terms), [p.terms]);\n const c: Ctx = {\n k: () => 'm' + n++,\n schemes: p.schemes,\n linkHref: p.linkHref,\n onLink: p.onLink,\n refHref: p.refHref,\n onRef: p.onRef,\n terms: p.terms,\n termsMark,\n termRe,\n };\n const src = String(p.children ?? '').replace(/\\r\\n?/g, '\\n');\n const cls = cx('ui-md', p.size === 'small' && 'is-small', p.className);\n if (p.inline) return <span className={cx(cls, 'is-inline')}>{inline(src.trim().replace(/\\n\\s*\\n/g, '\\n'), block(c))}</span>;\n const top = p.topLevel ?? 4;\n const render = (blocks: Block[]): React.ReactNode[] =>\n blocks.map((b) => {\n switch (b.t) {\n case 'h': {\n const H = `h${Math.min(6, top + b.level - 1)}` as 'h4';\n return (\n <H key={c.k()} className=\"ui-md-h\">\n {inline(b.text, noTerms(c))}\n </H>\n );\n }\n case 'p':\n return <p key={c.k()}>{inline(b.text, block(c))}</p>;\n case 'hr':\n return <hr key={c.k()} />;\n case 'details':\n return (\n <MdDetails key={c.k()} summary={inline(b.summary, noTerms(c))}>\n {render(b.blocks)}\n </MdDetails>\n );\n case 'alert':\n return (\n <Alert key={c.k()} tone={b.tone} className=\"ui-md-alert\">\n {render(b.blocks)}\n </Alert>\n );\n case 'quote':\n return <blockquote key={c.k()}>{render(b.blocks)}</blockquote>;\n case 'list': {\n const items = b.items.map((it) => <li key={c.k()}>{it.length === 1 && it[0].t === 'p' ? inline(it[0].text, block(c)) : render(it)}</li>);\n return b.ordered ? (\n <ol key={c.k()} start={b.start === 1 ? undefined : b.start}>\n {items}\n </ol>\n ) : (\n <ul key={c.k()}>{items}</ul>\n );\n }\n case 'code':\n return (\n <CodeView\n key={c.k()}\n className=\"ui-md-code\"\n code={b.code}\n language={fenceLang(b.lang)}\n languageLabel={b.lang ? undefined : false}\n copy\n lineNumbers={false}\n refHref={p.refHref}\n onRef={p.onRef}\n terms={p.terms}\n termsMark={termsMark}\n />\n );\n case 'table': {\n // Numbers right-aligned: a column whose cells are all numbers, unless the source sets its alignment.\n const n = b.head.length;\n const numeric = b.head.map((_, j) => b.rows.length > 0 && b.rows.every((r) => !r[j] || NUM.test(r[j])));\n const align = (j: number): React.CSSProperties | undefined => {\n const a = b.align[j] ?? (numeric[j] ? 'right' : null);\n return a ? { textAlign: a } : undefined;\n };\n return (\n <MdTable\n key={c.k()}\n label={b.head.map(plain).join('、')}\n heads={b.head.map((h) => inline(h, noTerms(c)))}\n headText={b.head.map(plain)}\n rows={b.rows.map((r) =>\n Array.from({ length: n }, (_, j) => {\n // A number column: the figures in Geist Mono (td.is-num), the unit (「46 分」「3.5 GB」) in the text font.\n const u = numeric[j] ? NUM_UNIT.exec(r[j] ?? '') : null;\n return u ? (\n <>\n {inline(u[1], block(c))}\n {u[2]}\n <span className=\"ui-unit\">{u[3]}</span>\n </>\n ) : (\n inline(r[j] ?? '', block(c))\n );\n }),\n )}\n numeric={numeric}\n align={align}\n />\n );\n }\n }\n });\n return <div className={cls}>{render(parse(src.split('\\n')))}</div>;\n}\n\n/** A header cell as plain text, for the label above each value when a narrow table turns into cards. */\nconst plain = (md: string) =>\n md\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/[`*_]/g, '')\n .trim();\n\n/** DA: a <details> block: a button with the summary, closed at first. The closed content stays in the page\n * (hidden=\"until-found\"), so the browser's find opens it, as in Section. */\nfunction MdDetails({ summary, children }: { summary: React.ReactNode; children: React.ReactNode }) {\n const [open, setOpen] = React.useState(false);\n const id = React.useId();\n const body = React.useRef<HTMLDivElement>(null);\n React.useLayoutEffect(() => {\n const el = body.current;\n if (!el) return;\n if (open) {\n el.removeAttribute('hidden');\n return;\n }\n el.setAttribute('hidden', 'until-found');\n const found = () => setOpen(true);\n el.addEventListener('beforematch', found);\n return () => el.removeEventListener('beforematch', found);\n }, [open]);\n return (\n <div className={cx('ui-md-details', open && 'is-open')}>\n <button type=\"button\" className=\"ui-md-summary\" aria-expanded={open} aria-controls={id} onClick={() => setOpen(!open)}>\n <Icon name=\"caret-right\" size={16} className=\"ui-md-caret\" />\n <span>{summary}</span>\n </button>\n <div id={id} ref={body} className=\"ui-md-details-body\">\n {children}\n </div>\n </div>\n );\n}\n\n/** A Markdown table: column borders in the header drag; the corner button shows the whole table in a wide dialog.\n * Under 480 px every row is a card instead, without either. The border, the dialog and the copy icon are the same as\n * DataTable's (internal/tableTools). */\nfunction MdTable(p: {\n label: string;\n heads: React.ReactNode[];\n headText: string[];\n rows: React.ReactNode[][];\n numeric: boolean[];\n align: (j: number) => React.CSSProperties | undefined;\n}) {\n const [widths, setWidths] = React.useState<number[] | null>(null);\n const [big, setBig] = React.useState(false);\n const [dragging, setDragging] = React.useState(false);\n const table = React.useRef<HTMLTableElement>(null);\n // Rounded up: a fixed column a fraction of a pixel narrower than it was drawn would wrap its longest word.\n const measure = () => [...(table.current?.querySelectorAll<HTMLElement>('thead th') ?? [])].map((th) => Math.ceil(th.getBoundingClientRect().width));\n // The drawn widths, kept for the borders' aria-valuenow (refs are not read while rendering).\n const [measured, setMeasured] = React.useState<number[]>([]);\n React.useLayoutEffect(() => {\n const el = table.current;\n if (!el) return;\n const update = () => {\n const m = [...el.querySelectorAll<HTMLElement>('thead th')].map((th) => Math.ceil(th.getBoundingClientRect().width));\n setMeasured((old) => (old.length === m.length && old.every((v, i) => v === m[i]) ? old : m));\n };\n update();\n const ro = new ResizeObserver(update);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n const body = (resize: boolean) => (\n <table\n ref={resize ? table : undefined}\n className=\"ui-md-table\"\n style={resize && widths ? { width: widths.reduce((a, b) => a + b, 0), tableLayout: 'fixed', minWidth: 0 } : undefined}\n >\n {resize && widths ? (\n <colgroup>\n {widths.map((w, j) => (\n <col key={j} style={{ width: w }} />\n ))}\n </colgroup>\n ) : null}\n <thead>\n <tr>\n {p.heads.map((h, j) => (\n <th key={j} style={p.align(j)}>\n {h}\n {resize ? (\n <ColResize\n name={p.headText[j]}\n width={widths?.[j] ?? measured[j] ?? 0}\n start={() => (widths ?? measure())[j]}\n onWidth={(w) => {\n const next = (widths ?? measure()).slice();\n next[j] = w;\n setWidths(next);\n }}\n onReset={() => setWidths(null)}\n onDragging={setDragging}\n />\n ) : null}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {p.rows.map((r, ri) => (\n <tr key={ri}>\n {r.map((cell, j) => (\n <td key={j} className={p.numeric[j] ? 'is-num' : undefined} style={p.align(j)} data-label={p.headText[j]}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n return (\n <div className={cx('ui-md-tablebox', dragging && 'is-resizing')}>\n <div className=\"ui-md-table-tools\">\n <ZoomButton onClick={() => setBig(true)} />\n </div>\n <div className=\"ui-md-table-wrap\" tabIndex={0} role=\"region\" aria-label={p.label}>\n {body(true)}\n </div>\n <TableDialog open={big} onClose={() => setBig(false)}>\n <div className=\"ui-md ui-md-table-wrap\" tabIndex={0} role=\"region\" aria-label={p.label}>\n {body(false)}\n </div>\n </TableDialog>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,aAAaA,mBAAY;AAiBzB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,UAAU;AAEhB,MAAM,QAAQ;AACd,MAAM,aAAwC;CAAE,MAAM;CAAQ,KAAK;CAAW,WAAW;CAAQ,SAAS;CAAW,SAAS;AAAS;AAEvI,MAAM,QAAQ;AACd,MAAM,UAAU;AAChB,MAAM,KAAK;AACX,MAAM,OAAO;AACb,MAAM,QAAQ;AACd,MAAM,YAAY;AAElB,SA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AAD;EAAK,WAAW,GAAG,kBAAkB,YAAY,aAAa;EAA9D,UAAA;GACE,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,YAAD,EAAY,eAAe,OAAO,IAAI,EAAI,CAAA;GACvC,CAAA;GACL,oBAAC,OAAD;IAAK,WAAU;IAAmB,UAAU;IAAG,MAAK;IAAS,cAAY,EAAE;IACxE,UAAA,KAAK,IAAI;GACP,CAAA;GACL,oBAAC,aAAD;IAAa,MAAM;IAAK,eAAe,OAAO,KAAK;IACjD,UAAA,oBAAC,OAAD;KAAK,WAAU;KAAyB,UAAU;KAAG,MAAK;KAAS,cAAY,EAAE;KAC9E,UAAA,KAAK,KAAK;IACR,CAAA;GACM,CAAA;EACV;;AAET"}
1
+ {"version":3,"file":"Markdown.js","names":["phCaretRight"],"sources":["../../../src/components/Markdown/Markdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Alert, type AlertTone } from '../Alert/Alert';\nimport { Icon } from '../../icons/Icon';\nimport { ColResize, TableDialog, ZoomButton } from '../../internal/tableTools';\nimport { cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { CodeView } from '../CodeView/CodeView';\nimport { languageOf } from '../CodeView/tokens';\nimport { InlineCode, type OnRef, type RefHref } from '../InlineCode/InlineCode';\nimport { AiMark } from '../AiMark/AiMark';\nimport { findTerms, termNode, termPattern, withTerms, type TermDef, type TermsMark } from '../../internal/terms';\nimport { includeIcons } from '../../icons/store';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phCaretRight);\n\n/* A small Markdown reader for project documents and code comments. It builds React elements only: no HTML from the\n source is ever run. HTML tags are dropped and their text kept (MX). */\n\ntype Block =\n | { t: 'h'; level: number; text: string }\n | { t: 'p'; text: string }\n | { t: 'code'; lang: string; code: string }\n | { t: 'quote'; blocks: Block[] }\n | { t: 'list'; ordered: boolean; start: number; items: Block[][] }\n | { t: 'table'; head: string[]; align: ('left' | 'right' | 'center' | null)[]; rows: string[][] }\n | { t: 'hr' }\n | { t: 'details'; summary: string; blocks: Block[] }\n | { t: 'alert'; tone: AlertTone; blocks: Block[] };\n\n// DA: <details> and <summary> are the only HTML let through, without attributes; they make a closed block.\nconst DETAILS_OPEN = /^\\s*<details\\b[^>]*>/i;\nconst DETAILS_TAG = /<(\\/?)details\\b[^>]*>/gi;\nconst SUMMARY = /<summary\\b[^>]*>([\\s\\S]*?)<\\/summary>/i;\n// NB: GitHub's alerts, > [!NOTE] and the like, shown as the system's Alert.\nconst ALERT = /^\\s*\\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\]\\s*$/i;\nconst ALERT_TONE: Record<string, AlertTone> = { NOTE: 'info', TIP: 'success', IMPORTANT: 'info', WARNING: 'warning', CAUTION: 'danger' };\n\nconst FENCE = /^ {0,3}(`{3,}|~{3,})\\s*([\\w+#.-]*)/;\nconst HEADING = /^ {0,3}(#{1,6})(?:\\s+(.*?))?\\s*#*\\s*$/;\nconst HR = /^ {0,3}([-*_])(?:\\s*\\1){2,}\\s*$/;\nconst ITEM = /^( {0,3})([-*+]|\\d{1,9}[.)])(\\s+|$)(.*)$/;\nconst QUOTE = /^ {0,3}> ?(.*)$/;\nconst TABLE_SEP = /^\\s*\\|?\\s*:?-{1,}:?\\s*(\\|\\s*:?-{1,}:?\\s*)*\\|?\\s*$/;\n\nfunction cells(line: string): string[] {\n let s = line.trim();\n if (s.startsWith('|')) s = s.slice(1);\n if (s.endsWith('|') && !s.endsWith('\\\\|')) s = s.slice(0, -1);\n const out: string[] = [];\n let cur = '';\n let code = false;\n for (let i = 0; i < s.length; i++) {\n const c = s[i];\n if (c === '\\\\' && s[i + 1] === '|') {\n cur += '|';\n i++;\n } else if (c === '`') {\n code = !code;\n cur += c;\n } else if (c === '|' && !code) {\n out.push(cur.trim());\n cur = '';\n } else cur += c;\n }\n out.push(cur.trim());\n return out;\n}\n\nconst blank = (l: string) => !l.trim();\nconst startsBlock = (l: string) => FENCE.test(l) || HEADING.test(l) || HR.test(l) || QUOTE.test(l) || ITEM.test(l);\n\nfunction parse(lines: string[]): Block[] {\n const out: Block[] = [];\n let i = 0;\n while (i < lines.length) {\n const line = lines[i];\n if (blank(line)) {\n i++;\n continue;\n }\n if (DETAILS_OPEN.test(line)) {\n // The matching </details>, counting nested ones; what follows it on the line goes on as more Markdown.\n const rest = lines.slice(i).join('\\n');\n DETAILS_TAG.lastIndex = 0;\n let depth = 0;\n let open = -1;\n let close = rest.length;\n let after = rest.length;\n for (let m = DETAILS_TAG.exec(rest); m; m = DETAILS_TAG.exec(rest)) {\n if (!m[1]) {\n if (depth++ === 0) open = m.index + m[0].length;\n } else if (--depth === 0) {\n close = m.index;\n after = m.index + m[0].length;\n break;\n }\n }\n let inner = rest.slice(open, close);\n const sum = SUMMARY.exec(inner);\n if (sum) inner = inner.slice(0, sum.index) + inner.slice(sum.index + sum[0].length);\n out.push({ t: 'details', summary: (sum?.[1] ?? '').trim(), blocks: parse(inner.split('\\n')) });\n return out.concat(parse(rest.slice(after).split('\\n')));\n }\n const fence = FENCE.exec(line);\n if (fence) {\n const mark = fence[1];\n const body: string[] = [];\n i++;\n while (i < lines.length && !lines[i].trim().startsWith(mark)) body.push(lines[i++]);\n i++;\n out.push({ t: 'code', lang: fence[2].toLowerCase(), code: body.join('\\n') });\n continue;\n }\n const h = HEADING.exec(line);\n if (h) {\n out.push({ t: 'h', level: h[1].length, text: h[2] ?? '' });\n i++;\n continue;\n }\n if (HR.test(line)) {\n out.push({ t: 'hr' });\n i++;\n continue;\n }\n if (QUOTE.test(line)) {\n const body: string[] = [];\n while (i < lines.length && !blank(lines[i]) && (QUOTE.test(lines[i]) || !startsBlock(lines[i]))) {\n body.push(QUOTE.exec(lines[i])?.[1] ?? lines[i]);\n i++;\n }\n const alert = body.length > 0 ? ALERT.exec(body[0]) : null;\n if (alert) out.push({ t: 'alert', tone: ALERT_TONE[alert[1].toUpperCase()], blocks: parse(body.slice(1)) });\n else out.push({ t: 'quote', blocks: parse(body) });\n continue;\n }\n const item = ITEM.exec(line);\n if (item) {\n const ordered = /\\d/.test(item[2]);\n const start = ordered ? parseInt(item[2], 10) : 1;\n const items: Block[][] = [];\n while (i < lines.length) {\n const m = ITEM.exec(lines[i]);\n if (!m || /\\d/.test(m[2]) !== ordered) break;\n const indent = m[1].length + m[2].length + Math.max(1, Math.min(m[3].length, 4));\n const body = [m[4]];\n i++;\n // The item's own lines: indented continuation (nested lists too), and lazy text right after it.\n while (i < lines.length) {\n const l = lines[i];\n if (blank(l)) {\n const next = lines[i + 1];\n if (next !== undefined && /^\\s+/.test(next) && next.search(/\\S/) >= indent) {\n body.push('');\n i++;\n continue;\n }\n break;\n }\n const lead = l.search(/\\S/);\n if (lead >= indent || (lead >= 2 && ITEM.test(l.trimStart()))) body.push(l.slice(Math.min(lead, indent)));\n else if (!startsBlock(l) && !ITEM.test(l)) body.push(l);\n else break;\n i++;\n }\n items.push(parse(body));\n if (i < lines.length && blank(lines[i])) {\n const next = lines[i + 1];\n if (next !== undefined && ITEM.test(next) && /\\d/.test(ITEM.exec(next)?.[2] ?? '') === ordered) {\n i++;\n continue;\n }\n break;\n }\n }\n out.push({ t: 'list', ordered, start, items });\n continue;\n }\n if (line.includes('|') && i + 1 < lines.length && TABLE_SEP.test(lines[i + 1]) && lines[i + 1].includes('-')) {\n const head = cells(line);\n const align = cells(lines[i + 1]).map((c) =>\n c.startsWith(':') && c.endsWith(':') ? 'center' : c.endsWith(':') ? 'right' : c.startsWith(':') ? 'left' : null,\n );\n const rows: string[][] = [];\n i += 2;\n while (i < lines.length && !blank(lines[i]) && lines[i].includes('|')) rows.push(cells(lines[i++]));\n out.push({ t: 'table', head, align, rows });\n continue;\n }\n // A paragraph: lines until a blank line or another block.\n const body = [line];\n i++;\n while (i < lines.length && !blank(lines[i]) && !startsBlock(lines[i])) body.push(lines[i++]);\n out.push({ t: 'p', text: body.join('\\n') });\n }\n return out;\n}\n\n/** Only http, https, mailto and relative addresses are kept; anything else (javascript:, data:) is not a link. */\nexport function safeHref(href: string): string | undefined {\n const h = href.trim();\n if (!h) return undefined;\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(h);\n if (!scheme) return h;\n return ['http', 'https', 'mailto'].includes(scheme[1].toLowerCase()) ? h : undefined;\n}\n\n// A path in inline code: folders and a file with an extension, or a file and line (src/app.c:86, docs/a.md).\nconst PATH = /^(?:\\.{1,2}\\/)?(?:[\\w.-]+\\/)*[\\w.-]+\\.[A-Za-z0-9]+(?::\\d+(?:-\\d+)?)?$/;\nconst isPath = (s: string) => PATH.test(s) && (s.includes('/') || /:\\d/.test(s));\n\n// Never links, even when listed in schemes.\nconst BLOCKED = ['javascript', 'data', 'vbscript'];\n\ninterface Ctx {\n /** Extra schemes (fn, file) handed to linkHref and onLink as they are. */\n schemes?: string[];\n /** The next key: counted from 0 on every render, so the same source gives the same keys. */\n k: () => string;\n linkHref?: (href: string) => string | undefined | null;\n onLink?: (href: string, e: React.MouseEvent<HTMLElement>) => void;\n refHref?: RefHref;\n onRef?: OnRef;\n terms?: readonly TermDef[];\n termsMark: TermsMark;\n /** All the words in one pattern; null without terms. */\n termRe: RegExp | null;\n /** Words already marked in this block (paragraph, list item, table cell). Absent: no words here (headings, link\n * text, a details summary). */\n seen?: Set<string>;\n}\n\n/** A new block: its own count of marked words. */\nconst block = (c: Ctx): Ctx => ({ ...c, seen: new Set() });\n/** No words marked inside (headings, link text, a summary button). */\nconst noTerms = (c: Ctx): Ctx => ({ ...c, seen: undefined });\n\nconst CJK = /[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\u3000-\\u303f\\uff00-\\uffef]/u;\n\n/** Inline Markdown: code spans, links, autolinks, bold, italic, hard breaks; HTML tags dropped, their text kept. */\nfunction inline(src: string, c: Ctx): React.ReactNode[] {\n let aiMark: string | null = null;\n const out: React.ReactNode[] = [];\n let text = '';\n const flush = () => {\n if (text && c.termRe && c.terms && c.seen) out.push(...withTerms(text, findTerms(text, c.terms, c.termRe, c.termsMark, c.seen), c.terms, c.k));\n else if (text) out.push(text);\n text = '';\n };\n let i = 0;\n while (i < src.length) {\n const ch = src[i];\n if (ch === '\\\\' && i + 1 < src.length && /[\\\\`*_{}[\\]()#+\\-.!|<>~]/.test(src[i + 1])) {\n text += src[i + 1];\n i += 2;\n continue;\n }\n if (ch === '\\\\' && src[i + 1] === '\\n') {\n flush();\n out.push(<br key={c.k()} />);\n i += 2;\n continue;\n }\n if (ch === '\\n') {\n // Two spaces before a line break make a break; otherwise it is a space.\n if (/ {2,}$/.test(text)) {\n text = text.replace(/ +$/, '');\n flush();\n out.push(<br key={c.k()} />);\n } else {\n // Lines joined: a space between words, none next to Chinese text or full-width punctuation.\n text = text.replace(/ +$/, '');\n const before = text.at(-1) ?? (typeof out.at(-1) === 'string' ? String(out.at(-1)).at(-1) : '');\n const after = src.slice(i + 1).trimStart()[0] ?? '';\n if (!CJK.test(before ?? '') && !CJK.test(after)) text += ' ';\n while (src[i + 1] === ' ') i++;\n }\n i++;\n continue;\n }\n if (ch === '`') {\n const run = /^`+/.exec(src.slice(i))?.[0] ?? '`';\n const end = src.indexOf(run, i + run.length);\n if (end > 0) {\n flush();\n let v = src.slice(i + run.length, end).replace(/\\n/g, ' ');\n if (/^ .* $/.test(v)) v = v.slice(1, -1);\n out.push(code(v, c));\n i = end + run.length;\n continue;\n }\n }\n if (ch === '<') {\n const auto = /^<((?:https?:|mailto:)[^\\s<>]+)>/i.exec(src.slice(i));\n if (auto) {\n flush();\n out.push(link(auto[1], [auto[1].replace(/^mailto:/i, '')], c));\n i += auto[0].length;\n continue;\n }\n const tag = /^<!--[\\s\\S]*?-->|^<\\/?[A-Za-z][\\w-]*(?:\\s[^<>]*)?\\/?>/.exec(src.slice(i));\n if (tag) {\n // MX: an HTML tag (or comment) is dropped; the text between tags stays.\n i += tag[0].length;\n continue;\n }\n }\n if (ch === '!' && src[i + 1] === '[') {\n // An image shows its alt text; nothing is loaded.\n const m = /^!\\[([^\\]]*)\\]\\([^)]*\\)/.exec(src.slice(i));\n if (m) {\n text += m[1];\n i += m[0].length;\n continue;\n }\n }\n if (ch === '[') {\n const m = matchLink(src, i);\n if (m) {\n // [AI](ai:) marks a paragraph, list item or cell written by AI: an AiMark at its end, wherever it is written.\n // Other words in the brackets, such as [推測](ai:), are shown in the same style.\n if (m.href.trim().toLowerCase() === 'ai:') {\n const words = m.text.trim();\n aiMark = words && words !== 'AI' ? words : '';\n i = m.end;\n if (src[i] === ' ') i++;\n continue;\n }\n flush();\n // [cookie](term:cookie) marks a word explicitly with its entry in terms.\n const termId = /^term:(.*)$/i.exec(m.href.trim())?.[1];\n if (termId !== undefined) {\n let id = termId;\n try {\n id = decodeURIComponent(termId);\n } catch {\n /* kept as written */\n }\n const t = c.terms?.find((x) => x.term === id);\n devWarn(!t, 'Markdown', `[${m.text}](term:${termId}) 找不到 terms 裡 term 為「${id}」的項目,只顯示文字。把它加進 terms,或改 term: 後面的字。`);\n c.seen?.add(id);\n out.push(t ? termNode(t, c.k(), inline(m.text, noTerms(c))) : <React.Fragment key={c.k()}>{inline(m.text, noTerms(c))}</React.Fragment>);\n i = m.end;\n continue;\n }\n // A link whose text is one code span ([`_sync_as`](fn:…)) is a name: accent monospace, no chip.\n const name = /^\\s*`([^`]+)`\\s*$/.exec(m.text)?.[1];\n out.push(link(m.href, inline(m.text, noTerms(c)), c, name));\n i = m.end;\n continue;\n }\n }\n if (ch === '*' || ch === '_') {\n const run = src[i + 1] === ch ? ch + ch : ch;\n // _ inside a word (snake_case) is not emphasis.\n const prev = src[i - 1];\n const intraword = ch === '_' && prev !== undefined && /\\w/.test(prev);\n const next = src[i + run.length];\n if (!intraword && next && !/\\s/.test(next)) {\n const end = findClose(src, i + run.length, run);\n if (end > 0) {\n flush();\n const inner = inline(src.slice(i + run.length, end), c);\n out.push(run.length === 2 ? <strong key={c.k()}>{inner}</strong> : <em key={c.k()}>{inner}</em>);\n i = end + run.length;\n continue;\n }\n }\n }\n text += ch;\n i++;\n }\n flush();\n if (aiMark != null) {\n // A trailing space before the mark is dropped; the mark keeps its own 8 px.\n const last = out[out.length - 1];\n if (typeof last === 'string') out[out.length - 1] = last.replace(/\\s+$/, '');\n out.push(<AiMark key={c.k()} text={aiMark || undefined} />);\n }\n return out;\n\n function code(v: string, ctx: Ctx): React.ReactNode {\n const onRef = ctx.onRef;\n if (isPath(v)) {\n // A file and line that points somewhere is a location: gray, one step smaller.\n const href = ctx.refHref?.(v) || undefined;\n const click = onRef\n ? (e: React.MouseEvent<HTMLElement>) => {\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onRef(v, e);\n }\n : undefined;\n if (href)\n return (\n <InlineCode key={ctx.k()} look=\"location\" href={href} onClick={click}>\n {v}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={ctx.k()} look=\"location\" onClick={click}>\n {v}\n </InlineCode>\n );\n }\n return <InlineCode key={ctx.k()}>{v}</InlineCode>;\n }\n}\n\nfunction matchLink(src: string, i: number): { text: string; href: string; end: number } | null {\n let depth = 0;\n let j = i;\n for (; j < src.length; j++) {\n if (src[j] === '\\\\') {\n j++;\n continue;\n }\n if (src[j] === '[') depth++;\n else if (src[j] === ']' && --depth === 0) break;\n }\n if (j >= src.length || src[j + 1] !== '(') return null;\n // The address may hold balanced parentheses (javascript:alert(1), wiki/Foo_(bar)); an optional \"title\" follows.\n let at = j + 2;\n while (src[at] === ' ') at++;\n let depth2 = 0;\n let href = '';\n for (; at < src.length; at++) {\n const ch = src[at];\n if (/\\s/.test(ch)) break;\n if (ch === '(') depth2++;\n else if (ch === ')') {\n if (depth2 === 0) break;\n depth2--;\n }\n href += ch;\n }\n const rest = /^(?:\\s+(?:\"[^\"]*\"|'[^']*'))?\\s*\\)/.exec(src.slice(at));\n if (!rest) return null;\n return { text: src.slice(i + 1, j), href: href.replace(/^<(.*)>$/, '$1'), end: at + rest[0].length };\n}\n\nfunction findClose(src: string, from: number, run: string): number {\n let j = from;\n while ((j = src.indexOf(run, j)) > 0) {\n const before = src[j - 1];\n const after = src[j + run.length];\n if (before && !/\\s/.test(before) && !(run[0] === '_' && after && /\\w/.test(after)) && !(run.length === 1 && after === run)) return j;\n j += run.length;\n }\n return -1;\n}\n\nfunction link(raw: string, children: React.ReactNode, c: Ctx, name?: string): React.ReactNode {\n // A scheme listed in schemes (fn:, file:) is up to linkHref and onLink: no address of its own.\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(raw.trim())?.[1].toLowerCase();\n const own = !!scheme && !BLOCKED.includes(scheme) && !!c.schemes?.some((x) => x.toLowerCase() === scheme);\n const safe = own ? raw.trim() : safeHref(raw);\n if (safe === undefined) return <React.Fragment key={c.k()}>{children}</React.Fragment>;\n const href = c.linkHref ? c.linkHref(safe) || undefined : own ? undefined : safe;\n if (!href && !c.onLink) return <React.Fragment key={c.k()}>{children}</React.Fragment>;\n const outside = !!href && /^https?:/i.test(href);\n const onLink = c.onLink;\n const click = onLink\n ? (e: React.MouseEvent<HTMLElement>) => {\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onLink(safe, e);\n }\n : undefined;\n if (name !== undefined && !(outside && !c.onLink)) {\n if (href)\n return (\n <InlineCode key={c.k()} look=\"name\" href={href} onClick={click}>\n {name}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={c.k()} look=\"name\" onClick={click}>\n {name}\n </InlineCode>\n );\n }\n if (!href)\n return (\n <button key={c.k()} type=\"button\" className=\"ui-md-link\" onClick={click}>\n {children}\n </button>\n );\n return (\n <a key={c.k()} className=\"ui-md-link\" href={href} onClick={click} {...(outside && !c.onLink ? { target: '_blank', rel: 'noopener noreferrer' } : {})}>\n {children}\n </a>\n );\n}\n\n// A fence's language name as CodeView knows it: ```python is py, ```bash is sh; file extensions work too (```ts).\nconst FENCE_LANG: Record<string, string> = {\n python: 'py',\n javascript: 'js',\n typescript: 'js',\n jsx: 'js',\n tsx: 'js',\n bash: 'sh',\n shell: 'sh',\n zsh: 'sh',\n console: 'sh',\n 'c++': 'c',\n};\nconst fenceLang = (l: string) => FENCE_LANG[l] ?? (languageOf('x.' + l) !== 'plain' ? languageOf('x.' + l) : l || 'plain');\n\n// A number cell's figures and its unit: [all, number, space, unit].\nconst NUM_UNIT = /^([-+]?(?:NT\\$\\s?)?[\\d,]+(?:\\.\\d+)?)(\\s?)(%|[A-Za-z]{1,3}|\\p{Script=Han}{1,2})$/u;\nconst NUM = /^[-+]?(?:NT\\$\\s?)?[\\d,]+(?:\\.\\d+)?\\s?(?:%|[A-Za-z]{1,3}|\\p{Script=Han}{1,2})?$/u;\n\nexport interface MarkdownProps {\n /** The Markdown text. */\n children: string;\n /** Only inline syntax (code, links, bold, italic), no paragraphs: for a one-line summary such as a README's first\n * sentence. Line breaks become spaces. */\n inline?: boolean;\n /** small: 13 px, for notes. Default: the same 16 px as the text around it. */\n size?: 'body' | 'small';\n /** The heading level `#` becomes. Default 4: # is an h4 (20 px), ## an h5, ### and deeper h6 (both 16 px bold). */\n topLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /** Link schemes of your own, such as ['fn', 'file']: [_sync_as](fn:harness/controller.py:VirtualRouter._sync_as)\n * goes to linkHref and onLink as written, which decide what it opens. javascript:, data: and vbscript: never link. */\n schemes?: string[];\n /** The address of a link (after the http, https, mailto or relative check); return undefined for no link. */\n linkHref?: (href: string) => string | undefined | null;\n /** A plain click on a link (the default navigation is prevented; Ctrl, ⌘ or Shift still open linkHref). */\n onLink?: (href: string, e: React.MouseEvent<HTMLElement>) => void;\n /** Inline code that is a path (harness/routing.py:108, docs/a.md) and paths in code blocks: their link. Same as\n * CodeView's refHref. */\n refHref?: RefHref;\n /** A plain click on such a path. Same as CodeView's onRef. */\n onRef?: OnRef;\n /** Words that get an explanation (Term variant=\"inline\"): matched whole and case-sensitive in plain text, not in\n * inline code, link text or headings; fenced code blocks match them in comments and strings. `[cookie](term:cookie)`\n * marks one explicitly, wherever it is. */\n terms?: readonly TermDef[];\n /** 'first' (default): each word only where it first appears in a paragraph, list item or table cell. 'all': everywhere. */\n termsMark?: TermsMark;\n className?: string;\n}\n\n/** Markdown from project documents and code comments, in the system's own type, code and table styles. Never runs HTML:\n * tags are dropped and their text kept; links only to http, https, mailto and relative addresses. */\nexport function Markdown(p: MarkdownProps) {\n // Keys count from 0 on every render, so the same source gives the same keys and nothing remounts.\n let n = 0;\n const termsMark = p.termsMark ?? 'first';\n const termRe = React.useMemo(() => termPattern(p.terms), [p.terms]);\n const c: Ctx = {\n k: () => 'm' + n++,\n schemes: p.schemes,\n linkHref: p.linkHref,\n onLink: p.onLink,\n refHref: p.refHref,\n onRef: p.onRef,\n terms: p.terms,\n termsMark,\n termRe,\n };\n const src = String(p.children ?? '').replace(/\\r\\n?/g, '\\n');\n const cls = cx('ui-md', p.size === 'small' && 'is-small', p.className);\n if (p.inline) return <span className={cx(cls, 'is-inline')}>{inline(src.trim().replace(/\\n\\s*\\n/g, '\\n'), block(c))}</span>;\n const top = p.topLevel ?? 4;\n const render = (blocks: Block[]): React.ReactNode[] =>\n blocks.map((b) => {\n switch (b.t) {\n case 'h': {\n const H = `h${Math.min(6, top + b.level - 1)}` as 'h4';\n return (\n <H key={c.k()} className=\"ui-md-h\">\n {inline(b.text, noTerms(c))}\n </H>\n );\n }\n case 'p':\n return <p key={c.k()}>{inline(b.text, block(c))}</p>;\n case 'hr':\n return <hr key={c.k()} />;\n case 'details':\n return (\n <MdDetails key={c.k()} summary={inline(b.summary, noTerms(c))}>\n {render(b.blocks)}\n </MdDetails>\n );\n case 'alert':\n return (\n <Alert key={c.k()} tone={b.tone} className=\"ui-md-alert\">\n {render(b.blocks)}\n </Alert>\n );\n case 'quote':\n return <blockquote key={c.k()}>{render(b.blocks)}</blockquote>;\n case 'list': {\n const items = b.items.map((it) => <li key={c.k()}>{it.length === 1 && it[0].t === 'p' ? inline(it[0].text, block(c)) : render(it)}</li>);\n return b.ordered ? (\n <ol key={c.k()} start={b.start === 1 ? undefined : b.start}>\n {items}\n </ol>\n ) : (\n <ul key={c.k()}>{items}</ul>\n );\n }\n case 'code':\n return (\n <CodeView\n key={c.k()}\n className=\"ui-md-code\"\n code={b.code}\n language={fenceLang(b.lang)}\n languageLabel={b.lang ? undefined : false}\n copy\n lineNumbers={false}\n refHref={p.refHref}\n onRef={p.onRef}\n terms={p.terms}\n termsMark={termsMark}\n />\n );\n case 'table': {\n // Numbers right-aligned: a column whose cells are all numbers, unless the source sets its alignment.\n const n = b.head.length;\n const numeric = b.head.map((_, j) => b.rows.length > 0 && b.rows.every((r) => !r[j] || NUM.test(r[j])));\n const align = (j: number): React.CSSProperties | undefined => {\n const a = b.align[j] ?? (numeric[j] ? 'right' : null);\n return a ? { textAlign: a } : undefined;\n };\n return (\n <MdTable\n key={c.k()}\n label={b.head.map(plain).join('、')}\n heads={b.head.map((h) => inline(h, noTerms(c)))}\n headText={b.head.map(plain)}\n rows={b.rows.map((r) =>\n Array.from({ length: n }, (_, j) => {\n // A number column: the figures in Geist Mono (td.is-num), the unit (「46 分」「3.5 GB」) in the text font.\n const u = numeric[j] ? NUM_UNIT.exec(r[j] ?? '') : null;\n return u ? (\n <>\n {inline(u[1], block(c))}\n {u[2]}\n <span className=\"ui-unit\">{u[3]}</span>\n </>\n ) : (\n inline(r[j] ?? '', block(c))\n );\n }),\n )}\n numeric={numeric}\n align={align}\n />\n );\n }\n }\n });\n return <div className={cls}>{render(parse(src.split('\\n')))}</div>;\n}\n\n/** A header cell as plain text, for the label above each value when a narrow table turns into cards. */\nconst plain = (md: string) =>\n md\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/[`*_]/g, '')\n .trim();\n\n/** DA: a <details> block: a button with the summary, closed at first. The closed content stays in the page\n * (hidden=\"until-found\"), so the browser's find opens it, as in Section. */\nfunction MdDetails({ summary, children }: { summary: React.ReactNode; children: React.ReactNode }) {\n const [open, setOpen] = React.useState(false);\n const id = React.useId();\n const body = React.useRef<HTMLDivElement>(null);\n React.useLayoutEffect(() => {\n const el = body.current;\n if (!el) return;\n if (open) {\n el.removeAttribute('hidden');\n return;\n }\n el.setAttribute('hidden', 'until-found');\n const found = () => setOpen(true);\n el.addEventListener('beforematch', found);\n return () => el.removeEventListener('beforematch', found);\n }, [open]);\n return (\n <div className={cx('ui-md-details', open && 'is-open')}>\n <button type=\"button\" className=\"ui-md-summary\" aria-expanded={open} aria-controls={id} onClick={() => setOpen(!open)}>\n <Icon name=\"caret-right\" size={16} className=\"ui-md-caret\" />\n <span>{summary}</span>\n </button>\n <div id={id} ref={body} className=\"ui-md-details-body\">\n {children}\n </div>\n </div>\n );\n}\n\n/** A Markdown table: column borders in the header drag; the corner button shows the whole table in a wide dialog.\n * Under 480 px every row is a card instead, without either. The border, the dialog and the copy icon are the same as\n * DataTable's (internal/tableTools). */\nfunction MdTable(p: {\n label: string;\n heads: React.ReactNode[];\n headText: string[];\n rows: React.ReactNode[][];\n numeric: boolean[];\n align: (j: number) => React.CSSProperties | undefined;\n}) {\n const [widths, setWidths] = React.useState<number[] | null>(null);\n const [big, setBig] = React.useState(false);\n const [dragging, setDragging] = React.useState(false);\n const table = React.useRef<HTMLTableElement>(null);\n // Rounded up: a fixed column a fraction of a pixel narrower than it was drawn would wrap its longest word.\n const measure = () => [...(table.current?.querySelectorAll<HTMLElement>('thead th') ?? [])].map((th) => Math.ceil(th.getBoundingClientRect().width));\n // The drawn widths, kept for the borders' aria-valuenow (refs are not read while rendering).\n const [measured, setMeasured] = React.useState<number[]>([]);\n React.useLayoutEffect(() => {\n const el = table.current;\n if (!el) return;\n const update = () => {\n const m = [...el.querySelectorAll<HTMLElement>('thead th')].map((th) => Math.ceil(th.getBoundingClientRect().width));\n setMeasured((old) => (old.length === m.length && old.every((v, i) => v === m[i]) ? old : m));\n };\n update();\n const ro = resizeObserver(update);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const body = (resize: boolean) => (\n <table\n ref={resize ? table : undefined}\n className=\"ui-md-table\"\n style={resize && widths ? { width: widths.reduce((a, b) => a + b, 0), tableLayout: 'fixed', minWidth: 0 } : undefined}\n >\n {resize && widths ? (\n <colgroup>\n {widths.map((w, j) => (\n <col key={j} style={{ width: w }} />\n ))}\n </colgroup>\n ) : null}\n <thead>\n <tr>\n {p.heads.map((h, j) => (\n <th key={j} style={p.align(j)}>\n {h}\n {resize ? (\n <ColResize\n name={p.headText[j]}\n width={widths?.[j] ?? measured[j] ?? 0}\n start={() => (widths ?? measure())[j]}\n onWidth={(w) => {\n const next = (widths ?? measure()).slice();\n next[j] = w;\n setWidths(next);\n }}\n onReset={() => setWidths(null)}\n onDragging={setDragging}\n />\n ) : null}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {p.rows.map((r, ri) => (\n <tr key={ri}>\n {r.map((cell, j) => (\n <td key={j} className={p.numeric[j] ? 'is-num' : undefined} style={p.align(j)} data-label={p.headText[j]}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n return (\n <div className={cx('ui-md-tablebox', dragging && 'is-resizing')}>\n <div className=\"ui-md-table-tools\">\n <ZoomButton onClick={() => setBig(true)} />\n </div>\n <div className=\"ui-md-table-wrap\" tabIndex={0} role=\"region\" aria-label={p.label}>\n {body(true)}\n </div>\n <TableDialog open={big} onClose={() => setBig(false)}>\n <div className=\"ui-md ui-md-table-wrap\" tabIndex={0} role=\"region\" aria-label={p.label}>\n {body(false)}\n </div>\n </TableDialog>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,aAAaA,mBAAY;AAiBzB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,UAAU;AAEhB,MAAM,QAAQ;AACd,MAAM,aAAwC;CAAE,MAAM;CAAQ,KAAK;CAAW,WAAW;CAAQ,SAAS;CAAW,SAAS;AAAS;AAEvI,MAAM,QAAQ;AACd,MAAM,UAAU;AAChB,MAAM,KAAK;AACX,MAAM,OAAO;AACb,MAAM,QAAQ;AACd,MAAM,YAAY;AAElB,SAAS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K,WAAW,GAAG,kBAAkB,YAAY,aAAa;EAA9D,UAAA;GACE,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,YAAD,EAAY,eAAe,OAAO,IAAI,EAAI,CAAA;GACvC,CAAA;GACL,oBAAC,OAAD;IAAK,WAAU;IAAmB,UAAU;IAAG,MAAK;IAAS,cAAY,EAAE;IACxE,UAAA,KAAK,IAAI;GACP,CAAA;GACL,oBAAC,aAAD;IAAa,MAAM;IAAK,eAAe,OAAO,KAAK;IACjD,UAAA,oBAAC,OAAD;KAAK,WAAU;KAAyB,UAAU;KAAG,MAAK;KAAS,cAAY,EAAE;KAC9E,UAAA,KAAK,KAAK;IACR,CAAA;GACM,CAAA;EACV;;AAET"}
@@ -84,7 +84,7 @@ function Section(p) {
84
84
  const check = () => {
85
85
  if (decodeURIComponent(location.hash.slice(1)) !== p.id) return;
86
86
  if (!openRef.current) setRef.current(true);
87
- requestAnimationFrame(() => head.current?.scrollIntoView({
87
+ requestAnimationFrame(() => head.current?.scrollIntoView?.({
88
88
  block: "start",
89
89
  behavior: reduced() ? "auto" : "smooth"
90
90
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"Section.js","names":["phArrowsInLineVertical","phArrowsOutLineVertical","phCaretRight"],"sources":["../../../src/components/Section/Section.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Icon } from '../../icons/Icon';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { IconButton } from '../IconButton/IconButton';\nimport { includeIcons } from '../../icons/store';\nimport phArrowsInLineVertical from '../../icons/ph/arrows-in-line-vertical';\nimport phArrowsOutLineVertical from '../../icons/ph/arrows-out-line-vertical';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phArrowsInLineVertical, phArrowsOutLineVertical, phCaretRight);\n\n/** What a SectionGroup shares with its sections: the last 「全部展開/全部收合」 and who is open. */\ninterface GroupCtx {\n /** Bumped on every 「全部展開/全部收合」, with the state it asked for. */\n all: { n: number; open: boolean };\n report: (key: string, open: boolean | null) => void;\n /** Some section is closed (or none reported yet): the toggle opens all; otherwise it closes all. */\n anyClosed: boolean;\n setAll: (open: boolean) => void;\n}\nconst Group = React.createContext<GroupCtx | null>(null);\n\n// SA: the open and close animation, the same as TreeList's children growing out of a folder.\nconst MOVE_MS = 260;\n\nconst reduced = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\nfunction readStored(key: string | undefined): boolean | undefined {\n if (!key) return undefined;\n try {\n const v = localStorage.getItem('ui-section:' + key);\n return v === '1' ? true : v === '0' ? false : undefined;\n } catch {\n return undefined;\n }\n}\nfunction writeStored(key: string | undefined, open: boolean) {\n if (!key) return;\n try {\n localStorage.setItem('ui-section:' + key, open ? '1' : '0');\n } catch {\n // Storage blocked or full: works the same, it only does not remember.\n }\n}\n\nexport interface SectionProps {\n /** The heading, 20 px bold (h4 size), above the 16 px content. */\n title: React.ReactNode;\n /** One line of key numbers right of the title, shown open or closed: 「29 個指令、4 個 namespace、3 個沒有逾時」.\n * Muted, cut with 「…」 when it does not fit. Part of the button: no links or buttons in it. */\n summary?: React.ReactNode;\n /** Uncontrolled: open at first. Default false. A stored state (storageKey) wins. */\n defaultOpen?: boolean;\n /** Controlled: open or closed; pair with onOpenChange. */\n open?: boolean;\n /** Called with the new state when the title is clicked, the address jumps here, or 「全部展開/全部收合」. */\n onOpenChange?: (open: boolean) => void;\n /** Anchor. When the address hash (or a link in the page) points at this id, the section opens and scrolls to its title. */\n id?: string;\n /** Closed: the content is not rendered at all. Default false: it stays in the page hidden, and the browser's find\n * (Ctrl+F) opens the section when it finds text in it. Set it on very long sections. */\n lazy?: boolean;\n /** Remembers open or closed in localStorage under this key. If storage fails it works the same, without remembering. */\n storageKey?: string;\n /** Controls right of the summary, such as a copy IconButton. Outside the title button: clicking them does not open\n * or close the section. */\n actions?: React.ReactNode;\n /** Heading level of the title. Default 3. The size stays 20 px whatever the level. */\n level?: 2 | 3 | 4 | 5 | 6;\n children?: React.ReactNode;\n className?: string;\n}\n\n/** A part of a page that can be closed: the title and a one-line summary stay visible. A line between sections;\n * the caret left of the title turns when it opens (260 ms, none with reduced motion). */\nexport function Section(p: SectionProps) {\n const group = React.useContext(Group);\n const uid = React.useId();\n const [own, setOwn] = React.useState(() => readStored(p.storageKey) ?? p.defaultOpen ?? false);\n const open = p.open ?? own;\n const set = React.useCallback(\n (v: boolean) => {\n if (p.open === undefined) setOwn(v);\n writeStored(p.storageKey, v);\n p.onOpenChange?.(v);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [p.open, p.storageKey, p.onOpenChange],\n );\n const setRef = React.useRef(set);\n const openRef = React.useRef(open);\n React.useLayoutEffect(() => {\n setRef.current = set;\n openRef.current = open;\n });\n\n // Lazy content stays mounted until the closing animation ends, so it has something to shrink.\n const [prevOpen, setPrevOpen] = React.useState(open);\n const [linger, setLinger] = React.useState(false);\n if (prevOpen !== open) {\n setPrevOpen(open);\n setLinger(!open);\n }\n React.useEffect(() => {\n if (!linger) return;\n const t = window.setTimeout(() => setLinger(false), reduced() ? 0 : MOVE_MS);\n return () => window.clearTimeout(t);\n }, [linger]);\n\n // Not lazy: closed content is hidden=\"until-found\", so the browser's find still reaches it and opens the section.\n const inner = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n const el = inner.current;\n if (!el || p.lazy) return;\n if (open) {\n el.removeAttribute('hidden');\n return;\n }\n const t = window.setTimeout(() => el.setAttribute('hidden', 'until-found'), reduced() ? 0 : MOVE_MS);\n const found = () => setRef.current(true);\n el.addEventListener('beforematch', found);\n return () => {\n window.clearTimeout(t);\n el.removeEventListener('beforematch', found);\n };\n }, [open, p.lazy]);\n\n // The address points here: open and scroll to the title.\n const head = React.useRef<HTMLHeadingElement>(null);\n React.useEffect(() => {\n if (!p.id) return;\n const check = () => {\n if (decodeURIComponent(location.hash.slice(1)) !== p.id) return;\n if (!openRef.current) setRef.current(true);\n requestAnimationFrame(() => head.current?.scrollIntoView({ block: 'start', behavior: reduced() ? 'auto' : 'smooth' }));\n };\n check();\n window.addEventListener('hashchange', check);\n return () => window.removeEventListener('hashchange', check);\n }, [p.id]);\n\n // 「全部展開/全部收合」 from the group, and this section's state reported back to it.\n const seen = React.useRef(group?.all.n ?? 0);\n React.useEffect(() => {\n if (!group || group.all.n === seen.current) return;\n seen.current = group.all.n;\n if (group.all.open !== openRef.current) setRef.current(group.all.open);\n }, [group, group?.all.n, group?.all.open]);\n const report = group?.report;\n React.useEffect(() => {\n report?.(uid, open);\n }, [report, uid, open]);\n React.useEffect(() => () => report?.(uid, null), [report, uid]);\n\n const H = `h${p.level ?? 3}` as 'h3';\n const body = uid + '-body';\n const showContent = !p.lazy || open || linger;\n return (\n <section id={p.id} className={cx('ui-sec', open && 'is-open', p.className)}>\n <div className=\"ui-sec-row\">\n <H ref={head} className=\"ui-sec-h\">\n <button type=\"button\" className=\"ui-sec-btn\" aria-expanded={open} aria-controls={body} onClick={() => set(!open)}>\n <Icon name=\"caret-right\" size={18} className=\"ui-sec-caret\" />\n <span className=\"ui-sec-title\">{p.title}</span>\n {p.summary != null && p.summary !== false ? <span className=\"ui-sec-sum\">{p.summary}</span> : null}\n </button>\n </H>\n {p.actions ? <div className=\"ui-sec-actions\">{p.actions}</div> : null}\n </div>\n <div id={body} className=\"ui-sec-body\">\n <div ref={inner} className=\"ui-sec-in\">\n {showContent ? <div className=\"ui-sec-content\">{p.children}</div> : null}\n </div>\n </div>\n </section>\n );\n}\n\nexport interface SectionGroupProps {\n /** Sections. One icon button above them on the right opens them all, or closes them all once all are open\n * (「全部展開」「全部收合」 as its tooltip and name). */\n children?: React.ReactNode;\n /** More controls on the same row, left of the button. */\n actions?: React.ReactNode;\n /** false: no row above the sections; put <SectionGroupToggle /> where you want it, such as the card's title row next\n * to its other icon buttons. It must be inside the SectionGroup. Default true. */\n bar?: boolean;\n className?: string;\n}\n\n/** A run of Sections with one 「全部展開/全部收合」 icon button. */\nexport function SectionGroup({ children, actions, bar = true, className }: SectionGroupProps) {\n const [all, setAllState] = React.useState({ n: 0, open: false });\n const [states, setStates] = React.useState<Record<string, boolean>>({});\n const report = React.useCallback((key: string, open: boolean | null) => {\n setStates((s) => {\n if (open === null) return key in s ? Object.fromEntries(Object.entries(s).filter(([id]) => id !== key)) : s;\n return s[key] === open ? s : { ...s, [key]: open };\n });\n }, []);\n const setAll = React.useCallback((open: boolean) => setAllState((a) => ({ n: a.n + 1, open })), []);\n const vals = Object.values(states);\n const anyClosed = vals.length === 0 || vals.some((v) => !v);\n const ctx = React.useMemo(() => ({ all, report, anyClosed, setAll }), [all, report, anyClosed, setAll]);\n return (\n <Group.Provider value={ctx}>\n <div className={cx('ui-sec-group', className)}>\n {bar ? (\n <div className=\"ui-sec-bar\">\n {actions ?? null}\n <SectionGroupToggle />\n </div>\n ) : null}\n {children}\n </div>\n </Group.Provider>\n );\n}\n\nexport interface SectionGroupToggleProps {\n className?: string;\n}\n\n/** GB: the 「全部展開/全部收合」 icon button of the SectionGroup around it, for a place of your own (with bar={false}).\n * Opens every section while any is closed, else closes them all; its tooltip and name say which. */\nexport function SectionGroupToggle({ className }: SectionGroupToggleProps) {\n const g = React.useContext(Group);\n if (!g) return null;\n const open = g.anyClosed;\n return (\n <IconButton\n className={cx('ui-sec-toggle', className)}\n icon={open ? 'arrows-out-line-vertical' : 'arrows-in-line-vertical'}\n label={open ? tr('全部展開') : tr('全部收合')}\n onClick={() => g.setAll(open)}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAUA,aAAaA,iCAAwBC,kCAAyBC,mBAAY;AAW1E,MAAM,QAAQ,MAAM,cAA+B,IAAI;AAGvD,MAAM,UAAU;AAEhB,MAAM,gBAAgB,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;AAEzG,SAAS,WAAW,KAA8C;CAChE,IAAI,CAAC,KAAK,OAAO,KAAA;CACjB,IAAI;EACF,MAAM,IAAI,aAAa,QAAQ,gBAAgB,GAAG;EAClD,OAAO,MAAM,MAAM,OAAO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E,WAAW,MAAM;GACf,IAAI,SAAS,MAAM,OAAO,OAAO,IAAI,OAAO,YAAY,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,OAAO,GAAG,CAAC,IAAI;GAC1G,OAAO,EAAE,SAAS,OAAO,IAAI;IAAE,GAAG;KAAI,MAAM;GAAK;EACnD,CAAC;CACH,GAAG,CAAC,CAAC;CACL,MAAM,SAAS,MAAM,aAAa,SAAkB,aAAa,OAAO;EAAE,GAAG,EAAE,IAAI;EAAG;CAAK,EAAE,GAAG,CAAC,CAAC;CAClG,MAAM,OAAO,OAAO,OAAO,MAAM;CACjC,MAAM,YAAY,KAAK,WAAW,KAAK,KAAK,MAAM,MAAM,CAAC,CAAC;CAC1D,MAAM,MAAM,MAAM,eAAe;EAAE;EAAK;EAAQ;EAAW;CAAO,IAAI;EAAC;EAAK;EAAQ;EAAW;CAAM,CAAC;CACtG,OACE,oBAAC,MAAM,UAAP;EAAgB,OAAO;EACrB,UAAA,qBAAC,OAAD;GAAK,WAAW,GAAG,gBAAgB,SAAS;GAA5C,UAAA,CACG,MACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,WAAW,MACZ,oBAAC,oBAAD,CAAqB,CAAA,CAClB;GACH,CAAA,IAAA,MACH,QACE;;CACS,CAAA;AAEpB;;;AAQA,SAAgB,mBAAmB,EAAE,aAAsC;CACzE,MAAM,IAAI,MAAM,WAAW,KAAK;CAChC,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,OAAO,EAAE;CACf,OACE,oBAAC,YAAD;EACE,WAAW,GAAG,iBAAiB,SAAS;EACxC,MAAM,OAAO,6BAA6B;EAC1C,OAAO,OAAO,GAAG,MAAM,IAAI,GAAG,MAAM;EACpC,eAAe,EAAE,OAAO,IAAI;CAC7B,CAAA;AAEL"}
1
+ {"version":3,"file":"Section.js","names":["phArrowsInLineVertical","phArrowsOutLineVertical","phCaretRight"],"sources":["../../../src/components/Section/Section.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Icon } from '../../icons/Icon';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { IconButton } from '../IconButton/IconButton';\nimport { includeIcons } from '../../icons/store';\nimport phArrowsInLineVertical from '../../icons/ph/arrows-in-line-vertical';\nimport phArrowsOutLineVertical from '../../icons/ph/arrows-out-line-vertical';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phArrowsInLineVertical, phArrowsOutLineVertical, phCaretRight);\n\n/** What a SectionGroup shares with its sections: the last 「全部展開/全部收合」 and who is open. */\ninterface GroupCtx {\n /** Bumped on every 「全部展開/全部收合」, with the state it asked for. */\n all: { n: number; open: boolean };\n report: (key: string, open: boolean | null) => void;\n /** Some section is closed (or none reported yet): the toggle opens all; otherwise it closes all. */\n anyClosed: boolean;\n setAll: (open: boolean) => void;\n}\nconst Group = React.createContext<GroupCtx | null>(null);\n\n// SA: the open and close animation, the same as TreeList's children growing out of a folder.\nconst MOVE_MS = 260;\n\nconst reduced = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\nfunction readStored(key: string | undefined): boolean | undefined {\n if (!key) return undefined;\n try {\n const v = localStorage.getItem('ui-section:' + key);\n return v === '1' ? true : v === '0' ? false : undefined;\n } catch {\n return undefined;\n }\n}\nfunction writeStored(key: string | undefined, open: boolean) {\n if (!key) return;\n try {\n localStorage.setItem('ui-section:' + key, open ? '1' : '0');\n } catch {\n // Storage blocked or full: works the same, it only does not remember.\n }\n}\n\nexport interface SectionProps {\n /** The heading, 20 px bold (h4 size), above the 16 px content. */\n title: React.ReactNode;\n /** One line of key numbers right of the title, shown open or closed: 「29 個指令、4 個 namespace、3 個沒有逾時」.\n * Muted, cut with 「…」 when it does not fit. Part of the button: no links or buttons in it. */\n summary?: React.ReactNode;\n /** Uncontrolled: open at first. Default false. A stored state (storageKey) wins. */\n defaultOpen?: boolean;\n /** Controlled: open or closed; pair with onOpenChange. */\n open?: boolean;\n /** Called with the new state when the title is clicked, the address jumps here, or 「全部展開/全部收合」. */\n onOpenChange?: (open: boolean) => void;\n /** Anchor. When the address hash (or a link in the page) points at this id, the section opens and scrolls to its title. */\n id?: string;\n /** Closed: the content is not rendered at all. Default false: it stays in the page hidden, and the browser's find\n * (Ctrl+F) opens the section when it finds text in it. Set it on very long sections. */\n lazy?: boolean;\n /** Remembers open or closed in localStorage under this key. If storage fails it works the same, without remembering. */\n storageKey?: string;\n /** Controls right of the summary, such as a copy IconButton. Outside the title button: clicking them does not open\n * or close the section. */\n actions?: React.ReactNode;\n /** Heading level of the title. Default 3. The size stays 20 px whatever the level. */\n level?: 2 | 3 | 4 | 5 | 6;\n children?: React.ReactNode;\n className?: string;\n}\n\n/** A part of a page that can be closed: the title and a one-line summary stay visible. A line between sections;\n * the caret left of the title turns when it opens (260 ms, none with reduced motion). */\nexport function Section(p: SectionProps) {\n const group = React.useContext(Group);\n const uid = React.useId();\n const [own, setOwn] = React.useState(() => readStored(p.storageKey) ?? p.defaultOpen ?? false);\n const open = p.open ?? own;\n const set = React.useCallback(\n (v: boolean) => {\n if (p.open === undefined) setOwn(v);\n writeStored(p.storageKey, v);\n p.onOpenChange?.(v);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [p.open, p.storageKey, p.onOpenChange],\n );\n const setRef = React.useRef(set);\n const openRef = React.useRef(open);\n React.useLayoutEffect(() => {\n setRef.current = set;\n openRef.current = open;\n });\n\n // Lazy content stays mounted until the closing animation ends, so it has something to shrink.\n const [prevOpen, setPrevOpen] = React.useState(open);\n const [linger, setLinger] = React.useState(false);\n if (prevOpen !== open) {\n setPrevOpen(open);\n setLinger(!open);\n }\n React.useEffect(() => {\n if (!linger) return;\n const t = window.setTimeout(() => setLinger(false), reduced() ? 0 : MOVE_MS);\n return () => window.clearTimeout(t);\n }, [linger]);\n\n // Not lazy: closed content is hidden=\"until-found\", so the browser's find still reaches it and opens the section.\n const inner = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n const el = inner.current;\n if (!el || p.lazy) return;\n if (open) {\n el.removeAttribute('hidden');\n return;\n }\n const t = window.setTimeout(() => el.setAttribute('hidden', 'until-found'), reduced() ? 0 : MOVE_MS);\n const found = () => setRef.current(true);\n el.addEventListener('beforematch', found);\n return () => {\n window.clearTimeout(t);\n el.removeEventListener('beforematch', found);\n };\n }, [open, p.lazy]);\n\n // The address points here: open and scroll to the title.\n const head = React.useRef<HTMLHeadingElement>(null);\n React.useEffect(() => {\n if (!p.id) return;\n const check = () => {\n if (decodeURIComponent(location.hash.slice(1)) !== p.id) return;\n if (!openRef.current) setRef.current(true);\n requestAnimationFrame(() => head.current?.scrollIntoView?.({ block: 'start', behavior: reduced() ? 'auto' : 'smooth' }));\n };\n check();\n window.addEventListener('hashchange', check);\n return () => window.removeEventListener('hashchange', check);\n }, [p.id]);\n\n // 「全部展開/全部收合」 from the group, and this section's state reported back to it.\n const seen = React.useRef(group?.all.n ?? 0);\n React.useEffect(() => {\n if (!group || group.all.n === seen.current) return;\n seen.current = group.all.n;\n if (group.all.open !== openRef.current) setRef.current(group.all.open);\n }, [group, group?.all.n, group?.all.open]);\n const report = group?.report;\n React.useEffect(() => {\n report?.(uid, open);\n }, [report, uid, open]);\n React.useEffect(() => () => report?.(uid, null), [report, uid]);\n\n const H = `h${p.level ?? 3}` as 'h3';\n const body = uid + '-body';\n const showContent = !p.lazy || open || linger;\n return (\n <section id={p.id} className={cx('ui-sec', open && 'is-open', p.className)}>\n <div className=\"ui-sec-row\">\n <H ref={head} className=\"ui-sec-h\">\n <button type=\"button\" className=\"ui-sec-btn\" aria-expanded={open} aria-controls={body} onClick={() => set(!open)}>\n <Icon name=\"caret-right\" size={18} className=\"ui-sec-caret\" />\n <span className=\"ui-sec-title\">{p.title}</span>\n {p.summary != null && p.summary !== false ? <span className=\"ui-sec-sum\">{p.summary}</span> : null}\n </button>\n </H>\n {p.actions ? <div className=\"ui-sec-actions\">{p.actions}</div> : null}\n </div>\n <div id={body} className=\"ui-sec-body\">\n <div ref={inner} className=\"ui-sec-in\">\n {showContent ? <div className=\"ui-sec-content\">{p.children}</div> : null}\n </div>\n </div>\n </section>\n );\n}\n\nexport interface SectionGroupProps {\n /** Sections. One icon button above them on the right opens them all, or closes them all once all are open\n * (「全部展開」「全部收合」 as its tooltip and name). */\n children?: React.ReactNode;\n /** More controls on the same row, left of the button. */\n actions?: React.ReactNode;\n /** false: no row above the sections; put <SectionGroupToggle /> where you want it, such as the card's title row next\n * to its other icon buttons. It must be inside the SectionGroup. Default true. */\n bar?: boolean;\n className?: string;\n}\n\n/** A run of Sections with one 「全部展開/全部收合」 icon button. */\nexport function SectionGroup({ children, actions, bar = true, className }: SectionGroupProps) {\n const [all, setAllState] = React.useState({ n: 0, open: false });\n const [states, setStates] = React.useState<Record<string, boolean>>({});\n const report = React.useCallback((key: string, open: boolean | null) => {\n setStates((s) => {\n if (open === null) return key in s ? Object.fromEntries(Object.entries(s).filter(([id]) => id !== key)) : s;\n return s[key] === open ? s : { ...s, [key]: open };\n });\n }, []);\n const setAll = React.useCallback((open: boolean) => setAllState((a) => ({ n: a.n + 1, open })), []);\n const vals = Object.values(states);\n const anyClosed = vals.length === 0 || vals.some((v) => !v);\n const ctx = React.useMemo(() => ({ all, report, anyClosed, setAll }), [all, report, anyClosed, setAll]);\n return (\n <Group.Provider value={ctx}>\n <div className={cx('ui-sec-group', className)}>\n {bar ? (\n <div className=\"ui-sec-bar\">\n {actions ?? null}\n <SectionGroupToggle />\n </div>\n ) : null}\n {children}\n </div>\n </Group.Provider>\n );\n}\n\nexport interface SectionGroupToggleProps {\n className?: string;\n}\n\n/** GB: the 「全部展開/全部收合」 icon button of the SectionGroup around it, for a place of your own (with bar={false}).\n * Opens every section while any is closed, else closes them all; its tooltip and name say which. */\nexport function SectionGroupToggle({ className }: SectionGroupToggleProps) {\n const g = React.useContext(Group);\n if (!g) return null;\n const open = g.anyClosed;\n return (\n <IconButton\n className={cx('ui-sec-toggle', className)}\n icon={open ? 'arrows-out-line-vert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AA;AAEpB;;;AAQA,SAAgB,mBAAmB,EAAE,aAAsC;CACzE,MAAM,IAAI,MAAM,WAAW,KAAK;CAChC,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,OAAO,EAAE;CACf,OACE,oBAAC,YAAD;EACE,WAAW,GAAG,iBAAiB,SAAS;EACxC,MAAM,OAAO,6BAA6B;EAC1C,OAAO,OAAO,GAAG,MAAM,IAAI,GAAG,MAAM;EACpC,eAAe,EAAE,OAAO,IAAI;CAC7B,CAAA;AAEL"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { dropTransition } from "../../motion.js";
3
- import { browserKey, cx } from "../../internal/util.js";
3
+ import { browserKey, cx, resizeObserver } from "../../internal/util.js";
4
4
  import { devWarn } from "../../internal/dev.js";
5
5
  import { IconOf } from "../../icons/Icon.js";
6
6
  import { Tooltip } from "../Tooltip/Tooltip.js";
@@ -24,9 +24,9 @@ function SegmentedControl({ items, value, onChange, label, iconOnly = false, cla
24
24
  width: el.offsetWidth
25
25
  });
26
26
  measure();
27
- const ro = new ResizeObserver(measure);
28
- ro.observe(el);
29
- return () => ro.disconnect();
27
+ const ro = resizeObserver(measure);
28
+ ro?.observe(el);
29
+ return () => ro?.disconnect();
30
30
  }, [idx, items.length]);
31
31
  const go = (i) => {
32
32
  if (i === idx || !items[i]) return;
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.js","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dropTransition } from '../../motion';\nimport { cx, browserKey } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { IconOf, type IconSource } from '../../icons/Icon';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport interface SegmentedItem<V extends string = string> {\n id: V;\n /** The words: shown, or with `iconOnly` the tooltip and what screen readers say. */\n label: string;\n /** Phosphor icon name or element; required with `iconOnly`. */\n icon?: IconSource;\n}\n\nexport interface SegmentedControlProps<V extends string = string> {\n items: SegmentedItem<V>[];\n value: V;\n onChange?: (id: V) => void;\n /** What the choice is about, for screen readers, e.g. 「顯示方式」. */\n label: string;\n /** Icons only, 28 px each, the words in a tooltip; for a bar such as Workbench's mainBar. Default false. */\n iconOnly?: boolean;\n className?: string;\n}\n\n/** A small switch between two or three ways of showing the same thing (預覽/原始碼), 28 px tall to sit in a toolbar\n * or Workbench's mainBar. The selected part is a raised white pill that slides; ← → move and pick. For views of\n * different content use Tabs. */\nexport function SegmentedControl<V extends string = string>({ items, value, onChange, label, iconOnly = false, className }: SegmentedControlProps<V>) {\n devWarn(\n iconOnly && items.some((t) => !t.icon),\n 'SegmentedControl',\n 'iconOnly 需要每一項都有 icon;沒有圖示的那一項只剩空白。補上 icon,或拿掉 iconOnly 改顯示文字。',\n );\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n const [box, setBox] = React.useState<{ left: number; width: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n if (!el) return;\n const measure = () => setBox({ left: el.offsetLeft, width: el.offsetWidth });\n measure();\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, [idx, items.length]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n onChange?.(items[i].id);\n };\n return (\n <div className={cx('ui-seg', iconOnly && 'is-icons', className)} role=\"radiogroup\" aria-label={label}>\n {box ? (\n <span className=\"ui-seg-ind\" aria-hidden=\"true\" style={{ left: box.left, width: box.width, transition: dropTransition('left', 'width', forward) }} />\n ) : null}\n {items.map((t, i) => {\n const btn = (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={i === idx}\n aria-label={iconOnly ? t.label : undefined}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-seg-item', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const n = items.length;\n const to = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? (i + 1) % n : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? (i - 1 + n) % n : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.icon ? <IconOf icon={t.icon} size={16} filled={iconOnly && i === idx} /> : null}\n {iconOnly ? null : <span>{t.label}</span>}\n </button>\n );\n return iconOnly ? (\n <Tooltip key={t.id} label={t.label} describe={false} side=\"bottom\">\n {btn}\n </Tooltip>\n ) : (\n btn\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,iBAA4C,EAAE,OAAO,OAAO,UAAU,OAAO,WAAW,OAAO,aAAuC;CACpJ,QACE,YAAY,MAAM,MAAM,MAAM,CAAC,EAAE,IAAI,GACrC,oBACA,gEACF;CACA,MAAM,OAAO,MAAM,OAAqC,CAAC,CAAC;CAC1D,MAAM,MAAM,KAAK,IACf,GACA,MAAM,WAAW,MAAM,EAAE,OAAO,KAAK,CACvC;CACA,MAAM,CAAC,KAAK,UAAU,MAAM,SAAiD,IAAI;CACjF,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,IAAI;CACjD,MAAM,sBAAsB;EAC1B,MAAM,KAAK,KAAK,QAAQ;EACxB,IAAI,CAAC,IAAI;EACT,MAAM,gBAAgB,OAAO;GAAE,MAAM,GAAG;GAAY,OAAO,GAAG;EAAY,CAAC;EAC3E,QAAQ;EACR,MAAM,KAAK,IAAI,eAAe,OAAO;EACrC,GAAG,QAAQ,EAAE;EACb,aAAa,GAAG,WAAW;CAC7B,GAAG,CAAC,KAAK,MAAM,MAAM,CAAC;CACtB,MAAM,MAAM,MAAc;EACxB,IAAI,MAAM,OAAO,CAAC,MAAM,IAAI;EAC5B,WAAW,IAAI,GAAG;EAClB,WAAW,MAAM,EAAE,CAAC,EAAE;CACxB;CACA,OACE,qBAAC,OAAD;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src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dropTransition } from '../../motion';\nimport { cx, browserKey, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { IconOf, type IconSource } from '../../icons/Icon';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport interface SegmentedItem<V extends string = string> {\n id: V;\n /** The words: shown, or with `iconOnly` the tooltip and what screen readers say. */\n label: string;\n /** Phosphor icon name or element; required with `iconOnly`. */\n icon?: IconSource;\n}\n\nexport interface SegmentedControlProps<V extends string = string> {\n items: SegmentedItem<V>[];\n value: V;\n onChange?: (id: V) => void;\n /** What the choice is about, for screen readers, e.g. 「顯示方式」. */\n label: string;\n /** Icons only, 28 px each, the words in a tooltip; for a bar such as Workbench's mainBar. Default false. */\n iconOnly?: boolean;\n className?: string;\n}\n\n/** A small switch between two or three ways of showing the same thing (預覽/原始碼), 28 px tall to sit in a toolbar\n * or Workbench's mainBar. The selected part is a raised white pill that slides; ← → move and pick. For views of\n * different content use Tabs. */\nexport function SegmentedControl<V extends string = string>({ items, value, onChange, label, iconOnly = false, className }: SegmentedControlProps<V>) {\n devWarn(\n iconOnly && items.some((t) => !t.icon),\n 'SegmentedControl',\n 'iconOnly 需要每一項都有 icon;沒有圖示的那一項只剩空白。補上 icon,或拿掉 iconOnly 改顯示文字。',\n );\n const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n const idx = Math.max(\n 0,\n items.findIndex((t) => t.id === value),\n );\n const [box, setBox] = React.useState<{ left: number; width: number } | null>(null);\n const [forward, setForward] = React.useState(true);\n React.useLayoutEffect(() => {\n const el = refs.current[idx];\n if (!el) return;\n const measure = () => setBox({ left: el.offsetLeft, width: el.offsetWidth });\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, [idx, items.length]);\n const go = (i: number) => {\n if (i === idx || !items[i]) return;\n setForward(i > idx);\n onChange?.(items[i].id);\n };\n return (\n <div className={cx('ui-seg', iconOnly && 'is-icons', className)} role=\"radiogroup\" aria-label={label}>\n {box ? (\n <span className=\"ui-seg-ind\" aria-hidden=\"true\" style={{ left: box.left, width: box.width, transition: dropTransition('left', 'width', forward) }} />\n ) : null}\n {items.map((t, i) => {\n const btn = (\n <button\n key={t.id}\n ref={(n) => {\n refs.current[i] = n;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={i === idx}\n aria-label={iconOnly ? t.label : undefined}\n tabIndex={i === idx ? 0 : -1}\n className={cx('ui-seg-item', i === idx && 'is-selected')}\n onClick={() => go(i)}\n onKeyDown={(e) => {\n if (browserKey(e)) return;\n const n = items.length;\n const to = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? (i + 1) % n : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? (i - 1 + n) % n : -1;\n if (to < 0) return;\n e.preventDefault();\n refs.current[to]?.focus();\n go(to);\n }}\n >\n {t.icon ? <IconOf icon={t.icon} size={16} filled={iconOnly && i === idx} /> : null}\n {iconOnly ? null : <span>{t.label}</span>}\n </button>\n );\n return iconOnly ? (\n <Tooltip key={t.id} label={t.label} describe={false} side=\"bottom\">\n {btn}\n </Tooltip>\n ) : (\n btn\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,iBAA4C,EAAE,OAAO,OAAO,UAAU,OAAO,WAAW,OAAO,aAAuC;CACpJ,QACE,YAAY,MAAM,MAAM,MAAM,CAAC,EAAE,IAAI,GACrC,oBACA,gEACF;CACA,MAAM,OAAO,MAAM,OAAqC,CAAC,CAAC;CAC1D,MAAM,MAAM,KAAK,IACf,GACA,MAAM,WAAW,MAAM,EAAE,OAAO,KAAK,CACvC;CACA,MAAM,CAAC,KAAK,UAAU,MAAM,SAAiD,IAAI;CACjF,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,IAAI;CACjD,MAAM,sBAAsB;EAC1B,MAAM,KAAK,KAAK,QAAQ;EACxB,IAAI,CAAC,IAAI;EACT,MA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AAD;KAAQ,MAAM,EAAE;KAAM,MAAM;KAAI,QAAQ,YAAY,MAAM;IAAM,CAAA,IAAI,MAC7E,WAAW,OAAO,oBAAC,QAAD,EAAA,UAAO,EAAE,MAAY,CAAA,CAClC;GAvBD,GAAA,EAAE,EAuBD;GAEV,OAAO,WACL,oBAAC,SAAD;IAAoB,OAAO,EAAE;IAAO,UAAU;IAAO,MAAK;IACvD,UAAA;GACM,GAFK,EAAE,EAEP,IAET;EAEJ,CAAC,CACE;;AAET"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { tr } from "../../i18n.js";
3
- import { browserKey, cx } from "../../internal/util.js";
3
+ import { browserKey, cx, resizeObserver } from "../../internal/util.js";
4
4
  import { devWarn } from "../../internal/dev.js";
5
5
  import * as React from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -41,9 +41,9 @@ function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, l
41
41
  if (!el) return;
42
42
  const measure = () => setWidth(el.clientWidth);
43
43
  measure();
44
- const ro = new ResizeObserver(measure);
45
- ro.observe(el);
46
- return () => ro.disconnect();
44
+ const ro = resizeObserver(measure);
45
+ ro?.observe(el);
46
+ return () => ro?.disconnect();
47
47
  }, []);
48
48
  const stacked = width > 0 && width < STACK;
49
49
  const maxB = Math.max(minB, width - HANDLE - minA);
@@ -68,7 +68,7 @@ function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, l
68
68
  if (e.button !== 0) return;
69
69
  e.preventDefault();
70
70
  try {
71
- e.currentTarget.setPointerCapture(e.pointerId);
71
+ e.currentTarget.setPointerCapture?.(e.pointerId);
72
72
  } catch {}
73
73
  e.currentTarget.focus({ preventScroll: true });
74
74
  dragging.current = true;
@@ -84,7 +84,7 @@ function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, l
84
84
  dragging.current = false;
85
85
  setDrag(false);
86
86
  try {
87
- if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);
87
+ if (e.currentTarget.hasPointerCapture?.(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);
88
88
  } catch {}
89
89
  if (root.current) write(storageKey, latest.current);
90
90
  };