@bigpixelrocket/uiok 0.2.2 → 0.2.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.
- package/CHANGELOG.md +37 -1
- package/dist/button/TextLink.d.ts +27 -0
- package/dist/button/TextLink.js +15 -0
- package/dist/button/button.css +48 -0
- package/dist/button/index.d.ts +2 -1
- package/dist/button/index.js +2 -1
- package/dist/dialog/ConfirmDialog.d.ts +7 -1
- package/dist/dialog/ConfirmDialog.js +9 -4
- package/dist/dialog/DialogLists.d.ts +8 -1
- package/dist/dialog/DialogLists.js +3 -2
- package/dist/field/field.css +110 -2
- package/dist/filter/filter.css +16 -0
- package/dist/grid/DataGrid.d.ts +10 -2
- package/dist/grid/DataGrid.js +47 -13
- package/dist/grid/DataGrid.logic.d.ts +16 -0
- package/dist/grid/DataGrid.logic.js +28 -0
- package/dist/grid/grid.css +128 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/labels/UiokLabels.d.ts +3 -0
- package/dist/labels/UiokLabels.js +3 -1
- package/dist/labels/index.d.ts +1 -0
- package/dist/labels/index.js +1 -0
- package/dist/labels/keys.js +2 -0
- package/dist/labels/paneTabs.d.ts +27 -0
- package/dist/labels/paneTabs.js +10 -0
- package/dist/labels/selectAll.d.ts +4 -1
- package/dist/labels/selectAll.js +1 -1
- package/dist/legend/KeyLegendStrip.d.ts +9 -1
- package/dist/legend/KeyLegendStrip.js +119 -5
- package/dist/legend/legend.css +52 -0
- package/dist/listing/Listing.d.ts +23 -5
- package/dist/listing/Listing.js +11 -8
- package/dist/listing/listing.css +106 -3
- package/dist/pane/PaneActions.d.ts +3 -1
- package/dist/pane/PaneActions.js +6 -5
- package/dist/pane/PaneTabs.d.ts +92 -0
- package/dist/pane/PaneTabs.js +326 -0
- package/dist/pane/PaneTabs.logic.d.ts +97 -0
- package/dist/pane/PaneTabs.logic.js +158 -0
- package/dist/pane/index.d.ts +5 -1
- package/dist/pane/index.js +5 -1
- package/dist/pane/panetabs.css +408 -0
- package/dist/pane/useTabDrag.d.ts +49 -0
- package/dist/pane/useTabDrag.js +306 -0
- package/dist/segmented/SegmentedChoice.d.ts +8 -1
- package/dist/segmented/SegmentedChoice.js +7 -4
- package/dist/styles.css +8 -0
- package/dist/surface/GroupSwatch.d.ts +22 -0
- package/dist/surface/GroupSwatch.js +15 -0
- package/dist/surface/Tag.d.ts +26 -0
- package/dist/surface/Tag.js +12 -0
- package/dist/surface/index.d.ts +7 -0
- package/dist/surface/index.js +7 -0
- package/dist/surface/surface.css +116 -1
- package/dist/themes/tokens.js +12 -1
- package/package.json +1 -1
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { draggedTabOrder, gatherTabs } from './PaneTabs.logic.js';
|
|
3
|
+
/** How far the pointer travels before a press on a tab becomes a drag, in pixels. */
|
|
4
|
+
export const DRAG_SLOP = 4;
|
|
5
|
+
/** Parses a duration token's computed value ("120ms", "0.12s") to milliseconds. */
|
|
6
|
+
const durationMs = (value) => {
|
|
7
|
+
const text = value.trim();
|
|
8
|
+
const amount = parseFloat(text);
|
|
9
|
+
return Number.isFinite(amount) ? (text.endsWith('ms') ? amount : amount * 1000) : 0;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Slides a tab from an offset back to where the layout now has it, over the
|
|
13
|
+
* fast duration token with its easing, so reduced motion (which zeroes the
|
|
14
|
+
* token) makes it a jump.
|
|
15
|
+
*/
|
|
16
|
+
function slideHome(tab, from) {
|
|
17
|
+
if (from === '' || from === 'none') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const style = getComputedStyle(tab);
|
|
21
|
+
const duration = durationMs(style.getPropertyValue('--duration-fast'));
|
|
22
|
+
if (duration <= 0) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// Optional: jsdom has no Web Animations.
|
|
26
|
+
tab.animate?.([{ transform: from }, { transform: 'none' }], {
|
|
27
|
+
duration,
|
|
28
|
+
easing: style.getPropertyValue('--ease-out').trim() || 'ease-out'
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Dragging a strip's tabs to reorder them. The held tab follows the pointer
|
|
33
|
+
* along the strip, lifted over its neighbours, and the strip reorders under
|
|
34
|
+
* it: a neighbour steps aside once the held tab covers half of it
|
|
35
|
+
* (`draggedTabOrder`). An unpinned tab stops at the pin rule and a pinned
|
|
36
|
+
* one moves only among the pinned; the hand never goes past the last tab on
|
|
37
|
+
* show, so nothing drops among the folded tabs. Picked tabs close up round
|
|
38
|
+
* the held one as the drag starts (`gatherTabs`) and ride as one block.
|
|
39
|
+
*
|
|
40
|
+
* Escape (or the window losing the focus, or a cancelled pointer) puts
|
|
41
|
+
* every tab back; the Escape is the drag's alone, taken on the window's
|
|
42
|
+
* capture ahead of every other handler, with its repeats until it comes up. Release hands the new order
|
|
43
|
+
* to the strip's `commit` when it changed. The window follows the pointer,
|
|
44
|
+
* since a reordered tab moves in the document and would drop a capture.
|
|
45
|
+
*/
|
|
46
|
+
export function useTabDrag() {
|
|
47
|
+
const [draggingIds, setDraggingIds] = useState([]);
|
|
48
|
+
const [liveOrder, setLiveOrder] = useState(null);
|
|
49
|
+
const stopRef = useRef(null);
|
|
50
|
+
// A drag in flight when the strip goes away must not leave the window listening.
|
|
51
|
+
useEffect(() => () => stopRef.current?.(), []);
|
|
52
|
+
const drag = useMemo(() => {
|
|
53
|
+
const tabs = new Map();
|
|
54
|
+
const refs = new Map();
|
|
55
|
+
const lastLefts = new Map();
|
|
56
|
+
// Where each tab was drawn as a drag was cancelled, which it slides back from.
|
|
57
|
+
const returning = new Map();
|
|
58
|
+
let handle = null;
|
|
59
|
+
let held = null;
|
|
60
|
+
const segmentOf = (order, id) => {
|
|
61
|
+
const pinned = handle?.pinned.has(id) ?? false;
|
|
62
|
+
return order.filter((other) => (handle?.pinned.has(other) ?? false) === pinned);
|
|
63
|
+
};
|
|
64
|
+
// The hand's tabs on show, in strip order, each with how far into the block it rides.
|
|
65
|
+
const blockOf = (at) => {
|
|
66
|
+
const order = handle?.order ?? at.ids;
|
|
67
|
+
const shown = order.flatMap((id) => {
|
|
68
|
+
const tab = at.ids.includes(id) ? tabs.get(id) : undefined;
|
|
69
|
+
return tab ? [{ id, tab }] : [];
|
|
70
|
+
});
|
|
71
|
+
const gap = parseFloat(getComputedStyle(handle?.strip ?? document.body).columnGap) || 0;
|
|
72
|
+
let width = 0;
|
|
73
|
+
const members = shown.map((member) => {
|
|
74
|
+
const into = width;
|
|
75
|
+
width += member.tab.offsetWidth + gap;
|
|
76
|
+
return { ...member, into };
|
|
77
|
+
});
|
|
78
|
+
return { members, width: Math.max(0, width - gap) };
|
|
79
|
+
};
|
|
80
|
+
// Where the block's near edge is: the pressed tab under the pointer where
|
|
81
|
+
// it was grabbed, but never outside its segment's tabs on show.
|
|
82
|
+
const heldLeft = (at) => {
|
|
83
|
+
const pressed = tabs.get(at.id);
|
|
84
|
+
const origin = pressed?.offsetParent?.getBoundingClientRect().left;
|
|
85
|
+
if (!handle || !pressed || origin === undefined) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const block = blockOf(at);
|
|
89
|
+
const into = block.members.find((member) => member.id === at.id)?.into ?? 0;
|
|
90
|
+
const shown = segmentOf(handle.order, at.id).flatMap((id) => {
|
|
91
|
+
const tab = tabs.get(id);
|
|
92
|
+
return tab ? [tab] : [];
|
|
93
|
+
});
|
|
94
|
+
const start = Math.min(...shown.map((tab) => tab.offsetLeft));
|
|
95
|
+
const end = Math.max(...shown.map((tab) => tab.offsetLeft + tab.offsetWidth)) - block.width;
|
|
96
|
+
return Math.max(start, Math.min(at.x - at.grab - origin - into, end));
|
|
97
|
+
};
|
|
98
|
+
const follow = () => {
|
|
99
|
+
const left = held?.moved ? heldLeft(held) : null;
|
|
100
|
+
if (held && left !== null) {
|
|
101
|
+
for (const { tab, into } of blockOf(held).members) {
|
|
102
|
+
tab.style.transform = `translateX(${left + into - tab.offsetLeft}px)`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
// A tab let go of slides from where the hand had it to its place.
|
|
107
|
+
const settle = (id) => {
|
|
108
|
+
const tab = tabs.get(id);
|
|
109
|
+
if (tab) {
|
|
110
|
+
const from = tab.style.transform;
|
|
111
|
+
tab.style.transform = '';
|
|
112
|
+
slideHome(tab, from);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const move = (event) => {
|
|
116
|
+
if (!held || !handle) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
held.direction = Math.sign(event.clientX - held.x) || held.direction;
|
|
120
|
+
held.x = event.clientX;
|
|
121
|
+
if (!held.moved) {
|
|
122
|
+
if (Math.abs(held.x - held.startX) < DRAG_SLOP) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
held.moved = true;
|
|
126
|
+
held.startOrder = handle.order;
|
|
127
|
+
window.addEventListener('keydown', escape, true);
|
|
128
|
+
setDraggingIds(held.ids);
|
|
129
|
+
// Picked tabs close up round the pressed one as the drag lifts them;
|
|
130
|
+
// the strip lays them out together before the block moves.
|
|
131
|
+
const gathered = gatherTabs(handle.order, held.ids, held.id);
|
|
132
|
+
if (gathered.some((id, index) => id !== handle?.order[index])) {
|
|
133
|
+
setLiveOrder(gathered);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
follow();
|
|
138
|
+
const left = heldLeft(held);
|
|
139
|
+
if (left === null) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const { id, ids, direction } = held;
|
|
143
|
+
const order = handle.order;
|
|
144
|
+
const segment = segmentOf(order, id);
|
|
145
|
+
const block = segment.filter((other) => ids.includes(other));
|
|
146
|
+
const moved = draggedTabOrder(segment.filter((other) => other === id || !ids.includes(other)), { id, left, width: blockOf(held).width }, segment.flatMap((other) => {
|
|
147
|
+
const tab = ids.includes(other) ? undefined : tabs.get(other);
|
|
148
|
+
return tab ? [{ id: other, left: tab.offsetLeft, width: tab.offsetWidth }] : [];
|
|
149
|
+
}), direction).flatMap((other) => (other === id ? block : [other]));
|
|
150
|
+
const others = order.filter((other) => !segment.includes(other));
|
|
151
|
+
const next = handle.pinned.has(id) ? [...moved, ...others] : [...others, ...moved];
|
|
152
|
+
if (next.some((other, index) => other !== order[index])) {
|
|
153
|
+
setLiveOrder(next);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const stop = () => {
|
|
157
|
+
window.removeEventListener('pointermove', move);
|
|
158
|
+
window.removeEventListener('pointerup', end);
|
|
159
|
+
window.removeEventListener('pointercancel', cancel);
|
|
160
|
+
window.removeEventListener('keydown', escape, true);
|
|
161
|
+
window.removeEventListener('blur', cancel);
|
|
162
|
+
stopRef.current = null;
|
|
163
|
+
};
|
|
164
|
+
// Ends the drag with every tab back where it began, and a press that was
|
|
165
|
+
// not yet a drag without its click.
|
|
166
|
+
function cancel() {
|
|
167
|
+
const dropped = held;
|
|
168
|
+
held = null;
|
|
169
|
+
stop();
|
|
170
|
+
if (dropped === null || !dropped.moved) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
for (const [id, tab] of tabs) {
|
|
174
|
+
returning.set(id, tab.getBoundingClientRect().left);
|
|
175
|
+
tab.style.transform = '';
|
|
176
|
+
}
|
|
177
|
+
setDraggingIds([]);
|
|
178
|
+
setLiveOrder(null);
|
|
179
|
+
}
|
|
180
|
+
function escape(event) {
|
|
181
|
+
if (event.key === 'Escape' && held?.moved) {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
event.stopImmediatePropagation();
|
|
184
|
+
cancel();
|
|
185
|
+
window.addEventListener('keydown', swallowEscape, true);
|
|
186
|
+
window.addEventListener('keyup', releaseEscape, true);
|
|
187
|
+
window.addEventListener('blur', releaseEscape);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// The Escape that cancelled, still held: its repeats are the cancel's too.
|
|
191
|
+
function swallowEscape(event) {
|
|
192
|
+
if (event.key === 'Escape') {
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
event.stopImmediatePropagation();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function releaseEscape(event) {
|
|
198
|
+
if (event instanceof KeyboardEvent && event.key !== 'Escape') {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
window.removeEventListener('keydown', swallowEscape, true);
|
|
202
|
+
window.removeEventListener('keyup', releaseEscape, true);
|
|
203
|
+
window.removeEventListener('blur', releaseEscape);
|
|
204
|
+
}
|
|
205
|
+
function end() {
|
|
206
|
+
const dropped = held;
|
|
207
|
+
held = null;
|
|
208
|
+
stop();
|
|
209
|
+
if (dropped === null) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (!dropped.moved) {
|
|
213
|
+
dropped.onClick?.();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
dropped.ids.forEach(settle);
|
|
217
|
+
setDraggingIds([]);
|
|
218
|
+
const order = handle?.order ?? dropped.startOrder;
|
|
219
|
+
if (order.some((id, index) => id !== dropped.startOrder[index])) {
|
|
220
|
+
handle?.commit(order);
|
|
221
|
+
}
|
|
222
|
+
setLiveOrder(null);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
begin: (id, tab, clientX, carried) => {
|
|
226
|
+
stopRef.current?.();
|
|
227
|
+
const pinned = handle?.pinned.has(id) ?? false;
|
|
228
|
+
const ids = carried?.ids.includes(id)
|
|
229
|
+
? carried.ids.filter((other) => (handle?.pinned.has(other) ?? false) === pinned)
|
|
230
|
+
: [id];
|
|
231
|
+
for (const [other, element] of tabs) {
|
|
232
|
+
lastLefts.set(other, element.offsetLeft);
|
|
233
|
+
}
|
|
234
|
+
held = {
|
|
235
|
+
id,
|
|
236
|
+
ids,
|
|
237
|
+
onClick: carried?.onClick ?? null,
|
|
238
|
+
startX: clientX,
|
|
239
|
+
grab: clientX - tab.getBoundingClientRect().left,
|
|
240
|
+
x: clientX,
|
|
241
|
+
direction: 0,
|
|
242
|
+
moved: false,
|
|
243
|
+
startOrder: handle?.order ?? []
|
|
244
|
+
};
|
|
245
|
+
returning.clear();
|
|
246
|
+
stopRef.current = stop;
|
|
247
|
+
window.addEventListener('pointermove', move);
|
|
248
|
+
window.addEventListener('pointerup', end);
|
|
249
|
+
window.addEventListener('pointercancel', cancel);
|
|
250
|
+
window.addEventListener('blur', cancel);
|
|
251
|
+
},
|
|
252
|
+
tabRef: (id) => {
|
|
253
|
+
let ref = refs.get(id);
|
|
254
|
+
if (ref === undefined) {
|
|
255
|
+
ref = (element) => {
|
|
256
|
+
if (element === null) {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
tabs.set(id, element);
|
|
260
|
+
return () => {
|
|
261
|
+
if (tabs.get(id) === element) {
|
|
262
|
+
tabs.delete(id);
|
|
263
|
+
lastLefts.delete(id);
|
|
264
|
+
returning.delete(id);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
refs.set(id, ref);
|
|
269
|
+
}
|
|
270
|
+
return ref;
|
|
271
|
+
},
|
|
272
|
+
afterLayout: (next) => {
|
|
273
|
+
handle = next;
|
|
274
|
+
for (const id of refs.keys()) {
|
|
275
|
+
if (!next.order.includes(id)) {
|
|
276
|
+
refs.delete(id);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const dragged = held?.moved ? held.ids : null;
|
|
280
|
+
for (const [id, tab] of tabs) {
|
|
281
|
+
const left = tab.offsetLeft;
|
|
282
|
+
const before = lastLefts.get(id);
|
|
283
|
+
const from = returning.get(id);
|
|
284
|
+
// A tab a cancel put back slides from where it was drawn.
|
|
285
|
+
if (from !== undefined) {
|
|
286
|
+
const at = tab.getBoundingClientRect().left;
|
|
287
|
+
returning.delete(id);
|
|
288
|
+
if (Math.abs(from - at) > 0.5) {
|
|
289
|
+
slideHome(tab, `translateX(${from - at}px)`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
// A neighbour the drag displaced slides to its new place instead of jumping.
|
|
293
|
+
if (dragged !== null &&
|
|
294
|
+
!dragged.includes(id) &&
|
|
295
|
+
before !== undefined &&
|
|
296
|
+
before !== left) {
|
|
297
|
+
slideHome(tab, `translateX(${before - left}px)`);
|
|
298
|
+
}
|
|
299
|
+
lastLefts.set(id, left);
|
|
300
|
+
}
|
|
301
|
+
follow();
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}, []);
|
|
305
|
+
return useMemo(() => ({ draggingIds, liveOrder, ...drag }), [draggingIds, liveOrder, drag]);
|
|
306
|
+
}
|
|
@@ -17,6 +17,13 @@ export interface SegmentedChoiceProps<T extends string | number | null> {
|
|
|
17
17
|
* None unless given; the chosen one should not be among them.
|
|
18
18
|
*/
|
|
19
19
|
readonly disabledChoices?: readonly T[];
|
|
20
|
+
/**
|
|
21
|
+
* Holds the whole choice while it cannot change (a change it started is
|
|
22
|
+
* running): every segment is disabled and the chosen one stays drawn as
|
|
23
|
+
* chosen, so the control still says what is set. Neither a click nor the
|
|
24
|
+
* arrow keys change it.
|
|
25
|
+
*/
|
|
26
|
+
readonly disabled?: boolean;
|
|
20
27
|
/**
|
|
21
28
|
* What the choice does, as the group's accessible description: the
|
|
22
29
|
* `control` half of `labelHelp(help)` spread on the group, whose `label`
|
|
@@ -35,4 +42,4 @@ export interface SegmentedChoiceProps<T extends string | number | null> {
|
|
|
35
42
|
* its own (`.segmented-choice` in `@bigpixelrocket/uiok/styles.css`), so it draws the same
|
|
36
43
|
* in a dialog and on a page.
|
|
37
44
|
*/
|
|
38
|
-
export declare function SegmentedChoice<T extends string | number | null>({ labelId, choices, value, onChange, render, disabledChoices, 'aria-description': description }: SegmentedChoiceProps<T>): ReactElement;
|
|
45
|
+
export declare function SegmentedChoice<T extends string | number | null>({ labelId, choices, value, onChange, render, disabledChoices, disabled, 'aria-description': description }: SegmentedChoiceProps<T>): ReactElement;
|
|
@@ -10,10 +10,13 @@ import { useRef } from 'react';
|
|
|
10
10
|
* its own (`.segmented-choice` in `@bigpixelrocket/uiok/styles.css`), so it draws the same
|
|
11
11
|
* in a dialog and on a page.
|
|
12
12
|
*/
|
|
13
|
-
export function SegmentedChoice({ labelId, choices, value, onChange, render, disabledChoices = [], 'aria-description': description }) {
|
|
13
|
+
export function SegmentedChoice({ labelId, choices, value, onChange, render, disabledChoices = [], disabled = false, 'aria-description': description }) {
|
|
14
14
|
const group = useRef(null);
|
|
15
15
|
const step = (event, delta) => {
|
|
16
16
|
event.preventDefault();
|
|
17
|
+
if (disabled) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
17
20
|
const from = choices.indexOf(value);
|
|
18
21
|
// The next choice that can be chosen, at most one lap round.
|
|
19
22
|
for (let moved = 1; moved < choices.length; moved += 1) {
|
|
@@ -26,16 +29,16 @@ export function SegmentedChoice({ labelId, choices, value, onChange, render, dis
|
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
};
|
|
29
|
-
return (_jsx("div", { "aria-description": description, "aria-labelledby": labelId, className: "segmented-choice", onKeyDown: (event) => {
|
|
32
|
+
return (_jsx("div", { "aria-description": description, "aria-disabled": disabled || undefined, "aria-labelledby": labelId, className: "segmented-choice", onKeyDown: (event) => {
|
|
30
33
|
if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {
|
|
31
34
|
step(event, 1);
|
|
32
35
|
}
|
|
33
36
|
else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {
|
|
34
37
|
step(event, -1);
|
|
35
38
|
}
|
|
36
|
-
}, ref: group, role: "radiogroup", children: choices.map((choice) => (_jsx("button", { "aria-checked": choice === value, className: "segmented-choice-option", disabled: disabledChoices.includes(choice), onClick: () => {
|
|
39
|
+
}, ref: group, role: "radiogroup", children: choices.map((choice) => (_jsx("button", { "aria-checked": choice === value, className: "segmented-choice-option", disabled: disabled || disabledChoices.includes(choice), onClick: () => {
|
|
37
40
|
// The chosen segment again changes nothing, so it reads nothing.
|
|
38
|
-
if (choice !== value) {
|
|
41
|
+
if (choice !== value && !disabled) {
|
|
39
42
|
onChange(choice);
|
|
40
43
|
}
|
|
41
44
|
}, role: "radio", tabIndex: choice === value ? 0 : -1, type: "button", children: render(choice) }, String(choice)))) }));
|
package/dist/styles.css
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
@import './palette/palette.css';
|
|
29
29
|
@import './charts/charts.css';
|
|
30
30
|
@import './terminal/terminal.css';
|
|
31
|
+
@import './pane/panetabs.css';
|
|
31
32
|
|
|
32
33
|
/* Shared looks a page puts on its own markup: form controls, notices, cards. */
|
|
33
34
|
@import './field/field.css';
|
|
@@ -200,6 +201,13 @@ meter::-webkit-meter-even-less-good-value {
|
|
|
200
201
|
text-transform: uppercase;
|
|
201
202
|
}
|
|
202
203
|
|
|
204
|
+
/* An overline over a group named by a name of its own (a schema, a host)
|
|
205
|
+
keeps that name's case, and the tracking that only capitals need. */
|
|
206
|
+
.overline.keep-case {
|
|
207
|
+
letter-spacing: normal;
|
|
208
|
+
text-transform: none;
|
|
209
|
+
}
|
|
210
|
+
|
|
203
211
|
/* A translucent layer over content that scrolls under it: the one frost
|
|
204
212
|
recipe (--frost), with the layer's own translucent fill. */
|
|
205
213
|
.frost {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { GroupHue } from '../themes/catalog.js';
|
|
3
|
+
/** Props for {@link GroupSwatch}. */
|
|
4
|
+
export interface GroupSwatchProps {
|
|
5
|
+
/** The group's hue, or null for no group, drawn faint. */
|
|
6
|
+
readonly group: GroupHue | null;
|
|
7
|
+
/** Its outline alone: a group that is closed or off. */
|
|
8
|
+
readonly hollow?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The group's name, given when nothing beside the swatch says it: the
|
|
11
|
+
* swatch becomes an image with that name and tooltip. Omitted, the swatch
|
|
12
|
+
* is hidden from assistive technology, since the name beside it says it.
|
|
13
|
+
*/
|
|
14
|
+
readonly label?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A group's colour beside its name: an 8px square (`--space-4`,
|
|
18
|
+
* `--radius-xs`) in the theme's `--group-<hue>`, filled, or outlined when
|
|
19
|
+
* `hollow`. A square, because a round dot is a state mark and a group's
|
|
20
|
+
* colour is a category, never a status. Draws `.group-swatch[data-group]`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function GroupSwatch({ group, hollow, label }: GroupSwatchProps): ReactElement;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
3
|
+
/**
|
|
4
|
+
* A group's colour beside its name: an 8px square (`--space-4`,
|
|
5
|
+
* `--radius-xs`) in the theme's `--group-<hue>`, filled, or outlined when
|
|
6
|
+
* `hollow`. A square, because a round dot is a state mark and a group's
|
|
7
|
+
* colour is a category, never a status. Draws `.group-swatch[data-group]`.
|
|
8
|
+
*/
|
|
9
|
+
export function GroupSwatch({ group, hollow = false, label }) {
|
|
10
|
+
const className = hollow ? 'group-swatch hollow' : 'group-swatch';
|
|
11
|
+
const naming = label
|
|
12
|
+
? { 'aria-label': label, role: 'img', ...tooltip(label) }
|
|
13
|
+
: { 'aria-hidden': true };
|
|
14
|
+
return _jsx("span", { className: className, "data-group": group ?? undefined, ...naming });
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A tag's tone: `neutral` a plain fact, `accent` a mark of note, `ready` a
|
|
4
|
+
* place that is safe or working, `warning` one that needs a second look, and
|
|
5
|
+
* `danger` one where a mistake costs most.
|
|
6
|
+
*/
|
|
7
|
+
export type TagTone = 'neutral' | 'accent' | 'ready' | 'warning' | 'danger';
|
|
8
|
+
/** Props for {@link Tag}. */
|
|
9
|
+
export interface TagProps {
|
|
10
|
+
/** The tag's words ("Production", "Template", "default"). */
|
|
11
|
+
readonly children: string;
|
|
12
|
+
/** The tone; `neutral` by default. */
|
|
13
|
+
readonly tone?: TagTone;
|
|
14
|
+
/** Sets the words in small capitals, as a release channel's tag. */
|
|
15
|
+
readonly caps?: boolean;
|
|
16
|
+
/** More than the words say, as a tooltip and the tag's accessible description. */
|
|
17
|
+
readonly tip?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A small worded tag beside a name: an environment, a kind ("Template",
|
|
21
|
+
* "System"), a default, a pending state. A pill washed in its tone with the
|
|
22
|
+
* words in the tone's text colour, legible on a cursor or marked row too.
|
|
23
|
+
* Draws `.tag[data-tone]` (`.caps`); the words keep their case unless
|
|
24
|
+
* `caps`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Tag({ children, tone, caps, tip }: TagProps): ReactElement;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describedTooltip } from '../tooltip/Tooltip.logic.js';
|
|
3
|
+
/**
|
|
4
|
+
* A small worded tag beside a name: an environment, a kind ("Template",
|
|
5
|
+
* "System"), a default, a pending state. A pill washed in its tone with the
|
|
6
|
+
* words in the tone's text colour, legible on a cursor or marked row too.
|
|
7
|
+
* Draws `.tag[data-tone]` (`.caps`); the words keep their case unless
|
|
8
|
+
* `caps`.
|
|
9
|
+
*/
|
|
10
|
+
export function Tag({ children, tone = 'neutral', caps = false, tip }) {
|
|
11
|
+
return (_jsx("span", { className: caps ? 'tag caps' : 'tag', "data-tone": tone, ...describedTooltip(tip), children: children }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surfaces: `GroupSwatch`, a group's colour beside its name, and `Tag`, a
|
|
3
|
+
* small worded tag in a tone. The notice and card looks of this area are
|
|
4
|
+
* classes in `@bigpixelrocket/uiok/styles.css`, with no module.
|
|
5
|
+
*/
|
|
6
|
+
export { GroupSwatch, type GroupSwatchProps } from './GroupSwatch.js';
|
|
7
|
+
export { Tag, type TagProps, type TagTone } from './Tag.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surfaces: `GroupSwatch`, a group's colour beside its name, and `Tag`, a
|
|
3
|
+
* small worded tag in a tone. The notice and card looks of this area are
|
|
4
|
+
* classes in `@bigpixelrocket/uiok/styles.css`, with no module.
|
|
5
|
+
*/
|
|
6
|
+
export { GroupSwatch } from './GroupSwatch.js';
|
|
7
|
+
export { Tag } from './Tag.js';
|
package/dist/surface/surface.css
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
- .card: a lifted panel that groups one subject's lines, framed in
|
|
14
14
|
--border-strong like every framed surface (panes, menus, the grid),
|
|
15
15
|
at the 12px surface inset at both ends, whatever its children's
|
|
16
|
-
margins.
|
|
16
|
+
margins.
|
|
17
|
+
- .group-swatch (GroupSwatch): a group's colour beside its name.
|
|
18
|
+
- .tag (Tag): a small worded tag in a tone beside a name. */
|
|
17
19
|
|
|
18
20
|
.notice {
|
|
19
21
|
/* The tone's glyph, 3:1 on every ground by its token. */
|
|
@@ -69,6 +71,14 @@
|
|
|
69
71
|
overflow-wrap: anywhere;
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
/* A server's or a system's own words inside a message (an error code, a
|
|
75
|
+
statement, a host) take the code face at the notice's size, so they
|
|
76
|
+
read as quoted, never as larger or smaller than the words round them. */
|
|
77
|
+
.notice code {
|
|
78
|
+
font-family: var(--font-mono);
|
|
79
|
+
font-size: inherit;
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
/* A message's words are content: a path or a server's reply in them is
|
|
73
83
|
what a user pastes into a report, so they can be swept and copied. */
|
|
74
84
|
.notice-text {
|
|
@@ -152,3 +162,108 @@
|
|
|
152
162
|
.card > :last-child {
|
|
153
163
|
margin-block-end: 0;
|
|
154
164
|
}
|
|
165
|
+
|
|
166
|
+
/* ---- Group swatch and tag (GroupSwatch, Tag) ---- */
|
|
167
|
+
|
|
168
|
+
/* A group's colour beside its name: the mark docs/tokens.md sizes (8px,
|
|
169
|
+
a 2px corner) in a categorical hue (--group-*), square because a round
|
|
170
|
+
dot is a state mark and a colour is not a state. With no group it is
|
|
171
|
+
faint; hollow is the same group while it is closed or off: its outline
|
|
172
|
+
alone, inside the same box. */
|
|
173
|
+
.group-swatch {
|
|
174
|
+
flex: none;
|
|
175
|
+
display: inline-block;
|
|
176
|
+
width: var(--space-4);
|
|
177
|
+
height: var(--space-4);
|
|
178
|
+
border-radius: var(--radius-xs);
|
|
179
|
+
background: var(--group-swatch-hue, var(--text-faint));
|
|
180
|
+
box-shadow: var(--group-dot-ring);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.group-swatch.hollow {
|
|
184
|
+
background: transparent;
|
|
185
|
+
box-shadow: inset 0 0 0 var(--line-strong) var(--group-swatch-hue, var(--text-faint));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.group-swatch[data-group='blue'] {
|
|
189
|
+
--group-swatch-hue: var(--group-blue);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.group-swatch[data-group='green'] {
|
|
193
|
+
--group-swatch-hue: var(--group-green);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.group-swatch[data-group='purple'] {
|
|
197
|
+
--group-swatch-hue: var(--group-purple);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.group-swatch[data-group='orange'] {
|
|
201
|
+
--group-swatch-hue: var(--group-orange);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.group-swatch[data-group='teal'] {
|
|
205
|
+
--group-swatch-hue: var(--group-teal);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.group-swatch[data-group='pink'] {
|
|
209
|
+
--group-swatch-hue: var(--group-pink);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.group-swatch[data-group='yellow'] {
|
|
213
|
+
--group-swatch-hue: var(--group-yellow);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.group-swatch[data-group='red'] {
|
|
217
|
+
--group-swatch-hue: var(--group-red);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* A small worded tag beside a name (an environment, a kind, a default): a
|
|
221
|
+
pill washed in its tone, the words in the tone's text role, which keeps
|
|
222
|
+
4.5:1 on its own wash and on every state ground, so a tag stays legible
|
|
223
|
+
on the cursor row and a marked row. The words keep their case; .caps
|
|
224
|
+
sets them as a release channel's tag. */
|
|
225
|
+
.tag {
|
|
226
|
+
--tag-wash: var(--fill);
|
|
227
|
+
--tag-text: var(--text-on-surface);
|
|
228
|
+
|
|
229
|
+
display: inline-flex;
|
|
230
|
+
flex: none;
|
|
231
|
+
align-items: center;
|
|
232
|
+
box-sizing: border-box;
|
|
233
|
+
max-width: 100%;
|
|
234
|
+
padding: 1px var(--space-3);
|
|
235
|
+
overflow: hidden;
|
|
236
|
+
border-radius: var(--radius-pill);
|
|
237
|
+
background: var(--tag-wash);
|
|
238
|
+
color: var(--tag-text);
|
|
239
|
+
font: var(--font-weight-medium) var(--font-size-caption) / var(--line-height-compact)
|
|
240
|
+
var(--font-ui);
|
|
241
|
+
text-overflow: ellipsis;
|
|
242
|
+
white-space: nowrap;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.tag[data-tone='accent'] {
|
|
246
|
+
--tag-wash: var(--accent-wash);
|
|
247
|
+
--tag-text: var(--accent-text);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.tag[data-tone='ready'] {
|
|
251
|
+
--tag-wash: var(--success-wash);
|
|
252
|
+
--tag-text: var(--success-text);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.tag[data-tone='warning'] {
|
|
256
|
+
--tag-wash: var(--warning-wash);
|
|
257
|
+
--tag-text: var(--warning-text);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.tag[data-tone='danger'] {
|
|
261
|
+
--tag-wash: var(--danger-wash);
|
|
262
|
+
--tag-text: var(--danger-text);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.tag.caps {
|
|
266
|
+
font-weight: var(--font-weight-strong);
|
|
267
|
+
letter-spacing: var(--tracking-caps);
|
|
268
|
+
text-transform: uppercase;
|
|
269
|
+
}
|
package/dist/themes/tokens.js
CHANGED
|
@@ -1170,11 +1170,22 @@ const BASE_TOKEN_NAMES = [
|
|
|
1170
1170
|
'--row-selected-text-dim',
|
|
1171
1171
|
'--pane-edge-shift',
|
|
1172
1172
|
'--pane-pin-ring',
|
|
1173
|
+
'--pane-tab-height',
|
|
1174
|
+
'--pane-tab-back',
|
|
1175
|
+
'--pane-tab-floor',
|
|
1173
1176
|
'--update-note-rows',
|
|
1174
1177
|
'--pager-height',
|
|
1175
1178
|
'--menu-font-size',
|
|
1176
1179
|
'--channel-tag-bg',
|
|
1177
|
-
'--line-reference'
|
|
1180
|
+
'--line-reference',
|
|
1181
|
+
'--group-swatch-hue',
|
|
1182
|
+
'--tag-wash',
|
|
1183
|
+
'--tag-text',
|
|
1184
|
+
'--data-grid-row-tint',
|
|
1185
|
+
'--data-grid-bar',
|
|
1186
|
+
'--data-grid-ring',
|
|
1187
|
+
'--row-level',
|
|
1188
|
+
'--field-columns'
|
|
1178
1189
|
];
|
|
1179
1190
|
/** Every token name uiok defines: the fixed tokens, those a theme sets, and the stylesheet's own. */
|
|
1180
1191
|
const UIOK_TOKEN_NAMES = new Set([
|