@stealthscale/component-a11y 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -38
- package/dist/cyclonedx/bom.json +1 -1
- package/dist/index.d.ts +47 -38
- package/dist/index.js +239 -253
- package/dist/recipe-BM8WGKWH.js +127 -0
- package/dist/theme.d.ts +3 -4
- package/dist/theme.js +4 -5
- package/package.json +28 -25
- package/dist/recipe-BKojQp6r.js +0 -106
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { n as recipe$1, r as recipe, t as recipe$2 } from "./recipe-
|
|
2
|
+
import { n as recipe$1, r as recipe, t as recipe$2 } from "./recipe-BM8WGKWH.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { createContext, use, useEffect, useId, useRef, useState } from "react";
|
|
5
5
|
import { useCallbackRef, useControllableState } from "@stealthscale/hooks";
|
|
@@ -7,62 +7,62 @@ import { createRecipeContext, createSlotRecipeContext } from "@stealthscale/them
|
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region src/roving-focus/context.ts
|
|
9
9
|
/**
|
|
10
|
-
* Binds the
|
|
10
|
+
* Binds the roving-focus slot recipe to React.
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* its
|
|
13
|
+
* The binding is a separate module from the recipe, because the theme compiler imports the recipe
|
|
14
|
+
* at build time and must not load the React runtime. The root resolves the variants, and each
|
|
15
|
+
* item reads its slot class from the root's context.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Creates the roving-focus recipe's `withProvider` binding for the root and `withContext` for the
|
|
19
|
+
* items.
|
|
19
20
|
*/
|
|
20
21
|
const { withContext: withContext$1, withProvider: withProvider$1 } = createSlotRecipeContext(recipe);
|
|
21
22
|
//#endregion
|
|
22
23
|
//#region src/roving-focus/use-roving-focus.ts
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
-
* inside it with the arrows.
|
|
25
|
+
* Implements a roving tabindex: Tab enters the group once, and the arrow keys move focus inside it.
|
|
26
26
|
*
|
|
27
27
|
* @remarks
|
|
28
|
-
* A toolbar, a
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* sees.
|
|
28
|
+
* A toolbar, a tab list and a menu bar each take one stop in the page's tab order. Items register
|
|
29
|
+
* themselves, because the root cannot see through the components its children are composed
|
|
30
|
+
* from. Registration follows effect order, which differs from source order once an item renders
|
|
31
|
+
* conditionally, so the registry sorts by document position and the arrows follow the order on
|
|
32
|
+
* screen.
|
|
34
33
|
*/
|
|
35
34
|
/**
|
|
36
|
-
* Maps
|
|
35
|
+
* Maps each block-axis arrow key to its step.
|
|
37
36
|
*/
|
|
38
37
|
const DOWN_THE_PAGE = {
|
|
39
38
|
ArrowDown: 1,
|
|
40
39
|
ArrowUp: -1
|
|
41
40
|
};
|
|
42
41
|
/**
|
|
43
|
-
* Maps
|
|
42
|
+
* Maps each inline-axis arrow key to its step in a left-to-right group.
|
|
44
43
|
*/
|
|
45
44
|
const ALONG_THE_LINE = {
|
|
46
45
|
ArrowLeft: -1,
|
|
47
46
|
ArrowRight: 1
|
|
48
47
|
};
|
|
49
48
|
/**
|
|
50
|
-
*
|
|
49
|
+
* Context that a root publishes its group on and every item below it reads.
|
|
51
50
|
*/
|
|
52
51
|
const RovingFocusContext = createContext(void 0);
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
53
|
+
* Compares two registrations by document position, for sorting in on-screen order.
|
|
55
54
|
*/
|
|
56
55
|
function byDocumentPosition(first, second) {
|
|
57
56
|
return (first.element.compareDocumentPosition(second.element) & Node.DOCUMENT_POSITION_FOLLOWING) === 0 ? 1 : -1;
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
60
|
-
*
|
|
59
|
+
* Translates a key press into the movement it requests.
|
|
61
60
|
*
|
|
62
|
-
* @param key - The key
|
|
63
|
-
* @param orientation -
|
|
64
|
-
* @param forward -
|
|
65
|
-
*
|
|
61
|
+
* @param key - The `key` value of the keyboard event.
|
|
62
|
+
* @param orientation - The axes the group responds to.
|
|
63
|
+
* @param forward - 1 in a left-to-right group and -1 in a right-to-left one, applied to the
|
|
64
|
+
* inline arrows only.
|
|
65
|
+
* @returns The requested step or end, or undefined when the group does not handle the key.
|
|
66
66
|
*/
|
|
67
67
|
function intentOf(key, orientation, forward) {
|
|
68
68
|
if (key === "Home") return "start";
|
|
@@ -73,17 +73,17 @@ function intentOf(key, orientation, forward) {
|
|
|
73
73
|
if (inline !== void 0) return orientation === "vertical" ? void 0 : inline * forward;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* Returns the destination item as the bounds of a one-item slice of the registration list.
|
|
77
77
|
*
|
|
78
78
|
* @remarks
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* @param list - The
|
|
83
|
-
* @param intent - The
|
|
84
|
-
* @param from - The item
|
|
85
|
-
* @param wrap - Whether
|
|
86
|
-
* @returns The
|
|
79
|
+
* Slice bounds keep the caller free of a branch. An index is typed as possibly undefined even
|
|
80
|
+
* when it is in range, and slicing an empty list returns an empty list, so a group with no items
|
|
81
|
+
* needs no special case.
|
|
82
|
+
* @param list - The registrations in document order.
|
|
83
|
+
* @param intent - The step or end the key requested.
|
|
84
|
+
* @param from - The identifier of the item with the tab stop.
|
|
85
|
+
* @param wrap - Whether a step past one end continues at the other.
|
|
86
|
+
* @returns The start and end bounds of a slice that contains the destination item.
|
|
87
87
|
*/
|
|
88
88
|
function spanOf(list, intent, from, wrap) {
|
|
89
89
|
const last = list.length - 1;
|
|
@@ -93,141 +93,129 @@ function spanOf(list, intent, from, wrap) {
|
|
|
93
93
|
return [to, to + 1];
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
96
|
+
* Creates a registry backed by a ref.
|
|
97
97
|
*
|
|
98
98
|
* @remarks
|
|
99
|
-
*
|
|
100
|
-
*
|
|
99
|
+
* Rendering depends on the active identifier and not on the list, so a list in state would
|
|
100
|
+
* re-render the whole group each time an item mounted, with no visible change.
|
|
101
101
|
*/
|
|
102
102
|
function useRegistry() {
|
|
103
|
-
const $ = c(
|
|
104
|
-
if ($[0] !== "6879b11696c2d2a5e563183941bb99f80ab3ad4b04bbc8a7ef4c43a80f829e8d") {
|
|
105
|
-
for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
106
|
-
$[0] = "6879b11696c2d2a5e563183941bb99f80ab3ad4b04bbc8a7ef4c43a80f829e8d";
|
|
107
|
-
}
|
|
103
|
+
const $ = c(5);
|
|
108
104
|
let t0;
|
|
109
|
-
if ($[
|
|
105
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
110
106
|
t0 = [];
|
|
111
|
-
$[
|
|
112
|
-
} else t0 = $[
|
|
107
|
+
$[0] = t0;
|
|
108
|
+
} else t0 = $[0];
|
|
113
109
|
const items = useRef(t0);
|
|
114
110
|
let t1;
|
|
115
|
-
if ($[
|
|
111
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
116
112
|
t1 = (registration) => {
|
|
117
113
|
items.current = [...items.current, registration];
|
|
118
114
|
};
|
|
119
|
-
$[
|
|
120
|
-
} else t1 = $[
|
|
115
|
+
$[1] = t1;
|
|
116
|
+
} else t1 = $[1];
|
|
121
117
|
const add = t1;
|
|
122
118
|
let t2;
|
|
123
|
-
if ($[
|
|
119
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
124
120
|
t2 = (node) => items.current.some((item) => item.element.contains(node));
|
|
125
|
-
$[
|
|
126
|
-
} else t2 = $[
|
|
127
|
-
const
|
|
121
|
+
$[2] = t2;
|
|
122
|
+
} else t2 = $[2];
|
|
123
|
+
const contains = t2;
|
|
128
124
|
let t3;
|
|
129
|
-
if ($[
|
|
125
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
130
126
|
t3 = () => items.current.toSorted(byDocumentPosition);
|
|
131
|
-
$[
|
|
132
|
-
} else t3 = $[
|
|
127
|
+
$[3] = t3;
|
|
128
|
+
} else t3 = $[3];
|
|
133
129
|
const ordered = t3;
|
|
134
130
|
let t4;
|
|
135
|
-
if ($[
|
|
131
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
136
132
|
const remove = (id) => {
|
|
137
133
|
items.current = items.current.filter((item_0) => item_0.id !== id);
|
|
138
134
|
};
|
|
139
135
|
t4 = {
|
|
140
136
|
add,
|
|
141
|
-
|
|
137
|
+
contains,
|
|
142
138
|
ordered,
|
|
143
139
|
remove
|
|
144
140
|
};
|
|
145
|
-
$[
|
|
146
|
-
} else t4 = $[
|
|
141
|
+
$[4] = t4;
|
|
142
|
+
} else t4 = $[4];
|
|
147
143
|
return t4;
|
|
148
144
|
}
|
|
149
145
|
/**
|
|
150
|
-
*
|
|
146
|
+
* Tracks which item has the tab stop, and defers to the caller when the group is controlled.
|
|
151
147
|
*/
|
|
152
148
|
function useTabStop(props) {
|
|
153
|
-
const $ = c(
|
|
154
|
-
if ($[0] !== "6879b11696c2d2a5e563183941bb99f80ab3ad4b04bbc8a7ef4c43a80f829e8d") {
|
|
155
|
-
for (let $i = 0; $i < 13; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
156
|
-
$[0] = "6879b11696c2d2a5e563183941bb99f80ab3ad4b04bbc8a7ef4c43a80f829e8d";
|
|
157
|
-
}
|
|
149
|
+
const $ = c(12);
|
|
158
150
|
const { activeId: driven, defaultActiveId, onActiveIdChange } = props;
|
|
159
151
|
let t0;
|
|
160
|
-
if ($[
|
|
152
|
+
if ($[0] !== defaultActiveId || $[1] !== driven || $[2] !== onActiveIdChange) {
|
|
161
153
|
t0 = {
|
|
162
154
|
defaultValue: defaultActiveId,
|
|
163
155
|
onChange: onActiveIdChange,
|
|
164
156
|
value: driven
|
|
165
157
|
};
|
|
166
|
-
$[
|
|
167
|
-
$[
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
} else t0 = $[
|
|
158
|
+
$[0] = defaultActiveId;
|
|
159
|
+
$[1] = driven;
|
|
160
|
+
$[2] = onActiveIdChange;
|
|
161
|
+
$[3] = t0;
|
|
162
|
+
} else t0 = $[3];
|
|
171
163
|
const [activeId, setActiveId] = useControllableState(t0);
|
|
172
164
|
const stop = useRef(activeId);
|
|
173
165
|
let t1;
|
|
174
166
|
let t2;
|
|
175
|
-
if ($[
|
|
167
|
+
if ($[4] !== activeId) {
|
|
176
168
|
t1 = () => {
|
|
177
169
|
stop.current = activeId;
|
|
178
170
|
};
|
|
179
171
|
t2 = [activeId];
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
172
|
+
$[4] = activeId;
|
|
173
|
+
$[5] = t1;
|
|
174
|
+
$[6] = t2;
|
|
183
175
|
} else {
|
|
184
|
-
t1 = $[
|
|
185
|
-
t2 = $[
|
|
176
|
+
t1 = $[5];
|
|
177
|
+
t2 = $[6];
|
|
186
178
|
}
|
|
187
179
|
useEffect(t1, t2);
|
|
188
180
|
let t3;
|
|
189
|
-
if ($[
|
|
181
|
+
if ($[7] !== setActiveId) {
|
|
190
182
|
t3 = (next) => {
|
|
191
183
|
stop.current = next;
|
|
192
184
|
setActiveId(next);
|
|
193
185
|
};
|
|
194
|
-
$[
|
|
195
|
-
$[
|
|
196
|
-
} else t3 = $[
|
|
186
|
+
$[7] = setActiveId;
|
|
187
|
+
$[8] = t3;
|
|
188
|
+
} else t3 = $[8];
|
|
197
189
|
const claim = useCallbackRef(t3);
|
|
198
190
|
let t4;
|
|
199
|
-
if ($[
|
|
191
|
+
if ($[9] !== activeId || $[10] !== claim) {
|
|
200
192
|
t4 = {
|
|
201
193
|
activeId,
|
|
202
194
|
claim,
|
|
203
195
|
stop
|
|
204
196
|
};
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
} else t4 = $[
|
|
197
|
+
$[9] = activeId;
|
|
198
|
+
$[10] = claim;
|
|
199
|
+
$[11] = t4;
|
|
200
|
+
} else t4 = $[11];
|
|
209
201
|
return t4;
|
|
210
202
|
}
|
|
211
203
|
/**
|
|
212
|
-
* Moves one tab stop
|
|
204
|
+
* Moves one tab stop across the items that register with the group.
|
|
213
205
|
*
|
|
214
206
|
* @remarks
|
|
215
|
-
* The first item to register takes the stop, so
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* @returns The
|
|
207
|
+
* The first item to register takes the stop, so Tab reaches the group from its first render.
|
|
208
|
+
* When the item with the stop unmounts, the stop passes to the first remaining item in document
|
|
209
|
+
* order, so the group stays in the tab order.
|
|
210
|
+
* @returns The context value for the items and the key handler for the root.
|
|
219
211
|
*/
|
|
220
212
|
function useRovingFocus(props) {
|
|
221
|
-
const $ = c(
|
|
222
|
-
if ($[0] !== "6879b11696c2d2a5e563183941bb99f80ab3ad4b04bbc8a7ef4c43a80f829e8d") {
|
|
223
|
-
for (let $i = 0; $i < 23; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
224
|
-
$[0] = "6879b11696c2d2a5e563183941bb99f80ab3ad4b04bbc8a7ef4c43a80f829e8d";
|
|
225
|
-
}
|
|
213
|
+
const $ = c(22);
|
|
226
214
|
const { orientation, wrap } = props;
|
|
227
|
-
const { add,
|
|
215
|
+
const { add, contains, ordered, remove } = useRegistry();
|
|
228
216
|
const { activeId, claim, stop } = useTabStop(props);
|
|
229
217
|
let t0;
|
|
230
|
-
if ($[
|
|
218
|
+
if ($[0] !== add || $[1] !== claim || $[2] !== ordered || $[3] !== remove || $[4] !== stop.current) {
|
|
231
219
|
t0 = (registration) => {
|
|
232
220
|
add(registration);
|
|
233
221
|
if (stop.current === void 0) claim(registration.id);
|
|
@@ -236,20 +224,20 @@ function useRovingFocus(props) {
|
|
|
236
224
|
if (stop.current === registration.id) claim(ordered()[0]?.id);
|
|
237
225
|
};
|
|
238
226
|
};
|
|
239
|
-
$[
|
|
240
|
-
$[
|
|
241
|
-
$[
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
} else t0 = $[
|
|
227
|
+
$[0] = add;
|
|
228
|
+
$[1] = claim;
|
|
229
|
+
$[2] = ordered;
|
|
230
|
+
$[3] = remove;
|
|
231
|
+
$[4] = stop.current;
|
|
232
|
+
$[5] = t0;
|
|
233
|
+
} else t0 = $[5];
|
|
246
234
|
const register = useCallbackRef(t0);
|
|
247
235
|
let t1;
|
|
248
|
-
if ($[
|
|
236
|
+
if ($[6] !== claim || $[7] !== contains || $[8] !== ordered || $[9] !== orientation || $[10] !== stop.current || $[11] !== wrap) {
|
|
249
237
|
t1 = (event) => {
|
|
250
238
|
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
|
251
239
|
const { target } = event;
|
|
252
|
-
if (!(target instanceof Node) || !
|
|
240
|
+
if (!(target instanceof Node) || !contains(target)) return;
|
|
253
241
|
const rightToLeft = globalThis.getComputedStyle(event.currentTarget).direction === "rtl";
|
|
254
242
|
const intent = intentOf(event.key, orientation, rightToLeft ? -1 : 1);
|
|
255
243
|
if (intent === void 0) return;
|
|
@@ -259,126 +247,125 @@ function useRovingFocus(props) {
|
|
|
259
247
|
}
|
|
260
248
|
event.preventDefault();
|
|
261
249
|
};
|
|
262
|
-
$[
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
265
|
-
$[
|
|
266
|
-
$[
|
|
267
|
-
$[
|
|
268
|
-
$[
|
|
269
|
-
} else t1 = $[
|
|
250
|
+
$[6] = claim;
|
|
251
|
+
$[7] = contains;
|
|
252
|
+
$[8] = ordered;
|
|
253
|
+
$[9] = orientation;
|
|
254
|
+
$[10] = stop.current;
|
|
255
|
+
$[11] = wrap;
|
|
256
|
+
$[12] = t1;
|
|
257
|
+
} else t1 = $[12];
|
|
270
258
|
const onKeyDown = useCallbackRef(t1);
|
|
271
259
|
let t2;
|
|
272
|
-
if ($[
|
|
260
|
+
if ($[13] !== claim) {
|
|
273
261
|
t2 = (id) => {
|
|
274
262
|
claim(id);
|
|
275
263
|
};
|
|
276
|
-
$[
|
|
277
|
-
$[
|
|
278
|
-
} else t2 = $[
|
|
264
|
+
$[13] = claim;
|
|
265
|
+
$[14] = t2;
|
|
266
|
+
} else t2 = $[14];
|
|
279
267
|
const onFocus = useCallbackRef(t2);
|
|
280
268
|
let t3;
|
|
281
|
-
if ($[
|
|
269
|
+
if ($[15] !== activeId || $[16] !== onFocus || $[17] !== register) {
|
|
282
270
|
t3 = {
|
|
283
271
|
activeId,
|
|
284
272
|
onFocus,
|
|
285
273
|
register
|
|
286
274
|
};
|
|
287
|
-
$[
|
|
288
|
-
$[
|
|
289
|
-
$[
|
|
290
|
-
$[
|
|
291
|
-
} else t3 = $[
|
|
275
|
+
$[15] = activeId;
|
|
276
|
+
$[16] = onFocus;
|
|
277
|
+
$[17] = register;
|
|
278
|
+
$[18] = t3;
|
|
279
|
+
} else t3 = $[18];
|
|
292
280
|
const t4 = t3;
|
|
293
281
|
let t5;
|
|
294
|
-
if ($[
|
|
282
|
+
if ($[19] !== onKeyDown || $[20] !== t4) {
|
|
295
283
|
t5 = {
|
|
296
284
|
group: t4,
|
|
297
285
|
onKeyDown
|
|
298
286
|
};
|
|
299
|
-
$[
|
|
300
|
-
$[
|
|
301
|
-
$[
|
|
302
|
-
} else t5 = $[
|
|
287
|
+
$[19] = onKeyDown;
|
|
288
|
+
$[20] = t4;
|
|
289
|
+
$[21] = t5;
|
|
290
|
+
} else t5 = $[21];
|
|
303
291
|
return t5;
|
|
304
292
|
}
|
|
305
293
|
//#endregion
|
|
306
294
|
//#region src/roving-focus/item.tsx
|
|
307
295
|
/**
|
|
308
|
-
*
|
|
296
|
+
* Renders one item of a roving focus group.
|
|
309
297
|
*
|
|
310
298
|
* @remarks
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
* the
|
|
315
|
-
*
|
|
316
|
-
*
|
|
299
|
+
* One item has `tabIndex` 0 and every other has -1, so the group is one stop in the tab order. A
|
|
300
|
+
* disabled item does not register, so the arrows step past it. It also refuses the stop when a
|
|
301
|
+
* pointer focuses it, because a stop on an unregistered item is unreachable by the arrows and
|
|
302
|
+
* removes the group from the tab order. The element is in state and not in a ref, so the
|
|
303
|
+
* registering effect runs again once the node exists. The group keys on the registration, so
|
|
304
|
+
* the item writes the DOM `id` only when the caller passes one, and a control rendered as an item
|
|
305
|
+
* keeps an id it needs, such as the one a menu trigger references. The item with the stop has
|
|
306
|
+
* `data-stop` and not `data-active`, because the theme styles `[data-active]` as a pressed
|
|
307
|
+
* control.
|
|
317
308
|
*/
|
|
318
309
|
/**
|
|
319
|
-
*
|
|
310
|
+
* Renders a `div` element with the item slot's classes.
|
|
320
311
|
*/
|
|
321
312
|
const Shell$1 = withContext$1("div", "item");
|
|
322
313
|
/**
|
|
323
|
-
*
|
|
314
|
+
* Renders an item with `tabIndex` 0 while it has the tab stop and -1 otherwise.
|
|
324
315
|
*
|
|
325
|
-
* @throws {@link Error} When
|
|
316
|
+
* @throws {@link Error} When rendered outside a root.
|
|
326
317
|
*/
|
|
327
318
|
function Item(props) {
|
|
328
|
-
const $ = c(
|
|
329
|
-
if ($[0] !== "906ba9f383c3499089f80a6d094880677f9a2e49a204ba65b1f93dfa19d6065b") {
|
|
330
|
-
for (let $i = 0; $i < 27; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
331
|
-
$[0] = "906ba9f383c3499089f80a6d094880677f9a2e49a204ba65b1f93dfa19d6065b";
|
|
332
|
-
}
|
|
319
|
+
const $ = c(26);
|
|
333
320
|
let handed;
|
|
334
321
|
let named;
|
|
335
322
|
let rest;
|
|
336
323
|
let t0;
|
|
337
|
-
if ($[
|
|
324
|
+
if ($[0] !== props) {
|
|
338
325
|
({disabled: t0, id: named, ref: handed, ...rest} = props);
|
|
339
|
-
$[
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
326
|
+
$[0] = props;
|
|
327
|
+
$[1] = handed;
|
|
328
|
+
$[2] = named;
|
|
329
|
+
$[3] = rest;
|
|
330
|
+
$[4] = t0;
|
|
344
331
|
} else {
|
|
345
|
-
handed = $[
|
|
346
|
-
named = $[
|
|
347
|
-
rest = $[
|
|
348
|
-
t0 = $[
|
|
332
|
+
handed = $[1];
|
|
333
|
+
named = $[2];
|
|
334
|
+
rest = $[3];
|
|
335
|
+
t0 = $[4];
|
|
349
336
|
}
|
|
350
337
|
const disabled = t0 === void 0 ? false : t0;
|
|
351
338
|
const group = use(RovingFocusContext);
|
|
352
|
-
if (group === void 0) throw new Error("RovingFocus.Item
|
|
339
|
+
if (group === void 0) throw new Error("RovingFocus.Item must be rendered inside RovingFocus.Root.");
|
|
353
340
|
const generated = useId();
|
|
354
341
|
const id = named ?? generated;
|
|
355
342
|
const { activeId, onFocus, register } = group;
|
|
356
343
|
const [element, setElement] = useState(null);
|
|
357
344
|
let t1;
|
|
358
|
-
if ($[
|
|
345
|
+
if ($[5] !== handed) {
|
|
359
346
|
t1 = (node) => {
|
|
360
347
|
setElement(node);
|
|
361
348
|
if (typeof handed === "function") handed(node);
|
|
362
349
|
else if (handed !== null && handed !== void 0) handed.current = node;
|
|
363
350
|
};
|
|
364
|
-
$[
|
|
365
|
-
$[
|
|
366
|
-
} else t1 = $[
|
|
351
|
+
$[5] = handed;
|
|
352
|
+
$[6] = t1;
|
|
353
|
+
} else t1 = $[6];
|
|
367
354
|
const attach = useCallbackRef(t1);
|
|
368
355
|
let t2;
|
|
369
|
-
if ($[
|
|
356
|
+
if ($[7] !== disabled || $[8] !== id || $[9] !== onFocus) {
|
|
370
357
|
t2 = () => {
|
|
371
358
|
if (!disabled) onFocus(id);
|
|
372
359
|
};
|
|
373
|
-
$[
|
|
374
|
-
$[
|
|
375
|
-
$[
|
|
376
|
-
$[
|
|
377
|
-
} else t2 = $[
|
|
360
|
+
$[7] = disabled;
|
|
361
|
+
$[8] = id;
|
|
362
|
+
$[9] = onFocus;
|
|
363
|
+
$[10] = t2;
|
|
364
|
+
} else t2 = $[10];
|
|
378
365
|
const claim = useCallbackRef(t2);
|
|
379
366
|
let t3;
|
|
380
367
|
let t4;
|
|
381
|
-
if ($[
|
|
368
|
+
if ($[11] !== disabled || $[12] !== element || $[13] !== id || $[14] !== register) {
|
|
382
369
|
t3 = () => {
|
|
383
370
|
if (element === null || disabled) return;
|
|
384
371
|
return register({
|
|
@@ -392,60 +379,56 @@ function Item(props) {
|
|
|
392
379
|
id,
|
|
393
380
|
register
|
|
394
381
|
];
|
|
395
|
-
$[
|
|
396
|
-
$[
|
|
397
|
-
$[
|
|
398
|
-
$[
|
|
399
|
-
$[
|
|
400
|
-
$[
|
|
382
|
+
$[11] = disabled;
|
|
383
|
+
$[12] = element;
|
|
384
|
+
$[13] = id;
|
|
385
|
+
$[14] = register;
|
|
386
|
+
$[15] = t3;
|
|
387
|
+
$[16] = t4;
|
|
401
388
|
} else {
|
|
402
|
-
t3 = $[
|
|
403
|
-
t4 = $[
|
|
389
|
+
t3 = $[15];
|
|
390
|
+
t4 = $[16];
|
|
404
391
|
}
|
|
405
392
|
useEffect(t3, t4);
|
|
406
393
|
const t5 = disabled || void 0;
|
|
407
|
-
const t6 =
|
|
408
|
-
const t7 =
|
|
394
|
+
const t6 = disabled ? "" : void 0;
|
|
395
|
+
const t7 = activeId === id ? "" : void 0;
|
|
409
396
|
const t8 = !disabled && activeId === id ? 0 : -1;
|
|
410
397
|
let t9;
|
|
411
|
-
if ($[
|
|
398
|
+
if ($[17] !== attach || $[18] !== claim || $[19] !== named || $[20] !== rest || $[21] !== t5 || $[22] !== t6 || $[23] !== t7 || $[24] !== t8) {
|
|
412
399
|
t9 = /* @__PURE__ */ jsx(Shell$1, {
|
|
413
400
|
"aria-disabled": t5,
|
|
414
|
-
"data-
|
|
415
|
-
"data-
|
|
416
|
-
id,
|
|
401
|
+
"data-disabled": t6,
|
|
402
|
+
"data-stop": t7,
|
|
403
|
+
id: named,
|
|
417
404
|
onFocus: claim,
|
|
418
405
|
ref: attach,
|
|
419
406
|
tabIndex: t8,
|
|
420
407
|
...rest
|
|
421
408
|
});
|
|
422
|
-
$[
|
|
423
|
-
$[
|
|
424
|
-
$[
|
|
425
|
-
$[
|
|
426
|
-
$[
|
|
427
|
-
$[
|
|
428
|
-
$[
|
|
429
|
-
$[
|
|
430
|
-
$[
|
|
431
|
-
} else t9 = $[
|
|
409
|
+
$[17] = attach;
|
|
410
|
+
$[18] = claim;
|
|
411
|
+
$[19] = named;
|
|
412
|
+
$[20] = rest;
|
|
413
|
+
$[21] = t5;
|
|
414
|
+
$[22] = t6;
|
|
415
|
+
$[23] = t7;
|
|
416
|
+
$[24] = t8;
|
|
417
|
+
$[25] = t9;
|
|
418
|
+
} else t9 = $[25];
|
|
432
419
|
return t9;
|
|
433
420
|
}
|
|
434
421
|
//#endregion
|
|
435
422
|
//#region src/roving-focus/root.tsx
|
|
436
423
|
/**
|
|
437
|
-
*
|
|
424
|
+
* Renders a `div` element with the root slot's classes.
|
|
438
425
|
*/
|
|
439
426
|
const Shell = withProvider$1("div", "root");
|
|
440
427
|
/**
|
|
441
|
-
* Keeps one tab stop for the items
|
|
428
|
+
* Keeps one tab stop for the items below it and moves the stop on the arrow keys.
|
|
442
429
|
*/
|
|
443
430
|
function Root(props) {
|
|
444
|
-
const $ = c(
|
|
445
|
-
if ($[0] !== "16a674b835753bf9fd806b5c17b8426cf42995a3c3e2732778987a1e4a0700e7") {
|
|
446
|
-
for (let $i = 0; $i < 27; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
447
|
-
$[0] = "16a674b835753bf9fd806b5c17b8426cf42995a3c3e2732778987a1e4a0700e7";
|
|
448
|
-
}
|
|
431
|
+
const $ = c(26);
|
|
449
432
|
let activeId;
|
|
450
433
|
let children;
|
|
451
434
|
let defaultActiveId;
|
|
@@ -453,29 +436,29 @@ function Root(props) {
|
|
|
453
436
|
let rest;
|
|
454
437
|
let t0;
|
|
455
438
|
let t1;
|
|
456
|
-
if ($[
|
|
439
|
+
if ($[0] !== props) {
|
|
457
440
|
({activeId, children, defaultActiveId, onActiveIdChange, orientation: t0, wrap: t1, ...rest} = props);
|
|
458
|
-
$[
|
|
459
|
-
$[
|
|
460
|
-
$[
|
|
461
|
-
$[
|
|
462
|
-
$[
|
|
463
|
-
$[
|
|
464
|
-
$[
|
|
465
|
-
$[
|
|
441
|
+
$[0] = props;
|
|
442
|
+
$[1] = activeId;
|
|
443
|
+
$[2] = children;
|
|
444
|
+
$[3] = defaultActiveId;
|
|
445
|
+
$[4] = onActiveIdChange;
|
|
446
|
+
$[5] = rest;
|
|
447
|
+
$[6] = t0;
|
|
448
|
+
$[7] = t1;
|
|
466
449
|
} else {
|
|
467
|
-
activeId = $[
|
|
468
|
-
children = $[
|
|
469
|
-
defaultActiveId = $[
|
|
470
|
-
onActiveIdChange = $[
|
|
471
|
-
rest = $[
|
|
472
|
-
t0 = $[
|
|
473
|
-
t1 = $[
|
|
450
|
+
activeId = $[1];
|
|
451
|
+
children = $[2];
|
|
452
|
+
defaultActiveId = $[3];
|
|
453
|
+
onActiveIdChange = $[4];
|
|
454
|
+
rest = $[5];
|
|
455
|
+
t0 = $[6];
|
|
456
|
+
t1 = $[7];
|
|
474
457
|
}
|
|
475
458
|
const orientation = t0 === void 0 ? "horizontal" : t0;
|
|
476
459
|
const wrap = t1 === void 0 ? false : t1;
|
|
477
460
|
let t2;
|
|
478
|
-
if ($[
|
|
461
|
+
if ($[8] !== activeId || $[9] !== defaultActiveId || $[10] !== onActiveIdChange || $[11] !== orientation || $[12] !== wrap) {
|
|
479
462
|
t2 = {
|
|
480
463
|
activeId,
|
|
481
464
|
defaultActiveId,
|
|
@@ -483,24 +466,24 @@ function Root(props) {
|
|
|
483
466
|
orientation,
|
|
484
467
|
wrap
|
|
485
468
|
};
|
|
486
|
-
$[
|
|
487
|
-
$[
|
|
488
|
-
$[
|
|
489
|
-
$[
|
|
490
|
-
$[
|
|
491
|
-
$[
|
|
492
|
-
} else t2 = $[
|
|
469
|
+
$[8] = activeId;
|
|
470
|
+
$[9] = defaultActiveId;
|
|
471
|
+
$[10] = onActiveIdChange;
|
|
472
|
+
$[11] = orientation;
|
|
473
|
+
$[12] = wrap;
|
|
474
|
+
$[13] = t2;
|
|
475
|
+
} else t2 = $[13];
|
|
493
476
|
const { group, onKeyDown } = useRovingFocus(t2);
|
|
494
477
|
let t3;
|
|
495
|
-
if ($[
|
|
478
|
+
if ($[14] !== orientation || $[15] !== rest.role) {
|
|
496
479
|
t3 = rest.role !== void 0 && orientation !== "both" ? { "aria-orientation": orientation } : void 0;
|
|
497
|
-
$[
|
|
498
|
-
$[
|
|
499
|
-
$[
|
|
500
|
-
} else t3 = $[
|
|
480
|
+
$[14] = orientation;
|
|
481
|
+
$[15] = rest.role;
|
|
482
|
+
$[16] = t3;
|
|
483
|
+
} else t3 = $[16];
|
|
501
484
|
const told = t3;
|
|
502
485
|
let t4;
|
|
503
|
-
if ($[
|
|
486
|
+
if ($[17] !== children || $[18] !== onKeyDown || $[19] !== orientation || $[20] !== rest || $[21] !== told) {
|
|
504
487
|
t4 = /* @__PURE__ */ jsx(Shell, {
|
|
505
488
|
onKeyDown,
|
|
506
489
|
orientation,
|
|
@@ -508,23 +491,23 @@ function Root(props) {
|
|
|
508
491
|
...rest,
|
|
509
492
|
children
|
|
510
493
|
});
|
|
511
|
-
$[
|
|
512
|
-
$[
|
|
513
|
-
$[
|
|
514
|
-
$[
|
|
515
|
-
$[
|
|
516
|
-
$[
|
|
517
|
-
} else t4 = $[
|
|
494
|
+
$[17] = children;
|
|
495
|
+
$[18] = onKeyDown;
|
|
496
|
+
$[19] = orientation;
|
|
497
|
+
$[20] = rest;
|
|
498
|
+
$[21] = told;
|
|
499
|
+
$[22] = t4;
|
|
500
|
+
} else t4 = $[22];
|
|
518
501
|
let t5;
|
|
519
|
-
if ($[
|
|
502
|
+
if ($[23] !== group || $[24] !== t4) {
|
|
520
503
|
t5 = /* @__PURE__ */ jsx(RovingFocusContext, {
|
|
521
504
|
value: group,
|
|
522
505
|
children: t4
|
|
523
506
|
});
|
|
524
|
-
$[
|
|
525
|
-
$[
|
|
526
|
-
$[
|
|
527
|
-
} else t5 = $[
|
|
507
|
+
$[23] = group;
|
|
508
|
+
$[24] = t4;
|
|
509
|
+
$[25] = t5;
|
|
510
|
+
} else t5 = $[25];
|
|
528
511
|
return t5;
|
|
529
512
|
}
|
|
530
513
|
//#endregion
|
|
@@ -536,32 +519,32 @@ var roving_focus_exports = /* @__PURE__ */ __exportAll({
|
|
|
536
519
|
//#endregion
|
|
537
520
|
//#region src/skip-nav/context.ts
|
|
538
521
|
/**
|
|
539
|
-
* Binds the skip
|
|
522
|
+
* Binds the skip-nav slot recipe to React.
|
|
540
523
|
*
|
|
541
524
|
* @remarks
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
* further down, and the two are never nested.
|
|
525
|
+
* The binding is a separate module from the recipe, because the theme compiler imports the recipe
|
|
526
|
+
* at build time and must not load the React runtime. The link and the target each use
|
|
527
|
+
* `withProvider`, because neither is rendered inside the other.
|
|
546
528
|
*/
|
|
547
529
|
/**
|
|
548
|
-
*
|
|
530
|
+
* Creates the skip-nav recipe's `withProvider` binding.
|
|
549
531
|
*/
|
|
550
532
|
const { withProvider } = createSlotRecipeContext(recipe$1);
|
|
551
533
|
//#endregion
|
|
552
534
|
//#region src/skip-nav/link.ts
|
|
553
535
|
/**
|
|
554
|
-
*
|
|
536
|
+
* Fragment identifier that the link's `href` and the target's `id` default to.
|
|
555
537
|
*/
|
|
556
538
|
const SKIP_NAV_TARGET = "content";
|
|
557
539
|
/**
|
|
558
|
-
*
|
|
540
|
+
* Renders an `a` element with the link slot's classes, pointing at `#content` by default.
|
|
559
541
|
*/
|
|
560
542
|
const Link = withProvider("a", "link", { defaultProps: { href: `#${SKIP_NAV_TARGET}` } });
|
|
561
543
|
//#endregion
|
|
562
544
|
//#region src/skip-nav/target.ts
|
|
563
545
|
/**
|
|
564
|
-
*
|
|
546
|
+
* Renders a `div` element with the target slot's classes, `id="content"` and `tabIndex` -1 by
|
|
547
|
+
* default.
|
|
565
548
|
*/
|
|
566
549
|
const Target = withProvider("div", "target", { defaultProps: {
|
|
567
550
|
id: SKIP_NAV_TARGET,
|
|
@@ -577,21 +560,24 @@ var skip_nav_exports = /* @__PURE__ */ __exportAll({
|
|
|
577
560
|
//#endregion
|
|
578
561
|
//#region src/visually-hidden/context.ts
|
|
579
562
|
/**
|
|
580
|
-
* Binds the hidden
|
|
563
|
+
* Binds the visually-hidden recipe to React.
|
|
581
564
|
*
|
|
582
565
|
* @remarks
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
* every compiler configuration that reads it.
|
|
566
|
+
* The binding is a separate module from the recipe, because the theme compiler imports the recipe
|
|
567
|
+
* at build time and must not load the React runtime.
|
|
586
568
|
*/
|
|
587
569
|
/**
|
|
588
|
-
*
|
|
570
|
+
* Creates the visually-hidden recipe's `withContext` binding and its `PropsProvider`.
|
|
571
|
+
*
|
|
572
|
+
* @remarks
|
|
573
|
+
* `PropsProvider` sets variants on every element bound below it. The package exports it as
|
|
574
|
+
* `VisuallyHiddenPropsProvider`.
|
|
589
575
|
*/
|
|
590
576
|
const { PropsProvider, withContext } = createRecipeContext(recipe$2);
|
|
591
577
|
//#endregion
|
|
592
578
|
//#region src/visually-hidden/visually-hidden.ts
|
|
593
579
|
/**
|
|
594
|
-
*
|
|
580
|
+
* Renders a `span` element with the classes of the visually-hidden recipe.
|
|
595
581
|
*/
|
|
596
582
|
const VisuallyHidden = withContext("span");
|
|
597
583
|
//#endregion
|