praxis-kit 4.0.3 → 4.1.1
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-R2RKHZNX.js} +968 -634
- package/dist/contract/index.d.ts +39 -27
- package/dist/lit/index.d.ts +42 -30
- package/dist/lit/index.js +653 -413
- package/dist/preact/index.d.ts +45 -31
- package/dist/preact/index.js +1009 -685
- 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 +521 -296
- package/dist/svelte/index.d.ts +55 -34
- package/dist/svelte/index.js +504 -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 +898 -693
- package/dist/web/index.d.ts +43 -31
- package/dist/web/index.js +652 -406
- package/package.json +3 -3
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,12 +2026,17 @@ 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";
|
|
1899
2033
|
function isOpenContent(...blockedTags) {
|
|
1900
2034
|
const set2 = new Set(blockedTags);
|
|
1901
|
-
return (child) =>
|
|
2035
|
+
return (child) => {
|
|
2036
|
+
if (!isObject(child) || !("type" in child)) return false;
|
|
2037
|
+
const tag = getTag(child);
|
|
2038
|
+
return tag === void 0 || !set2.has(tag);
|
|
2039
|
+
};
|
|
1902
2040
|
}
|
|
1903
2041
|
var METADATA_TAGS = ["script", "template"];
|
|
1904
2042
|
var metadataMatch = isTag(...METADATA_TAGS);
|
|
@@ -2068,38 +2206,396 @@ function getHtmlPropNormalizers(tag) {
|
|
|
2068
2206
|
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
2069
2207
|
}
|
|
2070
2208
|
|
|
2071
|
-
// ../../
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2209
|
+
// ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
|
|
2210
|
+
import { clsx as clsx2 } from "clsx";
|
|
2211
|
+
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
2212
|
+
var cx = clsx2;
|
|
2213
|
+
var cva = (base, config) => (props) => {
|
|
2214
|
+
var _config_compoundVariants;
|
|
2215
|
+
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);
|
|
2216
|
+
const { variants, defaultVariants } = config;
|
|
2217
|
+
const getVariantClassNames = Object.keys(variants).map((variant) => {
|
|
2218
|
+
const variantProp = props === null || props === void 0 ? void 0 : props[variant];
|
|
2219
|
+
const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
|
|
2220
|
+
if (variantProp === null) return null;
|
|
2221
|
+
const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
|
|
2222
|
+
return variants[variant][variantKey];
|
|
2223
|
+
});
|
|
2224
|
+
const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
|
|
2225
|
+
let [key, value] = param;
|
|
2226
|
+
if (value === void 0) {
|
|
2227
|
+
return acc;
|
|
2228
|
+
}
|
|
2229
|
+
acc[key] = value;
|
|
2230
|
+
return acc;
|
|
2231
|
+
}, {});
|
|
2232
|
+
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) => {
|
|
2233
|
+
let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
|
|
2234
|
+
return Object.entries(compoundVariantOptions).every((param2) => {
|
|
2235
|
+
let [key, value] = param2;
|
|
2236
|
+
return Array.isArray(value) ? value.includes({
|
|
2237
|
+
...defaultVariants,
|
|
2238
|
+
...propsWithoutUndefined
|
|
2239
|
+
}[key]) : {
|
|
2240
|
+
...defaultVariants,
|
|
2241
|
+
...propsWithoutUndefined
|
|
2242
|
+
}[key] === value;
|
|
2243
|
+
}) ? [
|
|
2244
|
+
...acc,
|
|
2245
|
+
cvClass,
|
|
2246
|
+
cvClassName
|
|
2247
|
+
] : acc;
|
|
2248
|
+
}, []);
|
|
2249
|
+
return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
2250
|
+
};
|
|
2075
2251
|
|
|
2076
|
-
// ../../lib/styling/src/
|
|
2077
|
-
function
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2252
|
+
// ../../lib/styling/src/cva.ts
|
|
2253
|
+
function cva2(base, config) {
|
|
2254
|
+
const fn = cva(base, config);
|
|
2255
|
+
return (props) => cn(fn(props));
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
// ../../lib/styling/src/static-class-resolver.ts
|
|
2259
|
+
var StaticClassResolver = class {
|
|
2260
|
+
#baseClass;
|
|
2261
|
+
#cache = /* @__PURE__ */ new Map();
|
|
2262
|
+
#resolveTag;
|
|
2263
|
+
constructor(baseClass, tagMap) {
|
|
2264
|
+
this.#baseClass = Array.isArray(baseClass) ? baseClass.join(" ") : baseClass;
|
|
2265
|
+
this.#resolveTag = tagMap ? (tag) => {
|
|
2266
|
+
const extra = tagMap[tag];
|
|
2267
|
+
if (!extra) return this.#baseClass;
|
|
2268
|
+
const extraStr = Array.isArray(extra) ? extra.join(" ") : extra;
|
|
2269
|
+
return `${this.#baseClass} ${extraStr}`;
|
|
2270
|
+
} : () => this.#baseClass;
|
|
2271
|
+
}
|
|
2272
|
+
resolve(tag, skipTagMap = false) {
|
|
2273
|
+
if (typeof tag !== "string" || skipTagMap) return this.#baseClass;
|
|
2274
|
+
const cached = this.#cache.get(tag);
|
|
2275
|
+
if (cached !== void 0) {
|
|
2276
|
+
this.#cache.delete(tag);
|
|
2277
|
+
this.#cache.set(tag, cached);
|
|
2278
|
+
return cached;
|
|
2279
|
+
}
|
|
2280
|
+
const result = this.#resolveTag(tag);
|
|
2281
|
+
this.#cache.set(tag, result);
|
|
2282
|
+
if (this.#cache.size > 200) {
|
|
2283
|
+
const lru = this.#cache.keys().next().value;
|
|
2284
|
+
if (lru !== void 0) this.#cache.delete(lru);
|
|
2285
|
+
}
|
|
2286
|
+
return result;
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
|
|
2290
|
+
// ../../lib/styling/src/variant-class-resolver.ts
|
|
2291
|
+
var VariantClassResolver = class _VariantClassResolver {
|
|
2292
|
+
#cvaFn;
|
|
2293
|
+
#recipeMap;
|
|
2294
|
+
#variantKeys;
|
|
2295
|
+
#precomputedClasses;
|
|
2296
|
+
#cache = /* @__PURE__ */ new Map();
|
|
2297
|
+
constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
|
|
2298
|
+
this.#cvaFn = cvaFn ?? null;
|
|
2299
|
+
this.#recipeMap = Object.freeze(recipeMap ?? {});
|
|
2300
|
+
this.#variantKeys = variantKeys ?? null;
|
|
2301
|
+
this.#precomputedClasses = precomputedClasses ?? null;
|
|
2302
|
+
}
|
|
2303
|
+
resolve({ props, recipe }) {
|
|
2304
|
+
const normalizedKey = recipe ?? "__none__";
|
|
2305
|
+
const cacheKey = this.#createCacheKey(props, normalizedKey);
|
|
2306
|
+
if (this.#precomputedClasses !== null) {
|
|
2307
|
+
const precomputed = this.#precomputedClasses[cacheKey];
|
|
2308
|
+
if (precomputed !== void 0) return precomputed;
|
|
2309
|
+
}
|
|
2310
|
+
const cached = this.#cache.get(cacheKey);
|
|
2311
|
+
if (cached !== void 0) {
|
|
2312
|
+
this.#cache.delete(cacheKey);
|
|
2313
|
+
this.#cache.set(cacheKey, cached);
|
|
2314
|
+
return cached;
|
|
2315
|
+
}
|
|
2316
|
+
const result = this.#compute(props, recipe);
|
|
2317
|
+
this.#cache.set(cacheKey, result);
|
|
2318
|
+
if (this.#cache.size > 1e3) {
|
|
2319
|
+
const lru = this.#cache.keys().next().value;
|
|
2320
|
+
if (lru !== void 0) this.#cache.delete(lru);
|
|
2321
|
+
}
|
|
2322
|
+
return result;
|
|
2323
|
+
}
|
|
2324
|
+
#compute(props, recipe) {
|
|
2325
|
+
if (!this.#cvaFn) return "";
|
|
2326
|
+
if (!recipe) return this.#cvaFn(props);
|
|
2327
|
+
const preset = this.#recipeMap[recipe];
|
|
2328
|
+
if (!preset) return this.#cvaFn(props);
|
|
2329
|
+
return this.#cvaFn({ ...preset, ...props });
|
|
2330
|
+
}
|
|
2331
|
+
// When variantKeys is provided, only those keys are included in the cache key — non-variant
|
|
2332
|
+
// props (className, id, etc.) produce identical CVA output and must not fragment the cache.
|
|
2333
|
+
// Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
|
|
2334
|
+
// String is built incrementally to avoid a parts[] array allocation on every render.
|
|
2335
|
+
#createCacheKey(props, recipe) {
|
|
2336
|
+
if (this.#variantKeys !== null) {
|
|
2337
|
+
let key2 = recipe;
|
|
2338
|
+
iterate.forEachSet(this.#variantKeys, (k) => {
|
|
2339
|
+
if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
2095
2340
|
});
|
|
2096
|
-
return
|
|
2341
|
+
return key2;
|
|
2342
|
+
}
|
|
2343
|
+
let key = recipe;
|
|
2344
|
+
iterate.forEach(Object.keys(props).sort(), (k) => {
|
|
2345
|
+
key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
2346
|
+
});
|
|
2347
|
+
return key;
|
|
2348
|
+
}
|
|
2349
|
+
static #serializeValue(value) {
|
|
2350
|
+
if (value === void 0) return "u";
|
|
2351
|
+
if (value === null) return "n";
|
|
2352
|
+
if (typeof value === "boolean") return `b:${value}`;
|
|
2353
|
+
if (typeof value === "string") return `s:${value}`;
|
|
2354
|
+
return `x:${String(value)}`;
|
|
2355
|
+
}
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2358
|
+
// ../../lib/styling/src/create-class-pipeline.ts
|
|
2359
|
+
function createClassPipeline(resolved) {
|
|
2360
|
+
const baseClass = resolved.baseClassName ?? "";
|
|
2361
|
+
const cvaFn = resolved.variants ? cva2("", {
|
|
2362
|
+
variants: resolved.variants,
|
|
2363
|
+
defaultVariants: resolved.defaultVariants,
|
|
2364
|
+
compoundVariants: resolved.compoundVariants
|
|
2365
|
+
}) : null;
|
|
2366
|
+
const variantKeys = resolved.variants ? new Set(Object.keys(resolved.variants)) : void 0;
|
|
2367
|
+
const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
|
|
2368
|
+
const variantResolver = new VariantClassResolver(
|
|
2369
|
+
cvaFn,
|
|
2370
|
+
resolved.recipeMap,
|
|
2371
|
+
variantKeys,
|
|
2372
|
+
resolved.precomputedClasses
|
|
2373
|
+
);
|
|
2374
|
+
return function resolveClasses(tag, props, className, recipe) {
|
|
2375
|
+
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
2376
|
+
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
2377
|
+
if (!className)
|
|
2378
|
+
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
2379
|
+
return cn(staticClasses, variantClasses, className);
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
// ../../lib/pipeline-kit/src/factory/define-pipeline.ts
|
|
2384
|
+
function definePipeline(factory) {
|
|
2385
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
2386
|
+
return (resolved) => {
|
|
2387
|
+
let pipeline = cache.get(resolved);
|
|
2388
|
+
if (!pipeline) {
|
|
2389
|
+
pipeline = factory(resolved);
|
|
2390
|
+
cache.set(resolved, pipeline);
|
|
2097
2391
|
}
|
|
2392
|
+
return pipeline;
|
|
2098
2393
|
};
|
|
2099
2394
|
}
|
|
2100
2395
|
|
|
2101
|
-
// ../core/src/
|
|
2396
|
+
// ../core/src/options/resolve-factory-options.ts
|
|
2102
2397
|
import { silentDiagnostics } from "../_shared/diagnostics.js";
|
|
2398
|
+
var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
|
|
2399
|
+
function composeNormalizers(normalizers, fn) {
|
|
2400
|
+
if (!normalizers?.length) return fn;
|
|
2401
|
+
return ((props) => {
|
|
2402
|
+
const patched = normalizers.reduce(
|
|
2403
|
+
(acc, normalizer) => ({ ...acc, ...normalizer(acc) }),
|
|
2404
|
+
props
|
|
2405
|
+
);
|
|
2406
|
+
return fn ? fn(patched) : patched;
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
function whenDefined(key, value) {
|
|
2410
|
+
return value === void 0 ? {} : { [key]: value };
|
|
2411
|
+
}
|
|
2412
|
+
function resolveFactoryOptions(options = {}) {
|
|
2413
|
+
const { styling, enforcement } = options;
|
|
2414
|
+
const composedNormalizeFn = composeNormalizers(enforcement?.props, options.normalize);
|
|
2415
|
+
const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
|
|
2416
|
+
return Object.freeze({
|
|
2417
|
+
defaultTag: options.tag ?? "div",
|
|
2418
|
+
diagnostics: enforcement?.diagnostics ?? silentDiagnostics,
|
|
2419
|
+
variantKeys,
|
|
2420
|
+
...whenDefined("displayName", options.name),
|
|
2421
|
+
...whenDefined("defaultProps", options.defaults),
|
|
2422
|
+
...whenDefined("baseClassName", styling?.base),
|
|
2423
|
+
...whenDefined("tagMap", styling?.tags),
|
|
2424
|
+
...whenDefined("recipeMap", styling?.presets),
|
|
2425
|
+
...whenDefined("variants", styling?.variants),
|
|
2426
|
+
...whenDefined("defaultVariants", styling?.defaults),
|
|
2427
|
+
...whenDefined("compoundVariants", styling?.compounds),
|
|
2428
|
+
...whenDefined("normalizeFn", composedNormalizeFn),
|
|
2429
|
+
...whenDefined("ariaRules", enforcement?.aria),
|
|
2430
|
+
...whenDefined("childRules", enforcement?.children),
|
|
2431
|
+
...whenDefined("allowedAs", enforcement?.allowedAs),
|
|
2432
|
+
...whenDefined("precomputedClasses", styling?.precomputedClasses)
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
// ../core/src/options/validate-factory-options.ts
|
|
2437
|
+
function validateFactoryOptions(resolved, diagnostics) {
|
|
2438
|
+
if (!diagnostics.active) return;
|
|
2439
|
+
const name = resolved.displayName ?? "Component";
|
|
2440
|
+
const { variants } = resolved;
|
|
2441
|
+
const checkSelection = (label2, selection) => {
|
|
2442
|
+
iterate.forEachEntry(selection, (dim, value) => {
|
|
2443
|
+
if (value === void 0 || value === null) return;
|
|
2444
|
+
if (!variants || !Object.hasOwn(variants, dim)) {
|
|
2445
|
+
diagnostics.error(ContractDiagnostics.unknownVariantDim(name, label2, dim));
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2448
|
+
const states = variants[dim];
|
|
2449
|
+
const stateKey = String(value);
|
|
2450
|
+
if (!Object.hasOwn(states, stateKey)) {
|
|
2451
|
+
diagnostics.error(
|
|
2452
|
+
ContractDiagnostics.unknownVariantValue(name, label2, dim, stateKey, Object.keys(states))
|
|
2453
|
+
);
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
2456
|
+
};
|
|
2457
|
+
const { recipeMap } = resolved;
|
|
2458
|
+
if (recipeMap) {
|
|
2459
|
+
iterate.forEachEntry(recipeMap, (recipeKey, selection) => {
|
|
2460
|
+
checkSelection(`preset "${recipeKey}"`, selection);
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
// ../core/src/options/validate-render-props.ts
|
|
2467
|
+
function label(name) {
|
|
2468
|
+
return name ? `[${name}]` : "[createContractComponent]";
|
|
2469
|
+
}
|
|
2470
|
+
function validateRenderProps(diagnostics, options, props, recipeKey) {
|
|
2471
|
+
const { recipeMap, variants, displayName } = options;
|
|
2472
|
+
const tag = label(displayName);
|
|
2473
|
+
if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
|
|
2474
|
+
diagnostics.error(ContractDiagnostics.unknownRecipeKey(tag, recipeKey));
|
|
2475
|
+
}
|
|
2476
|
+
if (variants) {
|
|
2477
|
+
iterate.forEachKey(variants, (key) => {
|
|
2478
|
+
if (!Object.hasOwn(props, key)) return;
|
|
2479
|
+
const value = props[key];
|
|
2480
|
+
if (value === void 0 || value === null) return;
|
|
2481
|
+
const dim = variants[key];
|
|
2482
|
+
if (dim && !Object.hasOwn(dim, String(value))) {
|
|
2483
|
+
diagnostics.error(ContractDiagnostics.invalidVariantValue(tag, key, String(value)));
|
|
2484
|
+
}
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
// ../core/src/factory/plugin-invariants.ts
|
|
2490
|
+
import { throwDiagnostics } from "../_shared/diagnostics.js";
|
|
2491
|
+
|
|
2492
|
+
// ../core/src/factory/plugin-diagnostics.ts
|
|
2493
|
+
import { DiagnosticCategory as DiagnosticCategory5, DiagnosticCode as DiagnosticCode5 } from "../_shared/diagnostics.js";
|
|
2494
|
+
var PluginDiagnostics = {
|
|
2495
|
+
invalidShape(received) {
|
|
2496
|
+
const got = received === null ? "null" : typeof received;
|
|
2497
|
+
return {
|
|
2498
|
+
code: DiagnosticCode5.PluginInvalidShape,
|
|
2499
|
+
category: DiagnosticCategory5.Internal,
|
|
2500
|
+
message: `[praxis-kit] Plugin factory must return an object with a 'pipeline' function. Got: ${got}.`
|
|
2501
|
+
};
|
|
2502
|
+
},
|
|
2503
|
+
pipelineReturnType(received) {
|
|
2504
|
+
const got = received === null ? "null" : Array.isArray(received) ? "array" : typeof received;
|
|
2505
|
+
return {
|
|
2506
|
+
code: DiagnosticCode5.PluginPipelineReturnType,
|
|
2507
|
+
category: DiagnosticCategory5.Internal,
|
|
2508
|
+
message: `[praxis-kit] Plugin pipeline must return a string. Got: ${got}.`
|
|
2509
|
+
};
|
|
2510
|
+
}
|
|
2511
|
+
};
|
|
2512
|
+
|
|
2513
|
+
// ../core/src/factory/plugin-invariants.ts
|
|
2514
|
+
function assertPluginShape(result) {
|
|
2515
|
+
if (result === null || typeof result !== "object")
|
|
2516
|
+
throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
|
|
2517
|
+
const plugin = result;
|
|
2518
|
+
if (typeof plugin.pipeline !== "function")
|
|
2519
|
+
throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
|
|
2520
|
+
}
|
|
2521
|
+
function guardPipeline(pipeline) {
|
|
2522
|
+
if (process.env.NODE_ENV === "production") return pipeline;
|
|
2523
|
+
return function guardedPipeline(tag, props, className, recipe) {
|
|
2524
|
+
const result = pipeline(tag, props, className, recipe);
|
|
2525
|
+
if (typeof result !== "string")
|
|
2526
|
+
throwDiagnostics.error(PluginDiagnostics.pipelineReturnType(result));
|
|
2527
|
+
return result;
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
// ../core/src/factory/create-polymorphic2.ts
|
|
2532
|
+
var createTagPipeline = (resolved) => makeResolveTag(resolved.defaultTag);
|
|
2533
|
+
var createPropsPipeline = (resolved) => (props) => mergeProps(resolved.defaultProps, props);
|
|
2534
|
+
var createHtmlPropNormalizersPipeline = () => getHtmlPropNormalizers;
|
|
2535
|
+
var createHtmlChildrenEvaluatorPipeline = () => getHtmlChildrenEvaluator;
|
|
2536
|
+
var createStylingClassPipeline = (resolved) => createClassPipeline(resolved);
|
|
2537
|
+
function resolveAriaRules(resolved) {
|
|
2538
|
+
return [.../* @__PURE__ */ new Set([...HTML_ARIA_RULES, ...resolved.ariaRules ?? []])];
|
|
2539
|
+
}
|
|
2540
|
+
var createAriaPipeline = (resolved) => {
|
|
2541
|
+
const rules = resolveAriaRules(resolved);
|
|
2542
|
+
const engine = new AriaPolicyEngine(resolved.diagnostics, rules.length ? { rules } : void 0);
|
|
2543
|
+
return (tag, props) => engine.validate(tag, props);
|
|
2544
|
+
};
|
|
2545
|
+
var memoizedTagPipeline = definePipeline(createTagPipeline);
|
|
2546
|
+
var memoizedPropsPipeline = definePipeline(createPropsPipeline);
|
|
2547
|
+
var memoizedHtmlPropNormalizersPipeline = definePipeline(createHtmlPropNormalizersPipeline);
|
|
2548
|
+
var memoizedHtmlChildrenEvaluatorPipeline = definePipeline(createHtmlChildrenEvaluatorPipeline);
|
|
2549
|
+
var memoizedClassPipeline = definePipeline(createStylingClassPipeline);
|
|
2550
|
+
var memoizedAriaPipeline = definePipeline(createAriaPipeline);
|
|
2551
|
+
function resolveAriaPassthrough(_tag, props) {
|
|
2552
|
+
return { props };
|
|
2553
|
+
}
|
|
2554
|
+
function resolveClassPlugin(factory, resolved, diagnostics) {
|
|
2555
|
+
if (!factory) return { pluginResult: void 0, classPipeline: memoizedClassPipeline(resolved) };
|
|
2556
|
+
const pluginResult = factory(resolved, diagnostics);
|
|
2557
|
+
assertPluginShape(pluginResult);
|
|
2558
|
+
return { pluginResult, classPipeline: guardPipeline(pluginResult.pipeline) };
|
|
2559
|
+
}
|
|
2560
|
+
function createPolymorphic2(options = {}) {
|
|
2561
|
+
const baseResolved = resolveFactoryOptions(options);
|
|
2562
|
+
const anyBaseResolved = baseResolved;
|
|
2563
|
+
const resolved = Object.freeze({
|
|
2564
|
+
...baseResolved,
|
|
2565
|
+
htmlPropNormalizersFn: memoizedHtmlPropNormalizersPipeline(anyBaseResolved),
|
|
2566
|
+
htmlChildrenEvaluatorFn: memoizedHtmlChildrenEvaluatorPipeline(anyBaseResolved)
|
|
2567
|
+
});
|
|
2568
|
+
const anyResolved = resolved;
|
|
2569
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2570
|
+
validateFactoryOptions(resolved, resolved.diagnostics);
|
|
2571
|
+
}
|
|
2572
|
+
const { pluginResult, classPipeline } = resolveClassPlugin(
|
|
2573
|
+
options.styling?.plugin,
|
|
2574
|
+
anyResolved,
|
|
2575
|
+
resolved.diagnostics
|
|
2576
|
+
);
|
|
2577
|
+
const resolveTag2 = memoizedTagPipeline(anyResolved);
|
|
2578
|
+
const resolveProps = memoizedPropsPipeline(anyResolved);
|
|
2579
|
+
const resolveAriaFn = options.enforcement !== void 0 ? memoizedAriaPipeline(anyResolved) : resolveAriaPassthrough;
|
|
2580
|
+
const methods = {
|
|
2581
|
+
resolveTag: resolveTag2,
|
|
2582
|
+
resolveProps,
|
|
2583
|
+
resolveClasses(tag, props, className, recipe) {
|
|
2584
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2585
|
+
validateRenderProps(resolved.diagnostics, resolved, props, recipe);
|
|
2586
|
+
}
|
|
2587
|
+
return classPipeline(tag, props, className, recipe);
|
|
2588
|
+
},
|
|
2589
|
+
resolveAria(tag, props) {
|
|
2590
|
+
return resolveAriaFn(tag, props);
|
|
2591
|
+
}
|
|
2592
|
+
};
|
|
2593
|
+
const runtimeObject = pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
|
|
2594
|
+
return runtimeObject;
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
// ../core/src/resolver/resolver.ts
|
|
2598
|
+
import { silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
|
|
2103
2599
|
function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
|
|
2104
2600
|
if (allowedAs.includes(tag)) return;
|
|
2105
2601
|
if (!diagnostics) return;
|
|
@@ -2107,33 +2603,49 @@ function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
|
|
|
2107
2603
|
diagnostics.error(ContractDiagnostics.allowedAsViolation(String(tag), allowedAs, component));
|
|
2108
2604
|
}
|
|
2109
2605
|
|
|
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);
|
|
2606
|
+
// ../../lib/adapter-utils/src/runtime/build-core-runtime.ts
|
|
2607
|
+
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
2608
|
+
function buildCoreRuntime(normalized) {
|
|
2609
|
+
const runtime = createPolymorphic2(normalized);
|
|
2610
|
+
const ownedKeys = "classPlugin" in runtime ? runtime.classPlugin.ownedKeys ?? EMPTY_SET : EMPTY_SET;
|
|
2611
|
+
return { runtime, ownedKeys };
|
|
2120
2612
|
}
|
|
2121
2613
|
|
|
2122
|
-
// ../../lib/adapter-utils/src/build-engines.ts
|
|
2614
|
+
// ../../lib/adapter-utils/src/runtime/build-engines.ts
|
|
2123
2615
|
function buildEngines(diagnostics, childRules, context) {
|
|
2124
2616
|
return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
|
|
2125
2617
|
}
|
|
2126
2618
|
|
|
2127
|
-
// ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
|
|
2128
|
-
import { throwDiagnostics, silentDiagnostics as
|
|
2129
|
-
function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics =
|
|
2619
|
+
// ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
|
|
2620
|
+
import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3 } from "../_shared/diagnostics.js";
|
|
2621
|
+
function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
|
|
2130
2622
|
return {
|
|
2131
2623
|
name: options.name ?? defaultName,
|
|
2132
2624
|
diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
|
|
2133
2625
|
};
|
|
2134
2626
|
}
|
|
2135
2627
|
|
|
2136
|
-
// ../../lib/adapter-utils/src/
|
|
2628
|
+
// ../../lib/adapter-utils/src/props/apply-filter.ts
|
|
2629
|
+
function applyFilter(props, filterProps, variantKeys) {
|
|
2630
|
+
const out = {};
|
|
2631
|
+
iterate.forEachEntry(props, (k) => {
|
|
2632
|
+
if (!Object.hasOwn(props, k)) return;
|
|
2633
|
+
if (filterProps(k, variantKeys)) return;
|
|
2634
|
+
out[k] = props[k];
|
|
2635
|
+
});
|
|
2636
|
+
return out;
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
// ../../lib/adapter-utils/src/props/compose-filter.ts
|
|
2640
|
+
function composeFilter(ownedKeys, filterProps) {
|
|
2641
|
+
const defaultFilter = (key, variantKeys) => variantKeys.has(key) || ownedKeys.has(key);
|
|
2642
|
+
if (!filterProps) {
|
|
2643
|
+
return defaultFilter;
|
|
2644
|
+
}
|
|
2645
|
+
return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
// ../../lib/adapter-utils/src/slot/slot-validator.ts
|
|
2137
2649
|
var SlotValidator = class extends InvariantBase {
|
|
2138
2650
|
#name;
|
|
2139
2651
|
#elementTerm;
|
|
@@ -2156,18 +2668,18 @@ var SlotValidator = class extends InvariantBase {
|
|
|
2156
2668
|
};
|
|
2157
2669
|
|
|
2158
2670
|
// ../../lib/adapter-utils/src/slot/policies.ts
|
|
2159
|
-
import { clsx } from "clsx";
|
|
2671
|
+
import { clsx as clsx3 } from "clsx";
|
|
2160
2672
|
function chainHandlers(childHandler, slotHandler) {
|
|
2161
2673
|
return (...args) => {
|
|
2162
2674
|
childHandler(...args);
|
|
2163
2675
|
const event = args[0];
|
|
2164
|
-
if (!(
|
|
2676
|
+
if (!(isObject(event) && "defaultPrevented" in event && event.defaultPrevented)) {
|
|
2165
2677
|
slotHandler(...args);
|
|
2166
2678
|
}
|
|
2167
2679
|
};
|
|
2168
2680
|
}
|
|
2169
2681
|
function mergeClassNames(slot, child) {
|
|
2170
|
-
return
|
|
2682
|
+
return clsx3(slot, child);
|
|
2171
2683
|
}
|
|
2172
2684
|
function mergeStyles(slot, child) {
|
|
2173
2685
|
if (!isPlainObject(slot) || !isPlainObject(child)) return child;
|
|
@@ -2199,449 +2711,261 @@ function applyMergePolicy(key, slotVal, childVal) {
|
|
|
2199
2711
|
return policyHandlers[classifyProp(key, slotVal, childVal)](slotVal, childVal);
|
|
2200
2712
|
}
|
|
2201
2713
|
|
|
2202
|
-
// ../../
|
|
2203
|
-
|
|
2204
|
-
return {
|
|
2205
|
-
identity: {
|
|
2206
|
-
id: name,
|
|
2207
|
-
name,
|
|
2208
|
-
tag
|
|
2209
|
-
},
|
|
2210
|
-
capabilities: {},
|
|
2211
|
-
metadata: {},
|
|
2212
|
-
diagnostics: []
|
|
2213
|
-
};
|
|
2214
|
-
}
|
|
2714
|
+
// ../../adapters/preact/src/render.tsx
|
|
2715
|
+
import { h as h2 } from "preact";
|
|
2215
2716
|
|
|
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
|
-
}
|
|
2717
|
+
// ../../adapters/preact/src/slot/Slot.tsx
|
|
2718
|
+
import { forwardRef } from "preact/compat";
|
|
2236
2719
|
|
|
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
|
-
}
|
|
2720
|
+
// ../../adapters/preact/src/slot/applySlot.ts
|
|
2721
|
+
import { isValidElement as isValidElement3 } from "preact";
|
|
2251
2722
|
|
|
2252
|
-
// ../../
|
|
2253
|
-
|
|
2254
|
-
const dec = decoration[nodeId];
|
|
2255
|
-
return { ...dec?.attributes ?? {}, ...dec?.variants ?? {} };
|
|
2256
|
-
}
|
|
2723
|
+
// ../../adapters/preact/src/slot/extractSlottable.ts
|
|
2724
|
+
import { h, Fragment as Fragment2, isValidElement as isValidElement2 } from "preact";
|
|
2257
2725
|
|
|
2258
|
-
// ../../
|
|
2259
|
-
|
|
2260
|
-
return backend.render({ definition, tree, render });
|
|
2261
|
-
}
|
|
2726
|
+
// ../../adapters/preact/src/slot/predicates.ts
|
|
2727
|
+
import { isValidElement } from "preact";
|
|
2262
2728
|
|
|
2263
|
-
// ../../
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
const
|
|
2278
|
-
|
|
2729
|
+
// ../../adapters/preact/src/slot/Slottable.tsx
|
|
2730
|
+
import { Fragment } from "preact";
|
|
2731
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2732
|
+
function Slottable({ children }) {
|
|
2733
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
// ../../adapters/preact/src/slot/predicates.ts
|
|
2737
|
+
function isSlottableElement(value) {
|
|
2738
|
+
return isValidElement(value) && value.type === Slottable;
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
// ../../adapters/preact/src/slot/extractSlottable.ts
|
|
2742
|
+
function extractSlottable(children) {
|
|
2743
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
2744
|
+
const slottables = childrenArray.filter(isSlottableElement);
|
|
2745
|
+
invariant(slottables.length <= 1, "Slot: multiple Slottable children are not allowed");
|
|
2746
|
+
if (slottables.length === 0) return null;
|
|
2747
|
+
const [slottable] = slottables;
|
|
2748
|
+
invariant(slottable, "Missing Slottable element");
|
|
2749
|
+
const child = slottable.props.children;
|
|
2750
|
+
invariant(
|
|
2751
|
+
child !== null && child !== void 0,
|
|
2752
|
+
"Slottable expects exactly one Preact element child, received null"
|
|
2279
2753
|
);
|
|
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
|
-
};
|
|
2754
|
+
invariant(
|
|
2755
|
+
typeof child !== "string" && typeof child !== "number",
|
|
2756
|
+
"Slottable expects exactly one Preact element child, received text content"
|
|
2757
|
+
);
|
|
2758
|
+
invariant(isValidElement2(child), "Slottable expects exactly one Preact element child");
|
|
2759
|
+
invariant(child.type !== Fragment2, "Slottable child cannot be a Fragment");
|
|
2760
|
+
const index = childrenArray.indexOf(slottable);
|
|
2761
|
+
return {
|
|
2762
|
+
child,
|
|
2763
|
+
rebuild(merged) {
|
|
2764
|
+
const out = childrenArray.map((node, i) => i === index ? merged : node);
|
|
2765
|
+
return h(Fragment2, null, ...out);
|
|
2332
2766
|
}
|
|
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
2767
|
};
|
|
2343
|
-
const compoundClasses = resolveCompounds(resolvedValues, compounds);
|
|
2344
|
-
return { variantClasses, compoundClasses };
|
|
2345
2768
|
}
|
|
2346
2769
|
|
|
2347
|
-
// ../../
|
|
2348
|
-
function
|
|
2349
|
-
|
|
2350
|
-
|
|
2770
|
+
// ../../adapters/preact/src/slot/applySlot.ts
|
|
2771
|
+
function applySlot(children, slotProps, ref, cloneSlotChild2) {
|
|
2772
|
+
const extraction = extractSlottable(children);
|
|
2773
|
+
if (extraction) {
|
|
2774
|
+
const merged = cloneSlotChild2({ child: extraction.child, slotProps, ref });
|
|
2775
|
+
return extraction.rebuild(merged);
|
|
2351
2776
|
}
|
|
2352
|
-
|
|
2353
|
-
return {
|
|
2354
|
-
execute(decoration, recipe) {
|
|
2355
|
-
return resolveClasses(decoration, variantConfig, defaults, recipe, compounds, variantLookup);
|
|
2356
|
-
}
|
|
2357
|
-
};
|
|
2777
|
+
invariant(isValidElement3(children), "Slot: child must be a valid Preact element");
|
|
2778
|
+
return cloneSlotChild2({ child: children, slotProps, ref });
|
|
2358
2779
|
}
|
|
2359
2780
|
|
|
2360
|
-
// ../../
|
|
2361
|
-
|
|
2362
|
-
return classes.filter(Boolean).join(" ");
|
|
2363
|
-
}
|
|
2781
|
+
// ../../adapters/preact/src/slot/cloneSlotChild.ts
|
|
2782
|
+
import { cloneElement, Fragment as Fragment3 } from "preact";
|
|
2364
2783
|
|
|
2365
|
-
// ../../
|
|
2366
|
-
function
|
|
2367
|
-
|
|
2368
|
-
return attributes !== void 0 ? { ...rest, attributes } : rest;
|
|
2784
|
+
// ../../adapters/preact/src/slot/composeRefs.ts
|
|
2785
|
+
function mergeRefs(...refs) {
|
|
2786
|
+
return mergeRefsCore(...refs);
|
|
2369
2787
|
}
|
|
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
|
-
};
|
|
2788
|
+
function getChildRef(child) {
|
|
2789
|
+
const ref = child.ref;
|
|
2790
|
+
return ref ?? null;
|
|
2382
2791
|
}
|
|
2383
2792
|
|
|
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
|
-
};
|
|
2793
|
+
// ../../adapters/preact/src/slot/cloneSlotChild.ts
|
|
2794
|
+
function cloneSlotChild({ child, slotProps, ref }) {
|
|
2795
|
+
const childProps = child.props;
|
|
2796
|
+
const isFragment = child.type === Fragment3;
|
|
2797
|
+
const childRef = isFragment ? null : getChildRef(child);
|
|
2798
|
+
const mergedRef = isFragment ? null : mergeRefs(ref, childRef);
|
|
2799
|
+
const merged = mergeSlotProps(slotProps, childProps);
|
|
2800
|
+
return cloneElement(child, mergedRef !== null ? { ...merged, ref: mergedRef } : merged);
|
|
2396
2801
|
}
|
|
2397
2802
|
|
|
2398
|
-
// ../../
|
|
2399
|
-
function
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2803
|
+
// ../../adapters/preact/src/slot/Slot.tsx
|
|
2804
|
+
var Slot = forwardRef(function Slot2({ children, ...slotProps }, ref) {
|
|
2805
|
+
return applySlot(children, slotProps, ref ?? null, cloneSlotChild);
|
|
2806
|
+
});
|
|
2807
|
+
Object.assign(Slot, { displayName: SLOT_NAME });
|
|
2808
|
+
|
|
2809
|
+
// ../../adapters/preact/src/render.tsx
|
|
2810
|
+
function buildRenderState(tag, directives, props, className, children) {
|
|
2811
|
+
const state = { tag, directives, props, className };
|
|
2812
|
+
if (children !== void 0) state.children = children;
|
|
2813
|
+
return state;
|
|
2814
|
+
}
|
|
2815
|
+
function prepareRenderState(runtime, props, filterProps) {
|
|
2816
|
+
const { as, asChild, children, className, recipe, ...rest } = props;
|
|
2817
|
+
const tag = runtime.resolveTag(as);
|
|
2818
|
+
if (runtime.options.allowedAs !== void 0 && as !== void 0) {
|
|
2819
|
+
enforceAllowedAs(
|
|
2820
|
+
tag,
|
|
2821
|
+
runtime.options.allowedAs,
|
|
2822
|
+
runtime.options.diagnostics,
|
|
2823
|
+
runtime.options.displayName
|
|
2824
|
+
);
|
|
2825
|
+
}
|
|
2826
|
+
const mergedProps = runtime.resolveProps(rest);
|
|
2827
|
+
const htmlNormalizers = runtime.options.htmlPropNormalizersFn?.(tag);
|
|
2828
|
+
const htmlNormalizedProps = htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), mergedProps) : mergedProps;
|
|
2829
|
+
const normalizedProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(htmlNormalizedProps) : htmlNormalizedProps;
|
|
2830
|
+
const resolvedClass = runtime.resolveClasses(tag, normalizedProps, className, recipe);
|
|
2831
|
+
const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
|
|
2832
|
+
const directives = {
|
|
2833
|
+
...as !== void 0 && { as },
|
|
2834
|
+
...asChild !== void 0 && { asChild }
|
|
2835
|
+
};
|
|
2836
|
+
return buildRenderState(tag, directives, filteredProps, resolvedClass, children);
|
|
2403
2837
|
}
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
// ../../adapters/preact/src/backend/extract-decoration.ts
|
|
2409
|
-
function isStyleValue(v) {
|
|
2410
|
-
return isString(v) || isNumber(v);
|
|
2838
|
+
function warnDiscardedChildren(originalChildren, normalizedChildren, validator) {
|
|
2839
|
+
if (!Array.isArray(originalChildren)) return;
|
|
2840
|
+
const discarded = originalChildren.length - normalizedChildren.length;
|
|
2841
|
+
if (discarded > 0) validator.warnDiscardedChildren(discarded);
|
|
2411
2842
|
}
|
|
2412
|
-
function
|
|
2413
|
-
return
|
|
2843
|
+
function isSingleElementArray(arr) {
|
|
2844
|
+
return arr.length === 1;
|
|
2414
2845
|
}
|
|
2415
|
-
function
|
|
2416
|
-
|
|
2417
|
-
|
|
2846
|
+
function resolveSlotChildren(children, normalized, validator) {
|
|
2847
|
+
warnDiscardedChildren(children, normalized, validator);
|
|
2848
|
+
if (isSingleElementArray(normalized)) {
|
|
2849
|
+
return normalized[0];
|
|
2418
2850
|
}
|
|
2851
|
+
if (normalized.length > 1 && normalized.some(isSlottableElement)) {
|
|
2852
|
+
return normalized;
|
|
2853
|
+
}
|
|
2854
|
+
validator.assertSingleChild(normalized.length);
|
|
2855
|
+
return null;
|
|
2419
2856
|
}
|
|
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)) {
|
|
2857
|
+
function validateSlotDirectives(directives, validator) {
|
|
2858
|
+
const { as, asChild } = directives;
|
|
2859
|
+
if (!asChild) return false;
|
|
2860
|
+
if (as !== void 0) {
|
|
2861
|
+
validator.assertExclusive();
|
|
2431
2862
|
return false;
|
|
2432
2863
|
}
|
|
2433
|
-
listeners[key] = value;
|
|
2434
2864
|
return true;
|
|
2435
2865
|
}
|
|
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
|
-
}
|
|
2866
|
+
function resolveSlotRender(state, getNormalized, validator) {
|
|
2867
|
+
if (!validateSlotDirectives(state.directives, validator)) return null;
|
|
2868
|
+
const child = resolveSlotChildren(state.children, getNormalized(), validator);
|
|
2869
|
+
if (child === null) return null;
|
|
2870
|
+
return { child };
|
|
2871
|
+
}
|
|
2872
|
+
function renderResolvedSlot(slotComponent, state, slotRender, ref) {
|
|
2873
|
+
return h2(slotComponent, {
|
|
2874
|
+
...state.props,
|
|
2875
|
+
className: state.className,
|
|
2876
|
+
ref,
|
|
2877
|
+
children: slotRender.child
|
|
2456
2878
|
});
|
|
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
2879
|
}
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
// ../../adapters/preact/src/backend/build-props.ts
|
|
2475
|
-
function buildPropsFromDecoration(id, decoration) {
|
|
2880
|
+
function tryRenderAsChild(state, ref, slotComponent, getNormalized, validator) {
|
|
2881
|
+
const slotRender = resolveSlotRender(state, getNormalized, validator);
|
|
2882
|
+
if (slotRender === null) return null;
|
|
2883
|
+
return renderResolvedSlot(slotComponent, state, slotRender, ref);
|
|
2884
|
+
}
|
|
2885
|
+
function buildElementProps(props, className, ref, children) {
|
|
2886
|
+
const { role, ...rest } = props;
|
|
2476
2887
|
return {
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
...
|
|
2481
|
-
...
|
|
2888
|
+
...rest,
|
|
2889
|
+
className,
|
|
2890
|
+
ref,
|
|
2891
|
+
...children !== void 0 && { children },
|
|
2892
|
+
...isKnownAriaRole(role) && { role }
|
|
2482
2893
|
};
|
|
2483
2894
|
}
|
|
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
|
-
|
|
2895
|
+
function renderIntrinsic(state, ref, runtime) {
|
|
2896
|
+
const elementProps = buildElementProps(state.props, state.className, ref, state.children);
|
|
2897
|
+
const domProps = typeof state.tag === "string" ? runtime.resolveAria(state.tag, elementProps).props : elementProps;
|
|
2898
|
+
return h2(state.tag, domProps);
|
|
2899
|
+
}
|
|
2900
|
+
function render({
|
|
2901
|
+
runtime,
|
|
2902
|
+
props,
|
|
2903
|
+
ref,
|
|
2904
|
+
slotComponent,
|
|
2905
|
+
normalizeChildren: normalizeChildren2,
|
|
2906
|
+
filterProps,
|
|
2907
|
+
slotValidator,
|
|
2908
|
+
childrenEvaluator
|
|
2909
|
+
}) {
|
|
2910
|
+
const state = prepareRenderState(runtime, props, filterProps);
|
|
2911
|
+
let normalizedChildren;
|
|
2912
|
+
const getNormalizedChildren = () => normalizedChildren ??= normalizeChildren2(state.children);
|
|
2913
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2914
|
+
childrenEvaluator?.evaluate(getNormalizedChildren());
|
|
2915
|
+
runtime.options.htmlChildrenEvaluatorFn?.(state.tag)?.evaluate(getNormalizedChildren());
|
|
2916
|
+
}
|
|
2917
|
+
const slotResult = tryRenderAsChild(
|
|
2918
|
+
state,
|
|
2919
|
+
ref,
|
|
2920
|
+
slotComponent,
|
|
2921
|
+
getNormalizedChildren,
|
|
2922
|
+
slotValidator
|
|
2509
2923
|
);
|
|
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
|
-
};
|
|
2924
|
+
return slotResult ?? renderIntrinsic(state, ref, runtime);
|
|
2521
2925
|
}
|
|
2522
2926
|
|
|
2523
2927
|
// ../../adapters/preact/src/normalize-children.ts
|
|
2524
|
-
import { isValidElement as
|
|
2928
|
+
import { isValidElement as isValidElement4 } from "preact";
|
|
2525
2929
|
function normalizeChildren(children) {
|
|
2526
|
-
if (
|
|
2527
|
-
if (Array.isArray(children)) return children.filter(
|
|
2930
|
+
if (isValidElement4(children)) return [children];
|
|
2931
|
+
if (Array.isArray(children)) return children.filter(isValidElement4);
|
|
2528
2932
|
return [];
|
|
2529
2933
|
}
|
|
2530
2934
|
|
|
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);
|
|
2935
|
+
// ../../adapters/preact/src/build-runtime.ts
|
|
2936
|
+
function normalizeOptions(options) {
|
|
2937
|
+
return {
|
|
2938
|
+
...options,
|
|
2939
|
+
...resolveAdapterCommonOptions(options),
|
|
2940
|
+
slotComponent: options.slotComponent ?? Slot
|
|
2941
|
+
};
|
|
2551
2942
|
}
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2943
|
+
function buildRuntime(options) {
|
|
2944
|
+
const normalized = normalizeOptions(options);
|
|
2945
|
+
const { runtime, ownedKeys } = buildCoreRuntime(normalized);
|
|
2946
|
+
const { diagnostics, enforcement, filterProps: userFilter, name, slotComponent } = normalized;
|
|
2947
|
+
const { childrenEvaluator } = buildEngines(diagnostics, enforcement?.children, name);
|
|
2948
|
+
const filterProps = composeFilter(ownedKeys, userFilter);
|
|
2949
|
+
const slotValidator = new SlotValidator(name, diagnostics, "Preact element");
|
|
2950
|
+
const built = {
|
|
2951
|
+
runtime,
|
|
2952
|
+
filterProps,
|
|
2953
|
+
slotValidator,
|
|
2954
|
+
slotComponent,
|
|
2955
|
+
normalizeChildren,
|
|
2956
|
+
...childrenEvaluator !== void 0 && { childrenEvaluator }
|
|
2957
|
+
};
|
|
2958
|
+
return built;
|
|
2558
2959
|
}
|
|
2559
2960
|
|
|
2560
2961
|
// ../../adapters/preact/src/create-contract-component.ts
|
|
2561
|
-
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
2562
2962
|
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);
|
|
2963
|
+
const bundle = buildRuntime(options);
|
|
2964
|
+
const Component = forwardRef2(function Component2(props, ref) {
|
|
2965
|
+
return render({ ...bundle, props, ref: ref ?? null });
|
|
2643
2966
|
});
|
|
2644
2967
|
applyDisplayName(Component, options.name);
|
|
2968
|
+
const defaultTag = bundle.runtime.options.defaultTag;
|
|
2645
2969
|
if (typeof defaultTag === "string") {
|
|
2646
2970
|
Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: defaultTag });
|
|
2647
2971
|
}
|