@sdxc/ui 2026.11.11 → 2026.11.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -61
- package/dist/app/app-shell-toggle.d.ts +2 -0
- package/dist/app/app-shell-toggle.js +5 -2
- package/dist/app/app-shell.d.ts +25 -1
- package/dist/app/app-shell.js +73 -38
- package/dist/app/auto-refresh.d.ts +2 -0
- package/dist/app/auto-refresh.js +3 -3
- package/dist/app/behaviors/refresh-schedule.d.ts +8 -3
- package/dist/app/behaviors/refresh-schedule.js +4 -3
- package/dist/app/board.d.ts +123 -0
- package/dist/app/board.js +224 -0
- package/dist/app/chart.d.ts +2 -2
- package/dist/app/chart.js +7 -3
- package/dist/app/check-runs.d.ts +116 -0
- package/dist/app/check-runs.js +201 -0
- package/dist/app/code-view.d.ts +172 -0
- package/dist/app/code-view.js +414 -0
- package/dist/app/command-palette.d.ts +38 -3
- package/dist/app/command-palette.js +53 -5
- package/dist/app/contribution-graph.d.ts +106 -0
- package/dist/app/contribution-graph.js +289 -0
- package/dist/app/detail-sheet.d.ts +7 -0
- package/dist/app/detail-sheet.js +7 -7
- package/dist/app/diff.d.ts +200 -0
- package/dist/app/diff.js +702 -0
- package/dist/app/filter-bar.d.ts +20 -0
- package/dist/app/filter-bar.js +35 -15
- package/dist/app/filter-menu.d.ts +144 -0
- package/dist/app/filter-menu.js +480 -0
- package/dist/app/gantt.d.ts +108 -0
- package/dist/app/gantt.js +420 -0
- package/dist/app/index.d.ts +20 -0
- package/dist/app/index.js +20 -0
- package/dist/app/log-viewer.d.ts +120 -0
- package/dist/app/log-viewer.js +384 -0
- package/dist/app/merge-box.d.ts +97 -0
- package/dist/app/merge-box.js +227 -0
- package/dist/app/mixins/app-shell-controls.d.ts +4 -1
- package/dist/app/mixins/app-shell-controls.js +64 -4
- package/dist/app/mixins/auto-refresh.d.ts +5 -2
- package/dist/app/mixins/auto-refresh.js +9 -3
- package/dist/app/mixins/close-popover-on-submit.d.ts +16 -0
- package/dist/app/mixins/close-popover-on-submit.js +32 -0
- package/dist/app/mixins/code-view-selection.d.ts +60 -0
- package/dist/app/mixins/code-view-selection.js +276 -0
- package/dist/app/mixins/command-palette.d.ts +15 -4
- package/dist/app/mixins/command-palette.js +94 -6
- package/dist/app/mixins/contribution-graph-keys.d.ts +19 -0
- package/dist/app/mixins/contribution-graph-keys.js +155 -0
- package/dist/app/mixins/diff-interactions.d.ts +72 -0
- package/dist/app/mixins/diff-interactions.js +269 -0
- package/dist/app/mixins/filter-menu-keys.d.ts +41 -0
- package/dist/app/mixins/filter-menu-keys.js +91 -0
- package/dist/app/mixins/gantt-today.d.ts +17 -0
- package/dist/app/mixins/gantt-today.js +50 -0
- package/dist/app/mixins/log-viewer.d.ts +29 -0
- package/dist/app/mixins/log-viewer.js +347 -0
- package/dist/app/mixins/optimistic-toggle-sync.d.ts +5 -0
- package/dist/app/mixins/optimistic-toggle-sync.js +25 -1
- package/dist/app/mixins/save-bar-sync.d.ts +7 -1
- package/dist/app/mixins/save-bar-sync.js +23 -4
- package/dist/app/mixins/save-status-sync.js +23 -1
- package/dist/app/mixins/split-view.js +1 -1
- package/dist/app/mixins/submit-on-close.d.ts +17 -0
- package/dist/app/mixins/submit-on-close.js +52 -0
- package/dist/app/mixins/tree-filter.d.ts +44 -0
- package/dist/app/mixins/tree-filter.js +111 -0
- package/dist/app/mixins/tree-navigation.d.ts +50 -0
- package/dist/app/mixins/tree-navigation.js +216 -0
- package/dist/app/optimistic-toggle.d.ts +8 -0
- package/dist/app/optimistic-toggle.js +3 -2
- package/dist/app/page-header.d.ts +18 -3
- package/dist/app/page-header.js +105 -50
- package/dist/app/profile-picker.d.ts +47 -0
- package/dist/app/profile-picker.js +104 -0
- package/dist/app/review-thread.d.ts +115 -0
- package/dist/app/review-thread.js +116 -0
- package/dist/app/save-bar.d.ts +5 -0
- package/dist/app/save-bar.js +1 -1
- package/dist/app/save-status.js +1 -1
- package/dist/app/settings-layout.d.ts +5 -0
- package/dist/app/settings-layout.js +5 -5
- package/dist/app/skeleton.d.ts +9 -0
- package/dist/app/skeleton.js +28 -0
- package/dist/app/split-view.d.ts +4 -0
- package/dist/app/split-view.js +3 -3
- package/dist/app/styles/code-tokens.d.ts +24 -0
- package/dist/app/styles/code-tokens.js +47 -0
- package/dist/app/tab-bar.d.ts +59 -0
- package/dist/app/tab-bar.js +111 -0
- package/dist/app/tree.d.ts +111 -14
- package/dist/app/tree.js +202 -15
- package/dist/app/utils/ansi.d.ts +55 -0
- package/dist/app/utils/ansi.js +157 -0
- package/dist/app/utils/diff-rows.d.ts +82 -0
- package/dist/app/utils/diff-rows.js +209 -0
- package/dist/app/utils/fuzzy-path.d.ts +58 -0
- package/dist/app/utils/fuzzy-path.js +202 -0
- package/dist/app/utils/line-range.d.ts +48 -0
- package/dist/app/utils/line-range.js +61 -0
- package/dist/app/utils/log-lines.d.ts +107 -0
- package/dist/app/utils/log-lines.js +170 -0
- package/dist/app/utils/tree-filter.d.ts +19 -0
- package/dist/app/utils/tree-filter.js +26 -0
- package/dist/app/view-options.d.ts +2 -0
- package/dist/app/view-options.js +2 -2
- package/dist/chat/activity.d.ts +72 -0
- package/dist/chat/activity.js +184 -0
- package/dist/chat/composer-submit.d.ts +38 -0
- package/dist/chat/composer-submit.js +44 -0
- package/dist/chat/composer.d.ts +47 -0
- package/dist/chat/composer.js +100 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/index.js +6 -0
- package/dist/chat/mixins/composer-send.d.ts +32 -0
- package/dist/chat/mixins/composer-send.js +121 -0
- package/dist/chat/mixins/reveal-stream.d.ts +68 -0
- package/dist/chat/mixins/reveal-stream.js +184 -0
- package/dist/chat/mixins/stream-target.d.ts +18 -0
- package/dist/chat/mixins/stream-target.js +38 -0
- package/dist/components/button.js +7 -1
- package/dist/components/character-count.d.ts +44 -0
- package/dist/components/character-count.js +68 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/label-chip.d.ts +42 -0
- package/dist/components/label-chip.js +86 -0
- package/dist/components/property-list.d.ts +9 -2
- package/dist/components/property-list.js +37 -10
- package/dist/components/textarea.js +6 -1
- package/dist/components/timeline.d.ts +62 -5
- package/dist/components/timeline.js +124 -5
- package/dist/docs/code-block.js +8 -31
- package/dist/docs/file-tree.js +3 -48
- package/dist/landing/case-study.d.ts +79 -0
- package/dist/landing/case-study.js +162 -0
- package/dist/landing/contributor-wall.d.ts +72 -0
- package/dist/landing/contributor-wall.js +129 -0
- package/dist/landing/countdown.d.ts +88 -0
- package/dist/landing/countdown.js +91 -0
- package/dist/landing/episode-player.d.ts +87 -0
- package/dist/landing/episode-player.js +113 -0
- package/dist/landing/faq-band.d.ts +3 -2
- package/dist/landing/faq-band.js +4 -3
- package/dist/landing/index.d.ts +7 -0
- package/dist/landing/index.js +7 -0
- package/dist/landing/landing-header.js +15 -4
- package/dist/landing/mixins/countdown-tick.d.ts +29 -0
- package/dist/landing/mixins/countdown-tick.js +65 -0
- package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
- package/dist/landing/mixins/usage-estimate-live.js +120 -0
- package/dist/landing/phone-frame.d.ts +2 -1
- package/dist/landing/price-list.d.ts +68 -0
- package/dist/landing/price-list.js +125 -0
- package/dist/landing/scroll-scene.d.ts +59 -0
- package/dist/landing/scroll-scene.js +70 -0
- package/dist/landing/sponsor-wall.d.ts +30 -6
- package/dist/landing/sponsor-wall.js +70 -14
- package/dist/landing/typed-terminal.d.ts +24 -6
- package/dist/landing/typed-terminal.js +22 -14
- package/dist/landing/usage-estimate.d.ts +127 -0
- package/dist/landing/usage-estimate.js +164 -0
- package/dist/landing/utils/countdown.d.ts +33 -0
- package/dist/landing/utils/countdown.js +42 -0
- package/dist/landing/utils/pause-toggle.d.ts +2 -1
- package/dist/mixins/character-count.d.ts +62 -0
- package/dist/mixins/character-count.js +139 -0
- package/dist/mixins/index.d.ts +6 -2
- package/dist/mixins/index.js +6 -2
- package/dist/mixins/invoker-fields.d.ts +18 -0
- package/dist/mixins/invoker-fields.js +60 -0
- package/dist/mixins/media-sync.d.ts +58 -0
- package/dist/mixins/media-sync.js +102 -0
- package/dist/mixins/menu-keys.d.ts +11 -0
- package/dist/mixins/menu-keys.js +79 -70
- package/dist/mixins/sortable.d.ts +96 -0
- package/dist/mixins/sortable.js +433 -0
- package/dist/utils/code-lines.d.ts +26 -0
- package/dist/utils/code-lines.js +29 -0
- package/dist/utils/file-icon.d.ts +31 -0
- package/dist/utils/file-icon.js +60 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/write-cookie.d.ts +15 -15
- package/dist/utils/write-cookie.js +10 -16
- package/dist/video/episode-list.d.ts +48 -0
- package/dist/video/episode-list.js +161 -0
- package/dist/video/index.d.ts +15 -0
- package/dist/video/index.js +15 -0
- package/dist/video/mixins/video-player-sync.d.ts +27 -0
- package/dist/video/mixins/video-player-sync.js +413 -0
- package/dist/video/mixins/video-shelf-steps.d.ts +20 -0
- package/dist/video/mixins/video-shelf-steps.js +79 -0
- package/dist/video/title-hero.d.ts +51 -0
- package/dist/video/title-hero.js +170 -0
- package/dist/video/utils/timeline.d.ts +55 -0
- package/dist/video/utils/timeline.js +90 -0
- package/dist/video/video-card.d.ts +51 -0
- package/dist/video/video-card.js +135 -0
- package/dist/video/video-player.d.ts +261 -0
- package/dist/video/video-player.js +927 -0
- package/dist/video/video-shelf.d.ts +58 -0
- package/dist/video/video-shelf.js +155 -0
- package/package.json +6 -3
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { ChevronDownIcon, CircleCheckIcon, CircleDotIcon, CircleMinusIcon, CircleSlashIcon, CircleXIcon, } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { animationHost, keyframes } from "@sdxc/u/animation";
|
|
5
|
+
import { fg, outline } from "@sdxc/u/color";
|
|
6
|
+
import { rounded } from "@sdxc/u/effects";
|
|
7
|
+
import { cursor, mergeMix, raw } from "@sdxc/u/general";
|
|
8
|
+
import { flex, gap, grow, inlineFlex, items, shrink } from "@sdxc/u/layout";
|
|
9
|
+
import { motionSafe } from "@sdxc/u/responsive";
|
|
10
|
+
import { minIs, pb, pi } from "@sdxc/u/size";
|
|
11
|
+
import { focusVisible, hover, when } from "@sdxc/u/state";
|
|
12
|
+
import { font, nowrap, tabularNums, text, textDecoration, truncate, weight, } from "@sdxc/u/typography";
|
|
13
|
+
/** Order rows and the summary's counts follow: what needs attention first, settled runs last. */
|
|
14
|
+
const STATE_ORDER = {
|
|
15
|
+
failure: 0,
|
|
16
|
+
pending: 1,
|
|
17
|
+
success: 2,
|
|
18
|
+
skipped: 3,
|
|
19
|
+
cancelled: 3,
|
|
20
|
+
};
|
|
21
|
+
/** The states in the order the summary sentence counts them. */
|
|
22
|
+
const SUMMARY_STATES = ["failure", "pending", "success", "skipped", "cancelled"];
|
|
23
|
+
/**
|
|
24
|
+
* Sorts runs failure → pending → success → skipped and cancelled, keeping the given order
|
|
25
|
+
* within a state, so the run that needs attention is the first row.
|
|
26
|
+
*
|
|
27
|
+
* @param runs The runs in any order.
|
|
28
|
+
* @returns A sorted copy.
|
|
29
|
+
*/
|
|
30
|
+
export function sortCheckRuns(runs) {
|
|
31
|
+
return runs
|
|
32
|
+
.map((run, index) => ({ run, index }))
|
|
33
|
+
.sort((a, b) => STATE_ORDER[a.run.state] - STATE_ORDER[b.run.state] || a.index - b.index)
|
|
34
|
+
.map(({ run }) => run);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Writes the summary sentence: each state with runs counted through `labels.counts`, joined as
|
|
38
|
+
* a list in `locale`, then wrapped by `labels.summary` with the total for its plural.
|
|
39
|
+
*
|
|
40
|
+
* @param runs The runs to count.
|
|
41
|
+
* @param labels The part's strings.
|
|
42
|
+
* @param locale Locale the counts are joined in.
|
|
43
|
+
* @returns The sentence, or `labels.empty` when there are no runs.
|
|
44
|
+
* @example checkRunsSummary(runs, labels, "en-GB") // "1 failing, 1 pending and 22 successful checks"
|
|
45
|
+
*/
|
|
46
|
+
export function checkRunsSummary(runs, labels, locale) {
|
|
47
|
+
if (runs.length === 0)
|
|
48
|
+
return labels.empty;
|
|
49
|
+
let parts = SUMMARY_STATES.flatMap((state) => {
|
|
50
|
+
let count = runs.filter((run) => run.state === state).length;
|
|
51
|
+
return count === 0 ? [] : [labels.counts[state](count)];
|
|
52
|
+
});
|
|
53
|
+
let list = new Intl.ListFormat(locale, { type: "conjunction", style: "long" }).format(parts);
|
|
54
|
+
return labels.summary(list, runs.length);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The state the whole set reads as: the first run after sorting, so one failure makes the set
|
|
58
|
+
* failing, a running check makes it pending, and a single pass outweighs skipped runs.
|
|
59
|
+
*
|
|
60
|
+
* @param runs The runs to summarise.
|
|
61
|
+
* @returns The overall state, or `undefined` for no runs.
|
|
62
|
+
*/
|
|
63
|
+
function overallState(runs) {
|
|
64
|
+
return sortCheckRuns(runs)[0]?.state;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Renders the summary sentence as the `<summary>` of a `<details>` that lists every run, failed
|
|
68
|
+
* ones first, opening on its own when a run failed. It is complete as server HTML: the native
|
|
69
|
+
* disclosure needs no island, and it reads only the theme's shared tokens.
|
|
70
|
+
*
|
|
71
|
+
* @param handle Runtime handle carrying the host `<details>`'s props.
|
|
72
|
+
* @returns The render function producing the part's markup.
|
|
73
|
+
* @example
|
|
74
|
+
* <CheckRuns
|
|
75
|
+
* runs={runs}
|
|
76
|
+
* locale="en"
|
|
77
|
+
* labels={{
|
|
78
|
+
* counts: { failure: (n) => `${n} failing`, pending: (n) => `${n} pending`, success: (n) => `${n} successful`, skipped: (n) => `${n} skipped`, cancelled: (n) => `${n} cancelled` },
|
|
79
|
+
* summary: (list, total) => `${list} ${total === 1 ? "check" : "checks"}`,
|
|
80
|
+
* states: { failure: "Failed", pending: "In progress", success: "Passed", skipped: "Skipped", cancelled: "Cancelled" },
|
|
81
|
+
* details: "Details",
|
|
82
|
+
* empty: "No checks",
|
|
83
|
+
* }}
|
|
84
|
+
* />
|
|
85
|
+
*/
|
|
86
|
+
export function CheckRuns(handle) {
|
|
87
|
+
return () => {
|
|
88
|
+
let { runs, labels, locale, open, mix, ...rest } = handle.props;
|
|
89
|
+
let sorted = sortCheckRuns(runs);
|
|
90
|
+
let overall = overallState(runs);
|
|
91
|
+
let isOpen = open ?? runs.some((run) => run.state === "failure");
|
|
92
|
+
return (_jsxs("details", { ...rest, open: isOpen, "data-slot": "check-runs", "data-state": overall, mix: mergeMix([minIs(0), text("sm")], mix), children: [_jsxs("summary", { "data-slot": "check-runs-summary", mix: [
|
|
93
|
+
flex(),
|
|
94
|
+
items("center"),
|
|
95
|
+
gap(2),
|
|
96
|
+
pb(1),
|
|
97
|
+
rounded("sm"),
|
|
98
|
+
cursor("pointer"),
|
|
99
|
+
weight("medium"),
|
|
100
|
+
fg("neutral.emphasis"),
|
|
101
|
+
raw({ listStyle: "none", "&::-webkit-details-marker": { display: "none" } }),
|
|
102
|
+
focusVisible(outline({ color: "brand.ring", offset: 2 })),
|
|
103
|
+
], children: [overall === undefined ? null : (_jsx(CheckRunIcon, { state: overall, label: labels.states[overall] })), _jsx("span", { mix: [grow(), minIs(0)], children: checkRunsSummary(runs, labels, locale) }), runs.length === 0 ? null : (_jsx(ChevronDownIcon, { size: 16, "aria-hidden": "true", mix: [
|
|
104
|
+
shrink(0),
|
|
105
|
+
fg("neutral.muted"),
|
|
106
|
+
motionSafe(raw({ transition: "rotate 150ms ease" })),
|
|
107
|
+
when(":is(details[open] > summary) > &", raw({ rotate: "180deg" })),
|
|
108
|
+
] }))] }), runs.length === 0 ? null : (_jsx("ul", { "data-slot": "check-runs-list", mix: [raw({ listStyle: "none", margin: 0, padding: 0 })], children: sorted.map((run, index) => (_jsx(CheckRunRow, { run: run, labels: labels }, index))) }))] }));
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* One run as a ruled row: its icon, name and workflow, duration, and a Details link whose
|
|
113
|
+
* accessible name ends with the run's name, so a list of "Details" links stays distinguishable.
|
|
114
|
+
*
|
|
115
|
+
* @param handle Runtime handle carrying the run and the part's strings.
|
|
116
|
+
* @returns The render function producing the row.
|
|
117
|
+
*/
|
|
118
|
+
function CheckRunRow(handle) {
|
|
119
|
+
return () => {
|
|
120
|
+
let { run, labels } = handle.props;
|
|
121
|
+
return (_jsxs("li", { "data-slot": "check-run", "data-state": run.state, mix: [
|
|
122
|
+
flex(),
|
|
123
|
+
items("center"),
|
|
124
|
+
gap(2),
|
|
125
|
+
pb(1.5),
|
|
126
|
+
pi(1),
|
|
127
|
+
minIs(0),
|
|
128
|
+
raw({ borderBlockStart: "1px solid var(--ui-neutral-border)" }),
|
|
129
|
+
], children: [_jsx(CheckRunIcon, { state: run.state, label: labels.states[run.state] }), _jsxs("span", { mix: [flex(), items("baseline"), gap(2), grow(), minIs(0)], children: [_jsx("span", { "data-slot": "check-run-name", mix: [weight("medium"), fg("neutral.emphasis"), truncate()], children: run.name }), run.workflow === undefined ? null : (_jsx("span", { "data-slot": "check-run-workflow", mix: [fg("neutral.muted"), truncate(), minIs(0)], children: run.workflow }))] }), run.duration === undefined ? null : (_jsx("span", { "data-slot": "check-run-duration", mix: [
|
|
130
|
+
shrink(0),
|
|
131
|
+
font("mono"),
|
|
132
|
+
text("xs"),
|
|
133
|
+
fg("neutral.muted"),
|
|
134
|
+
tabularNums(),
|
|
135
|
+
nowrap(),
|
|
136
|
+
], children: run.duration })), run.href === undefined ? null : (_jsxs("a", { href: run.href, "data-slot": "check-run-details", mix: [
|
|
137
|
+
shrink(0),
|
|
138
|
+
rounded("sm"),
|
|
139
|
+
fg("brand"),
|
|
140
|
+
textDecoration("none"),
|
|
141
|
+
hover(textDecoration("underline")),
|
|
142
|
+
focusVisible(outline({ color: "brand.ring", offset: 2 })),
|
|
143
|
+
], children: [labels.details, _jsxs("span", { mix: [visuallyHidden()], children: [" ", run.name] })] }))] }));
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A state's named icon, read by shape as well as tone (✗ failure, ● pending, ✓ success, ⊘ skipped,
|
|
148
|
+
* ⊖ cancelled), also usable alone as a commit's status. The pending icon pulses until the run
|
|
149
|
+
* settles, and holds still under reduced motion.
|
|
150
|
+
*
|
|
151
|
+
* @param handle Runtime handle carrying the state and its name.
|
|
152
|
+
* @returns The render function producing the icon.
|
|
153
|
+
* @example <CheckRunIcon state="failure" label={t("checks.failed")} />
|
|
154
|
+
*/
|
|
155
|
+
export function CheckRunIcon(handle) {
|
|
156
|
+
return () => {
|
|
157
|
+
let { state, label } = handle.props;
|
|
158
|
+
return (_jsx("span", { role: "img", "aria-label": label, "data-slot": "check-run-icon", "data-state": state, mix: [
|
|
159
|
+
inlineFlex(),
|
|
160
|
+
shrink(0),
|
|
161
|
+
fg("neutral.muted"),
|
|
162
|
+
keyframes("ui-check-run-pending", {
|
|
163
|
+
"0%, 100%": { opacity: 1 },
|
|
164
|
+
"50%": { opacity: 0.35 },
|
|
165
|
+
}),
|
|
166
|
+
when('&[data-state="failure"]', fg("danger")),
|
|
167
|
+
when('&[data-state="pending"]', [
|
|
168
|
+
fg("warning"),
|
|
169
|
+
motionSafe(animationHost("ui-check-run-pending", {
|
|
170
|
+
duration: "1.4s",
|
|
171
|
+
easing: "ease-in-out",
|
|
172
|
+
iterationCount: "infinite",
|
|
173
|
+
})),
|
|
174
|
+
]),
|
|
175
|
+
when('&[data-state="success"]', fg("success")),
|
|
176
|
+
], children: _jsx(StateGlyph, { state: state }) }));
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Draws the glyph for one state at the row's 16px icon size.
|
|
181
|
+
*
|
|
182
|
+
* @param handle Runtime handle carrying the state.
|
|
183
|
+
* @returns The render function producing the glyph.
|
|
184
|
+
*/
|
|
185
|
+
function StateGlyph(handle) {
|
|
186
|
+
return () => {
|
|
187
|
+
let { state } = handle.props;
|
|
188
|
+
switch (state) {
|
|
189
|
+
case "failure":
|
|
190
|
+
return _jsx(CircleXIcon, { size: 16, "aria-hidden": "true" });
|
|
191
|
+
case "pending":
|
|
192
|
+
return _jsx(CircleDotIcon, { size: 16, "aria-hidden": "true" });
|
|
193
|
+
case "success":
|
|
194
|
+
return _jsx(CircleCheckIcon, { size: 16, "aria-hidden": "true" });
|
|
195
|
+
case "skipped":
|
|
196
|
+
return _jsx(CircleSlashIcon, { size: 16, "aria-hidden": "true" });
|
|
197
|
+
case "cancelled":
|
|
198
|
+
return _jsx(CircleMinusIcon, { size: 16, "aria-hidden": "true" });
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A whole source file to read and cite: one table row per line, numbers painted from an
|
|
3
|
+
* attribute so a copy takes only code, rows in chunks the browser skips until they near the
|
|
4
|
+
* screen, a band for the cited lines, and blame hunks with an age strip beside them.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { EntryComponent, Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
import type { RelativeTimeFormat } from "../utils/relative-time.js";
|
|
11
|
+
import type { LineRange } from "./utils/line-range.js";
|
|
12
|
+
export type { LineRange } from "./utils/line-range.js";
|
|
13
|
+
export { lineLink, lineRangeHash, lineRangeQuery, parseLineRange } from "./utils/line-range.js";
|
|
14
|
+
/**
|
|
15
|
+
* Prop types for {@link CodeView} and its parts.
|
|
16
|
+
*/
|
|
17
|
+
export declare namespace CodeView {
|
|
18
|
+
/** One painted run of source; the runs `@sdxc/highlight` returns pass straight through. */
|
|
19
|
+
interface Token {
|
|
20
|
+
/** The token's kind ("keyword", "string"), which picks its color from the highlight theme. */
|
|
21
|
+
type: string;
|
|
22
|
+
/** The source text the run covers; the runs joined give back the line. */
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
/** The commit a blame hunk names. */
|
|
26
|
+
interface BlameCommit {
|
|
27
|
+
/** The commit's hash, shortened for display. */
|
|
28
|
+
sha: string;
|
|
29
|
+
/** The commit message's first line, the hunk's headline. */
|
|
30
|
+
subject: string;
|
|
31
|
+
/** Who made the commit, shown beside its age. */
|
|
32
|
+
author: string;
|
|
33
|
+
/** When the commit was made, which sets the hunk's age and its place on the strip. */
|
|
34
|
+
date: RelativeTimeFormat.DateInput;
|
|
35
|
+
/** Where the commit's page lives; the subject links there. */
|
|
36
|
+
href: string;
|
|
37
|
+
}
|
|
38
|
+
/** A run of lines, counted from 1, last changed by one commit. */
|
|
39
|
+
interface BlameHunk {
|
|
40
|
+
/** The hunk's first line. */
|
|
41
|
+
start: number;
|
|
42
|
+
/** The hunk's last line, inclusive. */
|
|
43
|
+
end: number;
|
|
44
|
+
/** The commit that last changed these lines. */
|
|
45
|
+
commit: BlameCommit;
|
|
46
|
+
}
|
|
47
|
+
/** Every string the view shows or announces; the library ships no copy. */
|
|
48
|
+
interface Labels {
|
|
49
|
+
/** Name of the button that opens the line menu, such as "Line options". */
|
|
50
|
+
lineMenu: string;
|
|
51
|
+
/** The line menu's item that copies the selected lines' text, such as "Copy line". */
|
|
52
|
+
copyLine: string;
|
|
53
|
+
/** The line menu's item that copies the cited lines' permalink, such as "Copy permalink". */
|
|
54
|
+
copyPermalink: string;
|
|
55
|
+
/** Shown when `issueHref` is set, such as "Reference in new issue". */
|
|
56
|
+
referenceInNewIssue?: string;
|
|
57
|
+
/** Announced once a line or a permalink is on the clipboard, such as "Copied". */
|
|
58
|
+
copied: string;
|
|
59
|
+
/** The help-sheet heading the view's keys list under. */
|
|
60
|
+
group?: string;
|
|
61
|
+
/** What `y` does in the help sheet, such as "Expand URL to its permalink". */
|
|
62
|
+
permalinkKey?: string;
|
|
63
|
+
/** What Escape does in the help sheet while lines are selected. */
|
|
64
|
+
clearSelection?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Props accepted by {@link CodeView}: every native `<div>` attribute for its root.
|
|
68
|
+
*/
|
|
69
|
+
interface Props extends TagProps<"div"> {
|
|
70
|
+
/** The file's source; a single trailing newline is dropped. */
|
|
71
|
+
code: string;
|
|
72
|
+
/** Language the code highlights as (`ts`, `css`); omitted, the code draws plain. */
|
|
73
|
+
language?: string;
|
|
74
|
+
/** The file's path, which names the table for assistive technology. */
|
|
75
|
+
path: string;
|
|
76
|
+
/** Runs already painted for `code`, which skip highlighting here. */
|
|
77
|
+
tokens?: readonly Token[];
|
|
78
|
+
/**
|
|
79
|
+
* The lines the page's address cites as `?L=3-8`, painted on the server so the band
|
|
80
|
+
* shows without script. Read it with `parseLineRange(url.searchParams.get("L"))`.
|
|
81
|
+
*/
|
|
82
|
+
selected?: LineRange;
|
|
83
|
+
/** The address each line number links to. @default lineLink(line), `?L=n#Ln` */
|
|
84
|
+
lineHref?: (line: number) => string;
|
|
85
|
+
/** Blame hunks; when set, each hunk draws its commit and age in a leading column. */
|
|
86
|
+
blame?: readonly BlameHunk[];
|
|
87
|
+
/** The address of this file at a fixed commit, which `y` and "Copy permalink" use. */
|
|
88
|
+
permalink?: string;
|
|
89
|
+
/** Where "Reference in new issue" goes; the permalink arrives as its `body` parameter. */
|
|
90
|
+
issueHref?: string;
|
|
91
|
+
/** Every string the view shows or announces, so it reads in any language. */
|
|
92
|
+
labels: Labels;
|
|
93
|
+
/** The moment blame ages count from. @default the current time */
|
|
94
|
+
now?: RelativeTimeFormat.DateInput;
|
|
95
|
+
/** The locale blame ages are written in. @default the runtime's locale */
|
|
96
|
+
locale?: string;
|
|
97
|
+
/** Lines per chunk. @default DEFAULT_CHUNK_SIZE */
|
|
98
|
+
chunkSize?: number;
|
|
99
|
+
/** A {@link CodeView.Header} drawn above the lines. */
|
|
100
|
+
children?: RemixNode;
|
|
101
|
+
}
|
|
102
|
+
/** Props accepted by {@link CodeView.Header}: every native `<div>` attribute. */
|
|
103
|
+
interface HeaderProps extends TagProps<"div"> {
|
|
104
|
+
/** The file's facts, such as "49 lines (42 loc) · 1.75 KB", built from {@link codeStats}. */
|
|
105
|
+
meta?: RemixNode;
|
|
106
|
+
/** Actions at the header's end: Raw, Copy, Download, a Code | Blame switch. */
|
|
107
|
+
children?: RemixNode;
|
|
108
|
+
}
|
|
109
|
+
/** Props accepted by {@link CodeView.AgeLegend}. */
|
|
110
|
+
interface AgeLegendProps extends TagProps<"div"> {
|
|
111
|
+
/** The legend's ends, such as `{ older: "Older", newer: "Newer" }`. */
|
|
112
|
+
labels: {
|
|
113
|
+
older: string;
|
|
114
|
+
newer: string;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** Props {@link CodeViewSelection} receives from {@link CodeView}. */
|
|
118
|
+
interface SelectionProps {
|
|
119
|
+
/** The `id` the line menu's popover takes. */
|
|
120
|
+
menuId: string;
|
|
121
|
+
/** The view's `permalink`, which `y` and "Copy permalink" extend with the selection. */
|
|
122
|
+
permalink?: string;
|
|
123
|
+
/** The view's `issueHref`, which shows "Reference in new issue" when set. */
|
|
124
|
+
issueHref?: string;
|
|
125
|
+
/** The view's strings. */
|
|
126
|
+
labels: Labels;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** The facts a file header reads out, counted from the source. */
|
|
130
|
+
export interface CodeStats {
|
|
131
|
+
/** Lines as the view numbers them. */
|
|
132
|
+
lines: number;
|
|
133
|
+
/** Lines holding anything other than whitespace. */
|
|
134
|
+
loc: number;
|
|
135
|
+
/** Size in bytes as UTF-8. */
|
|
136
|
+
bytes: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Counts a file the way its header reports it, dropping a single trailing newline as the
|
|
140
|
+
* view does, so "49 lines" matches the last number drawn.
|
|
141
|
+
*
|
|
142
|
+
* @param code The file's source.
|
|
143
|
+
* @returns Lines, lines of code and bytes, for the app to phrase in its own locale.
|
|
144
|
+
* @example let { lines, loc, bytes } = codeStats(source); t("file.meta", { lines, loc, size: formatBytes(bytes) })
|
|
145
|
+
*/
|
|
146
|
+
export declare function codeStats(code: string): CodeStats;
|
|
147
|
+
/**
|
|
148
|
+
* Without script `selected` and `#Ln` paint the cited lines, and each number links to `?L=n#Ln`;
|
|
149
|
+
* mapping `@sdxc/ui/app/code-view` runs {@link CodeViewSelection} for ranges, the menu and `y`.
|
|
150
|
+
* Set `--code-view-font-size`, `-line-height`, `-blame-width`, `-selected` and `--code-age-1`–`5`.
|
|
151
|
+
*
|
|
152
|
+
* @param handle Runtime handle carrying the view's props.
|
|
153
|
+
* @returns The render function producing the view.
|
|
154
|
+
* @example
|
|
155
|
+
* <CodeView path="app/routes.ts" language="ts" code={source} selected={parseLineRange(url.searchParams.get("L"))} permalink={`/blob/${sha}/app/routes.ts`} labels={labels}>
|
|
156
|
+
* <CodeView.Header meta={t("file.meta", codeStats(source))}>{actions}</CodeView.Header>
|
|
157
|
+
* </CodeView>
|
|
158
|
+
* @example
|
|
159
|
+
* <CodeView path="app/routes.ts" language="ts" code={source} blame={hunks} labels={labels} />
|
|
160
|
+
*/
|
|
161
|
+
export declare function CodeView(handle: Handle<CodeView.Props>): () => import("remix/component").RemixElement;
|
|
162
|
+
export declare namespace CodeView {
|
|
163
|
+
var Header: (handle: Handle<CodeView.HeaderProps>) => () => import("remix/component").RemixElement;
|
|
164
|
+
var AgeLegend: (handle: Handle<CodeView.AgeLegendProps>) => () => import("remix/component").RemixElement;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Client island every {@link CodeView} renders once: the line menu (Copy line, Copy
|
|
168
|
+
* permalink, Reference in new issue) and the `codeViewSelection()` mixin that owns the
|
|
169
|
+
* view's selection. Loads from `@sdxc/ui/app/code-view#CodeViewSelection` once the app's
|
|
170
|
+
* browser entry maps it; until then each number links to its own `?L=` address.
|
|
171
|
+
*/
|
|
172
|
+
export declare const CodeViewSelection: EntryComponent<CodeView.SelectionProps>;
|