praxis-kit 1.1.0 → 2.0.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/README.md +196 -0
- package/dist/{chunk-KDUNVQK2.js → chunk-ACAKUHH5.js} +531 -386
- package/dist/contract/index.d.ts +130 -0
- package/dist/contract/index.js +1370 -0
- package/dist/lit/index.d.ts +2 -1
- package/dist/lit/index.js +257 -184
- package/dist/{merge-refs-CfBqh1UO.d.ts → merge-refs-DxjWMq3U.d.ts} +2 -5
- package/dist/preact/index.d.ts +2 -5
- package/dist/preact/index.js +236 -187
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +1 -5
- package/dist/react/legacy.d.ts +3 -3
- package/dist/react/legacy.js +1 -5
- package/dist/solid/index.d.ts +2 -5
- package/dist/solid/index.js +238 -189
- package/dist/svelte/index.d.ts +3 -5
- package/dist/svelte/index.js +233 -186
- package/dist/vue/index.d.ts +2 -5
- package/dist/vue/index.js +236 -187
- package/dist/web/index.d.ts +2 -1
- package/dist/web/index.js +259 -185
- package/package.json +6 -2
|
@@ -0,0 +1,1370 @@
|
|
|
1
|
+
// ../core/dist/chunk-XFCAUPVZ.js
|
|
2
|
+
function assertNever(value) {
|
|
3
|
+
throw new Error(`Unexpected value: ${String(value)}`);
|
|
4
|
+
}
|
|
5
|
+
function isNull(value) {
|
|
6
|
+
return value === null;
|
|
7
|
+
}
|
|
8
|
+
function isObject(value) {
|
|
9
|
+
return !isNull(value) && typeof value === "object";
|
|
10
|
+
}
|
|
11
|
+
function isString(value) {
|
|
12
|
+
return typeof value === "string";
|
|
13
|
+
}
|
|
14
|
+
function isNumber(value) {
|
|
15
|
+
return typeof value === "number";
|
|
16
|
+
}
|
|
17
|
+
var KNOWN_ARIA_ROLES = [
|
|
18
|
+
"alert",
|
|
19
|
+
"alertdialog",
|
|
20
|
+
"application",
|
|
21
|
+
"article",
|
|
22
|
+
"banner",
|
|
23
|
+
"blockquote",
|
|
24
|
+
"button",
|
|
25
|
+
"caption",
|
|
26
|
+
"cell",
|
|
27
|
+
"checkbox",
|
|
28
|
+
"code",
|
|
29
|
+
"columnheader",
|
|
30
|
+
"combobox",
|
|
31
|
+
"complementary",
|
|
32
|
+
"contentinfo",
|
|
33
|
+
"definition",
|
|
34
|
+
"deletion",
|
|
35
|
+
"dialog",
|
|
36
|
+
"document",
|
|
37
|
+
"emphasis",
|
|
38
|
+
"feed",
|
|
39
|
+
"figure",
|
|
40
|
+
"form",
|
|
41
|
+
"generic",
|
|
42
|
+
"grid",
|
|
43
|
+
"gridcell",
|
|
44
|
+
"group",
|
|
45
|
+
"heading",
|
|
46
|
+
"img",
|
|
47
|
+
"insertion",
|
|
48
|
+
"link",
|
|
49
|
+
"list",
|
|
50
|
+
"listbox",
|
|
51
|
+
"listitem",
|
|
52
|
+
"log",
|
|
53
|
+
"main",
|
|
54
|
+
"marquee",
|
|
55
|
+
"math",
|
|
56
|
+
"menu",
|
|
57
|
+
"menubar",
|
|
58
|
+
"menuitem",
|
|
59
|
+
"menuitemcheckbox",
|
|
60
|
+
"menuitemradio",
|
|
61
|
+
"meter",
|
|
62
|
+
"navigation",
|
|
63
|
+
"none",
|
|
64
|
+
"note",
|
|
65
|
+
"option",
|
|
66
|
+
"paragraph",
|
|
67
|
+
"presentation",
|
|
68
|
+
"progressbar",
|
|
69
|
+
"radio",
|
|
70
|
+
"radiogroup",
|
|
71
|
+
"region",
|
|
72
|
+
"row",
|
|
73
|
+
"rowgroup",
|
|
74
|
+
"rowheader",
|
|
75
|
+
"scrollbar",
|
|
76
|
+
"search",
|
|
77
|
+
"searchbox",
|
|
78
|
+
"separator",
|
|
79
|
+
"slider",
|
|
80
|
+
"spinbutton",
|
|
81
|
+
"status",
|
|
82
|
+
"strong",
|
|
83
|
+
"subscript",
|
|
84
|
+
"superscript",
|
|
85
|
+
"switch",
|
|
86
|
+
"tab",
|
|
87
|
+
"table",
|
|
88
|
+
"tablist",
|
|
89
|
+
"tabpanel",
|
|
90
|
+
"term",
|
|
91
|
+
"textbox",
|
|
92
|
+
"time",
|
|
93
|
+
"timer",
|
|
94
|
+
"toolbar",
|
|
95
|
+
"tooltip",
|
|
96
|
+
"tree",
|
|
97
|
+
"treegrid",
|
|
98
|
+
"treeitem"
|
|
99
|
+
];
|
|
100
|
+
var KNOWN_ARIA_ROLES_SET = new Set(KNOWN_ARIA_ROLES);
|
|
101
|
+
var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
102
|
+
"aria-atomic",
|
|
103
|
+
"aria-busy",
|
|
104
|
+
"aria-controls",
|
|
105
|
+
"aria-current",
|
|
106
|
+
"aria-describedby",
|
|
107
|
+
"aria-details",
|
|
108
|
+
"aria-disabled",
|
|
109
|
+
"aria-errormessage",
|
|
110
|
+
"aria-flowto",
|
|
111
|
+
"aria-hidden",
|
|
112
|
+
"aria-keyshortcuts",
|
|
113
|
+
"aria-label",
|
|
114
|
+
"aria-labelledby",
|
|
115
|
+
"aria-live",
|
|
116
|
+
"aria-owns",
|
|
117
|
+
"aria-relevant",
|
|
118
|
+
"aria-roledescription"
|
|
119
|
+
]);
|
|
120
|
+
var IMPLICIT_ROLE_RECORD = {
|
|
121
|
+
article: "article",
|
|
122
|
+
aside: "complementary",
|
|
123
|
+
footer: "contentinfo",
|
|
124
|
+
header: "banner",
|
|
125
|
+
main: "main",
|
|
126
|
+
nav: "navigation",
|
|
127
|
+
button: "button",
|
|
128
|
+
a: "link",
|
|
129
|
+
select: "listbox",
|
|
130
|
+
h1: "heading",
|
|
131
|
+
h2: "heading",
|
|
132
|
+
h3: "heading",
|
|
133
|
+
h4: "heading",
|
|
134
|
+
h5: "heading",
|
|
135
|
+
h6: "heading",
|
|
136
|
+
ul: "list",
|
|
137
|
+
ol: "list",
|
|
138
|
+
li: "listitem",
|
|
139
|
+
table: "table",
|
|
140
|
+
tr: "row",
|
|
141
|
+
td: "cell",
|
|
142
|
+
th: "columnheader"
|
|
143
|
+
};
|
|
144
|
+
var STRONG_ROLES = [
|
|
145
|
+
"main",
|
|
146
|
+
"navigation",
|
|
147
|
+
"complementary",
|
|
148
|
+
"contentinfo",
|
|
149
|
+
"banner"
|
|
150
|
+
];
|
|
151
|
+
var STANDALONE_ROLES = ["article"];
|
|
152
|
+
var STRONG_ROLES_SET = new Set(STRONG_ROLES);
|
|
153
|
+
var STANDALONE_ROLES_SET = new Set(STANDALONE_ROLES);
|
|
154
|
+
var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
|
|
155
|
+
[
|
|
156
|
+
"aria-activedescendant",
|
|
157
|
+
/* @__PURE__ */ new Set([
|
|
158
|
+
"application",
|
|
159
|
+
"combobox",
|
|
160
|
+
"grid",
|
|
161
|
+
"group",
|
|
162
|
+
"listbox",
|
|
163
|
+
"menu",
|
|
164
|
+
"menubar",
|
|
165
|
+
"radiogroup",
|
|
166
|
+
"spinbutton",
|
|
167
|
+
"tablist",
|
|
168
|
+
"toolbar",
|
|
169
|
+
"textbox",
|
|
170
|
+
"tree",
|
|
171
|
+
"treegrid"
|
|
172
|
+
])
|
|
173
|
+
],
|
|
174
|
+
["aria-autocomplete", /* @__PURE__ */ new Set(["combobox", "searchbox", "textbox"])],
|
|
175
|
+
[
|
|
176
|
+
"aria-checked",
|
|
177
|
+
/* @__PURE__ */ new Set(["checkbox", "menuitemcheckbox", "option", "radio", "switch", "treeitem"])
|
|
178
|
+
],
|
|
179
|
+
["aria-colcount", /* @__PURE__ */ new Set(["grid", "table", "treegrid"])],
|
|
180
|
+
["aria-colindex", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "row", "rowheader"])],
|
|
181
|
+
["aria-colspan", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "rowheader"])],
|
|
182
|
+
[
|
|
183
|
+
"aria-expanded",
|
|
184
|
+
/* @__PURE__ */ new Set([
|
|
185
|
+
"button",
|
|
186
|
+
"combobox",
|
|
187
|
+
"gridcell",
|
|
188
|
+
"listbox",
|
|
189
|
+
"menuitem",
|
|
190
|
+
"menuitemcheckbox",
|
|
191
|
+
"menuitemradio",
|
|
192
|
+
"row",
|
|
193
|
+
"rowheader",
|
|
194
|
+
"tab",
|
|
195
|
+
"treeitem"
|
|
196
|
+
])
|
|
197
|
+
],
|
|
198
|
+
[
|
|
199
|
+
"aria-haspopup",
|
|
200
|
+
/* @__PURE__ */ new Set([
|
|
201
|
+
"button",
|
|
202
|
+
"combobox",
|
|
203
|
+
"gridcell",
|
|
204
|
+
"listbox",
|
|
205
|
+
"menuitem",
|
|
206
|
+
"menuitemcheckbox",
|
|
207
|
+
"menuitemradio",
|
|
208
|
+
"tab",
|
|
209
|
+
"treeitem"
|
|
210
|
+
])
|
|
211
|
+
],
|
|
212
|
+
["aria-level", /* @__PURE__ */ new Set(["heading", "listitem", "row", "treeitem"])],
|
|
213
|
+
["aria-modal", /* @__PURE__ */ new Set(["alertdialog", "dialog"])],
|
|
214
|
+
["aria-multiline", /* @__PURE__ */ new Set(["textbox"])],
|
|
215
|
+
["aria-multiselectable", /* @__PURE__ */ new Set(["grid", "listbox", "tablist", "tree", "treegrid"])],
|
|
216
|
+
[
|
|
217
|
+
"aria-orientation",
|
|
218
|
+
/* @__PURE__ */ new Set(["scrollbar", "select", "separator", "slider", "tablist", "toolbar", "tree"])
|
|
219
|
+
],
|
|
220
|
+
["aria-placeholder", /* @__PURE__ */ new Set(["searchbox", "textbox"])],
|
|
221
|
+
[
|
|
222
|
+
"aria-posinset",
|
|
223
|
+
/* @__PURE__ */ new Set([
|
|
224
|
+
"article",
|
|
225
|
+
"listitem",
|
|
226
|
+
"menuitem",
|
|
227
|
+
"menuitemcheckbox",
|
|
228
|
+
"menuitemradio",
|
|
229
|
+
"option",
|
|
230
|
+
"radio",
|
|
231
|
+
"row",
|
|
232
|
+
"tab"
|
|
233
|
+
])
|
|
234
|
+
],
|
|
235
|
+
["aria-pressed", /* @__PURE__ */ new Set(["button"])],
|
|
236
|
+
[
|
|
237
|
+
"aria-readonly",
|
|
238
|
+
/* @__PURE__ */ new Set([
|
|
239
|
+
"combobox",
|
|
240
|
+
"grid",
|
|
241
|
+
"gridcell",
|
|
242
|
+
"listbox",
|
|
243
|
+
"radiogroup",
|
|
244
|
+
"slider",
|
|
245
|
+
"spinbutton",
|
|
246
|
+
"textbox",
|
|
247
|
+
"tree",
|
|
248
|
+
"treegrid"
|
|
249
|
+
])
|
|
250
|
+
],
|
|
251
|
+
[
|
|
252
|
+
"aria-required",
|
|
253
|
+
/* @__PURE__ */ new Set([
|
|
254
|
+
"combobox",
|
|
255
|
+
"gridcell",
|
|
256
|
+
"listbox",
|
|
257
|
+
"radiogroup",
|
|
258
|
+
"spinbutton",
|
|
259
|
+
"textbox",
|
|
260
|
+
"tree",
|
|
261
|
+
"treegrid"
|
|
262
|
+
])
|
|
263
|
+
],
|
|
264
|
+
["aria-rowcount", /* @__PURE__ */ new Set(["grid", "table", "treegrid"])],
|
|
265
|
+
["aria-rowindex", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "row", "rowheader"])],
|
|
266
|
+
["aria-rowspan", /* @__PURE__ */ new Set(["cell", "columnheader", "gridcell", "rowheader"])],
|
|
267
|
+
[
|
|
268
|
+
"aria-selected",
|
|
269
|
+
/* @__PURE__ */ new Set(["columnheader", "gridcell", "option", "row", "rowheader", "tab", "treeitem"])
|
|
270
|
+
],
|
|
271
|
+
[
|
|
272
|
+
"aria-setsize",
|
|
273
|
+
/* @__PURE__ */ new Set([
|
|
274
|
+
"article",
|
|
275
|
+
"listitem",
|
|
276
|
+
"menuitem",
|
|
277
|
+
"menuitemcheckbox",
|
|
278
|
+
"menuitemradio",
|
|
279
|
+
"option",
|
|
280
|
+
"radio",
|
|
281
|
+
"row",
|
|
282
|
+
"tab"
|
|
283
|
+
])
|
|
284
|
+
],
|
|
285
|
+
["aria-sort", /* @__PURE__ */ new Set(["columnheader", "rowheader"])],
|
|
286
|
+
[
|
|
287
|
+
"aria-valuemax",
|
|
288
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
289
|
+
],
|
|
290
|
+
[
|
|
291
|
+
"aria-valuemin",
|
|
292
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
293
|
+
],
|
|
294
|
+
[
|
|
295
|
+
"aria-valuenow",
|
|
296
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
297
|
+
],
|
|
298
|
+
[
|
|
299
|
+
"aria-valuetext",
|
|
300
|
+
/* @__PURE__ */ new Set(["meter", "progressbar", "scrollbar", "separator", "slider", "spinbutton"])
|
|
301
|
+
]
|
|
302
|
+
]);
|
|
303
|
+
function isUndefined(value) {
|
|
304
|
+
return value === void 0;
|
|
305
|
+
}
|
|
306
|
+
function isGlobalAriaAttribute(attr) {
|
|
307
|
+
return GLOBAL_ARIA_ATTRIBUTES.has(attr);
|
|
308
|
+
}
|
|
309
|
+
function isAriaAttributeValidForRole(attr, role) {
|
|
310
|
+
const allowedRoles = ROLE_RESTRICTED_ATTRIBUTES.get(attr);
|
|
311
|
+
if (isUndefined(allowedRoles)) return true;
|
|
312
|
+
if (isUndefined(role)) return false;
|
|
313
|
+
return allowedRoles.has(role);
|
|
314
|
+
}
|
|
315
|
+
function isStrongImplicitRole(tag) {
|
|
316
|
+
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
317
|
+
return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
318
|
+
}
|
|
319
|
+
function isStandaloneTag(tag) {
|
|
320
|
+
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
321
|
+
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ../core/dist/chunk-VU44HAB7.js
|
|
325
|
+
var IMPLICIT_ROLE_RECORD2 = {
|
|
326
|
+
article: "article",
|
|
327
|
+
aside: "complementary",
|
|
328
|
+
footer: "contentinfo",
|
|
329
|
+
header: "banner",
|
|
330
|
+
main: "main",
|
|
331
|
+
nav: "navigation",
|
|
332
|
+
button: "button",
|
|
333
|
+
a: "link",
|
|
334
|
+
select: "listbox",
|
|
335
|
+
h1: "heading",
|
|
336
|
+
h2: "heading",
|
|
337
|
+
h3: "heading",
|
|
338
|
+
h4: "heading",
|
|
339
|
+
h5: "heading",
|
|
340
|
+
h6: "heading",
|
|
341
|
+
ul: "list",
|
|
342
|
+
ol: "list",
|
|
343
|
+
li: "listitem",
|
|
344
|
+
table: "table",
|
|
345
|
+
tr: "row",
|
|
346
|
+
td: "cell",
|
|
347
|
+
th: "columnheader"
|
|
348
|
+
};
|
|
349
|
+
function getImplicitRole(tag) {
|
|
350
|
+
if (tag in IMPLICIT_ROLE_RECORD2) return IMPLICIT_ROLE_RECORD2[tag];
|
|
351
|
+
return void 0;
|
|
352
|
+
}
|
|
353
|
+
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol("praxis.component-default-tag");
|
|
354
|
+
function resolveChildTag(child) {
|
|
355
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
356
|
+
const t = child.type;
|
|
357
|
+
if (isString(t)) return t;
|
|
358
|
+
if (isObject(t) && COMPONENT_DEFAULT_TAG in t) {
|
|
359
|
+
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
360
|
+
if (!isString(defaultTag)) return void 0;
|
|
361
|
+
const props = child.props;
|
|
362
|
+
const as = isObject(props) && "as" in props ? props.as : void 0;
|
|
363
|
+
return isString(as) ? as : defaultTag;
|
|
364
|
+
}
|
|
365
|
+
return void 0;
|
|
366
|
+
}
|
|
367
|
+
function isTag(...tags) {
|
|
368
|
+
const set = new Set(tags);
|
|
369
|
+
return (child) => {
|
|
370
|
+
const tag = resolveChildTag(child);
|
|
371
|
+
return tag !== void 0 && set.has(tag);
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
var pendingAsyncWarns = /* @__PURE__ */ new Set();
|
|
375
|
+
var asyncWarnScheduled = false;
|
|
376
|
+
function flushAsyncWarns() {
|
|
377
|
+
asyncWarnScheduled = false;
|
|
378
|
+
const messages = [...pendingAsyncWarns];
|
|
379
|
+
pendingAsyncWarns.clear();
|
|
380
|
+
for (const msg of messages) {
|
|
381
|
+
console.warn(msg);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function scheduleAsyncWarn(message) {
|
|
385
|
+
if (pendingAsyncWarns.has(message)) return;
|
|
386
|
+
pendingAsyncWarns.add(message);
|
|
387
|
+
if (!asyncWarnScheduled) {
|
|
388
|
+
asyncWarnScheduled = true;
|
|
389
|
+
queueMicrotask(flushAsyncWarns);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
var StrictBase = class {
|
|
393
|
+
strict;
|
|
394
|
+
constructor(strict) {
|
|
395
|
+
this.strict = strict;
|
|
396
|
+
}
|
|
397
|
+
violate(message) {
|
|
398
|
+
if (this.strict === true || this.strict === "throw") {
|
|
399
|
+
throw new Error(message);
|
|
400
|
+
}
|
|
401
|
+
this.warn(message);
|
|
402
|
+
}
|
|
403
|
+
// Always caps at console.warn — never throws. ARIA 'warning' violations route here
|
|
404
|
+
// so they surface even in strict='throw' mode without aborting a render.
|
|
405
|
+
warn(message) {
|
|
406
|
+
if (!this.strict) return;
|
|
407
|
+
if (this.strict === "async-warn") {
|
|
408
|
+
scheduleAsyncWarn(message);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
console.warn(message);
|
|
412
|
+
}
|
|
413
|
+
invariant(condition, message) {
|
|
414
|
+
if (!condition) {
|
|
415
|
+
this.violate(message);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
function isNull2(value) {
|
|
420
|
+
return value === null;
|
|
421
|
+
}
|
|
422
|
+
var VALID = [{ valid: true }];
|
|
423
|
+
function isIntrinsicTag(tag) {
|
|
424
|
+
return isString(tag);
|
|
425
|
+
}
|
|
426
|
+
function omitProp(obj, key) {
|
|
427
|
+
const { [key]: _, ...rest } = obj;
|
|
428
|
+
return rest;
|
|
429
|
+
}
|
|
430
|
+
var AriaPolicyEngine = class _AriaPolicyEngine extends StrictBase {
|
|
431
|
+
#extraRules;
|
|
432
|
+
#planCache = /* @__PURE__ */ new Map();
|
|
433
|
+
static #MAX_CACHE = 100;
|
|
434
|
+
// Memoized AriaFix objects keyed by attribute name — the ARIA attribute set is
|
|
435
|
+
// finite so this Map is bounded and avoids recreating closures on every cache miss.
|
|
436
|
+
static #removeAttributeFixCache = /* @__PURE__ */ new Map();
|
|
437
|
+
constructor(strict = "warn", options) {
|
|
438
|
+
super(strict);
|
|
439
|
+
this.#extraRules = options?.rules ?? [];
|
|
440
|
+
}
|
|
441
|
+
static #normalizeEmptyRole(tag, props) {
|
|
442
|
+
if (props.role !== "") return { normalized: false };
|
|
443
|
+
return {
|
|
444
|
+
normalized: true,
|
|
445
|
+
result: {
|
|
446
|
+
props: omitProp(props, "role"),
|
|
447
|
+
violations: [
|
|
448
|
+
{
|
|
449
|
+
message: `<${tag}> has an explicit empty role="". Omit the attribute instead.`,
|
|
450
|
+
tag,
|
|
451
|
+
role: "",
|
|
452
|
+
attribute: void 0,
|
|
453
|
+
severity: "warning",
|
|
454
|
+
phase: "evaluate"
|
|
455
|
+
}
|
|
456
|
+
]
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
static #deriveContext(tag, props) {
|
|
461
|
+
if (!isIntrinsicTag(tag)) return { proceed: false, result: { props, violations: [] } };
|
|
462
|
+
const implicitRole = getImplicitRole(tag);
|
|
463
|
+
const hasExplicitLiveRole = !implicitRole && _AriaPolicyEngine.#LIVE_REGION_ROLES.has(props.role ?? "");
|
|
464
|
+
if (!implicitRole && !hasExplicitLiveRole)
|
|
465
|
+
return { proceed: false, result: { props, violations: [] } };
|
|
466
|
+
const normalized = _AriaPolicyEngine.#normalizeEmptyRole(tag, props);
|
|
467
|
+
if (normalized.normalized) return { proceed: false, result: normalized.result };
|
|
468
|
+
const effectiveRole = props.role ?? implicitRole;
|
|
469
|
+
return {
|
|
470
|
+
proceed: true,
|
|
471
|
+
tag,
|
|
472
|
+
implicitRole,
|
|
473
|
+
effectiveRole,
|
|
474
|
+
context: { tag, props, implicitRole, effectiveRole }
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
static #runRules(rules, context) {
|
|
478
|
+
const violations = [];
|
|
479
|
+
const fixes = [];
|
|
480
|
+
for (const rule of rules) {
|
|
481
|
+
for (const result of rule(context)) {
|
|
482
|
+
if (!result.valid) {
|
|
483
|
+
violations.push({
|
|
484
|
+
message: result.message ?? `Invalid role "${context.props.role}" on <${context.tag}>`,
|
|
485
|
+
tag: context.tag,
|
|
486
|
+
role: context.props.role,
|
|
487
|
+
attribute: result.attribute,
|
|
488
|
+
severity: result.severity,
|
|
489
|
+
phase: "evaluate"
|
|
490
|
+
});
|
|
491
|
+
if (result.fixable) fixes.push(result.fix);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return { violations, fixes };
|
|
496
|
+
}
|
|
497
|
+
static #getRules(context) {
|
|
498
|
+
return _AriaPolicyEngine.#hasRole(context.props) ? _AriaPolicyEngine.#pipeline : [_AriaPolicyEngine.#checkInvalidAriaAttributes];
|
|
499
|
+
}
|
|
500
|
+
static evaluate(tag, props) {
|
|
501
|
+
const derived = _AriaPolicyEngine.#deriveContext(tag, props);
|
|
502
|
+
if (!derived.proceed) return derived.result;
|
|
503
|
+
const { tag: narrowedTag, implicitRole, context } = derived;
|
|
504
|
+
const { violations, fixes } = _AriaPolicyEngine.#runRules(
|
|
505
|
+
_AriaPolicyEngine.#getRules(context),
|
|
506
|
+
context
|
|
507
|
+
);
|
|
508
|
+
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole, props, fixes);
|
|
509
|
+
return { props: next, violations };
|
|
510
|
+
}
|
|
511
|
+
static #evaluateWithRules(tag, props, extraRules) {
|
|
512
|
+
const derived = _AriaPolicyEngine.#deriveContext(tag, props);
|
|
513
|
+
if (!derived.proceed) return derived.result;
|
|
514
|
+
const { tag: narrowedTag, implicitRole, context } = derived;
|
|
515
|
+
const { violations, fixes } = _AriaPolicyEngine.#runRules(
|
|
516
|
+
[..._AriaPolicyEngine.#getRules(context), ...extraRules],
|
|
517
|
+
context
|
|
518
|
+
);
|
|
519
|
+
const next = _AriaPolicyEngine.#applyFixes(narrowedTag, implicitRole, props, fixes);
|
|
520
|
+
return { props: next, violations };
|
|
521
|
+
}
|
|
522
|
+
report(violations) {
|
|
523
|
+
for (const v of violations) {
|
|
524
|
+
if (v.severity === "error") this.violate(v.message);
|
|
525
|
+
else this.warn(v.message);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
// Cache key covers only the aria-relevant subset of props (tag + role + aria-* attrs).
|
|
529
|
+
// Non-aria props (className, onClick, etc.) do not affect ARIA decisions and are excluded
|
|
530
|
+
// so cache hits survive re-renders that only change non-aria props.
|
|
531
|
+
// Note: #extraRules are NOT included in the key — each engine instance has its own Map,
|
|
532
|
+
// so two engines with different rules never share cache entries. If caching ever becomes
|
|
533
|
+
// static/shared, rule identity would need to be folded into the key.
|
|
534
|
+
static #createPlanKey(tag, props) {
|
|
535
|
+
if (!isIntrinsicTag(tag)) return null;
|
|
536
|
+
const parts = [tag];
|
|
537
|
+
if (typeof props.role === "string") parts.push(`role:${props.role}`);
|
|
538
|
+
const ariaEntries = [];
|
|
539
|
+
for (const k in props) {
|
|
540
|
+
if (!Object.hasOwn(props, k) || !k.startsWith("aria-")) continue;
|
|
541
|
+
const v = props[k];
|
|
542
|
+
if (!isString(v) && !isNumber(v) && typeof v !== "boolean") continue;
|
|
543
|
+
ariaEntries.push(`${k}:${String(v)}`);
|
|
544
|
+
}
|
|
545
|
+
if (ariaEntries.length > 0) parts.push(...ariaEntries.sort());
|
|
546
|
+
return parts.join("|");
|
|
547
|
+
}
|
|
548
|
+
static #computePlan(inputProps, resultProps) {
|
|
549
|
+
const removals = /* @__PURE__ */ new Set();
|
|
550
|
+
const updates = {};
|
|
551
|
+
for (const key in inputProps) {
|
|
552
|
+
if (Object.hasOwn(inputProps, key) && !(key in resultProps)) removals.add(key);
|
|
553
|
+
}
|
|
554
|
+
for (const key in resultProps) {
|
|
555
|
+
if (!Object.hasOwn(resultProps, key)) continue;
|
|
556
|
+
const resultVal = resultProps[key];
|
|
557
|
+
if (inputProps[key] !== resultVal) updates[key] = resultVal;
|
|
558
|
+
}
|
|
559
|
+
return { removals, updates };
|
|
560
|
+
}
|
|
561
|
+
static #applyPlan(props, removals, updates) {
|
|
562
|
+
const hasRemovals = removals.size > 0;
|
|
563
|
+
const hasUpdates = Object.keys(updates).length > 0;
|
|
564
|
+
if (!hasRemovals && !hasUpdates) return props;
|
|
565
|
+
const next = {};
|
|
566
|
+
for (const k in props) {
|
|
567
|
+
if (Object.hasOwn(props, k) && !removals.has(k)) next[k] = props[k];
|
|
568
|
+
}
|
|
569
|
+
Object.assign(next, updates);
|
|
570
|
+
return next;
|
|
571
|
+
}
|
|
572
|
+
validate(tag, props) {
|
|
573
|
+
const key = _AriaPolicyEngine.#createPlanKey(tag, props);
|
|
574
|
+
if (!isNull2(key)) {
|
|
575
|
+
const cached = this.#planCache.get(key);
|
|
576
|
+
if (cached !== void 0) {
|
|
577
|
+
this.#planCache.delete(key);
|
|
578
|
+
this.#planCache.set(key, cached);
|
|
579
|
+
if (cached.violations.length > 0) this.report(cached.violations);
|
|
580
|
+
return {
|
|
581
|
+
props: _AriaPolicyEngine.#applyPlan(props, cached.removals, cached.updates),
|
|
582
|
+
violations: cached.violations
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const result = this.#extraRules.length ? _AriaPolicyEngine.#evaluateWithRules(tag, props, this.#extraRules) : _AriaPolicyEngine.evaluate(tag, props);
|
|
587
|
+
if (result.violations.length > 0) this.report(result.violations);
|
|
588
|
+
if (!isNull2(key)) {
|
|
589
|
+
const { removals, updates } = _AriaPolicyEngine.#computePlan(
|
|
590
|
+
props,
|
|
591
|
+
result.props
|
|
592
|
+
);
|
|
593
|
+
const plan = { removals, updates, violations: result.violations };
|
|
594
|
+
this.#planCache.set(key, plan);
|
|
595
|
+
if (this.#planCache.size > _AriaPolicyEngine.#MAX_CACHE) {
|
|
596
|
+
const lru = this.#planCache.keys().next().value;
|
|
597
|
+
if (lru !== void 0) this.#planCache.delete(lru);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return result;
|
|
601
|
+
}
|
|
602
|
+
static #hasRole(props) {
|
|
603
|
+
return isString(props.role) && props.role.length > 0;
|
|
604
|
+
}
|
|
605
|
+
static #applyFixes(tag, implicitRole, props, fixes) {
|
|
606
|
+
if (fixes.length === 0) return props;
|
|
607
|
+
const sorted = [...fixes].sort((a, b) => (a.priority ?? Infinity) - (b.priority ?? Infinity));
|
|
608
|
+
let next = props;
|
|
609
|
+
for (const { apply } of sorted) {
|
|
610
|
+
const effectiveRole = next.role ?? implicitRole;
|
|
611
|
+
const fixContext = { tag, implicitRole, effectiveRole, props: next };
|
|
612
|
+
const fixResult = apply(fixContext);
|
|
613
|
+
if (fixResult.applied) next = fixResult.next;
|
|
614
|
+
}
|
|
615
|
+
return next;
|
|
616
|
+
}
|
|
617
|
+
static #removeRole = {
|
|
618
|
+
kind: "removeRole",
|
|
619
|
+
apply: ({ props }) => {
|
|
620
|
+
if (!("role" in props)) return { applied: false, next: props };
|
|
621
|
+
return { applied: true, next: omitProp(props, "role"), previous: props };
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
static #makeRemoveAttributeFix(attr) {
|
|
625
|
+
const cached = _AriaPolicyEngine.#removeAttributeFixCache.get(attr);
|
|
626
|
+
if (cached) return cached;
|
|
627
|
+
const fix = {
|
|
628
|
+
kind: `removeAttribute:${attr}`,
|
|
629
|
+
apply: ({ props }) => {
|
|
630
|
+
if (!(attr in props)) return { applied: false, next: props };
|
|
631
|
+
return { applied: true, next: omitProp(props, attr), previous: props };
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
_AriaPolicyEngine.#removeAttributeFixCache.set(attr, fix);
|
|
635
|
+
return fix;
|
|
636
|
+
}
|
|
637
|
+
// Snapshot diagnostic model: all rules evaluate against the same (tag, props, implicitRole) snapshot.
|
|
638
|
+
static #pipeline = [
|
|
639
|
+
_AriaPolicyEngine.#checkInvalidRoleOverride,
|
|
640
|
+
_AriaPolicyEngine.#checkRedundantRole,
|
|
641
|
+
_AriaPolicyEngine.#checkStandaloneRegion,
|
|
642
|
+
_AriaPolicyEngine.#checkInvalidAriaAttributes,
|
|
643
|
+
_AriaPolicyEngine.#checkMissingLiveRegion,
|
|
644
|
+
_AriaPolicyEngine.#checkMissingAtomic,
|
|
645
|
+
_AriaPolicyEngine.#checkInvalidAriaRelevant
|
|
646
|
+
];
|
|
647
|
+
static #checkInvalidRoleOverride({
|
|
648
|
+
tag,
|
|
649
|
+
props,
|
|
650
|
+
implicitRole
|
|
651
|
+
}) {
|
|
652
|
+
const role = props.role;
|
|
653
|
+
if (!implicitRole || !role || role === implicitRole) return VALID;
|
|
654
|
+
if (isStrongImplicitRole(tag) && role === "region") {
|
|
655
|
+
return [
|
|
656
|
+
{
|
|
657
|
+
valid: false,
|
|
658
|
+
fixable: true,
|
|
659
|
+
severity: "error",
|
|
660
|
+
fix: _AriaPolicyEngine.#removeRole,
|
|
661
|
+
message: `<${tag}> should not override its implicit role="${implicitRole}" with role="${role}".`
|
|
662
|
+
}
|
|
663
|
+
];
|
|
664
|
+
}
|
|
665
|
+
return VALID;
|
|
666
|
+
}
|
|
667
|
+
static #checkRedundantRole({ tag, props, implicitRole }) {
|
|
668
|
+
const role = props.role;
|
|
669
|
+
if (!implicitRole || !role || role !== implicitRole) return VALID;
|
|
670
|
+
return [
|
|
671
|
+
{
|
|
672
|
+
valid: false,
|
|
673
|
+
fixable: true,
|
|
674
|
+
severity: "warning",
|
|
675
|
+
fix: _AriaPolicyEngine.#removeRole,
|
|
676
|
+
message: `<${tag}> already has implicit role="${implicitRole}". Avoid redundant role assignment.`
|
|
677
|
+
}
|
|
678
|
+
];
|
|
679
|
+
}
|
|
680
|
+
static #checkStandaloneRegion({ tag, props, implicitRole }) {
|
|
681
|
+
const role = props.role;
|
|
682
|
+
if (role !== "region") return VALID;
|
|
683
|
+
if (!isStandaloneTag(tag)) return VALID;
|
|
684
|
+
return [
|
|
685
|
+
{
|
|
686
|
+
valid: false,
|
|
687
|
+
fixable: true,
|
|
688
|
+
severity: "error",
|
|
689
|
+
fix: _AriaPolicyEngine.#removeRole,
|
|
690
|
+
message: `<${tag}> is a self-contained element with implicit role="${implicitRole}". Assigning role="region" has been removed.`
|
|
691
|
+
}
|
|
692
|
+
];
|
|
693
|
+
}
|
|
694
|
+
static #checkInvalidAriaAttributes({
|
|
695
|
+
tag,
|
|
696
|
+
props,
|
|
697
|
+
effectiveRole
|
|
698
|
+
}) {
|
|
699
|
+
const results = [];
|
|
700
|
+
for (const key in props) {
|
|
701
|
+
if (!Object.hasOwn(props, key)) continue;
|
|
702
|
+
if (!key.startsWith("aria-")) continue;
|
|
703
|
+
if (isGlobalAriaAttribute(key)) continue;
|
|
704
|
+
if (isAriaAttributeValidForRole(key, effectiveRole)) continue;
|
|
705
|
+
results.push({
|
|
706
|
+
valid: false,
|
|
707
|
+
severity: "warning",
|
|
708
|
+
fixable: true,
|
|
709
|
+
attribute: key,
|
|
710
|
+
message: `"${key}" is not valid on role="${effectiveRole ?? tag}". It will be removed.`,
|
|
711
|
+
fix: _AriaPolicyEngine.#makeRemoveAttributeFix(key)
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
return results;
|
|
715
|
+
}
|
|
716
|
+
// WAI-ARIA live region roles and their implied aria-live politeness values.
|
|
717
|
+
static #LIVE_REGION_ROLES = /* @__PURE__ */ new Map([
|
|
718
|
+
["alert", "assertive"],
|
|
719
|
+
["status", "polite"],
|
|
720
|
+
["log", "polite"],
|
|
721
|
+
["timer", "off"]
|
|
722
|
+
]);
|
|
723
|
+
static #checkMissingLiveRegion({ effectiveRole, props }) {
|
|
724
|
+
if (!effectiveRole) return VALID;
|
|
725
|
+
const impliedLive = _AriaPolicyEngine.#LIVE_REGION_ROLES.get(effectiveRole);
|
|
726
|
+
if (!impliedLive) return VALID;
|
|
727
|
+
if ("aria-live" in props) return VALID;
|
|
728
|
+
const injectLive = {
|
|
729
|
+
kind: `injectLive:${effectiveRole}`,
|
|
730
|
+
apply: (ctx) => ({
|
|
731
|
+
applied: true,
|
|
732
|
+
next: { ...ctx.props, "aria-live": impliedLive },
|
|
733
|
+
previous: ctx.props
|
|
734
|
+
})
|
|
735
|
+
};
|
|
736
|
+
return [
|
|
737
|
+
{
|
|
738
|
+
valid: false,
|
|
739
|
+
fixable: true,
|
|
740
|
+
severity: "warning",
|
|
741
|
+
fix: injectLive,
|
|
742
|
+
message: `role="${effectiveRole}" implies aria-live="${impliedLive}" but it is missing. It has been injected.`
|
|
743
|
+
}
|
|
744
|
+
];
|
|
745
|
+
}
|
|
746
|
+
static #checkMissingAtomic({ effectiveRole, props }) {
|
|
747
|
+
if (!effectiveRole || !_AriaPolicyEngine.#LIVE_REGION_ROLES.has(effectiveRole)) return VALID;
|
|
748
|
+
if ("aria-atomic" in props) return VALID;
|
|
749
|
+
return [
|
|
750
|
+
{
|
|
751
|
+
valid: false,
|
|
752
|
+
fixable: false,
|
|
753
|
+
severity: "warning",
|
|
754
|
+
message: `role="${effectiveRole}" is a live region. Consider setting aria-atomic="true" if the full region should be announced as a unit, or aria-atomic="false" if only changed nodes should be read.`
|
|
755
|
+
}
|
|
756
|
+
];
|
|
757
|
+
}
|
|
758
|
+
static #VALID_RELEVANT_TOKENS = /* @__PURE__ */ new Set(["additions", "removals", "text", "all"]);
|
|
759
|
+
// Custom fix rules passed via `options.rules` must be pure functions of (tag, props) — the cache
|
|
760
|
+
// replays stored fixes against new prop objects, so fixes that close over external state will
|
|
761
|
+
// produce inconsistent results on cache hits.
|
|
762
|
+
static #normalizeRelevantAllFix = {
|
|
763
|
+
kind: "normalizeRelevantAll",
|
|
764
|
+
apply: ({ props: p }) => ({
|
|
765
|
+
applied: true,
|
|
766
|
+
next: { ...p, "aria-relevant": "all" },
|
|
767
|
+
previous: p
|
|
768
|
+
})
|
|
769
|
+
};
|
|
770
|
+
static #checkInvalidAriaRelevant({ props }) {
|
|
771
|
+
const relevant = props["aria-relevant"];
|
|
772
|
+
if (relevant === void 0) return VALID;
|
|
773
|
+
if (typeof relevant !== "string") return VALID;
|
|
774
|
+
const tokens = relevant.trim().split(/\s+/);
|
|
775
|
+
const invalid = tokens.filter((t) => !_AriaPolicyEngine.#VALID_RELEVANT_TOKENS.has(t));
|
|
776
|
+
if (invalid.length > 0) {
|
|
777
|
+
return [
|
|
778
|
+
{
|
|
779
|
+
valid: false,
|
|
780
|
+
fixable: true,
|
|
781
|
+
severity: "warning",
|
|
782
|
+
attribute: "aria-relevant",
|
|
783
|
+
message: `aria-relevant contains invalid token(s): ${invalid.map((t) => `"${t}"`).join(", ")}. Valid tokens are: additions, removals, text, all.`,
|
|
784
|
+
fix: _AriaPolicyEngine.#makeRemoveAttributeFix("aria-relevant")
|
|
785
|
+
}
|
|
786
|
+
];
|
|
787
|
+
}
|
|
788
|
+
if (tokens.includes("all") && tokens.length > 1) {
|
|
789
|
+
return [
|
|
790
|
+
{
|
|
791
|
+
valid: false,
|
|
792
|
+
fixable: true,
|
|
793
|
+
severity: "warning",
|
|
794
|
+
attribute: "aria-relevant",
|
|
795
|
+
message: `aria-relevant includes "all" alongside other tokens. "all" supersedes additions, removals, and text \u2014 use aria-relevant="all" alone.`,
|
|
796
|
+
fix: _AriaPolicyEngine.#normalizeRelevantAllFix
|
|
797
|
+
}
|
|
798
|
+
];
|
|
799
|
+
}
|
|
800
|
+
return VALID;
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
function getTypeName(value) {
|
|
804
|
+
if (value === null) return "null";
|
|
805
|
+
if (value === void 0) return "undefined";
|
|
806
|
+
const primitive = typeof value;
|
|
807
|
+
if (primitive !== "object") {
|
|
808
|
+
return primitive;
|
|
809
|
+
}
|
|
810
|
+
const name = value.constructor?.name;
|
|
811
|
+
return typeof name === "string" && name !== "Object" ? name : "object";
|
|
812
|
+
}
|
|
813
|
+
var MatchValidationErrorBuilder = class {
|
|
814
|
+
#prefix;
|
|
815
|
+
constructor(ctx = "") {
|
|
816
|
+
this.#prefix = ctx ? `${ctx}:
|
|
817
|
+
` : "";
|
|
818
|
+
}
|
|
819
|
+
#template(typeName, index, prefix = "", suffix = "") {
|
|
820
|
+
const leadingStr = prefix ? `${prefix} ` : "";
|
|
821
|
+
const followingStr = suffix ? ` ${suffix}` : "";
|
|
822
|
+
return `${leadingStr}child "${typeName}" at index ${index}${followingStr}.`;
|
|
823
|
+
}
|
|
824
|
+
unexpectedChild(typeName, index) {
|
|
825
|
+
return this.#template(typeName, index, "unexpected");
|
|
826
|
+
}
|
|
827
|
+
multipleMatches(typeName, index, ruleNames) {
|
|
828
|
+
const quoted = ruleNames.map((n) => `"${n}"`);
|
|
829
|
+
return this.#template(
|
|
830
|
+
typeName,
|
|
831
|
+
index,
|
|
832
|
+
"",
|
|
833
|
+
`matches multiple child rules: ${quoted.join(" and ")}`
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
#format(errors) {
|
|
837
|
+
return this.#prefix + errors.join("\n");
|
|
838
|
+
}
|
|
839
|
+
toError(errors) {
|
|
840
|
+
if (errors.length === 0) {
|
|
841
|
+
return new Error(this.#prefix + "Unknown validation error.");
|
|
842
|
+
}
|
|
843
|
+
return new Error(this.#format(errors));
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
function normalizeCardinality(input, impliesSingleton) {
|
|
847
|
+
const min = input?.min ?? 0;
|
|
848
|
+
const max = input?.max ?? (impliesSingleton ? 1 : Infinity);
|
|
849
|
+
if (min === 0 && max === Infinity) {
|
|
850
|
+
return { kind: "unbounded" };
|
|
851
|
+
}
|
|
852
|
+
if (min > max) {
|
|
853
|
+
throw new RangeError(`normalizeChildRule: min (${min}) cannot exceed max (${max})`);
|
|
854
|
+
}
|
|
855
|
+
return {
|
|
856
|
+
kind: "bounded",
|
|
857
|
+
min,
|
|
858
|
+
max
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
function normalizeChildRule(rule) {
|
|
862
|
+
const position = rule.position ?? "any";
|
|
863
|
+
const impliesSingleton = position === "first" || position === "last";
|
|
864
|
+
return {
|
|
865
|
+
...rule,
|
|
866
|
+
position,
|
|
867
|
+
cardinality: normalizeCardinality(rule.cardinality, impliesSingleton)
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
function getChildType(child) {
|
|
871
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
872
|
+
return child.type;
|
|
873
|
+
}
|
|
874
|
+
function buildPartialIndex(rules) {
|
|
875
|
+
const typeIndex = /* @__PURE__ */ new Map();
|
|
876
|
+
const duplicateTypes = /* @__PURE__ */ new Set();
|
|
877
|
+
const untypedIndices = [];
|
|
878
|
+
for (let ri = 0; ri < rules.length; ri++) {
|
|
879
|
+
const t = rules[ri].type;
|
|
880
|
+
if (t === void 0) {
|
|
881
|
+
untypedIndices.push(ri);
|
|
882
|
+
} else if (typeIndex.has(t)) {
|
|
883
|
+
duplicateTypes.add(t);
|
|
884
|
+
} else {
|
|
885
|
+
typeIndex.set(t, ri);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
if (duplicateTypes.size > 0) {
|
|
889
|
+
for (const t of duplicateTypes) typeIndex.delete(t);
|
|
890
|
+
for (let ri = 0; ri < rules.length; ri++) {
|
|
891
|
+
if (duplicateTypes.has(rules[ri].type)) untypedIndices.push(ri);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return { typeIndex, untypedIndices };
|
|
895
|
+
}
|
|
896
|
+
var RuleMatcher = class {
|
|
897
|
+
#rules;
|
|
898
|
+
#typeIndex;
|
|
899
|
+
#untypedIndices;
|
|
900
|
+
constructor(rules) {
|
|
901
|
+
this.#rules = rules;
|
|
902
|
+
const { typeIndex, untypedIndices } = buildPartialIndex(rules);
|
|
903
|
+
this.#typeIndex = typeIndex;
|
|
904
|
+
this.#untypedIndices = untypedIndices;
|
|
905
|
+
}
|
|
906
|
+
match(children) {
|
|
907
|
+
const forward = /* @__PURE__ */ new Map();
|
|
908
|
+
const reverse = /* @__PURE__ */ new Map();
|
|
909
|
+
const unexpectedIndices = /* @__PURE__ */ new Set();
|
|
910
|
+
const ambiguousIndices = /* @__PURE__ */ new Set();
|
|
911
|
+
for (let ri = 0; ri < this.#rules.length; ri++) {
|
|
912
|
+
reverse.set(ri, /* @__PURE__ */ new Set());
|
|
913
|
+
}
|
|
914
|
+
for (const [ci, child] of children.entries()) {
|
|
915
|
+
const t = getChildType(child);
|
|
916
|
+
if (t !== void 0) {
|
|
917
|
+
const ri = this.#typeIndex.get(t);
|
|
918
|
+
if (ri !== void 0) {
|
|
919
|
+
let childEntry = forward.get(ci);
|
|
920
|
+
if (!childEntry) {
|
|
921
|
+
childEntry = /* @__PURE__ */ new Set();
|
|
922
|
+
forward.set(ci, childEntry);
|
|
923
|
+
}
|
|
924
|
+
childEntry.add(ri);
|
|
925
|
+
reverse.get(ri).add(ci);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
for (const ri of this.#untypedIndices) {
|
|
929
|
+
if (!this.#rules[ri].match(child)) continue;
|
|
930
|
+
let childEntry = forward.get(ci);
|
|
931
|
+
if (!childEntry) {
|
|
932
|
+
childEntry = /* @__PURE__ */ new Set();
|
|
933
|
+
forward.set(ci, childEntry);
|
|
934
|
+
}
|
|
935
|
+
childEntry.add(ri);
|
|
936
|
+
reverse.get(ri).add(ci);
|
|
937
|
+
}
|
|
938
|
+
const entry = forward.get(ci);
|
|
939
|
+
if (!entry) {
|
|
940
|
+
unexpectedIndices.add(ci);
|
|
941
|
+
} else if (entry.size > 1) {
|
|
942
|
+
ambiguousIndices.add(ci);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return { matrix: { childToRules: { forward, reverse } }, unexpectedIndices, ambiguousIndices };
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
var RuleValidator = class _RuleValidator extends StrictBase {
|
|
949
|
+
#context;
|
|
950
|
+
constructor(context, strict) {
|
|
951
|
+
super(strict);
|
|
952
|
+
this.#context = context;
|
|
953
|
+
}
|
|
954
|
+
validate(rules, matrix, childCount) {
|
|
955
|
+
const firstIndex = 0;
|
|
956
|
+
const lastIndex = childCount - 1;
|
|
957
|
+
for (const [ri, rule] of rules.entries()) {
|
|
958
|
+
const matches = matrix.childToRules.reverse.get(ri);
|
|
959
|
+
const matchCount = matches.size;
|
|
960
|
+
this.#validateCardinality(rule, matchCount);
|
|
961
|
+
if (matchCount === 0) continue;
|
|
962
|
+
this.#validatePositions(rule, matches, firstIndex, lastIndex);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
#validateCardinality(rule, matchCount) {
|
|
966
|
+
const { cardinality, name } = rule;
|
|
967
|
+
if (cardinality.kind !== "bounded") {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
const { min, max } = cardinality;
|
|
971
|
+
if (matchCount < min) {
|
|
972
|
+
this.violate(`${this.#context}: "${name}" requires at least ${min}.`);
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
if (matchCount > max) {
|
|
976
|
+
this.violate(`${this.#context}: "${name}" allows at most ${max}.`);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
#validatePositions(rule, matches, firstIndex, lastIndex) {
|
|
980
|
+
const { name, position } = rule;
|
|
981
|
+
for (const index of matches) {
|
|
982
|
+
if (_RuleValidator.#isValidPosition(index, position, firstIndex, lastIndex)) {
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
this.violate(`${this.#context}: "${name}" must be ${position}, got index ${index}`);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
static #isValidPosition(matchIndex, position, firstIndex, lastIndex) {
|
|
989
|
+
switch (position) {
|
|
990
|
+
case "first":
|
|
991
|
+
return matchIndex === firstIndex;
|
|
992
|
+
case "last":
|
|
993
|
+
return matchIndex === lastIndex;
|
|
994
|
+
case "any":
|
|
995
|
+
return true;
|
|
996
|
+
default:
|
|
997
|
+
return assertNever(position);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
var ChildrenEvaluator = class extends StrictBase {
|
|
1002
|
+
#rules;
|
|
1003
|
+
#ruleNames;
|
|
1004
|
+
#matcher;
|
|
1005
|
+
#ruleValidator;
|
|
1006
|
+
#matchBuilder;
|
|
1007
|
+
constructor(rules, strict = "warn", context = "Component") {
|
|
1008
|
+
super(strict);
|
|
1009
|
+
this.#rules = rules.map((r) => normalizeChildRule(r));
|
|
1010
|
+
this.#ruleNames = this.#rules.map((r) => r.name);
|
|
1011
|
+
for (const rule of this.#rules) {
|
|
1012
|
+
const { name, position, cardinality } = rule;
|
|
1013
|
+
if ((position === "first" || position === "last") && (cardinality.kind === "unbounded" || cardinality.max > 1)) {
|
|
1014
|
+
throw new RangeError(
|
|
1015
|
+
`ChildrenEvaluator [${context}]: rule "${name}" sets position="${position}" with an unbound or >1 max. position="first|last" implies max=1.`
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
this.#matcher = new RuleMatcher(this.#rules);
|
|
1020
|
+
this.#ruleValidator = new RuleValidator(context, strict);
|
|
1021
|
+
this.#matchBuilder = new MatchValidationErrorBuilder(context);
|
|
1022
|
+
}
|
|
1023
|
+
evaluate(children) {
|
|
1024
|
+
if (!this.strict) return;
|
|
1025
|
+
const { matrix, unexpectedIndices, ambiguousIndices } = this.#matcher.match(children);
|
|
1026
|
+
this.#ruleValidator.validate(this.#rules, matrix, children.length);
|
|
1027
|
+
if (unexpectedIndices.size === 0 && ambiguousIndices.size === 0) return;
|
|
1028
|
+
const errors = [];
|
|
1029
|
+
const violating = [...unexpectedIndices, ...ambiguousIndices].sort((a, b) => a - b);
|
|
1030
|
+
for (const ci of violating) {
|
|
1031
|
+
const typeName = getTypeName(children[ci]);
|
|
1032
|
+
if (unexpectedIndices.has(ci)) {
|
|
1033
|
+
errors.push(this.#matchBuilder.unexpectedChild(typeName, ci));
|
|
1034
|
+
} else {
|
|
1035
|
+
const matches = matrix.childToRules.forward.get(ci);
|
|
1036
|
+
const names = [...matches].map((ri) => this.#ruleNames[ri] ?? `#${ri}`);
|
|
1037
|
+
errors.push(this.#matchBuilder.multipleMatches(typeName, ci, names));
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
this.invariant(errors.length === 0, this.#matchBuilder.toError(errors).message);
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
var activeProps = ({
|
|
1044
|
+
active,
|
|
1045
|
+
"aria-current": ariaCurrent,
|
|
1046
|
+
"data-active": dataActive
|
|
1047
|
+
}) => {
|
|
1048
|
+
if (!active) return {};
|
|
1049
|
+
return {
|
|
1050
|
+
...ariaCurrent === void 0 && {
|
|
1051
|
+
"aria-current": "true"
|
|
1052
|
+
},
|
|
1053
|
+
...dataActive === void 0 && {
|
|
1054
|
+
"data-active": ""
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
};
|
|
1058
|
+
var disabledProps = ({
|
|
1059
|
+
disabled,
|
|
1060
|
+
"aria-disabled": ariaDisabled,
|
|
1061
|
+
"data-disabled": dataDisabled
|
|
1062
|
+
}) => {
|
|
1063
|
+
if (!disabled) return {};
|
|
1064
|
+
return {
|
|
1065
|
+
...ariaDisabled === void 0 && { "aria-disabled": "true" },
|
|
1066
|
+
...dataDisabled === void 0 && { "data-disabled": "" }
|
|
1067
|
+
};
|
|
1068
|
+
};
|
|
1069
|
+
var expandedProps = ({
|
|
1070
|
+
expanded,
|
|
1071
|
+
"aria-expanded": ariaExpanded,
|
|
1072
|
+
"data-expanded": dataExpanded
|
|
1073
|
+
}) => {
|
|
1074
|
+
if (!expanded) return {};
|
|
1075
|
+
return {
|
|
1076
|
+
...ariaExpanded === void 0 && {
|
|
1077
|
+
"aria-expanded": "true"
|
|
1078
|
+
},
|
|
1079
|
+
...dataExpanded === void 0 && {
|
|
1080
|
+
"data-expanded": ""
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
};
|
|
1084
|
+
var invalidProps = ({
|
|
1085
|
+
invalid,
|
|
1086
|
+
"aria-invalid": ariaInvalid,
|
|
1087
|
+
"data-invalid": dataInvalid
|
|
1088
|
+
}) => {
|
|
1089
|
+
if (!invalid) return {};
|
|
1090
|
+
return {
|
|
1091
|
+
...ariaInvalid === void 0 && { "aria-invalid": "true" },
|
|
1092
|
+
...dataInvalid === void 0 && { "data-invalid": "" }
|
|
1093
|
+
};
|
|
1094
|
+
};
|
|
1095
|
+
var loadingProps = ({
|
|
1096
|
+
loading,
|
|
1097
|
+
"aria-busy": ariaBusy,
|
|
1098
|
+
"data-loading": dataLoading
|
|
1099
|
+
}) => {
|
|
1100
|
+
if (!loading) return {};
|
|
1101
|
+
return {
|
|
1102
|
+
...ariaBusy === void 0 && {
|
|
1103
|
+
"aria-busy": "true"
|
|
1104
|
+
},
|
|
1105
|
+
...dataLoading === void 0 && {
|
|
1106
|
+
"data-loading": ""
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
};
|
|
1110
|
+
var pressedProps = ({
|
|
1111
|
+
pressed,
|
|
1112
|
+
"aria-pressed": ariaPressed,
|
|
1113
|
+
"data-pressed": dataPressed
|
|
1114
|
+
}) => {
|
|
1115
|
+
if (!pressed) return {};
|
|
1116
|
+
return {
|
|
1117
|
+
...ariaPressed === void 0 && {
|
|
1118
|
+
"aria-pressed": "true"
|
|
1119
|
+
},
|
|
1120
|
+
...dataPressed === void 0 && {
|
|
1121
|
+
"data-pressed": ""
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
};
|
|
1125
|
+
var readonlyProps = ({
|
|
1126
|
+
readOnly,
|
|
1127
|
+
"aria-readonly": ariaReadonly,
|
|
1128
|
+
"data-readonly": dataReadonly
|
|
1129
|
+
}) => {
|
|
1130
|
+
if (!readOnly) return {};
|
|
1131
|
+
return {
|
|
1132
|
+
...ariaReadonly === void 0 && {
|
|
1133
|
+
"aria-readonly": "true"
|
|
1134
|
+
},
|
|
1135
|
+
...dataReadonly === void 0 && {
|
|
1136
|
+
"data-readonly": ""
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
};
|
|
1140
|
+
var selectedProps = ({
|
|
1141
|
+
selected,
|
|
1142
|
+
"aria-selected": ariaSelected,
|
|
1143
|
+
"data-selected": dataSelected
|
|
1144
|
+
}) => {
|
|
1145
|
+
if (!selected) return {};
|
|
1146
|
+
return {
|
|
1147
|
+
...ariaSelected === void 0 && {
|
|
1148
|
+
"aria-selected": "true"
|
|
1149
|
+
},
|
|
1150
|
+
...dataSelected === void 0 && {
|
|
1151
|
+
"data-selected": ""
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
|
|
1156
|
+
var removeLandmarkRoleOverride = {
|
|
1157
|
+
kind: "removeRole",
|
|
1158
|
+
apply: ({ props }) => {
|
|
1159
|
+
if (!("role" in props)) return { applied: false, next: props };
|
|
1160
|
+
const { role: _r, ...rest } = props;
|
|
1161
|
+
return { applied: true, next: rest, previous: props };
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
function landmarkRoleRule({ tag, props, implicitRole }) {
|
|
1165
|
+
if (!LANDMARK_TAG_SET.has(tag) || !implicitRole) return [];
|
|
1166
|
+
const role = props.role;
|
|
1167
|
+
if (!role || role === implicitRole) return [];
|
|
1168
|
+
return [
|
|
1169
|
+
{
|
|
1170
|
+
valid: false,
|
|
1171
|
+
fixable: true,
|
|
1172
|
+
severity: "error",
|
|
1173
|
+
fix: removeLandmarkRoleOverride,
|
|
1174
|
+
message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
|
|
1175
|
+
}
|
|
1176
|
+
];
|
|
1177
|
+
}
|
|
1178
|
+
function isOpenContent(...blockedTags) {
|
|
1179
|
+
const set = new Set(blockedTags);
|
|
1180
|
+
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set.has(child.type));
|
|
1181
|
+
}
|
|
1182
|
+
var METADATA_TAGS = ["script", "template"];
|
|
1183
|
+
var metadataMatch = isTag(...METADATA_TAGS);
|
|
1184
|
+
function metadata(name = "metadata") {
|
|
1185
|
+
return { name, match: metadataMatch };
|
|
1186
|
+
}
|
|
1187
|
+
function firstOptional(name, tag) {
|
|
1188
|
+
return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
|
|
1189
|
+
}
|
|
1190
|
+
function contract(children) {
|
|
1191
|
+
return { strict: "warn", children };
|
|
1192
|
+
}
|
|
1193
|
+
function ariaContract(aria) {
|
|
1194
|
+
return { strict: "warn", aria };
|
|
1195
|
+
}
|
|
1196
|
+
function firstChildContract(name, tag) {
|
|
1197
|
+
return contract([firstOptional(name, tag), { name: "content", match: isOpenContent(tag) }]);
|
|
1198
|
+
}
|
|
1199
|
+
var VOID_TAGS = [
|
|
1200
|
+
"area",
|
|
1201
|
+
"base",
|
|
1202
|
+
"br",
|
|
1203
|
+
"col",
|
|
1204
|
+
"embed",
|
|
1205
|
+
"hr",
|
|
1206
|
+
"img",
|
|
1207
|
+
"input",
|
|
1208
|
+
"link",
|
|
1209
|
+
"meta",
|
|
1210
|
+
"param",
|
|
1211
|
+
"source",
|
|
1212
|
+
"track",
|
|
1213
|
+
"wbr"
|
|
1214
|
+
];
|
|
1215
|
+
var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
|
|
1216
|
+
var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
|
|
1217
|
+
var listContract = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
|
|
1218
|
+
var tableContract = contract([
|
|
1219
|
+
firstOptional("caption", "caption"),
|
|
1220
|
+
{ name: "colgroup", match: isTag("colgroup") },
|
|
1221
|
+
{ name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
|
|
1222
|
+
{ name: "tbody", match: isTag("tbody") },
|
|
1223
|
+
{ name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
|
|
1224
|
+
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
1225
|
+
]);
|
|
1226
|
+
var tableBodyContract = contract([
|
|
1227
|
+
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
1228
|
+
]);
|
|
1229
|
+
var tableRowContract = contract([
|
|
1230
|
+
{ name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
|
|
1231
|
+
]);
|
|
1232
|
+
var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
|
|
1233
|
+
var dlContract = contract([
|
|
1234
|
+
{ name: "term", match: isTag("dt") },
|
|
1235
|
+
{ name: "description", match: isTag("dd") },
|
|
1236
|
+
{ name: "group", match: isTag("div") },
|
|
1237
|
+
metadata()
|
|
1238
|
+
]);
|
|
1239
|
+
var selectContract = contract([
|
|
1240
|
+
{ name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
|
|
1241
|
+
]);
|
|
1242
|
+
var optgroupContract = contract([
|
|
1243
|
+
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
1244
|
+
]);
|
|
1245
|
+
var datalistContract = contract([
|
|
1246
|
+
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
1247
|
+
]);
|
|
1248
|
+
var pictureContract = contract([
|
|
1249
|
+
{ name: "source", match: isTag("source", ...METADATA_TAGS) },
|
|
1250
|
+
{ name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
|
|
1251
|
+
]);
|
|
1252
|
+
var figureContract = contract([
|
|
1253
|
+
{ name: "caption", match: isTag("figcaption"), cardinality: { max: 1 } },
|
|
1254
|
+
{ name: "content", match: isOpenContent("figcaption") }
|
|
1255
|
+
]);
|
|
1256
|
+
var detailsContract = firstChildContract("summary", "summary");
|
|
1257
|
+
var fieldsetContract = firstChildContract("legend", "legend");
|
|
1258
|
+
var mediaContract = contract([
|
|
1259
|
+
{ name: "source", match: isTag("source") },
|
|
1260
|
+
{ name: "track", match: isTag("track") },
|
|
1261
|
+
metadata(),
|
|
1262
|
+
{ name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
|
|
1263
|
+
]);
|
|
1264
|
+
var headContract = contract([
|
|
1265
|
+
{
|
|
1266
|
+
name: "metadata",
|
|
1267
|
+
match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
|
|
1268
|
+
}
|
|
1269
|
+
]);
|
|
1270
|
+
var htmlContract = contract([
|
|
1271
|
+
{ name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
|
|
1272
|
+
{ name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
|
|
1273
|
+
]);
|
|
1274
|
+
var voidContract = contract([]);
|
|
1275
|
+
var textOnlyContract = contract([
|
|
1276
|
+
{
|
|
1277
|
+
name: "text",
|
|
1278
|
+
match: (child) => isString(child) || isNumber(child)
|
|
1279
|
+
}
|
|
1280
|
+
]);
|
|
1281
|
+
var landmarkContract = ariaContract([landmarkRoleRule]);
|
|
1282
|
+
var CONTRACT_GROUPS = [
|
|
1283
|
+
[VOID_TAGS, voidContract],
|
|
1284
|
+
[TEXT_ONLY_TAGS, textOnlyContract],
|
|
1285
|
+
[LANDMARK_TAGS, landmarkContract],
|
|
1286
|
+
[["ul", "ol", "menu"], listContract],
|
|
1287
|
+
[["audio", "video"], mediaContract],
|
|
1288
|
+
[["thead", "tbody", "tfoot"], tableBodyContract]
|
|
1289
|
+
];
|
|
1290
|
+
function contractMap(groups) {
|
|
1291
|
+
return Object.fromEntries(
|
|
1292
|
+
groups.flatMap(([tags, enforcement]) => tags.map((tag) => [tag, enforcement]))
|
|
1293
|
+
);
|
|
1294
|
+
}
|
|
1295
|
+
var htmlContracts = {
|
|
1296
|
+
...contractMap(CONTRACT_GROUPS),
|
|
1297
|
+
table: tableContract,
|
|
1298
|
+
tr: tableRowContract,
|
|
1299
|
+
colgroup: colgroupContract,
|
|
1300
|
+
dl: dlContract,
|
|
1301
|
+
select: selectContract,
|
|
1302
|
+
optgroup: optgroupContract,
|
|
1303
|
+
datalist: datalistContract,
|
|
1304
|
+
picture: pictureContract,
|
|
1305
|
+
figure: figureContract,
|
|
1306
|
+
details: detailsContract,
|
|
1307
|
+
fieldset: fieldsetContract,
|
|
1308
|
+
head: headContract,
|
|
1309
|
+
html: htmlContract
|
|
1310
|
+
};
|
|
1311
|
+
function buildEvaluatorMap() {
|
|
1312
|
+
const map = /* @__PURE__ */ new Map();
|
|
1313
|
+
for (const [tag, { children }] of Object.entries(htmlContracts)) {
|
|
1314
|
+
if (children?.length) {
|
|
1315
|
+
map.set(tag, new ChildrenEvaluator(children, "warn", `<${tag}>`));
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
return map;
|
|
1319
|
+
}
|
|
1320
|
+
var HTML_EVALUATORS = buildEvaluatorMap();
|
|
1321
|
+
|
|
1322
|
+
// ../core/dist/contract.js
|
|
1323
|
+
function stateContract(props) {
|
|
1324
|
+
return { props };
|
|
1325
|
+
}
|
|
1326
|
+
var activeContract = stateContract([activeProps]);
|
|
1327
|
+
var disabledContract = stateContract([disabledProps]);
|
|
1328
|
+
var expandedContract = stateContract([expandedProps]);
|
|
1329
|
+
var invalidContract = stateContract([invalidProps]);
|
|
1330
|
+
var loadingContract = stateContract([loadingProps]);
|
|
1331
|
+
var pressedContract = stateContract([pressedProps]);
|
|
1332
|
+
var readonlyContract = stateContract([readonlyProps]);
|
|
1333
|
+
var selectedContract = stateContract([selectedProps]);
|
|
1334
|
+
function mergeContracts(...contracts) {
|
|
1335
|
+
const props = contracts.flatMap((c) => c.props ?? []);
|
|
1336
|
+
const aria = contracts.flatMap((c) => c.aria ?? []);
|
|
1337
|
+
const children = contracts.flatMap((c) => c.children ?? []);
|
|
1338
|
+
let strict;
|
|
1339
|
+
let allowedAs;
|
|
1340
|
+
for (const c of contracts) {
|
|
1341
|
+
if (c.strict !== void 0) strict = c.strict;
|
|
1342
|
+
if (c.allowedAs !== void 0) allowedAs = c.allowedAs;
|
|
1343
|
+
}
|
|
1344
|
+
return {
|
|
1345
|
+
...props.length > 0 && { props },
|
|
1346
|
+
...aria.length > 0 && { aria },
|
|
1347
|
+
...children.length > 0 && { children },
|
|
1348
|
+
...strict !== void 0 && { strict },
|
|
1349
|
+
...allowedAs !== void 0 && { allowedAs }
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
export {
|
|
1353
|
+
activeContract,
|
|
1354
|
+
activeProps,
|
|
1355
|
+
disabledContract,
|
|
1356
|
+
disabledProps,
|
|
1357
|
+
expandedContract,
|
|
1358
|
+
expandedProps,
|
|
1359
|
+
invalidContract,
|
|
1360
|
+
invalidProps,
|
|
1361
|
+
loadingContract,
|
|
1362
|
+
loadingProps,
|
|
1363
|
+
mergeContracts,
|
|
1364
|
+
pressedContract,
|
|
1365
|
+
pressedProps,
|
|
1366
|
+
readonlyContract,
|
|
1367
|
+
readonlyProps,
|
|
1368
|
+
selectedContract,
|
|
1369
|
+
selectedProps
|
|
1370
|
+
};
|