@xeonr/platform-ui 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/AuthCode.d.ts +48 -0
- package/dist/auth/AuthCode.d.ts.map +1 -0
- package/dist/auth/AuthCode.js +197 -0
- package/dist/auth/AuthCode.js.map +1 -0
- package/dist/auth/AuthConsent.d.ts +69 -0
- package/dist/auth/AuthConsent.d.ts.map +1 -0
- package/dist/auth/AuthConsent.js +155 -0
- package/dist/auth/AuthConsent.js.map +1 -0
- package/dist/auth/AuthControls.d.ts +133 -0
- package/dist/auth/AuthControls.d.ts.map +1 -0
- package/dist/auth/AuthControls.js +379 -0
- package/dist/auth/AuthControls.js.map +1 -0
- package/dist/auth/AuthPanel.d.ts +106 -0
- package/dist/auth/AuthPanel.d.ts.map +1 -0
- package/dist/auth/AuthPanel.js +317 -0
- package/dist/auth/AuthPanel.js.map +1 -0
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +15 -0
- package/dist/auth.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kit/Anchored.js +109 -109
- package/dist/kit/Anchored.js.map +1 -1
- package/dist/kit/ApiKeyForm.js +73 -73
- package/dist/kit/ApiKeyForm.js.map +1 -1
- package/dist/kit/ApiKeys.js +144 -144
- package/dist/kit/ApiKeys.js.map +1 -1
- package/dist/kit/Badge.js +45 -45
- package/dist/kit/Badge.js.map +1 -1
- package/dist/kit/Blocks.d.ts.map +1 -1
- package/dist/kit/Blocks.js +103 -102
- package/dist/kit/Blocks.js.map +1 -1
- package/dist/kit/Board.js +54 -54
- package/dist/kit/Board.js.map +1 -1
- package/dist/kit/Button.d.ts +3 -3
- package/dist/kit/Button.d.ts.map +1 -1
- package/dist/kit/Button.js +55 -50
- package/dist/kit/Button.js.map +1 -1
- package/dist/kit/Card.d.ts.map +1 -1
- package/dist/kit/Card.js +36 -29
- package/dist/kit/Card.js.map +1 -1
- package/dist/kit/ChartFrame.js +54 -54
- package/dist/kit/ChartFrame.js.map +1 -1
- package/dist/kit/ChartTypes.js +215 -215
- package/dist/kit/ChartTypes.js.map +1 -1
- package/dist/kit/Charts.js +605 -605
- package/dist/kit/Charts.js.map +1 -1
- package/dist/kit/Checkbox.js +16 -16
- package/dist/kit/Checkbox.js.map +1 -1
- package/dist/kit/Chip.js +21 -21
- package/dist/kit/Chip.js.map +1 -1
- package/dist/kit/Choice.js +24 -24
- package/dist/kit/Choice.js.map +1 -1
- package/dist/kit/CodeEditor.js +25 -25
- package/dist/kit/CodeEditor.js.map +1 -1
- package/dist/kit/Color.js +74 -74
- package/dist/kit/Color.js.map +1 -1
- package/dist/kit/Combobox.js +67 -67
- package/dist/kit/Combobox.js.map +1 -1
- package/dist/kit/CommandPalette.d.ts.map +1 -1
- package/dist/kit/CommandPalette.js +96 -86
- package/dist/kit/CommandPalette.js.map +1 -1
- package/dist/kit/Comment.js +7 -7
- package/dist/kit/Comment.js.map +1 -1
- package/dist/kit/Controls.js +122 -122
- package/dist/kit/Controls.js.map +1 -1
- package/dist/kit/DataGrid.js +97 -97
- package/dist/kit/DataGrid.js.map +1 -1
- package/dist/kit/DataTable.d.ts.map +1 -1
- package/dist/kit/DataTable.js +196 -195
- package/dist/kit/DataTable.js.map +1 -1
- package/dist/kit/DatePicker.js +242 -242
- package/dist/kit/DatePicker.js.map +1 -1
- package/dist/kit/Drawer.d.ts.map +1 -1
- package/dist/kit/Drawer.js +15 -14
- package/dist/kit/Drawer.js.map +1 -1
- package/dist/kit/Dropzone.js +80 -80
- package/dist/kit/Dropzone.js.map +1 -1
- package/dist/kit/Editable.d.ts.map +1 -1
- package/dist/kit/Editable.js +130 -129
- package/dist/kit/Editable.js.map +1 -1
- package/dist/kit/EmptyState.d.ts.map +1 -1
- package/dist/kit/EmptyState.js +14 -13
- package/dist/kit/EmptyState.js.map +1 -1
- package/dist/kit/EntityHeader.d.ts.map +1 -1
- package/dist/kit/EntityHeader.js +17 -16
- package/dist/kit/EntityHeader.js.map +1 -1
- package/dist/kit/Facet.js +52 -52
- package/dist/kit/Facet.js.map +1 -1
- package/dist/kit/FacetRail.js +91 -91
- package/dist/kit/FacetRail.js.map +1 -1
- package/dist/kit/Forbidden.js +7 -7
- package/dist/kit/Forbidden.js.map +1 -1
- package/dist/kit/Form.d.ts.map +1 -1
- package/dist/kit/Form.js +144 -143
- package/dist/kit/Form.js.map +1 -1
- package/dist/kit/Graph.js +429 -429
- package/dist/kit/Graph.js.map +1 -1
- package/dist/kit/GroupedMultiSelect.js +115 -115
- package/dist/kit/GroupedMultiSelect.js.map +1 -1
- package/dist/kit/Icon.d.ts +2 -0
- package/dist/kit/Icon.d.ts.map +1 -1
- package/dist/kit/Icon.js +3 -1
- package/dist/kit/Icon.js.map +1 -1
- package/dist/kit/JumpList.js +11 -11
- package/dist/kit/JumpList.js.map +1 -1
- package/dist/kit/KV.js +6 -6
- package/dist/kit/KV.js.map +1 -1
- package/dist/kit/Layout.js +5 -5
- package/dist/kit/Layout.js.map +1 -1
- package/dist/kit/List.js +74 -74
- package/dist/kit/List.js.map +1 -1
- package/dist/kit/LogView.js +68 -68
- package/dist/kit/LogView.js.map +1 -1
- package/dist/kit/Markdown.js +37 -37
- package/dist/kit/Markdown.js.map +1 -1
- package/dist/kit/Marker.js +42 -42
- package/dist/kit/Marker.js.map +1 -1
- package/dist/kit/Menu.js +128 -128
- package/dist/kit/Menu.js.map +1 -1
- package/dist/kit/Modal.d.ts.map +1 -1
- package/dist/kit/Modal.js +86 -75
- package/dist/kit/Modal.js.map +1 -1
- package/dist/kit/MultiCombobox.js +157 -157
- package/dist/kit/MultiCombobox.js.map +1 -1
- package/dist/kit/PageHeader.d.ts.map +1 -1
- package/dist/kit/PageHeader.js +8 -7
- package/dist/kit/PageHeader.js.map +1 -1
- package/dist/kit/Panel.d.ts.map +1 -1
- package/dist/kit/Panel.js +33 -14
- package/dist/kit/Panel.js.map +1 -1
- package/dist/kit/Picker.js +159 -159
- package/dist/kit/Picker.js.map +1 -1
- package/dist/kit/PipelineFlow.js +86 -86
- package/dist/kit/PipelineFlow.js.map +1 -1
- package/dist/kit/Popover.js +67 -67
- package/dist/kit/Popover.js.map +1 -1
- package/dist/kit/Range.js +76 -76
- package/dist/kit/Range.js.map +1 -1
- package/dist/kit/Reorder.js +95 -95
- package/dist/kit/Reorder.js.map +1 -1
- package/dist/kit/Search.js +27 -27
- package/dist/kit/Search.js.map +1 -1
- package/dist/kit/Secret.js +26 -26
- package/dist/kit/Secret.js.map +1 -1
- package/dist/kit/Skeleton.js +14 -14
- package/dist/kit/Skeleton.js.map +1 -1
- package/dist/kit/Sparkline.js +51 -51
- package/dist/kit/Sparkline.js.map +1 -1
- package/dist/kit/Spectrum.js +163 -163
- package/dist/kit/Spectrum.js.map +1 -1
- package/dist/kit/Splash.js +3 -3
- package/dist/kit/Splash.js.map +1 -1
- package/dist/kit/Split.js +13 -13
- package/dist/kit/Split.js.map +1 -1
- package/dist/kit/SplitButton.d.ts.map +1 -1
- package/dist/kit/SplitButton.js +8 -6
- package/dist/kit/SplitButton.js.map +1 -1
- package/dist/kit/Stat.d.ts.map +1 -1
- package/dist/kit/Stat.js +61 -60
- package/dist/kit/Stat.js.map +1 -1
- package/dist/kit/Stepper.js +22 -22
- package/dist/kit/Stepper.js.map +1 -1
- package/dist/kit/TabStrip.js +68 -68
- package/dist/kit/TabStrip.js.map +1 -1
- package/dist/kit/Text.js +63 -63
- package/dist/kit/Text.js.map +1 -1
- package/dist/kit/Toast.js +29 -29
- package/dist/kit/Toast.js.map +1 -1
- package/dist/kit/Tooltip.js +83 -83
- package/dist/kit/Tooltip.js.map +1 -1
- package/dist/kit/Trace.js +33 -33
- package/dist/kit/Trace.js.map +1 -1
- package/dist/kit/Upload.js +88 -88
- package/dist/kit/Upload.js.map +1 -1
- package/dist/theme/ThemeProvider.d.ts +17 -1
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js +40 -4
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/ThemeScope.d.ts +9 -1
- package/dist/theme/ThemeScope.d.ts.map +1 -1
- package/dist/theme/ThemeScope.js +11 -4
- package/dist/theme/ThemeScope.js.map +1 -1
- package/dist/theme/tokens.d.ts +48 -0
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +167 -3
- package/dist/theme/tokens.js.map +1 -1
- package/package.json +8 -2
- package/scripts/stable-styled-ids.mjs +75 -0
package/dist/kit/Text.js
CHANGED
|
@@ -9,93 +9,93 @@ import { v } from "../theme/tokens.js";
|
|
|
9
9
|
// a figure tinted with the product brand reads as a link, and `run` has no
|
|
10
10
|
// meaning for a value that is already measured.
|
|
11
11
|
const textTones = {
|
|
12
|
-
|
|
12
|
+
ok: v.success, warn: v.warning, crit: v.danger, info: v.info, mut: v.muted, data: v.data
|
|
13
13
|
};
|
|
14
|
-
const toneColour = (t, fallback) =>
|
|
14
|
+
const toneColour = (t, fallback) => t ? textTones[t] : fallback;
|
|
15
15
|
// Text primitives every list and detail screen needs. These replace the
|
|
16
16
|
// MonoId / NameTxt / SubEnv / MutedNote / Num styled spans that each product
|
|
17
17
|
// screen had grown its own copy of.
|
|
18
18
|
/** Mono: a technical string — id, ref, path, host. */
|
|
19
|
-
export const Mono = styled.span `
|
|
19
|
+
export const Mono = styled.span.withConfig({ componentId: "sc-1sd14f-0" })`
|
|
20
20
|
font-family: ${v.mono};
|
|
21
21
|
font-size: ${(p) => p.$size ?? 12}px;
|
|
22
22
|
font-weight: ${(p) => p.$weight ?? "inherit"};
|
|
23
23
|
color: ${(p) => toneColour(p.$tone, p.$dim ? v.muted : v.text)};
|
|
24
|
-
${(p) => p.$truncate && css
|
|
24
|
+
${(p) => p.$truncate && css`display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;`}
|
|
25
25
|
`;
|
|
26
26
|
/** Num: a tabular figure, right-aligned in tables. */
|
|
27
|
-
export const Num = styled.span `
|
|
27
|
+
export const Num = styled.span.withConfig({ componentId: "sc-1sd14f-1" })`
|
|
28
28
|
font-variant-numeric: tabular-nums;
|
|
29
|
-
${(p) => p.$mono && css
|
|
29
|
+
${(p) => p.$mono && css`font-family: ${v.mono}; font-size: 12px;`}
|
|
30
30
|
color: ${(p) => toneColour(p.$tone, p.$faint ? v.faint : p.$dim ? v.muted : v.text)};
|
|
31
31
|
`;
|
|
32
32
|
/** Hint: secondary explanatory text under a control or a block. */
|
|
33
|
-
export const Hint = styled.p `
|
|
33
|
+
export const Hint = styled.p.withConfig({ componentId: "sc-1sd14f-2" })`
|
|
34
34
|
margin: 0;
|
|
35
35
|
font-size: ${(p) => p.$size ?? 11.5}px;
|
|
36
36
|
font-weight: 400;
|
|
37
37
|
line-height: 1.5;
|
|
38
|
-
color: ${(p) =>
|
|
38
|
+
color: ${(p) => p.$tone === "ok" ? v.success : p.$tone === "warn" ? v.warning : p.$tone === "crit" ? v.danger : p.$tone === "info" ? v.info : p.$tone === "mut" ? v.muted : v.faint};
|
|
39
39
|
`;
|
|
40
40
|
/** InlineHint: Hint as a span, for inside table cells and panel heads. */
|
|
41
|
-
export const InlineHint = styled(Hint).attrs({ as: "span" }) ``;
|
|
42
|
-
const CellWrap = styled.span `
|
|
41
|
+
export const InlineHint = styled(Hint).attrs({ as: "span" }).withConfig({ componentId: "sc-1sd14f-3" })``;
|
|
42
|
+
const CellWrap = styled.span.withConfig({ componentId: "sc-1sd14f-4" })`
|
|
43
43
|
display: flex;
|
|
44
44
|
flex-direction: column;
|
|
45
45
|
gap: 2px;
|
|
46
46
|
min-width: 0;
|
|
47
47
|
`;
|
|
48
|
-
const CellTitle = styled.span `
|
|
48
|
+
const CellTitle = styled.span.withConfig({ componentId: "sc-1sd14f-5" })`
|
|
49
49
|
font-weight: 600;
|
|
50
|
-
${(p) => p.$mono && css
|
|
50
|
+
${(p) => p.$mono && css`font-family: ${v.mono}; font-size: 12px; font-weight: 650;`}
|
|
51
51
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
52
52
|
`;
|
|
53
|
-
const CellSub = styled.span `
|
|
53
|
+
const CellSub = styled.span.withConfig({ componentId: "sc-1sd14f-6" })`
|
|
54
54
|
font-size: 11px;
|
|
55
55
|
color: ${v.faint};
|
|
56
|
-
${(p) => p.$mono !== false && css
|
|
56
|
+
${(p) => p.$mono !== false && css`font-family: ${v.mono};`}
|
|
57
57
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
58
58
|
`;
|
|
59
59
|
/** Cell: the two-line table cell — a title with a mono subline under it. */
|
|
60
60
|
export function Cell({ title, sub, subs, mono, subMono, tooltip }) {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const lines = [...(sub ? [sub] : []), ...(subs ?? [])].filter((l) => l !== null && l !== undefined && l !== "");
|
|
62
|
+
return _jsxs(CellWrap, { title: tooltip, children: [_jsx(CellTitle, { "$mono": mono, children: title }), lines.map((l, i) => _jsx(CellSub, { "$mono": subMono, children: l }, i))] });
|
|
63
63
|
}
|
|
64
|
-
const linkCss = css
|
|
64
|
+
const linkCss = css`
|
|
65
65
|
font: inherit;
|
|
66
|
-
${(p) => p.$mono && css
|
|
67
|
-
${(p) => p.$truncate && css
|
|
68
|
-
color: ${(p) =>
|
|
66
|
+
${(p) => p.$mono && css`font-family: ${v.mono}; font-size: 12px;`}
|
|
67
|
+
${(p) => p.$truncate && css`display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;`}
|
|
68
|
+
color: ${(p) => p.$tone === "mut" ? v.muted : v.info};
|
|
69
69
|
text-decoration: none;
|
|
70
70
|
cursor: pointer;
|
|
71
71
|
background: none; border: none; padding: 0;
|
|
72
72
|
&:hover { text-decoration: underline; color: ${v.text}; }
|
|
73
73
|
`;
|
|
74
|
-
const A = styled.a `${linkCss}`;
|
|
75
|
-
const L = styled(Link) `${linkCss}`;
|
|
76
|
-
const B = styled.button `${linkCss}`;
|
|
74
|
+
const A = styled.a.withConfig({ componentId: "sc-1sd14f-7" })`${linkCss}`;
|
|
75
|
+
const L = styled(Link).withConfig({ componentId: "sc-1sd14f-8" })`${linkCss}`;
|
|
76
|
+
const B = styled.button.withConfig({ componentId: "sc-1sd14f-9" })`${linkCss}`;
|
|
77
77
|
/** InlineLink: a link (router, external, or a button that reads as a link). */
|
|
78
78
|
export function InlineLink({ to, href, onClick, mono, tone, external, truncate, children, ...rest }) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
if (to)
|
|
80
|
+
return _jsx(L, { to: to, "$mono": mono, "$tone": tone, "$truncate": truncate, ...rest, children: children });
|
|
81
|
+
if (href)
|
|
82
|
+
return _jsx(A, { href: href, "$mono": mono, "$tone": tone, "$truncate": truncate, ...(external ? { target: "_blank", rel: "noreferrer" } : {}), ...rest, children: children });
|
|
83
|
+
return _jsx(B, { type: "button", onClick: onClick, "$mono": mono, "$tone": tone, "$truncate": truncate, ...rest, children: children });
|
|
84
84
|
}
|
|
85
85
|
// Added in 0.3.0 for the fer adoption: the quiet text spans, the prose surface
|
|
86
86
|
// for upstream-authored text, and the relative-time pair. All four were in
|
|
87
87
|
// three consoles already.
|
|
88
88
|
/** Muted: secondary text in the running line. */
|
|
89
|
-
export const Muted = styled.span `color: ${v.muted};`;
|
|
89
|
+
export const Muted = styled.span.withConfig({ componentId: "sc-1sd14f-10" })`color: ${v.muted};`;
|
|
90
90
|
/** Faint: tertiary text — captions, units, "of 40". */
|
|
91
|
-
export const Faint = styled.span `color: ${v.faint};`;
|
|
91
|
+
export const Faint = styled.span.withConfig({ componentId: "sc-1sd14f-11" })`color: ${v.faint};`;
|
|
92
92
|
/** InlineCode: a mono run inside prose — a ref, a field name, a path. */
|
|
93
|
-
export const InlineCode = styled.code `
|
|
93
|
+
export const InlineCode = styled.code.withConfig({ componentId: "sc-1sd14f-12" })`
|
|
94
94
|
font-family: ${v.mono};
|
|
95
95
|
font-size: 11.5px;
|
|
96
96
|
background: ${v.hover};
|
|
97
97
|
border: 1px solid ${v.line};
|
|
98
|
-
border-radius: 4px;
|
|
98
|
+
border-radius: min(4px, ${v.rCtl});
|
|
99
99
|
padding: 1px 5px;
|
|
100
100
|
color: ${v.muted};
|
|
101
101
|
white-space: nowrap;
|
|
@@ -105,7 +105,7 @@ export const InlineCode = styled.code `
|
|
|
105
105
|
* README, a description field. Newlines are preserved because the source has
|
|
106
106
|
* them, and the measure is capped so it stays readable beside a table.
|
|
107
107
|
*/
|
|
108
|
-
export const Prose = styled.div `
|
|
108
|
+
export const Prose = styled.div.withConfig({ componentId: "sc-1sd14f-13" })`
|
|
109
109
|
font-size: 12.5px;
|
|
110
110
|
color: ${v.muted};
|
|
111
111
|
line-height: 1.6;
|
|
@@ -116,7 +116,7 @@ export const Prose = styled.div `
|
|
|
116
116
|
font-family: ${v.mono};
|
|
117
117
|
font-size: 11.5px;
|
|
118
118
|
background: ${v.hover};
|
|
119
|
-
border-radius: 4px;
|
|
119
|
+
border-radius: min(4px, ${v.rCtl});
|
|
120
120
|
padding: 1px 4px;
|
|
121
121
|
}
|
|
122
122
|
`;
|
|
@@ -126,41 +126,41 @@ export const Prose = styled.div `
|
|
|
126
126
|
* correlating with a log.
|
|
127
127
|
*/
|
|
128
128
|
export function Ago({ at }) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
const d = toDate(at);
|
|
130
|
+
if (!d)
|
|
131
|
+
return _jsx(_Fragment, { children: "\u2014" });
|
|
132
|
+
return _jsx("time", { dateTime: d.toISOString(), title: d.toLocaleString(), children: relative(d) });
|
|
133
133
|
}
|
|
134
134
|
/** toDate normalises the shapes an API hands back; seconds for bigint. */
|
|
135
135
|
export function toDate(at) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
136
|
+
if (at === undefined || at === null)
|
|
137
|
+
return null;
|
|
138
|
+
if (at instanceof Date)
|
|
139
|
+
return at;
|
|
140
|
+
if (typeof at === "bigint")
|
|
141
|
+
return new Date(Number(at) * 1000);
|
|
142
|
+
if (typeof at === "number")
|
|
143
|
+
return new Date(at);
|
|
144
|
+
const parsed = new Date(at);
|
|
145
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
146
146
|
}
|
|
147
147
|
const UNITS = [
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
[60, "second"], [3600, "minute"], [86400, "hour"], [604800, "day"], [2629800, "week"], [31557600, "month"]];
|
|
149
|
+
|
|
150
150
|
/** relative renders the "3 days ago" string on its own, for a title or a cell. */
|
|
151
151
|
export function relative(d) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
152
|
+
const secs = (d.getTime() - Date.now()) / 1000;
|
|
153
|
+
const abs = Math.abs(secs);
|
|
154
|
+
const fmt = new Intl.RelativeTimeFormat(undefined, { numeric: "auto" });
|
|
155
|
+
if (abs < 60)
|
|
156
|
+
return fmt.format(Math.round(secs), "second");
|
|
157
|
+
for (let i = 1; i < UNITS.length; i++) {
|
|
158
|
+
const [limit, unit] = UNITS[i];
|
|
159
|
+
if (abs < limit) {
|
|
160
|
+
const [div] = UNITS[i - 1];
|
|
161
|
+
return fmt.format(Math.round(secs / div), unit);
|
|
163
162
|
}
|
|
164
|
-
|
|
163
|
+
}
|
|
164
|
+
return fmt.format(Math.round(secs / 31557600), "year");
|
|
165
165
|
}
|
|
166
|
-
//# sourceMappingURL=Text.js.map
|
|
166
|
+
//# sourceMappingURL=Text.js.map
|
package/dist/kit/Text.js.map
CHANGED
|
@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AI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;IACrC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE;IAC/B,IAAI,GAAG,GAAG,KAAK,EAAE;MACf,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAE;MAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC;IACjD;EACF;EACA,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAC,EAAE,MAAM,CAAC;AACxD","ignoreList":[]}
|
package/dist/kit/Toast.js
CHANGED
|
@@ -5,8 +5,8 @@ import { v } from "../theme/tokens.js";
|
|
|
5
5
|
import { Icon } from "./Icon.js";
|
|
6
6
|
import { reportShownError, traceIdOf, TraceRef } from "./Trace.js";
|
|
7
7
|
const Ctx = createContext(null);
|
|
8
|
-
const rise = keyframes
|
|
9
|
-
const Stack = styled.div `
|
|
8
|
+
const rise = keyframes`from { opacity: 0; transform: translateY(-6px); }`;
|
|
9
|
+
const Stack = styled.div.withConfig({ componentId: "sc-dhub5z-0" })`
|
|
10
10
|
position: fixed;
|
|
11
11
|
top: 14px;
|
|
12
12
|
right: 14px;
|
|
@@ -19,7 +19,7 @@ const Stack = styled.div `
|
|
|
19
19
|
never swallow clicks meant for what's underneath it. */
|
|
20
20
|
pointer-events: none;
|
|
21
21
|
`;
|
|
22
|
-
const Item = styled.div `
|
|
22
|
+
const Item = styled.div.withConfig({ componentId: "sc-dhub5z-1" })`
|
|
23
23
|
pointer-events: auto;
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: flex-start;
|
|
@@ -35,7 +35,7 @@ const Item = styled.div `
|
|
|
35
35
|
color: ${v.text};
|
|
36
36
|
border-left: 3px solid ${(p) => p.$kind === "ok" ? v.success : p.$kind === "err" ? v.danger : p.$kind === "pending" ? v.warning : v.brand};
|
|
37
37
|
`;
|
|
38
|
-
const Body = styled.div `
|
|
38
|
+
const Body = styled.div.withConfig({ componentId: "sc-dhub5z-2" })`
|
|
39
39
|
display: flex;
|
|
40
40
|
flex-direction: column;
|
|
41
41
|
gap: 4px;
|
|
@@ -49,33 +49,33 @@ const Body = styled.div `
|
|
|
49
49
|
* calling `push`. This is the fallback for everything it does not recognise.
|
|
50
50
|
*/
|
|
51
51
|
export function toastError(e) {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const traceId = traceIdOf(e);
|
|
53
|
+
return { kind: "err", text: String(e?.message ?? e), ...(traceId ? { traceId } : {}) };
|
|
54
54
|
}
|
|
55
55
|
export function ToastProvider({ children }) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
56
|
+
const [toasts, setToasts] = useState([]);
|
|
57
|
+
const idRef = useRef(1);
|
|
58
|
+
const push = useCallback((kind, text, opts) => {
|
|
59
|
+
const id = idRef.current++;
|
|
60
|
+
setToasts((t) => [...t, { id, kind, text, traceId: opts?.traceId }]);
|
|
61
|
+
setTimeout(() => setToasts((t) => t.filter((x) => x.id !== id)), kind === "err" ? 8000 : 5000);
|
|
62
|
+
}, []);
|
|
63
|
+
const api = useMemo(() => ({
|
|
64
|
+
push,
|
|
65
|
+
ok: (text) => push("ok", text),
|
|
66
|
+
error: (e, prefix) => {
|
|
67
|
+
const { kind, text, traceId } = toastError(e);
|
|
68
|
+
reportShownError(e, traceId);
|
|
69
|
+
push(kind, prefix ? `${prefix}: ${text}` : text, { traceId });
|
|
70
|
+
}
|
|
71
|
+
}), [push]);
|
|
72
|
+
return _jsxs(Ctx.Provider, { value: api, children: [children, _jsx(Stack, { role: "status", "aria-live": "polite", children: toasts.map((t) => _jsxs(Item, { "$kind": t.kind, children: [_jsx(Icon, { name: t.kind === "ok" ? "check" : t.kind === "err" ? "error" : t.kind === "pending" ? "clock" : "info" }), _jsxs(Body, { children: [_jsx("span", { children: t.text }), t.traceId ? _jsx(TraceRef, { id: t.traceId }) : null] })] }, t.id)) })] });
|
|
73
73
|
}
|
|
74
74
|
export function useToast() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const c = useContext(Ctx);
|
|
76
|
+
if (!c)
|
|
77
|
+
throw new Error("useToast outside ToastProvider");
|
|
78
|
+
return c;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* The toast API, or null outside a ToastProvider. For chrome that may toast
|
|
@@ -83,6 +83,6 @@ export function useToast() {
|
|
|
83
83
|
* dropped-section notice).
|
|
84
84
|
*/
|
|
85
85
|
export function useToastMaybe() {
|
|
86
|
-
|
|
86
|
+
return useContext(Ctx);
|
|
87
87
|
}
|
|
88
|
-
//# sourceMappingURL=Toast.js.map
|
|
88
|
+
//# sourceMappingURL=Toast.js.map
|
package/dist/kit/Toast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/kit/Toast.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAAS,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,QAAwB,OAAO;AACzG,OAAO,MAAM,IAAI,SAAS,QAAQ,mBAAmB;AACrD,SAAS,CAAC,QAAQ,oBAAoB;AACtC,SAAS,IAAI,QAAQ,WAAY;AACjC,SAAS,gBAAgB,EAAE,SAAS,EAAE,QAAQ,QAAQ,YAAa;AA0BnE,MAAM,GAAG,GAAG,aAAa,CAAkB,IAAI,CAAC;AAEhD,MAAM,IAAI,GAAG,SA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CAAC,OAAO,GAAG,KAAC,QAAQ,IAAC,EAAE,EAAE,CAAC,CAAC,OAAO,GAAI,GAAG,IAAI,IAC1C,KALE,CAAC,CAAC,EAAE,CAOhB,CAAC,GACI,IACK;AAEnB;AAEA,OAAM,SAAU,QAAQ;EACtB,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC;EACzB,IAAI,CAAC,CAAC;EAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC;EACzD,OAAO,CAAC;AACV;AAEA;;;;;AAKA,OAAM,SAAU,aAAa;EAC3B,OAAO,UAAU,CAAC,GAAG,CAAC;AACxB","ignoreList":[]}
|
package/dist/kit/Tooltip.js
CHANGED
|
@@ -18,8 +18,8 @@ import { v } from "../theme/tokens.js";
|
|
|
18
18
|
// clickable (it is `pointer-events: none` and it closes as the pointer leaves),
|
|
19
19
|
// because a thing you must hover a corridor to reach is a thing you cannot
|
|
20
20
|
// reach. Use `Popover` for a sheet with content, and `Menu` for actions.
|
|
21
|
-
const fadeIn = keyframes
|
|
22
|
-
const Bubble = styled.div `
|
|
21
|
+
const fadeIn = keyframes`from { opacity: 0; transform: translateY(2px); }`;
|
|
22
|
+
const Bubble = styled.div.withConfig({ componentId: "sc-1cko7hb-0" })`
|
|
23
23
|
position: fixed;
|
|
24
24
|
z-index: ${v.zPop};
|
|
25
25
|
max-width: ${(p) => p.$wide ?? 260}px;
|
|
@@ -41,35 +41,35 @@ const Bubble = styled.div `
|
|
|
41
41
|
code, .mono { font-family: ${v.mono}; font-size: 11px; }
|
|
42
42
|
`;
|
|
43
43
|
/** The hoverable span. `display: contents` would lose the hover target. */
|
|
44
|
-
const Anchor = styled.span `
|
|
44
|
+
const Anchor = styled.span.withConfig({ componentId: "sc-1cko7hb-1" })`
|
|
45
45
|
display: inline-flex;
|
|
46
46
|
min-width: 0;
|
|
47
47
|
max-width: 100%;
|
|
48
48
|
`;
|
|
49
49
|
/** Where the bubble goes, given the anchor and the bubble's own measured box. */
|
|
50
50
|
function place(anchor, box, prefer, align) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
51
|
+
const gap = 6;
|
|
52
|
+
if (prefer === "right" || prefer === "left") {
|
|
53
|
+
// beside the anchor (an icon rail), vertically centred; flips sides for room
|
|
54
|
+
const right = anchor.right + gap;
|
|
55
|
+
const leftOf = anchor.left - box.width - gap;
|
|
56
|
+
const fitsRight = right + box.width <= window.innerWidth - 8;
|
|
57
|
+
const fitsLeft = leftOf >= 8;
|
|
58
|
+
const x = prefer === "right" ? fitsRight || !fitsLeft ? right : leftOf : fitsLeft || !fitsRight ? leftOf : right;
|
|
59
|
+
const y = anchor.top + anchor.height / 2 - box.height / 2;
|
|
60
|
+
return { top: Math.max(8, Math.min(y, window.innerHeight - box.height - 8)), left: Math.max(8, x) };
|
|
61
|
+
}
|
|
62
|
+
const above = anchor.top - box.height - gap;
|
|
63
|
+
const below = anchor.bottom + gap;
|
|
64
|
+
// Flip to whichever side has room; prefer the caller's choice when both do.
|
|
65
|
+
const fitsAbove = above >= 8;
|
|
66
|
+
const fitsBelow = below + box.height <= window.innerHeight - 8;
|
|
67
|
+
const top = prefer === "top" ? fitsAbove || !fitsBelow ? above : below : fitsBelow || !fitsAbove ? below : above;
|
|
68
|
+
const raw = align === "start" ? anchor.left :
|
|
69
|
+
align === "end" ? anchor.right - box.width :
|
|
70
|
+
anchor.left + anchor.width / 2 - box.width / 2;
|
|
71
|
+
const left = Math.max(8, Math.min(raw, window.innerWidth - box.width - 8));
|
|
72
|
+
return { top: Math.max(8, top), left };
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Tooltip: hover or focus the child, get `label` in a themed bubble.
|
|
@@ -81,62 +81,62 @@ function place(anchor, box, prefer, align) {
|
|
|
81
81
|
* whatever is under it while you read the field it describes.
|
|
82
82
|
*/
|
|
83
83
|
export function Tooltip({ label, children, side = "top", align = "center", width, delay = 180, disabled, style, className }) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
84
|
+
const id = useId();
|
|
85
|
+
// the nearest ThemeScope's host, or body (CON-148)
|
|
86
|
+
const portalTarget = usePortalTarget();
|
|
87
|
+
const ref = useRef(null);
|
|
88
|
+
const bubble = useRef(null);
|
|
89
|
+
const timer = useRef(undefined);
|
|
90
|
+
const [anchor, setAnchor] = useState(null);
|
|
91
|
+
const [pos, setPos] = useState(null);
|
|
92
|
+
const close = useCallback(() => {
|
|
93
|
+
window.clearTimeout(timer.current);
|
|
94
|
+
setAnchor(null);
|
|
95
|
+
setPos(null);
|
|
96
|
+
}, []);
|
|
97
|
+
const open = useCallback(() => {
|
|
98
|
+
if (disabled)
|
|
99
|
+
return;
|
|
100
|
+
window.clearTimeout(timer.current);
|
|
101
|
+
const show = () => {
|
|
102
|
+
const rect = ref.current?.getBoundingClientRect();
|
|
103
|
+
if (rect)
|
|
104
|
+
setAnchor(rect);
|
|
105
|
+
};
|
|
106
|
+
if (delay > 0)
|
|
107
|
+
timer.current = window.setTimeout(show, delay);else
|
|
108
|
+
|
|
109
|
+
show();
|
|
110
|
+
}, [delay, disabled]);
|
|
111
|
+
// Measured once it is in the tree, so a two-line bubble flips above a row at
|
|
112
|
+
// the bottom of the viewport instead of being clipped by it. Rendered at
|
|
113
|
+
// opacity 0 until placed — an unplaced bubble at 0,0 is a visible flicker in
|
|
114
|
+
// the corner of the screen.
|
|
115
|
+
useLayoutEffect(() => {
|
|
116
|
+
if (!anchor)
|
|
117
|
+
return;
|
|
118
|
+
const box = bubble.current?.getBoundingClientRect();
|
|
119
|
+
if (box)
|
|
120
|
+
setPos(place(anchor, box, side, align));
|
|
121
|
+
}, [anchor, side, align]);
|
|
122
|
+
useLayoutEffect(() => {
|
|
123
|
+
if (!anchor)
|
|
124
|
+
return;
|
|
125
|
+
const onKey = (e) => {if (e.key === "Escape")
|
|
126
|
+
close();};
|
|
127
|
+
// Any scroll moves the anchor out from under the bubble; the cheapest
|
|
128
|
+
// correct answer is to dismiss rather than to track.
|
|
129
|
+
document.addEventListener("keydown", onKey);
|
|
130
|
+
window.addEventListener("scroll", close, true);
|
|
131
|
+
return () => {
|
|
132
|
+
document.removeEventListener("keydown", onKey);
|
|
133
|
+
window.removeEventListener("scroll", close, true);
|
|
134
|
+
};
|
|
135
|
+
}, [anchor, close]);
|
|
136
|
+
useLayoutEffect(() => () => window.clearTimeout(timer.current), []);
|
|
137
|
+
const shown = !disabled && anchor !== null;
|
|
138
|
+
return _jsxs(_Fragment, { children: [_jsx(Anchor, { ref: ref, style: style, className: className, onMouseEnter: open, onMouseLeave: close, onFocus: open, onBlur: close, "aria-describedby": shown ? id : undefined, children: children }), shown && portalTarget ?
|
|
139
|
+
createPortal(_jsx(Bubble, { ref: bubble, id: id, role: "tooltip", "$wide": width, style: pos ? { top: pos.top, left: pos.left } : { top: 0, left: 0, opacity: 0 }, children: label }), portalTarget) :
|
|
140
|
+
null] });
|
|
141
141
|
}
|
|
142
|
-
//# sourceMappingURL=Tooltip.js.map
|
|
142
|
+
//# sourceMappingURL=Tooltip.js.map
|
package/dist/kit/Tooltip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/kit/Tooltip.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAAS,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,QAA4C,OAAO;AACjH,SAAS,YAAY,QAAQ,WAAW;AACxC,SAAS,eAAe,QAAQ,wBAAyB;AACzD,OAAO,MAAM,IAAI,SAAS,QAAQ,mBAAmB;AACrD,SAAS,CAAC,QAAQ,oBAAoB;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,MAAM,GAAG,SAAS,kDAAkD;AAE1E,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,4CAAgC;;aAE5C,CAAC,CAAC,IAAI;eACJ,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,GAAG;;mBAEjB,CAAC,CAAC,KAAK;gBACV,CAAC,CAAC,QAAQ;sBACJ,CAAC,CAAC,KAAK;gBACb,CAAC,CAAC,IAAI;WACX,CAAC,CAAC,IAAI;iBACA,CAAC,CAAC,IAAI;;;;;eAKR,MAAM;;;;+BAIU,CAAC,CAAC,IAAI;CACpC;AAED;AACA,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI;;;;CAIzB;AAID;AACA,SAAS,KAAK,CAAC,MAAe,EAAE,GAAY,EAAE,MAAY,EAAE,KAAiC;EAC3F,MAAM,G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