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