praxis-kit 6.1.0 → 6.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.
- package/dist/{chunk-VUULGK5M.js → chunk-4YVNOMUS.js} +607 -564
- package/dist/contract/index.d.ts +11 -3
- package/dist/eslint/index.js +1 -1
- package/dist/guards/index.d.ts +36 -0
- package/dist/guards/index.js +62 -0
- package/dist/lit/index.d.ts +9 -2
- package/dist/lit/index.js +389 -340
- package/dist/preact/index.d.ts +9 -2
- package/dist/preact/index.js +496 -453
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/dist/react/legacy.d.ts +2 -2
- package/dist/react/legacy.js +1 -1
- package/dist/{react-options-AitAOrje.d.ts → react-options-DQTX4YS_.d.ts} +9 -2
- package/dist/solid/index.d.ts +9 -2
- package/dist/solid/index.js +485 -440
- package/dist/svelte/Polymorphic.svelte +2 -2
- package/dist/svelte/index.d.ts +10 -3
- package/dist/svelte/index.js +385 -340
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +3 -3
- package/dist/vue/index.d.ts +9 -2
- package/dist/vue/index.js +472 -421
- package/dist/web/index.d.ts +9 -2
- package/dist/web/index.js +389 -340
- package/package.json +10 -3
package/dist/solid/index.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
// ../../lib/primitive/src/
|
|
2
|
-
|
|
1
|
+
// ../../lib/primitive/src/tag/resolve-tag.ts
|
|
2
|
+
function makeResolveTag(defaultTag) {
|
|
3
|
+
return function tag(as) {
|
|
4
|
+
return as ?? defaultTag;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// ../../lib/primitive/src/rule/rule-brand.ts
|
|
9
|
+
var RULE_BRAND = /* @__PURE__ */ Symbol("praxis-kit/dynamic-rule");
|
|
10
|
+
|
|
11
|
+
// ../../lib/primitive/src/guards/foundational/is-defined.ts
|
|
12
|
+
function isUndefined(value) {
|
|
13
|
+
return value === void 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ../../lib/primitive/src/guards/foundational/is-null.ts
|
|
17
|
+
function isNull(value) {
|
|
18
|
+
return value === null;
|
|
19
|
+
}
|
|
20
|
+
function isNonNull(value) {
|
|
21
|
+
return value != null;
|
|
22
|
+
}
|
|
3
23
|
|
|
4
|
-
// ../../lib/primitive/src/utils/
|
|
24
|
+
// ../../lib/primitive/src/utils/type-guards.ts
|
|
5
25
|
function isObject(value, excludeArrays = false) {
|
|
6
26
|
if (value === null || typeof value !== "object") return false;
|
|
7
27
|
return excludeArrays ? !Array.isArray(value) : true;
|
|
@@ -13,57 +33,242 @@ function isNumber(value) {
|
|
|
13
33
|
return typeof value === "number";
|
|
14
34
|
}
|
|
15
35
|
|
|
16
|
-
// ../../lib/primitive/src/
|
|
17
|
-
function
|
|
18
|
-
return
|
|
36
|
+
// ../../lib/primitive/src/rule/is-dynamic-rule.ts
|
|
37
|
+
function isDynamicRule(rule) {
|
|
38
|
+
return isObject(rule, true) && rule[RULE_BRAND] === true;
|
|
19
39
|
}
|
|
20
40
|
|
|
21
|
-
// ../../lib/primitive/src/
|
|
22
|
-
function
|
|
23
|
-
return
|
|
41
|
+
// ../../lib/primitive/src/rule/resolve-rule.ts
|
|
42
|
+
function resolveRule(rule, context) {
|
|
43
|
+
return isDynamicRule(rule) ? rule.resolve(context) : rule;
|
|
24
44
|
}
|
|
25
45
|
|
|
26
|
-
// ../../lib/primitive/src/
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
const props = child.props;
|
|
30
|
-
if (!isObject(props)) return void 0;
|
|
31
|
-
const as = props.as;
|
|
32
|
-
return isString(as) && as !== "" ? as : void 0;
|
|
46
|
+
// ../../lib/primitive/src/utils/assert-never.ts
|
|
47
|
+
function assertNever(value) {
|
|
48
|
+
throw new Error(`Unexpected value: ${String(value)}`);
|
|
33
49
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
|
|
51
|
+
// ../../lib/primitive/src/utils/cn.ts
|
|
52
|
+
import { clsx } from "clsx";
|
|
53
|
+
function cn(...inputs) {
|
|
54
|
+
return clsx(...inputs);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ../../lib/primitive/src/utils/iterate.ts
|
|
58
|
+
function find(iterable, callback) {
|
|
59
|
+
for (const value of iterable) {
|
|
60
|
+
const result = callback(value);
|
|
61
|
+
if (result != null) {
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
42
64
|
}
|
|
43
|
-
return
|
|
65
|
+
return null;
|
|
44
66
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return (child2) => {
|
|
49
|
-
const tag2 = getTag(child2);
|
|
50
|
-
return tag2 !== void 0 && set3.has(tag2);
|
|
51
|
-
};
|
|
67
|
+
function some(iterable, predicate) {
|
|
68
|
+
for (const value of iterable) {
|
|
69
|
+
if (predicate(value)) return true;
|
|
52
70
|
}
|
|
53
|
-
|
|
54
|
-
const set2 = new Set(tags);
|
|
55
|
-
const tag = getTag(child);
|
|
56
|
-
return tag !== void 0 && set2.has(tag);
|
|
71
|
+
return false;
|
|
57
72
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
function every(iterable, predicate) {
|
|
74
|
+
let index = 0;
|
|
75
|
+
for (const value of iterable) {
|
|
76
|
+
if (!predicate(value, index++)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
function* filter(iterable, predicate) {
|
|
83
|
+
let index = 0;
|
|
84
|
+
for (const value of iterable) {
|
|
85
|
+
if (predicate(value, index++)) {
|
|
86
|
+
yield value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function* map(iterable, callback) {
|
|
91
|
+
let index = 0;
|
|
92
|
+
for (const value of iterable) {
|
|
93
|
+
yield callback(value, index++);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function forEach(iterable, callback) {
|
|
97
|
+
let index = 0;
|
|
98
|
+
for (const value of iterable) {
|
|
99
|
+
callback(value, index++);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function reduce(iterable, initial, callback) {
|
|
103
|
+
let accumulator = initial;
|
|
104
|
+
let index = 0;
|
|
105
|
+
for (const value of iterable) {
|
|
106
|
+
accumulator = callback(accumulator, value, index++);
|
|
107
|
+
}
|
|
108
|
+
return accumulator;
|
|
109
|
+
}
|
|
110
|
+
function collect(iterable, callback) {
|
|
111
|
+
const result = {};
|
|
112
|
+
let index = 0;
|
|
113
|
+
for (const value of iterable) {
|
|
114
|
+
const entry = callback(value, index++);
|
|
115
|
+
if (entry === null) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
result[entry[0]] = entry[1];
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
62
121
|
}
|
|
122
|
+
function findLast(value, callback) {
|
|
123
|
+
for (let index = value.length - 1; index >= 0; index--) {
|
|
124
|
+
const result = callback(value[index], index);
|
|
125
|
+
if (result != null) {
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function* items(collection) {
|
|
132
|
+
for (let i = 0; i < collection.length; i++) {
|
|
133
|
+
const item = collection.item(i);
|
|
134
|
+
if (item !== null) {
|
|
135
|
+
yield item;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function nodeList(list) {
|
|
140
|
+
return {
|
|
141
|
+
*[Symbol.iterator]() {
|
|
142
|
+
for (let i = 0; i < list.length; i++) {
|
|
143
|
+
const node = list.item(i);
|
|
144
|
+
if (node !== null) {
|
|
145
|
+
yield node;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function mapEntries(m) {
|
|
152
|
+
return m.entries();
|
|
153
|
+
}
|
|
154
|
+
function set(s) {
|
|
155
|
+
return s.values();
|
|
156
|
+
}
|
|
157
|
+
function hasOwn(object, key) {
|
|
158
|
+
return Object.hasOwn(object, key);
|
|
159
|
+
}
|
|
160
|
+
function* entries(object) {
|
|
161
|
+
for (const key in object) {
|
|
162
|
+
if (!hasOwn(object, key)) continue;
|
|
163
|
+
yield [key, object[key]];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function* keys(object) {
|
|
167
|
+
for (const [key] of entries(object)) {
|
|
168
|
+
yield key;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function* values(object) {
|
|
172
|
+
for (const [, value] of entries(object)) {
|
|
173
|
+
yield value;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function mapValues(object, callback) {
|
|
177
|
+
const result = {};
|
|
178
|
+
for (const [key, value] of entries(object)) {
|
|
179
|
+
result[key] = callback(value, key);
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
function forEachEntry(object, callback) {
|
|
184
|
+
for (const [key, value] of entries(object)) {
|
|
185
|
+
callback(key, value);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function forEachKey(object, callback) {
|
|
189
|
+
for (const key of keys(object)) {
|
|
190
|
+
callback(key);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function forEachValue(object, callback) {
|
|
194
|
+
for (const value of values(object)) {
|
|
195
|
+
callback(value);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function forEachSet(s, callback) {
|
|
199
|
+
for (const value of s) {
|
|
200
|
+
callback(value);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
var iterate = Object.freeze({
|
|
204
|
+
entries,
|
|
205
|
+
filter,
|
|
206
|
+
find,
|
|
207
|
+
findLast,
|
|
208
|
+
forEach,
|
|
209
|
+
forEachEntry,
|
|
210
|
+
forEachKey,
|
|
211
|
+
forEachSet,
|
|
212
|
+
forEachValue,
|
|
213
|
+
items,
|
|
214
|
+
keys,
|
|
215
|
+
map,
|
|
216
|
+
mapEntries,
|
|
217
|
+
mapValues,
|
|
218
|
+
nodeList,
|
|
219
|
+
reduce,
|
|
220
|
+
collect,
|
|
221
|
+
set,
|
|
222
|
+
some,
|
|
223
|
+
every,
|
|
224
|
+
values
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// ../../lib/primitive/src/utils/lru-cache.ts
|
|
228
|
+
var LRUCache = class {
|
|
229
|
+
#maxSize;
|
|
230
|
+
#store = /* @__PURE__ */ new Map();
|
|
231
|
+
constructor(maxSize) {
|
|
232
|
+
if (!Number.isInteger(maxSize) || maxSize < 1) {
|
|
233
|
+
throw new RangeError("LRUCache maxSize must be a positive integer.");
|
|
234
|
+
}
|
|
235
|
+
this.#maxSize = maxSize;
|
|
236
|
+
}
|
|
237
|
+
get(key) {
|
|
238
|
+
if (!this.#store.has(key)) return void 0;
|
|
239
|
+
const value = this.#store.get(key);
|
|
240
|
+
this.#store.delete(key);
|
|
241
|
+
this.#store.set(key, value);
|
|
242
|
+
return value;
|
|
243
|
+
}
|
|
244
|
+
set(key, value) {
|
|
245
|
+
this.#store.delete(key);
|
|
246
|
+
this.#store.set(key, value);
|
|
247
|
+
if (this.#store.size > this.#maxSize) {
|
|
248
|
+
const lru = this.#store.keys().next().value;
|
|
249
|
+
if (lru !== void 0) this.#store.delete(lru);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
has(key) {
|
|
253
|
+
return this.#store.has(key);
|
|
254
|
+
}
|
|
255
|
+
delete(key) {
|
|
256
|
+
return this.#store.delete(key);
|
|
257
|
+
}
|
|
258
|
+
get size() {
|
|
259
|
+
return this.#store.size;
|
|
260
|
+
}
|
|
261
|
+
clear() {
|
|
262
|
+
this.#store.clear();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
63
265
|
|
|
64
|
-
// ../../lib/
|
|
65
|
-
function
|
|
66
|
-
return
|
|
266
|
+
// ../../lib/primitive/src/utils/merge-props.ts
|
|
267
|
+
function mergeProps(defaultProps, props) {
|
|
268
|
+
return {
|
|
269
|
+
...defaultProps ?? {},
|
|
270
|
+
...props
|
|
271
|
+
};
|
|
67
272
|
}
|
|
68
273
|
|
|
69
274
|
// ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
|
|
@@ -324,366 +529,164 @@ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
|
|
|
324
529
|
["aria-pressed", /* @__PURE__ */ new Set(["button"])],
|
|
325
530
|
[
|
|
326
531
|
"aria-readonly",
|
|
327
|
-
/* @__PURE__ */ new Set([
|
|
328
|
-
"combobox",
|
|
329
|
-
"grid",
|
|
330
|
-
"gridcell",
|
|
331
|
-
"listbox",
|
|
332
|
-
"radiogroup",
|
|
333
|
-
"slider",
|
|
334
|
-
"spinbutton",
|
|
335
|
-
"textbox",
|
|
336
|
-
"tree",
|
|
337
|
-
"treegrid"
|
|
338
|
-
])
|
|
339
|
-
],
|
|
340
|
-
[
|
|
341
|
-
"aria-required",
|
|
342
|
-
/* @__PURE__ */ new Set([
|
|
343
|
-
"combobox",
|
|
344
|
-
"gridcell",
|
|
345
|
-
"listbox",
|
|
346
|
-
"radiogroup",
|
|
347
|
-
"spinbutton",
|
|
348
|
-
"textbox",
|
|
349
|
-
"tree",
|
|
350
|
-
"treegrid"
|
|
351
|
-
])
|
|
352
|
-
],
|
|
353
|
-
["aria-rowcount", /* @__PURE__ */ new Set(["grid", "table", "treegrid"])],
|
|
354
|
-
["aria-rowindex", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "row", "rowheader"])],
|
|
355
|
-
["aria-rowspan", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "rowheader"])],
|
|
356
|
-
[
|
|
357
|
-
"aria-selected",
|
|
358
|
-
/* @__PURE__ */ new Set(["columnheader", "gridcell", "option", "row", "rowheader", "tab", "treeitem"])
|
|
359
|
-
],
|
|
360
|
-
[
|
|
361
|
-
"aria-setsize",
|
|
362
|
-
/* @__PURE__ */ new Set([
|
|
363
|
-
"article",
|
|
364
|
-
"listitem",
|
|
365
|
-
"menuitem",
|
|
366
|
-
"menuitemcheckbox",
|
|
367
|
-
"menuitemradio",
|
|
368
|
-
"option",
|
|
369
|
-
"radio",
|
|
370
|
-
"row",
|
|
371
|
-
"tab"
|
|
372
|
-
])
|
|
373
|
-
],
|
|
374
|
-
["aria-sort", /* @__PURE__ */ new Set(["columnheader", "rowheader"])],
|
|
375
|
-
[
|
|
376
|
-
"aria-valuemax",
|
|
377
|
-
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
378
|
-
],
|
|
379
|
-
[
|
|
380
|
-
"aria-valuemin",
|
|
381
|
-
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
382
|
-
],
|
|
383
|
-
[
|
|
384
|
-
"aria-valuenow",
|
|
385
|
-
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
386
|
-
],
|
|
387
|
-
[
|
|
388
|
-
"aria-valuetext",
|
|
389
|
-
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
390
|
-
]
|
|
391
|
-
]);
|
|
392
|
-
|
|
393
|
-
// ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
|
|
394
|
-
function isGlobalAriaAttribute(attr) {
|
|
395
|
-
return GLOBAL_ARIA_ATTRIBUTES.has(attr);
|
|
396
|
-
}
|
|
397
|
-
function isAriaAttributeValidForRole(attr, role) {
|
|
398
|
-
const allowedRoles = ROLE_RESTRICTED_ATTRIBUTES.get(attr);
|
|
399
|
-
if (isUndefined(allowedRoles)) return true;
|
|
400
|
-
if (isUndefined(role)) return false;
|
|
401
|
-
return allowedRoles.has(role);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// ../../lib/primitive/src/guards/aria/is-aria-role.ts
|
|
405
|
-
function isStrongImplicitRole(tag) {
|
|
406
|
-
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
407
|
-
return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
408
|
-
}
|
|
409
|
-
function isStandaloneTag(tag) {
|
|
410
|
-
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
411
|
-
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
412
|
-
}
|
|
413
|
-
function getInputImplicitRole(type) {
|
|
414
|
-
if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
|
|
415
|
-
return INPUT_TYPE_ROLE_MAP[type];
|
|
416
|
-
}
|
|
417
|
-
function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
|
|
418
|
-
const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
|
|
419
|
-
if (!isNamed) return void 0;
|
|
420
|
-
if (tag === "section") return "region";
|
|
421
|
-
if (tag === "form") return "form";
|
|
422
|
-
return void 0;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// ../../lib/primitive/src/guards/aria/is-known-aria-role.ts
|
|
426
|
-
function isKnownAriaRole(value) {
|
|
427
|
-
return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// ../../lib/contract/src/aria/aria-role-policy.ts
|
|
431
|
-
function getImplicitRole(tag, props) {
|
|
432
|
-
if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
|
|
433
|
-
if (tag === "input") return getInputImplicitRole(props?.type);
|
|
434
|
-
if (tag === "img") return props?.alt === "" ? "none" : "img";
|
|
435
|
-
if (tag === "section" || tag === "form") {
|
|
436
|
-
return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
|
|
437
|
-
}
|
|
438
|
-
return void 0;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
// ../../lib/primitive/src/tag/resolve-tag.ts
|
|
442
|
-
function makeResolveTag(defaultTag) {
|
|
443
|
-
return function tag(as) {
|
|
444
|
-
return as ?? defaultTag;
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
// ../../lib/primitive/src/rule/rule-brand.ts
|
|
449
|
-
var RULE_BRAND = /* @__PURE__ */ Symbol("praxis-kit/dynamic-rule");
|
|
450
|
-
|
|
451
|
-
// ../../lib/primitive/src/rule/is-dynamic-rule.ts
|
|
452
|
-
function isDynamicRule(rule) {
|
|
453
|
-
return isObject(rule, true) && rule[RULE_BRAND] === true;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// ../../lib/primitive/src/rule/resolve-rule.ts
|
|
457
|
-
function resolveRule(rule, context) {
|
|
458
|
-
return isDynamicRule(rule) ? rule.resolve(context) : rule;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
// ../../lib/primitive/src/utils/assert-never.ts
|
|
462
|
-
function assertNever(value) {
|
|
463
|
-
throw new Error(`Unexpected value: ${String(value)}`);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
// ../../lib/primitive/src/utils/cn.ts
|
|
467
|
-
import { clsx } from "clsx";
|
|
468
|
-
function cn(...inputs) {
|
|
469
|
-
return clsx(...inputs);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
// ../../lib/primitive/src/utils/iterate.ts
|
|
473
|
-
function find(iterable, callback) {
|
|
474
|
-
for (const value of iterable) {
|
|
475
|
-
const result = callback(value);
|
|
476
|
-
if (result != null) {
|
|
477
|
-
return result;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
|
-
function some(iterable, predicate) {
|
|
483
|
-
for (const value of iterable) {
|
|
484
|
-
if (predicate(value)) return true;
|
|
485
|
-
}
|
|
486
|
-
return false;
|
|
487
|
-
}
|
|
488
|
-
function every(iterable, predicate) {
|
|
489
|
-
let index = 0;
|
|
490
|
-
for (const value of iterable) {
|
|
491
|
-
if (!predicate(value, index++)) {
|
|
492
|
-
return false;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
return true;
|
|
496
|
-
}
|
|
497
|
-
function* filter(iterable, predicate) {
|
|
498
|
-
let index = 0;
|
|
499
|
-
for (const value of iterable) {
|
|
500
|
-
if (predicate(value, index++)) {
|
|
501
|
-
yield value;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
function* map(iterable, callback) {
|
|
506
|
-
let index = 0;
|
|
507
|
-
for (const value of iterable) {
|
|
508
|
-
yield callback(value, index++);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
function forEach(iterable, callback) {
|
|
512
|
-
let index = 0;
|
|
513
|
-
for (const value of iterable) {
|
|
514
|
-
callback(value, index++);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
function reduce(iterable, initial, callback) {
|
|
518
|
-
let accumulator = initial;
|
|
519
|
-
let index = 0;
|
|
520
|
-
for (const value of iterable) {
|
|
521
|
-
accumulator = callback(accumulator, value, index++);
|
|
522
|
-
}
|
|
523
|
-
return accumulator;
|
|
524
|
-
}
|
|
525
|
-
function collect(iterable, callback) {
|
|
526
|
-
const result = {};
|
|
527
|
-
let index = 0;
|
|
528
|
-
for (const value of iterable) {
|
|
529
|
-
const entry = callback(value, index++);
|
|
530
|
-
if (entry === null) {
|
|
531
|
-
return null;
|
|
532
|
-
}
|
|
533
|
-
result[entry[0]] = entry[1];
|
|
534
|
-
}
|
|
535
|
-
return result;
|
|
536
|
-
}
|
|
537
|
-
function findLast(value, callback) {
|
|
538
|
-
for (let index = value.length - 1; index >= 0; index--) {
|
|
539
|
-
const result = callback(value[index], index);
|
|
540
|
-
if (result != null) {
|
|
541
|
-
return result;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
return null;
|
|
545
|
-
}
|
|
546
|
-
function* items(collection) {
|
|
547
|
-
for (let i = 0; i < collection.length; i++) {
|
|
548
|
-
const item = collection.item(i);
|
|
549
|
-
if (item !== null) {
|
|
550
|
-
yield item;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
function nodeList(list) {
|
|
555
|
-
return {
|
|
556
|
-
*[Symbol.iterator]() {
|
|
557
|
-
for (let i = 0; i < list.length; i++) {
|
|
558
|
-
const node = list.item(i);
|
|
559
|
-
if (node !== null) {
|
|
560
|
-
yield node;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
};
|
|
532
|
+
/* @__PURE__ */ new Set([
|
|
533
|
+
"combobox",
|
|
534
|
+
"grid",
|
|
535
|
+
"gridcell",
|
|
536
|
+
"listbox",
|
|
537
|
+
"radiogroup",
|
|
538
|
+
"slider",
|
|
539
|
+
"spinbutton",
|
|
540
|
+
"textbox",
|
|
541
|
+
"tree",
|
|
542
|
+
"treegrid"
|
|
543
|
+
])
|
|
544
|
+
],
|
|
545
|
+
[
|
|
546
|
+
"aria-required",
|
|
547
|
+
/* @__PURE__ */ new Set([
|
|
548
|
+
"combobox",
|
|
549
|
+
"gridcell",
|
|
550
|
+
"listbox",
|
|
551
|
+
"radiogroup",
|
|
552
|
+
"spinbutton",
|
|
553
|
+
"textbox",
|
|
554
|
+
"tree",
|
|
555
|
+
"treegrid"
|
|
556
|
+
])
|
|
557
|
+
],
|
|
558
|
+
["aria-rowcount", /* @__PURE__ */ new Set(["grid", "table", "treegrid"])],
|
|
559
|
+
["aria-rowindex", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "row", "rowheader"])],
|
|
560
|
+
["aria-rowspan", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "rowheader"])],
|
|
561
|
+
[
|
|
562
|
+
"aria-selected",
|
|
563
|
+
/* @__PURE__ */ new Set(["columnheader", "gridcell", "option", "row", "rowheader", "tab", "treeitem"])
|
|
564
|
+
],
|
|
565
|
+
[
|
|
566
|
+
"aria-setsize",
|
|
567
|
+
/* @__PURE__ */ new Set([
|
|
568
|
+
"article",
|
|
569
|
+
"listitem",
|
|
570
|
+
"menuitem",
|
|
571
|
+
"menuitemcheckbox",
|
|
572
|
+
"menuitemradio",
|
|
573
|
+
"option",
|
|
574
|
+
"radio",
|
|
575
|
+
"row",
|
|
576
|
+
"tab"
|
|
577
|
+
])
|
|
578
|
+
],
|
|
579
|
+
["aria-sort", /* @__PURE__ */ new Set(["columnheader", "rowheader"])],
|
|
580
|
+
[
|
|
581
|
+
"aria-valuemax",
|
|
582
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
583
|
+
],
|
|
584
|
+
[
|
|
585
|
+
"aria-valuemin",
|
|
586
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
587
|
+
],
|
|
588
|
+
[
|
|
589
|
+
"aria-valuenow",
|
|
590
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
591
|
+
],
|
|
592
|
+
[
|
|
593
|
+
"aria-valuetext",
|
|
594
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
595
|
+
]
|
|
596
|
+
]);
|
|
597
|
+
|
|
598
|
+
// ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
|
|
599
|
+
function isGlobalAriaAttribute(attr) {
|
|
600
|
+
return GLOBAL_ARIA_ATTRIBUTES.has(attr);
|
|
565
601
|
}
|
|
566
|
-
function
|
|
567
|
-
|
|
602
|
+
function isAriaAttributeValidForRole(attr, role) {
|
|
603
|
+
const allowedRoles = ROLE_RESTRICTED_ATTRIBUTES.get(attr);
|
|
604
|
+
if (isUndefined(allowedRoles)) return true;
|
|
605
|
+
if (isUndefined(role)) return false;
|
|
606
|
+
return allowedRoles.has(role);
|
|
568
607
|
}
|
|
569
|
-
|
|
570
|
-
|
|
608
|
+
|
|
609
|
+
// ../../lib/primitive/src/guards/aria/is-aria-role.ts
|
|
610
|
+
function isStrongImplicitRole(tag) {
|
|
611
|
+
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
612
|
+
return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
571
613
|
}
|
|
572
|
-
function
|
|
573
|
-
|
|
614
|
+
function isStandaloneTag(tag) {
|
|
615
|
+
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
616
|
+
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
574
617
|
}
|
|
575
|
-
function
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
yield [key, object[key]];
|
|
579
|
-
}
|
|
618
|
+
function getInputImplicitRole(type) {
|
|
619
|
+
if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
|
|
620
|
+
return INPUT_TYPE_ROLE_MAP[type];
|
|
580
621
|
}
|
|
581
|
-
function
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
622
|
+
function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
|
|
623
|
+
const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
|
|
624
|
+
if (!isNamed) return void 0;
|
|
625
|
+
if (tag === "section") return "region";
|
|
626
|
+
if (tag === "form") return "form";
|
|
627
|
+
return void 0;
|
|
585
628
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
629
|
+
|
|
630
|
+
// ../../lib/primitive/src/guards/aria/is-known-aria-role.ts
|
|
631
|
+
function isKnownAriaRole(value) {
|
|
632
|
+
return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
|
|
590
633
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
634
|
+
|
|
635
|
+
// ../../lib/primitive/src/guards/children/component-id.ts
|
|
636
|
+
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
|
|
637
|
+
|
|
638
|
+
// ../../lib/primitive/src/guards/children/is-tag.ts
|
|
639
|
+
function getAsProp(child) {
|
|
640
|
+
if (!isObject(child) || !("props" in child)) return void 0;
|
|
641
|
+
const props = child.props;
|
|
642
|
+
if (!isObject(props)) return void 0;
|
|
643
|
+
const as = props.as;
|
|
644
|
+
return isString(as) && as !== "" ? as : void 0;
|
|
597
645
|
}
|
|
598
|
-
function
|
|
599
|
-
|
|
600
|
-
|
|
646
|
+
function getTag(child) {
|
|
647
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
648
|
+
const t = child.type;
|
|
649
|
+
if (isString(t)) return t;
|
|
650
|
+
if (typeof t === "function" || isObject(t)) {
|
|
651
|
+
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
652
|
+
if (!isString(defaultTag)) return void 0;
|
|
653
|
+
return getAsProp(child) ?? defaultTag;
|
|
601
654
|
}
|
|
655
|
+
return void 0;
|
|
602
656
|
}
|
|
603
|
-
function
|
|
604
|
-
|
|
605
|
-
|
|
657
|
+
function isTag(...args) {
|
|
658
|
+
if (isString(args[0])) {
|
|
659
|
+
const set3 = new Set(args);
|
|
660
|
+
return (child2) => {
|
|
661
|
+
const tag2 = getTag(child2);
|
|
662
|
+
return tag2 !== void 0 && set3.has(tag2);
|
|
663
|
+
};
|
|
606
664
|
}
|
|
665
|
+
const [child, ...tags] = args;
|
|
666
|
+
const set2 = new Set(tags);
|
|
667
|
+
const tag = getTag(child);
|
|
668
|
+
return tag !== void 0 && set2.has(tag);
|
|
607
669
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
670
|
+
|
|
671
|
+
// ../../lib/adapter-utils/src/runtime/apply-display-name.ts
|
|
672
|
+
function applyDisplayName(component, name) {
|
|
673
|
+
Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
|
|
612
674
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
675
|
+
|
|
676
|
+
// ../../lib/adapter-utils/src/runtime/define-component.ts
|
|
677
|
+
function defineContractComponent(options) {
|
|
678
|
+
return (factory) => factory(options);
|
|
617
679
|
}
|
|
618
|
-
var iterate = Object.freeze({
|
|
619
|
-
entries,
|
|
620
|
-
filter,
|
|
621
|
-
find,
|
|
622
|
-
findLast,
|
|
623
|
-
forEach,
|
|
624
|
-
forEachEntry,
|
|
625
|
-
forEachKey,
|
|
626
|
-
forEachSet,
|
|
627
|
-
forEachValue,
|
|
628
|
-
items,
|
|
629
|
-
keys,
|
|
630
|
-
map,
|
|
631
|
-
mapEntries,
|
|
632
|
-
mapValues,
|
|
633
|
-
nodeList,
|
|
634
|
-
reduce,
|
|
635
|
-
collect,
|
|
636
|
-
set,
|
|
637
|
-
some,
|
|
638
|
-
every,
|
|
639
|
-
values
|
|
640
|
-
});
|
|
641
680
|
|
|
642
|
-
// ../../lib/
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
this.#maxSize = maxSize;
|
|
651
|
-
}
|
|
652
|
-
get(key) {
|
|
653
|
-
if (!this.#store.has(key)) return void 0;
|
|
654
|
-
const value = this.#store.get(key);
|
|
655
|
-
this.#store.delete(key);
|
|
656
|
-
this.#store.set(key, value);
|
|
657
|
-
return value;
|
|
658
|
-
}
|
|
659
|
-
set(key, value) {
|
|
660
|
-
this.#store.delete(key);
|
|
661
|
-
this.#store.set(key, value);
|
|
662
|
-
if (this.#store.size > this.#maxSize) {
|
|
663
|
-
const lru = this.#store.keys().next().value;
|
|
664
|
-
if (lru !== void 0) this.#store.delete(lru);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
has(key) {
|
|
668
|
-
return this.#store.has(key);
|
|
669
|
-
}
|
|
670
|
-
delete(key) {
|
|
671
|
-
return this.#store.delete(key);
|
|
672
|
-
}
|
|
673
|
-
get size() {
|
|
674
|
-
return this.#store.size;
|
|
675
|
-
}
|
|
676
|
-
clear() {
|
|
677
|
-
this.#store.clear();
|
|
681
|
+
// ../../lib/contract/src/aria/aria-role-policy.ts
|
|
682
|
+
function getImplicitRole(tag, props) {
|
|
683
|
+
if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
|
|
684
|
+
if (tag === "input") return getInputImplicitRole(props?.type);
|
|
685
|
+
if (tag === "img") return props?.alt === "" ? "none" : "img";
|
|
686
|
+
if (tag === "section" || tag === "form") {
|
|
687
|
+
return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
|
|
678
688
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
// ../../lib/primitive/src/utils/merge-props.ts
|
|
682
|
-
function mergeProps(defaultProps, props) {
|
|
683
|
-
return {
|
|
684
|
-
...defaultProps ?? {},
|
|
685
|
-
...props
|
|
686
|
-
};
|
|
689
|
+
return void 0;
|
|
687
690
|
}
|
|
688
691
|
|
|
689
692
|
// ../../lib/contract/src/diagnostics/aria.ts
|
|
@@ -1065,7 +1068,7 @@ var InvariantBase = class {
|
|
|
1065
1068
|
};
|
|
1066
1069
|
|
|
1067
1070
|
// ../../lib/contract/src/aria/polymorphic-validator.ts
|
|
1068
|
-
var
|
|
1071
|
+
var NO_VIOLATIONS = [{ valid: true }];
|
|
1069
1072
|
function isIntrinsicTag(tag) {
|
|
1070
1073
|
return isString(tag);
|
|
1071
1074
|
}
|
|
@@ -1107,17 +1110,20 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1107
1110
|
static #deriveContext(tag, props) {
|
|
1108
1111
|
if (!isIntrinsicTag(tag)) return { proceed: false, result: { props, violations: [] } };
|
|
1109
1112
|
const implicitRole = getImplicitRole(tag, props);
|
|
1110
|
-
const hasRole2 = implicitRole
|
|
1113
|
+
const hasRole2 = isNonNull(implicitRole) || isString(props.role) && props.role.length > 0;
|
|
1111
1114
|
if (!hasRole2) return { proceed: false, result: { props, violations: [] } };
|
|
1112
1115
|
const normalized = _AriaPolicyEngine.#normalizeEmptyRole(tag, props);
|
|
1113
|
-
|
|
1114
|
-
const
|
|
1116
|
+
const workingProps = normalized.normalized ? normalized.result.props : props;
|
|
1117
|
+
const preExistingViolations = normalized.normalized ? normalized.result.violations : [];
|
|
1118
|
+
const effectiveRole = workingProps.role ?? implicitRole;
|
|
1115
1119
|
return {
|
|
1116
1120
|
proceed: true,
|
|
1117
1121
|
tag,
|
|
1118
1122
|
implicitRole,
|
|
1119
1123
|
effectiveRole,
|
|
1120
|
-
|
|
1124
|
+
props: workingProps,
|
|
1125
|
+
preExistingViolations,
|
|
1126
|
+
context: { tag, props: workingProps, implicitRole, effectiveRole }
|
|
1121
1127
|
};
|
|
1122
1128
|
}
|
|
1123
1129
|
static #runRules(rules, context) {
|
|
@@ -1132,7 +1138,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1132
1138
|
} = context;
|
|
1133
1139
|
const { message, attribute, severity } = result;
|
|
1134
1140
|
const resolvedMessage = message ?? result.diagnostic?.message;
|
|
1135
|
-
const fallbackDiag = resolvedMessage
|
|
1141
|
+
const fallbackDiag = isNonNull(resolvedMessage) ? void 0 : AriaDiagnostics.invalidRole(role, tag);
|
|
1136
1142
|
violations.push({
|
|
1137
1143
|
message: resolvedMessage ?? fallbackDiag.message,
|
|
1138
1144
|
tag,
|
|
@@ -1140,8 +1146,8 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1140
1146
|
attribute,
|
|
1141
1147
|
severity,
|
|
1142
1148
|
phase: "evaluate",
|
|
1143
|
-
...result.diagnostic
|
|
1144
|
-
...fallbackDiag
|
|
1149
|
+
...isNonNull(result.diagnostic) && { diagnostic: result.diagnostic },
|
|
1150
|
+
...isNonNull(fallbackDiag) && { diagnostic: fallbackDiag }
|
|
1145
1151
|
});
|
|
1146
1152
|
if (result.fixable) fixes.push(result.fix);
|
|
1147
1153
|
});
|
|
@@ -1149,7 +1155,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1149
1155
|
return { violations, fixes };
|
|
1150
1156
|
}
|
|
1151
1157
|
static #getRules(context) {
|
|
1152
|
-
if (_AriaPolicyEngine.#hasRole(context.props) || context.effectiveRole
|
|
1158
|
+
if (_AriaPolicyEngine.#hasRole(context.props) || isNonNull(context.effectiveRole) && _AriaPolicyEngine.#LIVE_REGION_ROLES.has(context.effectiveRole)) {
|
|
1153
1159
|
return _AriaPolicyEngine.#pipeline;
|
|
1154
1160
|
}
|
|
1155
1161
|
return _AriaPolicyEngine.#implicitOnlyRules;
|
|
@@ -1157,24 +1163,36 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1157
1163
|
static evaluate(tag, props) {
|
|
1158
1164
|
const derived = _AriaPolicyEngine.#deriveContext(tag, props);
|
|
1159
1165
|
if (!derived.proceed) return derived.result;
|
|
1160
|
-
const {
|
|
1166
|
+
const {
|
|
1167
|
+
tag: narrowedTag,
|
|
1168
|
+
implicitRole,
|
|
1169
|
+
context,
|
|
1170
|
+
props: workingProps,
|
|
1171
|
+
preExistingViolations
|
|
1172
|
+
} = derived;
|
|
1161
1173
|
const { violations, fixes } = _AriaPolicyEngine.#runRules(
|
|
1162
1174
|
_AriaPolicyEngine.#getRules(context),
|
|
1163
1175
|
context
|
|
1164
1176
|
);
|
|
1165
|
-
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole,
|
|
1166
|
-
return { props: next, violations };
|
|
1177
|
+
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole, workingProps, fixes);
|
|
1178
|
+
return { props: next, violations: [...preExistingViolations, ...violations] };
|
|
1167
1179
|
}
|
|
1168
1180
|
static #evaluateWithRules(tag, props, extraRules) {
|
|
1169
1181
|
const derived = _AriaPolicyEngine.#deriveContext(tag, props);
|
|
1170
1182
|
if (!derived.proceed) return derived.result;
|
|
1171
|
-
const {
|
|
1183
|
+
const {
|
|
1184
|
+
tag: narrowedTag,
|
|
1185
|
+
implicitRole,
|
|
1186
|
+
context,
|
|
1187
|
+
props: workingProps,
|
|
1188
|
+
preExistingViolations
|
|
1189
|
+
} = derived;
|
|
1172
1190
|
const { violations, fixes } = _AriaPolicyEngine.#runRules(
|
|
1173
1191
|
[..._AriaPolicyEngine.#getRules(context), ...extraRules],
|
|
1174
1192
|
context
|
|
1175
1193
|
);
|
|
1176
|
-
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole,
|
|
1177
|
-
return { props: next, violations };
|
|
1194
|
+
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole, workingProps, fixes);
|
|
1195
|
+
return { props: next, violations: [...preExistingViolations, ...violations] };
|
|
1178
1196
|
}
|
|
1179
1197
|
report(violations) {
|
|
1180
1198
|
iterate.forEach(violations, (v) => {
|
|
@@ -1183,12 +1201,12 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1183
1201
|
else this.warn(d);
|
|
1184
1202
|
});
|
|
1185
1203
|
}
|
|
1186
|
-
// Cache key covers only the aria-relevant subset of props (tag + role + aria-* attrs)
|
|
1187
|
-
// Non-aria props (className, onClick, etc.) do
|
|
1188
|
-
// so cache hits survive re-renders
|
|
1189
|
-
//
|
|
1190
|
-
//
|
|
1191
|
-
//
|
|
1204
|
+
// Cache key covers only the aria-relevant subset of props (tag + role + aria-* attrs) —
|
|
1205
|
+
// exactly what the built-in pipeline reads. Non-aria props (className, onClick, etc.) do
|
|
1206
|
+
// not affect built-in ARIA decisions and are excluded so cache hits survive re-renders
|
|
1207
|
+
// that only change non-aria props. This key alone is unsound for #extraRules, which may
|
|
1208
|
+
// read arbitrary props outside this set — validate() extends it with #extraRulesKeySuffix,
|
|
1209
|
+
// or bypasses the cache, to account for that.
|
|
1192
1210
|
static #createPlanKey(tag, props) {
|
|
1193
1211
|
if (!isIntrinsicTag(tag)) return null;
|
|
1194
1212
|
const parts = [tag];
|
|
@@ -1204,6 +1222,23 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1204
1222
|
if (ariaEntries.length > 0) parts.push(...ariaEntries.sort());
|
|
1205
1223
|
return parts.join("|");
|
|
1206
1224
|
}
|
|
1225
|
+
// Extends the base cache key with the props each extra rule declares it reads (`readsProps`).
|
|
1226
|
+
// Returns null — meaning "don't cache" — if any extra rule omits `readsProps` (it may read
|
|
1227
|
+
// arbitrary props the key can't account for) or if a declared prop's value isn't a primitive
|
|
1228
|
+
// (object/array identity isn't stably representable in a string key).
|
|
1229
|
+
static #extraRulesKeySuffix(extraRules, props) {
|
|
1230
|
+
const parts = [];
|
|
1231
|
+
for (const rule of extraRules) {
|
|
1232
|
+
const readsProps = rule.readsProps;
|
|
1233
|
+
if (!isNonNull(readsProps)) return null;
|
|
1234
|
+
for (const propKey of readsProps) {
|
|
1235
|
+
const v = props[propKey];
|
|
1236
|
+
if (v !== void 0 && !isString(v) && !isNumber(v) && typeof v !== "boolean") return null;
|
|
1237
|
+
parts.push(`x:${propKey}:${String(v)}`);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return parts.sort().join("|");
|
|
1241
|
+
}
|
|
1207
1242
|
static #computePlan(inputProps, resultProps) {
|
|
1208
1243
|
const removals = /* @__PURE__ */ new Set();
|
|
1209
1244
|
const updates = {};
|
|
@@ -1227,7 +1262,12 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1227
1262
|
return next;
|
|
1228
1263
|
}
|
|
1229
1264
|
validate(tag, props) {
|
|
1230
|
-
const
|
|
1265
|
+
const baseKey = _AriaPolicyEngine.#createPlanKey(tag, props);
|
|
1266
|
+
let key = baseKey;
|
|
1267
|
+
if (this.#extraRules.length > 0) {
|
|
1268
|
+
const suffix = _AriaPolicyEngine.#extraRulesKeySuffix(this.#extraRules, props);
|
|
1269
|
+
key = isNonNull(baseKey) && isNonNull(suffix) ? `${baseKey}|${suffix}` : null;
|
|
1270
|
+
}
|
|
1231
1271
|
if (!isNull(key)) {
|
|
1232
1272
|
const cached = this.#planCache.get(key);
|
|
1233
1273
|
if (cached !== void 0) {
|
|
@@ -1317,7 +1357,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1317
1357
|
implicitRole
|
|
1318
1358
|
}) {
|
|
1319
1359
|
const role = props.role;
|
|
1320
|
-
if (!implicitRole || !role || role === implicitRole) return
|
|
1360
|
+
if (!implicitRole || !role || role === implicitRole) return NO_VIOLATIONS;
|
|
1321
1361
|
if (isStrongImplicitRole(tag) && role === "region") {
|
|
1322
1362
|
return [
|
|
1323
1363
|
{
|
|
@@ -1329,11 +1369,11 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1329
1369
|
}
|
|
1330
1370
|
];
|
|
1331
1371
|
}
|
|
1332
|
-
return
|
|
1372
|
+
return NO_VIOLATIONS;
|
|
1333
1373
|
}
|
|
1334
1374
|
static #checkRedundantRole({ tag, props, implicitRole }) {
|
|
1335
1375
|
const role = props.role;
|
|
1336
|
-
if (!implicitRole || !role || role !== implicitRole) return
|
|
1376
|
+
if (!implicitRole || !role || role !== implicitRole) return NO_VIOLATIONS;
|
|
1337
1377
|
return [
|
|
1338
1378
|
{
|
|
1339
1379
|
valid: false,
|
|
@@ -1346,8 +1386,8 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1346
1386
|
}
|
|
1347
1387
|
static #checkStandaloneRegion({ tag, props, implicitRole }) {
|
|
1348
1388
|
const role = props.role;
|
|
1349
|
-
if (role !== "region") return
|
|
1350
|
-
if (!isStandaloneTag(tag)) return
|
|
1389
|
+
if (role !== "region") return NO_VIOLATIONS;
|
|
1390
|
+
if (!isStandaloneTag(tag)) return NO_VIOLATIONS;
|
|
1351
1391
|
return [
|
|
1352
1392
|
{
|
|
1353
1393
|
valid: false,
|
|
@@ -1363,7 +1403,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1363
1403
|
props,
|
|
1364
1404
|
effectiveRole
|
|
1365
1405
|
}) {
|
|
1366
|
-
if (effectiveRole === "none" || effectiveRole === "presentation") return
|
|
1406
|
+
if (effectiveRole === "none" || effectiveRole === "presentation") return NO_VIOLATIONS;
|
|
1367
1407
|
const results = [];
|
|
1368
1408
|
iterate.forEachEntry(props, (key) => {
|
|
1369
1409
|
if (!key.startsWith("aria-")) return;
|
|
@@ -1481,12 +1521,12 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1481
1521
|
}
|
|
1482
1522
|
}
|
|
1483
1523
|
static #checkAriaAttributeValues({ props, effectiveRole }) {
|
|
1484
|
-
if (effectiveRole === "none" || effectiveRole === "presentation") return
|
|
1524
|
+
if (effectiveRole === "none" || effectiveRole === "presentation") return NO_VIOLATIONS;
|
|
1485
1525
|
const results = [];
|
|
1486
1526
|
iterate.forEachEntry(props, (key, value) => {
|
|
1487
1527
|
if (!key.startsWith("aria-")) return;
|
|
1488
1528
|
const type = _AriaPolicyEngine.#ARIA_VALUE_TYPES.get(key);
|
|
1489
|
-
if (type
|
|
1529
|
+
if (!isNonNull(type)) return;
|
|
1490
1530
|
if (_AriaPolicyEngine.#isValidAriaValue(value, type)) return;
|
|
1491
1531
|
results.push({
|
|
1492
1532
|
valid: false,
|
|
@@ -1517,13 +1557,13 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1517
1557
|
props,
|
|
1518
1558
|
effectiveRole
|
|
1519
1559
|
}) {
|
|
1520
|
-
if (effectiveRole === "none" || effectiveRole === "presentation") return
|
|
1560
|
+
if (effectiveRole === "none" || effectiveRole === "presentation") return NO_VIOLATIONS;
|
|
1521
1561
|
const implicitLevel = _AriaPolicyEngine.#HEADING_IMPLICIT_LEVELS.get(tag);
|
|
1522
|
-
if (implicitLevel
|
|
1562
|
+
if (!isNonNull(implicitLevel)) return NO_VIOLATIONS;
|
|
1523
1563
|
const raw = props["aria-level"];
|
|
1524
|
-
if (raw
|
|
1564
|
+
if (!isNonNull(raw)) return NO_VIOLATIONS;
|
|
1525
1565
|
const n = typeof raw === "number" ? raw : typeof raw === "string" ? parseInt(raw, 10) : NaN;
|
|
1526
|
-
if (!Number.isFinite(n) || n !== implicitLevel) return
|
|
1566
|
+
if (!Number.isFinite(n) || n !== implicitLevel) return NO_VIOLATIONS;
|
|
1527
1567
|
return [
|
|
1528
1568
|
{
|
|
1529
1569
|
valid: false,
|
|
@@ -1546,9 +1586,10 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1546
1586
|
props,
|
|
1547
1587
|
effectiveRole
|
|
1548
1588
|
}) {
|
|
1549
|
-
if (!effectiveRole || !_AriaPolicyEngine.#NAME_REQUIRED_ROLES.has(effectiveRole))
|
|
1550
|
-
|
|
1551
|
-
if (
|
|
1589
|
+
if (!effectiveRole || !_AriaPolicyEngine.#NAME_REQUIRED_ROLES.has(effectiveRole))
|
|
1590
|
+
return NO_VIOLATIONS;
|
|
1591
|
+
if ("aria-label" in props || "aria-labelledby" in props) return NO_VIOLATIONS;
|
|
1592
|
+
if (tag === "img" && typeof props.alt === "string" && props.alt.length > 0) return NO_VIOLATIONS;
|
|
1552
1593
|
return [
|
|
1553
1594
|
{
|
|
1554
1595
|
valid: false,
|
|
@@ -1571,9 +1612,9 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1571
1612
|
props,
|
|
1572
1613
|
effectiveRole
|
|
1573
1614
|
}) {
|
|
1574
|
-
if (!effectiveRole) return
|
|
1615
|
+
if (!effectiveRole) return NO_VIOLATIONS;
|
|
1575
1616
|
const required = _AriaPolicyEngine.#REQUIRED_PROPERTIES.get(effectiveRole);
|
|
1576
|
-
if (required
|
|
1617
|
+
if (!isNonNull(required)) return NO_VIOLATIONS;
|
|
1577
1618
|
const results = [];
|
|
1578
1619
|
iterate.forEach(required, (attr) => {
|
|
1579
1620
|
if (attr in props) return;
|
|
@@ -1597,12 +1638,12 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1597
1638
|
]);
|
|
1598
1639
|
// WAI-ARIA 1.2 §6.6: aria-hidden="true" must not be placed on focusable elements.
|
|
1599
1640
|
static #checkAriaHiddenOnFocusable({ tag, props }) {
|
|
1600
|
-
if (props["aria-hidden"] !== "true" && props["aria-hidden"] !== true) return
|
|
1641
|
+
if (props["aria-hidden"] !== "true" && props["aria-hidden"] !== true) return NO_VIOLATIONS;
|
|
1601
1642
|
const isInteractive = _AriaPolicyEngine.#INTERACTIVE_TAGS.has(tag);
|
|
1602
1643
|
if (!isInteractive) {
|
|
1603
1644
|
const tabindex = props.tabindex;
|
|
1604
1645
|
const n = typeof tabindex === "number" ? tabindex : typeof tabindex === "string" ? parseInt(tabindex, 10) : NaN;
|
|
1605
|
-
if (!Number.isFinite(n) || n < 0) return
|
|
1646
|
+
if (!Number.isFinite(n) || n < 0) return NO_VIOLATIONS;
|
|
1606
1647
|
}
|
|
1607
1648
|
return [
|
|
1608
1649
|
{
|
|
@@ -1621,7 +1662,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1621
1662
|
props,
|
|
1622
1663
|
effectiveRole
|
|
1623
1664
|
}) {
|
|
1624
|
-
if (effectiveRole !== "none" && effectiveRole !== "presentation") return
|
|
1665
|
+
if (effectiveRole !== "none" && effectiveRole !== "presentation") return NO_VIOLATIONS;
|
|
1625
1666
|
const results = [];
|
|
1626
1667
|
iterate.forEachEntry(props, (key) => {
|
|
1627
1668
|
if (!key.startsWith("aria-")) return;
|
|
@@ -1645,10 +1686,10 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1645
1686
|
["timer", "off"]
|
|
1646
1687
|
]);
|
|
1647
1688
|
static #checkMissingLiveRegion({ effectiveRole, props }) {
|
|
1648
|
-
if (!effectiveRole) return
|
|
1689
|
+
if (!effectiveRole) return NO_VIOLATIONS;
|
|
1649
1690
|
const impliedLive = _AriaPolicyEngine.#LIVE_REGION_ROLES.get(effectiveRole);
|
|
1650
|
-
if (!impliedLive) return
|
|
1651
|
-
if ("aria-live" in props) return
|
|
1691
|
+
if (!impliedLive) return NO_VIOLATIONS;
|
|
1692
|
+
if ("aria-live" in props) return NO_VIOLATIONS;
|
|
1652
1693
|
const injectLive = {
|
|
1653
1694
|
kind: `injectLive:${effectiveRole}`,
|
|
1654
1695
|
apply: (ctx) => ({
|
|
@@ -1668,8 +1709,9 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1668
1709
|
];
|
|
1669
1710
|
}
|
|
1670
1711
|
static #checkMissingAtomic({ effectiveRole, props }) {
|
|
1671
|
-
if (!effectiveRole || !_AriaPolicyEngine.#LIVE_REGION_ROLES.has(effectiveRole))
|
|
1672
|
-
|
|
1712
|
+
if (!effectiveRole || !_AriaPolicyEngine.#LIVE_REGION_ROLES.has(effectiveRole))
|
|
1713
|
+
return NO_VIOLATIONS;
|
|
1714
|
+
if ("aria-atomic" in props) return NO_VIOLATIONS;
|
|
1673
1715
|
return [
|
|
1674
1716
|
{
|
|
1675
1717
|
valid: false,
|
|
@@ -1693,8 +1735,8 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1693
1735
|
};
|
|
1694
1736
|
static #checkInvalidAriaRelevant({ props }) {
|
|
1695
1737
|
const relevant = props["aria-relevant"];
|
|
1696
|
-
if (relevant === void 0) return
|
|
1697
|
-
if (typeof relevant !== "string") return
|
|
1738
|
+
if (relevant === void 0) return NO_VIOLATIONS;
|
|
1739
|
+
if (typeof relevant !== "string") return NO_VIOLATIONS;
|
|
1698
1740
|
const tokens = relevant.trim().split(/\s+/);
|
|
1699
1741
|
const invalid = tokens.filter((t) => !_AriaPolicyEngine.#VALID_RELEVANT_TOKENS.has(t));
|
|
1700
1742
|
if (invalid.length > 0) {
|
|
@@ -1721,7 +1763,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1721
1763
|
}
|
|
1722
1764
|
];
|
|
1723
1765
|
}
|
|
1724
|
-
return
|
|
1766
|
+
return NO_VIOLATIONS;
|
|
1725
1767
|
}
|
|
1726
1768
|
};
|
|
1727
1769
|
|
|
@@ -2422,7 +2464,7 @@ function createClassPipeline(resolved) {
|
|
|
2422
2464
|
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
2423
2465
|
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
2424
2466
|
if (!className)
|
|
2425
|
-
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
2467
|
+
return (staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses) || void 0;
|
|
2426
2468
|
return cn(staticClasses, variantClasses, className);
|
|
2427
2469
|
};
|
|
2428
2470
|
}
|
|
@@ -2462,7 +2504,10 @@ function resolveFactoryOptions(options = {}) {
|
|
|
2462
2504
|
const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
|
|
2463
2505
|
return Object.freeze({
|
|
2464
2506
|
defaultTag: options.tag ?? "div",
|
|
2465
|
-
diagnostics: resolveDiagnostics(
|
|
2507
|
+
diagnostics: resolveDiagnostics(
|
|
2508
|
+
enforcement?.diagnostics,
|
|
2509
|
+
options.diagnostics ?? silentDiagnostics
|
|
2510
|
+
),
|
|
2466
2511
|
variantKeys,
|
|
2467
2512
|
...whenDefined("displayName", options.name),
|
|
2468
2513
|
...whenDefined("defaultProps", options.defaults),
|
|
@@ -2633,7 +2678,7 @@ function createPolymorphic2(options = {}) {
|
|
|
2633
2678
|
if (process.env.NODE_ENV !== "production") {
|
|
2634
2679
|
validateRenderProps(resolved.diagnostics, resolved, props, recipe);
|
|
2635
2680
|
}
|
|
2636
|
-
return classPipeline(tag, props, className, recipe);
|
|
2681
|
+
return classPipeline(tag, props, className, recipe) || void 0;
|
|
2637
2682
|
},
|
|
2638
2683
|
resolveAria(tag, props) {
|
|
2639
2684
|
return resolveAriaFn(tag, props);
|