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.
@@ -23,205 +23,47 @@ function isNull(value) {
23
23
  return value === null;
24
24
  }
25
25
 
26
- // ../../lib/adapter-utils/src/apply-display-name.ts
27
- function applyDisplayName(component, name) {
28
- Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
29
- }
30
-
31
- // ../../lib/primitive/src/tag/resolve-tag.ts
32
- function makeResolveTag(defaultTag) {
33
- return function tag(as) {
34
- return as ?? defaultTag;
35
- };
36
- }
37
-
38
- // ../../lib/primitive/src/utils/assert-never.ts
39
- function assertNever(value) {
40
- throw new Error(`Unexpected value: ${String(value)}`);
41
- }
42
-
43
- // ../../lib/primitive/src/utils/cn.ts
44
- import { clsx } from "clsx";
45
- function cn(...inputs) {
46
- return clsx(...inputs);
47
- }
48
-
49
- // ../../lib/primitive/src/utils/iterate.ts
50
- function find(iterable, callback) {
51
- for (const value of iterable) {
52
- const result = callback(value);
53
- if (result != null) {
54
- return result;
55
- }
56
- }
57
- return null;
58
- }
59
- function some(iterable, predicate) {
60
- for (const value of iterable) {
61
- if (predicate(value)) return true;
62
- }
63
- return false;
64
- }
65
- function every(iterable, predicate) {
66
- let index = 0;
67
- for (const value of iterable) {
68
- if (!predicate(value, index++)) {
69
- return false;
70
- }
71
- }
72
- return true;
73
- }
74
- function* filter(iterable, predicate) {
75
- let index = 0;
76
- for (const value of iterable) {
77
- if (predicate(value, index++)) {
78
- yield value;
79
- }
80
- }
81
- }
82
- function* map(iterable, callback) {
83
- let index = 0;
84
- for (const value of iterable) {
85
- yield callback(value, index++);
86
- }
87
- }
88
- function forEach(iterable, callback) {
89
- let index = 0;
90
- for (const value of iterable) {
91
- callback(value, index++);
92
- }
93
- }
94
- function reduce(iterable, initial, callback) {
95
- let accumulator = initial;
96
- let index = 0;
97
- for (const value of iterable) {
98
- accumulator = callback(accumulator, value, index++);
99
- }
100
- return accumulator;
101
- }
102
- function collect(iterable, callback) {
103
- const result = {};
104
- let index = 0;
105
- for (const value of iterable) {
106
- const entry = callback(value, index++);
107
- if (entry === null) {
108
- return null;
109
- }
110
- result[entry[0]] = entry[1];
111
- }
112
- return result;
113
- }
114
- function findLast(value, callback) {
115
- for (let index = value.length - 1; index >= 0; index--) {
116
- const result = callback(value[index], index);
117
- if (result != null) {
118
- return result;
119
- }
120
- }
121
- return null;
122
- }
123
- function* items(collection) {
124
- for (let i = 0; i < collection.length; i++) {
125
- const item = collection.item(i);
126
- if (item !== null) {
127
- yield item;
128
- }
129
- }
130
- }
131
- function nodeList(list) {
132
- return {
133
- *[Symbol.iterator]() {
134
- for (let i = 0; i < list.length; i++) {
135
- const node = list.item(i);
136
- if (node !== null) {
137
- yield node;
138
- }
139
- }
140
- }
141
- };
142
- }
143
- function mapEntries(m) {
144
- return m.entries();
145
- }
146
- function set(s) {
147
- return s.values();
148
- }
149
- function hasOwn(object, key) {
150
- return Object.hasOwn(object, key);
151
- }
152
- function* entries(object) {
153
- for (const key in object) {
154
- if (!hasOwn(object, key)) continue;
155
- yield [key, object[key]];
156
- }
157
- }
158
- function* keys(object) {
159
- for (const [key] of entries(object)) {
160
- yield key;
161
- }
162
- }
163
- function* values(object) {
164
- for (const [, value] of entries(object)) {
165
- yield value;
166
- }
167
- }
168
- function mapValues(object, callback) {
169
- const result = {};
170
- for (const [key, value] of entries(object)) {
171
- result[key] = callback(value, key);
172
- }
173
- return result;
174
- }
175
- function forEachEntry(object, callback) {
176
- for (const [key, value] of entries(object)) {
177
- callback(key, value);
178
- }
179
- }
180
- function forEachKey(object, callback) {
181
- for (const key of keys(object)) {
182
- callback(key);
26
+ // ../../lib/primitive/src/guards/children/is-tag.ts
27
+ function getAsProp(child) {
28
+ if (!isObject(child) || !("props" in child)) return void 0;
29
+ const props = child.props;
30
+ if (!isObject(props)) return void 0;
31
+ const as = props.as;
32
+ return isString(as) && as !== "" ? as : void 0;
33
+ }
34
+ function getTag(child) {
35
+ if (!isObject(child) || !("type" in child)) return void 0;
36
+ const t = child.type;
37
+ if (isString(t)) return t;
38
+ if (typeof t === "function" || isObject(t)) {
39
+ const defaultTag = t[COMPONENT_DEFAULT_TAG];
40
+ if (!isString(defaultTag)) return void 0;
41
+ return getAsProp(child) ?? defaultTag;
183
42
  }
43
+ return void 0;
184
44
  }
185
- function forEachValue(object, callback) {
186
- for (const value of values(object)) {
187
- callback(value);
45
+ function isTag(...args) {
46
+ if (isString(args[0])) {
47
+ const set3 = new Set(args);
48
+ return (child2) => {
49
+ const tag2 = getTag(child2);
50
+ return tag2 !== void 0 && set3.has(tag2);
51
+ };
188
52
  }
53
+ const [child, ...tags] = args;
54
+ const set2 = new Set(tags);
55
+ const tag = getTag(child);
56
+ return tag !== void 0 && set2.has(tag);
189
57
  }
190
- function forEachSet(s, callback) {
191
- for (const value of s) {
192
- callback(value);
193
- }
58
+
59
+ // ../../lib/adapter-utils/src/runtime/apply-display-name.ts
60
+ function applyDisplayName(component, name) {
61
+ Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
194
62
  }
195
- var iterate = Object.freeze({
196
- entries,
197
- filter,
198
- find,
199
- findLast,
200
- forEach,
201
- forEachEntry,
202
- forEachKey,
203
- forEachSet,
204
- forEachValue,
205
- items,
206
- keys,
207
- map,
208
- mapEntries,
209
- mapValues,
210
- nodeList,
211
- reduce,
212
- collect,
213
- set,
214
- some,
215
- every,
216
- values
217
- });
218
63
 
219
- // ../../lib/primitive/src/utils/merge-props.ts
220
- function mergeProps(defaultProps, props) {
221
- return {
222
- ...defaultProps ?? {},
223
- ...props
224
- };
64
+ // ../../lib/adapter-utils/src/runtime/define-component.ts
65
+ function defineContractComponent(options) {
66
+ return (factory) => factory(options);
225
67
  }
226
68
 
227
69
  // ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
@@ -246,7 +88,7 @@ var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
246
88
  ]);
247
89
 
248
90
  // ../../lib/primitive/src/constants/aria/implicit-role-record.ts
249
- var IMPLICIT_ROLE_RECORD = {
91
+ var IMPLICIT_ROLE_RECORD = Object.freeze({
250
92
  // Landmarks
251
93
  article: "article",
252
94
  aside: "complementary",
@@ -282,8 +124,8 @@ var IMPLICIT_ROLE_RECORD = {
282
124
  meter: "meter",
283
125
  output: "status",
284
126
  progress: "progressbar"
285
- };
286
- var INPUT_TYPE_ROLE_MAP = {
127
+ });
128
+ var INPUT_TYPE_ROLE_MAP = Object.freeze({
287
129
  checkbox: "checkbox",
288
130
  radio: "radio",
289
131
  range: "slider",
@@ -297,20 +139,22 @@ var INPUT_TYPE_ROLE_MAP = {
297
139
  submit: "button",
298
140
  reset: "button",
299
141
  image: "button"
300
- };
301
- var STRONG_ROLES = [
142
+ });
143
+ var STRONG_ROLES = Object.freeze([
302
144
  "main",
303
145
  "navigation",
304
146
  "complementary",
305
147
  "contentinfo",
306
148
  "banner"
307
- ];
308
- var STANDALONE_ROLES = ["article"];
149
+ ]);
150
+ var STANDALONE_ROLES = Object.freeze([
151
+ "article"
152
+ ]);
309
153
  var STRONG_ROLES_SET = new Set(STRONG_ROLES);
310
154
  var STANDALONE_ROLES_SET = new Set(STANDALONE_ROLES);
311
155
 
312
156
  // ../../lib/primitive/src/constants/aria/known-aria-roles.ts
313
- var KNOWN_ARIA_ROLES = [
157
+ var KNOWN_ARIA_ROLES = Object.freeze([
314
158
  "alert",
315
159
  "alertdialog",
316
160
  "application",
@@ -392,7 +236,7 @@ var KNOWN_ARIA_ROLES = [
392
236
  "tree",
393
237
  "treegrid",
394
238
  "treeitem"
395
- ];
239
+ ]);
396
240
  var KNOWN_ARIA_ROLES_SET = new Set(KNOWN_ARIA_ROLES);
397
241
 
398
242
  // ../../lib/primitive/src/constants/aria/role-restricted-attributes.ts
@@ -567,11 +411,11 @@ function isStandaloneTag(tag) {
567
411
  return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
568
412
  }
569
413
  function getInputImplicitRole(type) {
570
- if (type == null || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
414
+ if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
571
415
  return INPUT_TYPE_ROLE_MAP[type];
572
416
  }
573
417
  function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
574
- const isNamed = typeof ariaLabel === "string" || typeof ariaLabelledBy === "string";
418
+ const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
575
419
  if (!isNamed) return void 0;
576
420
  if (tag === "section") return "region";
577
421
  if (tag === "form") return "form";
@@ -583,17 +427,6 @@ function isKnownAriaRole(value) {
583
427
  return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
584
428
  }
585
429
 
586
- // ../../lib/adapter-utils/src/apply-filter.ts
587
- function applyFilter(props, filterProps, variantKeys) {
588
- const out = {};
589
- iterate.forEachEntry(props, (k) => {
590
- if (!Object.hasOwn(props, k)) return;
591
- if (filterProps(k, variantKeys)) return;
592
- out[k] = props[k];
593
- });
594
- return out;
595
- }
596
-
597
430
  // ../../lib/contract/src/aria/aria-role-policy.ts
598
431
  function getImplicitRole(tag, props) {
599
432
  if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
@@ -605,6 +438,202 @@ function getImplicitRole(tag, props) {
605
438
  return void 0;
606
439
  }
607
440
 
441
+ // ../../lib/primitive/src/tag/resolve-tag.ts
442
+ function makeResolveTag(defaultTag) {
443
+ return function tag(as) {
444
+ return as ?? defaultTag;
445
+ };
446
+ }
447
+
448
+ // ../../lib/primitive/src/utils/assert-never.ts
449
+ function assertNever(value) {
450
+ throw new Error(`Unexpected value: ${String(value)}`);
451
+ }
452
+
453
+ // ../../lib/primitive/src/utils/cn.ts
454
+ import { clsx } from "clsx";
455
+ function cn(...inputs) {
456
+ return clsx(...inputs);
457
+ }
458
+
459
+ // ../../lib/primitive/src/utils/iterate.ts
460
+ function find(iterable, callback) {
461
+ for (const value of iterable) {
462
+ const result = callback(value);
463
+ if (result != null) {
464
+ return result;
465
+ }
466
+ }
467
+ return null;
468
+ }
469
+ function some(iterable, predicate) {
470
+ for (const value of iterable) {
471
+ if (predicate(value)) return true;
472
+ }
473
+ return false;
474
+ }
475
+ function every(iterable, predicate) {
476
+ let index = 0;
477
+ for (const value of iterable) {
478
+ if (!predicate(value, index++)) {
479
+ return false;
480
+ }
481
+ }
482
+ return true;
483
+ }
484
+ function* filter(iterable, predicate) {
485
+ let index = 0;
486
+ for (const value of iterable) {
487
+ if (predicate(value, index++)) {
488
+ yield value;
489
+ }
490
+ }
491
+ }
492
+ function* map(iterable, callback) {
493
+ let index = 0;
494
+ for (const value of iterable) {
495
+ yield callback(value, index++);
496
+ }
497
+ }
498
+ function forEach(iterable, callback) {
499
+ let index = 0;
500
+ for (const value of iterable) {
501
+ callback(value, index++);
502
+ }
503
+ }
504
+ function reduce(iterable, initial, callback) {
505
+ let accumulator = initial;
506
+ let index = 0;
507
+ for (const value of iterable) {
508
+ accumulator = callback(accumulator, value, index++);
509
+ }
510
+ return accumulator;
511
+ }
512
+ function collect(iterable, callback) {
513
+ const result = {};
514
+ let index = 0;
515
+ for (const value of iterable) {
516
+ const entry = callback(value, index++);
517
+ if (entry === null) {
518
+ return null;
519
+ }
520
+ result[entry[0]] = entry[1];
521
+ }
522
+ return result;
523
+ }
524
+ function findLast(value, callback) {
525
+ for (let index = value.length - 1; index >= 0; index--) {
526
+ const result = callback(value[index], index);
527
+ if (result != null) {
528
+ return result;
529
+ }
530
+ }
531
+ return null;
532
+ }
533
+ function* items(collection) {
534
+ for (let i = 0; i < collection.length; i++) {
535
+ const item = collection.item(i);
536
+ if (item !== null) {
537
+ yield item;
538
+ }
539
+ }
540
+ }
541
+ function nodeList(list) {
542
+ return {
543
+ *[Symbol.iterator]() {
544
+ for (let i = 0; i < list.length; i++) {
545
+ const node = list.item(i);
546
+ if (node !== null) {
547
+ yield node;
548
+ }
549
+ }
550
+ }
551
+ };
552
+ }
553
+ function mapEntries(m) {
554
+ return m.entries();
555
+ }
556
+ function set(s) {
557
+ return s.values();
558
+ }
559
+ function hasOwn(object, key) {
560
+ return Object.hasOwn(object, key);
561
+ }
562
+ function* entries(object) {
563
+ for (const key in object) {
564
+ if (!hasOwn(object, key)) continue;
565
+ yield [key, object[key]];
566
+ }
567
+ }
568
+ function* keys(object) {
569
+ for (const [key] of entries(object)) {
570
+ yield key;
571
+ }
572
+ }
573
+ function* values(object) {
574
+ for (const [, value] of entries(object)) {
575
+ yield value;
576
+ }
577
+ }
578
+ function mapValues(object, callback) {
579
+ const result = {};
580
+ for (const [key, value] of entries(object)) {
581
+ result[key] = callback(value, key);
582
+ }
583
+ return result;
584
+ }
585
+ function forEachEntry(object, callback) {
586
+ for (const [key, value] of entries(object)) {
587
+ callback(key, value);
588
+ }
589
+ }
590
+ function forEachKey(object, callback) {
591
+ for (const key of keys(object)) {
592
+ callback(key);
593
+ }
594
+ }
595
+ function forEachValue(object, callback) {
596
+ for (const value of values(object)) {
597
+ callback(value);
598
+ }
599
+ }
600
+ function forEachSet(s, callback) {
601
+ for (const value of s) {
602
+ callback(value);
603
+ }
604
+ }
605
+ var iterate = Object.freeze({
606
+ entries,
607
+ filter,
608
+ find,
609
+ findLast,
610
+ forEach,
611
+ forEachEntry,
612
+ forEachKey,
613
+ forEachSet,
614
+ forEachValue,
615
+ items,
616
+ keys,
617
+ map,
618
+ mapEntries,
619
+ mapValues,
620
+ nodeList,
621
+ reduce,
622
+ collect,
623
+ set,
624
+ some,
625
+ every,
626
+ values
627
+ });
628
+
629
+ // ../../lib/primitive/src/utils/merge-props.ts
630
+ function mergeProps(defaultProps, props) {
631
+ return {
632
+ ...defaultProps ?? {},
633
+ ...props
634
+ };
635
+ }
636
+
608
637
  // ../../lib/contract/src/strict/invariant-base.ts
609
638
  var InvariantBase = class {
610
639
  diagnostics;
@@ -1660,7 +1689,7 @@ function getTypeName(value) {
1660
1689
  return primitive;
1661
1690
  }
1662
1691
  const name = value.constructor?.name;
1663
- return typeof name === "string" && name !== "Object" ? name : "object";
1692
+ return isString(name) && name !== "Object" ? name : "object";
1664
1693
  }
1665
1694
 
1666
1695
  // ../../lib/contract/src/children/normalize-child-rule.ts
@@ -1911,6 +1940,9 @@ var readonlyProps = ({
1911
1940
  };
1912
1941
  };
1913
1942
 
1943
+ // ../core/src/html/evaluators.ts
1944
+ import { warnDiagnostics as warnDiagnostics2 } from "../_shared/diagnostics.js";
1945
+
1914
1946
  // ../core/src/html/aria-rules.ts
1915
1947
  var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
1916
1948
  var removeLandmarkRoleOverride = {
@@ -1953,6 +1985,167 @@ function landmarkNameAdvisory(ctx) {
1953
1985
  }
1954
1986
  var HTML_ARIA_RULES = [landmarkRoleRule, landmarkNameAdvisory];
1955
1987
 
1988
+ // ../core/src/html/contracts.ts
1989
+ import { warnDiagnostics } from "../_shared/diagnostics.js";
1990
+ function isOpenContent(...blockedTags) {
1991
+ const set2 = new Set(blockedTags);
1992
+ return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set2.has(child.type));
1993
+ }
1994
+ var METADATA_TAGS = ["script", "template"];
1995
+ var metadataMatch = isTag(...METADATA_TAGS);
1996
+ function metadata(name = "metadata") {
1997
+ return { name, match: metadataMatch };
1998
+ }
1999
+ function firstOptional(name, tag) {
2000
+ return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
2001
+ }
2002
+ function contract(children) {
2003
+ return { diagnostics: warnDiagnostics, children };
2004
+ }
2005
+ function ariaContract(aria) {
2006
+ return { diagnostics: warnDiagnostics, aria };
2007
+ }
2008
+ function firstChildContract(name, tag) {
2009
+ return contract([firstOptional(name, tag), { name: "content", match: isOpenContent(tag) }]);
2010
+ }
2011
+ var VOID_TAGS = [
2012
+ "area",
2013
+ "base",
2014
+ "br",
2015
+ "col",
2016
+ "embed",
2017
+ "hr",
2018
+ "img",
2019
+ "input",
2020
+ "link",
2021
+ "meta",
2022
+ "param",
2023
+ "source",
2024
+ "track",
2025
+ "wbr"
2026
+ ];
2027
+ var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
2028
+ var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
2029
+ var listContract = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
2030
+ var tableContract = contract([
2031
+ firstOptional("caption", "caption"),
2032
+ { name: "colgroup", match: isTag("colgroup") },
2033
+ { name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
2034
+ { name: "tbody", match: isTag("tbody") },
2035
+ { name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
2036
+ { name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
2037
+ ]);
2038
+ var tableBodyContract = contract([
2039
+ { name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
2040
+ ]);
2041
+ var tableRowContract = contract([
2042
+ { name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
2043
+ ]);
2044
+ var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
2045
+ var dlContract = contract([
2046
+ { name: "term", match: isTag("dt") },
2047
+ { name: "description", match: isTag("dd") },
2048
+ { name: "group", match: isTag("div") },
2049
+ metadata()
2050
+ ]);
2051
+ var selectContract = contract([
2052
+ { name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
2053
+ ]);
2054
+ var optgroupContract = contract([
2055
+ { name: "option", match: isTag("option", ...METADATA_TAGS) }
2056
+ ]);
2057
+ var datalistContract = contract([
2058
+ { name: "option", match: isTag("option", ...METADATA_TAGS) }
2059
+ ]);
2060
+ var pictureContract = contract([
2061
+ { name: "source", match: isTag("source", ...METADATA_TAGS) },
2062
+ { name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
2063
+ ]);
2064
+ var figureContract = contract([
2065
+ { name: "caption", match: isTag("figcaption"), cardinality: { max: 1 } },
2066
+ { name: "content", match: isOpenContent("figcaption") }
2067
+ ]);
2068
+ var detailsContract = firstChildContract("summary", "summary");
2069
+ var fieldsetContract = firstChildContract("legend", "legend");
2070
+ var mediaContract = contract([
2071
+ { name: "source", match: isTag("source") },
2072
+ { name: "track", match: isTag("track") },
2073
+ metadata(),
2074
+ { name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
2075
+ ]);
2076
+ var headContract = contract([
2077
+ {
2078
+ name: "metadata",
2079
+ match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
2080
+ }
2081
+ ]);
2082
+ var htmlContract = contract([
2083
+ { name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
2084
+ { name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
2085
+ ]);
2086
+ var voidContract = contract([]);
2087
+ var textOnlyContract = contract([
2088
+ {
2089
+ name: "text",
2090
+ match: (child) => isString(child) || isNumber(child)
2091
+ }
2092
+ ]);
2093
+ var landmarkContract = ariaContract([landmarkRoleRule, landmarkNameAdvisory]);
2094
+ var dialogContract = ariaContract([requireAccessibleName]);
2095
+ var menuContract = ariaContract([requireAccessibleName]);
2096
+ var menubarContract = ariaContract([requireAccessibleName]);
2097
+ var treeContract = ariaContract([requireAccessibleName]);
2098
+ var gridContract = ariaContract([requireAccessibleName]);
2099
+ var listboxContract = ariaContract([requireAccessibleName]);
2100
+ var tablistContract = ariaContract([requireAccessibleName]);
2101
+ var radiogroupContract = ariaContract([requireAccessibleName]);
2102
+ var CONTRACT_GROUPS = [
2103
+ [VOID_TAGS, voidContract],
2104
+ [TEXT_ONLY_TAGS, textOnlyContract],
2105
+ [LANDMARK_TAGS, landmarkContract],
2106
+ [["ul", "ol", "menu"], listContract],
2107
+ [["audio", "video"], mediaContract],
2108
+ [["thead", "tbody", "tfoot"], tableBodyContract]
2109
+ ];
2110
+ function contractMap(groups) {
2111
+ return Object.fromEntries(
2112
+ groups.flatMap(([tags, enforcement]) => tags.map((tag) => [tag, enforcement]))
2113
+ );
2114
+ }
2115
+ var htmlContracts = {
2116
+ ...contractMap(CONTRACT_GROUPS),
2117
+ table: tableContract,
2118
+ tr: tableRowContract,
2119
+ colgroup: colgroupContract,
2120
+ dl: dlContract,
2121
+ select: selectContract,
2122
+ optgroup: optgroupContract,
2123
+ datalist: datalistContract,
2124
+ picture: pictureContract,
2125
+ figure: figureContract,
2126
+ details: detailsContract,
2127
+ fieldset: fieldsetContract,
2128
+ dialog: dialogContract,
2129
+ head: headContract,
2130
+ html: htmlContract
2131
+ };
2132
+
2133
+ // ../core/src/html/evaluators.ts
2134
+ var htmlDiagnostics = warnDiagnostics2;
2135
+ function buildEvaluatorMap() {
2136
+ const map2 = /* @__PURE__ */ new Map();
2137
+ iterate.forEachEntry(htmlContracts, (tag, { children }) => {
2138
+ if (children?.length) {
2139
+ map2.set(tag, new ChildrenEvaluator(children, htmlDiagnostics, `<${tag}>`));
2140
+ }
2141
+ });
2142
+ return map2;
2143
+ }
2144
+ var HTML_EVALUATORS = buildEvaluatorMap();
2145
+ function getHtmlChildrenEvaluator(tag) {
2146
+ return typeof tag === "string" ? HTML_EVALUATORS.get(tag) : void 0;
2147
+ }
2148
+
1956
2149
  // ../core/src/html/prop-normalizers.ts
1957
2150
  var HTML_FORM_NORMALIZERS = /* @__PURE__ */ new Map([
1958
2151
  ["button", [disabledProps]],
@@ -2140,6 +2333,19 @@ function createClassPipeline(resolved) {
2140
2333
  };
2141
2334
  }
2142
2335
 
2336
+ // ../../lib/pipeline-kit/src/factory/define-pipeline.ts
2337
+ function definePipeline(factory) {
2338
+ const cache = /* @__PURE__ */ new WeakMap();
2339
+ return (resolved) => {
2340
+ let pipeline = cache.get(resolved);
2341
+ if (!pipeline) {
2342
+ pipeline = factory(resolved);
2343
+ cache.set(resolved, pipeline);
2344
+ }
2345
+ return pipeline;
2346
+ };
2347
+ }
2348
+
2143
2349
  // ../core/src/options/resolve-factory-options.ts
2144
2350
  import { silentDiagnostics } from "../_shared/diagnostics.js";
2145
2351
  var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
@@ -2275,89 +2481,82 @@ function guardPipeline(pipeline) {
2275
2481
  };
2276
2482
  }
2277
2483
 
2278
- // ../core/src/factory/create-polymorphic.ts
2279
- var NOOP_CLASS_PIPELINE = (_tag, _props, className) => Array.isArray(className) ? className.join(" ") : className ?? "";
2280
- function resolveClassPipeline(options, resolved, diagnostics, capabilities) {
2281
- const factory = options.styling?.plugin;
2282
- if (!factory) {
2283
- const createClassPipeline2 = capabilities?.createClassPipeline;
2284
- const classPipeline2 = createClassPipeline2 ? createClassPipeline2(resolved) : NOOP_CLASS_PIPELINE;
2285
- return { pluginResult: void 0, classPipeline: classPipeline2 };
2286
- }
2484
+ // ../core/src/factory/create-polymorphic2.ts
2485
+ var createTagPipeline = (resolved) => makeResolveTag(resolved.defaultTag);
2486
+ var createPropsPipeline = (resolved) => (props) => mergeProps(resolved.defaultProps, props);
2487
+ var createHtmlPropNormalizersPipeline = () => getHtmlPropNormalizers;
2488
+ var createHtmlChildrenEvaluatorPipeline = () => getHtmlChildrenEvaluator;
2489
+ var createStylingClassPipeline = (resolved) => createClassPipeline(resolved);
2490
+ function resolveAriaRules(resolved) {
2491
+ return [.../* @__PURE__ */ new Set([...HTML_ARIA_RULES, ...resolved.ariaRules ?? []])];
2492
+ }
2493
+ var createAriaPipeline = (resolved) => {
2494
+ const rules = resolveAriaRules(resolved);
2495
+ const engine = new AriaPolicyEngine(resolved.diagnostics, rules.length ? { rules } : void 0);
2496
+ return (tag, props) => engine.validate(tag, props);
2497
+ };
2498
+ var memoizedTagPipeline = definePipeline(createTagPipeline);
2499
+ var memoizedPropsPipeline = definePipeline(createPropsPipeline);
2500
+ var memoizedHtmlPropNormalizersPipeline = definePipeline(createHtmlPropNormalizersPipeline);
2501
+ var memoizedHtmlChildrenEvaluatorPipeline = definePipeline(createHtmlChildrenEvaluatorPipeline);
2502
+ var memoizedClassPipeline = definePipeline(createStylingClassPipeline);
2503
+ var memoizedAriaPipeline = definePipeline(createAriaPipeline);
2504
+ function resolveAriaPassthrough(_tag, props) {
2505
+ return { props };
2506
+ }
2507
+ function resolveClassPlugin(factory, resolved, diagnostics) {
2508
+ if (!factory) return { pluginResult: void 0, classPipeline: memoizedClassPipeline(resolved) };
2287
2509
  const pluginResult = factory(resolved, diagnostics);
2288
2510
  assertPluginShape(pluginResult);
2289
- const classPipeline = guardPipeline(pluginResult.pipeline);
2290
- return { pluginResult, classPipeline };
2511
+ return { pluginResult, classPipeline: guardPipeline(pluginResult.pipeline) };
2291
2512
  }
2292
- function createRuntimeMethods(resolved, classPipeline, engine, renderDiagnostics) {
2293
- return {
2294
- resolveTag: makeResolveTag(resolved.defaultTag),
2295
- resolveProps(props) {
2296
- return mergeProps(resolved.defaultProps, props);
2297
- },
2513
+ function createPolymorphic2(options = {}) {
2514
+ const baseResolved = resolveFactoryOptions(options);
2515
+ const anyBaseResolved = baseResolved;
2516
+ const resolved = Object.freeze({
2517
+ ...baseResolved,
2518
+ htmlPropNormalizersFn: memoizedHtmlPropNormalizersPipeline(anyBaseResolved),
2519
+ htmlChildrenEvaluatorFn: memoizedHtmlChildrenEvaluatorPipeline(anyBaseResolved)
2520
+ });
2521
+ const anyResolved = resolved;
2522
+ if (process.env.NODE_ENV !== "production") {
2523
+ validateFactoryOptions(resolved, resolved.diagnostics);
2524
+ }
2525
+ const { pluginResult, classPipeline } = resolveClassPlugin(
2526
+ options.styling?.plugin,
2527
+ anyResolved,
2528
+ resolved.diagnostics
2529
+ );
2530
+ const resolveTag3 = memoizedTagPipeline(anyResolved);
2531
+ const resolveProps = memoizedPropsPipeline(anyResolved);
2532
+ const resolveAriaFn = options.enforcement !== void 0 ? memoizedAriaPipeline(anyResolved) : resolveAriaPassthrough;
2533
+ const methods = {
2534
+ resolveTag: resolveTag3,
2535
+ resolveProps,
2298
2536
  resolveClasses(tag, props, className, recipe) {
2299
2537
  if (process.env.NODE_ENV !== "production") {
2300
- validateRenderProps(renderDiagnostics, resolved, props, recipe);
2538
+ validateRenderProps(resolved.diagnostics, resolved, props, recipe);
2301
2539
  }
2302
2540
  return classPipeline(tag, props, className, recipe);
2303
2541
  },
2304
2542
  resolveAria(tag, props) {
2305
- if (!engine) return { props };
2306
- const result = engine.validate(tag, props);
2307
- return { props: result.props };
2543
+ return resolveAriaFn(tag, props);
2308
2544
  }
2309
2545
  };
2310
- }
2311
- function createRuntimeObject(methods, resolved, pluginResult) {
2312
- return pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
2313
- }
2314
- function createPolymorphic(options = {}, capabilities) {
2315
- const baseResolved = resolveFactoryOptions(options);
2316
- const resolved = capabilities?.htmlPropNormalizersFn !== void 0 ? Object.freeze({
2317
- ...baseResolved,
2318
- htmlPropNormalizersFn: capabilities.htmlPropNormalizersFn
2319
- }) : baseResolved;
2320
- if (process.env.NODE_ENV !== "production") {
2321
- validateFactoryOptions(resolved, resolved.diagnostics);
2322
- }
2323
- const { pluginResult, classPipeline } = resolveClassPipeline(
2324
- options,
2325
- resolved,
2326
- resolved.diagnostics,
2327
- capabilities
2328
- );
2329
- const allAriaRules = [
2330
- .../* @__PURE__ */ new Set([...capabilities?.htmlAriaRules ?? [], ...resolved.ariaRules ?? []])
2331
- ];
2332
- const engine = options.enforcement !== void 0 && capabilities?.AriaEngine ? new capabilities.AriaEngine(
2333
- resolved.diagnostics,
2334
- allAriaRules.length ? { rules: allAriaRules } : void 0
2335
- ) : null;
2336
- const methods = createRuntimeMethods(resolved, classPipeline, engine, resolved.diagnostics);
2337
- return createRuntimeObject(
2338
- methods,
2339
- resolved,
2340
- pluginResult
2341
- );
2546
+ const runtimeObject = pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
2547
+ return runtimeObject;
2342
2548
  }
2343
2549
 
2344
- // ../core/src/factory/create-polymorphic-full.ts
2345
- var FULL_CAPABILITIES = {
2346
- createClassPipeline,
2347
- AriaEngine: AriaPolicyEngine,
2348
- htmlAriaRules: HTML_ARIA_RULES,
2349
- htmlPropNormalizersFn: getHtmlPropNormalizers
2350
- };
2351
- function createPolymorphic2(options = {}) {
2352
- return createPolymorphic(options, FULL_CAPABILITIES);
2550
+ // ../core/src/resolver/resolver.ts
2551
+ import { silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
2552
+ function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
2553
+ if (allowedAs.includes(tag)) return;
2554
+ if (!diagnostics) return;
2555
+ const component = displayName ?? String(tag);
2556
+ diagnostics.error(ContractDiagnostics.allowedAsViolation(String(tag), allowedAs, component));
2353
2557
  }
2354
2558
 
2355
- // ../../lib/adapter-utils/src/define-component.ts
2356
- function defineContractComponent(options) {
2357
- return (factory) => factory(options);
2358
- }
2359
-
2360
- // ../../lib/adapter-utils/src/build-core-runtime.ts
2559
+ // ../../lib/adapter-utils/src/runtime/build-core-runtime.ts
2361
2560
  var EMPTY_SET = /* @__PURE__ */ new Set();
2362
2561
  function buildCoreRuntime(normalized) {
2363
2562
  const runtime = createPolymorphic2(normalized);
@@ -2365,12 +2564,32 @@ function buildCoreRuntime(normalized) {
2365
2564
  return { runtime, ownedKeys };
2366
2565
  }
2367
2566
 
2368
- // ../../lib/adapter-utils/src/build-engines.ts
2567
+ // ../../lib/adapter-utils/src/runtime/build-engines.ts
2369
2568
  function buildEngines(diagnostics, childRules, context) {
2370
2569
  return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
2371
2570
  }
2372
2571
 
2373
- // ../../lib/adapter-utils/src/compose-filter.ts
2572
+ // ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
2573
+ import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3 } from "../_shared/diagnostics.js";
2574
+ function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
2575
+ return {
2576
+ name: options.name ?? defaultName,
2577
+ diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
2578
+ };
2579
+ }
2580
+
2581
+ // ../../lib/adapter-utils/src/props/apply-filter.ts
2582
+ function applyFilter(props, filterProps, variantKeys) {
2583
+ const out = {};
2584
+ iterate.forEachEntry(props, (k) => {
2585
+ if (!Object.hasOwn(props, k)) return;
2586
+ if (filterProps(k, variantKeys)) return;
2587
+ out[k] = props[k];
2588
+ });
2589
+ return out;
2590
+ }
2591
+
2592
+ // ../../lib/adapter-utils/src/props/compose-filter.ts
2374
2593
  function composeFilter(ownedKeys, filterProps) {
2375
2594
  const defaultFilter = (key, variantKeys) => variantKeys.has(key) || ownedKeys.has(key);
2376
2595
  if (!filterProps) {
@@ -2379,15 +2598,6 @@ function composeFilter(ownedKeys, filterProps) {
2379
2598
  return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
2380
2599
  }
2381
2600
 
2382
- // ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
2383
- import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
2384
- function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
2385
- return {
2386
- name: options.name ?? defaultName,
2387
- diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
2388
- };
2389
- }
2390
-
2391
2601
  // ../../adapters/solid/src/slot/slot-validator.ts
2392
2602
  var SlotValidator = class extends InvariantBase {
2393
2603
  #name;
@@ -2464,7 +2674,7 @@ function resolveTag2(runtime, as) {
2464
2674
  return runtime.resolveTag(as);
2465
2675
  }
2466
2676
  function resolveDomProps(tag, elementProps, runtime) {
2467
- return typeof tag === "string" ? runtime.resolveAria(tag, elementProps).props : elementProps;
2677
+ return isString(tag) ? runtime.resolveAria(tag, elementProps).props : elementProps;
2468
2678
  }
2469
2679
  function tryRenderAsChild(known, filteredProps, resolvedClass, slotValidator) {
2470
2680
  if (!known.asChild) return null;
@@ -2505,9 +2715,20 @@ function render({
2505
2715
  const filteredProps = createMemo(
2506
2716
  () => applyFilter(normalizedProps(), filterProps, runtime.options.variantKeys)
2507
2717
  );
2718
+ const { allowedAs } = runtime.options;
2719
+ if (allowedAs !== void 0) {
2720
+ createEffect(
2721
+ () => enforceAllowedAs(tag(), allowedAs, runtime.options.diagnostics, runtime.options.displayName)
2722
+ );
2723
+ }
2508
2724
  if (process.env.NODE_ENV !== "production" && childrenEvaluator) {
2509
2725
  createEffect(() => childrenEvaluator.evaluate(toChildArray(known.children)));
2510
2726
  }
2727
+ if (process.env.NODE_ENV !== "production") {
2728
+ createEffect(
2729
+ () => runtime.options.htmlChildrenEvaluatorFn?.(tag())?.evaluate(toChildArray(known.children))
2730
+ );
2731
+ }
2511
2732
  const slotResult = tryRenderAsChild(known, filteredProps, resolvedClass, slotValidator);
2512
2733
  if (slotResult !== null) return slotResult;
2513
2734
  const domProps = createMemo(() => {