@bigpixelrocket/uiok 0.1.3 → 0.2.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.
Files changed (146) hide show
  1. package/CHANGELOG.md +95 -1
  2. package/README.md +1 -1
  3. package/dist/activity/ActivityBar.d.ts +21 -8
  4. package/dist/activity/ActivityBar.js +15 -5
  5. package/dist/activity/activity.css +53 -6
  6. package/dist/button/Button.d.ts +10 -6
  7. package/dist/button/Button.js +6 -1
  8. package/dist/button/button.css +201 -33
  9. package/dist/charts/Line.logic.d.ts +6 -0
  10. package/dist/charts/Line.logic.js +9 -0
  11. package/dist/charts/LineChart.js +11 -4
  12. package/dist/charts/Pie.logic.d.ts +89 -1
  13. package/dist/charts/Pie.logic.js +272 -2
  14. package/dist/charts/PieChart.d.ts +2 -1
  15. package/dist/charts/PieChart.js +12 -5
  16. package/dist/charts/PieFill.d.ts +15 -0
  17. package/dist/charts/PieFill.js +33 -0
  18. package/dist/charts/ResultChart.d.ts +2 -2
  19. package/dist/charts/ResultChart.js +173 -47
  20. package/dist/charts/ResultChart.logic.d.ts +60 -4
  21. package/dist/charts/ResultChart.logic.js +105 -6
  22. package/dist/charts/Scatter.logic.d.ts +18 -4
  23. package/dist/charts/Scatter.logic.js +98 -22
  24. package/dist/charts/ScatterChart.js +19 -5
  25. package/dist/charts/charts.css +233 -116
  26. package/dist/charts/seriesColour.d.ts +2 -0
  27. package/dist/charts/seriesColour.js +1 -1
  28. package/dist/datetime/DateTimePicker.d.ts +12 -2
  29. package/dist/datetime/DateTimePicker.js +61 -16
  30. package/dist/datetime/DateTimePicker.logic.d.ts +29 -0
  31. package/dist/datetime/DateTimePicker.logic.js +25 -0
  32. package/dist/datetime/datetime.css +89 -49
  33. package/dist/dialog/ConfirmDialog.d.ts +69 -20
  34. package/dist/dialog/ConfirmDialog.js +39 -12
  35. package/dist/dialog/DialogLayer.d.ts +25 -0
  36. package/dist/dialog/DialogLayer.js +24 -0
  37. package/dist/dialog/DialogLegend.d.ts +2 -1
  38. package/dist/dialog/DialogLegend.js +10 -5
  39. package/dist/dialog/DialogLegend.logic.d.ts +15 -3
  40. package/dist/dialog/DialogLegend.logic.js +8 -4
  41. package/dist/dialog/DialogLists.d.ts +157 -0
  42. package/dist/dialog/DialogLists.js +137 -0
  43. package/dist/dialog/ModalDialog.d.ts +20 -15
  44. package/dist/dialog/ModalDialog.js +22 -7
  45. package/dist/dialog/dialog.css +570 -127
  46. package/dist/dialog/index.d.ts +7 -1
  47. package/dist/dialog/index.js +7 -1
  48. package/dist/field/Check.d.ts +15 -0
  49. package/dist/field/Check.js +23 -0
  50. package/dist/field/field.css +812 -0
  51. package/dist/field/index.d.ts +10 -0
  52. package/dist/field/index.js +10 -0
  53. package/dist/field/labelHelp.d.ts +33 -0
  54. package/dist/field/labelHelp.js +22 -0
  55. package/dist/filter/FilterIcon.js +2 -1
  56. package/dist/filter/filter.css +72 -20
  57. package/dist/grid/DataGrid.d.ts +8 -1
  58. package/dist/grid/DataGrid.js +115 -40
  59. package/dist/grid/DataGrid.logic.d.ts +15 -3
  60. package/dist/grid/DataGrid.logic.js +18 -5
  61. package/dist/grid/grid.css +481 -56
  62. package/dist/icon/Spinner.d.ts +16 -0
  63. package/dist/icon/Spinner.js +13 -0
  64. package/dist/icon/index.d.ts +5 -0
  65. package/dist/icon/index.js +5 -0
  66. package/dist/icon/sizes.d.ts +19 -0
  67. package/dist/icon/sizes.js +19 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +2 -0
  70. package/dist/keychord/KeyChord.d.ts +12 -1
  71. package/dist/keychord/KeyChord.js +2 -2
  72. package/dist/keychord/index.d.ts +1 -1
  73. package/dist/keychord/keychord.css +87 -9
  74. package/dist/labels/dialog.d.ts +12 -1
  75. package/dist/labels/dialog.js +3 -1
  76. package/dist/labels/selectAll.d.ts +4 -4
  77. package/dist/labels/selectAll.js +1 -1
  78. package/dist/legend/KeyLegendStrip.js +1 -1
  79. package/dist/legend/legend.css +82 -57
  80. package/dist/listing/Listing.d.ts +17 -10
  81. package/dist/listing/Listing.js +33 -26
  82. package/dist/listing/listing.css +1665 -237
  83. package/dist/menu/menu.css +227 -67
  84. package/dist/menu/useBellBeat.js +2 -2
  85. package/dist/namecut/NameCut.d.ts +3 -1
  86. package/dist/namecut/NameCut.js +152 -5
  87. package/dist/namecut/NameCut.logic.d.ts +5 -3
  88. package/dist/namecut/NameCut.logic.js +20 -5
  89. package/dist/namecut/namecut.css +27 -7
  90. package/dist/pager/Pager.d.ts +12 -4
  91. package/dist/pager/Pager.js +21 -7
  92. package/dist/pager/pager.css +41 -30
  93. package/dist/palette/Palette.js +2 -1
  94. package/dist/palette/palette.css +121 -60
  95. package/dist/pane/PaneActions.d.ts +56 -14
  96. package/dist/pane/PaneActions.js +64 -16
  97. package/dist/pane/PaneFrame.d.ts +37 -5
  98. package/dist/pane/PaneFrame.js +246 -11
  99. package/dist/pane/index.d.ts +4 -2
  100. package/dist/pane/index.js +4 -2
  101. package/dist/pane/toolWords.d.ts +14 -0
  102. package/dist/pane/toolWords.js +26 -0
  103. package/dist/pane/useToolbarFit.d.ts +25 -0
  104. package/dist/pane/useToolbarFit.js +95 -0
  105. package/dist/run/RunHeader.d.ts +5 -3
  106. package/dist/run/RunHeader.js +11 -8
  107. package/dist/run/run.css +64 -79
  108. package/dist/segmented/SegmentedChoice.d.ts +18 -2
  109. package/dist/segmented/SegmentedChoice.js +18 -7
  110. package/dist/segmented/segmented.css +62 -22
  111. package/dist/selectall/SelectAllBar.d.ts +4 -3
  112. package/dist/selectall/SelectAllBar.js +4 -3
  113. package/dist/selectall/selectall.css +17 -12
  114. package/dist/shell/shell.css +1073 -0
  115. package/dist/styles.css +620 -22
  116. package/dist/surface/surface.css +154 -0
  117. package/dist/tabs/PageTabs.d.ts +10 -5
  118. package/dist/tabs/PageTabs.js +126 -37
  119. package/dist/tabs/tabs.css +131 -51
  120. package/dist/terminal/Terminal.js +3 -1
  121. package/dist/terminal/Terminal.logic.d.ts +5 -4
  122. package/dist/terminal/Terminal.logic.js +9 -4
  123. package/dist/terminal/TerminalMenu.d.ts +4 -1
  124. package/dist/terminal/TerminalMenu.js +12 -5
  125. package/dist/terminal/ghostty/contrast.logic.d.ts +45 -0
  126. package/dist/terminal/ghostty/contrast.logic.js +130 -0
  127. package/dist/terminal/ghostty/core.d.ts +6 -0
  128. package/dist/terminal/ghostty/renderer.d.ts +9 -2
  129. package/dist/terminal/ghostty/renderer.js +91 -14
  130. package/dist/terminal/ghostty/surface.d.ts +8 -0
  131. package/dist/terminal/ghostty/surface.js +27 -1
  132. package/dist/terminal/terminal.css +87 -61
  133. package/dist/text/text.css +16 -7
  134. package/dist/themes/catalog.js +4 -3
  135. package/dist/themes/themes.generated.css +1307 -264
  136. package/dist/themes/tokens.d.ts +69 -14
  137. package/dist/themes/tokens.js +920 -97
  138. package/dist/tokens.css +239 -0
  139. package/dist/tooltip/Tooltip.d.ts +6 -0
  140. package/dist/tooltip/Tooltip.js +48 -6
  141. package/dist/tooltip/Tooltip.logic.d.ts +89 -12
  142. package/dist/tooltip/Tooltip.logic.js +142 -20
  143. package/dist/tooltip/index.d.ts +1 -1
  144. package/dist/tooltip/index.js +1 -1
  145. package/dist/tooltip/tooltip.css +39 -9
  146. package/package.json +9 -3
@@ -0,0 +1,154 @@
1
+ /* ---- Notices and cards (docs/components/surface.md) ----
2
+
3
+ Surfaces a page draws around its own content, as classes on the page's
4
+ own markup. No component: their words are the page's.
5
+
6
+ - .notice: an application's status line, never a web page's alert. It
7
+ sits on the surface it is about (a step, a field, a pane) with no fill,
8
+ no frame, and no side bar of its own: a small status glyph in the
9
+ tone's colour, the words in --text, and an optional small button after
10
+ them. Tones: .notice-danger, .notice-warning, .notice-success; none is
11
+ a note. .notice-card sets it as the window's status line under a
12
+ header: the same plain line at the window's inset, a hairline under it.
13
+ - .card: a lifted panel that groups one subject's lines, framed in
14
+ --border-strong like every framed surface (panes, menus, the grid),
15
+ at the 12px surface inset at both ends, whatever its children's
16
+ margins. */
17
+
18
+ .notice {
19
+ /* The tone's glyph, 3:1 on every ground by its token. */
20
+ --notice-tone: var(--text-faint);
21
+
22
+ display: flex;
23
+ align-items: flex-start;
24
+ gap: var(--space-3);
25
+ box-sizing: border-box;
26
+ min-width: 0;
27
+ margin: 0;
28
+ padding: 0;
29
+ color: var(--text);
30
+ font: var(--font-weight-regular) var(--font-size-small) / var(--line-height-compact)
31
+ var(--font-ui);
32
+ }
33
+
34
+ .notice-danger {
35
+ --notice-tone: var(--danger);
36
+ }
37
+
38
+ .notice-warning {
39
+ --notice-tone: var(--warning);
40
+ }
41
+
42
+ .notice-success {
43
+ --notice-tone: var(--success);
44
+ }
45
+
46
+ /* The glyph (a lucide icon of --icon-md, or anything marked .notice-glyph)
47
+ sits on the first line's centre in the tone. */
48
+ .notice > svg:first-child,
49
+ .notice-glyph {
50
+ flex: none;
51
+ width: var(--icon-md);
52
+ height: var(--icon-md);
53
+ margin-block: var(--space-1);
54
+ color: var(--notice-tone);
55
+ }
56
+
57
+ /* A glyph wrapped in .notice-glyph (a Spinner in a span) fills its box,
58
+ off the text baseline. */
59
+ .notice-glyph > svg {
60
+ display: block;
61
+ width: 100%;
62
+ height: 100%;
63
+ }
64
+
65
+ .notice-text {
66
+ flex: 0 1 auto;
67
+ min-width: 0;
68
+ margin: 0;
69
+ overflow-wrap: anywhere;
70
+ }
71
+
72
+ /* A message's words are content: a path or a server's reply in them is
73
+ what a user pastes into a report, so they can be swept and copied. */
74
+ .notice-text {
75
+ -webkit-user-select: text;
76
+ user-select: text;
77
+ }
78
+
79
+ /* An action follows the words, as a status line's button does, centred
80
+ on the message's first line. */
81
+ .notice-actions {
82
+ display: flex;
83
+ flex: none;
84
+ align-items: center;
85
+ gap: var(--space-2);
86
+ margin-block: calc((var(--line-height-compact) - var(--control-height-sm)) / 2);
87
+ margin-inline-start: var(--space-2);
88
+ }
89
+
90
+ /* The window's status line under a header, about a state that stands
91
+ until the user fixes it elsewhere (a settings file with a mistake): the
92
+ notice's plain line at the window's inset, with a hairline under it to
93
+ part it from the panes. No fill, no tint, no side bar, no shadow, and no
94
+ close cross: it goes when its cause does. */
95
+ .notice-card {
96
+ align-items: center;
97
+ padding: var(--space-2) var(--space-6);
98
+ border-bottom: var(--line) solid var(--border);
99
+ }
100
+
101
+ .notice-card .notice-actions {
102
+ margin-block: 0;
103
+ }
104
+
105
+ /* A status line is one line: in a narrow window its words are cut with an
106
+ ellipsis rather than wrapped onto a second line that pushes the panes
107
+ down. The host gives the words their whole text as a tooltip while cut
108
+ (cutTooltip on the .notice-text). */
109
+ .notice-card .notice-text {
110
+ overflow: hidden;
111
+ text-overflow: ellipsis;
112
+ white-space: nowrap;
113
+ }
114
+
115
+ /* The danger glyph for a message whose markup draws none: a field's
116
+ problem (.field-problem), a listing's refusal (.pane-message.danger),
117
+ and a palette's failure note (.palette-failure) lead with the danger
118
+ tone's CircleAlert, drawn as a mask in --danger, so they read as the same status line a notice is, words in --text. A host
119
+ that draws its own glyph first (an svg) gets no second one. */
120
+ :is(
121
+ .field-problem,
122
+ :where(.listing-root) .pane-message.danger,
123
+ :where(.palette-notes) .palette-failure
124
+ ):not(:has(> svg:first-child))::before {
125
+ content: '';
126
+ flex: none;
127
+ width: var(--icon-md);
128
+ height: var(--icon-md);
129
+ background: var(--danger);
130
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E")
131
+ center / contain no-repeat;
132
+ }
133
+
134
+ .card {
135
+ box-sizing: border-box;
136
+ min-width: 0;
137
+ padding: var(--space-6);
138
+ border: var(--line) solid var(--border-strong);
139
+ border-radius: var(--radius-md);
140
+ background: var(--card-bg);
141
+ }
142
+
143
+ /* The card's inset is its spacing at both ends: its first child starts at
144
+ the 12px edge and its last ends there, whatever margins a heading or a
145
+ paragraph brings. Space between children stays the content's own (a
146
+ paragraph's margin, a grid's gap), so a card laid out as a grid is not
147
+ spaced twice. */
148
+ .card > :first-child {
149
+ margin-block-start: 0;
150
+ }
151
+
152
+ .card > :last-child {
153
+ margin-block-end: 0;
154
+ }
@@ -1,4 +1,4 @@
1
- import type { LucideIcon } from 'lucide-react';
1
+ import { type LucideIcon } from 'lucide-react';
2
2
  import { type ReactElement } from 'react';
3
3
  import type { LinkLook } from '../pane/PaneActions.js';
4
4
  /** One tab of a page's strip. */
@@ -35,9 +35,14 @@ export interface PageTabsProps<Id extends string> {
35
35
  * current tab. `pills` draws the second, smaller strip a tab's own pages
36
36
  * take under the first.
37
37
  *
38
- * A strip too narrow for its tabs scrolls sideways: it fades each edge that
39
- * hides tabs (`data-overflow`), and keeps the current tab in view when it
40
- * first draws and whenever `current` or the tabs change, scrolling only
41
- * the strip, never the page.
38
+ * A strip too narrow for its tabs scrolls sideways and draws whole tabs
39
+ * only: a tab that would be cut at an edge is not drawn (`data-clipped`),
40
+ * and each edge that hides tabs (`data-overflow`) shows a small chevron in
41
+ * its own room, which a click pages the strip toward by whole tabs. The
42
+ * chevron is left out of the tab order and the accessibility tree, where
43
+ * the arrow keys already reach every tab; a tab not drawn stays in both.
44
+ * The strip comes to rest on a tab start, and keeps the current tab whole
45
+ * and in view when it first draws and whenever `current` or the tabs
46
+ * change, scrolling only the strip, never the page.
42
47
  */
43
48
  export declare function PageTabs<Id extends string>({ label, tabs, current, onSelect, pills, look }: PageTabsProps<Id>): ReactElement;
@@ -1,15 +1,42 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ChevronLeft, ChevronRight } from 'lucide-react';
2
3
  import { useEffect, useLayoutEffect, useRef } from 'react';
4
+ import { ICON_MD } from '../icon/index.js';
3
5
  import { tooltip } from '../tooltip/Tooltip.logic.js';
4
6
  /**
5
- * How far the strip's edge fade reaches, in pixels; `tabs.css` draws the
6
- * fade this wide, and a tab scrolled into view clears it.
7
+ * The room, in pixels, the chevron takes at an edge that hides tabs; no
8
+ * tab is drawn there. `tabs.css` sizes the chevron (`--space-12`) and the
9
+ * strip's snap padding to match.
7
10
  */
8
- const EDGE_FADE = 24;
11
+ const EDGE = 24;
12
+ /** Slack for subpixel tab boxes, so a tab that fits is never taken for cut. */
13
+ const SLACK = 0.5;
14
+ /**
15
+ * The span of `strip`, in viewport pixels, where a tab is drawn: its box,
16
+ * less the chevron's room at each edge `data-overflow` marks.
17
+ */
18
+ function clearSpan(strip) {
19
+ const bounds = strip.getBoundingClientRect();
20
+ const sides = strip.getAttribute('data-overflow') ?? '';
21
+ return {
22
+ start: bounds.left + (sides.includes('start') ? EDGE : 0),
23
+ end: bounds.right - (sides.includes('end') ? EDGE : 0)
24
+ };
25
+ }
26
+ /** The tabs of `strip`, in drawing order. */
27
+ function tabsOf(strip) {
28
+ return [...strip.querySelectorAll('[data-page-tab]')];
29
+ }
9
30
  /**
10
31
  * Marks the sides of `strip` that hide tabs past its edge as
11
32
  * `data-overflow="start end"` (either, both, or the attribute removed), so
12
- * `tabs.css` fades those edges and a reader can tell more tabs are there.
33
+ * `tabs.css` shows a chevron there, and marks `data-clipped` every tab that
34
+ * does not lie whole in the clear span, which `tabs.css` does not draw: the
35
+ * strip shows whole tabs only, ending after the last one that fits. A tab
36
+ * wider than the clear span left between both chevrons may never lie whole
37
+ * in the span (at an end of the scroll, as near the strip's whole width as
38
+ * one chevron allows), so it is drawn cut wherever it crosses the span, and
39
+ * stays visible and clickable.
13
40
  */
14
41
  function markOverflow(strip) {
15
42
  const sides = [];
@@ -21,6 +48,14 @@ function markOverflow(strip) {
21
48
  strip.removeAttribute('data-overflow');
22
49
  else
23
50
  strip.setAttribute('data-overflow', sides.join(' '));
51
+ const span = clearSpan(strip);
52
+ const room = strip.getBoundingClientRect().width - 2 * EDGE;
53
+ for (const tab of tabsOf(strip)) {
54
+ const box = tab.getBoundingClientRect();
55
+ const whole = box.left >= span.start - SLACK && box.right <= span.end + SLACK;
56
+ const oversized = box.width > room + SLACK && box.right > span.start && box.left < span.end;
57
+ tab.toggleAttribute('data-clipped', !whole && !oversized);
58
+ }
24
59
  }
25
60
  /**
26
61
  * The tab of `strip` whose id is `id`, if it draws one. The id is compared
@@ -29,30 +64,76 @@ function markOverflow(strip) {
29
64
  * rendered into an iframe's document has that window's elements).
30
65
  */
31
66
  function tabOf(strip, id) {
32
- for (const tab of strip.querySelectorAll('[data-page-tab]')) {
33
- if (tab.dataset.pageTab === id)
34
- return tab;
35
- }
36
- return null;
67
+ return tabsOf(strip).find((tab) => tab.dataset.pageTab === id) ?? null;
37
68
  }
38
69
  /**
39
- * Scrolls `strip` sideways, and only `strip`, so `tab` sits clear of the
40
- * edge fade, or as near as the scroll allows; a tab already clear stays
41
- * put. Smooth unless `instant` or the reader prefers reduced motion.
70
+ * Scrolls `strip` by `by`, kept within its scroll, at once: a desktop tab
71
+ * strip moves by a step, it does not glide.
42
72
  */
43
- function revealTab(strip, tab, instant) {
73
+ function scrollStrip(strip, by) {
74
+ const within = Math.max(-strip.scrollLeft, Math.min(by, strip.scrollWidth - strip.clientWidth - strip.scrollLeft));
75
+ if (within === 0)
76
+ return;
77
+ strip.scrollBy({ left: within, behavior: 'instant' });
78
+ }
79
+ /**
80
+ * Scrolls `strip` sideways, and only `strip`, so `tab` lies whole clear of
81
+ * the chevrons' room, or as near as the scroll allows; a tab already clear
82
+ * stays put. The strip snaps to tab starts (`tabs.css`), so the scroll
83
+ * lands on one: a tab behind the start edge comes to rest at the start
84
+ * chevron's inner edge, and one past the end edge brings in the first tab
85
+ * start that clears it, which the snap then keeps.
86
+ */
87
+ function revealTab(strip, tab) {
44
88
  const bounds = strip.getBoundingClientRect();
45
89
  const box = tab.getBoundingClientRect();
46
- const before = box.left - (bounds.left + EDGE_FADE);
47
- const after = box.right - (bounds.right - EDGE_FADE);
48
- // A tab wider than the clear span shows its start.
49
- const wanted = before < 0 ? before : after > 0 ? Math.min(after, before) : 0;
50
- // Within the scroll there is: an end tab needs no move into the padding.
51
- const by = Math.max(-strip.scrollLeft, Math.min(wanted, strip.scrollWidth - strip.clientWidth - strip.scrollLeft));
52
- if (by === 0)
53
- return;
54
- const still = instant || (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false);
55
- strip.scrollBy({ left: by, behavior: still ? 'instant' : 'smooth' });
90
+ const before = box.left - (bounds.left + EDGE);
91
+ const after = box.right - (bounds.right - EDGE);
92
+ let wanted = 0;
93
+ if (before < 0)
94
+ wanted = before;
95
+ else if (after > 0) {
96
+ // The first tab start that, at the chevron's inner edge, clears this
97
+ // tab; a tab wider than the clear span shows its own start.
98
+ wanted = before;
99
+ for (const other of tabsOf(strip)) {
100
+ const start = other.getBoundingClientRect().left - (bounds.left + EDGE);
101
+ if (start >= after) {
102
+ wanted = Math.min(start, before);
103
+ break;
104
+ }
105
+ }
106
+ }
107
+ scrollStrip(strip, wanted);
108
+ }
109
+ /**
110
+ * Pages `strip` toward `side` by whole tabs: toward the end, the first tab
111
+ * not drawn there comes to rest at the start chevron's inner edge; toward
112
+ * the start, the strip rests on the earliest tab start that still shows
113
+ * the last tab not drawn there whole. Either rest is a tab start, which
114
+ * the strip's mandatory snap keeps. A tab wider than the clear span, which
115
+ * no rest shows whole, is passed by its start, so every page moves.
116
+ */
117
+ function pageStrip(strip, side) {
118
+ const bounds = strip.getBoundingClientRect();
119
+ const span = clearSpan(strip);
120
+ const tabs = tabsOf(strip).map((tab) => tab.getBoundingClientRect());
121
+ const inner = bounds.left + EDGE;
122
+ let by;
123
+ if (side === 'end') {
124
+ const next = tabs.find((box) => box.right > span.end + SLACK && box.left > inner + SLACK);
125
+ if (next !== undefined)
126
+ by = next.left - inner;
127
+ }
128
+ else {
129
+ const last = tabs.filter((box) => box.left < span.start - SLACK).at(-1);
130
+ const room = bounds.width - 2 * EDGE;
131
+ if (last !== undefined) {
132
+ const first = tabs.find((box) => box.left >= last.right - room) ?? last;
133
+ by = Math.min(first.left, last.left) - inner;
134
+ }
135
+ }
136
+ scrollStrip(strip, by ?? (side === 'start' ? -1 : 1) * Math.max(EDGE, bounds.width - 2 * EDGE));
56
137
  }
57
138
  /**
58
139
  * The tab strip a page draws under its path bar: one tab per page of the
@@ -64,20 +145,24 @@ function revealTab(strip, tab, instant) {
64
145
  * current tab. `pills` draws the second, smaller strip a tab's own pages
65
146
  * take under the first.
66
147
  *
67
- * A strip too narrow for its tabs scrolls sideways: it fades each edge that
68
- * hides tabs (`data-overflow`), and keeps the current tab in view when it
69
- * first draws and whenever `current` or the tabs change, scrolling only
70
- * the strip, never the page.
148
+ * A strip too narrow for its tabs scrolls sideways and draws whole tabs
149
+ * only: a tab that would be cut at an edge is not drawn (`data-clipped`),
150
+ * and each edge that hides tabs (`data-overflow`) shows a small chevron in
151
+ * its own room, which a click pages the strip toward by whole tabs. The
152
+ * chevron is left out of the tab order and the accessibility tree, where
153
+ * the arrow keys already reach every tab; a tab not drawn stays in both.
154
+ * The strip comes to rest on a tab start, and keeps the current tab whole
155
+ * and in view when it first draws and whenever `current` or the tabs
156
+ * change, scrolling only the strip, never the page.
71
157
  */
72
158
  export function PageTabs({ label, tabs, current, onSelect, pills = false, look = 'both' }) {
73
159
  const strip = useRef(null);
74
160
  const focusable = current ?? tabs[0]?.id ?? null;
75
- const drawn = useRef(false);
76
161
  // The tabs drawn, as a value that changes only when they do, not with
77
162
  // each new array a caller passes.
78
163
  const ids = JSON.stringify(tabs.map((tab) => tab.id));
79
- // The edge fade follows scrolling, resizing (a tab's look or font
80
- // included), and the tabs drawn.
164
+ // The edge marks and the tabs drawn whole follow scrolling, resizing (a
165
+ // tab's look or font included), and the tabs drawn.
81
166
  useEffect(() => {
82
167
  const element = strip.current;
83
168
  if (element === null)
@@ -94,18 +179,15 @@ export function PageTabs({ label, tabs, current, onSelect, pills = false, look =
94
179
  resizes?.disconnect();
95
180
  };
96
181
  }, [ids]);
97
- // The current tab stays in view: at once, before the first paint, when
98
- // the strip first draws tabs, then smoothly as it or the tabs change.
182
+ // The current tab stays in view, before the strip paints, when it first
183
+ // draws tabs and whenever the current tab or the tabs change.
99
184
  useLayoutEffect(() => {
100
185
  const element = strip.current;
101
186
  if (element === null)
102
187
  return;
103
- const instant = !drawn.current;
104
188
  const tab = current === null ? null : tabOf(element, current);
105
- if (element.children.length > 0)
106
- drawn.current = true;
107
189
  if (tab !== null)
108
- revealTab(element, tab, instant);
190
+ revealTab(element, tab);
109
191
  }, [current, ids]);
110
192
  const onKeyDown = (event) => {
111
193
  if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight')
@@ -123,5 +205,12 @@ export function PageTabs({ label, tabs, current, onSelect, pills = false, look =
123
205
  if (strip.current !== null)
124
206
  tabOf(strip.current, next.id)?.focus();
125
207
  };
126
- return (_jsx("div", { "aria-label": label, className: pills ? 'page-tabs pills' : 'page-tabs', onKeyDown: onKeyDown, ref: strip, role: "tablist", children: tabs.map(({ id, label: name, icon: Icon }) => (_jsxs("button", { "aria-label": look === 'icons' ? name : undefined, "aria-selected": id === current, className: "page-tab", "data-page-tab": id, onClick: () => onSelect(id), role: "tab", tabIndex: id === focusable ? 0 : -1, type: "button", ...(look === 'icons' ? tooltip(name) : {}), children: [look !== 'text' && _jsx(Icon, { "aria-hidden": true, size: 13 }), look !== 'icons' && _jsx("span", { children: name })] }, id))) }));
208
+ const chevron = (side) => {
209
+ const Icon = side === 'start' ? ChevronLeft : ChevronRight;
210
+ return (_jsx("button", { "aria-hidden": true, className: `page-tabs-more ${side}`, onClick: () => {
211
+ if (strip.current !== null)
212
+ pageStrip(strip.current, side);
213
+ }, tabIndex: -1, type: "button", children: _jsx(Icon, { "aria-hidden": true, size: ICON_MD }) }));
214
+ };
215
+ return (_jsxs("div", { className: pills ? 'page-tabs-frame pills' : 'page-tabs-frame', children: [_jsx("div", { "aria-label": label, className: pills ? 'page-tabs pills' : 'page-tabs', onKeyDown: onKeyDown, ref: strip, role: "tablist", children: tabs.map(({ id, label: name, icon: Icon }) => (_jsxs("button", { "aria-label": look === 'icons' ? name : undefined, "aria-selected": id === current, className: "page-tab", "data-page-tab": id, onClick: () => onSelect(id), role: "tab", tabIndex: id === focusable ? 0 : -1, type: "button", ...(look === 'icons' ? tooltip(name) : {}), children: [look !== 'text' && _jsx(Icon, { "aria-hidden": true, size: ICON_MD }), look !== 'icons' && _jsx("span", { "data-label": name, children: name })] }, id))) }), chevron('start'), chevron('end')] }));
127
216
  }
@@ -1,88 +1,168 @@
1
1
  /* ---- Page tabs (PageTabs) ----
2
2
 
3
- The level's pages as tabs under a path bar, the current one underlined
4
- in the accent. A strip too narrow for its tabs scrolls sideways and
5
- fades each edge that hides tabs (PageTabs sets data-overflow). */
6
- .page-tabs {
3
+ The level's pages as tabs under a path bar, each a small cornered tab
4
+ inside the strip, the current one on the current item's tint and ring,
5
+ as a desktop tab control draws it (no web underline); the second strip
6
+ wears the same look in smaller type. A strip too narrow for its tabs scrolls sideways and
7
+ draws whole tabs only: PageTabs marks data-clipped any tab that does not
8
+ lie whole between the chevrons, and marks data-overflow each edge that
9
+ hides tabs, where a chevron pages the strip. Hover and pressed come from
10
+ the base stylesheet's track recipe. */
11
+
12
+ /* The frame holds the strip and its two chevrons, drawn over the strip's
13
+ ends, where no tab is drawn while they show. */
14
+ .page-tabs-frame {
15
+ position: relative;
7
16
  flex: none;
17
+ min-width: 0;
18
+ }
19
+
20
+ /* The strip has room above and below its tabs, as the toolbars around it
21
+ have round their controls (a form's action bar stands its 24px buttons
22
+ 6px from each edge): the tabs are 24px pills, 6px clear of the strip's
23
+ top and of its hairline. */
24
+ .page-tabs {
8
25
  display: flex;
9
- align-items: stretch;
10
- gap: 2px;
11
- height: 28px;
12
- padding: 0 6px;
26
+ align-items: center;
27
+ gap: var(--space-1);
28
+ height: calc(var(--control-height-sm) + 2 * var(--space-3));
29
+ padding: var(--space-3);
13
30
  overflow-x: auto;
14
31
  box-sizing: border-box;
15
- border-bottom: 1px solid var(--border);
32
+ /* The strip's hairline, under the tabs, which stand clear of it. */
33
+ box-shadow: inset 0 calc(-1 * var(--line)) 0 var(--border);
16
34
  scrollbar-width: none;
35
+ /* A scrolled strip always comes to rest with a tab's start at the start
36
+ chevron's inner edge (or at either end of its scroll); a tab wider
37
+ than the strip is a snap area the reader can scroll within. Tabs snap by
38
+ their start only: an end snap would let the strip rest with the last
39
+ tab whole and the first cut. The padding is the chevron's room, EDGE in
40
+ PageTabs.tsx, and PageTabs scrolls to tab starts, so a tab it brings in
41
+ already rests on a snap position. */
42
+ scroll-snap-type: x mandatory;
43
+ scroll-padding-inline: var(--space-12);
17
44
  }
18
45
 
19
- /* The fade is a mask, so it shows whatever lies under the strip; a mask
20
- reads only alpha, and --text is opaque in every theme. Its 24px matches
21
- EDGE_FADE in PageTabs.tsx, which scrolls the current tab clear of it. */
22
- .page-tabs[data-overflow] {
23
- --page-tabs-fade-start: 0px;
24
- --page-tabs-fade-end: 0px;
25
- mask-image: linear-gradient(
26
- to right,
27
- transparent,
28
- var(--text) var(--page-tabs-fade-start),
29
- var(--text) calc(100% - var(--page-tabs-fade-end)),
30
- transparent
31
- );
46
+ /* A tab that would be cut is not drawn: the strip ends after the last tab
47
+ that fits whole, and the chevron beside it says there are more. (A tab
48
+ wider than the clear span, which never fits whole, is drawn cut.) It stays
49
+ in the tab order and the accessibility tree, and the arrow keys bring it
50
+ in; it takes no click while it is not drawn. */
51
+ .page-tab[data-clipped] {
52
+ opacity: 0;
53
+ pointer-events: none;
32
54
  }
33
55
 
34
- .page-tabs[data-overflow~='start'] {
35
- --page-tabs-fade-start: 24px;
56
+ /* The chevron at an end that hides tabs: a quiet glyph in its own room,
57
+ where no tab is drawn, its click area that room's width and the strip's
58
+ height. */
59
+ .page-tabs-more {
60
+ position: absolute;
61
+ inset-block: 0;
62
+ display: none;
63
+ align-items: center;
64
+ width: var(--space-12);
65
+ padding: 0;
66
+ border: none;
67
+ background: transparent;
68
+ color: var(--text-dim);
69
+ cursor: default;
70
+ }
71
+
72
+ .page-tabs-more:hover {
73
+ color: var(--text);
36
74
  }
37
75
 
38
- .page-tabs[data-overflow~='end'] {
39
- --page-tabs-fade-end: 24px;
76
+ /* The glyph answers the pointer in a small box of its own, as a quiet
77
+ control does: a wash under hover, the pressed wash while held. The box
78
+ pads the glyph and pulls back by the same step, so the glyph stays where
79
+ it rests and the wash stays in the chevron's room. */
80
+ .page-tabs-more > svg {
81
+ box-sizing: content-box;
82
+ margin: calc(-1 * var(--space-1));
83
+ padding: var(--space-1);
84
+ border-radius: var(--radius-sm);
85
+ }
86
+
87
+ .page-tabs-more:hover > svg {
88
+ background: var(--hover-wash);
89
+ }
90
+
91
+ .page-tabs-more:active > svg {
92
+ background: var(--pressed-wash);
93
+ box-shadow: var(--press-frost);
94
+ }
95
+
96
+ .page-tabs-more.start {
97
+ inset-inline-start: 0;
98
+ justify-content: flex-start;
99
+ }
100
+
101
+ .page-tabs-more.end {
102
+ inset-inline-end: 0;
103
+ justify-content: flex-end;
104
+ }
105
+
106
+ .page-tabs-frame:has(> .page-tabs[data-overflow~='start']) > .page-tabs-more.start,
107
+ .page-tabs-frame:has(> .page-tabs[data-overflow~='end']) > .page-tabs-more.end {
108
+ display: flex;
40
109
  }
41
110
 
42
111
  .page-tab {
43
112
  display: inline-flex;
44
113
  align-items: center;
45
- gap: 6px;
46
- padding: 0 10px;
114
+ gap: var(--space-3);
115
+ height: var(--control-height-sm);
116
+ padding: 0 var(--space-5);
47
117
  border: none;
48
- border-bottom: 2px solid transparent;
118
+ border-radius: var(--radius-sm);
49
119
  background: transparent;
50
120
  color: var(--text-dim);
51
- font: 12px var(--font-ui);
121
+ font: var(--font-size-small) var(--font-ui);
52
122
  white-space: nowrap;
53
- cursor: pointer;
123
+ cursor: default;
124
+ scroll-snap-align: start;
54
125
  }
55
126
 
56
- .page-tab:hover:enabled {
57
- background: var(--hover-wash);
58
- color: var(--text);
127
+ /* The name keeps the width of its bold self, so no tab moves sideways when
128
+ the current one changes. */
129
+ .page-tab > span {
130
+ display: inline-flex;
131
+ flex-direction: column;
132
+ }
133
+
134
+ .page-tab > span::after {
135
+ height: 0;
136
+ overflow: hidden;
137
+ visibility: hidden;
138
+ font-weight: var(--font-weight-strong);
139
+ /* Empty alternative text: the copy never joins the tab's accessible name. */
140
+ content: attr(data-label) / '';
59
141
  }
60
142
 
61
143
  .page-tab[aria-selected='true'] {
62
- border-bottom-color: var(--accent);
63
- color: var(--text);
64
- font-weight: 600;
144
+ background: var(--current-bg);
145
+ box-shadow: inset 0 0 0 var(--line) var(--current-ring);
146
+ color: var(--current-text);
147
+ font-weight: var(--font-weight-strong);
65
148
  }
66
149
 
150
+ /* The strip scrolls sideways and clips anything outside it: the ring sits
151
+ inside the tab, never cut. */
67
152
  .page-tab:focus-visible {
68
- outline: 2px solid var(--accent);
69
- outline-offset: -2px;
153
+ outline-offset: var(--focus-offset-inset);
70
154
  }
71
155
 
72
- /* The second strip, a tab's own pages: rounded pills on a shorter row, the current one washed. */
156
+ /* The second strip, a tab's own pages: the same tabs on a shorter row, in
157
+ smaller type, 20px pills with 4px of room above and below. */
73
158
  .page-tabs.pills {
74
- height: 26px;
75
- padding: 3px 6px;
76
- gap: 4px;
159
+ height: calc(var(--control-height-xs) + 2 * var(--space-2));
160
+ padding: var(--space-2) var(--space-3);
161
+ gap: var(--space-2);
77
162
  }
78
163
 
79
164
  .page-tabs.pills .page-tab {
80
- padding: 0 8px;
81
- border-bottom: none;
82
- border-radius: 999px;
83
- font-size: 11px;
84
- }
85
-
86
- .page-tabs.pills .page-tab[aria-selected='true'] {
87
- background: var(--cursor-row-bg);
165
+ height: var(--control-height-xs);
166
+ padding: 0 var(--space-4);
167
+ font-size: var(--font-size-caption);
88
168
  }
@@ -38,7 +38,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
38
38
  * a log mirror), and an interactive terminal's label sits on its input
39
39
  * element.
40
40
  */
41
+ import { CircleAlert } from 'lucide-react';
41
42
  import { useContext, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
43
+ import { ICON_MD } from '../icon/index.js';
42
44
  import { useLabels } from '../labels/UiokProvider.js';
43
45
  import { subscribeThemeChange } from '../themes/attributes.js';
44
46
  import { GhosttyTerminalSurface } from './ghostty/surface.js';
@@ -294,7 +296,7 @@ export function Terminal({ ariaLabel, onInput, onResize, onConsumed, onBell, act
294
296
  }, [readOnly]);
295
297
  // Titled on every render, so an open menu follows a change of labels.
296
298
  const menuItems = menu === null ? null : terminalMenuItems(menu.state, labels, menuChords);
297
- return (_jsxs("div", { className: className === undefined ? 'terminal' : `terminal ${className}`, children: [_jsx("div", { "aria-label": readOnly ? ariaLabel : undefined, className: "terminal-mount", hidden: failed, ref: mountRef, role: readOnly ? 'group' : undefined, tabIndex: readOnly ? 0 : -1 }), failed && _jsx("p", { className: "terminal-failure", children: labels.startFailed }), menu !== null && (_jsx(TerminalMenu, { at: menu.at, items: menuItems ?? [], label: labels.menu, onClose: (by) => {
299
+ return (_jsxs("div", { className: className === undefined ? 'terminal' : `terminal ${className}`, children: [_jsx("div", { "aria-label": readOnly ? ariaLabel : undefined, className: "terminal-mount", hidden: failed, ref: mountRef, role: readOnly ? 'group' : undefined, tabIndex: readOnly ? 0 : -1 }), failed && (_jsxs("div", { className: "terminal-failure", role: "alert", children: [_jsx(CircleAlert, { "aria-hidden": true, className: "terminal-failure-glyph", size: ICON_MD }), _jsx("p", { className: "terminal-failure-text", children: labels.startFailed })] })), menu !== null && (_jsx(TerminalMenu, { at: menu.at, items: menuItems ?? [], label: labels.menu, onClose: (by) => {
298
300
  setMenu(null);
299
301
  if (by === 'keyboard')
300
302
  surfaceRef.current?.focus();