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/preact/index.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
// ../../lib/primitive/src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (value === null || typeof value !== "object") return false;
|
|
7
|
-
return excludeArrays ? !Array.isArray(value) : true;
|
|
8
|
-
}
|
|
9
|
-
function isString(value) {
|
|
10
|
-
return typeof value === "string";
|
|
11
|
-
}
|
|
12
|
-
function isNumber(value) {
|
|
13
|
-
return typeof value === "number";
|
|
1
|
+
// ../../lib/primitive/src/tag/resolve-tag.ts
|
|
2
|
+
function makeResolveTag(defaultTag) {
|
|
3
|
+
return function tag(as) {
|
|
4
|
+
return as ?? defaultTag;
|
|
5
|
+
};
|
|
14
6
|
}
|
|
15
7
|
|
|
8
|
+
// ../../lib/primitive/src/merge/constants.ts
|
|
9
|
+
var EVENT_HANDLER_RE = /^on[A-Z]/;
|
|
10
|
+
|
|
11
|
+
// ../../lib/primitive/src/rule/rule-brand.ts
|
|
12
|
+
var RULE_BRAND = /* @__PURE__ */ Symbol("praxis-kit/dynamic-rule");
|
|
13
|
+
|
|
16
14
|
// ../../lib/primitive/src/guards/foundational/is-defined.ts
|
|
17
15
|
function isUndefined(value) {
|
|
18
16
|
return value === void 0;
|
|
@@ -22,72 +20,282 @@ function isUndefined(value) {
|
|
|
22
20
|
function isNull(value) {
|
|
23
21
|
return value === null;
|
|
24
22
|
}
|
|
23
|
+
function isNonNull(value) {
|
|
24
|
+
return value != null;
|
|
25
|
+
}
|
|
25
26
|
|
|
26
|
-
// ../../lib/primitive/src/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
// ../../lib/primitive/src/utils/type-guards.ts
|
|
28
|
+
function isObject(value, excludeArrays = false) {
|
|
29
|
+
if (value === null || typeof value !== "object") return false;
|
|
30
|
+
return excludeArrays ? !Array.isArray(value) : true;
|
|
31
|
+
}
|
|
32
|
+
function isString(value) {
|
|
33
|
+
return typeof value === "string";
|
|
34
|
+
}
|
|
35
|
+
function isNumber(value) {
|
|
36
|
+
return typeof value === "number";
|
|
37
|
+
}
|
|
30
38
|
function isFunction(value) {
|
|
31
39
|
return typeof value === "function";
|
|
32
40
|
}
|
|
33
41
|
function isPlainObject(value) {
|
|
34
|
-
if (!isObject(value)) return false;
|
|
42
|
+
if (!isObject(value, true)) return false;
|
|
35
43
|
const proto = Object.getPrototypeOf(value);
|
|
36
44
|
return proto === Object.prototype || proto === null;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
// ../../lib/primitive/src/
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
const props = child.props;
|
|
43
|
-
if (!isObject(props)) return void 0;
|
|
44
|
-
const as = props.as;
|
|
45
|
-
return isString(as) && as !== "" ? as : void 0;
|
|
47
|
+
// ../../lib/primitive/src/rule/is-dynamic-rule.ts
|
|
48
|
+
function isDynamicRule(rule) {
|
|
49
|
+
return isObject(rule, true) && rule[RULE_BRAND] === true;
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (typeof t === "function" || isObject(t)) {
|
|
52
|
-
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
53
|
-
if (!isString(defaultTag)) return void 0;
|
|
54
|
-
return getAsProp(child) ?? defaultTag;
|
|
55
|
-
}
|
|
56
|
-
return void 0;
|
|
51
|
+
|
|
52
|
+
// ../../lib/primitive/src/rule/resolve-rule.ts
|
|
53
|
+
function resolveRule(rule, context) {
|
|
54
|
+
return isDynamicRule(rule) ? rule.resolve(context) : rule;
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const tag2 = getTag(child2);
|
|
63
|
-
return tag2 !== void 0 && set3.has(tag2);
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
const [child, ...tags] = args;
|
|
67
|
-
const set2 = new Set(tags);
|
|
68
|
-
const tag = getTag(child);
|
|
69
|
-
return tag !== void 0 && set2.has(tag);
|
|
56
|
+
|
|
57
|
+
// ../../lib/primitive/src/utils/assert-never.ts
|
|
58
|
+
function assertNever(value) {
|
|
59
|
+
throw new Error(`Unexpected value: ${String(value)}`);
|
|
70
60
|
}
|
|
71
61
|
|
|
72
|
-
// ../../
|
|
73
|
-
import {
|
|
62
|
+
// ../../lib/primitive/src/utils/cn.ts
|
|
63
|
+
import { clsx } from "clsx";
|
|
64
|
+
function cn(...inputs) {
|
|
65
|
+
return clsx(...inputs);
|
|
66
|
+
}
|
|
74
67
|
|
|
75
|
-
// ../../lib/
|
|
76
|
-
function
|
|
77
|
-
|
|
68
|
+
// ../../lib/primitive/src/utils/iterate.ts
|
|
69
|
+
function find(iterable, callback) {
|
|
70
|
+
for (const value of iterable) {
|
|
71
|
+
const result = callback(value);
|
|
72
|
+
if (result != null) {
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
78
77
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
78
|
+
function some(iterable, predicate) {
|
|
79
|
+
for (const value of iterable) {
|
|
80
|
+
if (predicate(value)) return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
function every(iterable, predicate) {
|
|
85
|
+
let index = 0;
|
|
86
|
+
for (const value of iterable) {
|
|
87
|
+
if (!predicate(value, index++)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
function* filter(iterable, predicate) {
|
|
94
|
+
let index = 0;
|
|
95
|
+
for (const value of iterable) {
|
|
96
|
+
if (predicate(value, index++)) {
|
|
97
|
+
yield value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function* map(iterable, callback) {
|
|
102
|
+
let index = 0;
|
|
103
|
+
for (const value of iterable) {
|
|
104
|
+
yield callback(value, index++);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function forEach(iterable, callback) {
|
|
108
|
+
let index = 0;
|
|
109
|
+
for (const value of iterable) {
|
|
110
|
+
callback(value, index++);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function reduce(iterable, initial, callback) {
|
|
114
|
+
let accumulator = initial;
|
|
115
|
+
let index = 0;
|
|
116
|
+
for (const value of iterable) {
|
|
117
|
+
accumulator = callback(accumulator, value, index++);
|
|
118
|
+
}
|
|
119
|
+
return accumulator;
|
|
81
120
|
}
|
|
121
|
+
function collect(iterable, callback) {
|
|
122
|
+
const result = {};
|
|
123
|
+
let index = 0;
|
|
124
|
+
for (const value of iterable) {
|
|
125
|
+
const entry = callback(value, index++);
|
|
126
|
+
if (entry === null) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
result[entry[0]] = entry[1];
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
function findLast(value, callback) {
|
|
134
|
+
for (let index = value.length - 1; index >= 0; index--) {
|
|
135
|
+
const result = callback(value[index], index);
|
|
136
|
+
if (result != null) {
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
function* items(collection) {
|
|
143
|
+
for (let i = 0; i < collection.length; i++) {
|
|
144
|
+
const item = collection.item(i);
|
|
145
|
+
if (item !== null) {
|
|
146
|
+
yield item;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function nodeList(list) {
|
|
151
|
+
return {
|
|
152
|
+
*[Symbol.iterator]() {
|
|
153
|
+
for (let i = 0; i < list.length; i++) {
|
|
154
|
+
const node = list.item(i);
|
|
155
|
+
if (node !== null) {
|
|
156
|
+
yield node;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function mapEntries(m) {
|
|
163
|
+
return m.entries();
|
|
164
|
+
}
|
|
165
|
+
function set(s) {
|
|
166
|
+
return s.values();
|
|
167
|
+
}
|
|
168
|
+
function hasOwn(object, key) {
|
|
169
|
+
return Object.hasOwn(object, key);
|
|
170
|
+
}
|
|
171
|
+
function* entries(object) {
|
|
172
|
+
for (const key in object) {
|
|
173
|
+
if (!hasOwn(object, key)) continue;
|
|
174
|
+
yield [key, object[key]];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function* keys(object) {
|
|
178
|
+
for (const [key] of entries(object)) {
|
|
179
|
+
yield key;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function* values(object) {
|
|
183
|
+
for (const [, value] of entries(object)) {
|
|
184
|
+
yield value;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function mapValues(object, callback) {
|
|
188
|
+
const result = {};
|
|
189
|
+
for (const [key, value] of entries(object)) {
|
|
190
|
+
result[key] = callback(value, key);
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
function forEachEntry(object, callback) {
|
|
195
|
+
for (const [key, value] of entries(object)) {
|
|
196
|
+
callback(key, value);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function forEachKey(object, callback) {
|
|
200
|
+
for (const key of keys(object)) {
|
|
201
|
+
callback(key);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function forEachValue(object, callback) {
|
|
205
|
+
for (const value of values(object)) {
|
|
206
|
+
callback(value);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function forEachSet(s, callback) {
|
|
210
|
+
for (const value of s) {
|
|
211
|
+
callback(value);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
var iterate = Object.freeze({
|
|
215
|
+
entries,
|
|
216
|
+
filter,
|
|
217
|
+
find,
|
|
218
|
+
findLast,
|
|
219
|
+
forEach,
|
|
220
|
+
forEachEntry,
|
|
221
|
+
forEachKey,
|
|
222
|
+
forEachSet,
|
|
223
|
+
forEachValue,
|
|
224
|
+
items,
|
|
225
|
+
keys,
|
|
226
|
+
map,
|
|
227
|
+
mapEntries,
|
|
228
|
+
mapValues,
|
|
229
|
+
nodeList,
|
|
230
|
+
reduce,
|
|
231
|
+
collect,
|
|
232
|
+
set,
|
|
233
|
+
some,
|
|
234
|
+
every,
|
|
235
|
+
values
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// ../../lib/primitive/src/utils/lru-cache.ts
|
|
239
|
+
var LRUCache = class {
|
|
240
|
+
#maxSize;
|
|
241
|
+
#store = /* @__PURE__ */ new Map();
|
|
242
|
+
constructor(maxSize) {
|
|
243
|
+
if (!Number.isInteger(maxSize) || maxSize < 1) {
|
|
244
|
+
throw new RangeError("LRUCache maxSize must be a positive integer.");
|
|
245
|
+
}
|
|
246
|
+
this.#maxSize = maxSize;
|
|
247
|
+
}
|
|
248
|
+
get(key) {
|
|
249
|
+
if (!this.#store.has(key)) return void 0;
|
|
250
|
+
const value = this.#store.get(key);
|
|
251
|
+
this.#store.delete(key);
|
|
252
|
+
this.#store.set(key, value);
|
|
253
|
+
return value;
|
|
254
|
+
}
|
|
255
|
+
set(key, value) {
|
|
256
|
+
this.#store.delete(key);
|
|
257
|
+
this.#store.set(key, value);
|
|
258
|
+
if (this.#store.size > this.#maxSize) {
|
|
259
|
+
const lru = this.#store.keys().next().value;
|
|
260
|
+
if (lru !== void 0) this.#store.delete(lru);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
has(key) {
|
|
264
|
+
return this.#store.has(key);
|
|
265
|
+
}
|
|
266
|
+
delete(key) {
|
|
267
|
+
return this.#store.delete(key);
|
|
268
|
+
}
|
|
269
|
+
get size() {
|
|
270
|
+
return this.#store.size;
|
|
271
|
+
}
|
|
272
|
+
clear() {
|
|
273
|
+
this.#store.clear();
|
|
274
|
+
}
|
|
275
|
+
};
|
|
82
276
|
|
|
83
|
-
// ../../lib/
|
|
84
|
-
function
|
|
85
|
-
|
|
277
|
+
// ../../lib/primitive/src/utils/merge-refs.ts
|
|
278
|
+
function mergeRefsCore(...refs) {
|
|
279
|
+
const resolvedRefs = refs.filter((r) => r != null);
|
|
280
|
+
if (resolvedRefs.length === 0) return null;
|
|
281
|
+
if (resolvedRefs.length === 1) return resolvedRefs[0] ?? null;
|
|
282
|
+
return (value) => {
|
|
283
|
+
iterate.forEach(resolvedRefs, (ref) => {
|
|
284
|
+
if (isFunction(ref)) {
|
|
285
|
+
ref(value);
|
|
286
|
+
} else {
|
|
287
|
+
ref.current = value;
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
};
|
|
86
291
|
}
|
|
87
292
|
|
|
88
|
-
// ../../lib/
|
|
89
|
-
function
|
|
90
|
-
return
|
|
293
|
+
// ../../lib/primitive/src/utils/merge-props.ts
|
|
294
|
+
function mergeProps(defaultProps, props) {
|
|
295
|
+
return {
|
|
296
|
+
...defaultProps ?? {},
|
|
297
|
+
...props
|
|
298
|
+
};
|
|
91
299
|
}
|
|
92
300
|
|
|
93
301
|
// ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
|
|
@@ -369,364 +577,157 @@ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
|
|
|
369
577
|
"listbox",
|
|
370
578
|
"radiogroup",
|
|
371
579
|
"spinbutton",
|
|
372
|
-
"textbox",
|
|
373
|
-
"tree",
|
|
374
|
-
"treegrid"
|
|
375
|
-
])
|
|
376
|
-
],
|
|
377
|
-
["aria-rowcount", /* @__PURE__ */ new Set(["grid", "table", "treegrid"])],
|
|
378
|
-
["aria-rowindex", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "row", "rowheader"])],
|
|
379
|
-
["aria-rowspan", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "rowheader"])],
|
|
380
|
-
[
|
|
381
|
-
"aria-selected",
|
|
382
|
-
/* @__PURE__ */ new Set(["columnheader", "gridcell", "option", "row", "rowheader", "tab", "treeitem"])
|
|
383
|
-
],
|
|
384
|
-
[
|
|
385
|
-
"aria-setsize",
|
|
386
|
-
/* @__PURE__ */ new Set([
|
|
387
|
-
"article",
|
|
388
|
-
"listitem",
|
|
389
|
-
"menuitem",
|
|
390
|
-
"menuitemcheckbox",
|
|
391
|
-
"menuitemradio",
|
|
392
|
-
"option",
|
|
393
|
-
"radio",
|
|
394
|
-
"row",
|
|
395
|
-
"tab"
|
|
396
|
-
])
|
|
397
|
-
],
|
|
398
|
-
["aria-sort", /* @__PURE__ */ new Set(["columnheader", "rowheader"])],
|
|
399
|
-
[
|
|
400
|
-
"aria-valuemax",
|
|
401
|
-
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
402
|
-
],
|
|
403
|
-
[
|
|
404
|
-
"aria-valuemin",
|
|
405
|
-
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
406
|
-
],
|
|
407
|
-
[
|
|
408
|
-
"aria-valuenow",
|
|
409
|
-
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
410
|
-
],
|
|
411
|
-
[
|
|
412
|
-
"aria-valuetext",
|
|
413
|
-
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
414
|
-
]
|
|
415
|
-
]);
|
|
416
|
-
|
|
417
|
-
// ../../lib/primitive/src/
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
function
|
|
422
|
-
|
|
423
|
-
if (isUndefined(allowedRoles)) return true;
|
|
424
|
-
if (isUndefined(role)) return false;
|
|
425
|
-
return allowedRoles.has(role);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// ../../lib/primitive/src/constants/primitive/slot-name.ts
|
|
429
|
-
var SLOT_NAME = "Slot";
|
|
430
|
-
|
|
431
|
-
// ../../lib/primitive/src/guards/aria/is-aria-role.ts
|
|
432
|
-
function isStrongImplicitRole(tag) {
|
|
433
|
-
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
434
|
-
return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
435
|
-
}
|
|
436
|
-
function isStandaloneTag(tag) {
|
|
437
|
-
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
438
|
-
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
439
|
-
}
|
|
440
|
-
function getInputImplicitRole(type) {
|
|
441
|
-
if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
|
|
442
|
-
return INPUT_TYPE_ROLE_MAP[type];
|
|
443
|
-
}
|
|
444
|
-
function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
|
|
445
|
-
const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
|
|
446
|
-
if (!isNamed) return void 0;
|
|
447
|
-
if (tag === "section") return "region";
|
|
448
|
-
if (tag === "form") return "form";
|
|
449
|
-
return void 0;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// ../../lib/primitive/src/guards/aria/is-known-aria-role.ts
|
|
453
|
-
function isKnownAriaRole(value) {
|
|
454
|
-
return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
// ../../lib/contract/src/aria/aria-role-policy.ts
|
|
458
|
-
function getImplicitRole(tag, props) {
|
|
459
|
-
if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
|
|
460
|
-
if (tag === "input") return getInputImplicitRole(props?.type);
|
|
461
|
-
if (tag === "img") return props?.alt === "" ? "none" : "img";
|
|
462
|
-
if (tag === "section" || tag === "form") {
|
|
463
|
-
return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
|
|
464
|
-
}
|
|
465
|
-
return void 0;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// ../../lib/primitive/src/tag/resolve-tag.ts
|
|
469
|
-
function makeResolveTag(defaultTag) {
|
|
470
|
-
return function tag(as) {
|
|
471
|
-
return as ?? defaultTag;
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// ../../lib/primitive/src/rule/rule-brand.ts
|
|
476
|
-
var RULE_BRAND = /* @__PURE__ */ Symbol("praxis-kit/dynamic-rule");
|
|
477
|
-
|
|
478
|
-
// ../../lib/primitive/src/rule/is-dynamic-rule.ts
|
|
479
|
-
function isDynamicRule(rule) {
|
|
480
|
-
return isObject(rule, true) && rule[RULE_BRAND] === true;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// ../../lib/primitive/src/rule/resolve-rule.ts
|
|
484
|
-
function resolveRule(rule, context) {
|
|
485
|
-
return isDynamicRule(rule) ? rule.resolve(context) : rule;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// ../../lib/primitive/src/utils/assert-never.ts
|
|
489
|
-
function assertNever(value) {
|
|
490
|
-
throw new Error(`Unexpected value: ${String(value)}`);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
// ../../lib/primitive/src/utils/cn.ts
|
|
494
|
-
import { clsx } from "clsx";
|
|
495
|
-
function cn(...inputs) {
|
|
496
|
-
return clsx(...inputs);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// ../../lib/primitive/src/utils/iterate.ts
|
|
500
|
-
function find(iterable, callback) {
|
|
501
|
-
for (const value of iterable) {
|
|
502
|
-
const result = callback(value);
|
|
503
|
-
if (result != null) {
|
|
504
|
-
return result;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
return null;
|
|
508
|
-
}
|
|
509
|
-
function some(iterable, predicate) {
|
|
510
|
-
for (const value of iterable) {
|
|
511
|
-
if (predicate(value)) return true;
|
|
512
|
-
}
|
|
513
|
-
return false;
|
|
514
|
-
}
|
|
515
|
-
function every(iterable, predicate) {
|
|
516
|
-
let index = 0;
|
|
517
|
-
for (const value of iterable) {
|
|
518
|
-
if (!predicate(value, index++)) {
|
|
519
|
-
return false;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return true;
|
|
523
|
-
}
|
|
524
|
-
function* filter(iterable, predicate) {
|
|
525
|
-
let index = 0;
|
|
526
|
-
for (const value of iterable) {
|
|
527
|
-
if (predicate(value, index++)) {
|
|
528
|
-
yield value;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
function* map(iterable, callback) {
|
|
533
|
-
let index = 0;
|
|
534
|
-
for (const value of iterable) {
|
|
535
|
-
yield callback(value, index++);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
function forEach(iterable, callback) {
|
|
539
|
-
let index = 0;
|
|
540
|
-
for (const value of iterable) {
|
|
541
|
-
callback(value, index++);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
function reduce(iterable, initial, callback) {
|
|
545
|
-
let accumulator = initial;
|
|
546
|
-
let index = 0;
|
|
547
|
-
for (const value of iterable) {
|
|
548
|
-
accumulator = callback(accumulator, value, index++);
|
|
549
|
-
}
|
|
550
|
-
return accumulator;
|
|
551
|
-
}
|
|
552
|
-
function collect(iterable, callback) {
|
|
553
|
-
const result = {};
|
|
554
|
-
let index = 0;
|
|
555
|
-
for (const value of iterable) {
|
|
556
|
-
const entry = callback(value, index++);
|
|
557
|
-
if (entry === null) {
|
|
558
|
-
return null;
|
|
559
|
-
}
|
|
560
|
-
result[entry[0]] = entry[1];
|
|
561
|
-
}
|
|
562
|
-
return result;
|
|
563
|
-
}
|
|
564
|
-
function findLast(value, callback) {
|
|
565
|
-
for (let index = value.length - 1; index >= 0; index--) {
|
|
566
|
-
const result = callback(value[index], index);
|
|
567
|
-
if (result != null) {
|
|
568
|
-
return result;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
return null;
|
|
572
|
-
}
|
|
573
|
-
function* items(collection) {
|
|
574
|
-
for (let i = 0; i < collection.length; i++) {
|
|
575
|
-
const item = collection.item(i);
|
|
576
|
-
if (item !== null) {
|
|
577
|
-
yield item;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
function nodeList(list) {
|
|
582
|
-
return {
|
|
583
|
-
*[Symbol.iterator]() {
|
|
584
|
-
for (let i = 0; i < list.length; i++) {
|
|
585
|
-
const node = list.item(i);
|
|
586
|
-
if (node !== null) {
|
|
587
|
-
yield node;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
};
|
|
580
|
+
"textbox",
|
|
581
|
+
"tree",
|
|
582
|
+
"treegrid"
|
|
583
|
+
])
|
|
584
|
+
],
|
|
585
|
+
["aria-rowcount", /* @__PURE__ */ new Set(["grid", "table", "treegrid"])],
|
|
586
|
+
["aria-rowindex", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "row", "rowheader"])],
|
|
587
|
+
["aria-rowspan", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "rowheader"])],
|
|
588
|
+
[
|
|
589
|
+
"aria-selected",
|
|
590
|
+
/* @__PURE__ */ new Set(["columnheader", "gridcell", "option", "row", "rowheader", "tab", "treeitem"])
|
|
591
|
+
],
|
|
592
|
+
[
|
|
593
|
+
"aria-setsize",
|
|
594
|
+
/* @__PURE__ */ new Set([
|
|
595
|
+
"article",
|
|
596
|
+
"listitem",
|
|
597
|
+
"menuitem",
|
|
598
|
+
"menuitemcheckbox",
|
|
599
|
+
"menuitemradio",
|
|
600
|
+
"option",
|
|
601
|
+
"radio",
|
|
602
|
+
"row",
|
|
603
|
+
"tab"
|
|
604
|
+
])
|
|
605
|
+
],
|
|
606
|
+
["aria-sort", /* @__PURE__ */ new Set(["columnheader", "rowheader"])],
|
|
607
|
+
[
|
|
608
|
+
"aria-valuemax",
|
|
609
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
610
|
+
],
|
|
611
|
+
[
|
|
612
|
+
"aria-valuemin",
|
|
613
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
614
|
+
],
|
|
615
|
+
[
|
|
616
|
+
"aria-valuenow",
|
|
617
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
618
|
+
],
|
|
619
|
+
[
|
|
620
|
+
"aria-valuetext",
|
|
621
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
622
|
+
]
|
|
623
|
+
]);
|
|
624
|
+
|
|
625
|
+
// ../../lib/primitive/src/constants/primitive/slot-name.ts
|
|
626
|
+
var SLOT_NAME = "Slot";
|
|
627
|
+
|
|
628
|
+
// ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
|
|
629
|
+
function isGlobalAriaAttribute(attr) {
|
|
630
|
+
return GLOBAL_ARIA_ATTRIBUTES.has(attr);
|
|
592
631
|
}
|
|
593
|
-
function
|
|
594
|
-
|
|
632
|
+
function isAriaAttributeValidForRole(attr, role) {
|
|
633
|
+
const allowedRoles = ROLE_RESTRICTED_ATTRIBUTES.get(attr);
|
|
634
|
+
if (isUndefined(allowedRoles)) return true;
|
|
635
|
+
if (isUndefined(role)) return false;
|
|
636
|
+
return allowedRoles.has(role);
|
|
595
637
|
}
|
|
596
|
-
|
|
597
|
-
|
|
638
|
+
|
|
639
|
+
// ../../lib/primitive/src/guards/aria/is-aria-role.ts
|
|
640
|
+
function isStrongImplicitRole(tag) {
|
|
641
|
+
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
642
|
+
return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
598
643
|
}
|
|
599
|
-
function
|
|
600
|
-
|
|
644
|
+
function isStandaloneTag(tag) {
|
|
645
|
+
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
646
|
+
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
601
647
|
}
|
|
602
|
-
function
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
yield [key, object[key]];
|
|
606
|
-
}
|
|
648
|
+
function getInputImplicitRole(type) {
|
|
649
|
+
if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
|
|
650
|
+
return INPUT_TYPE_ROLE_MAP[type];
|
|
607
651
|
}
|
|
608
|
-
function
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
652
|
+
function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
|
|
653
|
+
const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
|
|
654
|
+
if (!isNamed) return void 0;
|
|
655
|
+
if (tag === "section") return "region";
|
|
656
|
+
if (tag === "form") return "form";
|
|
657
|
+
return void 0;
|
|
612
658
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
659
|
+
|
|
660
|
+
// ../../lib/primitive/src/guards/aria/is-known-aria-role.ts
|
|
661
|
+
function isKnownAriaRole(value) {
|
|
662
|
+
return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
|
|
617
663
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
664
|
+
|
|
665
|
+
// ../../lib/primitive/src/guards/children/component-id.ts
|
|
666
|
+
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
|
|
667
|
+
|
|
668
|
+
// ../../lib/primitive/src/guards/children/is-tag.ts
|
|
669
|
+
function getAsProp(child) {
|
|
670
|
+
if (!isObject(child) || !("props" in child)) return void 0;
|
|
671
|
+
const props = child.props;
|
|
672
|
+
if (!isObject(props)) return void 0;
|
|
673
|
+
const as = props.as;
|
|
674
|
+
return isString(as) && as !== "" ? as : void 0;
|
|
624
675
|
}
|
|
625
|
-
function
|
|
626
|
-
|
|
627
|
-
|
|
676
|
+
function getTag(child) {
|
|
677
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
678
|
+
const t = child.type;
|
|
679
|
+
if (isString(t)) return t;
|
|
680
|
+
if (typeof t === "function" || isObject(t)) {
|
|
681
|
+
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
682
|
+
if (!isString(defaultTag)) return void 0;
|
|
683
|
+
return getAsProp(child) ?? defaultTag;
|
|
628
684
|
}
|
|
685
|
+
return void 0;
|
|
629
686
|
}
|
|
630
|
-
function
|
|
631
|
-
|
|
632
|
-
|
|
687
|
+
function isTag(...args) {
|
|
688
|
+
if (isString(args[0])) {
|
|
689
|
+
const set3 = new Set(args);
|
|
690
|
+
return (child2) => {
|
|
691
|
+
const tag2 = getTag(child2);
|
|
692
|
+
return tag2 !== void 0 && set3.has(tag2);
|
|
693
|
+
};
|
|
633
694
|
}
|
|
695
|
+
const [child, ...tags] = args;
|
|
696
|
+
const set2 = new Set(tags);
|
|
697
|
+
const tag = getTag(child);
|
|
698
|
+
return tag !== void 0 && set2.has(tag);
|
|
634
699
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
700
|
+
|
|
701
|
+
// ../../adapters/preact/src/create-contract-component.ts
|
|
702
|
+
import { forwardRef as forwardRef2 } from "preact/compat";
|
|
703
|
+
|
|
704
|
+
// ../../lib/adapter-utils/src/invariant.ts
|
|
705
|
+
function panic(message) {
|
|
706
|
+
throw new Error(message);
|
|
639
707
|
}
|
|
640
|
-
function
|
|
641
|
-
|
|
642
|
-
callback(value);
|
|
643
|
-
}
|
|
708
|
+
function invariant(condition, message) {
|
|
709
|
+
if (!condition) panic(message);
|
|
644
710
|
}
|
|
645
|
-
var iterate = Object.freeze({
|
|
646
|
-
entries,
|
|
647
|
-
filter,
|
|
648
|
-
find,
|
|
649
|
-
findLast,
|
|
650
|
-
forEach,
|
|
651
|
-
forEachEntry,
|
|
652
|
-
forEachKey,
|
|
653
|
-
forEachSet,
|
|
654
|
-
forEachValue,
|
|
655
|
-
items,
|
|
656
|
-
keys,
|
|
657
|
-
map,
|
|
658
|
-
mapEntries,
|
|
659
|
-
mapValues,
|
|
660
|
-
nodeList,
|
|
661
|
-
reduce,
|
|
662
|
-
collect,
|
|
663
|
-
set,
|
|
664
|
-
some,
|
|
665
|
-
every,
|
|
666
|
-
values
|
|
667
|
-
});
|
|
668
711
|
|
|
669
|
-
// ../../lib/
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
constructor(maxSize) {
|
|
674
|
-
if (!Number.isInteger(maxSize) || maxSize < 1) {
|
|
675
|
-
throw new RangeError("LRUCache maxSize must be a positive integer.");
|
|
676
|
-
}
|
|
677
|
-
this.#maxSize = maxSize;
|
|
678
|
-
}
|
|
679
|
-
get(key) {
|
|
680
|
-
if (!this.#store.has(key)) return void 0;
|
|
681
|
-
const value = this.#store.get(key);
|
|
682
|
-
this.#store.delete(key);
|
|
683
|
-
this.#store.set(key, value);
|
|
684
|
-
return value;
|
|
685
|
-
}
|
|
686
|
-
set(key, value) {
|
|
687
|
-
this.#store.delete(key);
|
|
688
|
-
this.#store.set(key, value);
|
|
689
|
-
if (this.#store.size > this.#maxSize) {
|
|
690
|
-
const lru = this.#store.keys().next().value;
|
|
691
|
-
if (lru !== void 0) this.#store.delete(lru);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
has(key) {
|
|
695
|
-
return this.#store.has(key);
|
|
696
|
-
}
|
|
697
|
-
delete(key) {
|
|
698
|
-
return this.#store.delete(key);
|
|
699
|
-
}
|
|
700
|
-
get size() {
|
|
701
|
-
return this.#store.size;
|
|
702
|
-
}
|
|
703
|
-
clear() {
|
|
704
|
-
this.#store.clear();
|
|
705
|
-
}
|
|
706
|
-
};
|
|
712
|
+
// ../../lib/adapter-utils/src/runtime/apply-display-name.ts
|
|
713
|
+
function applyDisplayName(component, name) {
|
|
714
|
+
Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
|
|
715
|
+
}
|
|
707
716
|
|
|
708
|
-
// ../../lib/
|
|
709
|
-
function
|
|
710
|
-
|
|
711
|
-
if (active.length === 0) return null;
|
|
712
|
-
if (active.length === 1) return active[0];
|
|
713
|
-
return (value) => {
|
|
714
|
-
iterate.forEach(active, (ref) => {
|
|
715
|
-
if (typeof ref === "function") {
|
|
716
|
-
ref(value);
|
|
717
|
-
} else {
|
|
718
|
-
ref.current = value;
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
};
|
|
717
|
+
// ../../lib/adapter-utils/src/runtime/define-component.ts
|
|
718
|
+
function defineContractComponent(options) {
|
|
719
|
+
return (factory) => factory(options);
|
|
722
720
|
}
|
|
723
721
|
|
|
724
|
-
// ../../lib/
|
|
725
|
-
function
|
|
726
|
-
return
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
722
|
+
// ../../lib/contract/src/aria/aria-role-policy.ts
|
|
723
|
+
function getImplicitRole(tag, props) {
|
|
724
|
+
if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
|
|
725
|
+
if (tag === "input") return getInputImplicitRole(props?.type);
|
|
726
|
+
if (tag === "img") return props?.alt === "" ? "none" : "img";
|
|
727
|
+
if (tag === "section" || tag === "form") {
|
|
728
|
+
return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
|
|
729
|
+
}
|
|
730
|
+
return void 0;
|
|
730
731
|
}
|
|
731
732
|
|
|
732
733
|
// ../../lib/contract/src/diagnostics/aria.ts
|
|
@@ -1108,7 +1109,7 @@ var InvariantBase = class {
|
|
|
1108
1109
|
};
|
|
1109
1110
|
|
|
1110
1111
|
// ../../lib/contract/src/aria/polymorphic-validator.ts
|
|
1111
|
-
var
|
|
1112
|
+
var NO_VIOLATIONS = [{ valid: true }];
|
|
1112
1113
|
function isIntrinsicTag(tag) {
|
|
1113
1114
|
return isString(tag);
|
|
1114
1115
|
}
|
|
@@ -1150,17 +1151,20 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1150
1151
|
static #deriveContext(tag, props) {
|
|
1151
1152
|
if (!isIntrinsicTag(tag)) return { proceed: false, result: { props, violations: [] } };
|
|
1152
1153
|
const implicitRole = getImplicitRole(tag, props);
|
|
1153
|
-
const hasRole2 = implicitRole
|
|
1154
|
+
const hasRole2 = isNonNull(implicitRole) || isString(props.role) && props.role.length > 0;
|
|
1154
1155
|
if (!hasRole2) return { proceed: false, result: { props, violations: [] } };
|
|
1155
1156
|
const normalized = _AriaPolicyEngine.#normalizeEmptyRole(tag, props);
|
|
1156
|
-
|
|
1157
|
-
const
|
|
1157
|
+
const workingProps = normalized.normalized ? normalized.result.props : props;
|
|
1158
|
+
const preExistingViolations = normalized.normalized ? normalized.result.violations : [];
|
|
1159
|
+
const effectiveRole = workingProps.role ?? implicitRole;
|
|
1158
1160
|
return {
|
|
1159
1161
|
proceed: true,
|
|
1160
1162
|
tag,
|
|
1161
1163
|
implicitRole,
|
|
1162
1164
|
effectiveRole,
|
|
1163
|
-
|
|
1165
|
+
props: workingProps,
|
|
1166
|
+
preExistingViolations,
|
|
1167
|
+
context: { tag, props: workingProps, implicitRole, effectiveRole }
|
|
1164
1168
|
};
|
|
1165
1169
|
}
|
|
1166
1170
|
static #runRules(rules, context) {
|
|
@@ -1175,7 +1179,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1175
1179
|
} = context;
|
|
1176
1180
|
const { message, attribute, severity } = result;
|
|
1177
1181
|
const resolvedMessage = message ?? result.diagnostic?.message;
|
|
1178
|
-
const fallbackDiag = resolvedMessage
|
|
1182
|
+
const fallbackDiag = isNonNull(resolvedMessage) ? void 0 : AriaDiagnostics.invalidRole(role, tag);
|
|
1179
1183
|
violations.push({
|
|
1180
1184
|
message: resolvedMessage ?? fallbackDiag.message,
|
|
1181
1185
|
tag,
|
|
@@ -1183,8 +1187,8 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1183
1187
|
attribute,
|
|
1184
1188
|
severity,
|
|
1185
1189
|
phase: "evaluate",
|
|
1186
|
-
...result.diagnostic
|
|
1187
|
-
...fallbackDiag
|
|
1190
|
+
...isNonNull(result.diagnostic) && { diagnostic: result.diagnostic },
|
|
1191
|
+
...isNonNull(fallbackDiag) && { diagnostic: fallbackDiag }
|
|
1188
1192
|
});
|
|
1189
1193
|
if (result.fixable) fixes.push(result.fix);
|
|
1190
1194
|
});
|
|
@@ -1192,7 +1196,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1192
1196
|
return { violations, fixes };
|
|
1193
1197
|
}
|
|
1194
1198
|
static #getRules(context) {
|
|
1195
|
-
if (_AriaPolicyEngine.#hasRole(context.props) || context.effectiveRole
|
|
1199
|
+
if (_AriaPolicyEngine.#hasRole(context.props) || isNonNull(context.effectiveRole) && _AriaPolicyEngine.#LIVE_REGION_ROLES.has(context.effectiveRole)) {
|
|
1196
1200
|
return _AriaPolicyEngine.#pipeline;
|
|
1197
1201
|
}
|
|
1198
1202
|
return _AriaPolicyEngine.#implicitOnlyRules;
|
|
@@ -1200,24 +1204,36 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1200
1204
|
static evaluate(tag, props) {
|
|
1201
1205
|
const derived = _AriaPolicyEngine.#deriveContext(tag, props);
|
|
1202
1206
|
if (!derived.proceed) return derived.result;
|
|
1203
|
-
const {
|
|
1207
|
+
const {
|
|
1208
|
+
tag: narrowedTag,
|
|
1209
|
+
implicitRole,
|
|
1210
|
+
context,
|
|
1211
|
+
props: workingProps,
|
|
1212
|
+
preExistingViolations
|
|
1213
|
+
} = derived;
|
|
1204
1214
|
const { violations, fixes } = _AriaPolicyEngine.#runRules(
|
|
1205
1215
|
_AriaPolicyEngine.#getRules(context),
|
|
1206
1216
|
context
|
|
1207
1217
|
);
|
|
1208
|
-
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole,
|
|
1209
|
-
return { props: next, violations };
|
|
1218
|
+
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole, workingProps, fixes);
|
|
1219
|
+
return { props: next, violations: [...preExistingViolations, ...violations] };
|
|
1210
1220
|
}
|
|
1211
1221
|
static #evaluateWithRules(tag, props, extraRules) {
|
|
1212
1222
|
const derived = _AriaPolicyEngine.#deriveContext(tag, props);
|
|
1213
1223
|
if (!derived.proceed) return derived.result;
|
|
1214
|
-
const {
|
|
1224
|
+
const {
|
|
1225
|
+
tag: narrowedTag,
|
|
1226
|
+
implicitRole,
|
|
1227
|
+
context,
|
|
1228
|
+
props: workingProps,
|
|
1229
|
+
preExistingViolations
|
|
1230
|
+
} = derived;
|
|
1215
1231
|
const { violations, fixes } = _AriaPolicyEngine.#runRules(
|
|
1216
1232
|
[..._AriaPolicyEngine.#getRules(context), ...extraRules],
|
|
1217
1233
|
context
|
|
1218
1234
|
);
|
|
1219
|
-
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole,
|
|
1220
|
-
return { props: next, violations };
|
|
1235
|
+
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole, workingProps, fixes);
|
|
1236
|
+
return { props: next, violations: [...preExistingViolations, ...violations] };
|
|
1221
1237
|
}
|
|
1222
1238
|
report(violations) {
|
|
1223
1239
|
iterate.forEach(violations, (v) => {
|
|
@@ -1226,12 +1242,12 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1226
1242
|
else this.warn(d);
|
|
1227
1243
|
});
|
|
1228
1244
|
}
|
|
1229
|
-
// Cache key covers only the aria-relevant subset of props (tag + role + aria-* attrs)
|
|
1230
|
-
// Non-aria props (className, onClick, etc.) do
|
|
1231
|
-
// so cache hits survive re-renders
|
|
1232
|
-
//
|
|
1233
|
-
//
|
|
1234
|
-
//
|
|
1245
|
+
// Cache key covers only the aria-relevant subset of props (tag + role + aria-* attrs) —
|
|
1246
|
+
// exactly what the built-in pipeline reads. Non-aria props (className, onClick, etc.) do
|
|
1247
|
+
// not affect built-in ARIA decisions and are excluded so cache hits survive re-renders
|
|
1248
|
+
// that only change non-aria props. This key alone is unsound for #extraRules, which may
|
|
1249
|
+
// read arbitrary props outside this set — validate() extends it with #extraRulesKeySuffix,
|
|
1250
|
+
// or bypasses the cache, to account for that.
|
|
1235
1251
|
static #createPlanKey(tag, props) {
|
|
1236
1252
|
if (!isIntrinsicTag(tag)) return null;
|
|
1237
1253
|
const parts = [tag];
|
|
@@ -1247,6 +1263,23 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1247
1263
|
if (ariaEntries.length > 0) parts.push(...ariaEntries.sort());
|
|
1248
1264
|
return parts.join("|");
|
|
1249
1265
|
}
|
|
1266
|
+
// Extends the base cache key with the props each extra rule declares it reads (`readsProps`).
|
|
1267
|
+
// Returns null — meaning "don't cache" — if any extra rule omits `readsProps` (it may read
|
|
1268
|
+
// arbitrary props the key can't account for) or if a declared prop's value isn't a primitive
|
|
1269
|
+
// (object/array identity isn't stably representable in a string key).
|
|
1270
|
+
static #extraRulesKeySuffix(extraRules, props) {
|
|
1271
|
+
const parts = [];
|
|
1272
|
+
for (const rule of extraRules) {
|
|
1273
|
+
const readsProps = rule.readsProps;
|
|
1274
|
+
if (!isNonNull(readsProps)) return null;
|
|
1275
|
+
for (const propKey of readsProps) {
|
|
1276
|
+
const v = props[propKey];
|
|
1277
|
+
if (v !== void 0 && !isString(v) && !isNumber(v) && typeof v !== "boolean") return null;
|
|
1278
|
+
parts.push(`x:${propKey}:${String(v)}`);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
return parts.sort().join("|");
|
|
1282
|
+
}
|
|
1250
1283
|
static #computePlan(inputProps, resultProps) {
|
|
1251
1284
|
const removals = /* @__PURE__ */ new Set();
|
|
1252
1285
|
const updates = {};
|
|
@@ -1270,7 +1303,12 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1270
1303
|
return next;
|
|
1271
1304
|
}
|
|
1272
1305
|
validate(tag, props) {
|
|
1273
|
-
const
|
|
1306
|
+
const baseKey = _AriaPolicyEngine.#createPlanKey(tag, props);
|
|
1307
|
+
let key = baseKey;
|
|
1308
|
+
if (this.#extraRules.length > 0) {
|
|
1309
|
+
const suffix = _AriaPolicyEngine.#extraRulesKeySuffix(this.#extraRules, props);
|
|
1310
|
+
key = isNonNull(baseKey) && isNonNull(suffix) ? `${baseKey}|${suffix}` : null;
|
|
1311
|
+
}
|
|
1274
1312
|
if (!isNull(key)) {
|
|
1275
1313
|
const cached = this.#planCache.get(key);
|
|
1276
1314
|
if (cached !== void 0) {
|
|
@@ -1360,7 +1398,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1360
1398
|
implicitRole
|
|
1361
1399
|
}) {
|
|
1362
1400
|
const role = props.role;
|
|
1363
|
-
if (!implicitRole || !role || role === implicitRole) return
|
|
1401
|
+
if (!implicitRole || !role || role === implicitRole) return NO_VIOLATIONS;
|
|
1364
1402
|
if (isStrongImplicitRole(tag) && role === "region") {
|
|
1365
1403
|
return [
|
|
1366
1404
|
{
|
|
@@ -1372,11 +1410,11 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1372
1410
|
}
|
|
1373
1411
|
];
|
|
1374
1412
|
}
|
|
1375
|
-
return
|
|
1413
|
+
return NO_VIOLATIONS;
|
|
1376
1414
|
}
|
|
1377
1415
|
static #checkRedundantRole({ tag, props, implicitRole }) {
|
|
1378
1416
|
const role = props.role;
|
|
1379
|
-
if (!implicitRole || !role || role !== implicitRole) return
|
|
1417
|
+
if (!implicitRole || !role || role !== implicitRole) return NO_VIOLATIONS;
|
|
1380
1418
|
return [
|
|
1381
1419
|
{
|
|
1382
1420
|
valid: false,
|
|
@@ -1389,8 +1427,8 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1389
1427
|
}
|
|
1390
1428
|
static #checkStandaloneRegion({ tag, props, implicitRole }) {
|
|
1391
1429
|
const role = props.role;
|
|
1392
|
-
if (role !== "region") return
|
|
1393
|
-
if (!isStandaloneTag(tag)) return
|
|
1430
|
+
if (role !== "region") return NO_VIOLATIONS;
|
|
1431
|
+
if (!isStandaloneTag(tag)) return NO_VIOLATIONS;
|
|
1394
1432
|
return [
|
|
1395
1433
|
{
|
|
1396
1434
|
valid: false,
|
|
@@ -1406,7 +1444,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1406
1444
|
props,
|
|
1407
1445
|
effectiveRole
|
|
1408
1446
|
}) {
|
|
1409
|
-
if (effectiveRole === "none" || effectiveRole === "presentation") return
|
|
1447
|
+
if (effectiveRole === "none" || effectiveRole === "presentation") return NO_VIOLATIONS;
|
|
1410
1448
|
const results = [];
|
|
1411
1449
|
iterate.forEachEntry(props, (key) => {
|
|
1412
1450
|
if (!key.startsWith("aria-")) return;
|
|
@@ -1524,12 +1562,12 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1524
1562
|
}
|
|
1525
1563
|
}
|
|
1526
1564
|
static #checkAriaAttributeValues({ props, effectiveRole }) {
|
|
1527
|
-
if (effectiveRole === "none" || effectiveRole === "presentation") return
|
|
1565
|
+
if (effectiveRole === "none" || effectiveRole === "presentation") return NO_VIOLATIONS;
|
|
1528
1566
|
const results = [];
|
|
1529
1567
|
iterate.forEachEntry(props, (key, value) => {
|
|
1530
1568
|
if (!key.startsWith("aria-")) return;
|
|
1531
1569
|
const type = _AriaPolicyEngine.#ARIA_VALUE_TYPES.get(key);
|
|
1532
|
-
if (type
|
|
1570
|
+
if (!isNonNull(type)) return;
|
|
1533
1571
|
if (_AriaPolicyEngine.#isValidAriaValue(value, type)) return;
|
|
1534
1572
|
results.push({
|
|
1535
1573
|
valid: false,
|
|
@@ -1560,13 +1598,13 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1560
1598
|
props,
|
|
1561
1599
|
effectiveRole
|
|
1562
1600
|
}) {
|
|
1563
|
-
if (effectiveRole === "none" || effectiveRole === "presentation") return
|
|
1601
|
+
if (effectiveRole === "none" || effectiveRole === "presentation") return NO_VIOLATIONS;
|
|
1564
1602
|
const implicitLevel = _AriaPolicyEngine.#HEADING_IMPLICIT_LEVELS.get(tag);
|
|
1565
|
-
if (implicitLevel
|
|
1603
|
+
if (!isNonNull(implicitLevel)) return NO_VIOLATIONS;
|
|
1566
1604
|
const raw = props["aria-level"];
|
|
1567
|
-
if (raw
|
|
1605
|
+
if (!isNonNull(raw)) return NO_VIOLATIONS;
|
|
1568
1606
|
const n = typeof raw === "number" ? raw : typeof raw === "string" ? parseInt(raw, 10) : NaN;
|
|
1569
|
-
if (!Number.isFinite(n) || n !== implicitLevel) return
|
|
1607
|
+
if (!Number.isFinite(n) || n !== implicitLevel) return NO_VIOLATIONS;
|
|
1570
1608
|
return [
|
|
1571
1609
|
{
|
|
1572
1610
|
valid: false,
|
|
@@ -1589,9 +1627,10 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1589
1627
|
props,
|
|
1590
1628
|
effectiveRole
|
|
1591
1629
|
}) {
|
|
1592
|
-
if (!effectiveRole || !_AriaPolicyEngine.#NAME_REQUIRED_ROLES.has(effectiveRole))
|
|
1593
|
-
|
|
1594
|
-
if (
|
|
1630
|
+
if (!effectiveRole || !_AriaPolicyEngine.#NAME_REQUIRED_ROLES.has(effectiveRole))
|
|
1631
|
+
return NO_VIOLATIONS;
|
|
1632
|
+
if ("aria-label" in props || "aria-labelledby" in props) return NO_VIOLATIONS;
|
|
1633
|
+
if (tag === "img" && typeof props.alt === "string" && props.alt.length > 0) return NO_VIOLATIONS;
|
|
1595
1634
|
return [
|
|
1596
1635
|
{
|
|
1597
1636
|
valid: false,
|
|
@@ -1614,9 +1653,9 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1614
1653
|
props,
|
|
1615
1654
|
effectiveRole
|
|
1616
1655
|
}) {
|
|
1617
|
-
if (!effectiveRole) return
|
|
1656
|
+
if (!effectiveRole) return NO_VIOLATIONS;
|
|
1618
1657
|
const required = _AriaPolicyEngine.#REQUIRED_PROPERTIES.get(effectiveRole);
|
|
1619
|
-
if (required
|
|
1658
|
+
if (!isNonNull(required)) return NO_VIOLATIONS;
|
|
1620
1659
|
const results = [];
|
|
1621
1660
|
iterate.forEach(required, (attr) => {
|
|
1622
1661
|
if (attr in props) return;
|
|
@@ -1640,12 +1679,12 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1640
1679
|
]);
|
|
1641
1680
|
// WAI-ARIA 1.2 §6.6: aria-hidden="true" must not be placed on focusable elements.
|
|
1642
1681
|
static #checkAriaHiddenOnFocusable({ tag, props }) {
|
|
1643
|
-
if (props["aria-hidden"] !== "true" && props["aria-hidden"] !== true) return
|
|
1682
|
+
if (props["aria-hidden"] !== "true" && props["aria-hidden"] !== true) return NO_VIOLATIONS;
|
|
1644
1683
|
const isInteractive = _AriaPolicyEngine.#INTERACTIVE_TAGS.has(tag);
|
|
1645
1684
|
if (!isInteractive) {
|
|
1646
1685
|
const tabindex = props.tabindex;
|
|
1647
1686
|
const n = typeof tabindex === "number" ? tabindex : typeof tabindex === "string" ? parseInt(tabindex, 10) : NaN;
|
|
1648
|
-
if (!Number.isFinite(n) || n < 0) return
|
|
1687
|
+
if (!Number.isFinite(n) || n < 0) return NO_VIOLATIONS;
|
|
1649
1688
|
}
|
|
1650
1689
|
return [
|
|
1651
1690
|
{
|
|
@@ -1664,7 +1703,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1664
1703
|
props,
|
|
1665
1704
|
effectiveRole
|
|
1666
1705
|
}) {
|
|
1667
|
-
if (effectiveRole !== "none" && effectiveRole !== "presentation") return
|
|
1706
|
+
if (effectiveRole !== "none" && effectiveRole !== "presentation") return NO_VIOLATIONS;
|
|
1668
1707
|
const results = [];
|
|
1669
1708
|
iterate.forEachEntry(props, (key) => {
|
|
1670
1709
|
if (!key.startsWith("aria-")) return;
|
|
@@ -1688,10 +1727,10 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1688
1727
|
["timer", "off"]
|
|
1689
1728
|
]);
|
|
1690
1729
|
static #checkMissingLiveRegion({ effectiveRole, props }) {
|
|
1691
|
-
if (!effectiveRole) return
|
|
1730
|
+
if (!effectiveRole) return NO_VIOLATIONS;
|
|
1692
1731
|
const impliedLive = _AriaPolicyEngine.#LIVE_REGION_ROLES.get(effectiveRole);
|
|
1693
|
-
if (!impliedLive) return
|
|
1694
|
-
if ("aria-live" in props) return
|
|
1732
|
+
if (!impliedLive) return NO_VIOLATIONS;
|
|
1733
|
+
if ("aria-live" in props) return NO_VIOLATIONS;
|
|
1695
1734
|
const injectLive = {
|
|
1696
1735
|
kind: `injectLive:${effectiveRole}`,
|
|
1697
1736
|
apply: (ctx) => ({
|
|
@@ -1711,8 +1750,9 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1711
1750
|
];
|
|
1712
1751
|
}
|
|
1713
1752
|
static #checkMissingAtomic({ effectiveRole, props }) {
|
|
1714
|
-
if (!effectiveRole || !_AriaPolicyEngine.#LIVE_REGION_ROLES.has(effectiveRole))
|
|
1715
|
-
|
|
1753
|
+
if (!effectiveRole || !_AriaPolicyEngine.#LIVE_REGION_ROLES.has(effectiveRole))
|
|
1754
|
+
return NO_VIOLATIONS;
|
|
1755
|
+
if ("aria-atomic" in props) return NO_VIOLATIONS;
|
|
1716
1756
|
return [
|
|
1717
1757
|
{
|
|
1718
1758
|
valid: false,
|
|
@@ -1736,8 +1776,8 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1736
1776
|
};
|
|
1737
1777
|
static #checkInvalidAriaRelevant({ props }) {
|
|
1738
1778
|
const relevant = props["aria-relevant"];
|
|
1739
|
-
if (relevant === void 0) return
|
|
1740
|
-
if (typeof relevant !== "string") return
|
|
1779
|
+
if (relevant === void 0) return NO_VIOLATIONS;
|
|
1780
|
+
if (typeof relevant !== "string") return NO_VIOLATIONS;
|
|
1741
1781
|
const tokens = relevant.trim().split(/\s+/);
|
|
1742
1782
|
const invalid = tokens.filter((t) => !_AriaPolicyEngine.#VALID_RELEVANT_TOKENS.has(t));
|
|
1743
1783
|
if (invalid.length > 0) {
|
|
@@ -1764,7 +1804,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1764
1804
|
}
|
|
1765
1805
|
];
|
|
1766
1806
|
}
|
|
1767
|
-
return
|
|
1807
|
+
return NO_VIOLATIONS;
|
|
1768
1808
|
}
|
|
1769
1809
|
};
|
|
1770
1810
|
|
|
@@ -2465,7 +2505,7 @@ function createClassPipeline(resolved) {
|
|
|
2465
2505
|
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
2466
2506
|
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
2467
2507
|
if (!className)
|
|
2468
|
-
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
2508
|
+
return (staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses) || void 0;
|
|
2469
2509
|
return cn(staticClasses, variantClasses, className);
|
|
2470
2510
|
};
|
|
2471
2511
|
}
|
|
@@ -2505,7 +2545,10 @@ function resolveFactoryOptions(options = {}) {
|
|
|
2505
2545
|
const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
|
|
2506
2546
|
return Object.freeze({
|
|
2507
2547
|
defaultTag: options.tag ?? "div",
|
|
2508
|
-
diagnostics: resolveDiagnostics(
|
|
2548
|
+
diagnostics: resolveDiagnostics(
|
|
2549
|
+
enforcement?.diagnostics,
|
|
2550
|
+
options.diagnostics ?? silentDiagnostics
|
|
2551
|
+
),
|
|
2509
2552
|
variantKeys,
|
|
2510
2553
|
...whenDefined("displayName", options.name),
|
|
2511
2554
|
...whenDefined("defaultProps", options.defaults),
|
|
@@ -2676,7 +2719,7 @@ function createPolymorphic2(options = {}) {
|
|
|
2676
2719
|
if (process.env.NODE_ENV !== "production") {
|
|
2677
2720
|
validateRenderProps(resolved.diagnostics, resolved, props, recipe);
|
|
2678
2721
|
}
|
|
2679
|
-
return classPipeline(tag, props, className, recipe);
|
|
2722
|
+
return classPipeline(tag, props, className, recipe) || void 0;
|
|
2680
2723
|
},
|
|
2681
2724
|
resolveAria(tag, props) {
|
|
2682
2725
|
return resolveAriaFn(tag, props);
|