praxis-kit 4.0.1 → 4.1.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/_shared/diagnostics.d.ts +209 -0
- package/dist/_shared/diagnostics.js +289 -0
- package/dist/{chunk-TJRHF6MS.js → chunk-LA6WGQA6.js} +1023 -822
- package/dist/codemod/index.js +23 -15
- package/dist/contract/index.d.ts +46 -173
- package/dist/eslint/index.js +21 -17
- package/dist/lit/index.d.ts +44 -173
- package/dist/lit/index.js +705 -598
- package/dist/preact/index.d.ts +47 -174
- package/dist/preact/index.js +1077 -886
- package/dist/react/index.d.ts +25 -11
- package/dist/react/index.js +21 -143
- package/dist/react/legacy.d.ts +4 -3
- package/dist/react/legacy.js +28 -147
- package/dist/{merge-refs-CEpa0zK1.d.ts → react-options-XrRof248.d.ts} +170 -255
- package/dist/solid/index.d.ts +47 -174
- package/dist/solid/index.js +630 -538
- package/dist/svelte/index.d.ts +57 -177
- package/dist/svelte/index.js +609 -534
- package/dist/tailwind/index.d.ts +23 -157
- package/dist/tailwind/index.js +11 -119
- package/dist/vite-plugin/index.d.ts +10 -12
- package/dist/vue/index.d.ts +47 -174
- package/dist/vue/index.js +969 -897
- package/dist/web/index.d.ts +45 -174
- package/dist/web/index.js +707 -594
- package/package.json +6 -6
package/dist/preact/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// ../../lib/
|
|
2
|
-
|
|
3
|
-
Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
|
|
4
|
-
}
|
|
1
|
+
// ../../lib/primitive/src/guards/children/component-id.ts
|
|
2
|
+
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
|
|
5
3
|
|
|
6
4
|
// ../../lib/primitive/src/utils/is-object.ts
|
|
7
5
|
function isObject(value, excludeArrays = false) {
|
|
@@ -15,6 +13,16 @@ function isNumber(value) {
|
|
|
15
13
|
return typeof value === "number";
|
|
16
14
|
}
|
|
17
15
|
|
|
16
|
+
// ../../lib/primitive/src/guards/foundational/is-defined.ts
|
|
17
|
+
function isUndefined(value) {
|
|
18
|
+
return value === void 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ../../lib/primitive/src/guards/foundational/is-null.ts
|
|
22
|
+
function isNull(value) {
|
|
23
|
+
return value === null;
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
// ../../lib/primitive/src/merge/constants.ts
|
|
19
27
|
var EVENT_HANDLER_RE = /^on[A-Z]/;
|
|
20
28
|
|
|
@@ -28,195 +36,58 @@ function isPlainObject(value) {
|
|
|
28
36
|
return proto === Object.prototype || proto === null;
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
// ../../lib/primitive/src/
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
for (const value of iterable) {
|
|
39
|
-
const result = callback(value);
|
|
40
|
-
if (result != null) {
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
function some(iterable, predicate) {
|
|
47
|
-
for (const value of iterable) {
|
|
48
|
-
if (predicate(value)) return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
function every(iterable, predicate) {
|
|
53
|
-
let index = 0;
|
|
54
|
-
for (const value of iterable) {
|
|
55
|
-
if (!predicate(value, index++)) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
function* filter(iterable, predicate) {
|
|
62
|
-
let index = 0;
|
|
63
|
-
for (const value of iterable) {
|
|
64
|
-
if (predicate(value, index++)) {
|
|
65
|
-
yield value;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function* map(iterable, callback) {
|
|
70
|
-
let index = 0;
|
|
71
|
-
for (const value of iterable) {
|
|
72
|
-
yield callback(value, index++);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function forEach(iterable, callback) {
|
|
76
|
-
let index = 0;
|
|
77
|
-
for (const value of iterable) {
|
|
78
|
-
callback(value, index++);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function reduce(iterable, initial, callback) {
|
|
82
|
-
let accumulator = initial;
|
|
83
|
-
let index = 0;
|
|
84
|
-
for (const value of iterable) {
|
|
85
|
-
accumulator = callback(accumulator, value, index++);
|
|
86
|
-
}
|
|
87
|
-
return accumulator;
|
|
88
|
-
}
|
|
89
|
-
function collect(iterable, callback) {
|
|
90
|
-
const result = {};
|
|
91
|
-
let index = 0;
|
|
92
|
-
for (const value of iterable) {
|
|
93
|
-
const entry = callback(value, index++);
|
|
94
|
-
if (entry === null) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
result[entry[0]] = entry[1];
|
|
98
|
-
}
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
function findLast(value, callback) {
|
|
102
|
-
for (let index = value.length - 1; index >= 0; index--) {
|
|
103
|
-
const result = callback(value[index], index);
|
|
104
|
-
if (result != null) {
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
function* items(collection) {
|
|
111
|
-
for (let i = 0; i < collection.length; i++) {
|
|
112
|
-
const item = collection.item(i);
|
|
113
|
-
if (item !== null) {
|
|
114
|
-
yield item;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function nodeList(list) {
|
|
119
|
-
return {
|
|
120
|
-
*[Symbol.iterator]() {
|
|
121
|
-
for (let i = 0; i < list.length; i++) {
|
|
122
|
-
const node = list.item(i);
|
|
123
|
-
if (node !== null) {
|
|
124
|
-
yield node;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function mapEntries(m) {
|
|
131
|
-
return m.entries();
|
|
132
|
-
}
|
|
133
|
-
function set(s) {
|
|
134
|
-
return s.values();
|
|
135
|
-
}
|
|
136
|
-
function hasOwn(object, key) {
|
|
137
|
-
return Object.hasOwn(object, key);
|
|
138
|
-
}
|
|
139
|
-
function* entries(object) {
|
|
140
|
-
for (const key in object) {
|
|
141
|
-
if (!hasOwn(object, key)) continue;
|
|
142
|
-
yield [key, object[key]];
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
function* keys(object) {
|
|
146
|
-
for (const [key] of entries(object)) {
|
|
147
|
-
yield key;
|
|
148
|
-
}
|
|
39
|
+
// ../../lib/primitive/src/guards/children/is-tag.ts
|
|
40
|
+
function getAsProp(child) {
|
|
41
|
+
if (!isObject(child) || !("props" in child)) return void 0;
|
|
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;
|
|
149
46
|
}
|
|
150
|
-
function
|
|
151
|
-
|
|
152
|
-
|
|
47
|
+
function getTag(child) {
|
|
48
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
49
|
+
const t = child.type;
|
|
50
|
+
if (isString(t)) return t;
|
|
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;
|
|
153
55
|
}
|
|
56
|
+
return void 0;
|
|
154
57
|
}
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
58
|
+
function isTag(...args) {
|
|
59
|
+
if (isString(args[0])) {
|
|
60
|
+
const set3 = new Set(args);
|
|
61
|
+
return (child2) => {
|
|
62
|
+
const tag2 = getTag(child2);
|
|
63
|
+
return tag2 !== void 0 && set3.has(tag2);
|
|
64
|
+
};
|
|
159
65
|
}
|
|
160
|
-
|
|
66
|
+
const [child, ...tags] = args;
|
|
67
|
+
const set2 = new Set(tags);
|
|
68
|
+
const tag = getTag(child);
|
|
69
|
+
return tag !== void 0 && set2.has(tag);
|
|
161
70
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
71
|
+
|
|
72
|
+
// ../../adapters/preact/src/create-contract-component.ts
|
|
73
|
+
import { forwardRef as forwardRef2 } from "preact/compat";
|
|
74
|
+
|
|
75
|
+
// ../../lib/adapter-utils/src/invariant.ts
|
|
76
|
+
function panic(message) {
|
|
77
|
+
throw new Error(message);
|
|
166
78
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
callback(key);
|
|
170
|
-
}
|
|
79
|
+
function invariant(condition, message) {
|
|
80
|
+
if (!condition) panic(message);
|
|
171
81
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
function forEachSet(s, callback) {
|
|
178
|
-
for (const value of s) {
|
|
179
|
-
callback(value);
|
|
180
|
-
}
|
|
82
|
+
|
|
83
|
+
// ../../lib/adapter-utils/src/runtime/apply-display-name.ts
|
|
84
|
+
function applyDisplayName(component, name) {
|
|
85
|
+
Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
|
|
181
86
|
}
|
|
182
|
-
var iterate = Object.freeze({
|
|
183
|
-
entries,
|
|
184
|
-
filter,
|
|
185
|
-
find,
|
|
186
|
-
findLast,
|
|
187
|
-
forEach,
|
|
188
|
-
forEachEntry,
|
|
189
|
-
forEachKey,
|
|
190
|
-
forEachSet,
|
|
191
|
-
forEachValue,
|
|
192
|
-
items,
|
|
193
|
-
keys,
|
|
194
|
-
map,
|
|
195
|
-
mapEntries,
|
|
196
|
-
mapValues,
|
|
197
|
-
nodeList,
|
|
198
|
-
reduce,
|
|
199
|
-
collect,
|
|
200
|
-
set,
|
|
201
|
-
some,
|
|
202
|
-
every,
|
|
203
|
-
values
|
|
204
|
-
});
|
|
205
87
|
|
|
206
|
-
// ../../lib/
|
|
207
|
-
function
|
|
208
|
-
|
|
209
|
-
if (active.length === 0) return null;
|
|
210
|
-
if (active.length === 1) return active[0];
|
|
211
|
-
return (value) => {
|
|
212
|
-
iterate.forEach(active, (ref) => {
|
|
213
|
-
if (typeof ref === "function") {
|
|
214
|
-
ref(value);
|
|
215
|
-
} else {
|
|
216
|
-
ref.current = value;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
};
|
|
88
|
+
// ../../lib/adapter-utils/src/runtime/define-component.ts
|
|
89
|
+
function defineContractComponent(options) {
|
|
90
|
+
return (factory) => factory(options);
|
|
220
91
|
}
|
|
221
92
|
|
|
222
93
|
// ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
|
|
@@ -241,7 +112,7 @@ var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
241
112
|
]);
|
|
242
113
|
|
|
243
114
|
// ../../lib/primitive/src/constants/aria/implicit-role-record.ts
|
|
244
|
-
var IMPLICIT_ROLE_RECORD = {
|
|
115
|
+
var IMPLICIT_ROLE_RECORD = Object.freeze({
|
|
245
116
|
// Landmarks
|
|
246
117
|
article: "article",
|
|
247
118
|
aside: "complementary",
|
|
@@ -277,8 +148,8 @@ var IMPLICIT_ROLE_RECORD = {
|
|
|
277
148
|
meter: "meter",
|
|
278
149
|
output: "status",
|
|
279
150
|
progress: "progressbar"
|
|
280
|
-
};
|
|
281
|
-
var INPUT_TYPE_ROLE_MAP = {
|
|
151
|
+
});
|
|
152
|
+
var INPUT_TYPE_ROLE_MAP = Object.freeze({
|
|
282
153
|
checkbox: "checkbox",
|
|
283
154
|
radio: "radio",
|
|
284
155
|
range: "slider",
|
|
@@ -292,18 +163,106 @@ var INPUT_TYPE_ROLE_MAP = {
|
|
|
292
163
|
submit: "button",
|
|
293
164
|
reset: "button",
|
|
294
165
|
image: "button"
|
|
295
|
-
};
|
|
296
|
-
var STRONG_ROLES = [
|
|
166
|
+
});
|
|
167
|
+
var STRONG_ROLES = Object.freeze([
|
|
297
168
|
"main",
|
|
298
169
|
"navigation",
|
|
299
170
|
"complementary",
|
|
300
171
|
"contentinfo",
|
|
301
172
|
"banner"
|
|
302
|
-
];
|
|
303
|
-
var STANDALONE_ROLES = [
|
|
173
|
+
]);
|
|
174
|
+
var STANDALONE_ROLES = Object.freeze([
|
|
175
|
+
"article"
|
|
176
|
+
]);
|
|
304
177
|
var STRONG_ROLES_SET = new Set(STRONG_ROLES);
|
|
305
178
|
var STANDALONE_ROLES_SET = new Set(STANDALONE_ROLES);
|
|
306
179
|
|
|
180
|
+
// ../../lib/primitive/src/constants/aria/known-aria-roles.ts
|
|
181
|
+
var KNOWN_ARIA_ROLES = Object.freeze([
|
|
182
|
+
"alert",
|
|
183
|
+
"alertdialog",
|
|
184
|
+
"application",
|
|
185
|
+
"article",
|
|
186
|
+
"banner",
|
|
187
|
+
"blockquote",
|
|
188
|
+
"button",
|
|
189
|
+
"caption",
|
|
190
|
+
"cell",
|
|
191
|
+
"checkbox",
|
|
192
|
+
"code",
|
|
193
|
+
"columnheader",
|
|
194
|
+
"combobox",
|
|
195
|
+
"complementary",
|
|
196
|
+
"contentinfo",
|
|
197
|
+
"definition",
|
|
198
|
+
"deletion",
|
|
199
|
+
"dialog",
|
|
200
|
+
"document",
|
|
201
|
+
"emphasis",
|
|
202
|
+
"feed",
|
|
203
|
+
"figure",
|
|
204
|
+
"form",
|
|
205
|
+
"generic",
|
|
206
|
+
"grid",
|
|
207
|
+
"gridcell",
|
|
208
|
+
"group",
|
|
209
|
+
"heading",
|
|
210
|
+
"img",
|
|
211
|
+
"insertion",
|
|
212
|
+
"link",
|
|
213
|
+
"list",
|
|
214
|
+
"listbox",
|
|
215
|
+
"listitem",
|
|
216
|
+
"log",
|
|
217
|
+
"main",
|
|
218
|
+
"marquee",
|
|
219
|
+
"math",
|
|
220
|
+
"menu",
|
|
221
|
+
"menubar",
|
|
222
|
+
"menuitem",
|
|
223
|
+
"menuitemcheckbox",
|
|
224
|
+
"menuitemradio",
|
|
225
|
+
"meter",
|
|
226
|
+
"navigation",
|
|
227
|
+
"none",
|
|
228
|
+
"note",
|
|
229
|
+
"option",
|
|
230
|
+
"paragraph",
|
|
231
|
+
"presentation",
|
|
232
|
+
"progressbar",
|
|
233
|
+
"radio",
|
|
234
|
+
"radiogroup",
|
|
235
|
+
"region",
|
|
236
|
+
"row",
|
|
237
|
+
"rowgroup",
|
|
238
|
+
"rowheader",
|
|
239
|
+
"scrollbar",
|
|
240
|
+
"search",
|
|
241
|
+
"searchbox",
|
|
242
|
+
"separator",
|
|
243
|
+
"slider",
|
|
244
|
+
"spinbutton",
|
|
245
|
+
"status",
|
|
246
|
+
"strong",
|
|
247
|
+
"subscript",
|
|
248
|
+
"superscript",
|
|
249
|
+
"switch",
|
|
250
|
+
"tab",
|
|
251
|
+
"table",
|
|
252
|
+
"tablist",
|
|
253
|
+
"tabpanel",
|
|
254
|
+
"term",
|
|
255
|
+
"textbox",
|
|
256
|
+
"time",
|
|
257
|
+
"timer",
|
|
258
|
+
"toolbar",
|
|
259
|
+
"tooltip",
|
|
260
|
+
"tree",
|
|
261
|
+
"treegrid",
|
|
262
|
+
"treeitem"
|
|
263
|
+
]);
|
|
264
|
+
var KNOWN_ARIA_ROLES_SET = new Set(KNOWN_ARIA_ROLES);
|
|
265
|
+
|
|
307
266
|
// ../../lib/primitive/src/constants/aria/role-restricted-attributes.ts
|
|
308
267
|
var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
|
|
309
268
|
[
|
|
@@ -455,16 +414,6 @@ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
|
|
|
455
414
|
]
|
|
456
415
|
]);
|
|
457
416
|
|
|
458
|
-
// ../../lib/primitive/src/guards/foundational/is-defined.ts
|
|
459
|
-
function isUndefined(value) {
|
|
460
|
-
return value === void 0;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// ../../lib/primitive/src/guards/foundational/is-null.ts
|
|
464
|
-
function isNull(value) {
|
|
465
|
-
return value === null;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
417
|
// ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
|
|
469
418
|
function isGlobalAriaAttribute(attr) {
|
|
470
419
|
return GLOBAL_ARIA_ATTRIBUTES.has(attr);
|
|
@@ -476,6 +425,9 @@ function isAriaAttributeValidForRole(attr, role) {
|
|
|
476
425
|
return allowedRoles.has(role);
|
|
477
426
|
}
|
|
478
427
|
|
|
428
|
+
// ../../lib/primitive/src/constants/primitive/slot-name.ts
|
|
429
|
+
var SLOT_NAME = "Slot";
|
|
430
|
+
|
|
479
431
|
// ../../lib/primitive/src/guards/aria/is-aria-role.ts
|
|
480
432
|
function isStrongImplicitRole(tag) {
|
|
481
433
|
if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
|
|
@@ -486,51 +438,20 @@ function isStandaloneTag(tag) {
|
|
|
486
438
|
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
487
439
|
}
|
|
488
440
|
function getInputImplicitRole(type) {
|
|
489
|
-
if (type
|
|
441
|
+
if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
|
|
490
442
|
return INPUT_TYPE_ROLE_MAP[type];
|
|
491
443
|
}
|
|
492
444
|
function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
|
|
493
|
-
const isNamed =
|
|
445
|
+
const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
|
|
494
446
|
if (!isNamed) return void 0;
|
|
495
447
|
if (tag === "section") return "region";
|
|
496
448
|
if (tag === "form") return "form";
|
|
497
449
|
return void 0;
|
|
498
450
|
}
|
|
499
451
|
|
|
500
|
-
// ../../lib/primitive/src/guards/
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
// ../../lib/primitive/src/guards/children/is-tag.ts
|
|
504
|
-
function getAsProp(child) {
|
|
505
|
-
if (!isObject(child) || !("props" in child)) return void 0;
|
|
506
|
-
const props = child.props;
|
|
507
|
-
if (!isObject(props)) return void 0;
|
|
508
|
-
const as = props.as;
|
|
509
|
-
return isString(as) && as !== "" ? as : void 0;
|
|
510
|
-
}
|
|
511
|
-
function getTag(child) {
|
|
512
|
-
if (!isObject(child) || !("type" in child)) return void 0;
|
|
513
|
-
const t = child.type;
|
|
514
|
-
if (isString(t)) return t;
|
|
515
|
-
if (typeof t === "function" || isObject(t)) {
|
|
516
|
-
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
517
|
-
if (!isString(defaultTag)) return void 0;
|
|
518
|
-
return getAsProp(child) ?? defaultTag;
|
|
519
|
-
}
|
|
520
|
-
return void 0;
|
|
521
|
-
}
|
|
522
|
-
function isTag(...args) {
|
|
523
|
-
if (isString(args[0])) {
|
|
524
|
-
const set3 = new Set(args);
|
|
525
|
-
return (child2) => {
|
|
526
|
-
const tag2 = getTag(child2);
|
|
527
|
-
return tag2 !== void 0 && set3.has(tag2);
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
const [child, ...tags] = args;
|
|
531
|
-
const set2 = new Set(tags);
|
|
532
|
-
const tag = getTag(child);
|
|
533
|
-
return tag !== void 0 && set2.has(tag);
|
|
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);
|
|
534
455
|
}
|
|
535
456
|
|
|
536
457
|
// ../../lib/contract/src/aria/aria-role-policy.ts
|
|
@@ -544,6 +465,218 @@ function getImplicitRole(tag, props) {
|
|
|
544
465
|
return void 0;
|
|
545
466
|
}
|
|
546
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/utils/assert-never.ts
|
|
476
|
+
function assertNever(value) {
|
|
477
|
+
throw new Error(`Unexpected value: ${String(value)}`);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// ../../lib/primitive/src/utils/cn.ts
|
|
481
|
+
import { clsx } from "clsx";
|
|
482
|
+
function cn(...inputs) {
|
|
483
|
+
return clsx(...inputs);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// ../../lib/primitive/src/utils/iterate.ts
|
|
487
|
+
function find(iterable, callback) {
|
|
488
|
+
for (const value of iterable) {
|
|
489
|
+
const result = callback(value);
|
|
490
|
+
if (result != null) {
|
|
491
|
+
return result;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
function some(iterable, predicate) {
|
|
497
|
+
for (const value of iterable) {
|
|
498
|
+
if (predicate(value)) return true;
|
|
499
|
+
}
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
function every(iterable, predicate) {
|
|
503
|
+
let index = 0;
|
|
504
|
+
for (const value of iterable) {
|
|
505
|
+
if (!predicate(value, index++)) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
function* filter(iterable, predicate) {
|
|
512
|
+
let index = 0;
|
|
513
|
+
for (const value of iterable) {
|
|
514
|
+
if (predicate(value, index++)) {
|
|
515
|
+
yield value;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function* map(iterable, callback) {
|
|
520
|
+
let index = 0;
|
|
521
|
+
for (const value of iterable) {
|
|
522
|
+
yield callback(value, index++);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function forEach(iterable, callback) {
|
|
526
|
+
let index = 0;
|
|
527
|
+
for (const value of iterable) {
|
|
528
|
+
callback(value, index++);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function reduce(iterable, initial, callback) {
|
|
532
|
+
let accumulator = initial;
|
|
533
|
+
let index = 0;
|
|
534
|
+
for (const value of iterable) {
|
|
535
|
+
accumulator = callback(accumulator, value, index++);
|
|
536
|
+
}
|
|
537
|
+
return accumulator;
|
|
538
|
+
}
|
|
539
|
+
function collect(iterable, callback) {
|
|
540
|
+
const result = {};
|
|
541
|
+
let index = 0;
|
|
542
|
+
for (const value of iterable) {
|
|
543
|
+
const entry = callback(value, index++);
|
|
544
|
+
if (entry === null) {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
result[entry[0]] = entry[1];
|
|
548
|
+
}
|
|
549
|
+
return result;
|
|
550
|
+
}
|
|
551
|
+
function findLast(value, callback) {
|
|
552
|
+
for (let index = value.length - 1; index >= 0; index--) {
|
|
553
|
+
const result = callback(value[index], index);
|
|
554
|
+
if (result != null) {
|
|
555
|
+
return result;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
function* items(collection) {
|
|
561
|
+
for (let i = 0; i < collection.length; i++) {
|
|
562
|
+
const item = collection.item(i);
|
|
563
|
+
if (item !== null) {
|
|
564
|
+
yield item;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function nodeList(list) {
|
|
569
|
+
return {
|
|
570
|
+
*[Symbol.iterator]() {
|
|
571
|
+
for (let i = 0; i < list.length; i++) {
|
|
572
|
+
const node = list.item(i);
|
|
573
|
+
if (node !== null) {
|
|
574
|
+
yield node;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
function mapEntries(m) {
|
|
581
|
+
return m.entries();
|
|
582
|
+
}
|
|
583
|
+
function set(s) {
|
|
584
|
+
return s.values();
|
|
585
|
+
}
|
|
586
|
+
function hasOwn(object, key) {
|
|
587
|
+
return Object.hasOwn(object, key);
|
|
588
|
+
}
|
|
589
|
+
function* entries(object) {
|
|
590
|
+
for (const key in object) {
|
|
591
|
+
if (!hasOwn(object, key)) continue;
|
|
592
|
+
yield [key, object[key]];
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function* keys(object) {
|
|
596
|
+
for (const [key] of entries(object)) {
|
|
597
|
+
yield key;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
function* values(object) {
|
|
601
|
+
for (const [, value] of entries(object)) {
|
|
602
|
+
yield value;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
function mapValues(object, callback) {
|
|
606
|
+
const result = {};
|
|
607
|
+
for (const [key, value] of entries(object)) {
|
|
608
|
+
result[key] = callback(value, key);
|
|
609
|
+
}
|
|
610
|
+
return result;
|
|
611
|
+
}
|
|
612
|
+
function forEachEntry(object, callback) {
|
|
613
|
+
for (const [key, value] of entries(object)) {
|
|
614
|
+
callback(key, value);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
function forEachKey(object, callback) {
|
|
618
|
+
for (const key of keys(object)) {
|
|
619
|
+
callback(key);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function forEachValue(object, callback) {
|
|
623
|
+
for (const value of values(object)) {
|
|
624
|
+
callback(value);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function forEachSet(s, callback) {
|
|
628
|
+
for (const value of s) {
|
|
629
|
+
callback(value);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
var iterate = Object.freeze({
|
|
633
|
+
entries,
|
|
634
|
+
filter,
|
|
635
|
+
find,
|
|
636
|
+
findLast,
|
|
637
|
+
forEach,
|
|
638
|
+
forEachEntry,
|
|
639
|
+
forEachKey,
|
|
640
|
+
forEachSet,
|
|
641
|
+
forEachValue,
|
|
642
|
+
items,
|
|
643
|
+
keys,
|
|
644
|
+
map,
|
|
645
|
+
mapEntries,
|
|
646
|
+
mapValues,
|
|
647
|
+
nodeList,
|
|
648
|
+
reduce,
|
|
649
|
+
collect,
|
|
650
|
+
set,
|
|
651
|
+
some,
|
|
652
|
+
every,
|
|
653
|
+
values
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// ../../lib/primitive/src/utils/merge-refs.ts
|
|
657
|
+
function mergeRefsCore(...refs) {
|
|
658
|
+
const active = refs.filter((r) => r != null);
|
|
659
|
+
if (active.length === 0) return null;
|
|
660
|
+
if (active.length === 1) return active[0];
|
|
661
|
+
return (value) => {
|
|
662
|
+
iterate.forEach(active, (ref) => {
|
|
663
|
+
if (typeof ref === "function") {
|
|
664
|
+
ref(value);
|
|
665
|
+
} else {
|
|
666
|
+
ref.current = value;
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// ../../lib/primitive/src/utils/merge-props.ts
|
|
673
|
+
function mergeProps(defaultProps, props) {
|
|
674
|
+
return {
|
|
675
|
+
...defaultProps ?? {},
|
|
676
|
+
...props
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
547
680
|
// ../../lib/contract/src/strict/invariant-base.ts
|
|
548
681
|
var InvariantBase = class {
|
|
549
682
|
diagnostics;
|
|
@@ -566,159 +699,21 @@ var InvariantBase = class {
|
|
|
566
699
|
}
|
|
567
700
|
};
|
|
568
701
|
|
|
569
|
-
// ../../lib/diagnostics/src/category.ts
|
|
570
|
-
var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
|
|
571
|
-
DiagnosticCategory2[DiagnosticCategory2["Contract"] = 0] = "Contract";
|
|
572
|
-
DiagnosticCategory2[DiagnosticCategory2["HTML"] = 1] = "HTML";
|
|
573
|
-
DiagnosticCategory2[DiagnosticCategory2["ARIA"] = 2] = "ARIA";
|
|
574
|
-
DiagnosticCategory2[DiagnosticCategory2["Composition"] = 3] = "Composition";
|
|
575
|
-
DiagnosticCategory2[DiagnosticCategory2["Rendering"] = 4] = "Rendering";
|
|
576
|
-
DiagnosticCategory2[DiagnosticCategory2["Accessibility"] = 5] = "Accessibility";
|
|
577
|
-
DiagnosticCategory2[DiagnosticCategory2["Performance"] = 6] = "Performance";
|
|
578
|
-
DiagnosticCategory2[DiagnosticCategory2["Internal"] = 7] = "Internal";
|
|
579
|
-
DiagnosticCategory2[DiagnosticCategory2["Deprecation"] = 8] = "Deprecation";
|
|
580
|
-
DiagnosticCategory2[DiagnosticCategory2["Lint"] = 9] = "Lint";
|
|
581
|
-
return DiagnosticCategory2;
|
|
582
|
-
})(DiagnosticCategory || {});
|
|
583
|
-
|
|
584
|
-
// ../../lib/diagnostics/src/error.ts
|
|
585
|
-
var PraxisError = class extends Error {
|
|
586
|
-
diagnostic;
|
|
587
|
-
constructor(diagnostic) {
|
|
588
|
-
super(diagnostic.message);
|
|
589
|
-
this.name = "PraxisError";
|
|
590
|
-
this.diagnostic = diagnostic;
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
// ../../lib/diagnostics/src/severity.ts
|
|
595
|
-
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
596
|
-
Severity2[Severity2["Debug"] = 0] = "Debug";
|
|
597
|
-
Severity2[Severity2["Info"] = 1] = "Info";
|
|
598
|
-
Severity2[Severity2["Warning"] = 2] = "Warning";
|
|
599
|
-
Severity2[Severity2["Error"] = 3] = "Error";
|
|
600
|
-
Severity2[Severity2["Fatal"] = 4] = "Fatal";
|
|
601
|
-
return Severity2;
|
|
602
|
-
})(Severity || {});
|
|
603
|
-
|
|
604
|
-
// ../../lib/diagnostics/src/policy.ts
|
|
605
|
-
var DefaultPolicy = class {
|
|
606
|
-
reportThreshold;
|
|
607
|
-
throwThreshold;
|
|
608
|
-
constructor({
|
|
609
|
-
reportThreshold = 1 /* Info */,
|
|
610
|
-
throwThreshold = 4 /* Fatal */
|
|
611
|
-
} = {}) {
|
|
612
|
-
this.reportThreshold = reportThreshold;
|
|
613
|
-
this.throwThreshold = throwThreshold;
|
|
614
|
-
}
|
|
615
|
-
resolve(diagnostic) {
|
|
616
|
-
if (diagnostic.severity >= this.throwThreshold) return 2 /* Throw */;
|
|
617
|
-
if (diagnostic.severity >= this.reportThreshold) return 1 /* Report */;
|
|
618
|
-
return 0 /* Ignore */;
|
|
619
|
-
}
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
// ../../lib/diagnostics/src/diagnostics.ts
|
|
623
|
-
var Diagnostics = class {
|
|
624
|
-
reporter;
|
|
625
|
-
policy;
|
|
626
|
-
// Pre-computed at construction time: true if Warning-level diagnostics are not ignored.
|
|
627
|
-
active;
|
|
628
|
-
constructor(reporter, policy = new DefaultPolicy()) {
|
|
629
|
-
this.reporter = reporter;
|
|
630
|
-
this.policy = policy;
|
|
631
|
-
this.active = policy.resolve({ severity: 2 /* Warning */ }) !== 0 /* Ignore */;
|
|
632
|
-
}
|
|
633
|
-
report(diagnostic) {
|
|
634
|
-
const enforcement = this.policy.resolve(diagnostic);
|
|
635
|
-
if (enforcement === 0 /* Ignore */) return diagnostic;
|
|
636
|
-
if (enforcement === 2 /* Throw */) throw new PraxisError(diagnostic);
|
|
637
|
-
this.reporter.report(diagnostic);
|
|
638
|
-
return diagnostic;
|
|
639
|
-
}
|
|
640
|
-
warn(input) {
|
|
641
|
-
return this.report({ ...input, severity: 2 /* Warning */ });
|
|
642
|
-
}
|
|
643
|
-
error(input) {
|
|
644
|
-
return this.report({ ...input, severity: 3 /* Error */ });
|
|
645
|
-
}
|
|
646
|
-
info(input) {
|
|
647
|
-
return this.report({ ...input, severity: 1 /* Info */ });
|
|
648
|
-
}
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
// ../../lib/diagnostics/src/formatter.ts
|
|
652
|
-
function formatDiagnostic(diagnostic) {
|
|
653
|
-
const level = Severity[diagnostic.severity];
|
|
654
|
-
const category = DiagnosticCategory[diagnostic.category];
|
|
655
|
-
const prefix = category !== void 0 ? `[${category}] ` : "";
|
|
656
|
-
return `${level} ${diagnostic.code}: ${prefix}${diagnostic.message}`;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
// ../../lib/diagnostics/src/console-reporter.ts
|
|
660
|
-
var ConsoleReporter = class {
|
|
661
|
-
report(diagnostic) {
|
|
662
|
-
const message = formatDiagnostic(diagnostic);
|
|
663
|
-
switch (diagnostic.severity) {
|
|
664
|
-
case 0 /* Debug */:
|
|
665
|
-
console.debug(message);
|
|
666
|
-
break;
|
|
667
|
-
case 1 /* Info */:
|
|
668
|
-
console.info(message);
|
|
669
|
-
break;
|
|
670
|
-
case 2 /* Warning */:
|
|
671
|
-
console.warn(message);
|
|
672
|
-
break;
|
|
673
|
-
case 3 /* Error */:
|
|
674
|
-
case 4 /* Fatal */:
|
|
675
|
-
console.error(message);
|
|
676
|
-
break;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
// ../../lib/diagnostics/src/null-reporter.ts
|
|
682
|
-
var nullReporter = {
|
|
683
|
-
report() {
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
// ../../lib/diagnostics/src/presets.ts
|
|
688
|
-
var ignoreAllPolicy = {
|
|
689
|
-
resolve(_) {
|
|
690
|
-
return 0 /* Ignore */;
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
var warnOnlyReporter = {
|
|
694
|
-
report(diagnostic) {
|
|
695
|
-
console.warn(formatDiagnostic(diagnostic));
|
|
696
|
-
}
|
|
697
|
-
};
|
|
698
|
-
var silentDiagnostics = new Diagnostics(nullReporter, ignoreAllPolicy);
|
|
699
|
-
var warnDiagnostics = new Diagnostics(
|
|
700
|
-
warnOnlyReporter,
|
|
701
|
-
new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 4 /* Fatal */ })
|
|
702
|
-
);
|
|
703
|
-
var throwDiagnostics = new Diagnostics(
|
|
704
|
-
new ConsoleReporter(),
|
|
705
|
-
new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 3 /* Error */ })
|
|
706
|
-
);
|
|
707
|
-
|
|
708
702
|
// ../../lib/contract/src/diagnostics/aria.ts
|
|
703
|
+
import { DiagnosticCategory, DiagnosticCode } from "../_shared/diagnostics.js";
|
|
709
704
|
var AriaDiagnostics = {
|
|
710
705
|
/** Generic bridge for violations produced by external AriaRule functions. */
|
|
711
706
|
fromViolation(v) {
|
|
712
707
|
return {
|
|
713
|
-
code:
|
|
714
|
-
category:
|
|
708
|
+
code: DiagnosticCode.AriaViolation,
|
|
709
|
+
category: DiagnosticCategory.ARIA,
|
|
715
710
|
message: v.message
|
|
716
711
|
};
|
|
717
712
|
},
|
|
718
713
|
attributeInvalid(key, role) {
|
|
719
714
|
return {
|
|
720
|
-
code:
|
|
721
|
-
category:
|
|
715
|
+
code: DiagnosticCode.AriaAttributeInvalid,
|
|
716
|
+
category: DiagnosticCategory.ARIA,
|
|
722
717
|
message: `"${key}" is not valid on role="${role}". It will be removed.`,
|
|
723
718
|
rationale: "Invalid ARIA attributes are ignored by assistive technology and may trigger accessibility-tree warnings in browser devtools.",
|
|
724
719
|
suggestions: [
|
|
@@ -731,8 +726,8 @@ var AriaDiagnostics = {
|
|
|
731
726
|
},
|
|
732
727
|
missingLiveRegion(role, impliedLive) {
|
|
733
728
|
return {
|
|
734
|
-
code:
|
|
735
|
-
category:
|
|
729
|
+
code: DiagnosticCode.AriaMissingLiveRegion,
|
|
730
|
+
category: DiagnosticCategory.ARIA,
|
|
736
731
|
message: `role="${role}" implies aria-live="${impliedLive}" but it is missing. It has been injected.`,
|
|
737
732
|
rationale: "Live-region roles announce dynamic content changes to screen readers. Without aria-live the politeness level is unspecified and announcements may be silent.",
|
|
738
733
|
suggestions: [
|
|
@@ -746,8 +741,8 @@ var AriaDiagnostics = {
|
|
|
746
741
|
},
|
|
747
742
|
missingAtomic(role) {
|
|
748
743
|
return {
|
|
749
|
-
code:
|
|
750
|
-
category:
|
|
744
|
+
code: DiagnosticCode.AriaMissingAtomic,
|
|
745
|
+
category: DiagnosticCategory.ARIA,
|
|
751
746
|
message: `role="${role}" 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.`,
|
|
752
747
|
rationale: "aria-atomic controls whether assistive technology announces the entire live region or only the changed nodes. Omitting it leaves the behaviour browser-defined."
|
|
753
748
|
};
|
|
@@ -755,8 +750,8 @@ var AriaDiagnostics = {
|
|
|
755
750
|
relevantInvalidTokens(invalid) {
|
|
756
751
|
const quoted = invalid.map((t) => `"${t}"`).join(", ");
|
|
757
752
|
return {
|
|
758
|
-
code:
|
|
759
|
-
category:
|
|
753
|
+
code: DiagnosticCode.AriaRelevantInvalidToken,
|
|
754
|
+
category: DiagnosticCategory.ARIA,
|
|
760
755
|
message: `aria-relevant contains invalid token(s): ${quoted}. Valid tokens are: additions, removals, text, all.`,
|
|
761
756
|
rationale: "aria-relevant accepts a space-separated list of change types. Unrecognised tokens are silently ignored by assistive technology, making the attribute ineffective.",
|
|
762
757
|
suggestions: [
|
|
@@ -769,8 +764,8 @@ var AriaDiagnostics = {
|
|
|
769
764
|
},
|
|
770
765
|
relevantSuperseded() {
|
|
771
766
|
return {
|
|
772
|
-
code:
|
|
773
|
-
category:
|
|
767
|
+
code: DiagnosticCode.AriaRelevantSuperseded,
|
|
768
|
+
category: DiagnosticCategory.ARIA,
|
|
774
769
|
message: 'aria-relevant includes "all" alongside other tokens. "all" supersedes additions, removals, and text \u2014 use aria-relevant="all" alone.',
|
|
775
770
|
rationale: '"all" is equivalent to "additions removals text". Combining it with other tokens is redundant and may confuse readers of the markup.',
|
|
776
771
|
suggestions: [
|
|
@@ -783,8 +778,8 @@ var AriaDiagnostics = {
|
|
|
783
778
|
},
|
|
784
779
|
missingAccessibleName(tag) {
|
|
785
780
|
return {
|
|
786
|
-
code:
|
|
787
|
-
category:
|
|
781
|
+
code: DiagnosticCode.AriaMissingAccessibleName,
|
|
782
|
+
category: DiagnosticCategory.ARIA,
|
|
788
783
|
message: `<${tag}> has no accessible name. Add aria-label or aria-labelledby.`,
|
|
789
784
|
rationale: "Elements with a landmark or interactive role must have an accessible name so that assistive technology can identify them when presenting the page outline.",
|
|
790
785
|
suggestions: [
|
|
@@ -801,8 +796,8 @@ var AriaDiagnostics = {
|
|
|
801
796
|
},
|
|
802
797
|
attributeOnPresentational(attr, tag) {
|
|
803
798
|
return {
|
|
804
|
-
code:
|
|
805
|
-
category:
|
|
799
|
+
code: DiagnosticCode.AriaAttributeOnPresentational,
|
|
800
|
+
category: DiagnosticCategory.ARIA,
|
|
806
801
|
message: `"${attr}" is not allowed on a presentational <${tag}>. Presentational elements are invisible to assistive technology.`,
|
|
807
802
|
rationale: 'role="none" and role="presentation" (including <img alt="">) remove an element from the accessibility tree. ARIA attributes on such elements are ignored by assistive technology.',
|
|
808
803
|
suggestions: [
|
|
@@ -815,8 +810,8 @@ var AriaDiagnostics = {
|
|
|
815
810
|
},
|
|
816
811
|
ariaHiddenOnFocusable(tag) {
|
|
817
812
|
return {
|
|
818
|
-
code:
|
|
819
|
-
category:
|
|
813
|
+
code: DiagnosticCode.AriaHiddenOnFocusable,
|
|
814
|
+
category: DiagnosticCategory.ARIA,
|
|
820
815
|
message: `aria-hidden="true" must not be used on focusable <${tag}> elements. Screen reader users who navigate by keyboard will encounter the element but receive no information about it.`,
|
|
821
816
|
rationale: 'aria-hidden removes an element from the accessibility tree while leaving it keyboard-reachable. This creates a "ghost" \u2014 a focusable element assistive technology cannot describe.',
|
|
822
817
|
suggestions: [
|
|
@@ -834,8 +829,8 @@ var AriaDiagnostics = {
|
|
|
834
829
|
invalidAttributeValue(attr, value, expected) {
|
|
835
830
|
const got = value === null ? "null" : value === void 0 ? "undefined" : typeof value === "string" ? `"${value}"` : String(value);
|
|
836
831
|
return {
|
|
837
|
-
code:
|
|
838
|
-
category:
|
|
832
|
+
code: DiagnosticCode.AriaInvalidAttributeValue,
|
|
833
|
+
category: DiagnosticCategory.ARIA,
|
|
839
834
|
message: `"${attr}" has an invalid value (${got}). Expected: ${expected}.`,
|
|
840
835
|
rationale: "ARIA attributes with invalid values are silently ignored by assistive technology, making the markup semantically inert.",
|
|
841
836
|
suggestions: [
|
|
@@ -848,8 +843,8 @@ var AriaDiagnostics = {
|
|
|
848
843
|
},
|
|
849
844
|
redundantAriaLevel(tag, level) {
|
|
850
845
|
return {
|
|
851
|
-
code:
|
|
852
|
-
category:
|
|
846
|
+
code: DiagnosticCode.AriaRedundantLevelAttribute,
|
|
847
|
+
category: DiagnosticCategory.ARIA,
|
|
853
848
|
message: `aria-level="${level}" is redundant on <${tag}>: the element already has an implicit heading level of ${level}. Remove the attribute.`,
|
|
854
849
|
rationale: 'Restating the implicit aria-level adds noise without semantic value. Use aria-level only to override the native heading level (e.g. aria-level="3" on <h2>).',
|
|
855
850
|
suggestions: [
|
|
@@ -862,8 +857,8 @@ var AriaDiagnostics = {
|
|
|
862
857
|
},
|
|
863
858
|
requiredProperty(attr, role) {
|
|
864
859
|
return {
|
|
865
|
-
code:
|
|
866
|
-
category:
|
|
860
|
+
code: DiagnosticCode.AriaRequiredProperty,
|
|
861
|
+
category: DiagnosticCategory.ARIA,
|
|
867
862
|
message: `"${attr}" is required for role="${role}" but is missing.`,
|
|
868
863
|
rationale: `WAI-ARIA 1.2 specifies required states and properties for certain roles. Without "${attr}", assistive technology cannot correctly communicate the element's state to users.`,
|
|
869
864
|
suggestions: [
|
|
@@ -876,8 +871,8 @@ var AriaDiagnostics = {
|
|
|
876
871
|
},
|
|
877
872
|
invalidRole(role, tag) {
|
|
878
873
|
return {
|
|
879
|
-
code:
|
|
880
|
-
category:
|
|
874
|
+
code: DiagnosticCode.AriaInvalidRole,
|
|
875
|
+
category: DiagnosticCategory.ARIA,
|
|
881
876
|
message: `Invalid role "${role ?? ""}" on <${tag}>.`,
|
|
882
877
|
rationale: "An unrecognised or misapplied ARIA role is ignored by assistive technology and may degrade the accessibility of the element."
|
|
883
878
|
};
|
|
@@ -885,11 +880,12 @@ var AriaDiagnostics = {
|
|
|
885
880
|
};
|
|
886
881
|
|
|
887
882
|
// ../../lib/contract/src/diagnostics/contract.ts
|
|
883
|
+
import { DiagnosticCategory as DiagnosticCategory2, DiagnosticCode as DiagnosticCode2 } from "../_shared/diagnostics.js";
|
|
888
884
|
var ContractDiagnostics = {
|
|
889
885
|
unexpectedChild(typeName, index, context) {
|
|
890
886
|
return {
|
|
891
|
-
code:
|
|
892
|
-
category:
|
|
887
|
+
code: DiagnosticCode2.UnexpectedChild,
|
|
888
|
+
category: DiagnosticCategory2.Contract,
|
|
893
889
|
component: context,
|
|
894
890
|
message: `${context}: unexpected child "${typeName}" at index ${index}.`
|
|
895
891
|
};
|
|
@@ -897,69 +893,69 @@ var ContractDiagnostics = {
|
|
|
897
893
|
ambiguousChild(typeName, index, ruleNames, context) {
|
|
898
894
|
const quoted = ruleNames.map((n) => `"${n}"`).join(" and ");
|
|
899
895
|
return {
|
|
900
|
-
code:
|
|
901
|
-
category:
|
|
896
|
+
code: DiagnosticCode2.AmbiguousChild,
|
|
897
|
+
category: DiagnosticCategory2.Contract,
|
|
902
898
|
component: context,
|
|
903
899
|
message: `${context}: child "${typeName}" at index ${index} matches multiple child rules: ${quoted}.`
|
|
904
900
|
};
|
|
905
901
|
},
|
|
906
902
|
cardinalityMin(ruleName, min, context) {
|
|
907
903
|
return {
|
|
908
|
-
code:
|
|
909
|
-
category:
|
|
904
|
+
code: DiagnosticCode2.CardinalityMin,
|
|
905
|
+
category: DiagnosticCategory2.Contract,
|
|
910
906
|
component: context,
|
|
911
907
|
message: `${context}: "${ruleName}" requires at least ${min}.`
|
|
912
908
|
};
|
|
913
909
|
},
|
|
914
910
|
cardinalityMax(ruleName, max, context) {
|
|
915
911
|
return {
|
|
916
|
-
code:
|
|
917
|
-
category:
|
|
912
|
+
code: DiagnosticCode2.CardinalityMax,
|
|
913
|
+
category: DiagnosticCategory2.Contract,
|
|
918
914
|
component: context,
|
|
919
915
|
message: `${context}: "${ruleName}" allows at most ${max}.`
|
|
920
916
|
};
|
|
921
917
|
},
|
|
922
918
|
positionViolation(ruleName, position, index, context) {
|
|
923
919
|
return {
|
|
924
|
-
code:
|
|
925
|
-
category:
|
|
920
|
+
code: DiagnosticCode2.PositionViolation,
|
|
921
|
+
category: DiagnosticCategory2.Contract,
|
|
926
922
|
component: context,
|
|
927
923
|
message: `${context}: "${ruleName}" must be ${position}, got index ${index}`
|
|
928
924
|
};
|
|
929
925
|
},
|
|
930
|
-
unknownVariantDim(component,
|
|
926
|
+
unknownVariantDim(component, label2, dim) {
|
|
931
927
|
return {
|
|
932
|
-
code:
|
|
933
|
-
category:
|
|
934
|
-
message: `${component}: ${
|
|
928
|
+
code: DiagnosticCode2.ContractUnknownVariantDim,
|
|
929
|
+
category: DiagnosticCategory2.Contract,
|
|
930
|
+
message: `${component}: ${label2} references unknown variant "${dim}".`
|
|
935
931
|
};
|
|
936
932
|
},
|
|
937
|
-
unknownVariantValue(component,
|
|
933
|
+
unknownVariantValue(component, label2, dim, value, valid) {
|
|
938
934
|
return {
|
|
939
|
-
code:
|
|
940
|
-
category:
|
|
941
|
-
message: `${component}: ${
|
|
935
|
+
code: DiagnosticCode2.ContractUnknownVariantValue,
|
|
936
|
+
category: DiagnosticCategory2.Contract,
|
|
937
|
+
message: `${component}: ${label2} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
|
|
942
938
|
};
|
|
943
939
|
},
|
|
944
940
|
unknownRecipeKey(component, key) {
|
|
945
941
|
return {
|
|
946
|
-
code:
|
|
947
|
-
category:
|
|
942
|
+
code: DiagnosticCode2.ContractUnknownRecipeKey,
|
|
943
|
+
category: DiagnosticCategory2.Contract,
|
|
948
944
|
message: `${component} Unknown recipeKey "${key}" \u2014 no preset with that name exists.`
|
|
949
945
|
};
|
|
950
946
|
},
|
|
951
947
|
invalidVariantValue(component, key, value) {
|
|
952
948
|
return {
|
|
953
|
-
code:
|
|
954
|
-
category:
|
|
949
|
+
code: DiagnosticCode2.ContractInvalidVariantValue,
|
|
950
|
+
category: DiagnosticCategory2.Contract,
|
|
955
951
|
message: `${component} Variant "${key}=${value}" is not a defined value for the "${key}" dimension.`
|
|
956
952
|
};
|
|
957
953
|
},
|
|
958
954
|
allowedAsViolation(tag, allowedAs, component) {
|
|
959
955
|
const allowed = allowedAs.map((t) => `"${String(t)}"`).join(", ");
|
|
960
956
|
return {
|
|
961
|
-
code:
|
|
962
|
-
category:
|
|
957
|
+
code: DiagnosticCode2.AllowedAsViolation,
|
|
958
|
+
category: DiagnosticCategory2.Contract,
|
|
963
959
|
component,
|
|
964
960
|
message: `<${component}>: "as" prop received "${tag}" but only [${allowed}] are allowed.`
|
|
965
961
|
};
|
|
@@ -967,73 +963,75 @@ var ContractDiagnostics = {
|
|
|
967
963
|
};
|
|
968
964
|
|
|
969
965
|
// ../../lib/contract/src/diagnostics/html.ts
|
|
966
|
+
import { DiagnosticCategory as DiagnosticCategory3, DiagnosticCode as DiagnosticCode3 } from "../_shared/diagnostics.js";
|
|
970
967
|
var HtmlDiagnostics = {
|
|
971
968
|
emptyRole(tag) {
|
|
972
969
|
return {
|
|
973
|
-
code:
|
|
974
|
-
category:
|
|
970
|
+
code: DiagnosticCode3.HtmlEmptyRole,
|
|
971
|
+
category: DiagnosticCategory3.HTML,
|
|
975
972
|
message: `<${tag}> has an explicit empty role="". Omit the attribute instead.`
|
|
976
973
|
};
|
|
977
974
|
},
|
|
978
975
|
implicitRoleRedundant(tag, implicitRole) {
|
|
979
976
|
return {
|
|
980
|
-
code:
|
|
981
|
-
category:
|
|
977
|
+
code: DiagnosticCode3.HtmlImplicitRoleRedundant,
|
|
978
|
+
category: DiagnosticCategory3.HTML,
|
|
982
979
|
message: `<${tag}> already has implicit role="${implicitRole}". Avoid redundant role assignment.`
|
|
983
980
|
};
|
|
984
981
|
},
|
|
985
982
|
implicitRoleOverride(tag, implicitRole, role) {
|
|
986
983
|
return {
|
|
987
|
-
code:
|
|
988
|
-
category:
|
|
984
|
+
code: DiagnosticCode3.HtmlImplicitRoleOverride,
|
|
985
|
+
category: DiagnosticCategory3.HTML,
|
|
989
986
|
message: `<${tag}> should not override its implicit role="${implicitRole}" with role="${role}".`
|
|
990
987
|
};
|
|
991
988
|
},
|
|
992
989
|
standaloneRegionOverride(tag, implicitRole) {
|
|
993
990
|
return {
|
|
994
|
-
code:
|
|
995
|
-
category:
|
|
991
|
+
code: DiagnosticCode3.HtmlStandaloneRegionOverride,
|
|
992
|
+
category: DiagnosticCategory3.HTML,
|
|
996
993
|
message: `<${tag}> is a self-contained element with implicit role="${implicitRole}". Assigning role="region" has been removed.`
|
|
997
994
|
};
|
|
998
995
|
},
|
|
999
996
|
landmarkRoleOverride(tag, implicitRole, role) {
|
|
1000
997
|
return {
|
|
1001
|
-
code:
|
|
1002
|
-
category:
|
|
998
|
+
code: DiagnosticCode3.HtmlLandmarkRoleOverride,
|
|
999
|
+
category: DiagnosticCategory3.HTML,
|
|
1003
1000
|
message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
|
|
1004
1001
|
};
|
|
1005
1002
|
},
|
|
1006
1003
|
invalidChild(child, parent, allowed) {
|
|
1007
1004
|
return {
|
|
1008
|
-
code:
|
|
1009
|
-
category:
|
|
1005
|
+
code: DiagnosticCode3.HtmlInvalidChild,
|
|
1006
|
+
category: DiagnosticCategory3.HTML,
|
|
1010
1007
|
message: `<${child}> is not a valid direct child of <${parent}>. Allowed: ${allowed}.`
|
|
1011
1008
|
};
|
|
1012
1009
|
}
|
|
1013
1010
|
};
|
|
1014
1011
|
|
|
1015
1012
|
// ../../lib/contract/src/diagnostics/slot.ts
|
|
1013
|
+
import { DiagnosticCategory as DiagnosticCategory4, DiagnosticCode as DiagnosticCode4 } from "../_shared/diagnostics.js";
|
|
1016
1014
|
var SlotDiagnostics = {
|
|
1017
1015
|
exclusive(name) {
|
|
1018
1016
|
return {
|
|
1019
|
-
code:
|
|
1020
|
-
category:
|
|
1017
|
+
code: DiagnosticCode4.SlotExclusive,
|
|
1018
|
+
category: DiagnosticCategory4.Contract,
|
|
1021
1019
|
component: name,
|
|
1022
1020
|
message: `${name}: "as" and "asChild" are mutually exclusive`
|
|
1023
1021
|
};
|
|
1024
1022
|
},
|
|
1025
1023
|
singleChildRequired(name, elementTerm) {
|
|
1026
1024
|
return {
|
|
1027
|
-
code:
|
|
1028
|
-
category:
|
|
1025
|
+
code: DiagnosticCode4.SlotSingleChild,
|
|
1026
|
+
category: DiagnosticCategory4.Contract,
|
|
1029
1027
|
component: name,
|
|
1030
1028
|
message: `${name}: asChild requires a ${elementTerm} child`
|
|
1031
1029
|
};
|
|
1032
1030
|
},
|
|
1033
1031
|
singleChildExceeded(name, elementTerm, count) {
|
|
1034
1032
|
return {
|
|
1035
|
-
code:
|
|
1036
|
-
category:
|
|
1033
|
+
code: DiagnosticCode4.SlotSingleChild,
|
|
1034
|
+
category: DiagnosticCategory4.Contract,
|
|
1037
1035
|
component: name,
|
|
1038
1036
|
message: `${name}: asChild requires exactly one ${elementTerm} child, got ${count}`
|
|
1039
1037
|
};
|
|
@@ -1041,16 +1039,16 @@ var SlotDiagnostics = {
|
|
|
1041
1039
|
discardedChildren(name, elementTerm, count) {
|
|
1042
1040
|
const suffix = count === 1 ? "" : "ren";
|
|
1043
1041
|
return {
|
|
1044
|
-
code:
|
|
1045
|
-
category:
|
|
1042
|
+
code: DiagnosticCode4.SlotDiscardedChildren,
|
|
1043
|
+
category: DiagnosticCategory4.Contract,
|
|
1046
1044
|
component: name,
|
|
1047
1045
|
message: `${name}: asChild discarded ${count} non-element child${suffix} \u2014 only ${elementTerm}s are valid asChild children.`
|
|
1048
1046
|
};
|
|
1049
1047
|
},
|
|
1050
1048
|
renderFnRequired(name, received) {
|
|
1051
1049
|
return {
|
|
1052
|
-
code:
|
|
1053
|
-
category:
|
|
1050
|
+
code: DiagnosticCode4.SlotRenderFn,
|
|
1051
|
+
category: DiagnosticCategory4.Contract,
|
|
1054
1052
|
component: name,
|
|
1055
1053
|
message: `${name}: asChild requires a render function as children, got ${received}`
|
|
1056
1054
|
};
|
|
@@ -1734,7 +1732,7 @@ function getTypeName(value) {
|
|
|
1734
1732
|
return primitive;
|
|
1735
1733
|
}
|
|
1736
1734
|
const name = value.constructor?.name;
|
|
1737
|
-
return
|
|
1735
|
+
return isString(name) && name !== "Object" ? name : "object";
|
|
1738
1736
|
}
|
|
1739
1737
|
|
|
1740
1738
|
// ../../lib/contract/src/children/normalize-child-rule.ts
|
|
@@ -1985,6 +1983,9 @@ var readonlyProps = ({
|
|
|
1985
1983
|
};
|
|
1986
1984
|
};
|
|
1987
1985
|
|
|
1986
|
+
// ../core/src/html/evaluators.ts
|
|
1987
|
+
import { warnDiagnostics as warnDiagnostics2 } from "../_shared/diagnostics.js";
|
|
1988
|
+
|
|
1988
1989
|
// ../core/src/html/aria-rules.ts
|
|
1989
1990
|
var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
|
|
1990
1991
|
var removeLandmarkRoleOverride = {
|
|
@@ -2025,8 +2026,10 @@ function landmarkNameAdvisory(ctx) {
|
|
|
2025
2026
|
if (!ctx.implicitRole || !NAMED_LANDMARK_TAGS.has(ctx.tag)) return [];
|
|
2026
2027
|
return requireAccessibleName(ctx);
|
|
2027
2028
|
}
|
|
2029
|
+
var HTML_ARIA_RULES = [landmarkRoleRule, landmarkNameAdvisory];
|
|
2028
2030
|
|
|
2029
2031
|
// ../core/src/html/contracts.ts
|
|
2032
|
+
import { warnDiagnostics } from "../_shared/diagnostics.js";
|
|
2030
2033
|
function isOpenContent(...blockedTags) {
|
|
2031
2034
|
const set2 = new Set(blockedTags);
|
|
2032
2035
|
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set2.has(child.type));
|
|
@@ -2171,7 +2174,7 @@ var htmlContracts = {
|
|
|
2171
2174
|
};
|
|
2172
2175
|
|
|
2173
2176
|
// ../core/src/html/evaluators.ts
|
|
2174
|
-
var htmlDiagnostics =
|
|
2177
|
+
var htmlDiagnostics = warnDiagnostics2;
|
|
2175
2178
|
function buildEvaluatorMap() {
|
|
2176
2179
|
const map2 = /* @__PURE__ */ new Map();
|
|
2177
2180
|
iterate.forEachEntry(htmlContracts, (tag, { children }) => {
|
|
@@ -2199,37 +2202,396 @@ function getHtmlPropNormalizers(tag) {
|
|
|
2199
2202
|
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
2200
2203
|
}
|
|
2201
2204
|
|
|
2202
|
-
// ../../
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2205
|
+
// ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
|
|
2206
|
+
import { clsx as clsx2 } from "clsx";
|
|
2207
|
+
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
2208
|
+
var cx = clsx2;
|
|
2209
|
+
var cva = (base, config) => (props) => {
|
|
2210
|
+
var _config_compoundVariants;
|
|
2211
|
+
if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
2212
|
+
const { variants, defaultVariants } = config;
|
|
2213
|
+
const getVariantClassNames = Object.keys(variants).map((variant) => {
|
|
2214
|
+
const variantProp = props === null || props === void 0 ? void 0 : props[variant];
|
|
2215
|
+
const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
|
|
2216
|
+
if (variantProp === null) return null;
|
|
2217
|
+
const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
|
|
2218
|
+
return variants[variant][variantKey];
|
|
2219
|
+
});
|
|
2220
|
+
const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
|
|
2221
|
+
let [key, value] = param;
|
|
2222
|
+
if (value === void 0) {
|
|
2223
|
+
return acc;
|
|
2224
|
+
}
|
|
2225
|
+
acc[key] = value;
|
|
2226
|
+
return acc;
|
|
2227
|
+
}, {});
|
|
2228
|
+
const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
|
|
2229
|
+
let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
|
|
2230
|
+
return Object.entries(compoundVariantOptions).every((param2) => {
|
|
2231
|
+
let [key, value] = param2;
|
|
2232
|
+
return Array.isArray(value) ? value.includes({
|
|
2233
|
+
...defaultVariants,
|
|
2234
|
+
...propsWithoutUndefined
|
|
2235
|
+
}[key]) : {
|
|
2236
|
+
...defaultVariants,
|
|
2237
|
+
...propsWithoutUndefined
|
|
2238
|
+
}[key] === value;
|
|
2239
|
+
}) ? [
|
|
2240
|
+
...acc,
|
|
2241
|
+
cvClass,
|
|
2242
|
+
cvClassName
|
|
2243
|
+
] : acc;
|
|
2244
|
+
}, []);
|
|
2245
|
+
return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
2246
|
+
};
|
|
2206
2247
|
|
|
2207
|
-
// ../../lib/styling/src/
|
|
2208
|
-
function
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2248
|
+
// ../../lib/styling/src/cva.ts
|
|
2249
|
+
function cva2(base, config) {
|
|
2250
|
+
const fn = cva(base, config);
|
|
2251
|
+
return (props) => cn(fn(props));
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
// ../../lib/styling/src/static-class-resolver.ts
|
|
2255
|
+
var StaticClassResolver = class {
|
|
2256
|
+
#baseClass;
|
|
2257
|
+
#cache = /* @__PURE__ */ new Map();
|
|
2258
|
+
#resolveTag;
|
|
2259
|
+
constructor(baseClass, tagMap) {
|
|
2260
|
+
this.#baseClass = Array.isArray(baseClass) ? baseClass.join(" ") : baseClass;
|
|
2261
|
+
this.#resolveTag = tagMap ? (tag) => {
|
|
2262
|
+
const extra = tagMap[tag];
|
|
2263
|
+
if (!extra) return this.#baseClass;
|
|
2264
|
+
const extraStr = Array.isArray(extra) ? extra.join(" ") : extra;
|
|
2265
|
+
return `${this.#baseClass} ${extraStr}`;
|
|
2266
|
+
} : () => this.#baseClass;
|
|
2267
|
+
}
|
|
2268
|
+
resolve(tag, skipTagMap = false) {
|
|
2269
|
+
if (typeof tag !== "string" || skipTagMap) return this.#baseClass;
|
|
2270
|
+
const cached = this.#cache.get(tag);
|
|
2271
|
+
if (cached !== void 0) {
|
|
2272
|
+
this.#cache.delete(tag);
|
|
2273
|
+
this.#cache.set(tag, cached);
|
|
2274
|
+
return cached;
|
|
2275
|
+
}
|
|
2276
|
+
const result = this.#resolveTag(tag);
|
|
2277
|
+
this.#cache.set(tag, result);
|
|
2278
|
+
if (this.#cache.size > 200) {
|
|
2279
|
+
const lru = this.#cache.keys().next().value;
|
|
2280
|
+
if (lru !== void 0) this.#cache.delete(lru);
|
|
2281
|
+
}
|
|
2282
|
+
return result;
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2285
|
+
|
|
2286
|
+
// ../../lib/styling/src/variant-class-resolver.ts
|
|
2287
|
+
var VariantClassResolver = class _VariantClassResolver {
|
|
2288
|
+
#cvaFn;
|
|
2289
|
+
#recipeMap;
|
|
2290
|
+
#variantKeys;
|
|
2291
|
+
#precomputedClasses;
|
|
2292
|
+
#cache = /* @__PURE__ */ new Map();
|
|
2293
|
+
constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
|
|
2294
|
+
this.#cvaFn = cvaFn ?? null;
|
|
2295
|
+
this.#recipeMap = Object.freeze(recipeMap ?? {});
|
|
2296
|
+
this.#variantKeys = variantKeys ?? null;
|
|
2297
|
+
this.#precomputedClasses = precomputedClasses ?? null;
|
|
2298
|
+
}
|
|
2299
|
+
resolve({ props, recipe }) {
|
|
2300
|
+
const normalizedKey = recipe ?? "__none__";
|
|
2301
|
+
const cacheKey = this.#createCacheKey(props, normalizedKey);
|
|
2302
|
+
if (this.#precomputedClasses !== null) {
|
|
2303
|
+
const precomputed = this.#precomputedClasses[cacheKey];
|
|
2304
|
+
if (precomputed !== void 0) return precomputed;
|
|
2305
|
+
}
|
|
2306
|
+
const cached = this.#cache.get(cacheKey);
|
|
2307
|
+
if (cached !== void 0) {
|
|
2308
|
+
this.#cache.delete(cacheKey);
|
|
2309
|
+
this.#cache.set(cacheKey, cached);
|
|
2310
|
+
return cached;
|
|
2311
|
+
}
|
|
2312
|
+
const result = this.#compute(props, recipe);
|
|
2313
|
+
this.#cache.set(cacheKey, result);
|
|
2314
|
+
if (this.#cache.size > 1e3) {
|
|
2315
|
+
const lru = this.#cache.keys().next().value;
|
|
2316
|
+
if (lru !== void 0) this.#cache.delete(lru);
|
|
2317
|
+
}
|
|
2318
|
+
return result;
|
|
2319
|
+
}
|
|
2320
|
+
#compute(props, recipe) {
|
|
2321
|
+
if (!this.#cvaFn) return "";
|
|
2322
|
+
if (!recipe) return this.#cvaFn(props);
|
|
2323
|
+
const preset = this.#recipeMap[recipe];
|
|
2324
|
+
if (!preset) return this.#cvaFn(props);
|
|
2325
|
+
return this.#cvaFn({ ...preset, ...props });
|
|
2326
|
+
}
|
|
2327
|
+
// When variantKeys is provided, only those keys are included in the cache key — non-variant
|
|
2328
|
+
// props (className, id, etc.) produce identical CVA output and must not fragment the cache.
|
|
2329
|
+
// Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
|
|
2330
|
+
// String is built incrementally to avoid a parts[] array allocation on every render.
|
|
2331
|
+
#createCacheKey(props, recipe) {
|
|
2332
|
+
if (this.#variantKeys !== null) {
|
|
2333
|
+
let key2 = recipe;
|
|
2334
|
+
iterate.forEachSet(this.#variantKeys, (k) => {
|
|
2335
|
+
if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
2226
2336
|
});
|
|
2227
|
-
return
|
|
2337
|
+
return key2;
|
|
2338
|
+
}
|
|
2339
|
+
let key = recipe;
|
|
2340
|
+
iterate.forEach(Object.keys(props).sort(), (k) => {
|
|
2341
|
+
key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
2342
|
+
});
|
|
2343
|
+
return key;
|
|
2344
|
+
}
|
|
2345
|
+
static #serializeValue(value) {
|
|
2346
|
+
if (value === void 0) return "u";
|
|
2347
|
+
if (value === null) return "n";
|
|
2348
|
+
if (typeof value === "boolean") return `b:${value}`;
|
|
2349
|
+
if (typeof value === "string") return `s:${value}`;
|
|
2350
|
+
return `x:${String(value)}`;
|
|
2351
|
+
}
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
// ../../lib/styling/src/create-class-pipeline.ts
|
|
2355
|
+
function createClassPipeline(resolved) {
|
|
2356
|
+
const baseClass = resolved.baseClassName ?? "";
|
|
2357
|
+
const cvaFn = resolved.variants ? cva2("", {
|
|
2358
|
+
variants: resolved.variants,
|
|
2359
|
+
defaultVariants: resolved.defaultVariants,
|
|
2360
|
+
compoundVariants: resolved.compoundVariants
|
|
2361
|
+
}) : null;
|
|
2362
|
+
const variantKeys = resolved.variants ? new Set(Object.keys(resolved.variants)) : void 0;
|
|
2363
|
+
const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
|
|
2364
|
+
const variantResolver = new VariantClassResolver(
|
|
2365
|
+
cvaFn,
|
|
2366
|
+
resolved.recipeMap,
|
|
2367
|
+
variantKeys,
|
|
2368
|
+
resolved.precomputedClasses
|
|
2369
|
+
);
|
|
2370
|
+
return function resolveClasses(tag, props, className, recipe) {
|
|
2371
|
+
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
2372
|
+
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
2373
|
+
if (!className)
|
|
2374
|
+
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
2375
|
+
return cn(staticClasses, variantClasses, className);
|
|
2376
|
+
};
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
// ../../lib/pipeline-kit/src/factory/define-pipeline.ts
|
|
2380
|
+
function definePipeline(factory) {
|
|
2381
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
2382
|
+
return (resolved) => {
|
|
2383
|
+
let pipeline = cache.get(resolved);
|
|
2384
|
+
if (!pipeline) {
|
|
2385
|
+
pipeline = factory(resolved);
|
|
2386
|
+
cache.set(resolved, pipeline);
|
|
2387
|
+
}
|
|
2388
|
+
return pipeline;
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
// ../core/src/options/resolve-factory-options.ts
|
|
2393
|
+
import { silentDiagnostics } from "../_shared/diagnostics.js";
|
|
2394
|
+
var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
|
|
2395
|
+
function composeNormalizers(normalizers, fn) {
|
|
2396
|
+
if (!normalizers?.length) return fn;
|
|
2397
|
+
return ((props) => {
|
|
2398
|
+
const patched = normalizers.reduce(
|
|
2399
|
+
(acc, normalizer) => ({ ...acc, ...normalizer(acc) }),
|
|
2400
|
+
props
|
|
2401
|
+
);
|
|
2402
|
+
return fn ? fn(patched) : patched;
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
function whenDefined(key, value) {
|
|
2406
|
+
return value === void 0 ? {} : { [key]: value };
|
|
2407
|
+
}
|
|
2408
|
+
function resolveFactoryOptions(options = {}) {
|
|
2409
|
+
const { styling, enforcement } = options;
|
|
2410
|
+
const composedNormalizeFn = composeNormalizers(enforcement?.props, options.normalize);
|
|
2411
|
+
const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
|
|
2412
|
+
return Object.freeze({
|
|
2413
|
+
defaultTag: options.tag ?? "div",
|
|
2414
|
+
diagnostics: enforcement?.diagnostics ?? silentDiagnostics,
|
|
2415
|
+
variantKeys,
|
|
2416
|
+
...whenDefined("displayName", options.name),
|
|
2417
|
+
...whenDefined("defaultProps", options.defaults),
|
|
2418
|
+
...whenDefined("baseClassName", styling?.base),
|
|
2419
|
+
...whenDefined("tagMap", styling?.tags),
|
|
2420
|
+
...whenDefined("recipeMap", styling?.presets),
|
|
2421
|
+
...whenDefined("variants", styling?.variants),
|
|
2422
|
+
...whenDefined("defaultVariants", styling?.defaults),
|
|
2423
|
+
...whenDefined("compoundVariants", styling?.compounds),
|
|
2424
|
+
...whenDefined("normalizeFn", composedNormalizeFn),
|
|
2425
|
+
...whenDefined("ariaRules", enforcement?.aria),
|
|
2426
|
+
...whenDefined("childRules", enforcement?.children),
|
|
2427
|
+
...whenDefined("allowedAs", enforcement?.allowedAs),
|
|
2428
|
+
...whenDefined("precomputedClasses", styling?.precomputedClasses)
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
// ../core/src/options/validate-factory-options.ts
|
|
2433
|
+
function validateFactoryOptions(resolved, diagnostics) {
|
|
2434
|
+
if (!diagnostics.active) return;
|
|
2435
|
+
const name = resolved.displayName ?? "Component";
|
|
2436
|
+
const { variants } = resolved;
|
|
2437
|
+
const checkSelection = (label2, selection) => {
|
|
2438
|
+
iterate.forEachEntry(selection, (dim, value) => {
|
|
2439
|
+
if (value === void 0 || value === null) return;
|
|
2440
|
+
if (!variants || !Object.hasOwn(variants, dim)) {
|
|
2441
|
+
diagnostics.error(ContractDiagnostics.unknownVariantDim(name, label2, dim));
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2444
|
+
const states = variants[dim];
|
|
2445
|
+
const stateKey = String(value);
|
|
2446
|
+
if (!Object.hasOwn(states, stateKey)) {
|
|
2447
|
+
diagnostics.error(
|
|
2448
|
+
ContractDiagnostics.unknownVariantValue(name, label2, dim, stateKey, Object.keys(states))
|
|
2449
|
+
);
|
|
2450
|
+
}
|
|
2451
|
+
});
|
|
2452
|
+
};
|
|
2453
|
+
const { recipeMap } = resolved;
|
|
2454
|
+
if (recipeMap) {
|
|
2455
|
+
iterate.forEachEntry(recipeMap, (recipeKey, selection) => {
|
|
2456
|
+
checkSelection(`preset "${recipeKey}"`, selection);
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
// ../core/src/options/validate-render-props.ts
|
|
2463
|
+
function label(name) {
|
|
2464
|
+
return name ? `[${name}]` : "[createContractComponent]";
|
|
2465
|
+
}
|
|
2466
|
+
function validateRenderProps(diagnostics, options, props, recipeKey) {
|
|
2467
|
+
const { recipeMap, variants, displayName } = options;
|
|
2468
|
+
const tag = label(displayName);
|
|
2469
|
+
if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
|
|
2470
|
+
diagnostics.error(ContractDiagnostics.unknownRecipeKey(tag, recipeKey));
|
|
2471
|
+
}
|
|
2472
|
+
if (variants) {
|
|
2473
|
+
iterate.forEachKey(variants, (key) => {
|
|
2474
|
+
if (!Object.hasOwn(props, key)) return;
|
|
2475
|
+
const value = props[key];
|
|
2476
|
+
if (value === void 0 || value === null) return;
|
|
2477
|
+
const dim = variants[key];
|
|
2478
|
+
if (dim && !Object.hasOwn(dim, String(value))) {
|
|
2479
|
+
diagnostics.error(ContractDiagnostics.invalidVariantValue(tag, key, String(value)));
|
|
2480
|
+
}
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
// ../core/src/factory/plugin-invariants.ts
|
|
2486
|
+
import { throwDiagnostics } from "../_shared/diagnostics.js";
|
|
2487
|
+
|
|
2488
|
+
// ../core/src/factory/plugin-diagnostics.ts
|
|
2489
|
+
import { DiagnosticCategory as DiagnosticCategory5, DiagnosticCode as DiagnosticCode5 } from "../_shared/diagnostics.js";
|
|
2490
|
+
var PluginDiagnostics = {
|
|
2491
|
+
invalidShape(received) {
|
|
2492
|
+
const got = received === null ? "null" : typeof received;
|
|
2493
|
+
return {
|
|
2494
|
+
code: DiagnosticCode5.PluginInvalidShape,
|
|
2495
|
+
category: DiagnosticCategory5.Internal,
|
|
2496
|
+
message: `[praxis-kit] Plugin factory must return an object with a 'pipeline' function. Got: ${got}.`
|
|
2497
|
+
};
|
|
2498
|
+
},
|
|
2499
|
+
pipelineReturnType(received) {
|
|
2500
|
+
const got = received === null ? "null" : Array.isArray(received) ? "array" : typeof received;
|
|
2501
|
+
return {
|
|
2502
|
+
code: DiagnosticCode5.PluginPipelineReturnType,
|
|
2503
|
+
category: DiagnosticCategory5.Internal,
|
|
2504
|
+
message: `[praxis-kit] Plugin pipeline must return a string. Got: ${got}.`
|
|
2505
|
+
};
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
|
|
2509
|
+
// ../core/src/factory/plugin-invariants.ts
|
|
2510
|
+
function assertPluginShape(result) {
|
|
2511
|
+
if (result === null || typeof result !== "object")
|
|
2512
|
+
throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
|
|
2513
|
+
const plugin = result;
|
|
2514
|
+
if (typeof plugin.pipeline !== "function")
|
|
2515
|
+
throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
|
|
2516
|
+
}
|
|
2517
|
+
function guardPipeline(pipeline) {
|
|
2518
|
+
if (process.env.NODE_ENV === "production") return pipeline;
|
|
2519
|
+
return function guardedPipeline(tag, props, className, recipe) {
|
|
2520
|
+
const result = pipeline(tag, props, className, recipe);
|
|
2521
|
+
if (typeof result !== "string")
|
|
2522
|
+
throwDiagnostics.error(PluginDiagnostics.pipelineReturnType(result));
|
|
2523
|
+
return result;
|
|
2524
|
+
};
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
// ../core/src/factory/create-polymorphic2.ts
|
|
2528
|
+
var createTagPipeline = (resolved) => makeResolveTag(resolved.defaultTag);
|
|
2529
|
+
var createPropsPipeline = (resolved) => (props) => mergeProps(resolved.defaultProps, props);
|
|
2530
|
+
var createHtmlPropNormalizersPipeline = () => getHtmlPropNormalizers;
|
|
2531
|
+
var createHtmlChildrenEvaluatorPipeline = () => getHtmlChildrenEvaluator;
|
|
2532
|
+
var createStylingClassPipeline = (resolved) => createClassPipeline(resolved);
|
|
2533
|
+
function resolveAriaRules(resolved) {
|
|
2534
|
+
return [.../* @__PURE__ */ new Set([...HTML_ARIA_RULES, ...resolved.ariaRules ?? []])];
|
|
2535
|
+
}
|
|
2536
|
+
var createAriaPipeline = (resolved) => {
|
|
2537
|
+
const rules = resolveAriaRules(resolved);
|
|
2538
|
+
const engine = new AriaPolicyEngine(resolved.diagnostics, rules.length ? { rules } : void 0);
|
|
2539
|
+
return (tag, props) => engine.validate(tag, props);
|
|
2540
|
+
};
|
|
2541
|
+
var memoizedTagPipeline = definePipeline(createTagPipeline);
|
|
2542
|
+
var memoizedPropsPipeline = definePipeline(createPropsPipeline);
|
|
2543
|
+
var memoizedHtmlPropNormalizersPipeline = definePipeline(createHtmlPropNormalizersPipeline);
|
|
2544
|
+
var memoizedHtmlChildrenEvaluatorPipeline = definePipeline(createHtmlChildrenEvaluatorPipeline);
|
|
2545
|
+
var memoizedClassPipeline = definePipeline(createStylingClassPipeline);
|
|
2546
|
+
var memoizedAriaPipeline = definePipeline(createAriaPipeline);
|
|
2547
|
+
function resolveAriaPassthrough(_tag, props) {
|
|
2548
|
+
return { props };
|
|
2549
|
+
}
|
|
2550
|
+
function resolveClassPlugin(factory, resolved, diagnostics) {
|
|
2551
|
+
if (!factory) return { pluginResult: void 0, classPipeline: memoizedClassPipeline(resolved) };
|
|
2552
|
+
const pluginResult = factory(resolved, diagnostics);
|
|
2553
|
+
assertPluginShape(pluginResult);
|
|
2554
|
+
return { pluginResult, classPipeline: guardPipeline(pluginResult.pipeline) };
|
|
2555
|
+
}
|
|
2556
|
+
function createPolymorphic2(options = {}) {
|
|
2557
|
+
const baseResolved = resolveFactoryOptions(options);
|
|
2558
|
+
const anyBaseResolved = baseResolved;
|
|
2559
|
+
const resolved = Object.freeze({
|
|
2560
|
+
...baseResolved,
|
|
2561
|
+
htmlPropNormalizersFn: memoizedHtmlPropNormalizersPipeline(anyBaseResolved),
|
|
2562
|
+
htmlChildrenEvaluatorFn: memoizedHtmlChildrenEvaluatorPipeline(anyBaseResolved)
|
|
2563
|
+
});
|
|
2564
|
+
const anyResolved = resolved;
|
|
2565
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2566
|
+
validateFactoryOptions(resolved, resolved.diagnostics);
|
|
2567
|
+
}
|
|
2568
|
+
const { pluginResult, classPipeline } = resolveClassPlugin(
|
|
2569
|
+
options.styling?.plugin,
|
|
2570
|
+
anyResolved,
|
|
2571
|
+
resolved.diagnostics
|
|
2572
|
+
);
|
|
2573
|
+
const resolveTag2 = memoizedTagPipeline(anyResolved);
|
|
2574
|
+
const resolveProps = memoizedPropsPipeline(anyResolved);
|
|
2575
|
+
const resolveAriaFn = options.enforcement !== void 0 ? memoizedAriaPipeline(anyResolved) : resolveAriaPassthrough;
|
|
2576
|
+
const methods = {
|
|
2577
|
+
resolveTag: resolveTag2,
|
|
2578
|
+
resolveProps,
|
|
2579
|
+
resolveClasses(tag, props, className, recipe) {
|
|
2580
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2581
|
+
validateRenderProps(resolved.diagnostics, resolved, props, recipe);
|
|
2582
|
+
}
|
|
2583
|
+
return classPipeline(tag, props, className, recipe);
|
|
2584
|
+
},
|
|
2585
|
+
resolveAria(tag, props) {
|
|
2586
|
+
return resolveAriaFn(tag, props);
|
|
2228
2587
|
}
|
|
2229
2588
|
};
|
|
2589
|
+
const runtimeObject = pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
|
|
2590
|
+
return runtimeObject;
|
|
2230
2591
|
}
|
|
2231
2592
|
|
|
2232
2593
|
// ../core/src/resolver/resolver.ts
|
|
2594
|
+
import { silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
|
|
2233
2595
|
function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
|
|
2234
2596
|
if (allowedAs.includes(tag)) return;
|
|
2235
2597
|
if (!diagnostics) return;
|
|
@@ -2237,32 +2599,49 @@ function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
|
|
|
2237
2599
|
diagnostics.error(ContractDiagnostics.allowedAsViolation(String(tag), allowedAs, component));
|
|
2238
2600
|
}
|
|
2239
2601
|
|
|
2240
|
-
// ../../lib/adapter-utils/src/
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
|
-
// ../../lib/adapter-utils/src/define-component.ts
|
|
2248
|
-
function defineContractComponent(options) {
|
|
2249
|
-
return (factory) => factory(options);
|
|
2602
|
+
// ../../lib/adapter-utils/src/runtime/build-core-runtime.ts
|
|
2603
|
+
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
2604
|
+
function buildCoreRuntime(normalized) {
|
|
2605
|
+
const runtime = createPolymorphic2(normalized);
|
|
2606
|
+
const ownedKeys = "classPlugin" in runtime ? runtime.classPlugin.ownedKeys ?? EMPTY_SET : EMPTY_SET;
|
|
2607
|
+
return { runtime, ownedKeys };
|
|
2250
2608
|
}
|
|
2251
2609
|
|
|
2252
|
-
// ../../lib/adapter-utils/src/build-engines.ts
|
|
2610
|
+
// ../../lib/adapter-utils/src/runtime/build-engines.ts
|
|
2253
2611
|
function buildEngines(diagnostics, childRules, context) {
|
|
2254
2612
|
return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
|
|
2255
2613
|
}
|
|
2256
2614
|
|
|
2257
|
-
// ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
|
|
2258
|
-
|
|
2615
|
+
// ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
|
|
2616
|
+
import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3 } from "../_shared/diagnostics.js";
|
|
2617
|
+
function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
|
|
2259
2618
|
return {
|
|
2260
2619
|
name: options.name ?? defaultName,
|
|
2261
2620
|
diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
|
|
2262
2621
|
};
|
|
2263
2622
|
}
|
|
2264
2623
|
|
|
2265
|
-
// ../../lib/adapter-utils/src/
|
|
2624
|
+
// ../../lib/adapter-utils/src/props/apply-filter.ts
|
|
2625
|
+
function applyFilter(props, filterProps, variantKeys) {
|
|
2626
|
+
const out = {};
|
|
2627
|
+
iterate.forEachEntry(props, (k) => {
|
|
2628
|
+
if (!Object.hasOwn(props, k)) return;
|
|
2629
|
+
if (filterProps(k, variantKeys)) return;
|
|
2630
|
+
out[k] = props[k];
|
|
2631
|
+
});
|
|
2632
|
+
return out;
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
// ../../lib/adapter-utils/src/props/compose-filter.ts
|
|
2636
|
+
function composeFilter(ownedKeys, filterProps) {
|
|
2637
|
+
const defaultFilter = (key, variantKeys) => variantKeys.has(key) || ownedKeys.has(key);
|
|
2638
|
+
if (!filterProps) {
|
|
2639
|
+
return defaultFilter;
|
|
2640
|
+
}
|
|
2641
|
+
return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
// ../../lib/adapter-utils/src/slot/slot-validator.ts
|
|
2266
2645
|
var SlotValidator = class extends InvariantBase {
|
|
2267
2646
|
#name;
|
|
2268
2647
|
#elementTerm;
|
|
@@ -2285,18 +2664,18 @@ var SlotValidator = class extends InvariantBase {
|
|
|
2285
2664
|
};
|
|
2286
2665
|
|
|
2287
2666
|
// ../../lib/adapter-utils/src/slot/policies.ts
|
|
2288
|
-
import { clsx } from "clsx";
|
|
2667
|
+
import { clsx as clsx3 } from "clsx";
|
|
2289
2668
|
function chainHandlers(childHandler, slotHandler) {
|
|
2290
2669
|
return (...args) => {
|
|
2291
2670
|
childHandler(...args);
|
|
2292
2671
|
const event = args[0];
|
|
2293
|
-
if (!(
|
|
2672
|
+
if (!(isObject(event) && "defaultPrevented" in event && event.defaultPrevented)) {
|
|
2294
2673
|
slotHandler(...args);
|
|
2295
2674
|
}
|
|
2296
2675
|
};
|
|
2297
2676
|
}
|
|
2298
2677
|
function mergeClassNames(slot, child) {
|
|
2299
|
-
return
|
|
2678
|
+
return clsx3(slot, child);
|
|
2300
2679
|
}
|
|
2301
2680
|
function mergeStyles(slot, child) {
|
|
2302
2681
|
if (!isPlainObject(slot) || !isPlainObject(child)) return child;
|
|
@@ -2328,449 +2707,261 @@ function applyMergePolicy(key, slotVal, childVal) {
|
|
|
2328
2707
|
return policyHandlers[classifyProp(key, slotVal, childVal)](slotVal, childVal);
|
|
2329
2708
|
}
|
|
2330
2709
|
|
|
2331
|
-
// ../../
|
|
2332
|
-
|
|
2333
|
-
return {
|
|
2334
|
-
identity: {
|
|
2335
|
-
id: name,
|
|
2336
|
-
name,
|
|
2337
|
-
tag
|
|
2338
|
-
},
|
|
2339
|
-
capabilities: {},
|
|
2340
|
-
metadata: {},
|
|
2341
|
-
diagnostics: []
|
|
2342
|
-
};
|
|
2343
|
-
}
|
|
2710
|
+
// ../../adapters/preact/src/render.tsx
|
|
2711
|
+
import { h as h2 } from "preact";
|
|
2344
2712
|
|
|
2345
|
-
// ../../
|
|
2346
|
-
|
|
2347
|
-
return Array.isArray(cls) ? cls.join(" ") : cls;
|
|
2348
|
-
}
|
|
2349
|
-
function mapVariantRecord(source, mapper) {
|
|
2350
|
-
return iterate.mapValues(
|
|
2351
|
-
source,
|
|
2352
|
-
(inner) => iterate.mapValues(inner, mapper)
|
|
2353
|
-
);
|
|
2354
|
-
}
|
|
2355
|
-
function buildVariantConfig(variants, presets, defaults, compounds) {
|
|
2356
|
-
return {
|
|
2357
|
-
variants: mapVariantRecord(variants ?? {}, flattenClassName),
|
|
2358
|
-
...presets !== void 0 && Object.keys(presets).length > 0 && { presets },
|
|
2359
|
-
...defaults !== void 0 && Object.keys(defaults).length > 0 && { defaults },
|
|
2360
|
-
...compounds !== void 0 && compounds.length > 0 && {
|
|
2361
|
-
compounds
|
|
2362
|
-
}
|
|
2363
|
-
};
|
|
2364
|
-
}
|
|
2713
|
+
// ../../adapters/preact/src/slot/Slot.tsx
|
|
2714
|
+
import { forwardRef } from "preact/compat";
|
|
2365
2715
|
|
|
2366
|
-
// ../../
|
|
2367
|
-
|
|
2368
|
-
const existing = decoration[nodeId] ?? {};
|
|
2369
|
-
const next = { ...existing.attributes };
|
|
2370
|
-
if (removedKeys !== void 0) {
|
|
2371
|
-
iterate.forEachSet(removedKeys, (key) => {
|
|
2372
|
-
delete next[key];
|
|
2373
|
-
});
|
|
2374
|
-
}
|
|
2375
|
-
Object.assign(next, incoming);
|
|
2376
|
-
const { attributes: _dropped, ...rest } = existing;
|
|
2377
|
-
const nextDecoration = Object.keys(next).length > 0 ? { ...rest, attributes: next } : rest;
|
|
2378
|
-
return { ...decoration, [nodeId]: nextDecoration };
|
|
2379
|
-
}
|
|
2716
|
+
// ../../adapters/preact/src/slot/applySlot.ts
|
|
2717
|
+
import { isValidElement as isValidElement3 } from "preact";
|
|
2380
2718
|
|
|
2381
|
-
// ../../
|
|
2382
|
-
|
|
2383
|
-
const dec = decoration[nodeId];
|
|
2384
|
-
return { ...dec?.attributes ?? {}, ...dec?.variants ?? {} };
|
|
2385
|
-
}
|
|
2719
|
+
// ../../adapters/preact/src/slot/extractSlottable.ts
|
|
2720
|
+
import { h, Fragment as Fragment2, isValidElement as isValidElement2 } from "preact";
|
|
2386
2721
|
|
|
2387
|
-
// ../../
|
|
2388
|
-
|
|
2389
|
-
return backend.render({ definition, tree, render });
|
|
2390
|
-
}
|
|
2722
|
+
// ../../adapters/preact/src/slot/predicates.ts
|
|
2723
|
+
import { isValidElement } from "preact";
|
|
2391
2724
|
|
|
2392
|
-
// ../../
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2725
|
+
// ../../adapters/preact/src/slot/Slottable.tsx
|
|
2726
|
+
import { Fragment } from "preact";
|
|
2727
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2728
|
+
function Slottable({ children }) {
|
|
2729
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
// ../../adapters/preact/src/slot/predicates.ts
|
|
2733
|
+
function isSlottableElement(value) {
|
|
2734
|
+
return isValidElement(value) && value.type === Slottable;
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
// ../../adapters/preact/src/slot/extractSlottable.ts
|
|
2738
|
+
function extractSlottable(children) {
|
|
2739
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
2740
|
+
const slottables = childrenArray.filter(isSlottableElement);
|
|
2741
|
+
invariant(slottables.length <= 1, "Slot: multiple Slottable children are not allowed");
|
|
2742
|
+
if (slottables.length === 0) return null;
|
|
2743
|
+
const [slottable] = slottables;
|
|
2744
|
+
invariant(slottable, "Missing Slottable element");
|
|
2745
|
+
const child = slottable.props.children;
|
|
2746
|
+
invariant(
|
|
2747
|
+
child !== null && child !== void 0,
|
|
2748
|
+
"Slottable expects exactly one Preact element child, received null"
|
|
2408
2749
|
);
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
const
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
// ../../runtime/core/src/build-render-context.ts
|
|
2422
|
-
function buildRenderContext(decoration = {}) {
|
|
2423
|
-
return { decoration: new Map(Object.entries(decoration)) };
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
|
-
// ../../lib/adapter-utils/src/resolve-compounds.ts
|
|
2427
|
-
function matchesCompound(active, compound) {
|
|
2428
|
-
const { class: _, ...conditions } = compound;
|
|
2429
|
-
return Object.entries(conditions).every(([key, expected]) => {
|
|
2430
|
-
const actual = active[key];
|
|
2431
|
-
return Array.isArray(expected) ? expected.includes(actual) : actual === expected;
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2434
|
-
function resolveCompounds(active, compounds) {
|
|
2435
|
-
if (!compounds?.length) return [];
|
|
2436
|
-
const out = [];
|
|
2437
|
-
iterate.forEach(compounds, (compound) => {
|
|
2438
|
-
if (matchesCompound(active, compound)) {
|
|
2439
|
-
out.push(flattenClassName(compound.class));
|
|
2440
|
-
}
|
|
2441
|
-
});
|
|
2442
|
-
return out;
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
|
-
// ../../lib/adapter-utils/src/resolve-classes.ts
|
|
2446
|
-
function resolveClasses(decoration, variantConfig, variantDefaults, recipe, compounds, variantLookup) {
|
|
2447
|
-
const active = getActiveProps("root", decoration);
|
|
2448
|
-
if (variantLookup !== void 0 && recipe === void 0) {
|
|
2449
|
-
const activeVariants = {};
|
|
2450
|
-
iterate.forEachKey(variantConfig.variants, (key) => {
|
|
2451
|
-
const value = active[key];
|
|
2452
|
-
if (typeof value === "string") activeVariants[key] = value;
|
|
2453
|
-
});
|
|
2454
|
-
const lookupKey = buildPrecomputedKey(activeVariants);
|
|
2455
|
-
const precomputedValue = variantLookup[lookupKey];
|
|
2456
|
-
if (precomputedValue !== void 0) {
|
|
2457
|
-
return {
|
|
2458
|
-
variantClasses: precomputedValue !== "" ? [precomputedValue] : [],
|
|
2459
|
-
compoundClasses: []
|
|
2460
|
-
};
|
|
2750
|
+
invariant(
|
|
2751
|
+
typeof child !== "string" && typeof child !== "number",
|
|
2752
|
+
"Slottable expects exactly one Preact element child, received text content"
|
|
2753
|
+
);
|
|
2754
|
+
invariant(isValidElement2(child), "Slottable expects exactly one Preact element child");
|
|
2755
|
+
invariant(child.type !== Fragment2, "Slottable child cannot be a Fragment");
|
|
2756
|
+
const index = childrenArray.indexOf(slottable);
|
|
2757
|
+
return {
|
|
2758
|
+
child,
|
|
2759
|
+
rebuild(merged) {
|
|
2760
|
+
const out = childrenArray.map((node, i) => i === index ? merged : node);
|
|
2761
|
+
return h(Fragment2, null, ...out);
|
|
2461
2762
|
}
|
|
2462
|
-
}
|
|
2463
|
-
const passInput = recipe !== void 0 ? { ...active, preset: recipe } : active;
|
|
2464
|
-
const { context } = createVariantPass(passInput, variantConfig).execute({ classes: [] });
|
|
2465
|
-
const variantClasses = context.classes;
|
|
2466
|
-
const presetOverrides = recipe !== void 0 ? variantConfig.presets?.[recipe] ?? {} : {};
|
|
2467
|
-
const resolvedValues = {
|
|
2468
|
-
...variantDefaults,
|
|
2469
|
-
...presetOverrides,
|
|
2470
|
-
...active
|
|
2471
2763
|
};
|
|
2472
|
-
const compoundClasses = resolveCompounds(resolvedValues, compounds);
|
|
2473
|
-
return { variantClasses, compoundClasses };
|
|
2474
2764
|
}
|
|
2475
2765
|
|
|
2476
|
-
// ../../
|
|
2477
|
-
function
|
|
2478
|
-
|
|
2479
|
-
|
|
2766
|
+
// ../../adapters/preact/src/slot/applySlot.ts
|
|
2767
|
+
function applySlot(children, slotProps, ref, cloneSlotChild2) {
|
|
2768
|
+
const extraction = extractSlottable(children);
|
|
2769
|
+
if (extraction) {
|
|
2770
|
+
const merged = cloneSlotChild2({ child: extraction.child, slotProps, ref });
|
|
2771
|
+
return extraction.rebuild(merged);
|
|
2480
2772
|
}
|
|
2481
|
-
|
|
2482
|
-
return {
|
|
2483
|
-
execute(decoration, recipe) {
|
|
2484
|
-
return resolveClasses(decoration, variantConfig, defaults, recipe, compounds, variantLookup);
|
|
2485
|
-
}
|
|
2486
|
-
};
|
|
2773
|
+
invariant(isValidElement3(children), "Slot: child must be a valid Preact element");
|
|
2774
|
+
return cloneSlotChild2({ child: children, slotProps, ref });
|
|
2487
2775
|
}
|
|
2488
2776
|
|
|
2489
|
-
// ../../
|
|
2490
|
-
|
|
2491
|
-
return classes.filter(Boolean).join(" ");
|
|
2492
|
-
}
|
|
2777
|
+
// ../../adapters/preact/src/slot/cloneSlotChild.ts
|
|
2778
|
+
import { cloneElement, Fragment as Fragment3 } from "preact";
|
|
2493
2779
|
|
|
2494
|
-
// ../../
|
|
2495
|
-
function
|
|
2496
|
-
|
|
2497
|
-
return attributes !== void 0 ? { ...rest, attributes } : rest;
|
|
2780
|
+
// ../../adapters/preact/src/slot/composeRefs.ts
|
|
2781
|
+
function mergeRefs(...refs) {
|
|
2782
|
+
return mergeRefsCore(...refs);
|
|
2498
2783
|
}
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
if (ariaEngine === void 0) return decoration;
|
|
2503
|
-
const dec = decoration["root"];
|
|
2504
|
-
if (dec?.attributes === void 0) return decoration;
|
|
2505
|
-
const result = ariaEngine.validate(tag, dec.attributes);
|
|
2506
|
-
const cleaned = result.props;
|
|
2507
|
-
return {
|
|
2508
|
-
...decoration,
|
|
2509
|
-
root: withAttributes(dec, Object.keys(cleaned).length > 0 ? cleaned : void 0)
|
|
2510
|
-
};
|
|
2784
|
+
function getChildRef(child) {
|
|
2785
|
+
const ref = child.ref;
|
|
2786
|
+
return ref ?? null;
|
|
2511
2787
|
}
|
|
2512
2788
|
|
|
2513
|
-
// ../../
|
|
2514
|
-
function
|
|
2515
|
-
|
|
2516
|
-
const
|
|
2517
|
-
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2520
|
-
);
|
|
2521
|
-
return {
|
|
2522
|
-
...decoration,
|
|
2523
|
-
root: withAttributes(dec, Object.keys(kept).length > 0 ? kept : void 0)
|
|
2524
|
-
};
|
|
2789
|
+
// ../../adapters/preact/src/slot/cloneSlotChild.ts
|
|
2790
|
+
function cloneSlotChild({ child, slotProps, ref }) {
|
|
2791
|
+
const childProps = child.props;
|
|
2792
|
+
const isFragment = child.type === Fragment3;
|
|
2793
|
+
const childRef = isFragment ? null : getChildRef(child);
|
|
2794
|
+
const mergedRef = isFragment ? null : mergeRefs(ref, childRef);
|
|
2795
|
+
const merged = mergeSlotProps(slotProps, childProps);
|
|
2796
|
+
return cloneElement(child, mergedRef !== null ? { ...merged, ref: mergedRef } : merged);
|
|
2525
2797
|
}
|
|
2526
2798
|
|
|
2527
|
-
// ../../
|
|
2528
|
-
function
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2799
|
+
// ../../adapters/preact/src/slot/Slot.tsx
|
|
2800
|
+
var Slot = forwardRef(function Slot2({ children, ...slotProps }, ref) {
|
|
2801
|
+
return applySlot(children, slotProps, ref ?? null, cloneSlotChild);
|
|
2802
|
+
});
|
|
2803
|
+
Object.assign(Slot, { displayName: SLOT_NAME });
|
|
2804
|
+
|
|
2805
|
+
// ../../adapters/preact/src/render.tsx
|
|
2806
|
+
function buildRenderState(tag, directives, props, className, children) {
|
|
2807
|
+
const state = { tag, directives, props, className };
|
|
2808
|
+
if (children !== void 0) state.children = children;
|
|
2809
|
+
return state;
|
|
2810
|
+
}
|
|
2811
|
+
function prepareRenderState(runtime, props, filterProps) {
|
|
2812
|
+
const { as, asChild, children, className, recipe, ...rest } = props;
|
|
2813
|
+
const tag = runtime.resolveTag(as);
|
|
2814
|
+
if (runtime.options.allowedAs !== void 0 && as !== void 0) {
|
|
2815
|
+
enforceAllowedAs(
|
|
2816
|
+
tag,
|
|
2817
|
+
runtime.options.allowedAs,
|
|
2818
|
+
runtime.options.diagnostics,
|
|
2819
|
+
runtime.options.displayName
|
|
2820
|
+
);
|
|
2821
|
+
}
|
|
2822
|
+
const mergedProps = runtime.resolveProps(rest);
|
|
2823
|
+
const htmlNormalizers = runtime.options.htmlPropNormalizersFn?.(tag);
|
|
2824
|
+
const htmlNormalizedProps = htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), mergedProps) : mergedProps;
|
|
2825
|
+
const normalizedProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(htmlNormalizedProps) : htmlNormalizedProps;
|
|
2826
|
+
const resolvedClass = runtime.resolveClasses(tag, normalizedProps, className, recipe);
|
|
2827
|
+
const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
|
|
2828
|
+
const directives = {
|
|
2829
|
+
...as !== void 0 && { as },
|
|
2830
|
+
...asChild !== void 0 && { asChild }
|
|
2831
|
+
};
|
|
2832
|
+
return buildRenderState(tag, directives, filteredProps, resolvedClass, children);
|
|
2532
2833
|
}
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
// ../../adapters/preact/src/backend/extract-decoration.ts
|
|
2538
|
-
function isStyleValue(v) {
|
|
2539
|
-
return isString(v) || isNumber(v);
|
|
2834
|
+
function warnDiscardedChildren(originalChildren, normalizedChildren, validator) {
|
|
2835
|
+
if (!Array.isArray(originalChildren)) return;
|
|
2836
|
+
const discarded = originalChildren.length - normalizedChildren.length;
|
|
2837
|
+
if (discarded > 0) validator.warnDiscardedChildren(discarded);
|
|
2540
2838
|
}
|
|
2541
|
-
function
|
|
2542
|
-
return
|
|
2839
|
+
function isSingleElementArray(arr) {
|
|
2840
|
+
return arr.length === 1;
|
|
2543
2841
|
}
|
|
2544
|
-
function
|
|
2545
|
-
|
|
2546
|
-
|
|
2842
|
+
function resolveSlotChildren(children, normalized, validator) {
|
|
2843
|
+
warnDiscardedChildren(children, normalized, validator);
|
|
2844
|
+
if (isSingleElementArray(normalized)) {
|
|
2845
|
+
return normalized[0];
|
|
2547
2846
|
}
|
|
2847
|
+
if (normalized.length > 1 && normalized.some(isSlottableElement)) {
|
|
2848
|
+
return normalized;
|
|
2849
|
+
}
|
|
2850
|
+
validator.assertSingleChild(normalized.length);
|
|
2851
|
+
return null;
|
|
2548
2852
|
}
|
|
2549
|
-
function
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
}
|
|
2555
|
-
});
|
|
2556
|
-
return true;
|
|
2557
|
-
}
|
|
2558
|
-
function extractListener(key, value, listeners) {
|
|
2559
|
-
if (!key.startsWith("on") || !isFunction(value)) {
|
|
2853
|
+
function validateSlotDirectives(directives, validator) {
|
|
2854
|
+
const { as, asChild } = directives;
|
|
2855
|
+
if (!asChild) return false;
|
|
2856
|
+
if (as !== void 0) {
|
|
2857
|
+
validator.assertExclusive();
|
|
2560
2858
|
return false;
|
|
2561
2859
|
}
|
|
2562
|
-
listeners[key] = value;
|
|
2563
2860
|
return true;
|
|
2564
2861
|
}
|
|
2565
|
-
function
|
|
2566
|
-
if (
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
const dec = {};
|
|
2578
|
-
iterate.forEachEntry(props, (key, value) => {
|
|
2579
|
-
if (key === "children" || key === "slot" || key === "ref") return;
|
|
2580
|
-
if (key === "style" && extractStyles(value, styles)) return;
|
|
2581
|
-
if (extractListener(key, value, listeners)) return;
|
|
2582
|
-
if (isAttributeValue(value)) {
|
|
2583
|
-
extractAttributeOrVariant(key, value, attributes, variants, variantKeys);
|
|
2584
|
-
}
|
|
2862
|
+
function resolveSlotRender(state, getNormalized, validator) {
|
|
2863
|
+
if (!validateSlotDirectives(state.directives, validator)) return null;
|
|
2864
|
+
const child = resolveSlotChildren(state.children, getNormalized(), validator);
|
|
2865
|
+
if (child === null) return null;
|
|
2866
|
+
return { child };
|
|
2867
|
+
}
|
|
2868
|
+
function renderResolvedSlot(slotComponent, state, slotRender, ref) {
|
|
2869
|
+
return h2(slotComponent, {
|
|
2870
|
+
...state.props,
|
|
2871
|
+
className: state.className,
|
|
2872
|
+
ref,
|
|
2873
|
+
children: slotRender.child
|
|
2585
2874
|
});
|
|
2586
|
-
assignIfNotEmpty(dec, "attributes", attributes);
|
|
2587
|
-
assignIfNotEmpty(dec, "styles", styles);
|
|
2588
|
-
assignIfNotEmpty(dec, "listeners", listeners);
|
|
2589
|
-
assignIfNotEmpty(dec, "variants", variants);
|
|
2590
|
-
const ref = props.ref;
|
|
2591
|
-
if (ref !== void 0) {
|
|
2592
|
-
dec.ref = ref;
|
|
2593
|
-
}
|
|
2594
|
-
return dec;
|
|
2595
2875
|
}
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
// ../../adapters/preact/src/backend/build-props.ts
|
|
2604
|
-
function buildPropsFromDecoration(id, decoration) {
|
|
2876
|
+
function tryRenderAsChild(state, ref, slotComponent, getNormalized, validator) {
|
|
2877
|
+
const slotRender = resolveSlotRender(state, getNormalized, validator);
|
|
2878
|
+
if (slotRender === null) return null;
|
|
2879
|
+
return renderResolvedSlot(slotComponent, state, slotRender, ref);
|
|
2880
|
+
}
|
|
2881
|
+
function buildElementProps(props, className, ref, children) {
|
|
2882
|
+
const { role, ...rest } = props;
|
|
2605
2883
|
return {
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
...
|
|
2610
|
-
...
|
|
2884
|
+
...rest,
|
|
2885
|
+
className,
|
|
2886
|
+
ref,
|
|
2887
|
+
...children !== void 0 && { children },
|
|
2888
|
+
...isKnownAriaRole(role) && { role }
|
|
2611
2889
|
};
|
|
2612
2890
|
}
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2891
|
+
function renderIntrinsic(state, ref, runtime) {
|
|
2892
|
+
const elementProps = buildElementProps(state.props, state.className, ref, state.children);
|
|
2893
|
+
const domProps = typeof state.tag === "string" ? runtime.resolveAria(state.tag, elementProps).props : elementProps;
|
|
2894
|
+
return h2(state.tag, domProps);
|
|
2895
|
+
}
|
|
2896
|
+
function render({
|
|
2897
|
+
runtime,
|
|
2898
|
+
props,
|
|
2899
|
+
ref,
|
|
2900
|
+
slotComponent,
|
|
2901
|
+
normalizeChildren: normalizeChildren2,
|
|
2902
|
+
filterProps,
|
|
2903
|
+
slotValidator,
|
|
2904
|
+
childrenEvaluator
|
|
2905
|
+
}) {
|
|
2906
|
+
const state = prepareRenderState(runtime, props, filterProps);
|
|
2907
|
+
let normalizedChildren;
|
|
2908
|
+
const getNormalizedChildren = () => normalizedChildren ??= normalizeChildren2(state.children);
|
|
2909
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2910
|
+
childrenEvaluator?.evaluate(getNormalizedChildren());
|
|
2911
|
+
runtime.options.htmlChildrenEvaluatorFn?.(state.tag)?.evaluate(getNormalizedChildren());
|
|
2912
|
+
}
|
|
2913
|
+
const slotResult = tryRenderAsChild(
|
|
2914
|
+
state,
|
|
2915
|
+
ref,
|
|
2916
|
+
slotComponent,
|
|
2917
|
+
getNormalizedChildren,
|
|
2918
|
+
slotValidator
|
|
2638
2919
|
);
|
|
2639
|
-
return
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
// ../../adapters/preact/src/helpers/make-render-as-child.ts
|
|
2643
|
-
import { isValidElement } from "preact";
|
|
2644
|
-
function makeRenderAsChild(cloneSlotChild2) {
|
|
2645
|
-
return function renderAsChild(children, className, ref) {
|
|
2646
|
-
if (!isValidElement(children)) throw new Error("asChild requires a Preact element child");
|
|
2647
|
-
const slotProps = className ? { className } : {};
|
|
2648
|
-
return cloneSlotChild2({ child: children, slotProps, ref: ref ?? null });
|
|
2649
|
-
};
|
|
2920
|
+
return slotResult ?? renderIntrinsic(state, ref, runtime);
|
|
2650
2921
|
}
|
|
2651
2922
|
|
|
2652
2923
|
// ../../adapters/preact/src/normalize-children.ts
|
|
2653
|
-
import { isValidElement as
|
|
2924
|
+
import { isValidElement as isValidElement4 } from "preact";
|
|
2654
2925
|
function normalizeChildren(children) {
|
|
2655
|
-
if (
|
|
2656
|
-
if (Array.isArray(children)) return children.filter(
|
|
2926
|
+
if (isValidElement4(children)) return [children];
|
|
2927
|
+
if (Array.isArray(children)) return children.filter(isValidElement4);
|
|
2657
2928
|
return [];
|
|
2658
2929
|
}
|
|
2659
2930
|
|
|
2660
|
-
// ../../adapters/preact/src/
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
}
|
|
2667
|
-
function getChildRef(child) {
|
|
2668
|
-
const ref = child.ref;
|
|
2669
|
-
return ref ?? null;
|
|
2670
|
-
}
|
|
2671
|
-
|
|
2672
|
-
// ../../adapters/preact/src/slot/cloneSlotChild.ts
|
|
2673
|
-
function cloneSlotChild({ child, slotProps, ref }) {
|
|
2674
|
-
const childProps = child.props;
|
|
2675
|
-
const isFragment = child.type === Fragment2;
|
|
2676
|
-
const childRef = isFragment ? null : getChildRef(child);
|
|
2677
|
-
const mergedRef = isFragment ? null : mergeRefs(ref, childRef);
|
|
2678
|
-
const merged = mergeSlotProps(slotProps, childProps);
|
|
2679
|
-
return cloneElement2(child, mergedRef !== null ? { ...merged, ref: mergedRef } : merged);
|
|
2931
|
+
// ../../adapters/preact/src/build-runtime.ts
|
|
2932
|
+
function normalizeOptions(options) {
|
|
2933
|
+
return {
|
|
2934
|
+
...options,
|
|
2935
|
+
...resolveAdapterCommonOptions(options),
|
|
2936
|
+
slotComponent: options.slotComponent ?? Slot
|
|
2937
|
+
};
|
|
2680
2938
|
}
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2939
|
+
function buildRuntime(options) {
|
|
2940
|
+
const normalized = normalizeOptions(options);
|
|
2941
|
+
const { runtime, ownedKeys } = buildCoreRuntime(normalized);
|
|
2942
|
+
const { diagnostics, enforcement, filterProps: userFilter, name, slotComponent } = normalized;
|
|
2943
|
+
const { childrenEvaluator } = buildEngines(diagnostics, enforcement?.children, name);
|
|
2944
|
+
const filterProps = composeFilter(ownedKeys, userFilter);
|
|
2945
|
+
const slotValidator = new SlotValidator(name, diagnostics, "Preact element");
|
|
2946
|
+
const built = {
|
|
2947
|
+
runtime,
|
|
2948
|
+
filterProps,
|
|
2949
|
+
slotValidator,
|
|
2950
|
+
slotComponent,
|
|
2951
|
+
normalizeChildren,
|
|
2952
|
+
...childrenEvaluator !== void 0 && { childrenEvaluator }
|
|
2953
|
+
};
|
|
2954
|
+
return built;
|
|
2687
2955
|
}
|
|
2688
2956
|
|
|
2689
2957
|
// ../../adapters/preact/src/create-contract-component.ts
|
|
2690
|
-
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
2691
2958
|
function createContractComponent(options) {
|
|
2692
|
-
const
|
|
2693
|
-
const
|
|
2694
|
-
|
|
2695
|
-
const definition = buildDefinition(displayName, defaultTag);
|
|
2696
|
-
const variantKeys = new Set(Object.keys(options.styling?.variants ?? {}));
|
|
2697
|
-
const domDefaults = options.defaults;
|
|
2698
|
-
const stylePipeline = buildStylePipeline(
|
|
2699
|
-
options.styling?.variants,
|
|
2700
|
-
options.styling?.presets,
|
|
2701
|
-
options.styling?.defaults ?? {},
|
|
2702
|
-
options.styling?.compounds,
|
|
2703
|
-
void 0
|
|
2704
|
-
);
|
|
2705
|
-
const base = options.styling?.base !== void 0 ? flattenClassName(options.styling.base) : void 0;
|
|
2706
|
-
const filterFn = options.filterProps;
|
|
2707
|
-
const allowedAs = options.enforcement?.allowedAs;
|
|
2708
|
-
const normalizeFn = options.normalize;
|
|
2709
|
-
const enforcementNormalizers = options.enforcement?.props;
|
|
2710
|
-
const classPlugin = options.styling?.plugin !== void 0 ? options.styling.plugin(
|
|
2711
|
-
options.styling,
|
|
2712
|
-
resolved.diagnostics
|
|
2713
|
-
) : void 0;
|
|
2714
|
-
const pluginKeys = classPlugin?.ownedKeys ?? EMPTY_SET;
|
|
2715
|
-
const { childrenEvaluator: explicitEvaluator } = buildEngines(
|
|
2716
|
-
resolved.diagnostics,
|
|
2717
|
-
options.enforcement?.children,
|
|
2718
|
-
displayName
|
|
2719
|
-
);
|
|
2720
|
-
const ariaEngine = options.enforcement !== void 0 ? new AriaPolicyEngine(resolved.diagnostics) : void 0;
|
|
2721
|
-
const slotValidator = new SlotValidator(displayName, resolved.diagnostics, "Preact element");
|
|
2722
|
-
const renderAsChild = makeRenderAsChild(cloneSlotChild);
|
|
2723
|
-
const Component = forwardRef(function Component2(props, ref) {
|
|
2724
|
-
const {
|
|
2725
|
-
as,
|
|
2726
|
-
asChild,
|
|
2727
|
-
children,
|
|
2728
|
-
className: callerClassName,
|
|
2729
|
-
recipe,
|
|
2730
|
-
...ownProps
|
|
2731
|
-
} = props;
|
|
2732
|
-
const tag = typeof as === "string" ? as : defaultTag;
|
|
2733
|
-
if (allowedAs !== void 0) enforceAllowedAs(tag, allowedAs, resolved.diagnostics, displayName);
|
|
2734
|
-
const rawBaseProps = domDefaults !== void 0 ? { ...domDefaults, ...ownProps } : ownProps;
|
|
2735
|
-
const normalizedProps = applyPropNormalizers(tag, rawBaseProps, enforcementNormalizers);
|
|
2736
|
-
const baseProps = normalizeFn !== void 0 ? normalizeFn(normalizedProps) : normalizedProps;
|
|
2737
|
-
const pluginProps = {};
|
|
2738
|
-
const propsForExtraction = pluginKeys.size > 0 ? Object.fromEntries(
|
|
2739
|
-
Object.entries(baseProps).filter(([k]) => {
|
|
2740
|
-
if (pluginKeys.has(k)) {
|
|
2741
|
-
pluginProps[k] = baseProps[k];
|
|
2742
|
-
return false;
|
|
2743
|
-
}
|
|
2744
|
-
return true;
|
|
2745
|
-
})
|
|
2746
|
-
) : baseProps;
|
|
2747
|
-
const rootDec = extractDecoration(propsForExtraction, variantKeys);
|
|
2748
|
-
const decoration = applyAria(
|
|
2749
|
-
Object.keys(rootDec).length > 0 ? { root: rootDec } : {},
|
|
2750
|
-
tag,
|
|
2751
|
-
ariaEngine
|
|
2752
|
-
);
|
|
2753
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2754
|
-
const childEval = explicitEvaluator ?? getHtmlChildrenEvaluator(tag);
|
|
2755
|
-
childEval?.evaluate(normalizeChildren(children));
|
|
2756
|
-
}
|
|
2757
|
-
const recipeName = typeof recipe === "string" ? recipe : void 0;
|
|
2758
|
-
const { variantClasses, compoundClasses } = stylePipeline ? stylePipeline.execute(decoration, recipeName) : { variantClasses: [], compoundClasses: [] };
|
|
2759
|
-
const rawClassName = joinClasses(base, ...variantClasses, ...compoundClasses, callerClassName);
|
|
2760
|
-
const className = classPlugin !== void 0 ? classPlugin.pipeline(tag, pluginProps, rawClassName, recipeName) : rawClassName;
|
|
2761
|
-
if (asChild === true) {
|
|
2762
|
-
if (typeof as === "string") {
|
|
2763
|
-
slotValidator.assertExclusive();
|
|
2764
|
-
} else {
|
|
2765
|
-
return renderAsChild(children, className, ref ?? null);
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2768
|
-
let finalDecoration = className ? applyAttributes("root", { className }, decoration, variantKeys) : decoration;
|
|
2769
|
-
finalDecoration = applyFilterProps(finalDecoration, filterFn, variantKeys);
|
|
2770
|
-
finalDecoration = applyRef(finalDecoration, ref ?? null);
|
|
2771
|
-
return renderNormally(definition, tag, finalDecoration, children);
|
|
2959
|
+
const bundle = buildRuntime(options);
|
|
2960
|
+
const Component = forwardRef2(function Component2(props, ref) {
|
|
2961
|
+
return render({ ...bundle, props, ref: ref ?? null });
|
|
2772
2962
|
});
|
|
2773
2963
|
applyDisplayName(Component, options.name);
|
|
2964
|
+
const defaultTag = bundle.runtime.options.defaultTag;
|
|
2774
2965
|
if (typeof defaultTag === "string") {
|
|
2775
2966
|
Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: defaultTag });
|
|
2776
2967
|
}
|