@sdxc/ui 2026.11.1 → 2026.11.4
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 +1 -1
- package/dist/app/app-shell-toggle.d.ts +31 -0
- package/dist/app/app-shell-toggle.js +43 -0
- package/dist/app/app-shell.d.ts +131 -0
- package/dist/app/app-shell.js +542 -0
- package/dist/app/auto-refresh.d.ts +104 -0
- package/dist/app/auto-refresh.js +126 -0
- package/dist/app/behaviors/refresh-schedule.d.ts +53 -0
- package/dist/app/behaviors/refresh-schedule.js +95 -0
- package/dist/app/behaviors/shortcuts.d.ts +175 -0
- package/dist/app/behaviors/shortcuts.js +401 -0
- package/dist/app/behaviors/toaster.d.ts +31 -2
- package/dist/app/behaviors/toaster.js +62 -5
- package/dist/app/chart.d.ts +62 -8
- package/dist/app/chart.js +207 -9
- package/dist/app/command-palette.d.ts +132 -0
- package/dist/app/command-palette.js +181 -0
- package/dist/app/danger-zone.d.ts +66 -0
- package/dist/app/danger-zone.js +66 -0
- package/dist/app/detail-sheet.d.ts +119 -0
- package/dist/app/detail-sheet.js +173 -0
- package/dist/app/drop-zone.d.ts +2 -1
- package/dist/app/drop-zone.js +6 -3
- package/dist/app/editor-layout.d.ts +69 -0
- package/dist/app/editor-layout.js +143 -0
- package/dist/app/empty.d.ts +56 -19
- package/dist/app/empty.js +129 -22
- package/dist/app/filter-bar.d.ts +169 -0
- package/dist/app/filter-bar.js +346 -0
- package/dist/app/index.d.ts +51 -0
- package/dist/app/index.js +51 -0
- package/dist/app/keyboard-help.d.ts +66 -0
- package/dist/app/keyboard-help.js +56 -0
- package/dist/app/mixins/app-shell-controls.d.ts +46 -0
- package/dist/app/mixins/app-shell-controls.js +131 -0
- package/dist/app/mixins/auto-refresh.d.ts +29 -0
- package/dist/app/mixins/auto-refresh.js +66 -0
- package/dist/app/mixins/command-palette.d.ts +56 -0
- package/dist/app/mixins/command-palette.js +297 -0
- package/dist/app/mixins/copy-permalink.d.ts +26 -0
- package/dist/app/mixins/copy-permalink.js +54 -0
- package/dist/app/mixins/detail-sheet-keys.d.ts +28 -0
- package/dist/app/mixins/detail-sheet-keys.js +88 -0
- package/dist/app/mixins/escape-link.d.ts +17 -0
- package/dist/app/mixins/escape-link.js +35 -0
- package/dist/app/mixins/keyboard-help.d.ts +38 -0
- package/dist/app/mixins/keyboard-help.js +51 -0
- package/dist/app/mixins/optimistic-toggle-sync.d.ts +80 -0
- package/dist/app/mixins/optimistic-toggle-sync.js +153 -0
- package/dist/app/mixins/range-picker-keys.d.ts +18 -0
- package/dist/app/mixins/range-picker-keys.js +94 -0
- package/dist/app/mixins/row-navigation.d.ts +85 -0
- package/dist/app/mixins/row-navigation.js +208 -0
- package/dist/app/mixins/save-bar-sync.d.ts +27 -0
- package/dist/app/mixins/save-bar-sync.js +106 -0
- package/dist/app/mixins/save-shortcut.d.ts +47 -0
- package/dist/app/mixins/save-shortcut.js +101 -0
- package/dist/app/mixins/save-status-sync.d.ts +77 -0
- package/dist/app/mixins/save-status-sync.js +159 -0
- package/dist/app/mixins/selection-bar-sync.d.ts +32 -0
- package/dist/app/mixins/selection-bar-sync.js +151 -0
- package/dist/app/mixins/split-view.d.ts +66 -0
- package/dist/app/mixins/split-view.js +319 -0
- package/dist/app/mixins/status-strip-keys.d.ts +17 -0
- package/dist/app/mixins/status-strip-keys.js +79 -0
- package/dist/app/mixins/submit-on-change.d.ts +16 -0
- package/dist/app/mixins/submit-on-change.js +28 -0
- package/dist/app/mixins/table-selection.d.ts +39 -0
- package/dist/app/mixins/table-selection.js +272 -0
- package/dist/app/mixins/toast-queue.d.ts +36 -0
- package/dist/app/mixins/toast-queue.js +77 -0
- package/dist/app/mixins/toast-stack.d.ts +20 -0
- package/dist/app/mixins/toast-stack.js +55 -0
- package/dist/app/optimistic-toggle.d.ts +48 -0
- package/dist/app/optimistic-toggle.js +38 -0
- package/dist/app/page-header.d.ts +71 -0
- package/dist/app/page-header.js +249 -0
- package/dist/app/range-picker.d.ts +102 -0
- package/dist/app/range-picker.js +118 -0
- package/dist/app/save-bar.d.ts +54 -0
- package/dist/app/save-bar.js +64 -0
- package/dist/app/save-status.d.ts +50 -0
- package/dist/app/save-status.js +54 -0
- package/dist/app/selection-bar.d.ts +101 -0
- package/dist/app/selection-bar.js +157 -0
- package/dist/app/settings-layout.d.ts +70 -0
- package/dist/app/settings-layout.js +112 -0
- package/dist/app/settings-section.d.ts +140 -0
- package/dist/app/settings-section.js +182 -0
- package/dist/app/skeleton.d.ts +47 -4
- package/dist/app/skeleton.js +149 -2
- package/dist/app/sparkline.d.ts +61 -0
- package/dist/app/sparkline.js +145 -0
- package/dist/app/split-view.d.ts +154 -0
- package/dist/app/split-view.js +272 -0
- package/dist/app/stat-card.d.ts +109 -0
- package/dist/app/stat-card.js +379 -0
- package/dist/app/status-strip.d.ts +70 -0
- package/dist/app/status-strip.js +155 -0
- package/dist/app/styles/action-row.d.ts +41 -0
- package/dist/app/styles/action-row.js +59 -0
- package/dist/app/styles/stat-delta.d.ts +29 -0
- package/dist/app/styles/stat-delta.js +36 -0
- package/dist/app/styles/toast-stack.d.ts +21 -0
- package/dist/app/styles/toast-stack.js +54 -0
- package/dist/app/table.d.ts +199 -24
- package/dist/app/table.js +640 -36
- package/dist/app/toast.d.ts +105 -5
- package/dist/app/toast.js +89 -17
- package/dist/app/toasts.d.ts +49 -0
- package/dist/app/toasts.js +103 -0
- package/dist/app/utils/app-shell-cookie.d.ts +21 -0
- package/dist/app/utils/app-shell-cookie.js +33 -0
- package/dist/app/utils/chart-marker-indices.d.ts +9 -5
- package/dist/app/utils/chart-marker-indices.js +9 -8
- package/dist/app/utils/chart-path.d.ts +14 -10
- package/dist/app/utils/chart-path.js +46 -18
- package/dist/app/utils/edited-time.d.ts +19 -0
- package/dist/app/utils/edited-time.js +35 -0
- package/dist/app/utils/key-target.d.ts +23 -0
- package/dist/app/utils/key-target.js +48 -0
- package/dist/app/utils/search-params.d.ts +69 -0
- package/dist/app/utils/search-params.js +132 -0
- package/dist/app/utils/shortcut-groups.d.ts +21 -0
- package/dist/app/utils/shortcut-groups.js +53 -0
- package/dist/app/utils/split-view-layout.d.ts +48 -0
- package/dist/app/utils/split-view-layout.js +71 -0
- package/dist/app/view-options.d.ts +99 -0
- package/dist/app/view-options.js +182 -0
- package/dist/components/banner.d.ts +61 -0
- package/dist/components/banner.js +101 -0
- package/dist/components/confirm.d.ts +54 -5
- package/dist/components/confirm.js +44 -5
- package/dist/components/group.d.ts +14 -0
- package/dist/components/group.js +66 -11
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/input.js +9 -3
- package/dist/components/link-button.js +8 -2
- package/dist/components/property-list.d.ts +76 -0
- package/dist/components/property-list.js +175 -0
- package/dist/components/relative-time.d.ts +72 -0
- package/dist/components/relative-time.js +45 -0
- package/dist/components/status-dot.d.ts +62 -0
- package/dist/components/status-dot.js +99 -0
- package/dist/components/text-field.d.ts +17 -2
- package/dist/components/text-field.js +13 -4
- package/dist/components/timeline.d.ts +67 -0
- package/dist/components/timeline.js +159 -0
- package/dist/components/typeset.d.ts +2 -1
- package/dist/components/typeset.js +4 -1
- package/dist/docs/code-tabs-sync.d.ts +1 -1
- package/dist/docs/code-tabs-sync.js +2 -2
- package/dist/docs/copy-button.d.ts +1 -1
- package/dist/docs/copy-button.js +2 -2
- package/dist/docs/docs-feedback.d.ts +12 -0
- package/dist/docs/docs-feedback.js +4 -2
- package/dist/docs/docs-hub.js +4 -4
- package/dist/docs/docs-layout.d.ts +1 -1
- package/dist/docs/docs-layout.js +1 -1
- package/dist/docs/docs-nav-tools.d.ts +11 -5
- package/dist/docs/docs-nav-tools.js +5 -4
- package/dist/docs/docs-nav.d.ts +12 -5
- package/dist/docs/docs-nav.js +20 -8
- package/dist/docs/docs-pager.d.ts +5 -1
- package/dist/docs/docs-pager.js +7 -6
- package/dist/docs/mixins/docs-nav-tools.d.ts +3 -3
- package/dist/docs/mixins/docs-nav-tools.js +42 -17
- package/dist/docs/next-steps.js +3 -2
- package/dist/docs/page-actions.d.ts +1 -1
- package/dist/docs/page-actions.js +2 -2
- package/dist/docs/table-of-contents.d.ts +1 -1
- package/dist/docs/table-of-contents.js +2 -2
- package/dist/docs/utils/docs-filter.d.ts +26 -0
- package/dist/docs/utils/docs-filter.js +53 -0
- package/dist/mixins/confirm-phrase.d.ts +19 -0
- package/dist/mixins/confirm-phrase.js +56 -0
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/mixins/viewer-time.d.ts +20 -0
- package/dist/mixins/viewer-time.js +40 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/segmented-control.d.ts +49 -0
- package/dist/styles/segmented-control.js +71 -0
- package/dist/test/table.d.ts +65 -0
- package/dist/test/table.js +108 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/relative-time.d.ts +44 -0
- package/dist/utils/relative-time.js +69 -0
- package/package.json +6 -6
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
|
|
2
|
+
import { MinusIcon, TrendingDownIcon, TrendingUpIcon } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { bg, border, fg } from "@sdxc/u/color";
|
|
5
|
+
import { rounded } from "@sdxc/u/effects";
|
|
6
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
7
|
+
import { block, container, grid, hstack, inlineBlock, inlineFlex, items } from "@sdxc/u/layout";
|
|
8
|
+
import { bs, is, minIs, pi } from "@sdxc/u/size";
|
|
9
|
+
import { data } from "@sdxc/u/state";
|
|
10
|
+
import { nowrap, tabularNums, text, verticalAlign, weight } from "@sdxc/u/typography";
|
|
11
|
+
import { STAT_COMPACT, STAT_GROUP_CONTAINER, statDeltaPlacement } from "./styles/stat-delta.js";
|
|
12
|
+
/** Column count a group lays out at full width when `columns` is omitted. */
|
|
13
|
+
const DEFAULT_COLUMNS = 4;
|
|
14
|
+
/** Layout a group uses when `variant` is omitted. */
|
|
15
|
+
const DEFAULT_VARIANT = "cards";
|
|
16
|
+
/** Whether a skeleton reserves a delta when `delta` is omitted. */
|
|
17
|
+
const DEFAULT_SKELETON_DELTA = true;
|
|
18
|
+
/** Whether a skeleton's delta reserves a comparison when `comparison` is omitted. */
|
|
19
|
+
const DEFAULT_SKELETON_COMPARISON = true;
|
|
20
|
+
/** Widths of the bars a skeleton draws per footer line when `footerLines` is set. */
|
|
21
|
+
const FOOTER_LINE_WIDTHS = ["90%", "60%"];
|
|
22
|
+
/** Whether a skeleton reserves a footer when `footer` is omitted. */
|
|
23
|
+
const DEFAULT_SKELETON_FOOTER = true;
|
|
24
|
+
/** Width of a comparison's placeholder: about "vs previous 24 hours" in the comparison's text. */
|
|
25
|
+
const COMPARISON_BAR = "10em";
|
|
26
|
+
/** Decorative arrow drawn in the delta pill for each trend. */
|
|
27
|
+
const TREND_ICONS = { up: TrendingUpIcon, down: TrendingDownIcon, flat: MinusIcon };
|
|
28
|
+
/** Fallback for the neutral border colour, matching the theme's own default. */
|
|
29
|
+
const BORDER = "var(--ui-neutral-border, color-mix(in oklab, CanvasText 16%, transparent))";
|
|
30
|
+
/**
|
|
31
|
+
* Picks the delta's tone from its meaning: a rise is good unless `invert` says a fall is.
|
|
32
|
+
*
|
|
33
|
+
* @param trend Direction the number moved.
|
|
34
|
+
* @param invert Whether a fall is the good direction.
|
|
35
|
+
* @returns The semantic role the pill is drawn in.
|
|
36
|
+
*/
|
|
37
|
+
function deltaTone(trend, invert) {
|
|
38
|
+
if (trend === "flat")
|
|
39
|
+
return "neutral";
|
|
40
|
+
return (trend === "up") !== invert ? "success" : "danger";
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Renders one stat: a grid that sets the label and delta on one line, the value under them,
|
|
44
|
+
* then the trend and the footer, in that order whatever order the parts are written in. With
|
|
45
|
+
* `href` the whole card is one link, and `current` marks it as the metric being shown.
|
|
46
|
+
*
|
|
47
|
+
* @param handle Runtime handle carrying the card's props.
|
|
48
|
+
* @returns The render function producing the card's markup.
|
|
49
|
+
* @example
|
|
50
|
+
* <StatCard>
|
|
51
|
+
* <StatCard.Label>{t("stats.uptime")}</StatCard.Label>
|
|
52
|
+
* <StatCard.Value>99.98%</StatCard.Value>
|
|
53
|
+
* <StatCard.Delta trend="up" comparison={t("stats.vsLastWeek")}>+0.02%</StatCard.Delta>
|
|
54
|
+
* <StatCard.Footer>{t("stats.uptimeFooter")}</StatCard.Footer>
|
|
55
|
+
* </StatCard>
|
|
56
|
+
* @example
|
|
57
|
+
* <StatCard href="?metric=latency" current={metric === "latency"}>…</StatCard>
|
|
58
|
+
*/
|
|
59
|
+
export function StatCard(handle) {
|
|
60
|
+
return () => {
|
|
61
|
+
let { href, current, children, mix, ...rest } = handle.props;
|
|
62
|
+
let frame = [
|
|
63
|
+
/**
|
|
64
|
+
* Every variant's frame lives in one rule keyed off the group, so the variant always
|
|
65
|
+
* wins over the default card frame whatever order the stylesheet layers land in.
|
|
66
|
+
*/
|
|
67
|
+
raw({
|
|
68
|
+
display: "grid",
|
|
69
|
+
gridTemplateColumns: "minmax(0, 1fr) auto",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
alignContent: "start",
|
|
72
|
+
columnGap: "0.75rem",
|
|
73
|
+
rowGap: "0.375rem",
|
|
74
|
+
minInlineSize: "0",
|
|
75
|
+
padding: "var(--ui-stat-card-padding, 1.25rem)",
|
|
76
|
+
border: `1px solid ${BORDER}`,
|
|
77
|
+
borderRadius: "var(--ui-radius-lg, 0.75rem)",
|
|
78
|
+
backgroundColor: "var(--ui-bg, Canvas)",
|
|
79
|
+
color: "inherit",
|
|
80
|
+
textDecoration: "none",
|
|
81
|
+
outlineOffset: "-2px",
|
|
82
|
+
transition: "background-color 150ms ease-out",
|
|
83
|
+
'[data-stat-group="ruled"] > &': {
|
|
84
|
+
paddingInline: "0",
|
|
85
|
+
paddingBlockEnd: "0",
|
|
86
|
+
border: "none",
|
|
87
|
+
borderBlockStart: `1px solid ${BORDER}`,
|
|
88
|
+
borderRadius: "0",
|
|
89
|
+
backgroundColor: "transparent",
|
|
90
|
+
},
|
|
91
|
+
'[data-stat-group="tabs"] > &': {
|
|
92
|
+
border: "none",
|
|
93
|
+
borderInlineEnd: `1px solid ${BORDER}`,
|
|
94
|
+
borderBlockEnd: `1px solid ${BORDER}`,
|
|
95
|
+
borderRadius: "0",
|
|
96
|
+
backgroundColor: "transparent",
|
|
97
|
+
},
|
|
98
|
+
"&:is(a):hover": { backgroundColor: "var(--ui-neutral-bg-tint, transparent)" },
|
|
99
|
+
'&[aria-current="true"]': {
|
|
100
|
+
boxShadow: "inset 0 -2px 0 0 var(--ui-brand-fg, currentColor)",
|
|
101
|
+
},
|
|
102
|
+
"&:focus-visible": { outline: "2px solid var(--ui-brand-ring, Highlight)" },
|
|
103
|
+
"@media (prefers-reduced-motion: reduce)": { transition: "none" },
|
|
104
|
+
[STAT_COMPACT]: {
|
|
105
|
+
'[data-stat-split]:not([data-stat-group="ruled"]) > &': {
|
|
106
|
+
padding: "var(--ui-stat-card-padding, 0.875rem)",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
];
|
|
111
|
+
if (href !== undefined) {
|
|
112
|
+
return (_jsx("a", { href: href, "aria-current": current ? "true" : undefined, "data-slot": "stat-card", ...rest, mix: mergeMix(frame, mix), children: children }));
|
|
113
|
+
}
|
|
114
|
+
return (_jsx("div", { "data-slot": "stat-card", ...rest, mix: mergeMix(frame, mix), children: children }));
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Lays stats out by the width of their container: one column, two compact ones from 18rem,
|
|
119
|
+
* two full-size from 28rem, and `columns` from 52rem. `cards` boxes each stat, `ruled` sets them as columns under a 1px rule, and
|
|
120
|
+
* `tabs` joins link cards into one divided strip, the current one underlined.
|
|
121
|
+
*
|
|
122
|
+
* @param handle Runtime handle carrying the group's props.
|
|
123
|
+
* @returns The render function producing the group's markup.
|
|
124
|
+
* @example
|
|
125
|
+
* <StatCard.Group variant="ruled" aria-label={t("stats.overview")}>{cards}</StatCard.Group>
|
|
126
|
+
* @example
|
|
127
|
+
* <StatCard.Group variant="tabs" columns={3} aria-label={t("stats.metrics")}>{tabs}</StatCard.Group>
|
|
128
|
+
*/
|
|
129
|
+
StatCard.Group = function StatCardGroup(handle) {
|
|
130
|
+
return () => {
|
|
131
|
+
let { variant, columns, children, mix, ...rest } = handle.props;
|
|
132
|
+
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
133
|
+
let wide = Math.max(1, Math.round(columns ?? DEFAULT_COLUMNS));
|
|
134
|
+
let middle = Math.min(2, wide);
|
|
135
|
+
let tabs = resolvedVariant === "tabs";
|
|
136
|
+
return (_jsx("div", { role: "group", "data-slot": "stat-group", "data-variant": resolvedVariant, ...rest, mix: mergeMix([
|
|
137
|
+
block(),
|
|
138
|
+
is("full"),
|
|
139
|
+
minIs(0),
|
|
140
|
+
container(STAT_GROUP_CONTAINER),
|
|
141
|
+
tabs
|
|
142
|
+
? raw({
|
|
143
|
+
border: `1px solid ${BORDER}`,
|
|
144
|
+
borderRadius: "var(--ui-radius-lg, 0.75rem)",
|
|
145
|
+
overflow: "clip",
|
|
146
|
+
})
|
|
147
|
+
: undefined,
|
|
148
|
+
], mix), children: _jsx("div", { "data-stat-group": resolvedVariant, "data-stat-split": middle > 1 ? "" : undefined, mix: [
|
|
149
|
+
grid(),
|
|
150
|
+
/**
|
|
151
|
+
* Every column count lives in one rule, so the widest layout that fits always wins
|
|
152
|
+
* whatever order the stylesheet layers land in.
|
|
153
|
+
*/
|
|
154
|
+
raw({
|
|
155
|
+
gridTemplateColumns: "minmax(0, 1fr)",
|
|
156
|
+
gap: tabs ? "0" : "1rem",
|
|
157
|
+
columnGap: resolvedVariant === "ruled" ? "2rem" : undefined,
|
|
158
|
+
rowGap: resolvedVariant === "ruled" ? "1.5rem" : undefined,
|
|
159
|
+
marginInlineEnd: tabs ? "-1px" : undefined,
|
|
160
|
+
marginBlockEnd: tabs ? "-1px" : undefined,
|
|
161
|
+
[`@container ${STAT_GROUP_CONTAINER} (min-width: 18rem)`]: {
|
|
162
|
+
gridTemplateColumns: `repeat(${middle}, minmax(0, 1fr))`,
|
|
163
|
+
},
|
|
164
|
+
[`@container ${STAT_GROUP_CONTAINER} (min-width: 52rem)`]: {
|
|
165
|
+
gridTemplateColumns: `repeat(${wide}, minmax(0, 1fr))`,
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
], children: children }) }));
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Renders the stat's name in muted 14px text at the start of the first line.
|
|
173
|
+
*
|
|
174
|
+
* @param handle Runtime handle carrying the label's props.
|
|
175
|
+
* @returns The render function producing the label's markup.
|
|
176
|
+
* @example
|
|
177
|
+
* <StatCard.Label>{t("stats.p95")}</StatCard.Label>
|
|
178
|
+
*/
|
|
179
|
+
StatCard.Label = function StatCardLabel(handle) {
|
|
180
|
+
return () => {
|
|
181
|
+
let { mix, ...rest } = handle.props;
|
|
182
|
+
return (_jsx("div", { "data-slot": "stat-card-label", ...rest, mix: mergeMix([
|
|
183
|
+
raw({ order: 0, minInlineSize: "0" }),
|
|
184
|
+
text("sm"),
|
|
185
|
+
weight("medium"),
|
|
186
|
+
fg("neutral.muted"),
|
|
187
|
+
], mix) }));
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Renders the number at `--ui-stat-value-size` (30px in a card, 24px in ruled columns, 22px in
|
|
192
|
+
* a compact group), semibold in tabular figures, so values in a row line up and a live update
|
|
193
|
+
* never shifts its width. Pass `—` for an unknown value.
|
|
194
|
+
*
|
|
195
|
+
* @param handle Runtime handle carrying the value's props.
|
|
196
|
+
* @returns The render function producing the value's markup.
|
|
197
|
+
* @example
|
|
198
|
+
* <StatCard.Value>182 ms</StatCard.Value>
|
|
199
|
+
*/
|
|
200
|
+
StatCard.Value = function StatCardValue(handle) {
|
|
201
|
+
return () => {
|
|
202
|
+
let { mix, ...rest } = handle.props;
|
|
203
|
+
return (_jsx("div", { "data-slot": "stat-card-value", ...rest, mix: mergeMix([
|
|
204
|
+
tabularNums(),
|
|
205
|
+
raw({
|
|
206
|
+
order: 2,
|
|
207
|
+
gridColumn: "1 / -1",
|
|
208
|
+
minInlineSize: "0",
|
|
209
|
+
fontSize: "var(--ui-stat-value-size, 1.875rem)",
|
|
210
|
+
lineHeight: "1.2",
|
|
211
|
+
fontWeight: "600",
|
|
212
|
+
letterSpacing: "-0.01em",
|
|
213
|
+
'[data-stat-group="ruled"] > * > &': {
|
|
214
|
+
fontSize: "var(--ui-stat-value-size, 1.5rem)",
|
|
215
|
+
},
|
|
216
|
+
[STAT_COMPACT]: {
|
|
217
|
+
"[data-stat-split] > * > &": { fontSize: "var(--ui-stat-value-size, 1.375rem)" },
|
|
218
|
+
},
|
|
219
|
+
}),
|
|
220
|
+
], mix) }));
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Renders the change as a pill toned by meaning (success when it moved the good way, danger
|
|
225
|
+
* when the bad way, neutral when flat) with a decorative arrow, then the comparison in muted
|
|
226
|
+
* text. It sits at the end of the label's line in a card, and under the value elsewhere.
|
|
227
|
+
*
|
|
228
|
+
* @param handle Runtime handle carrying the delta's props.
|
|
229
|
+
* @returns The render function producing the delta's markup.
|
|
230
|
+
* @example
|
|
231
|
+
* <StatCard.Delta trend="up" invert trendLabel={t("stats.increased")} comparison={t("stats.vsLastWeek")}>+12 ms</StatCard.Delta>
|
|
232
|
+
*/
|
|
233
|
+
StatCard.Delta = function StatCardDelta(handle) {
|
|
234
|
+
return () => {
|
|
235
|
+
let { trend, invert, trendLabel, comparison, children, mix, ...rest } = handle.props;
|
|
236
|
+
let tone = deltaTone(trend, invert ?? false);
|
|
237
|
+
let Icon = TREND_ICONS[trend];
|
|
238
|
+
return (_jsxs("span", { "data-slot": "stat-card-delta", "data-trend": trend, "data-tone": tone, ...rest, mix: mergeMix([hstack({ gap: 1.5, align: "center" }), nowrap(), statDeltaPlacement()], mix), children: [_jsxs("span", { "data-slot": "stat-card-delta-pill", mix: [
|
|
239
|
+
inlineFlex(),
|
|
240
|
+
items("center"),
|
|
241
|
+
raw({ gap: "0.25rem" }),
|
|
242
|
+
bs("var(--ui-stat-delta-block-size, 1.375rem)"),
|
|
243
|
+
pi(2),
|
|
244
|
+
rounded("full"),
|
|
245
|
+
border({ width: 1, style: "solid" }),
|
|
246
|
+
text("xs"),
|
|
247
|
+
weight("medium"),
|
|
248
|
+
tabularNums(),
|
|
249
|
+
data("tone", "success", [bg("success.tint"), fg("success"), border("success")]),
|
|
250
|
+
data("tone", "danger", [bg("danger.tint"), fg("danger"), border("danger")]),
|
|
251
|
+
data("tone", "neutral", [bg("neutral.tint"), fg("neutral"), border("neutral")]),
|
|
252
|
+
], "data-tone": tone, children: [_jsx(Icon, { size: 12, "aria-hidden": "true" }), trendLabel ? _jsx("span", { mix: [visuallyHidden()], children: trendLabel }) : null, children] }), comparison === undefined ? null : (_jsx("span", { "data-slot": "stat-card-comparison", mix: [text("xs"), fg("neutral.muted")], children: comparison }))] }));
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Holds a trend under the value, such as a {@link Sparkline}, at `--ui-stat-chart-block-size`
|
|
257
|
+
* across the card's full width.
|
|
258
|
+
*
|
|
259
|
+
* @param handle Runtime handle carrying the slot's props.
|
|
260
|
+
* @returns The render function producing the slot's markup.
|
|
261
|
+
* @example
|
|
262
|
+
* <StatCard.Chart><Sparkline values={latency} label={t("stats.latencyTrend")} area /></StatCard.Chart>
|
|
263
|
+
*/
|
|
264
|
+
StatCard.Chart = function StatCardChart(handle) {
|
|
265
|
+
return () => {
|
|
266
|
+
let { mix, ...rest } = handle.props;
|
|
267
|
+
return (_jsx("div", { "data-slot": "stat-card-chart", ...rest, mix: mergeMix([
|
|
268
|
+
raw({
|
|
269
|
+
order: 4,
|
|
270
|
+
gridColumn: "1 / -1",
|
|
271
|
+
display: "flex",
|
|
272
|
+
alignItems: "stretch",
|
|
273
|
+
minInlineSize: "0",
|
|
274
|
+
blockSize: "var(--ui-stat-chart-block-size, 2.5rem)",
|
|
275
|
+
"--ui-sparkline-block-size": "100%",
|
|
276
|
+
}),
|
|
277
|
+
], mix) }));
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Renders the sentence that explains the number ("2 monitors down since 09:14"), muted, under
|
|
282
|
+
* everything else.
|
|
283
|
+
*
|
|
284
|
+
* @param handle Runtime handle carrying the footer's props.
|
|
285
|
+
* @returns The render function producing the footer's markup.
|
|
286
|
+
* @example
|
|
287
|
+
* <StatCard.Footer>{t("stats.incidentsFooter", { count: 2 })}</StatCard.Footer>
|
|
288
|
+
*/
|
|
289
|
+
StatCard.Footer = function StatCardFooter(handle) {
|
|
290
|
+
return () => {
|
|
291
|
+
let { mix, ...rest } = handle.props;
|
|
292
|
+
return (_jsx("div", { "data-slot": "stat-card-footer", ...rest, mix: mergeMix([
|
|
293
|
+
raw({
|
|
294
|
+
order: 5,
|
|
295
|
+
gridColumn: "1 / -1",
|
|
296
|
+
minInlineSize: "0",
|
|
297
|
+
marginBlockStart: "0.25rem",
|
|
298
|
+
}),
|
|
299
|
+
text("sm"),
|
|
300
|
+
fg("neutral.muted"),
|
|
301
|
+
], mix) }));
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Stands in for a stat while it loads: the same parts placed by the same container queries,
|
|
306
|
+
* with bars that wrap where a comparison and a 40-character footer sentence wrap, so the card
|
|
307
|
+
* keeps its height when the real one streams in.
|
|
308
|
+
*
|
|
309
|
+
* @param handle Runtime handle carrying the skeleton's props.
|
|
310
|
+
* @returns The render function producing the placeholder's markup.
|
|
311
|
+
* @example
|
|
312
|
+
* <StatCard.Skeleton chart />
|
|
313
|
+
* @example
|
|
314
|
+
* <StatCard.Skeleton comparison={false} footer={false} />
|
|
315
|
+
* @example
|
|
316
|
+
* <StatCard.Skeleton footerLines={2} />
|
|
317
|
+
* @example
|
|
318
|
+
* <StatCard.Skeleton label="Monthly Pings Usage" footer="Out of 43,200 estimated" delta={false} />
|
|
319
|
+
*/
|
|
320
|
+
StatCard.Skeleton = function StatCardSkeleton(handle) {
|
|
321
|
+
return () => {
|
|
322
|
+
let { delta, comparison, chart, footer, footerLines, label, mix, ...rest } = handle.props;
|
|
323
|
+
return (_jsxs(StatCard, { "aria-hidden": "true", "data-skeleton": "", ...rest, mix: mix, children: [_jsx(StatCard.Label, { children: label ? (_jsx(StatCardGhostText, { slot: "stat-card-skeleton-label", children: label })) : (_jsx(StatCardBar, { width: "40%" })) }), _jsx(StatCard.Value, { children: _jsx(StatCardBar, { width: "5ch" }) }), (delta ?? DEFAULT_SKELETON_DELTA) ? (_jsxs("span", { "data-slot": "stat-card-delta", mix: [hstack({ gap: 1.5, align: "center" }), nowrap(), statDeltaPlacement()], children: [_jsx("span", { mix: [
|
|
324
|
+
block(),
|
|
325
|
+
is("3.5rem"),
|
|
326
|
+
bs("var(--ui-stat-delta-block-size, 1.375rem)"),
|
|
327
|
+
rounded("full"),
|
|
328
|
+
raw({ backgroundColor: BORDER }),
|
|
329
|
+
] }), (comparison ?? DEFAULT_SKELETON_COMPARISON) ? (_jsx("span", { "data-slot": "stat-card-comparison", mix: [text("xs")], children: _jsx(StatCardBar, { width: COMPARISON_BAR }) })) : null] })) : null, chart ? (_jsx(StatCard.Chart, { children: _jsx(StatCardBar, { width: "100%", block: true }) })) : null, (footer ?? DEFAULT_SKELETON_FOOTER) ? (_jsx(StatCard.Footer, { children: _jsx(StatCardSkeletonFooter, { footer: footer, lines: footerLines }) })) : null] }));
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* A skeleton's footer lines: the real text when given, else a fixed number of lines, else bars
|
|
334
|
+
* that wrap where a 40-character sentence does.
|
|
335
|
+
*/
|
|
336
|
+
function StatCardSkeletonFooter(handle) {
|
|
337
|
+
return () => {
|
|
338
|
+
let { footer, lines } = handle.props;
|
|
339
|
+
if (typeof footer === "string") {
|
|
340
|
+
return _jsx(StatCardGhostText, { slot: "stat-card-skeleton-footer", children: footer });
|
|
341
|
+
}
|
|
342
|
+
if (lines) {
|
|
343
|
+
return FOOTER_LINE_WIDTHS.slice(0, lines).map((width) => (_jsx("span", { mix: [block()], children: _jsx(StatCardBar, { width: width }) })));
|
|
344
|
+
}
|
|
345
|
+
return (_jsxs(_Fragment, { children: [_jsx(StatCardBar, { width: "6em" }), " ", _jsx(StatCardBar, { width: "4em" }), " ", _jsx(StatCardBar, { width: "5em" })] }));
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Real copy drawn as invisible text on a placeholder bar, one bar per wrapped line, so a
|
|
350
|
+
* skeleton's part wraps to exactly the lines the card's text takes at every width.
|
|
351
|
+
*/
|
|
352
|
+
function StatCardGhostText(handle) {
|
|
353
|
+
return () => (_jsx("span", { "data-slot": handle.props.slot, mix: [
|
|
354
|
+
rounded("md"),
|
|
355
|
+
raw({
|
|
356
|
+
color: "transparent",
|
|
357
|
+
backgroundColor: BORDER,
|
|
358
|
+
boxDecorationBreak: "clone",
|
|
359
|
+
WebkitBoxDecorationBreak: "clone",
|
|
360
|
+
}),
|
|
361
|
+
], children: handle.props.children }));
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* One placeholder bar: an inline block shorter than its line, so the part around it keeps
|
|
365
|
+
* the line height the real text gives it, or a block filling a slot of fixed height.
|
|
366
|
+
*/
|
|
367
|
+
function StatCardBar(handle) {
|
|
368
|
+
return () => {
|
|
369
|
+
let { width, block: fills } = handle.props;
|
|
370
|
+
return (_jsx("span", { "data-slot": "stat-card-skeleton-bar", mix: [
|
|
371
|
+
fills ? block() : inlineBlock(),
|
|
372
|
+
is(width),
|
|
373
|
+
bs(fills ? "100%" : "0.75em"),
|
|
374
|
+
verticalAlign("middle"),
|
|
375
|
+
rounded("md"),
|
|
376
|
+
raw({ backgroundColor: BORDER }),
|
|
377
|
+
] }));
|
|
378
|
+
};
|
|
379
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A row of per-period bars, such as 90 days of uptime: each bar is tinted by its status,
|
|
3
|
+
* hatched where nothing was recorded, and shows its date and value on hover or focus, with a
|
|
4
|
+
* caption naming the window and the summary figure. Bars thin out to fit any container, and
|
|
5
|
+
* form one Tab stop that ←/→, Home and End move through once its island hydrates.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { EntryComponent, Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
11
|
+
/**
|
|
12
|
+
* Prop types for {@link StatusStrip}.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace StatusStrip {
|
|
15
|
+
/**
|
|
16
|
+
* What one period recorded: `up` is success, `degraded` warning, `down` danger, `paused`
|
|
17
|
+
* neutral, and `no-data` a hatched bar that reads as unknown rather than as zero.
|
|
18
|
+
*/
|
|
19
|
+
type Status = "up" | "degraded" | "down" | "paused" | "no-data";
|
|
20
|
+
/** One period, oldest first in {@link Props.periods}. */
|
|
21
|
+
interface Period {
|
|
22
|
+
status: Status;
|
|
23
|
+
/** The period's date or name, shown first in its tooltip ("Oct 3"). */
|
|
24
|
+
label: string;
|
|
25
|
+
/** The period's figure, shown after the label ("99.2% · 1,438 of 1,440 checks"). */
|
|
26
|
+
value?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Per-part styling for the parts a strip composes. */
|
|
29
|
+
interface PartsProps {
|
|
30
|
+
caption?: TagProps<"div">["mix"];
|
|
31
|
+
bars?: TagProps<"div">["mix"];
|
|
32
|
+
bar?: TagProps<"button">["mix"];
|
|
33
|
+
}
|
|
34
|
+
/** Props accepted by {@link StatusStrip}. */
|
|
35
|
+
interface Props extends Omit<TagProps<"div">, "children"> {
|
|
36
|
+
periods: readonly Period[];
|
|
37
|
+
/** Accessible name of the bars' toolbar ("Uptime, last 90 days"). */
|
|
38
|
+
label: string;
|
|
39
|
+
/** The summary figure set in the middle of the caption ("99.95% uptime"). */
|
|
40
|
+
summary?: RemixNode;
|
|
41
|
+
/** Caption under the oldest end ("90 days ago"). */
|
|
42
|
+
start?: RemixNode;
|
|
43
|
+
/** Caption under the newest end ("Today"). */
|
|
44
|
+
end?: RemixNode;
|
|
45
|
+
parts?: PartsProps;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Renders one bar per period as a button named by its label and value, inside a toolbar named by
|
|
50
|
+
* `label`, then the caption. The newest bar is the strip's one Tab stop, and {@link StatusStripKeys}
|
|
51
|
+
* moves it with the arrows; a bar's tooltip shows its name on hover and keyboard focus with no script.
|
|
52
|
+
*
|
|
53
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
54
|
+
* @returns The render function producing the strip's markup.
|
|
55
|
+
* @example
|
|
56
|
+
* <StatusStrip
|
|
57
|
+
* label={t("monitor.uptimeWindow")}
|
|
58
|
+
* summary={t("monitor.uptime", { percent: "99.95" })}
|
|
59
|
+
* start={t("time.daysAgo", { count: 90 })}
|
|
60
|
+
* end={t("time.today")}
|
|
61
|
+
* periods={days.map((day) => ({ status: day.status, label: formatDay(day.date), value: formatUptime(day) }))}
|
|
62
|
+
* />
|
|
63
|
+
*/
|
|
64
|
+
export declare function StatusStrip(handle: Handle<StatusStrip.Props>): () => import("remix/component").RemixElement;
|
|
65
|
+
/**
|
|
66
|
+
* Client island behind {@link StatusStrip}'s keyboard navigation: a hidden marker whose
|
|
67
|
+
* `statusStripKeys()` walks the strip it sits in. Loads from `@sdxc/ui/app/status-strip#StatusStripKeys`
|
|
68
|
+
* once the app's browser entry maps it; until then the newest bar stays the strip's one Tab stop.
|
|
69
|
+
*/
|
|
70
|
+
export declare const StatusStripKeys: EntryComponent<Record<never, never>>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { bg, fg } from "@sdxc/u/color";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { container, flex, grow, hstack, relative, vstack } from "@sdxc/u/layout";
|
|
5
|
+
import { bs, minIs } from "@sdxc/u/size";
|
|
6
|
+
import { nowrap, tabularNums, text, weight } from "@sdxc/u/typography";
|
|
7
|
+
import { clientEntry } from "remix/component";
|
|
8
|
+
import { statusStripKeys } from "./mixins/status-strip-keys.js";
|
|
9
|
+
/** Container the strip measures, so its bars tighten in a narrow card rather than a narrow page. */
|
|
10
|
+
const STRIP_CONTAINER = "ui-status-strip";
|
|
11
|
+
/**
|
|
12
|
+
* Share of the strip, from either end, inside which a bar's tooltip aligns to that end instead
|
|
13
|
+
* of centring, so a tooltip near the edge stays inside the strip's box.
|
|
14
|
+
*/
|
|
15
|
+
const EDGE_SHARE = 0.2;
|
|
16
|
+
/**
|
|
17
|
+
* Pins the tooltips of the bars near either end to that end instead of centring them, so a
|
|
18
|
+
* tooltip near the edge stays inside the strip's box. The rule depends only on the bar count, so
|
|
19
|
+
* every strip of the same length shares it.
|
|
20
|
+
*
|
|
21
|
+
* @param count How many bars the strip draws.
|
|
22
|
+
* @returns The rules aligning the oldest and newest bars' tooltips to their ends.
|
|
23
|
+
*/
|
|
24
|
+
function edgeRules(count) {
|
|
25
|
+
let edge = count <= 1 ? 0 : Math.ceil(EDGE_SHARE * (count - 1));
|
|
26
|
+
if (edge === 0)
|
|
27
|
+
return {};
|
|
28
|
+
let rules = {};
|
|
29
|
+
rules[`& > button:nth-child(-n + ${edge})::after`] = {
|
|
30
|
+
insetInlineStart: "0",
|
|
31
|
+
insetInlineEnd: "auto",
|
|
32
|
+
translate: "none",
|
|
33
|
+
};
|
|
34
|
+
rules[`& > button:nth-last-child(-n + ${edge})::after`] = {
|
|
35
|
+
insetInlineStart: "auto",
|
|
36
|
+
insetInlineEnd: "0",
|
|
37
|
+
translate: "none",
|
|
38
|
+
};
|
|
39
|
+
return rules;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Renders one bar per period as a button named by its label and value, inside a toolbar named by
|
|
43
|
+
* `label`, then the caption. The newest bar is the strip's one Tab stop, and {@link StatusStripKeys}
|
|
44
|
+
* moves it with the arrows; a bar's tooltip shows its name on hover and keyboard focus with no script.
|
|
45
|
+
*
|
|
46
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
47
|
+
* @returns The render function producing the strip's markup.
|
|
48
|
+
* @example
|
|
49
|
+
* <StatusStrip
|
|
50
|
+
* label={t("monitor.uptimeWindow")}
|
|
51
|
+
* summary={t("monitor.uptime", { percent: "99.95" })}
|
|
52
|
+
* start={t("time.daysAgo", { count: 90 })}
|
|
53
|
+
* end={t("time.today")}
|
|
54
|
+
* periods={days.map((day) => ({ status: day.status, label: formatDay(day.date), value: formatUptime(day) }))}
|
|
55
|
+
* />
|
|
56
|
+
*/
|
|
57
|
+
export function StatusStrip(handle) {
|
|
58
|
+
return () => {
|
|
59
|
+
let { periods, label, summary, start, end, parts, mix, ...rest } = handle.props;
|
|
60
|
+
let hasCaption = summary !== undefined || start !== undefined || end !== undefined;
|
|
61
|
+
return (_jsxs("div", { "data-slot": "status-strip", ...rest, mix: mergeMix([vstack({ gap: 1.5, align: "stretch" }), minIs(0), container(STRIP_CONTAINER)], mix), children: [_jsx("div", { role: "toolbar", "aria-label": label, "data-slot": "status-strip-bars", mix: [
|
|
62
|
+
relative(),
|
|
63
|
+
flex(),
|
|
64
|
+
bs("var(--ui-status-strip-block-size, 2rem)"),
|
|
65
|
+
/**
|
|
66
|
+
* Every bar and its tooltip is painted from this one rule, so a bar's markup is only
|
|
67
|
+
* its status, Tab order and name. Both gaps, every status and the tooltip's shown
|
|
68
|
+
* state share it, so each always wins whatever order the stylesheet layers land in.
|
|
69
|
+
*/
|
|
70
|
+
raw({
|
|
71
|
+
gap: "1px",
|
|
72
|
+
[`@container ${STRIP_CONTAINER} (min-width: 30rem)`]: {
|
|
73
|
+
gap: "var(--ui-status-strip-gap, 2px)",
|
|
74
|
+
},
|
|
75
|
+
"& > button": {
|
|
76
|
+
position: "relative",
|
|
77
|
+
flexGrow: "1",
|
|
78
|
+
flexBasis: "0%",
|
|
79
|
+
minInlineSize: "0",
|
|
80
|
+
padding: "0",
|
|
81
|
+
border: "none",
|
|
82
|
+
cursor: "default",
|
|
83
|
+
borderRadius: "var(--ui-status-strip-radius, 1px)",
|
|
84
|
+
backgroundColor: "var(--ui-neutral-border)",
|
|
85
|
+
},
|
|
86
|
+
'& > [data-status="up"]': { backgroundColor: "var(--ui-success-bg-solid)" },
|
|
87
|
+
'& > [data-status="degraded"]': { backgroundColor: "var(--ui-warning-bg-solid)" },
|
|
88
|
+
'& > [data-status="down"]': { backgroundColor: "var(--ui-danger-bg-solid)" },
|
|
89
|
+
'& > [data-status="no-data"]': {
|
|
90
|
+
backgroundColor: "transparent",
|
|
91
|
+
backgroundImage: "repeating-linear-gradient(-45deg, var(--ui-neutral-border, color-mix(in oklab, CanvasText 16%, transparent)) 0 1.5px, transparent 1.5px 4px)",
|
|
92
|
+
boxShadow: "inset 0 0 0 1px var(--ui-neutral-border, color-mix(in oklab, CanvasText 16%, transparent))",
|
|
93
|
+
},
|
|
94
|
+
"& > button:hover": { opacity: "0.8" },
|
|
95
|
+
"& > button:focus-visible": {
|
|
96
|
+
outline: "2px solid var(--ui-brand-ring)",
|
|
97
|
+
outlineOffset: "1px",
|
|
98
|
+
zIndex: "1",
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* The tooltip is the bar's own generated box reading its accessible name, so it
|
|
102
|
+
* needs no markup and no script. Hidden, it takes no box at all, so the bars at the
|
|
103
|
+
* edges never widen a page, and shown it wraps inside the strip's width.
|
|
104
|
+
*/
|
|
105
|
+
"& > button::after": {
|
|
106
|
+
content: "attr(aria-label)",
|
|
107
|
+
position: "absolute",
|
|
108
|
+
zIndex: "10",
|
|
109
|
+
display: "none",
|
|
110
|
+
boxSizing: "border-box",
|
|
111
|
+
inlineSize: "max-content",
|
|
112
|
+
maxInlineSize: "100cqi",
|
|
113
|
+
insetBlockEnd: "calc(100% + var(--ui-status-strip-tooltip-gap, 0.375rem))",
|
|
114
|
+
insetInlineStart: "50%",
|
|
115
|
+
translate: "-50% 0",
|
|
116
|
+
paddingInline: "calc(var(--ui-spacing, 0.25rem) * 2)",
|
|
117
|
+
paddingBlock: "var(--ui-spacing, 0.25rem)",
|
|
118
|
+
borderRadius: "var(--ui-radius-md, 0.375rem)",
|
|
119
|
+
color: "var(--ui-neutral-fg-on-solid)",
|
|
120
|
+
backgroundColor: "var(--ui-neutral-bg-solid)",
|
|
121
|
+
boxShadow: "var(--ui-shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1))",
|
|
122
|
+
fontSize: "var(--ui-text-xs, 0.75rem)",
|
|
123
|
+
lineHeight: "var(--ui-leading-xs, calc(1 / 0.75))",
|
|
124
|
+
fontWeight: "500",
|
|
125
|
+
fontVariantNumeric: "tabular-nums",
|
|
126
|
+
textAlign: "start",
|
|
127
|
+
whiteSpace: "normal",
|
|
128
|
+
pointerEvents: "none",
|
|
129
|
+
},
|
|
130
|
+
"& > button:is(:hover, :focus-visible)::after": { display: "block" },
|
|
131
|
+
}),
|
|
132
|
+
raw(edgeRules(periods.length)),
|
|
133
|
+
parts?.bars,
|
|
134
|
+
], children: periods.map((period, index) => (_jsx("button", { type: "button", tabIndex: index === periods.length - 1 ? 0 : -1, "aria-label": period.value ? `${period.label}, ${period.value}` : period.label, "data-status": period.status, mix: parts?.bar }, index))) }), _jsx(StatusStripKeys, {}), hasCaption ? (_jsxs("div", { "data-slot": "status-strip-caption", mix: [
|
|
135
|
+
hstack({ gap: 2, align: "center" }),
|
|
136
|
+
text("xs"),
|
|
137
|
+
fg("neutral.muted"),
|
|
138
|
+
nowrap(),
|
|
139
|
+
tabularNums(),
|
|
140
|
+
parts?.caption,
|
|
141
|
+
], children: [start === undefined ? null : _jsx("span", { children: start }), _jsx(StatusStripRule, {}), summary === undefined ? null : (_jsx("span", { "data-slot": "status-strip-summary", mix: [fg("neutral"), weight("medium")], children: summary })), summary === undefined ? null : _jsx(StatusStripRule, {}), end === undefined ? null : _jsx("span", { children: end })] })) : null] }));
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Client island behind {@link StatusStrip}'s keyboard navigation: a hidden marker whose
|
|
146
|
+
* `statusStripKeys()` walks the strip it sits in. Loads from `@sdxc/ui/app/status-strip#StatusStripKeys`
|
|
147
|
+
* once the app's browser entry maps it; until then the newest bar stays the strip's one Tab stop.
|
|
148
|
+
*/
|
|
149
|
+
export const StatusStripKeys = clientEntry("@sdxc/ui/app/status-strip#StatusStripKeys", function StatusStripKeys() {
|
|
150
|
+
return () => _jsx("span", { hidden: true, "data-slot": "status-strip-keys", mix: [statusStripKeys()] });
|
|
151
|
+
});
|
|
152
|
+
/** The hairline filling the caption between its words, so the summary sits centred in the window. */
|
|
153
|
+
function StatusStripRule() {
|
|
154
|
+
return () => _jsx("span", { "aria-hidden": "true", mix: [grow(), bs("1px"), bg("neutral.border")] });
|
|
155
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The placement every settings-style action row shares: a button that acts at once sits at
|
|
3
|
+
* the row's end centred on the title's first line, or under the text at its start, and a
|
|
4
|
+
* narrow container always stacks it under the text.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { UtilityMixin } from "@sdxc/u";
|
|
10
|
+
import type { ElementProps, MixinDescriptor } from "remix/component";
|
|
11
|
+
import type { CSSStyles } from "../../utils/css-styles.js";
|
|
12
|
+
/**
|
|
13
|
+
* Where an action row's button sits on a wide container: `"end"` beside the title's first
|
|
14
|
+
* line, for a description of a line or two; `"below"` under the text, for a longer one or
|
|
15
|
+
* one holding a list or warning.
|
|
16
|
+
*/
|
|
17
|
+
export type ActionPlacement = "end" | "below";
|
|
18
|
+
/**
|
|
19
|
+
* Lays out an action row as a grid of its text block and its control: one column with the
|
|
20
|
+
* control under the text at its start, and for `"end"` on a container at least 32rem wide,
|
|
21
|
+
* the text taking the flexible width and the control its own at the end.
|
|
22
|
+
*
|
|
23
|
+
* @param containerName The container query name the row measures.
|
|
24
|
+
* @param placement Where the control sits on a wide container.
|
|
25
|
+
* @param gap The grid's row and column gap.
|
|
26
|
+
* @returns A mixin for the row's grid element.
|
|
27
|
+
* @example
|
|
28
|
+
* <div mix={[actionRowGrid("ui-settings-card", "end", "0.5rem 1.5rem")]}>{text}{control}</div>
|
|
29
|
+
*/
|
|
30
|
+
export declare function actionRowGrid<Node extends Element = Element>(containerName: string, placement: ActionPlacement, gap: string): MixinDescriptor<Node, [styles: CSSStyles], ElementProps>;
|
|
31
|
+
/**
|
|
32
|
+
* Centres an end-placed control on the title's first line: on a wide container the
|
|
33
|
+
* control's box is one small-text line tall and the button overflows it evenly into the
|
|
34
|
+
* row's padding. Below 32rem the box wraps the control as stacked content.
|
|
35
|
+
*
|
|
36
|
+
* @param containerName The container query name the row measures.
|
|
37
|
+
* @returns The mixins for the element wrapping the row's control.
|
|
38
|
+
* @example
|
|
39
|
+
* <div mix={[onTitleLine("ui-settings-card")]}><Button>Open billing portal</Button></div>
|
|
40
|
+
*/
|
|
41
|
+
export declare function onTitleLine(containerName: string): UtilityMixin[];
|