praxis-kit 4.0.3 → 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 +14 -17
- package/dist/{chunk-DRGZ4ZI2.js → chunk-LA6WGQA6.js} +963 -633
- package/dist/contract/index.d.ts +39 -27
- package/dist/lit/index.d.ts +42 -30
- package/dist/lit/index.js +649 -413
- package/dist/preact/index.d.ts +45 -31
- package/dist/preact/index.js +1004 -684
- package/dist/react/index.d.ts +24 -11
- package/dist/react/index.js +21 -143
- package/dist/react/legacy.d.ts +3 -3
- package/dist/react/legacy.js +28 -147
- package/dist/{merge-refs-B0YcfdtP.d.ts → react-options-XrRof248.d.ts} +156 -100
- package/dist/solid/index.d.ts +45 -31
- package/dist/solid/index.js +517 -296
- package/dist/svelte/index.d.ts +55 -34
- package/dist/svelte/index.js +500 -296
- package/dist/tailwind/index.d.ts +29 -22
- package/dist/vite-plugin/index.d.ts +10 -12
- package/dist/vue/index.d.ts +45 -31
- package/dist/vue/index.js +893 -692
- package/dist/web/index.d.ts +43 -31
- package/dist/web/index.js +648 -406
- package/package.json +4 -4
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
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function* values(object) {
|
|
151
|
-
for (const [, value] of entries(object)) {
|
|
152
|
-
yield value;
|
|
153
|
-
}
|
|
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;
|
|
154
46
|
}
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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;
|
|
159
55
|
}
|
|
160
|
-
return
|
|
56
|
+
return void 0;
|
|
161
57
|
}
|
|
162
|
-
function
|
|
163
|
-
|
|
164
|
-
|
|
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
|
+
};
|
|
165
65
|
}
|
|
66
|
+
const [child, ...tags] = args;
|
|
67
|
+
const set2 = new Set(tags);
|
|
68
|
+
const tag = getTag(child);
|
|
69
|
+
return tag !== void 0 && set2.has(tag);
|
|
166
70
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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);
|
|
171
78
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
callback(value);
|
|
175
|
-
}
|
|
79
|
+
function invariant(condition, message) {
|
|
80
|
+
if (!condition) panic(message);
|
|
176
81
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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,62 +438,243 @@ 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;
|
|
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);
|
|
510
455
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (
|
|
515
|
-
if (
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
return
|
|
456
|
+
|
|
457
|
+
// ../../lib/contract/src/aria/aria-role-policy.ts
|
|
458
|
+
function getImplicitRole(tag, props) {
|
|
459
|
+
if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
|
|
460
|
+
if (tag === "input") return getInputImplicitRole(props?.type);
|
|
461
|
+
if (tag === "img") return props?.alt === "" ? "none" : "img";
|
|
462
|
+
if (tag === "section" || tag === "form") {
|
|
463
|
+
return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
|
|
519
464
|
}
|
|
520
465
|
return void 0;
|
|
521
466
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
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
|
+
}
|
|
529
493
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
+
};
|
|
534
670
|
}
|
|
535
671
|
|
|
536
|
-
// ../../lib/
|
|
537
|
-
function
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
|
|
543
|
-
}
|
|
544
|
-
return void 0;
|
|
672
|
+
// ../../lib/primitive/src/utils/merge-props.ts
|
|
673
|
+
function mergeProps(defaultProps, props) {
|
|
674
|
+
return {
|
|
675
|
+
...defaultProps ?? {},
|
|
676
|
+
...props
|
|
677
|
+
};
|
|
545
678
|
}
|
|
546
679
|
|
|
547
680
|
// ../../lib/contract/src/strict/invariant-base.ts
|
|
@@ -790,18 +923,18 @@ var ContractDiagnostics = {
|
|
|
790
923
|
message: `${context}: "${ruleName}" must be ${position}, got index ${index}`
|
|
791
924
|
};
|
|
792
925
|
},
|
|
793
|
-
unknownVariantDim(component,
|
|
926
|
+
unknownVariantDim(component, label2, dim) {
|
|
794
927
|
return {
|
|
795
928
|
code: DiagnosticCode2.ContractUnknownVariantDim,
|
|
796
929
|
category: DiagnosticCategory2.Contract,
|
|
797
|
-
message: `${component}: ${
|
|
930
|
+
message: `${component}: ${label2} references unknown variant "${dim}".`
|
|
798
931
|
};
|
|
799
932
|
},
|
|
800
|
-
unknownVariantValue(component,
|
|
933
|
+
unknownVariantValue(component, label2, dim, value, valid) {
|
|
801
934
|
return {
|
|
802
935
|
code: DiagnosticCode2.ContractUnknownVariantValue,
|
|
803
936
|
category: DiagnosticCategory2.Contract,
|
|
804
|
-
message: `${component}: ${
|
|
937
|
+
message: `${component}: ${label2} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
|
|
805
938
|
};
|
|
806
939
|
},
|
|
807
940
|
unknownRecipeKey(component, key) {
|
|
@@ -1599,7 +1732,7 @@ function getTypeName(value) {
|
|
|
1599
1732
|
return primitive;
|
|
1600
1733
|
}
|
|
1601
1734
|
const name = value.constructor?.name;
|
|
1602
|
-
return
|
|
1735
|
+
return isString(name) && name !== "Object" ? name : "object";
|
|
1603
1736
|
}
|
|
1604
1737
|
|
|
1605
1738
|
// ../../lib/contract/src/children/normalize-child-rule.ts
|
|
@@ -1893,6 +2026,7 @@ function landmarkNameAdvisory(ctx) {
|
|
|
1893
2026
|
if (!ctx.implicitRole || !NAMED_LANDMARK_TAGS.has(ctx.tag)) return [];
|
|
1894
2027
|
return requireAccessibleName(ctx);
|
|
1895
2028
|
}
|
|
2029
|
+
var HTML_ARIA_RULES = [landmarkRoleRule, landmarkNameAdvisory];
|
|
1896
2030
|
|
|
1897
2031
|
// ../core/src/html/contracts.ts
|
|
1898
2032
|
import { warnDiagnostics } from "../_shared/diagnostics.js";
|
|
@@ -2068,38 +2202,396 @@ function getHtmlPropNormalizers(tag) {
|
|
|
2068
2202
|
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
2069
2203
|
}
|
|
2070
2204
|
|
|
2071
|
-
// ../../
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
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
|
+
};
|
|
2075
2247
|
|
|
2076
|
-
// ../../lib/styling/src/
|
|
2077
|
-
function
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
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])}`;
|
|
2095
2336
|
});
|
|
2096
|
-
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);
|
|
2097
2387
|
}
|
|
2388
|
+
return pipeline;
|
|
2098
2389
|
};
|
|
2099
2390
|
}
|
|
2100
2391
|
|
|
2101
|
-
// ../core/src/
|
|
2392
|
+
// ../core/src/options/resolve-factory-options.ts
|
|
2102
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);
|
|
2587
|
+
}
|
|
2588
|
+
};
|
|
2589
|
+
const runtimeObject = pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
|
|
2590
|
+
return runtimeObject;
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
// ../core/src/resolver/resolver.ts
|
|
2594
|
+
import { silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
|
|
2103
2595
|
function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
|
|
2104
2596
|
if (allowedAs.includes(tag)) return;
|
|
2105
2597
|
if (!diagnostics) return;
|
|
@@ -2107,33 +2599,49 @@ function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
|
|
|
2107
2599
|
diagnostics.error(ContractDiagnostics.allowedAsViolation(String(tag), allowedAs, component));
|
|
2108
2600
|
}
|
|
2109
2601
|
|
|
2110
|
-
// ../../lib/adapter-utils/src/
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
}
|
|
2116
|
-
|
|
2117
|
-
// ../../lib/adapter-utils/src/define-component.ts
|
|
2118
|
-
function defineContractComponent(options) {
|
|
2119
|
-
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 };
|
|
2120
2608
|
}
|
|
2121
2609
|
|
|
2122
|
-
// ../../lib/adapter-utils/src/build-engines.ts
|
|
2610
|
+
// ../../lib/adapter-utils/src/runtime/build-engines.ts
|
|
2123
2611
|
function buildEngines(diagnostics, childRules, context) {
|
|
2124
2612
|
return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
|
|
2125
2613
|
}
|
|
2126
2614
|
|
|
2127
|
-
// ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
|
|
2128
|
-
import { throwDiagnostics, silentDiagnostics as
|
|
2129
|
-
function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics =
|
|
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) {
|
|
2130
2618
|
return {
|
|
2131
2619
|
name: options.name ?? defaultName,
|
|
2132
2620
|
diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
|
|
2133
2621
|
};
|
|
2134
2622
|
}
|
|
2135
2623
|
|
|
2136
|
-
// ../../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
|
|
2137
2645
|
var SlotValidator = class extends InvariantBase {
|
|
2138
2646
|
#name;
|
|
2139
2647
|
#elementTerm;
|
|
@@ -2156,18 +2664,18 @@ var SlotValidator = class extends InvariantBase {
|
|
|
2156
2664
|
};
|
|
2157
2665
|
|
|
2158
2666
|
// ../../lib/adapter-utils/src/slot/policies.ts
|
|
2159
|
-
import { clsx } from "clsx";
|
|
2667
|
+
import { clsx as clsx3 } from "clsx";
|
|
2160
2668
|
function chainHandlers(childHandler, slotHandler) {
|
|
2161
2669
|
return (...args) => {
|
|
2162
2670
|
childHandler(...args);
|
|
2163
2671
|
const event = args[0];
|
|
2164
|
-
if (!(
|
|
2672
|
+
if (!(isObject(event) && "defaultPrevented" in event && event.defaultPrevented)) {
|
|
2165
2673
|
slotHandler(...args);
|
|
2166
2674
|
}
|
|
2167
2675
|
};
|
|
2168
2676
|
}
|
|
2169
2677
|
function mergeClassNames(slot, child) {
|
|
2170
|
-
return
|
|
2678
|
+
return clsx3(slot, child);
|
|
2171
2679
|
}
|
|
2172
2680
|
function mergeStyles(slot, child) {
|
|
2173
2681
|
if (!isPlainObject(slot) || !isPlainObject(child)) return child;
|
|
@@ -2199,449 +2707,261 @@ function applyMergePolicy(key, slotVal, childVal) {
|
|
|
2199
2707
|
return policyHandlers[classifyProp(key, slotVal, childVal)](slotVal, childVal);
|
|
2200
2708
|
}
|
|
2201
2709
|
|
|
2202
|
-
// ../../
|
|
2203
|
-
|
|
2204
|
-
return {
|
|
2205
|
-
identity: {
|
|
2206
|
-
id: name,
|
|
2207
|
-
name,
|
|
2208
|
-
tag
|
|
2209
|
-
},
|
|
2210
|
-
capabilities: {},
|
|
2211
|
-
metadata: {},
|
|
2212
|
-
diagnostics: []
|
|
2213
|
-
};
|
|
2214
|
-
}
|
|
2710
|
+
// ../../adapters/preact/src/render.tsx
|
|
2711
|
+
import { h as h2 } from "preact";
|
|
2215
2712
|
|
|
2216
|
-
// ../../
|
|
2217
|
-
|
|
2218
|
-
return Array.isArray(cls) ? cls.join(" ") : cls;
|
|
2219
|
-
}
|
|
2220
|
-
function mapVariantRecord(source, mapper) {
|
|
2221
|
-
return iterate.mapValues(
|
|
2222
|
-
source,
|
|
2223
|
-
(inner) => iterate.mapValues(inner, mapper)
|
|
2224
|
-
);
|
|
2225
|
-
}
|
|
2226
|
-
function buildVariantConfig(variants, presets, defaults, compounds) {
|
|
2227
|
-
return {
|
|
2228
|
-
variants: mapVariantRecord(variants ?? {}, flattenClassName),
|
|
2229
|
-
...presets !== void 0 && Object.keys(presets).length > 0 && { presets },
|
|
2230
|
-
...defaults !== void 0 && Object.keys(defaults).length > 0 && { defaults },
|
|
2231
|
-
...compounds !== void 0 && compounds.length > 0 && {
|
|
2232
|
-
compounds
|
|
2233
|
-
}
|
|
2234
|
-
};
|
|
2235
|
-
}
|
|
2713
|
+
// ../../adapters/preact/src/slot/Slot.tsx
|
|
2714
|
+
import { forwardRef } from "preact/compat";
|
|
2236
2715
|
|
|
2237
|
-
// ../../
|
|
2238
|
-
|
|
2239
|
-
const existing = decoration[nodeId] ?? {};
|
|
2240
|
-
const next = { ...existing.attributes };
|
|
2241
|
-
if (removedKeys !== void 0) {
|
|
2242
|
-
iterate.forEachSet(removedKeys, (key) => {
|
|
2243
|
-
delete next[key];
|
|
2244
|
-
});
|
|
2245
|
-
}
|
|
2246
|
-
Object.assign(next, incoming);
|
|
2247
|
-
const { attributes: _dropped, ...rest } = existing;
|
|
2248
|
-
const nextDecoration = Object.keys(next).length > 0 ? { ...rest, attributes: next } : rest;
|
|
2249
|
-
return { ...decoration, [nodeId]: nextDecoration };
|
|
2250
|
-
}
|
|
2716
|
+
// ../../adapters/preact/src/slot/applySlot.ts
|
|
2717
|
+
import { isValidElement as isValidElement3 } from "preact";
|
|
2251
2718
|
|
|
2252
|
-
// ../../
|
|
2253
|
-
|
|
2254
|
-
const dec = decoration[nodeId];
|
|
2255
|
-
return { ...dec?.attributes ?? {}, ...dec?.variants ?? {} };
|
|
2256
|
-
}
|
|
2719
|
+
// ../../adapters/preact/src/slot/extractSlottable.ts
|
|
2720
|
+
import { h, Fragment as Fragment2, isValidElement as isValidElement2 } from "preact";
|
|
2257
2721
|
|
|
2258
|
-
// ../../
|
|
2259
|
-
|
|
2260
|
-
return backend.render({ definition, tree, render });
|
|
2261
|
-
}
|
|
2722
|
+
// ../../adapters/preact/src/slot/predicates.ts
|
|
2723
|
+
import { isValidElement } from "preact";
|
|
2262
2724
|
|
|
2263
|
-
// ../../
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
const
|
|
2278
|
-
|
|
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"
|
|
2279
2749
|
);
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
const
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
// ../../runtime/core/src/build-render-context.ts
|
|
2293
|
-
function buildRenderContext(decoration = {}) {
|
|
2294
|
-
return { decoration: new Map(Object.entries(decoration)) };
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
// ../../lib/adapter-utils/src/resolve-compounds.ts
|
|
2298
|
-
function matchesCompound(active, compound) {
|
|
2299
|
-
const { class: _, ...conditions } = compound;
|
|
2300
|
-
return Object.entries(conditions).every(([key, expected]) => {
|
|
2301
|
-
const actual = active[key];
|
|
2302
|
-
return Array.isArray(expected) ? expected.includes(actual) : actual === expected;
|
|
2303
|
-
});
|
|
2304
|
-
}
|
|
2305
|
-
function resolveCompounds(active, compounds) {
|
|
2306
|
-
if (!compounds?.length) return [];
|
|
2307
|
-
const out = [];
|
|
2308
|
-
iterate.forEach(compounds, (compound) => {
|
|
2309
|
-
if (matchesCompound(active, compound)) {
|
|
2310
|
-
out.push(flattenClassName(compound.class));
|
|
2311
|
-
}
|
|
2312
|
-
});
|
|
2313
|
-
return out;
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
// ../../lib/adapter-utils/src/resolve-classes.ts
|
|
2317
|
-
function resolveClasses(decoration, variantConfig, variantDefaults, recipe, compounds, variantLookup) {
|
|
2318
|
-
const active = getActiveProps("root", decoration);
|
|
2319
|
-
if (variantLookup !== void 0 && recipe === void 0) {
|
|
2320
|
-
const activeVariants = {};
|
|
2321
|
-
iterate.forEachKey(variantConfig.variants, (key) => {
|
|
2322
|
-
const value = active[key];
|
|
2323
|
-
if (typeof value === "string") activeVariants[key] = value;
|
|
2324
|
-
});
|
|
2325
|
-
const lookupKey = buildPrecomputedKey(activeVariants);
|
|
2326
|
-
const precomputedValue = variantLookup[lookupKey];
|
|
2327
|
-
if (precomputedValue !== void 0) {
|
|
2328
|
-
return {
|
|
2329
|
-
variantClasses: precomputedValue !== "" ? [precomputedValue] : [],
|
|
2330
|
-
compoundClasses: []
|
|
2331
|
-
};
|
|
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);
|
|
2332
2762
|
}
|
|
2333
|
-
}
|
|
2334
|
-
const passInput = recipe !== void 0 ? { ...active, preset: recipe } : active;
|
|
2335
|
-
const { context } = createVariantPass(passInput, variantConfig).execute({ classes: [] });
|
|
2336
|
-
const variantClasses = context.classes;
|
|
2337
|
-
const presetOverrides = recipe !== void 0 ? variantConfig.presets?.[recipe] ?? {} : {};
|
|
2338
|
-
const resolvedValues = {
|
|
2339
|
-
...variantDefaults,
|
|
2340
|
-
...presetOverrides,
|
|
2341
|
-
...active
|
|
2342
2763
|
};
|
|
2343
|
-
const compoundClasses = resolveCompounds(resolvedValues, compounds);
|
|
2344
|
-
return { variantClasses, compoundClasses };
|
|
2345
2764
|
}
|
|
2346
2765
|
|
|
2347
|
-
// ../../
|
|
2348
|
-
function
|
|
2349
|
-
|
|
2350
|
-
|
|
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);
|
|
2351
2772
|
}
|
|
2352
|
-
|
|
2353
|
-
return {
|
|
2354
|
-
execute(decoration, recipe) {
|
|
2355
|
-
return resolveClasses(decoration, variantConfig, defaults, recipe, compounds, variantLookup);
|
|
2356
|
-
}
|
|
2357
|
-
};
|
|
2773
|
+
invariant(isValidElement3(children), "Slot: child must be a valid Preact element");
|
|
2774
|
+
return cloneSlotChild2({ child: children, slotProps, ref });
|
|
2358
2775
|
}
|
|
2359
2776
|
|
|
2360
|
-
// ../../
|
|
2361
|
-
|
|
2362
|
-
return classes.filter(Boolean).join(" ");
|
|
2363
|
-
}
|
|
2777
|
+
// ../../adapters/preact/src/slot/cloneSlotChild.ts
|
|
2778
|
+
import { cloneElement, Fragment as Fragment3 } from "preact";
|
|
2364
2779
|
|
|
2365
|
-
// ../../
|
|
2366
|
-
function
|
|
2367
|
-
|
|
2368
|
-
return attributes !== void 0 ? { ...rest, attributes } : rest;
|
|
2780
|
+
// ../../adapters/preact/src/slot/composeRefs.ts
|
|
2781
|
+
function mergeRefs(...refs) {
|
|
2782
|
+
return mergeRefsCore(...refs);
|
|
2369
2783
|
}
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
if (ariaEngine === void 0) return decoration;
|
|
2374
|
-
const dec = decoration["root"];
|
|
2375
|
-
if (dec?.attributes === void 0) return decoration;
|
|
2376
|
-
const result = ariaEngine.validate(tag, dec.attributes);
|
|
2377
|
-
const cleaned = result.props;
|
|
2378
|
-
return {
|
|
2379
|
-
...decoration,
|
|
2380
|
-
root: withAttributes(dec, Object.keys(cleaned).length > 0 ? cleaned : void 0)
|
|
2381
|
-
};
|
|
2784
|
+
function getChildRef(child) {
|
|
2785
|
+
const ref = child.ref;
|
|
2786
|
+
return ref ?? null;
|
|
2382
2787
|
}
|
|
2383
2788
|
|
|
2384
|
-
// ../../
|
|
2385
|
-
function
|
|
2386
|
-
|
|
2387
|
-
const
|
|
2388
|
-
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2391
|
-
);
|
|
2392
|
-
return {
|
|
2393
|
-
...decoration,
|
|
2394
|
-
root: withAttributes(dec, Object.keys(kept).length > 0 ? kept : void 0)
|
|
2395
|
-
};
|
|
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);
|
|
2396
2797
|
}
|
|
2397
2798
|
|
|
2398
|
-
// ../../
|
|
2399
|
-
function
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
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);
|
|
2403
2833
|
}
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
// ../../adapters/preact/src/backend/extract-decoration.ts
|
|
2409
|
-
function isStyleValue(v) {
|
|
2410
|
-
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);
|
|
2411
2838
|
}
|
|
2412
|
-
function
|
|
2413
|
-
return
|
|
2839
|
+
function isSingleElementArray(arr) {
|
|
2840
|
+
return arr.length === 1;
|
|
2414
2841
|
}
|
|
2415
|
-
function
|
|
2416
|
-
|
|
2417
|
-
|
|
2842
|
+
function resolveSlotChildren(children, normalized, validator) {
|
|
2843
|
+
warnDiscardedChildren(children, normalized, validator);
|
|
2844
|
+
if (isSingleElementArray(normalized)) {
|
|
2845
|
+
return normalized[0];
|
|
2418
2846
|
}
|
|
2847
|
+
if (normalized.length > 1 && normalized.some(isSlottableElement)) {
|
|
2848
|
+
return normalized;
|
|
2849
|
+
}
|
|
2850
|
+
validator.assertSingleChild(normalized.length);
|
|
2851
|
+
return null;
|
|
2419
2852
|
}
|
|
2420
|
-
function
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
}
|
|
2426
|
-
});
|
|
2427
|
-
return true;
|
|
2428
|
-
}
|
|
2429
|
-
function extractListener(key, value, listeners) {
|
|
2430
|
-
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();
|
|
2431
2858
|
return false;
|
|
2432
2859
|
}
|
|
2433
|
-
listeners[key] = value;
|
|
2434
2860
|
return true;
|
|
2435
2861
|
}
|
|
2436
|
-
function
|
|
2437
|
-
if (
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
const dec = {};
|
|
2449
|
-
iterate.forEachEntry(props, (key, value) => {
|
|
2450
|
-
if (key === "children" || key === "slot" || key === "ref") return;
|
|
2451
|
-
if (key === "style" && extractStyles(value, styles)) return;
|
|
2452
|
-
if (extractListener(key, value, listeners)) return;
|
|
2453
|
-
if (isAttributeValue(value)) {
|
|
2454
|
-
extractAttributeOrVariant(key, value, attributes, variants, variantKeys);
|
|
2455
|
-
}
|
|
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
|
|
2456
2874
|
});
|
|
2457
|
-
assignIfNotEmpty(dec, "attributes", attributes);
|
|
2458
|
-
assignIfNotEmpty(dec, "styles", styles);
|
|
2459
|
-
assignIfNotEmpty(dec, "listeners", listeners);
|
|
2460
|
-
assignIfNotEmpty(dec, "variants", variants);
|
|
2461
|
-
const ref = props.ref;
|
|
2462
|
-
if (ref !== void 0) {
|
|
2463
|
-
dec.ref = ref;
|
|
2464
|
-
}
|
|
2465
|
-
return dec;
|
|
2466
2875
|
}
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
// ../../adapters/preact/src/backend/build-props.ts
|
|
2475
|
-
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;
|
|
2476
2883
|
return {
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
...
|
|
2481
|
-
...
|
|
2884
|
+
...rest,
|
|
2885
|
+
className,
|
|
2886
|
+
ref,
|
|
2887
|
+
...children !== void 0 && { children },
|
|
2888
|
+
...isKnownAriaRole(role) && { role }
|
|
2482
2889
|
};
|
|
2483
2890
|
}
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
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
|
|
2509
2919
|
);
|
|
2510
|
-
return
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2513
|
-
// ../../adapters/preact/src/helpers/make-render-as-child.ts
|
|
2514
|
-
import { isValidElement } from "preact";
|
|
2515
|
-
function makeRenderAsChild(cloneSlotChild2) {
|
|
2516
|
-
return function renderAsChild(children, className, ref) {
|
|
2517
|
-
if (!isValidElement(children)) throw new Error("asChild requires a Preact element child");
|
|
2518
|
-
const slotProps = className ? { className } : {};
|
|
2519
|
-
return cloneSlotChild2({ child: children, slotProps, ref: ref ?? null });
|
|
2520
|
-
};
|
|
2920
|
+
return slotResult ?? renderIntrinsic(state, ref, runtime);
|
|
2521
2921
|
}
|
|
2522
2922
|
|
|
2523
2923
|
// ../../adapters/preact/src/normalize-children.ts
|
|
2524
|
-
import { isValidElement as
|
|
2924
|
+
import { isValidElement as isValidElement4 } from "preact";
|
|
2525
2925
|
function normalizeChildren(children) {
|
|
2526
|
-
if (
|
|
2527
|
-
if (Array.isArray(children)) return children.filter(
|
|
2926
|
+
if (isValidElement4(children)) return [children];
|
|
2927
|
+
if (Array.isArray(children)) return children.filter(isValidElement4);
|
|
2528
2928
|
return [];
|
|
2529
2929
|
}
|
|
2530
2930
|
|
|
2531
|
-
// ../../adapters/preact/src/
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
}
|
|
2538
|
-
function getChildRef(child) {
|
|
2539
|
-
const ref = child.ref;
|
|
2540
|
-
return ref ?? null;
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
|
-
// ../../adapters/preact/src/slot/cloneSlotChild.ts
|
|
2544
|
-
function cloneSlotChild({ child, slotProps, ref }) {
|
|
2545
|
-
const childProps = child.props;
|
|
2546
|
-
const isFragment = child.type === Fragment2;
|
|
2547
|
-
const childRef = isFragment ? null : getChildRef(child);
|
|
2548
|
-
const mergedRef = isFragment ? null : mergeRefs(ref, childRef);
|
|
2549
|
-
const merged = mergeSlotProps(slotProps, childProps);
|
|
2550
|
-
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
|
+
};
|
|
2551
2938
|
}
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
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;
|
|
2558
2955
|
}
|
|
2559
2956
|
|
|
2560
2957
|
// ../../adapters/preact/src/create-contract-component.ts
|
|
2561
|
-
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
2562
2958
|
function createContractComponent(options) {
|
|
2563
|
-
const
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2566
|
-
const definition = buildDefinition(displayName, defaultTag);
|
|
2567
|
-
const variantKeys = new Set(Object.keys(options.styling?.variants ?? {}));
|
|
2568
|
-
const domDefaults = options.defaults;
|
|
2569
|
-
const stylePipeline = buildStylePipeline(
|
|
2570
|
-
options.styling?.variants,
|
|
2571
|
-
options.styling?.presets,
|
|
2572
|
-
options.styling?.defaults ?? {},
|
|
2573
|
-
options.styling?.compounds,
|
|
2574
|
-
void 0
|
|
2575
|
-
);
|
|
2576
|
-
const base = options.styling?.base !== void 0 ? flattenClassName(options.styling.base) : void 0;
|
|
2577
|
-
const filterFn = options.filterProps;
|
|
2578
|
-
const allowedAs = options.enforcement?.allowedAs;
|
|
2579
|
-
const normalizeFn = options.normalize;
|
|
2580
|
-
const enforcementNormalizers = options.enforcement?.props;
|
|
2581
|
-
const classPlugin = options.styling?.plugin !== void 0 ? options.styling.plugin(
|
|
2582
|
-
options.styling,
|
|
2583
|
-
resolved.diagnostics
|
|
2584
|
-
) : void 0;
|
|
2585
|
-
const pluginKeys = classPlugin?.ownedKeys ?? EMPTY_SET;
|
|
2586
|
-
const { childrenEvaluator: explicitEvaluator } = buildEngines(
|
|
2587
|
-
resolved.diagnostics,
|
|
2588
|
-
options.enforcement?.children,
|
|
2589
|
-
displayName
|
|
2590
|
-
);
|
|
2591
|
-
const ariaEngine = options.enforcement !== void 0 ? new AriaPolicyEngine(resolved.diagnostics) : void 0;
|
|
2592
|
-
const slotValidator = new SlotValidator(displayName, resolved.diagnostics, "Preact element");
|
|
2593
|
-
const renderAsChild = makeRenderAsChild(cloneSlotChild);
|
|
2594
|
-
const Component = forwardRef(function Component2(props, ref) {
|
|
2595
|
-
const {
|
|
2596
|
-
as,
|
|
2597
|
-
asChild,
|
|
2598
|
-
children,
|
|
2599
|
-
className: callerClassName,
|
|
2600
|
-
recipe,
|
|
2601
|
-
...ownProps
|
|
2602
|
-
} = props;
|
|
2603
|
-
const tag = typeof as === "string" ? as : defaultTag;
|
|
2604
|
-
if (allowedAs !== void 0) enforceAllowedAs(tag, allowedAs, resolved.diagnostics, displayName);
|
|
2605
|
-
const rawBaseProps = domDefaults !== void 0 ? { ...domDefaults, ...ownProps } : ownProps;
|
|
2606
|
-
const normalizedProps = applyPropNormalizers(tag, rawBaseProps, enforcementNormalizers);
|
|
2607
|
-
const baseProps = normalizeFn !== void 0 ? normalizeFn(normalizedProps) : normalizedProps;
|
|
2608
|
-
const pluginProps = {};
|
|
2609
|
-
const propsForExtraction = pluginKeys.size > 0 ? Object.fromEntries(
|
|
2610
|
-
Object.entries(baseProps).filter(([k]) => {
|
|
2611
|
-
if (pluginKeys.has(k)) {
|
|
2612
|
-
pluginProps[k] = baseProps[k];
|
|
2613
|
-
return false;
|
|
2614
|
-
}
|
|
2615
|
-
return true;
|
|
2616
|
-
})
|
|
2617
|
-
) : baseProps;
|
|
2618
|
-
const rootDec = extractDecoration(propsForExtraction, variantKeys);
|
|
2619
|
-
const decoration = applyAria(
|
|
2620
|
-
Object.keys(rootDec).length > 0 ? { root: rootDec } : {},
|
|
2621
|
-
tag,
|
|
2622
|
-
ariaEngine
|
|
2623
|
-
);
|
|
2624
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2625
|
-
const childEval = explicitEvaluator ?? getHtmlChildrenEvaluator(tag);
|
|
2626
|
-
childEval?.evaluate(normalizeChildren(children));
|
|
2627
|
-
}
|
|
2628
|
-
const recipeName = typeof recipe === "string" ? recipe : void 0;
|
|
2629
|
-
const { variantClasses, compoundClasses } = stylePipeline ? stylePipeline.execute(decoration, recipeName) : { variantClasses: [], compoundClasses: [] };
|
|
2630
|
-
const rawClassName = joinClasses(base, ...variantClasses, ...compoundClasses, callerClassName);
|
|
2631
|
-
const className = classPlugin !== void 0 ? classPlugin.pipeline(tag, pluginProps, rawClassName, recipeName) : rawClassName;
|
|
2632
|
-
if (asChild === true) {
|
|
2633
|
-
if (typeof as === "string") {
|
|
2634
|
-
slotValidator.assertExclusive();
|
|
2635
|
-
} else {
|
|
2636
|
-
return renderAsChild(children, className, ref ?? null);
|
|
2637
|
-
}
|
|
2638
|
-
}
|
|
2639
|
-
let finalDecoration = className ? applyAttributes("root", { className }, decoration, variantKeys) : decoration;
|
|
2640
|
-
finalDecoration = applyFilterProps(finalDecoration, filterFn, variantKeys);
|
|
2641
|
-
finalDecoration = applyRef(finalDecoration, ref ?? null);
|
|
2642
|
-
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 });
|
|
2643
2962
|
});
|
|
2644
2963
|
applyDisplayName(Component, options.name);
|
|
2964
|
+
const defaultTag = bundle.runtime.options.defaultTag;
|
|
2645
2965
|
if (typeof defaultTag === "string") {
|
|
2646
2966
|
Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: defaultTag });
|
|
2647
2967
|
}
|