@apliteni/apliteni-ui 0.142.0 → 0.142.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +24 -36
  2. package/guidelines/state-set.md +4 -4
  3. package/package.json +3 -3
  4. package/react/dist/index.css +2 -2
  5. package/react/dist/index.js +12 -5
  6. package/src/index.d.ts +13 -96
  7. package/src/index.js +17 -30
  8. package/src/logic/account-nav.js +9 -0
  9. package/src/logic/code.js +75 -0
  10. package/src/logic/dropdown-placement.js +671 -0
  11. package/src/logic/feedback.js +16 -0
  12. package/src/logic/theme.js +5 -0
  13. package/src/styles/command-palette.css +9 -5
  14. package/src/styles/drawer.css +8 -0
  15. package/src/styles/dropdown.css +30 -8
  16. package/src/styles/feedback.css +1 -1
  17. package/src/styles/filter-bar.css +5 -2
  18. package/src/styles/input.css +14 -15
  19. package/src/styles/layout.css +5 -2
  20. package/src/styles/table.css +28 -2
  21. package/src/styles/topbar.css +8 -6
  22. package/src/components/account-nav.js +0 -44
  23. package/src/components/avatar.js +0 -53
  24. package/src/components/back.js +0 -57
  25. package/src/components/button-busy.js +0 -69
  26. package/src/components/command-palette.js +0 -471
  27. package/src/components/confirm.js +0 -131
  28. package/src/components/drawer.js +0 -169
  29. package/src/components/dropdown.js +0 -1713
  30. package/src/components/feedback.js +0 -182
  31. package/src/components/filter-bar.js +0 -86
  32. package/src/components/footer.js +0 -102
  33. package/src/components/index.js +0 -424
  34. package/src/components/loading.js +0 -127
  35. package/src/components/nav.js +0 -220
  36. package/src/components/overlay.js +0 -263
  37. package/src/components/pagination.js +0 -323
  38. package/src/components/segmented.js +0 -33
  39. package/src/components/shell.js +0 -511
  40. package/src/components/stat.js +0 -82
  41. package/src/components/success.js +0 -131
  42. package/src/components/table-values.js +0 -32
  43. package/src/components/tabs.js +0 -82
  44. package/src/components/toasts.js +0 -118
  45. package/src/components/tooltip.js +0 -347
  46. package/src/components/topbar.js +0 -269
@@ -0,0 +1,16 @@
1
+ // The section a selection belongs to: the closest ancestor-or-preceding h2|h3 that
2
+ // carries an id, else the first such heading in `root`. The vanilla feedback widget
3
+ // and the React <Feedback> both ask it.
4
+ export function nearestSection(node, root) {
5
+ let el = node && node.nodeType === 3 ? node.parentNode : node;
6
+ while (el && el !== root) {
7
+ let p = el;
8
+ while (p) {
9
+ if (p.tagName && /^H[23]$/.test(p.tagName) && p.id) return p;
10
+ p = p.previousElementSibling;
11
+ }
12
+ el = el.parentElement;
13
+ }
14
+ return root ? root.querySelector('h2[id],h3[id]') : null;
15
+ }
16
+
@@ -0,0 +1,5 @@
1
+ import { icon, sun, moon } from '../assets/icons.js';
2
+
3
+ // The glyph for a saved theme choice, including automatic mode. The vanilla toggle
4
+ // and the React <ThemeToggle> both draw it.
5
+ export const themeIcon = (t) => t === 'auto' ? icon('monitor') : t === 'light' ? sun : moon;
@@ -124,13 +124,17 @@
124
124
  color: var(--text);
125
125
  background: none;
126
126
  border: 0;
127
- /* The one control in the kit that removes the indicator and puts no
128
- outline: var(--ring) back, against base.css. It is the only tab stop in
129
- the dialog and it holds focus from the frame it opens, so a ring would be
130
- painted the whole time the palette is up and would mark nothing; the panel
131
- already carries one, and the caret says where the typing goes. */
127
+ /* The ring goes on the search row, which is this field's box. */
132
128
  outline: none;
133
129
  }
130
+ /* The shared field ring, drawn inward because the panel clips. The divider goes
131
+ transparent under it, as a field's border does, so focus has one line.
132
+ why: docs/foundations.md#the-focus-ring */
133
+ .ui-cmdk__search:has(.ui-cmdk__input:focus-visible) {
134
+ border-bottom-color: transparent;
135
+ outline: var(--ring-scroll);
136
+ outline-offset: var(--ring-scroll-offset);
137
+ }
134
138
  .ui-cmdk__input::placeholder { /* muted-ink: placeholder — empty command search */ color: var(--muted); }
135
139
 
136
140
  /* -- The list ------------------------------------------------------------- */
@@ -232,6 +232,14 @@
232
232
  padding-block: var(--space-1);
233
233
  overflow-wrap: anywhere;
234
234
  }
235
+ /* A control in the value column has its own border and padding, so its first line sits lower
236
+ than a label's. A row whose value holds a field or a dropdown lines both first lines up on
237
+ their baseline, whatever the control is, and a row of text keeps its place. At 560px and
238
+ below the label stacks over the value and there is nothing to align. A field's own label
239
+ stays for a screen reader only when one field fills the value cell. With two
240
+ fields, each label remains visible to name its control. */
241
+ .ui-drawer__row:has(> dd :is(.ui-input, .ui-textarea, .ui-select, .ui-dropdown)) > :is(dt, dd) { align-self: baseline; }
242
+ .ui-drawer__row > dd:has(> .ui-field:only-child) > .ui-field > .ui-field__label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
235
243
  .ui-drawer__row dt { color: var(--text); }
236
244
  .ui-drawer__row dd { color: var(--text); font-variant-numeric: tabular-nums; }
237
245
  .ui-drawer .ui-drawer__rows + *,
@@ -83,14 +83,20 @@
83
83
  --caret-ink: 1.6px;
84
84
  --caret-off: calc((var(--caret) - var(--caret-ink)) / 2.8284); /* 2√2 — the 45° turn's projection */
85
85
  width: var(--caret); height: var(--caret);
86
- border-right: var(--caret-ink) solid var(--muted);
87
- border-bottom: var(--caret-ink) solid var(--muted);
86
+ /* Two gradient strips, not borders: Chromium rounds a border to whole device pixels,
87
+ so a 1.6px border painted 1.03px of ink, where the select's SVG stroke paints 1.58px. */
88
+ background:
89
+ linear-gradient(var(--muted), var(--muted)) right / var(--caret-ink) 100% no-repeat,
90
+ linear-gradient(var(--muted), var(--muted)) bottom / 100% var(--caret-ink) no-repeat;
88
91
  /* Shift BEFORE rotate, so it lands in page space rather than on the turned axis. */
89
92
  transform: translateY(calc(var(--caret-off) * -1)) rotate(45deg);
90
93
  transition: transform var(--dur-fast) var(--ease);
91
94
  flex: none;
92
95
  }
93
96
  .ui-dropdown.open .ui-dropdown__chevron { transform: translateY(var(--caret-off)) rotate(-135deg); }
97
+ @media (forced-colors: active) {
98
+ .ui-dropdown__chevron { background: none; border-right: var(--caret-ink) solid ButtonText; border-bottom: var(--caret-ink) solid ButtonText; }
99
+ }
94
100
 
95
101
  /* Panel — the popover surface */
96
102
  .ui-dropdown__panel {
@@ -210,6 +216,12 @@
210
216
  at the room the viewport left either way. #489 */
211
217
  .ui-dropdown__panel.is-scroll { --ui-dropdown-cap: var(--ui-dropdown-max); }
212
218
 
219
+ /* On a phone, the panel keeps the page's 16px margin at the shell fold.
220
+ why: docs/components.md#the-dropdown-panel */
221
+ @media (max-width: 720px) {
222
+ .ui-dropdown__panel { --ui-dropdown-edge: var(--space-4); }
223
+ }
224
+
213
225
  /* The wiring adds this where the room is below the floor: even spending the whole
214
226
  edge inset, there is no usable height. The panel keeps its cap — it is never
215
227
  taller than 300px — and scrolls inside it. Its room runs past the fold, so the
@@ -316,12 +328,22 @@
316
328
  color: var(--text);
317
329
  transition: background var(--dur-fast) var(--ease);
318
330
  }
319
- /* Rows keep a reading surface; hover adds an edge. A row that is hovered AND focused
320
- draws the ring and not the hover edge — both are outlines now, and the focus rule
321
- comes later — which is one indicator rather than two.
331
+ /* Hover is a fill and an outline means focus, so a hovered row draws no edge. A row that is
332
+ hovered AND focused draws the ring over the fill.
322
333
  why: docs/foundations.md#elevation */
323
- .ui-dropdown__item:hover { outline: 1px solid var(--control-edge); outline-offset: -1px; background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ }
324
- .ui-dropdown__item:focus-visible { background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ outline: var(--ring); outline-offset: var(--ring-offset); }
334
+ .ui-dropdown__item:hover { background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ }
335
+ /* Light only: the panel is --bg-elevated, which --surface matches exactly there, so the
336
+ hover fill above changed nothing. --surface-3 is the quiet fill the drawer's close mark
337
+ takes on hover, one step under the --surface-2 that .is-active takes below.
338
+ why: docs/foundations.md#elevation */
339
+ :where(:root[data-theme="light"]) .ui-dropdown__item:hover { background: var(--surface-3); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ }
340
+ @media (forced-colors: active) {
341
+ .ui-dropdown__item:hover { border: 1px solid Highlight; padding: 8px 11px; }
342
+ }
343
+ /* The row draws its ring inward, so a row scrolled flush with the list's edge cannot have it
344
+ clipped and the list scrolls as it did.
345
+ why: docs/foundations.md#the-focus-ring */
346
+ .ui-dropdown__item:focus-visible { background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ outline: var(--ring-scroll); outline-offset: var(--ring-scroll-offset); }
325
347
  .ui-dropdown__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
326
348
  .ui-dropdown__label { font-family: var(--font-sans); font-size: calc(var(--text-sm) - 0.5px); color: var(--strong); font-weight: 600; letter-spacing: 0.01em; }
327
349
  .ui-dropdown__desc { font-size: var(--text-xs); color: var(--text); line-height: 1.35; }
@@ -444,7 +466,7 @@
444
466
 
445
467
  .ui-dropdown__search-input::placeholder { /* muted-ink: placeholder — empty search field */ color: var(--muted); }
446
468
  .ui-dropdown__search-input:hover { border-color: var(--field-edge-hover); }
447
- .ui-dropdown__search-input:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); }
469
+ .ui-dropdown__search-input:focus-visible { border-color: transparent; outline: var(--ring); outline-offset: var(--ring-offset); }
448
470
 
449
471
  /* The rows' own cap, read from the same property the panel reads: the `scroll`
450
472
  option lands on the list when there is a field above it. #489 */
@@ -131,7 +131,7 @@
131
131
 
132
132
  /* Error banner */
133
133
  .ui-fbc__err { margin: 14px 20px 0; background: color-mix(in srgb, var(--pink) 14%, transparent); /* code-bg: inherit — text-only validation message has no nested focus target. */ color: var(--chip-danger-ink); font-size: var(--text-sm); padding: 11px 15px; border-radius: 11px; display: none; }
134
- .ui-fbc__err.show { display: block; }
134
+ .ui-fbc__err.show { display: block; /* motion: still — the React Feedback renders the error already shown; its fade is the is-entering animation beside it. */ }
135
135
  /* A failed send's line fades in; wireFeedback() adds the class as it shows it. */
136
136
  .ui-fbc__err.is-entering { animation: m-fade var(--dur-fast) var(--ease-out) both; }
137
137
 
@@ -11,6 +11,9 @@
11
11
  outside it. It joins the shared recomposition in tokens.css beside .ui-seg,
12
12
  which is also what hands an inline code chip the page from here. */
13
13
  background: var(--surface);
14
+ /* A chip with no value draws no remove mark, so it stops taking its height from the
15
+ mark's line box. The bar names the height; every chip keeps it. */
16
+ min-height: var(--ui-filter-row-h);
14
17
  }
15
18
  .ui-filter-bar__chip .ui-dropdown__trigger { border: 0; background: transparent; padding: var(--space-1) var(--space-2); }
16
19
  /* The chip is the edge the row's other boxes are measured against, so it fades with them:
@@ -123,8 +126,8 @@
123
126
  why: docs/components.md#a-filter-row-holds-its-panels */
124
127
  .ui-filter-bar .ui-dropdown__item.is-selected:hover { background: color-mix(in srgb, var(--glow-purple), var(--accent) 9%); /* code-bg: inherit — a translucent wash moves the ground, not the chip on it. */ }
125
128
 
126
- /* A chip's height — its remove mark's line box, padding and border — named so the control
127
- stands as tall on a line of its own, where there is no chip to stretch to. */
129
+ /* A chip's height — a remove mark's line box, padding and border — named so every chip,
130
+ with or without a mark, and a control on a line of its own stand as tall. */
128
131
  .ui-filter-bar { --ui-filter-row-h: calc(2px + 2 * var(--space-1) + var(--leading-normal) * var(--text-lg)); }
129
132
 
130
133
  /* A chip's neighbour takes the chip's corner, that height and edge, but not its painted fill:
@@ -38,18 +38,6 @@
38
38
  .ui-textarea:hover,
39
39
  .ui-select:hover { border-color: var(--field-edge-hover); }
40
40
 
41
- /* The band and nothing beside it. Recolouring the field's own 1px edge to the
42
- accent drew a SECOND accent band one pixel inside the first, and the unpainted
43
- pixel between them read as a halo on the light ground — which is the glow Artur
44
- rejected on #578 round r34. The edge keeps its resting ink.
45
- why: docs/foundations.md#the-focus-ring */
46
- .ui-input:focus-visible,
47
- .ui-textarea:focus-visible,
48
- .ui-select:focus-visible {
49
- outline: var(--ring);
50
- outline-offset: var(--ring-offset);
51
- }
52
-
53
41
  .ui-input::placeholder,
54
42
  .ui-textarea::placeholder { /* muted-ink: placeholder — empty form field */ color: var(--muted); opacity: 0.9; }
55
43
 
@@ -75,7 +63,15 @@
75
63
 
76
64
  .ui-input.is-invalid, .ui-select.is-invalid,
77
65
  .ui-textarea.is-invalid { border-color: var(--pink); }
78
- /* Invalid fields keep the shared focus indicator; their border carries the error. */
66
+ /* Keep the border's width, but make its ink transparent while the ring shows.
67
+ This also outranks the invalid and hover edges, so focus has one line. */
68
+ .ui-input:focus-visible,
69
+ .ui-textarea:focus-visible,
70
+ .ui-select:focus-visible {
71
+ border-color: transparent;
72
+ outline: var(--ring);
73
+ outline-offset: var(--ring-offset);
74
+ }
79
75
 
80
76
  /* A search field with a value gets the browser's own clear button, and the
81
77
  browser paints it — near-black on the light field, white on the dark one,
@@ -110,17 +106,20 @@
110
106
  which is the colour every other quiet glyph on a field takes. It was one frozen
111
107
  hex until #295, dark --muted's old value, which the ladder's re-pick left behind
112
108
  at 2.49:1 on the light field. Held by stories/colour-tokens.test.js.
109
+ The mark is .ui-dropdown__chevron drawn as a path: its 8px border caret turned 45
110
+ degrees, at its 1.6px stroke and lifted by --caret-off, so both controls show one
111
+ chevron. It is a plain stroke with butt ends and a mitred point, 11.3px wide.
113
112
  why: docs/foundations.md#colour-and-contrast */
114
113
  .ui-select {
115
114
  appearance: none;
116
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a29db6' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
115
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='-6 -6 12 12' fill='none' stroke='%23a29db6' stroke-width='1.6'%3E%3Cpath d='M-5.09 -2.83L0 2.26l5.09-5.09'/%3E%3C/svg%3E");
117
116
  background-repeat: no-repeat;
118
117
  background-position: right 15px center;
119
118
  padding-right: 40px;
120
119
  cursor: pointer;
121
120
  }
122
121
  :root[data-theme="light"] .ui-select {
123
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c6270' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
122
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='-6 -6 12 12' fill='none' stroke='%235c6270' stroke-width='1.6'%3E%3Cpath d='M-5.09 -2.83L0 2.26l5.09-5.09'/%3E%3C/svg%3E");
124
123
  }
125
124
 
126
125
  /* Checkbox / radio — custom, token-driven. DataTable's selection boxes are bare
@@ -118,8 +118,7 @@
118
118
  was the same sentence in a second file. What is left here is the rail's own
119
119
  resting step. */
120
120
  /* Re-tuned at #295, which took the light rail down a step with the page. Below 720px
121
- the glyph is the whole row, so it is held at text grade rather than at 1.4.11's bar —
122
- stories/apps/shell-states.test.js:1535 `a resting glyph is dimmer but still legible`. */
121
+ the glyph is the whole row, so it is held at text grade rather than at 1.4.11's bar. */
123
122
  .ui-app__rail .ui-nav__ic svg { opacity: 0.66; }
124
123
 
125
124
  /* A destructive row of the rail is a navigation row and rests like one; the danger
@@ -280,6 +279,10 @@
280
279
  :where(.ui-app.is-collapsed) .ui-app__rail .ui-nav__item.is-active { isolation: isolate; background: none; }
281
280
  :where(.ui-app.is-collapsed) .ui-app__rail .ui-nav__item.is-active::before { content: ""; position: absolute; left: 0; top: 50%; width: var(--ui-nav-strip); height: 100%; border-radius: 10px; transform: translateY(-50%); /* motion: still — a mark on the current row, whose own highlight already transitions; this centres it, it does not travel */ background: var(--surface-3); /* code-bg: inherit — The plate contains no focus target. */ z-index: -1; }
282
281
  :where(.ui-app.is-collapsed) .ui-app__rail .ui-nav__item:not(.is-danger):not(.is-active):hover { background: none; }
282
+ /* A row closes to the glyph column, so the rail's clip does not cut the right side of its
283
+ focus ring. why: docs/components.md#the-page-shell */
284
+ :where(.ui-app.is-collapsed) .ui-app__rail .ui-nav__item,
285
+ :where(.ui-app.is-collapsed) .ui-app__rail .ui-app__user-trigger { width: var(--ui-nav-strip); }
283
286
  /* The label IS the chip. `fixed` is the fallback placement, out of the rail's own
284
287
  clip; the @supports branch below pins it to the row and is the only one that
285
288
  survives a scroll. The toggle's selector is unscoped, because it is wordless at
@@ -50,6 +50,10 @@
50
50
  .ui-table tfoot th { text-align: right; }
51
51
  .ui-table td.ui-table__title { color: var(--strong); font-weight: var(--weight-medium); width: 99%; white-space: normal; }
52
52
  .ui-table th:last-child { padding-right: 0; }
53
+ /* The last body cell ends where its header and the table end. A right-aligned amount in the
54
+ last column stood 16px in from both, because only the header and the action cell dropped
55
+ the cell gap. The variants below state their own end padding. why: docs/foundations.md#spacing-and-rhythm */
56
+ .ui-table td:last-child { padding-right: 0; }
53
57
  .ui-table td.ui-table__act { padding-right: 0; text-align: right; }
54
58
  .ui-table tr.is-dead td { /* muted-ink: state — revoked row */ color: var(--muted); }
55
59
  .ui-table tbody tr { transition: background var(--dur-fast) var(--ease); }
@@ -68,6 +72,12 @@
68
72
  border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
69
73
  .ui-table--hover:not(.ui-table--zebra) tbody tr:hover td:last-child {
70
74
  border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
75
+ /* The hover band is the last cell, which ends where the figures end, so a hovered row's fill
76
+ stopped at the last glyph. The last column of a hover table keeps one cell gap of room
77
+ inside the band, header and body alike, so the figures and their header still share one
78
+ right edge. The dense and compact variants state their own end padding below, and an
79
+ action cell keeps none. */
80
+ :where(.ui-table--hover:not(.ui-table--zebra)) :is(th, td):not(.ui-table__act):last-child { padding-right: var(--space-4); }
71
81
 
72
82
  /* Data-table modifiers, composable: .ui-table--dense --zebra --hover.
73
83
  * --dense --space-3 across, --space-2 down — one step in from the base table
@@ -178,6 +188,9 @@
178
188
  padding: var(--space-4) var(--space-4) var(--space-4) 0;
179
189
  border-radius: var(--radius-xs);
180
190
  }
191
+ /* The last cell gave up its end gap above, so the link it holds gives up the same. */
192
+ .ui-table td.ui-table__linked:where(:last-child) > :is(a:not([class]), a.ui-identity):only-child { padding-right: 0; }
193
+ :where(.ui-table--hover:not(.ui-table--zebra)) td.ui-table__linked:last-child > :is(a:not([class]), a.ui-identity):only-child { padding-right: var(--space-4); }
181
194
  .ui-table--dense td.ui-table__linked > :is(a:not([class]), a.ui-identity):only-child { padding: var(--space-2) var(--space-3); }
182
195
  .ui-table--compact td.ui-table__linked > :is(a:not([class]), a.ui-identity):only-child { padding: var(--space-1) var(--space-3); }
183
196
  /* Zebra insets the row's END cells only, so the fill does too: a marked identity behind a
@@ -298,7 +311,11 @@
298
311
  half, so at 24px it hides a 12px shade outright — which is why the two sizes are
299
312
  not one. why: guidelines/dense-tables.md */
300
313
  .ui-table-scroll {
301
- overflow: auto; max-height: var(--ui-table-height, 70vh); padding: 0 var(--space-1);
314
+ overflow: auto; max-height: var(--ui-table-height, 70vh);
315
+ /* A transparent border, not padding: positioned cells cover an outline on the scrollport's
316
+ padding. The side and bottom bands draw in the border at the visible edge at every scroll
317
+ position. why: docs/foundations.md#the-focus-ring */
318
+ border: 0 solid transparent; border-inline-width: var(--space-1); border-bottom-width: var(--space-1); background-origin: border-box;
302
319
  background-color: var(--table-bg);
303
320
  background-image:
304
321
  linear-gradient(to right, var(--table-bg) 50%, transparent),
@@ -326,13 +343,22 @@
326
343
  }
327
344
  /* The kit's first ringed scroller, and a scroll region inside a card like the rest, so
328
345
  it draws the band inward too rather than spending a halo across the card around it.
329
- It had no room of its own to draw in — the padding above is horizontal — which is the
346
+ It had no room of its own to draw in — the border above is horizontal — which is the
330
347
  second reason the band is an outline: it is painted over the rows, in the cell padding
331
348
  of the first and last, rather than under them. #531
332
349
  why: docs/foundations.md#the-focus-ring */
333
350
  .ui-table-scroll:focus-visible { outline: var(--ring-scroll); outline-offset: var(--ring-scroll-offset); }
351
+ @media (forced-colors: active) {
352
+ .ui-table-scroll { border-color: Canvas; }
353
+ }
334
354
  .ui-table--sticky { border-collapse: separate; border-spacing: 0; }
335
355
  .ui-table--sticky thead th { position: sticky; top: 0; z-index: var(--z-sticky); background: var(--table-bg); padding-top: var(--space-2); }
356
+ /* The header sticks at the region's top edge, which is where the inward band draws, and a
357
+ positioned cell paints over an outline. While the region holds the ring, the header
358
+ gives up the band's own 3px, so the ring is whole on the top side. The side bands lie in
359
+ the region's border, which no cell reaches.
360
+ why: docs/foundations.md#the-focus-ring */
361
+ .ui-table-scroll:focus-visible .ui-table--sticky thead th { clip-path: inset(calc(var(--ring-gap-width) + var(--ring-width)) 0 0 0); }
336
362
  .ui-table--pinned .ui-table__identity, .ui-table--pinned .ui-table__selection { position: sticky; left: 0; z-index: var(--z-base); background: var(--table-bg); border-right: 1px solid var(--border); }
337
363
  .ui-table--pinned thead .ui-table__identity, .ui-table--pinned thead .ui-table__selection { z-index: calc(var(--z-sticky) + 1); }
338
364
  /* The divider is the pin's edge: it says the column stayed while the rest moved under it.
@@ -210,12 +210,14 @@
210
210
  font: inherit;
211
211
  transition: background var(--dur-fast) var(--ease);
212
212
  }
213
- /* Menu rows use the reading surface and an edge on hover — see
214
- src/styles/dropdown.css:323 `.ui-dropdown__item:hover`.
215
- why: docs/foundations.md#elevation */
216
- .vopt:hover { outline: 1px solid var(--control-edge); outline-offset: -1px; background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ }
217
- /* The row is a keyboard stop: src/components/dropdown.js:1663
218
- `items[next < 0 ? 0 : next]?.focus()` moves focus onto a `[data-dd-item]` with
213
+ /* Hover fills the row. Only keyboard focus draws its outline. */
214
+ .vopt:hover { background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ }
215
+ :where(:root[data-theme="light"]) .vopt:hover { background: var(--surface-3); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ }
216
+ @media (forced-colors: active) {
217
+ .vopt:hover { border: 1px solid Highlight; padding: 9px 12px; }
218
+ }
219
+ /* The row is a keyboard stop: react/src/Dropdown.tsx:758
220
+ `els[next < 0 ? 0 : next]?.focus()` moves focus onto a `[data-dd-item]` with
219
221
  the arrow keys, and this is one. It takes the ring on its own 10px radius, the
220
222
  same way `.amenu a` above does. #482 */
221
223
  .vopt:focus-visible { outline: var(--ring); outline-offset: var(--ring-offset); }
@@ -1,44 +0,0 @@
1
- // The one account navigation definition, and the one way to hand it to a sink
2
- // that interpolates raw. It lives here rather than in shell.js because both
3
- // shell.js and topbar.js need it and shell.js already imports topbar.js — the
4
- // other direction would be a cycle. shell.js re-exports ACCOUNT_NAV, which is
5
- // the published name docs/components.md documents.
6
- // why: docs/components.md#the-page-shell
7
- import { esc } from './index.js';
8
- import { avatarInitials } from '../logic/avatar.js';
9
-
10
- // nav.js item objects. Labels are raw text — every nav primitive escapes, so a
11
- // pre-escaped `&amp;` would come out as `&amp;amp;`. `key` means credentials;
12
- // `plug` means integration. These two are the kit's default, so each is a live
13
- // link on a consumer's /account page — a screen the kit does not ship belongs
14
- // in the caller's own nav, not here.
15
- export const ACCOUNT_NAV = [
16
- { id: 'prefs', icon: 'gear', label: 'Preferences' },
17
- { id: 'access', icon: 'key', label: 'Access & agents' },
18
- ];
19
-
20
- // topbar()'s account menu speaks [id, icon, label, href?, target?] tuples, and
21
- // it interpolates every field raw — the label, the href and the target alike.
22
- // Escape all three on the way in rather than sending the menu a string the rail
23
- // would have escaped a second time.
24
- export const toMenuTuple = (it) => [
25
- esc(it.id ?? ''), it.icon, esc(it.label || ''),
26
- it.href ? esc(it.href) : it.href,
27
- it.target ? esc(it.target) : it.target,
28
- ];
29
-
30
- // What accountMenu() falls back to. Derived on call, not frozen at import, so
31
- // the menu and the rail cannot answer differently about the same definition.
32
- export const accountMenuNav = () => ACCOUNT_NAV.map(toMenuTuple);
33
-
34
- // One reader, one pair of initials. The rail (shell.js) and the topbar's
35
- // account menu (topbar.js) both draw an avatar for the same person, and each
36
- // computed it for itself: the rail preferred the display name, the menu only
37
- // ever read the email's local part. So the /account preset — the one screen
38
- // with both on it — said "AL" in the rail and "A" in the topbar. This lives
39
- // beside ACCOUNT_NAV for the same reason ACCOUNT_NAV lives here: both files
40
- // need it and shell.js already imports topbar.js.
41
- //
42
- // The displayed name alone supplies the letters. The part draws its user glyph
43
- // when no name is shown.
44
- export const initials = (name) => avatarInitials(name);
@@ -1,53 +0,0 @@
1
- import { esc, icon } from './index.js';
2
- import { safeUrl } from '../html.js';
3
- import { avatarHue, avatarInitials } from '../logic/avatar.js';
4
- export { avatarHue, avatarInitials, AVATAR_HUES } from '../logic/avatar.js';
5
-
6
- // Avatar — a person's round mark. The letters come from `name`, the hue from a hash of
7
- // `key`, and a photo covers the letter. A photo that fails to load removes itself, so the
8
- // letter shows and not the browser's broken-image glyph.
9
- // With no name the mark is the `user` glyph; `empty` is a dashed ring for "no one yet".
10
- // It is decoration beside the name it stands for, so it is hidden from assistive
11
- // technology, and it has no cursor, hover or focus of its own.
12
- // why: docs/components.md#avatar
13
- const cx = (...a) => a.filter(Boolean).join(' ');
14
- const wiredDocs = new WeakSet();
15
-
16
- function wireAvatarPhotos(doc) {
17
- if (!doc || wiredDocs.has(doc)) return;
18
- wiredDocs.add(doc);
19
- doc.querySelectorAll('.ui-avatar > img[data-avatar-photo]').forEach((img) => {
20
- if (!img.complete) return;
21
- if (img.naturalWidth > 0) img.classList.add('is-loaded');
22
- else img.remove();
23
- });
24
- doc.addEventListener('load', (event) => {
25
- if (event.target?.matches?.('.ui-avatar > img[data-avatar-photo]')) event.target.classList.add('is-loaded');
26
- }, true);
27
- doc.addEventListener('error', (event) => {
28
- if (event.target?.matches?.('.ui-avatar > img[data-avatar-photo]')) event.target.remove();
29
- }, true);
30
- }
31
-
32
- if (typeof document !== 'undefined') wireAvatarPhotos(document);
33
-
34
- /**
35
- * @param {object} [o]
36
- * @param {string|number} [o.key] the app's stable id for the person; picks the hue
37
- * @param {string} [o.name] the person's name; empty draws the `user` glyph
38
- * @param {string} [o.initials] the letters to draw, when the caller has already chosen them
39
- * @param {string} [o.src] a photo URL; the letters show if it fails to load
40
- * @param {24|32} [o.size] the mark's size in px
41
- * @param {boolean} [o.empty] a dashed ring in place of a person
42
- * @returns {string} html
43
- */
44
- export function avatar({ key, name, initials, src, size = 24, empty = false } = {}) {
45
- if (typeof document !== 'undefined') wireAvatarPhotos(document);
46
- const base = ['ui-avatar', size === 32 && 'ui-avatar--32'];
47
- if (empty) return `<span class="${esc(cx(...base, 'ui-avatar--empty'))}" aria-hidden="true"></span>`;
48
- const letters = initials || avatarInitials(name);
49
- if (!letters) return `<span class="${esc(cx(...base, 'ui-avatar--anon'))}" aria-hidden="true">${icon('user')}</span>`;
50
- const hue = avatarHue(key ?? name ?? letters);
51
- const img = src ? `<img data-avatar-photo src="${esc(safeUrl(src))}" alt="" loading="lazy">` : '';
52
- return `<span class="${esc(cx(...base, `ui-avatar--h${hue}`))}" data-initials="${letters.length}" aria-hidden="true">${esc(letters)}${img}</span>`;
53
- }
@@ -1,57 +0,0 @@
1
- // Back link — the control that takes a reader from a page up to the page it sits
2
- // under, as an HTML string.
3
- //
4
- // It is a link to an address the caller names, never a script that walks the
5
- // browser's history. A page opened in a new tab, from a bookmark or from a shared
6
- // address has no history to walk, and the browser's own Back button already does
7
- // that job; an <a href> is also the one shape a reader can open in a new tab.
8
- //
9
- // It has one treatment and takes no variant: a chevron and the destination's
10
- // name in dim ink, with no box. Four were rendered side by side on
11
- // docs/reviews/270-back-control.html and the owner chose this one, so the other
12
- // three — a bordered button above the title, an icon-only arrow beside it, and
13
- // the breadcrumb trail alone — are not built here.
14
- // why: docs/components.md#the-back-link
15
- import { esc, icon } from './index.js';
16
-
17
- // "Back" names a direction rather than a place. It is what a caller who names no
18
- // destination gets, and the one label that is not spelled out as "Back to …".
19
- const BARE = 'Back';
20
-
21
- // A `javascript:` address is the history walk this component replaces, arriving
22
- // through the one parameter it has. Before a browser reads the scheme it strips
23
- // C0 controls and spaces from the front and removes every tab, LF and CR wherever
24
- // they sit, so "java\tscript:" is still javascript:. The check reads the address the
25
- // same way (WHATWG URL Standard, basic URL parser).
26
- const SCRIPTED = /^(?:javascript|data|vbscript):/i;
27
- const LEADING = /^[\u0000-\u0020]+/;
28
- const TAB_OR_NEWLINE = /[\t\n\r]/g;
29
-
30
- // A label that already says "Back to Invoices" names the place after those words, or the
31
- // link would be read as "Back to Back to Invoices". The whole phrase, since "Backups" and
32
- // "Back office" are places too. why: docs/components.md#the-back-link
33
- const SAID = /^back\s+to(?:\s+|$)/i;
34
-
35
- const text = (v) => (typeof v === 'string' || typeof v === 'number' ? String(v).trim() : '');
36
-
37
- /**
38
- * backLink({ href, label }) → the link a page under another page puts above its
39
- * title.
40
- *
41
- * `label` is the destination's name, spelled the way the sidebar or the trail
42
- * spells it. The arrow says "back" on screen and is aria-hidden, so the link's
43
- * accessible name says it in words: "Back to Invoices". That name still contains
44
- * the visible text, which is what WCAG 2.5.3 asks of a named control.
45
- *
46
- * No address, no link: a back control with nowhere to go renders nothing.
47
- */
48
- export function backLink({ href, label } = {}) {
49
- const to = text(href);
50
- if (!to || SCRIPTED.test(to.replace(LEADING, '').replace(TAB_OR_NEWLINE, ''))) return '';
51
- const name = text(label).replace(SAID, '');
52
- const bare = !name || name.toLowerCase() === BARE.toLowerCase();
53
- const shown = bare ? BARE : name;
54
- const named = bare ? '' : ` aria-label="${esc(`${BARE} to ${name}`)}"`;
55
- return `<a class="ui-back" href="${esc(to)}"${named}>${icon('chevronLeft')}`
56
- + `<span class="ui-back__label">${esc(shown)}</span></a>`;
57
- }
@@ -1,69 +0,0 @@
1
- const disabledBeforeBusy = new WeakMap();
2
- const wired = new WeakSet();
3
-
4
- function wireActivationGuard(element) {
5
- if (wired.has(element)) return;
6
- const block = event => {
7
- if (element.getAttribute('aria-busy') !== 'true') return;
8
- if (event.type !== 'click' && event.key !== 'Enter' && event.key !== ' ') return;
9
- event.preventDefault();
10
- event.stopImmediatePropagation();
11
- };
12
- for (const type of ['click', 'keydown', 'keyup']) element.addEventListener(type, block, true);
13
- element.setAttribute('data-btn-wired', '');
14
- wired.add(element);
15
- }
16
-
17
- /** Update a factory button in place, preserving its icons and prior disabled state. */
18
- export function setButtonBusy(element, { busy } = {}) {
19
- wireActivationGuard(element);
20
- const wasBusy = element.getAttribute('aria-busy') === 'true';
21
- if ((busy || wasBusy) && !disabledBeforeBusy.has(element)) disabledBeforeBusy.set(element, {
22
- disabled: wasBusy ? element.hasAttribute('data-btn-disabled') : element.hasAttribute('disabled'),
23
- ariaDisabled: wasBusy && !element.hasAttribute('data-btn-disabled') ? null : element.getAttribute('aria-disabled'),
24
- });
25
- if (busy) {
26
- element.removeAttribute('data-btn-ready');
27
- element.setAttribute('aria-busy', 'true');
28
- element.toggleAttribute('disabled', disabledBeforeBusy.get(element).disabled);
29
- element.setAttribute('aria-disabled', 'true');
30
- if (!element.querySelector('.ui-btn__dots')) {
31
- const dots = element.ownerDocument.createElement('span');
32
- dots.className = 'ui-btn__dots';
33
- dots.setAttribute('aria-hidden', 'true');
34
- dots.innerHTML = '<i></i><i></i><i></i>';
35
- element.append(dots);
36
- }
37
- } else if (wasBusy) {
38
- element.setAttribute('data-btn-ready', '');
39
- element.removeAttribute('aria-busy');
40
- element.querySelector('.ui-btn__dots')?.remove();
41
- const prior = disabledBeforeBusy.get(element);
42
- element.toggleAttribute('disabled', prior?.disabled ?? false);
43
- if (prior?.ariaDisabled != null) element.setAttribute('aria-disabled', prior.ariaDisabled);
44
- else element.removeAttribute('aria-disabled');
45
- disabledBeforeBusy.delete(element);
46
- }
47
- if (busy || wasBusy) {
48
- let status = element.nextElementSibling;
49
- if (!status?.classList.contains('ui-btn__status')) {
50
- status = element.ownerDocument.createElement('span');
51
- status.className = 'ui-sr ui-btn__status';
52
- status.setAttribute('role', 'status');
53
- status.setAttribute('aria-live', 'polite');
54
- element.after(status);
55
- // Register the empty live region before its first text update.
56
- setTimeout(() => {
57
- status.textContent = messageFor(element);
58
- }, 0);
59
- } else {
60
- const message = messageFor(element);
61
- if (status.textContent !== message) status.textContent = message;
62
- }
63
- }
64
- }
65
-
66
- function messageFor(element) {
67
- const name = element.querySelector('.ui-btn__label')?.textContent ?? element.getAttribute('aria-label') ?? 'Button';
68
- return `${name}: ${element.getAttribute('aria-busy') === 'true' ? 'in progress' : 'complete'}`;
69
- }