@sdxc/ui 2026.11.11 → 2026.11.14
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 +89 -44
- 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 +19 -0
- package/dist/app/index.js +19 -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 +333 -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/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/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 +11 -6
- 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/index.d.ts +11 -0
- package/dist/video/index.js +11 -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/utils/timeline.d.ts +55 -0
- package/dist/video/utils/timeline.js +90 -0
- package/dist/video/video-player.d.ts +261 -0
- package/dist/video/video-player.js +927 -0
- package/package.json +6 -3
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A year of per-day counts at a glance, as a real `<table role="grid">`: weeks are columns, weekdays
|
|
3
|
+
* rows, and each day is tinted one of five levels drawn from the accent, so each app's theme recolours
|
|
4
|
+
* it. Every day names its count; an optional island adds one shared tooltip and arrow-key navigation.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { EntryComponent, Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link ContributionGraph}.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace ContributionGraph {
|
|
14
|
+
/** One day's count; days missing from `days` count zero. */
|
|
15
|
+
interface Day {
|
|
16
|
+
/** The day as `YYYY-MM-DD`. */
|
|
17
|
+
date: string;
|
|
18
|
+
/** Picks the day's level against `levels`; repeated dates add up. */
|
|
19
|
+
count: number;
|
|
20
|
+
}
|
|
21
|
+
/** Every string the graph shows, so an app translates each one. */
|
|
22
|
+
interface Labels {
|
|
23
|
+
/** The table's caption, the graph's summary ("4,015 contributions in the last year"). */
|
|
24
|
+
caption: string;
|
|
25
|
+
/**
|
|
26
|
+
* A day's name, plural on its count, from the date the graph formats in `locale`:
|
|
27
|
+
* `(12, "Tuesday, Nov 3") => "12 contributions on Tuesday, Nov 3"`.
|
|
28
|
+
*/
|
|
29
|
+
day: (count: number, date: string) => string;
|
|
30
|
+
/** The legend's low end ("Less"). */
|
|
31
|
+
less: string;
|
|
32
|
+
/** The legend's high end ("More"). */
|
|
33
|
+
more: string;
|
|
34
|
+
}
|
|
35
|
+
/** Props accepted by {@link ContributionGraph}; the host is a `<div>`. */
|
|
36
|
+
interface Props extends Omit<TagProps<"div">, "children"> {
|
|
37
|
+
/** The counts to plot, in any order; only days between `start` and `end` are drawn. */
|
|
38
|
+
days: readonly Day[];
|
|
39
|
+
/** The first day drawn, as `YYYY-MM-DD`. */
|
|
40
|
+
start: string;
|
|
41
|
+
/** The last day drawn, as `YYYY-MM-DD`; its week is kept in view on a phone. */
|
|
42
|
+
end: string;
|
|
43
|
+
/** Lower bound of levels 0 to 4: a day takes the highest level its count reaches. @default [0, 1, 4, 8, 12] */
|
|
44
|
+
levels?: readonly number[];
|
|
45
|
+
/** Where a day leads, such as that day's activity; days are links when set. */
|
|
46
|
+
href?: (date: string) => string;
|
|
47
|
+
/** Locale for month and weekday names, and for the first day of the week. */
|
|
48
|
+
locale?: string;
|
|
49
|
+
/** First day of the week, 0 = Sunday; defaults to the locale's. */
|
|
50
|
+
weekStart?: number;
|
|
51
|
+
/** Every string the graph shows, so it reads in any language. */
|
|
52
|
+
labels: Labels;
|
|
53
|
+
}
|
|
54
|
+
/** Props {@link ContributionGraphTooltip} serializes for hydration, which is why they are a `type`. */
|
|
55
|
+
type TooltipProps = {
|
|
56
|
+
/** The CSS anchor name the tooltip positions against, unique to its graph. */
|
|
57
|
+
anchor: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The first day of the week in `locale`, 0 = Sunday, read from `Intl.Locale`'s week info; a
|
|
62
|
+
* runtime without it starts weeks on Sunday.
|
|
63
|
+
*
|
|
64
|
+
* @param locale The locale to read; unset reads the runtime's.
|
|
65
|
+
* @returns The weekday a week starts on.
|
|
66
|
+
*/
|
|
67
|
+
export declare function weekStartFor(locale?: string): number;
|
|
68
|
+
/**
|
|
69
|
+
* The level a count reaches: the highest index of `levels` whose lower bound it meets, so with
|
|
70
|
+
* the default bounds a single contribution is level 1 and twelve or more is level 4.
|
|
71
|
+
*
|
|
72
|
+
* @param count The day's count.
|
|
73
|
+
* @param levels Lower bound of each level, ascending.
|
|
74
|
+
* @returns A level from 0 to 4.
|
|
75
|
+
*/
|
|
76
|
+
export declare function contributionLevel(count: number, levels?: readonly number[]): number;
|
|
77
|
+
/**
|
|
78
|
+
* Without script each day's `title` names its count; mapping `@sdxc/ui/app/contribution-graph` in
|
|
79
|
+
* the browser entry runs {@link ContributionGraphTooltip}, for a shared tooltip and arrow keys. Size
|
|
80
|
+
* it with `--ui-contribution-graph-cell` and `-gap`, match `-bg` to the surface, tint `--graph-level-0`–`4`.
|
|
81
|
+
*
|
|
82
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
83
|
+
* @returns The render function producing the graph's markup.
|
|
84
|
+
* @example
|
|
85
|
+
* <ContributionGraph
|
|
86
|
+
* days={days}
|
|
87
|
+
* start="2025-11-14"
|
|
88
|
+
* end="2026-11-13"
|
|
89
|
+
* locale="en-US"
|
|
90
|
+
* href={(date) => `/activity?date=${date}`}
|
|
91
|
+
* labels={{
|
|
92
|
+
* caption: t("profile.contributions", { count: total }),
|
|
93
|
+
* day: (count, date) => t("profile.contributionsOn", { count, date }),
|
|
94
|
+
* less: t("graph.less"),
|
|
95
|
+
* more: t("graph.more"),
|
|
96
|
+
* }}
|
|
97
|
+
* />
|
|
98
|
+
*/
|
|
99
|
+
export declare function ContributionGraph(handle: Handle<ContributionGraph.Props>): () => import("remix/component").RemixElement;
|
|
100
|
+
/**
|
|
101
|
+
* Client island behind {@link ContributionGraph}'s tooltip and keyboard: a manual popover that
|
|
102
|
+
* `contributionGraphKeys()` fills with the hovered or focused day's name and anchors to it, while
|
|
103
|
+
* the arrows walk the days. Loads from `@sdxc/ui/app/contribution-graph#ContributionGraphTooltip`
|
|
104
|
+
* once the app's browser entry maps it.
|
|
105
|
+
*/
|
|
106
|
+
export declare const ContributionGraphTooltip: EntryComponent<ContributionGraph.TooltipProps>;
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { iife } from "@sdxc/iife";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { fg } from "@sdxc/u/color";
|
|
5
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
6
|
+
import { flex, gap, items, justify } from "@sdxc/u/layout";
|
|
7
|
+
import { minIs } from "@sdxc/u/size";
|
|
8
|
+
import { nowrap, tabularNums, text, weight } from "@sdxc/u/typography";
|
|
9
|
+
import { attrs, clientEntry } from "remix/component";
|
|
10
|
+
import { contributionGraphKeys } from "./mixins/contribution-graph-keys.js";
|
|
11
|
+
/** Lower bound of each level, 0 through 4, when `levels` is unset. */
|
|
12
|
+
const DEFAULT_LEVELS = [0, 1, 4, 8, 12];
|
|
13
|
+
/** Milliseconds in one day; dates are counted in UTC, so every day is exactly this long. */
|
|
14
|
+
const DAY_MS = 86_400_000;
|
|
15
|
+
/** Weekdays whose row header shows (Mon, Wed, Fri, as 0 = Sunday); the others stay for screen readers. */
|
|
16
|
+
const SHOWN_WEEKDAYS = new Set([1, 3, 5]);
|
|
17
|
+
/** The levels a day can take, lowest first. */
|
|
18
|
+
const LEVELS = [0, 1, 2, 3, 4];
|
|
19
|
+
/**
|
|
20
|
+
* Share of the accent each level mixes into the empty level's tint, so level 4 is the accent
|
|
21
|
+
* itself and the steps between read evenly on a light or a dark surface.
|
|
22
|
+
*/
|
|
23
|
+
const LEVEL_SHARE = { 1: 30, 2: 55, 3: 80 };
|
|
24
|
+
/**
|
|
25
|
+
* Parses `YYYY-MM-DD` as a UTC day number, so the grid never shifts with the server's time zone.
|
|
26
|
+
*
|
|
27
|
+
* @param date The day as `YYYY-MM-DD`.
|
|
28
|
+
* @returns Days since the Unix epoch.
|
|
29
|
+
*/
|
|
30
|
+
function dayNumber(date) {
|
|
31
|
+
let [year = 1970, month = 1, day = 1] = date.split("-").map(Number);
|
|
32
|
+
return Math.round(Date.UTC(year, month - 1, day) / DAY_MS);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Writes a UTC day number back as `YYYY-MM-DD`.
|
|
36
|
+
*
|
|
37
|
+
* @param day Days since the Unix epoch.
|
|
38
|
+
* @returns The ISO date.
|
|
39
|
+
*/
|
|
40
|
+
function isoDate(day) {
|
|
41
|
+
return new Date(day * DAY_MS).toISOString().slice(0, 10);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The weekday of a UTC day number, 0 = Sunday; day 0 of the epoch was a Thursday.
|
|
45
|
+
*
|
|
46
|
+
* @param day Days since the Unix epoch.
|
|
47
|
+
* @returns The weekday.
|
|
48
|
+
*/
|
|
49
|
+
function weekdayOf(day) {
|
|
50
|
+
return (((day + 4) % 7) + 7) % 7;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The first day of the week in `locale`, 0 = Sunday, read from `Intl.Locale`'s week info; a
|
|
54
|
+
* runtime without it starts weeks on Sunday.
|
|
55
|
+
*
|
|
56
|
+
* @param locale The locale to read; unset reads the runtime's.
|
|
57
|
+
* @returns The weekday a week starts on.
|
|
58
|
+
*/
|
|
59
|
+
export function weekStartFor(locale) {
|
|
60
|
+
let resolved = new Intl.Locale(locale ?? new Intl.DateTimeFormat().resolvedOptions().locale);
|
|
61
|
+
let withInfo = resolved;
|
|
62
|
+
let firstDay = withInfo.getWeekInfo?.().firstDay ?? withInfo.weekInfo?.firstDay ?? 7;
|
|
63
|
+
return firstDay % 7;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The level a count reaches: the highest index of `levels` whose lower bound it meets, so with
|
|
67
|
+
* the default bounds a single contribution is level 1 and twelve or more is level 4.
|
|
68
|
+
*
|
|
69
|
+
* @param count The day's count.
|
|
70
|
+
* @param levels Lower bound of each level, ascending.
|
|
71
|
+
* @returns A level from 0 to 4.
|
|
72
|
+
*/
|
|
73
|
+
export function contributionLevel(count, levels = DEFAULT_LEVELS) {
|
|
74
|
+
let level = 0;
|
|
75
|
+
for (let index = 1; index < Math.min(levels.length, 5); index++) {
|
|
76
|
+
if (count >= levels[index])
|
|
77
|
+
level = index;
|
|
78
|
+
}
|
|
79
|
+
return level;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A CSS dashed ident from a component id, which may hold characters an ident cannot.
|
|
83
|
+
*
|
|
84
|
+
* @param id The component's id.
|
|
85
|
+
* @returns The anchor name the tooltip and the active day share.
|
|
86
|
+
*/
|
|
87
|
+
function anchorName(id) {
|
|
88
|
+
return `--ui-contribution-graph-${id.replace(/[^\w-]/g, "-")}`;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Without script each day's `title` names its count; mapping `@sdxc/ui/app/contribution-graph` in
|
|
92
|
+
* the browser entry runs {@link ContributionGraphTooltip}, for a shared tooltip and arrow keys. Size
|
|
93
|
+
* it with `--ui-contribution-graph-cell` and `-gap`, match `-bg` to the surface, tint `--graph-level-0`–`4`.
|
|
94
|
+
*
|
|
95
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
96
|
+
* @returns The render function producing the graph's markup.
|
|
97
|
+
* @example
|
|
98
|
+
* <ContributionGraph
|
|
99
|
+
* days={days}
|
|
100
|
+
* start="2025-11-14"
|
|
101
|
+
* end="2026-11-13"
|
|
102
|
+
* locale="en-US"
|
|
103
|
+
* href={(date) => `/activity?date=${date}`}
|
|
104
|
+
* labels={{
|
|
105
|
+
* caption: t("profile.contributions", { count: total }),
|
|
106
|
+
* day: (count, date) => t("profile.contributionsOn", { count, date }),
|
|
107
|
+
* less: t("graph.less"),
|
|
108
|
+
* more: t("graph.more"),
|
|
109
|
+
* }}
|
|
110
|
+
* />
|
|
111
|
+
*/
|
|
112
|
+
export function ContributionGraph(handle) {
|
|
113
|
+
return () => {
|
|
114
|
+
let { days, start, end, levels, href, locale, weekStart, labels, mix, ...rest } = handle.props;
|
|
115
|
+
let first = dayNumber(start);
|
|
116
|
+
let last = Math.max(first, dayNumber(end));
|
|
117
|
+
let startsOn = weekStart ?? weekStartFor(locale);
|
|
118
|
+
let gridStart = first - ((weekdayOf(first) - startsOn + 7) % 7);
|
|
119
|
+
let weekCount = Math.floor((last - gridStart) / 7) + 1;
|
|
120
|
+
let counts = new Map();
|
|
121
|
+
for (let entry of days) {
|
|
122
|
+
let day = dayNumber(entry.date);
|
|
123
|
+
counts.set(day, (counts.get(day) ?? 0) + entry.count);
|
|
124
|
+
}
|
|
125
|
+
let weeks = Array.from({ length: weekCount }, (_, index) => {
|
|
126
|
+
let weekFirst = gridStart + index * 7;
|
|
127
|
+
return { first: weekFirst, month: isoDate(Math.max(weekFirst, first)).slice(0, 7) };
|
|
128
|
+
});
|
|
129
|
+
let months = [];
|
|
130
|
+
for (let week of weeks) {
|
|
131
|
+
let previous = months.at(-1);
|
|
132
|
+
if (previous && previous.month === week.month)
|
|
133
|
+
previous.span += 1;
|
|
134
|
+
else
|
|
135
|
+
months.push({ month: week.month, span: 1 });
|
|
136
|
+
}
|
|
137
|
+
let monthName = new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" });
|
|
138
|
+
let weekdayName = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: "UTC" });
|
|
139
|
+
let dateName = new Intl.DateTimeFormat(locale, {
|
|
140
|
+
weekday: "long",
|
|
141
|
+
month: "short",
|
|
142
|
+
day: "numeric",
|
|
143
|
+
timeZone: "UTC",
|
|
144
|
+
});
|
|
145
|
+
let anchor = anchorName(handle.id);
|
|
146
|
+
return (_jsxs("div", { ...rest, "data-slot": "contribution-graph", mix: mergeMix([flex(), raw({ flexDirection: "column" }), gap(2), minIs(0)], mix), children: [_jsx("p", { "aria-hidden": "true", "data-slot": "contribution-graph-summary", mix: [raw({ margin: 0 }), text("sm"), weight("medium"), fg("neutral.emphasis")], children: labels.caption }), _jsx("div", { "data-slot": "contribution-graph-scroller", mix: [
|
|
147
|
+
minIs(0),
|
|
148
|
+
/**
|
|
149
|
+
* Laid out from the end, the scroller's resting position is its newest week, so a
|
|
150
|
+
* phone opens on the current week with no script; the table's end margin takes the
|
|
151
|
+
* spare room when it fits, which keeps it at the start of a wide box.
|
|
152
|
+
*/
|
|
153
|
+
raw({
|
|
154
|
+
display: "flex",
|
|
155
|
+
flexDirection: "row-reverse",
|
|
156
|
+
overflowX: "auto",
|
|
157
|
+
overscrollBehaviorX: "contain",
|
|
158
|
+
paddingBlockEnd: "0.25rem",
|
|
159
|
+
}),
|
|
160
|
+
], children: _jsxs("table", { "aria-readonly": "true", "data-slot": "contribution-graph-table", mix: [
|
|
161
|
+
/** The days form an ARIA grid, so arrows move between them as between cells. */
|
|
162
|
+
attrs({ role: "grid" }),
|
|
163
|
+
raw({
|
|
164
|
+
flexShrink: 0,
|
|
165
|
+
marginInlineEnd: "auto",
|
|
166
|
+
borderCollapse: "separate",
|
|
167
|
+
borderSpacing: "var(--ui-contribution-graph-gap, 3px)",
|
|
168
|
+
fontSize: "var(--ui-text-xs, 0.75rem)",
|
|
169
|
+
lineHeight: "1",
|
|
170
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
171
|
+
"& th": { fontWeight: 400, padding: 0, textAlign: "start", whiteSpace: "nowrap" },
|
|
172
|
+
"& thead th": { blockSize: "1rem", verticalAlign: "bottom" },
|
|
173
|
+
'& th[scope="row"]': {
|
|
174
|
+
position: "sticky",
|
|
175
|
+
insetInlineStart: 0,
|
|
176
|
+
zIndex: 1,
|
|
177
|
+
paddingInlineEnd: "0.375rem",
|
|
178
|
+
backgroundColor: "var(--ui-contribution-graph-bg, var(--ui-bg, Canvas))",
|
|
179
|
+
boxShadow: "0 0 0 var(--ui-contribution-graph-gap, 3px) var(--ui-contribution-graph-bg, var(--ui-bg, Canvas))",
|
|
180
|
+
},
|
|
181
|
+
"& td[data-level]": {
|
|
182
|
+
inlineSize: "var(--ui-contribution-graph-cell, 10px)",
|
|
183
|
+
blockSize: "var(--ui-contribution-graph-cell, 10px)",
|
|
184
|
+
padding: 0,
|
|
185
|
+
borderRadius: "2px",
|
|
186
|
+
boxShadow: "inset 0 0 0 1px color-mix(in oklab, var(--ui-neutral-fg, CanvasText) 6%, transparent)",
|
|
187
|
+
},
|
|
188
|
+
"& td > a": {
|
|
189
|
+
display: "block",
|
|
190
|
+
inlineSize: "100%",
|
|
191
|
+
blockSize: "100%",
|
|
192
|
+
borderRadius: "inherit",
|
|
193
|
+
},
|
|
194
|
+
'& [data-slot="contribution-graph-day"]:focus-visible': {
|
|
195
|
+
outline: "2px solid var(--ui-brand-ring)",
|
|
196
|
+
outlineOffset: "1px",
|
|
197
|
+
},
|
|
198
|
+
}),
|
|
199
|
+
raw(levelRules("& td")),
|
|
200
|
+
], children: [_jsx("caption", { mix: [visuallyHidden()], children: labels.caption }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("td", {}), months.map((group) => (_jsx("th", { scope: "colgroup", colSpan: group.span, children: _jsx("span", { mix: group.span < 2 ? [visuallyHidden()] : undefined, children: monthName.format(new Date(dayNumber(`${group.month}-01`) * DAY_MS)) }) })))] }) }), _jsx("tbody", { children: Array.from({ length: 7 }, (_, row) => {
|
|
201
|
+
let weekday = (startsOn + row) % 7;
|
|
202
|
+
return (_jsxs("tr", { children: [_jsx("th", { scope: "row", children: _jsx("span", { mix: SHOWN_WEEKDAYS.has(weekday) ? undefined : [visuallyHidden()], children: weekdayName.format(new Date((gridStart + row) * DAY_MS)) }) }), weeks.map((week, index) => {
|
|
203
|
+
let day = week.first + row;
|
|
204
|
+
if (day < first || day > last)
|
|
205
|
+
return _jsx("td", { "data-outside": "" });
|
|
206
|
+
let count = counts.get(day) ?? 0;
|
|
207
|
+
let date = isoDate(day);
|
|
208
|
+
let name = labels.day(count, dateName.format(new Date(day * DAY_MS)));
|
|
209
|
+
let level = contributionLevel(count, levels);
|
|
210
|
+
let tabIndex = day === last ? 0 : -1;
|
|
211
|
+
if (href) {
|
|
212
|
+
return (_jsx("td", { "data-level": level, "data-count": count, children: _jsx("a", { href: href(date), tabIndex: tabIndex, "aria-label": name, title: name, "data-slot": "contribution-graph-day", "data-date": date, "data-week": index, "data-row": row }) }));
|
|
213
|
+
}
|
|
214
|
+
return (_jsx("td", { tabIndex: tabIndex, "aria-label": name, title: name, "data-slot": "contribution-graph-day", "data-level": level, "data-count": count, "data-date": date, "data-week": index, "data-row": row }));
|
|
215
|
+
})] }));
|
|
216
|
+
}) })] }) }), _jsxs("div", { "data-slot": "contribution-graph-legend", mix: [
|
|
217
|
+
flex(),
|
|
218
|
+
items("center"),
|
|
219
|
+
justify("end"),
|
|
220
|
+
gap(1),
|
|
221
|
+
text("xs"),
|
|
222
|
+
fg("neutral.muted"),
|
|
223
|
+
nowrap(),
|
|
224
|
+
tabularNums(),
|
|
225
|
+
raw({
|
|
226
|
+
"& > [data-level]": {
|
|
227
|
+
inlineSize: "var(--ui-contribution-graph-cell, 10px)",
|
|
228
|
+
blockSize: "var(--ui-contribution-graph-cell, 10px)",
|
|
229
|
+
borderRadius: "2px",
|
|
230
|
+
},
|
|
231
|
+
}),
|
|
232
|
+
raw(levelRules("& > span")),
|
|
233
|
+
], children: [_jsx("span", { mix: [raw({ marginInlineEnd: "0.25rem" })], children: labels.less }), LEVELS.map((level) => (_jsx("span", { "aria-hidden": "true", "data-level": level }))), _jsx("span", { mix: [raw({ marginInlineStart: "0.25rem" })], children: labels.more })] }), _jsx(ContributionGraphTooltip, { anchor: anchor })] }));
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Tints each level from its `--graph-level-N` token, which an app's theme may set; unset, level 0 is
|
|
238
|
+
* the neutral tint and levels 1–4 mix the accent into it, so both light and dark themes are designed.
|
|
239
|
+
*
|
|
240
|
+
* @param prefix Selector, relative to the rule's host, of the elements carrying `data-level`.
|
|
241
|
+
* @returns One rule per level.
|
|
242
|
+
*/
|
|
243
|
+
function levelRules(prefix) {
|
|
244
|
+
let empty = "var(--graph-level-0, var(--ui-neutral-bg-tint-hover))";
|
|
245
|
+
let rules = {};
|
|
246
|
+
for (let level of LEVELS) {
|
|
247
|
+
let fallback = iife(() => {
|
|
248
|
+
if (level === 0)
|
|
249
|
+
return "var(--ui-neutral-bg-tint-hover)";
|
|
250
|
+
if (level === 4)
|
|
251
|
+
return "var(--ui-brand-bg-solid)";
|
|
252
|
+
return `color-mix(in oklab, var(--ui-brand-bg-solid) ${LEVEL_SHARE[level]}%, ${empty})`;
|
|
253
|
+
});
|
|
254
|
+
rules[`${prefix}[data-level="${level}"]`] = {
|
|
255
|
+
backgroundColor: `var(--graph-level-${level}, ${fallback})`,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
return rules;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Client island behind {@link ContributionGraph}'s tooltip and keyboard: a manual popover that
|
|
262
|
+
* `contributionGraphKeys()` fills with the hovered or focused day's name and anchors to it, while
|
|
263
|
+
* the arrows walk the days. Loads from `@sdxc/ui/app/contribution-graph#ContributionGraphTooltip`
|
|
264
|
+
* once the app's browser entry maps it.
|
|
265
|
+
*/
|
|
266
|
+
export const ContributionGraphTooltip = clientEntry("@sdxc/ui/app/contribution-graph#ContributionGraphTooltip", function ContributionGraphTooltip(handle) {
|
|
267
|
+
return () => (_jsx("div", { popover: "manual", role: "tooltip", "data-slot": "contribution-graph-tooltip", mix: [
|
|
268
|
+
contributionGraphKeys(handle.props.anchor),
|
|
269
|
+
raw({
|
|
270
|
+
inset: "auto",
|
|
271
|
+
margin: 0,
|
|
272
|
+
marginBlockEnd: "0.375rem",
|
|
273
|
+
positionArea: "top",
|
|
274
|
+
positionTryFallbacks: "flip-block",
|
|
275
|
+
paddingInline: "0.5rem",
|
|
276
|
+
paddingBlock: "0.25rem",
|
|
277
|
+
border: "none",
|
|
278
|
+
borderRadius: "var(--ui-radius-md, 0.375rem)",
|
|
279
|
+
color: "var(--ui-neutral-fg-on-solid)",
|
|
280
|
+
backgroundColor: "var(--ui-neutral-bg-solid)",
|
|
281
|
+
boxShadow: "var(--ui-shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1))",
|
|
282
|
+
fontSize: "var(--ui-text-xs, 0.75rem)",
|
|
283
|
+
lineHeight: "var(--ui-leading-xs, calc(1 / 0.75))",
|
|
284
|
+
fontWeight: 500,
|
|
285
|
+
whiteSpace: "nowrap",
|
|
286
|
+
pointerEvents: "none",
|
|
287
|
+
}),
|
|
288
|
+
] }));
|
|
289
|
+
});
|
|
@@ -47,6 +47,11 @@ export declare namespace DetailSheet {
|
|
|
47
47
|
description?: RemixNode;
|
|
48
48
|
/** The list URL without the record open. Close and Esc follow it. */
|
|
49
49
|
closeHref: string;
|
|
50
|
+
/**
|
|
51
|
+
* The named `<Frame>` Close, Previous and Next load into, so stepping through records
|
|
52
|
+
* reloads only that frame while the address still moves; unset loads the whole page.
|
|
53
|
+
*/
|
|
54
|
+
target?: string;
|
|
50
55
|
/** The URL a teammate can open this record at; shows the copy button. */
|
|
51
56
|
permalink?: string;
|
|
52
57
|
/** Shows `n / N` with previous/next links and their keys. */
|
|
@@ -82,6 +87,8 @@ export type DetailSheetControlsProps = {
|
|
|
82
87
|
total?: number;
|
|
83
88
|
previousHref?: string | null;
|
|
84
89
|
nextHref?: string | null;
|
|
90
|
+
/** The frame the navigation links load into. */
|
|
91
|
+
target?: string;
|
|
85
92
|
labels: DetailSheet.Labels;
|
|
86
93
|
/** Where Esc, k/j and ↑/↓ answer. */
|
|
87
94
|
keys?: DetailSheetKeyScope;
|
package/dist/app/detail-sheet.js
CHANGED
|
@@ -47,8 +47,8 @@ function controlStyle() {
|
|
|
47
47
|
*/
|
|
48
48
|
function NavLink(handle) {
|
|
49
49
|
return () => {
|
|
50
|
-
let { link, rel, href, label, keys, children } = handle.props;
|
|
51
|
-
return (_jsx("a", { href: href ?? undefined, "aria-label": label, title: label, "aria-keyshortcuts": keys, "aria-disabled": href ? undefined : "true", rel: rel, [DETAIL_SHEET_LINK_ATTRIBUTE]: link, mix: controlStyle(), children: children }));
|
|
50
|
+
let { link, rel, href, label, keys, target, children } = handle.props;
|
|
51
|
+
return (_jsx("a", { href: href ?? undefined, "aria-label": label, title: label, "aria-keyshortcuts": keys, "aria-disabled": href ? undefined : "true", "data-rmx-target": href ? target : undefined, rel: rel, [DETAIL_SHEET_LINK_ATTRIBUTE]: link, mix: controlStyle(), children: children }));
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -61,7 +61,7 @@ function NavLink(handle) {
|
|
|
61
61
|
*/
|
|
62
62
|
export const DetailSheetControls = clientEntry("@sdxc/ui/app/detail-sheet#DetailSheetControls", function DetailSheetControls(handle) {
|
|
63
63
|
return () => {
|
|
64
|
-
let { closeHref, permalink, index, total, previousHref, nextHref, labels, keys } = handle.props;
|
|
64
|
+
let { closeHref, permalink, index, total, previousHref, nextHref, target, labels, keys } = handle.props;
|
|
65
65
|
let positioned = index !== undefined && total !== undefined;
|
|
66
66
|
return (_jsxs("div", { "data-slot": "detail-sheet-controls", mix: [
|
|
67
67
|
hstack({ gap: 0.5, align: "center" }),
|
|
@@ -73,11 +73,11 @@ export const DetailSheetControls = clientEntry("@sdxc/ui/app/detail-sheet#Detail
|
|
|
73
73
|
fg("neutral.muted"),
|
|
74
74
|
tabularNums(),
|
|
75
75
|
raw({ whiteSpace: "nowrap" }),
|
|
76
|
-
], children: [_jsx("span", { mix: [visuallyHidden()], children: `${labels.position} ` }), `${index} / ${total}`] }), _jsx(NavLink, { link: "previous", rel: "prev", href: previousHref, label: labels.previous, keys: "k ArrowUp", children: _jsx(ChevronUpIcon, { size: 16, "aria-hidden": "true" }) }), _jsx(NavLink, { link: "next", rel: "next", href: nextHref, label: labels.next, keys: "j ArrowDown", children: _jsx(ChevronDownIcon, { size: 16, "aria-hidden": "true" }) })] })) : null, permalink ? (_jsxs("button", { type: "button", "data-slot": "detail-sheet-copy", "aria-label": labels.copyLink, title: labels.copyLink, mix: [
|
|
76
|
+
], children: [_jsx("span", { mix: [visuallyHidden()], children: `${labels.position} ` }), `${index} / ${total}`] }), _jsx(NavLink, { link: "previous", rel: "prev", href: previousHref, label: labels.previous, keys: "k ArrowUp", target: target, children: _jsx(ChevronUpIcon, { size: 16, "aria-hidden": "true" }) }), _jsx(NavLink, { link: "next", rel: "next", href: nextHref, label: labels.next, keys: "j ArrowDown", target: target, children: _jsx(ChevronDownIcon, { size: 16, "aria-hidden": "true" }) })] })) : null, permalink ? (_jsxs("button", { type: "button", "data-slot": "detail-sheet-copy", "aria-label": labels.copyLink, title: labels.copyLink, mix: [
|
|
77
77
|
...controlStyle(),
|
|
78
78
|
when("&[data-copied]", fg("success")),
|
|
79
79
|
copyPermalink(permalink, labels.linkCopied),
|
|
80
|
-
], children: [_jsx(LinkIcon, { size: 16, "aria-hidden": "true" }), _jsx("span", { role: "status", mix: [visuallyHidden()] })] })) : null, _jsx(NavLink, { link: "close", href: closeHref, label: labels.close, keys: "Escape", children: _jsx(XIcon, { size: 16, "aria-hidden": "true" }) })] }));
|
|
80
|
+
], children: [_jsx(LinkIcon, { size: 16, "aria-hidden": "true" }), _jsx("span", { role: "status", mix: [visuallyHidden()] })] })) : null, _jsx(NavLink, { link: "close", href: closeHref, label: labels.close, keys: "Escape", target: target, children: _jsx(XIcon, { size: 16, "aria-hidden": "true" }) })] }));
|
|
81
81
|
};
|
|
82
82
|
});
|
|
83
83
|
/**
|
|
@@ -103,7 +103,7 @@ export const DetailSheetControls = clientEntry("@sdxc/ui/app/detail-sheet#Detail
|
|
|
103
103
|
*/
|
|
104
104
|
export function DetailSheet(handle) {
|
|
105
105
|
return () => {
|
|
106
|
-
let { id, title, description, closeHref, permalink, position, actions, footer, inset, keys, labels, children, mix, ...rest } = handle.props;
|
|
106
|
+
let { id, title, description, closeHref, target, permalink, position, actions, footer, inset, keys, labels, children, mix, ...rest } = handle.props;
|
|
107
107
|
let titleId = `${id}-title`;
|
|
108
108
|
let edge = inset ? "var(--ui-app-inset-gap, 0.5rem)" : "0px";
|
|
109
109
|
return (_jsx("aside", { id: id, "aria-labelledby": titleId, tabIndex: -1, "data-slot": "detail-sheet", "data-inset": inset ? "" : undefined, ...rest, mix: mergeMix([
|
|
@@ -159,7 +159,7 @@ export function DetailSheet(handle) {
|
|
|
159
159
|
pb(3),
|
|
160
160
|
borderEdge("bottom", { width: 1, color: "neutral" }),
|
|
161
161
|
shrink(0),
|
|
162
|
-
], children: [_jsxs("div", { mix: [vstack({ gap: 0.5 }), minIs(0), raw({ paddingBlockStart: "0.25rem" })], children: [_jsx("h2", { id: titleId, mix: [m(0), text("base"), weight("semibold"), leading("1.5rem"), truncate()], children: title }), description ? (_jsx("p", { mix: [m(0), text("sm"), fg("neutral.muted")], children: description })) : null] }), _jsxs("div", { mix: [hstack({ gap: 1, align: "center" }), shrink(0), minBs("2rem")], children: [actions, _jsx(DetailSheetControls, { sheetId: id, closeHref: closeHref, permalink: permalink, index: position?.index, total: position?.total, previousHref: position?.previousHref ?? null, nextHref: position?.nextHref ?? null, labels: labels, keys: keys })] })] }), _jsx("div", { "data-slot": "detail-sheet-body", mix: [raw({ flex: "1 1 auto" }), minBs(0), overflow("auto"), p(4), vstack({ gap: 5 })], children: children }), footer ? (_jsx("footer", { "data-slot": "detail-sheet-footer", mix: [
|
|
162
|
+
], children: [_jsxs("div", { mix: [vstack({ gap: 0.5 }), minIs(0), raw({ paddingBlockStart: "0.25rem" })], children: [_jsx("h2", { id: titleId, mix: [m(0), text("base"), weight("semibold"), leading("1.5rem"), truncate()], children: title }), description ? (_jsx("p", { mix: [m(0), text("sm"), fg("neutral.muted")], children: description })) : null] }), _jsxs("div", { mix: [hstack({ gap: 1, align: "center" }), shrink(0), minBs("2rem")], children: [actions, _jsx(DetailSheetControls, { sheetId: id, closeHref: closeHref, permalink: permalink, index: position?.index, total: position?.total, previousHref: position?.previousHref ?? null, nextHref: position?.nextHref ?? null, target: target, labels: labels, keys: keys })] })] }), _jsx("div", { "data-slot": "detail-sheet-body", mix: [raw({ flex: "1 1 auto" }), minBs(0), overflow("auto"), p(4), vstack({ gap: 5 })], children: children }), footer ? (_jsx("footer", { "data-slot": "detail-sheet-footer", mix: [
|
|
163
163
|
flex(),
|
|
164
164
|
items("center"),
|
|
165
165
|
justify("end"),
|