praxis-kit 6.1.1 → 6.2.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.
@@ -1,5 +1,12 @@
1
- // ../../lib/primitive/src/guards/children/component-id.ts
2
- var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
1
+ // ../../lib/primitive/src/tag/resolve-tag.ts
2
+ function makeResolveTag(defaultTag) {
3
+ return function tag(as) {
4
+ return as ?? defaultTag;
5
+ };
6
+ }
7
+
8
+ // ../../lib/primitive/src/rule/rule-brand.ts
9
+ var RULE_BRAND = /* @__PURE__ */ Symbol("praxis-kit/dynamic-rule");
3
10
 
4
11
  // ../../lib/primitive/src/guards/foundational/is-defined.ts
5
12
  function isUndefined(value) {
@@ -26,76 +33,271 @@ function isNumber(value) {
26
33
  return typeof value === "number";
27
34
  }
28
35
 
29
- // ../../lib/primitive/src/guards/children/is-tag.ts
30
- function getAsProp(child) {
31
- if (!isObject(child) || !("props" in child)) return void 0;
32
- const props = child.props;
33
- if (!isObject(props)) return void 0;
34
- const as = props.as;
35
- return isString(as) && as !== "" ? as : void 0;
36
- }
37
- function getTag(child) {
38
- if (!isObject(child) || !("type" in child)) return void 0;
39
- const t = child.type;
40
- if (isString(t)) return t;
41
- if (typeof t === "function" || isObject(t)) {
42
- const defaultTag = t[COMPONENT_DEFAULT_TAG];
43
- if (!isString(defaultTag)) return void 0;
44
- return getAsProp(child) ?? defaultTag;
45
- }
46
- return void 0;
36
+ // ../../lib/primitive/src/rule/is-dynamic-rule.ts
37
+ function isDynamicRule(rule) {
38
+ return isObject(rule, true) && rule[RULE_BRAND] === true;
47
39
  }
48
- function isTag(...args) {
49
- if (isString(args[0])) {
50
- const set3 = new Set(args);
51
- return (child2) => {
52
- const tag2 = getTag(child2);
53
- return tag2 !== void 0 && set3.has(tag2);
54
- };
55
- }
56
- const [child, ...tags] = args;
57
- const set2 = new Set(tags);
58
- const tag = getTag(child);
59
- return tag !== void 0 && set2.has(tag);
40
+
41
+ // ../../lib/primitive/src/rule/resolve-rule.ts
42
+ function resolveRule(rule, context) {
43
+ return isDynamicRule(rule) ? rule.resolve(context) : rule;
60
44
  }
61
45
 
62
- // ../../lib/adapter-utils/src/runtime/apply-display-name.ts
63
- function applyDisplayName(component, name) {
64
- Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
46
+ // ../../lib/primitive/src/utils/assert-never.ts
47
+ function assertNever(value) {
48
+ throw new Error(`Unexpected value: ${String(value)}`);
65
49
  }
66
50
 
67
- // ../../lib/adapter-utils/src/runtime/define-component.ts
68
- function defineContractComponent(options) {
69
- return (factory) => factory(options);
51
+ // ../../lib/primitive/src/utils/cn.ts
52
+ import { clsx } from "clsx";
53
+ function cn(...inputs) {
54
+ return clsx(...inputs);
70
55
  }
71
56
 
72
- // ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
73
- var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
74
- "aria-atomic",
75
- "aria-busy",
76
- "aria-controls",
77
- "aria-current",
78
- "aria-describedby",
79
- "aria-details",
80
- "aria-disabled",
81
- "aria-errormessage",
82
- "aria-flowto",
83
- "aria-hidden",
84
- "aria-keyshortcuts",
85
- "aria-label",
86
- "aria-labelledby",
87
- "aria-live",
88
- "aria-owns",
89
- "aria-relevant",
90
- "aria-roledescription"
91
- ]);
57
+ // ../../lib/primitive/src/utils/iterate.ts
58
+ function find(iterable, callback) {
59
+ for (const value of iterable) {
60
+ const result = callback(value);
61
+ if (result != null) {
62
+ return result;
63
+ }
64
+ }
65
+ return null;
66
+ }
67
+ function some(iterable, predicate) {
68
+ for (const value of iterable) {
69
+ if (predicate(value)) return true;
70
+ }
71
+ return false;
72
+ }
73
+ function every(iterable, predicate) {
74
+ let index = 0;
75
+ for (const value of iterable) {
76
+ if (!predicate(value, index++)) {
77
+ return false;
78
+ }
79
+ }
80
+ return true;
81
+ }
82
+ function* filter(iterable, predicate) {
83
+ let index = 0;
84
+ for (const value of iterable) {
85
+ if (predicate(value, index++)) {
86
+ yield value;
87
+ }
88
+ }
89
+ }
90
+ function* map(iterable, callback) {
91
+ let index = 0;
92
+ for (const value of iterable) {
93
+ yield callback(value, index++);
94
+ }
95
+ }
96
+ function forEach(iterable, callback) {
97
+ let index = 0;
98
+ for (const value of iterable) {
99
+ callback(value, index++);
100
+ }
101
+ }
102
+ function reduce(iterable, initial, callback) {
103
+ let accumulator = initial;
104
+ let index = 0;
105
+ for (const value of iterable) {
106
+ accumulator = callback(accumulator, value, index++);
107
+ }
108
+ return accumulator;
109
+ }
110
+ function collect(iterable, callback) {
111
+ const result = {};
112
+ let index = 0;
113
+ for (const value of iterable) {
114
+ const entry = callback(value, index++);
115
+ if (entry === null) {
116
+ return null;
117
+ }
118
+ result[entry[0]] = entry[1];
119
+ }
120
+ return result;
121
+ }
122
+ function findLast(value, callback) {
123
+ for (let index = value.length - 1; index >= 0; index--) {
124
+ const result = callback(value[index], index);
125
+ if (result != null) {
126
+ return result;
127
+ }
128
+ }
129
+ return null;
130
+ }
131
+ function* items(collection) {
132
+ for (let i = 0; i < collection.length; i++) {
133
+ const item = collection.item(i);
134
+ if (item !== null) {
135
+ yield item;
136
+ }
137
+ }
138
+ }
139
+ function nodeList(list) {
140
+ return {
141
+ *[Symbol.iterator]() {
142
+ for (let i = 0; i < list.length; i++) {
143
+ const node = list.item(i);
144
+ if (node !== null) {
145
+ yield node;
146
+ }
147
+ }
148
+ }
149
+ };
150
+ }
151
+ function mapEntries(m) {
152
+ return m.entries();
153
+ }
154
+ function set(s) {
155
+ return s.values();
156
+ }
157
+ function hasOwn(object, key) {
158
+ return Object.hasOwn(object, key);
159
+ }
160
+ function* entries(object) {
161
+ for (const key in object) {
162
+ if (!hasOwn(object, key)) continue;
163
+ yield [key, object[key]];
164
+ }
165
+ }
166
+ function* keys(object) {
167
+ for (const [key] of entries(object)) {
168
+ yield key;
169
+ }
170
+ }
171
+ function* values(object) {
172
+ for (const [, value] of entries(object)) {
173
+ yield value;
174
+ }
175
+ }
176
+ function mapValues(object, callback) {
177
+ const result = {};
178
+ for (const [key, value] of entries(object)) {
179
+ result[key] = callback(value, key);
180
+ }
181
+ return result;
182
+ }
183
+ function forEachEntry(object, callback) {
184
+ for (const [key, value] of entries(object)) {
185
+ callback(key, value);
186
+ }
187
+ }
188
+ function forEachKey(object, callback) {
189
+ for (const key of keys(object)) {
190
+ callback(key);
191
+ }
192
+ }
193
+ function forEachValue(object, callback) {
194
+ for (const value of values(object)) {
195
+ callback(value);
196
+ }
197
+ }
198
+ function forEachSet(s, callback) {
199
+ for (const value of s) {
200
+ callback(value);
201
+ }
202
+ }
203
+ var iterate = Object.freeze({
204
+ entries,
205
+ filter,
206
+ find,
207
+ findLast,
208
+ forEach,
209
+ forEachEntry,
210
+ forEachKey,
211
+ forEachSet,
212
+ forEachValue,
213
+ items,
214
+ keys,
215
+ map,
216
+ mapEntries,
217
+ mapValues,
218
+ nodeList,
219
+ reduce,
220
+ collect,
221
+ set,
222
+ some,
223
+ every,
224
+ values
225
+ });
92
226
 
93
- // ../../lib/primitive/src/constants/aria/implicit-role-record.ts
94
- var IMPLICIT_ROLE_RECORD = Object.freeze({
95
- // Landmarks
96
- article: "article",
97
- aside: "complementary",
98
- footer: "contentinfo",
227
+ // ../../lib/primitive/src/utils/lru-cache.ts
228
+ var LRUCache = class {
229
+ #maxSize;
230
+ #store = /* @__PURE__ */ new Map();
231
+ constructor(maxSize) {
232
+ if (!Number.isInteger(maxSize) || maxSize < 1) {
233
+ throw new RangeError("LRUCache maxSize must be a positive integer.");
234
+ }
235
+ this.#maxSize = maxSize;
236
+ }
237
+ get(key) {
238
+ if (!this.#store.has(key)) return void 0;
239
+ const value = this.#store.get(key);
240
+ this.#store.delete(key);
241
+ this.#store.set(key, value);
242
+ return value;
243
+ }
244
+ set(key, value) {
245
+ this.#store.delete(key);
246
+ this.#store.set(key, value);
247
+ if (this.#store.size > this.#maxSize) {
248
+ const lru = this.#store.keys().next().value;
249
+ if (lru !== void 0) this.#store.delete(lru);
250
+ }
251
+ }
252
+ has(key) {
253
+ return this.#store.has(key);
254
+ }
255
+ delete(key) {
256
+ return this.#store.delete(key);
257
+ }
258
+ get size() {
259
+ return this.#store.size;
260
+ }
261
+ clear() {
262
+ this.#store.clear();
263
+ }
264
+ };
265
+
266
+ // ../../lib/primitive/src/utils/merge-props.ts
267
+ function mergeProps(defaultProps, props) {
268
+ return {
269
+ ...defaultProps ?? {},
270
+ ...props
271
+ };
272
+ }
273
+
274
+ // ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
275
+ var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
276
+ "aria-atomic",
277
+ "aria-busy",
278
+ "aria-controls",
279
+ "aria-current",
280
+ "aria-describedby",
281
+ "aria-details",
282
+ "aria-disabled",
283
+ "aria-errormessage",
284
+ "aria-flowto",
285
+ "aria-hidden",
286
+ "aria-keyshortcuts",
287
+ "aria-label",
288
+ "aria-labelledby",
289
+ "aria-live",
290
+ "aria-owns",
291
+ "aria-relevant",
292
+ "aria-roledescription"
293
+ ]);
294
+
295
+ // ../../lib/primitive/src/constants/aria/implicit-role-record.ts
296
+ var IMPLICIT_ROLE_RECORD = Object.freeze({
297
+ // Landmarks
298
+ article: "article",
299
+ aside: "complementary",
300
+ footer: "contentinfo",
99
301
  header: "banner",
100
302
  main: "main",
101
303
  nav: "navigation",
@@ -430,263 +632,61 @@ function isKnownAriaRole(value) {
430
632
  return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
431
633
  }
432
634
 
433
- // ../../lib/contract/src/aria/aria-role-policy.ts
434
- function getImplicitRole(tag, props) {
435
- if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
436
- if (tag === "input") return getInputImplicitRole(props?.type);
437
- if (tag === "img") return props?.alt === "" ? "none" : "img";
438
- if (tag === "section" || tag === "form") {
439
- return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
440
- }
441
- return void 0;
442
- }
443
-
444
- // ../../lib/primitive/src/tag/resolve-tag.ts
445
- function makeResolveTag(defaultTag) {
446
- return function tag(as) {
447
- return as ?? defaultTag;
448
- };
449
- }
450
-
451
- // ../../lib/primitive/src/rule/rule-brand.ts
452
- var RULE_BRAND = /* @__PURE__ */ Symbol("praxis-kit/dynamic-rule");
453
-
454
- // ../../lib/primitive/src/rule/is-dynamic-rule.ts
455
- function isDynamicRule(rule) {
456
- return isObject(rule, true) && rule[RULE_BRAND] === true;
457
- }
458
-
459
- // ../../lib/primitive/src/rule/resolve-rule.ts
460
- function resolveRule(rule, context) {
461
- return isDynamicRule(rule) ? rule.resolve(context) : rule;
462
- }
463
-
464
- // ../../lib/primitive/src/utils/assert-never.ts
465
- function assertNever(value) {
466
- throw new Error(`Unexpected value: ${String(value)}`);
467
- }
468
-
469
- // ../../lib/primitive/src/utils/cn.ts
470
- import { clsx } from "clsx";
471
- function cn(...inputs) {
472
- return clsx(...inputs);
473
- }
635
+ // ../../lib/primitive/src/guards/children/component-id.ts
636
+ var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
474
637
 
475
- // ../../lib/primitive/src/utils/iterate.ts
476
- function find(iterable, callback) {
477
- for (const value of iterable) {
478
- const result = callback(value);
479
- if (result != null) {
480
- return result;
481
- }
482
- }
483
- return null;
484
- }
485
- function some(iterable, predicate) {
486
- for (const value of iterable) {
487
- if (predicate(value)) return true;
488
- }
489
- return false;
490
- }
491
- function every(iterable, predicate) {
492
- let index = 0;
493
- for (const value of iterable) {
494
- if (!predicate(value, index++)) {
495
- return false;
496
- }
497
- }
498
- return true;
499
- }
500
- function* filter(iterable, predicate) {
501
- let index = 0;
502
- for (const value of iterable) {
503
- if (predicate(value, index++)) {
504
- yield value;
505
- }
506
- }
507
- }
508
- function* map(iterable, callback) {
509
- let index = 0;
510
- for (const value of iterable) {
511
- yield callback(value, index++);
512
- }
513
- }
514
- function forEach(iterable, callback) {
515
- let index = 0;
516
- for (const value of iterable) {
517
- callback(value, index++);
518
- }
519
- }
520
- function reduce(iterable, initial, callback) {
521
- let accumulator = initial;
522
- let index = 0;
523
- for (const value of iterable) {
524
- accumulator = callback(accumulator, value, index++);
525
- }
526
- return accumulator;
527
- }
528
- function collect(iterable, callback) {
529
- const result = {};
530
- let index = 0;
531
- for (const value of iterable) {
532
- const entry = callback(value, index++);
533
- if (entry === null) {
534
- return null;
535
- }
536
- result[entry[0]] = entry[1];
537
- }
538
- return result;
539
- }
540
- function findLast(value, callback) {
541
- for (let index = value.length - 1; index >= 0; index--) {
542
- const result = callback(value[index], index);
543
- if (result != null) {
544
- return result;
545
- }
546
- }
547
- return null;
548
- }
549
- function* items(collection) {
550
- for (let i = 0; i < collection.length; i++) {
551
- const item = collection.item(i);
552
- if (item !== null) {
553
- yield item;
554
- }
555
- }
556
- }
557
- function nodeList(list) {
558
- return {
559
- *[Symbol.iterator]() {
560
- for (let i = 0; i < list.length; i++) {
561
- const node = list.item(i);
562
- if (node !== null) {
563
- yield node;
564
- }
565
- }
566
- }
567
- };
568
- }
569
- function mapEntries(m) {
570
- return m.entries();
571
- }
572
- function set(s) {
573
- return s.values();
574
- }
575
- function hasOwn(object, key) {
576
- return Object.hasOwn(object, key);
577
- }
578
- function* entries(object) {
579
- for (const key in object) {
580
- if (!hasOwn(object, key)) continue;
581
- yield [key, object[key]];
582
- }
583
- }
584
- function* keys(object) {
585
- for (const [key] of entries(object)) {
586
- yield key;
587
- }
588
- }
589
- function* values(object) {
590
- for (const [, value] of entries(object)) {
591
- yield value;
592
- }
593
- }
594
- function mapValues(object, callback) {
595
- const result = {};
596
- for (const [key, value] of entries(object)) {
597
- result[key] = callback(value, key);
598
- }
599
- return result;
638
+ // ../../lib/primitive/src/guards/children/is-tag.ts
639
+ function getAsProp(child) {
640
+ if (!isObject(child) || !("props" in child)) return void 0;
641
+ const props = child.props;
642
+ if (!isObject(props)) return void 0;
643
+ const as = props.as;
644
+ return isString(as) && as !== "" ? as : void 0;
600
645
  }
601
- function forEachEntry(object, callback) {
602
- for (const [key, value] of entries(object)) {
603
- callback(key, value);
646
+ function getTag(child) {
647
+ if (!isObject(child) || !("type" in child)) return void 0;
648
+ const t = child.type;
649
+ if (isString(t)) return t;
650
+ if (typeof t === "function" || isObject(t)) {
651
+ const defaultTag = t[COMPONENT_DEFAULT_TAG];
652
+ if (!isString(defaultTag)) return void 0;
653
+ return getAsProp(child) ?? defaultTag;
604
654
  }
655
+ return void 0;
605
656
  }
606
- function forEachKey(object, callback) {
607
- for (const key of keys(object)) {
608
- callback(key);
657
+ function isTag(...args) {
658
+ if (isString(args[0])) {
659
+ const set3 = new Set(args);
660
+ return (child2) => {
661
+ const tag2 = getTag(child2);
662
+ return tag2 !== void 0 && set3.has(tag2);
663
+ };
609
664
  }
665
+ const [child, ...tags] = args;
666
+ const set2 = new Set(tags);
667
+ const tag = getTag(child);
668
+ return tag !== void 0 && set2.has(tag);
610
669
  }
611
- function forEachValue(object, callback) {
612
- for (const value of values(object)) {
613
- callback(value);
614
- }
670
+
671
+ // ../../lib/adapter-utils/src/runtime/apply-display-name.ts
672
+ function applyDisplayName(component, name) {
673
+ Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
615
674
  }
616
- function forEachSet(s, callback) {
617
- for (const value of s) {
618
- callback(value);
619
- }
675
+
676
+ // ../../lib/adapter-utils/src/runtime/define-component.ts
677
+ function defineContractComponent(options) {
678
+ return (factory) => factory(options);
620
679
  }
621
- var iterate = Object.freeze({
622
- entries,
623
- filter,
624
- find,
625
- findLast,
626
- forEach,
627
- forEachEntry,
628
- forEachKey,
629
- forEachSet,
630
- forEachValue,
631
- items,
632
- keys,
633
- map,
634
- mapEntries,
635
- mapValues,
636
- nodeList,
637
- reduce,
638
- collect,
639
- set,
640
- some,
641
- every,
642
- values
643
- });
644
680
 
645
- // ../../lib/primitive/src/utils/lru-cache.ts
646
- var LRUCache = class {
647
- #maxSize;
648
- #store = /* @__PURE__ */ new Map();
649
- constructor(maxSize) {
650
- if (!Number.isInteger(maxSize) || maxSize < 1) {
651
- throw new RangeError("LRUCache maxSize must be a positive integer.");
652
- }
653
- this.#maxSize = maxSize;
654
- }
655
- get(key) {
656
- if (!this.#store.has(key)) return void 0;
657
- const value = this.#store.get(key);
658
- this.#store.delete(key);
659
- this.#store.set(key, value);
660
- return value;
661
- }
662
- set(key, value) {
663
- this.#store.delete(key);
664
- this.#store.set(key, value);
665
- if (this.#store.size > this.#maxSize) {
666
- const lru = this.#store.keys().next().value;
667
- if (lru !== void 0) this.#store.delete(lru);
668
- }
669
- }
670
- has(key) {
671
- return this.#store.has(key);
672
- }
673
- delete(key) {
674
- return this.#store.delete(key);
675
- }
676
- get size() {
677
- return this.#store.size;
678
- }
679
- clear() {
680
- this.#store.clear();
681
+ // ../../lib/contract/src/aria/aria-role-policy.ts
682
+ function getImplicitRole(tag, props) {
683
+ if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
684
+ if (tag === "input") return getInputImplicitRole(props?.type);
685
+ if (tag === "img") return props?.alt === "" ? "none" : "img";
686
+ if (tag === "section" || tag === "form") {
687
+ return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
681
688
  }
682
- };
683
-
684
- // ../../lib/primitive/src/utils/merge-props.ts
685
- function mergeProps(defaultProps, props) {
686
- return {
687
- ...defaultProps ?? {},
688
- ...props
689
- };
689
+ return void 0;
690
690
  }
691
691
 
692
692
  // ../../lib/contract/src/diagnostics/aria.ts
@@ -2504,7 +2504,10 @@ function resolveFactoryOptions(options = {}) {
2504
2504
  const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
2505
2505
  return Object.freeze({
2506
2506
  defaultTag: options.tag ?? "div",
2507
- diagnostics: resolveDiagnostics(enforcement?.diagnostics, silentDiagnostics),
2507
+ diagnostics: resolveDiagnostics(
2508
+ enforcement?.diagnostics,
2509
+ options.diagnostics ?? silentDiagnostics
2510
+ ),
2508
2511
  variantKeys,
2509
2512
  ...whenDefined("displayName", options.name),
2510
2513
  ...whenDefined("defaultProps", options.defaults),
@@ -291,6 +291,11 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
291
291
  readonly normalize?: NormalizeFn<NoInfer<Props>>;
292
292
  readonly styling?: StylingOptions<V, TPreset, TPlugin>;
293
293
  readonly enforcement?: EnforcementOptions<TAllowed>;
294
+ /**
295
+ * Adapter-resolved diagnostics default, spread in by `resolveAdapterCommonOptions`. Not meant to
296
+ * be set directly by component authors — use `enforcement.diagnostics` to override per component.
297
+ */
298
+ readonly diagnostics?: Diagnostics;
294
299
  };
295
300
 
296
301
  type ResolvedFactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>> = {