praxis-kit 2.0.1 → 3.0.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/{chunk-ACAKUHH5.js → chunk-PBBPAHMV.js} +170 -164
- package/dist/contract/index.d.ts +21 -18
- package/dist/contract/index.js +2 -2
- package/dist/lit/index.d.ts +26 -23
- package/dist/lit/index.js +45 -45
- package/dist/{merge-refs-DxjWMq3U.d.ts → merge-refs-CfAbwCKz.d.ts} +28 -19
- package/dist/preact/index.d.ts +28 -21
- package/dist/preact/index.js +40 -40
- package/dist/react/index.d.ts +8 -10
- package/dist/react/index.js +2 -6
- package/dist/react/legacy.d.ts +7 -7
- package/dist/react/legacy.js +3 -1
- package/dist/solid/index.d.ts +29 -22
- package/dist/solid/index.js +40 -40
- package/dist/svelte/index.d.ts +33 -30
- package/dist/svelte/index.js +38 -38
- package/dist/tailwind/index.js +23 -23
- package/dist/vite-plugin/index.d.ts +76 -50
- package/dist/vite-plugin/index.js +146 -41
- package/dist/vue/index.d.ts +28 -21
- package/dist/vue/index.js +40 -40
- package/dist/web/index.d.ts +26 -23
- package/dist/web/index.js +43 -43
- package/package.json +1 -1
|
@@ -1,117 +1,6 @@
|
|
|
1
|
-
// ../../
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
if (active.length === 0) return null;
|
|
5
|
-
if (active.length === 1) return active[0];
|
|
6
|
-
return (value) => {
|
|
7
|
-
for (const ref of active) {
|
|
8
|
-
if (typeof ref === "function") {
|
|
9
|
-
ref(value);
|
|
10
|
-
} else {
|
|
11
|
-
ref.current = value;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// ../../adapters/react/src/shared/slot/Slottable.tsx
|
|
18
|
-
import { Fragment } from "react";
|
|
19
|
-
import { jsx } from "react/jsx-runtime";
|
|
20
|
-
function Slottable({ children }) {
|
|
21
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ../../lib/primitive/src/utils/is-object.ts
|
|
25
|
-
function isNull(value) {
|
|
26
|
-
return value === null;
|
|
27
|
-
}
|
|
28
|
-
function isObject(value) {
|
|
29
|
-
return !isNull(value) && typeof value === "object";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// ../../lib/primitive/src/merge/constants.ts
|
|
33
|
-
var EVENT_HANDLER_RE = /^on[A-Z]/;
|
|
34
|
-
|
|
35
|
-
// ../../lib/primitive/src/merge/predicates.ts
|
|
36
|
-
function isFunction(value) {
|
|
37
|
-
return typeof value === "function";
|
|
38
|
-
}
|
|
39
|
-
function isPlainObject(value) {
|
|
40
|
-
if (!isObject(value)) return false;
|
|
41
|
-
const proto = Object.getPrototypeOf(value);
|
|
42
|
-
return proto === Object.prototype || proto === null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ../shared/src/constants/primitive/slot-name.ts
|
|
46
|
-
var SLOT_NAME = "Slot";
|
|
47
|
-
|
|
48
|
-
// ../../adapters/react/src/shared/slot/clone.ts
|
|
49
|
-
import { cloneElement } from "react";
|
|
50
|
-
function cloneWithProps(child, props, ref) {
|
|
51
|
-
return cloneElement(child, ref !== null ? { ...props, ref } : props);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ../../adapters/react/src/shared/slot/invariant.ts
|
|
55
|
-
function panic(message) {
|
|
56
|
-
throw new Error(message);
|
|
57
|
-
}
|
|
58
|
-
function invariant(condition, message) {
|
|
59
|
-
if (!condition) panic(message);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// ../../adapters/react/src/shared/slot/applySlot.ts
|
|
63
|
-
import { isValidElement as isValidElement3 } from "react";
|
|
64
|
-
|
|
65
|
-
// ../../adapters/react/src/shared/slot/extractSlottable.ts
|
|
66
|
-
import { createElement, Fragment as Fragment2, isValidElement as isValidElement2 } from "react";
|
|
67
|
-
|
|
68
|
-
// ../../adapters/react/src/shared/slot/predicates.ts
|
|
69
|
-
import { isValidElement } from "react";
|
|
70
|
-
function isSlottableElement(value) {
|
|
71
|
-
return isValidElement(value) && value.type === Slottable;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// ../../adapters/react/src/shared/slot/extractSlottable.ts
|
|
75
|
-
function extractSlottable(children) {
|
|
76
|
-
const childrenArray = Array.isArray(children) ? children : [children];
|
|
77
|
-
const slottables = childrenArray.filter(isSlottableElement);
|
|
78
|
-
invariant(slottables.length <= 1, "Slot: multiple Slottable children are not allowed");
|
|
79
|
-
if (slottables.length === 0) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
const [slottable] = slottables;
|
|
83
|
-
invariant(slottable, "Missing Slottable element");
|
|
84
|
-
const child = slottable.props.children;
|
|
85
|
-
invariant(
|
|
86
|
-
child !== null && child !== void 0,
|
|
87
|
-
"Slottable expects exactly one React element child, received null"
|
|
88
|
-
);
|
|
89
|
-
invariant(
|
|
90
|
-
typeof child !== "string" && typeof child !== "number",
|
|
91
|
-
"Slottable expects exactly one React element child, received text content"
|
|
92
|
-
);
|
|
93
|
-
invariant(isValidElement2(child), "Slottable expects exactly one React element child");
|
|
94
|
-
invariant(child.type !== Fragment2, "Slottable child cannot be a Fragment");
|
|
95
|
-
const index = childrenArray.indexOf(slottable);
|
|
96
|
-
return {
|
|
97
|
-
child,
|
|
98
|
-
// Fragment wrapper: Slot owns no DOM node; ref composition happens only on the merge target.
|
|
99
|
-
rebuild(merged) {
|
|
100
|
-
const out = childrenArray.map((node, i) => i === index ? merged : node);
|
|
101
|
-
return createElement(Fragment2, null, ...out);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// ../../adapters/react/src/shared/slot/applySlot.ts
|
|
107
|
-
function applySlot(children, slotProps, ref, cloneSlotChild) {
|
|
108
|
-
const extraction = extractSlottable(children);
|
|
109
|
-
if (extraction) {
|
|
110
|
-
const merged = cloneSlotChild({ child: extraction.child, slotProps, ref });
|
|
111
|
-
return extraction.rebuild(merged);
|
|
112
|
-
}
|
|
113
|
-
invariant(isValidElement3(children), "Slot: child must be a valid React element");
|
|
114
|
-
return cloneSlotChild({ child: children, slotProps, ref });
|
|
1
|
+
// ../../lib/adapter-utils/src/define-component.ts
|
|
2
|
+
function defineContractComponent(options) {
|
|
3
|
+
return (factory) => factory(options);
|
|
115
4
|
}
|
|
116
5
|
|
|
117
6
|
// ../../lib/adapter-utils/src/apply-filter.ts
|
|
@@ -125,7 +14,7 @@ function applyFilter(props, filterProps, variantKeys) {
|
|
|
125
14
|
return out;
|
|
126
15
|
}
|
|
127
16
|
|
|
128
|
-
// ../core/dist/chunk-
|
|
17
|
+
// ../core/dist/chunk-KKSHJDE7.js
|
|
129
18
|
function makeResolveTag(defaultTag) {
|
|
130
19
|
return function tag(as) {
|
|
131
20
|
return as ?? defaultTag;
|
|
@@ -156,11 +45,11 @@ function mergeProps(defaultProps, props) {
|
|
|
156
45
|
...props
|
|
157
46
|
};
|
|
158
47
|
}
|
|
159
|
-
function
|
|
48
|
+
function isNull(value) {
|
|
160
49
|
return value === null;
|
|
161
50
|
}
|
|
162
|
-
function
|
|
163
|
-
return !
|
|
51
|
+
function isObject(value) {
|
|
52
|
+
return !isNull(value) && typeof value === "object";
|
|
164
53
|
}
|
|
165
54
|
function isString(value) {
|
|
166
55
|
return typeof value === "string";
|
|
@@ -194,7 +83,7 @@ function resolveFactoryOptions(options = {}) {
|
|
|
194
83
|
...whenDefined("defaultProps", options.defaults),
|
|
195
84
|
...whenDefined("baseClassName", styling?.base),
|
|
196
85
|
...whenDefined("tagMap", styling?.tags),
|
|
197
|
-
...whenDefined("
|
|
86
|
+
...whenDefined("recipeMap", styling?.presets),
|
|
198
87
|
...whenDefined("variants", styling?.variants),
|
|
199
88
|
...whenDefined("defaultVariants", styling?.defaults),
|
|
200
89
|
...whenDefined("compoundVariants", styling?.compounds),
|
|
@@ -235,10 +124,10 @@ function validateFactoryOptions(resolved) {
|
|
|
235
124
|
}
|
|
236
125
|
}
|
|
237
126
|
};
|
|
238
|
-
const {
|
|
239
|
-
if (
|
|
240
|
-
for (const
|
|
241
|
-
checkSelection(`preset "${
|
|
127
|
+
const { recipeMap } = resolved;
|
|
128
|
+
if (recipeMap) {
|
|
129
|
+
for (const recipeKey in recipeMap) {
|
|
130
|
+
checkSelection(`preset "${recipeKey}"`, recipeMap[recipeKey]);
|
|
242
131
|
}
|
|
243
132
|
}
|
|
244
133
|
if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
|
|
@@ -274,12 +163,12 @@ function report2(strict, message) {
|
|
|
274
163
|
function label(name) {
|
|
275
164
|
return name ? `[${name}]` : "[createContractComponent]";
|
|
276
165
|
}
|
|
277
|
-
function validateRenderProps(options, props,
|
|
278
|
-
const { strict,
|
|
166
|
+
function validateRenderProps(options, props, recipeKey) {
|
|
167
|
+
const { strict, recipeMap, variants, displayName } = options;
|
|
279
168
|
if (!strict) return;
|
|
280
169
|
const tag = label(displayName);
|
|
281
|
-
if (
|
|
282
|
-
report2(strict, `${tag} Unknown
|
|
170
|
+
if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
|
|
171
|
+
report2(strict, `${tag} Unknown recipeKey "${recipeKey}" \u2014 no preset with that name exists.`);
|
|
283
172
|
}
|
|
284
173
|
if (variants) {
|
|
285
174
|
for (const key in variants) {
|
|
@@ -296,7 +185,7 @@ function validateRenderProps(options, props, presetKey) {
|
|
|
296
185
|
}
|
|
297
186
|
}
|
|
298
187
|
}
|
|
299
|
-
function
|
|
188
|
+
function panic(message) {
|
|
300
189
|
throw new Error(message);
|
|
301
190
|
}
|
|
302
191
|
function describe(value) {
|
|
@@ -306,21 +195,21 @@ function describe(value) {
|
|
|
306
195
|
}
|
|
307
196
|
function assertPluginShape(result) {
|
|
308
197
|
if (result === null || typeof result !== "object")
|
|
309
|
-
|
|
198
|
+
panic(
|
|
310
199
|
`[praxis-kit] Plugin factory must return an object with a 'pipeline' function. Got: ${result === null ? "null" : typeof result}.`
|
|
311
200
|
);
|
|
312
201
|
const plugin = result;
|
|
313
202
|
if (typeof plugin.pipeline !== "function")
|
|
314
|
-
|
|
203
|
+
panic(
|
|
315
204
|
`[praxis-kit] Plugin factory return value is missing a 'pipeline' function. Got pipeline: ${typeof plugin.pipeline}.`
|
|
316
205
|
);
|
|
317
206
|
}
|
|
318
207
|
function guardPipeline(pipeline) {
|
|
319
208
|
if (process.env.NODE_ENV === "production") return pipeline;
|
|
320
|
-
return function guardedPipeline(tag, props, className,
|
|
321
|
-
const result = pipeline(tag, props, className,
|
|
209
|
+
return function guardedPipeline(tag, props, className, recipe) {
|
|
210
|
+
const result = pipeline(tag, props, className, recipe);
|
|
322
211
|
if (typeof result !== "string")
|
|
323
|
-
|
|
212
|
+
panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
|
|
324
213
|
return result;
|
|
325
214
|
};
|
|
326
215
|
}
|
|
@@ -343,11 +232,11 @@ function createRuntimeMethods(resolved, classPipeline, engine) {
|
|
|
343
232
|
resolveProps(props) {
|
|
344
233
|
return mergeProps(resolved.defaultProps, props);
|
|
345
234
|
},
|
|
346
|
-
resolveClasses(tag, props, className,
|
|
235
|
+
resolveClasses(tag, props, className, recipe) {
|
|
347
236
|
if (process.env.NODE_ENV !== "production") {
|
|
348
|
-
validateRenderProps(resolved, props,
|
|
237
|
+
validateRenderProps(resolved, props, recipe);
|
|
349
238
|
}
|
|
350
|
-
return classPipeline(tag, props, className,
|
|
239
|
+
return classPipeline(tag, props, className, recipe);
|
|
351
240
|
},
|
|
352
241
|
resolveAria(tag, props) {
|
|
353
242
|
if (!engine) return { props };
|
|
@@ -696,7 +585,7 @@ function isKnownAriaRole(value) {
|
|
|
696
585
|
return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
|
|
697
586
|
}
|
|
698
587
|
|
|
699
|
-
// ../core/dist/chunk-
|
|
588
|
+
// ../core/dist/chunk-BNVYTMYV.js
|
|
700
589
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
701
590
|
article: "article",
|
|
702
591
|
aside: "complementary",
|
|
@@ -727,14 +616,14 @@ function getImplicitRole(tag) {
|
|
|
727
616
|
}
|
|
728
617
|
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol("praxis.component-default-tag");
|
|
729
618
|
function resolveChildTag(child) {
|
|
730
|
-
if (!
|
|
619
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
731
620
|
const t = child.type;
|
|
732
621
|
if (isString(t)) return t;
|
|
733
|
-
if (
|
|
622
|
+
if (isObject(t) && COMPONENT_DEFAULT_TAG in t) {
|
|
734
623
|
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
735
624
|
if (!isString(defaultTag)) return void 0;
|
|
736
625
|
const props = child.props;
|
|
737
|
-
const as =
|
|
626
|
+
const as = isObject(props) && "as" in props ? props.as : void 0;
|
|
738
627
|
return isString(as) ? as : defaultTag;
|
|
739
628
|
}
|
|
740
629
|
return void 0;
|
|
@@ -791,7 +680,7 @@ var StrictBase = class {
|
|
|
791
680
|
}
|
|
792
681
|
}
|
|
793
682
|
};
|
|
794
|
-
function
|
|
683
|
+
function isNull2(value) {
|
|
795
684
|
return value === null;
|
|
796
685
|
}
|
|
797
686
|
var VALID = [{ valid: true }];
|
|
@@ -946,7 +835,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends StrictBase {
|
|
|
946
835
|
}
|
|
947
836
|
validate(tag, props) {
|
|
948
837
|
const key = _AriaPolicyEngine.#createPlanKey(tag, props);
|
|
949
|
-
if (!
|
|
838
|
+
if (!isNull2(key)) {
|
|
950
839
|
const cached = this.#planCache.get(key);
|
|
951
840
|
if (cached !== void 0) {
|
|
952
841
|
this.#planCache.delete(key);
|
|
@@ -960,7 +849,7 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends StrictBase {
|
|
|
960
849
|
}
|
|
961
850
|
const result = this.#extraRules.length ? _AriaPolicyEngine.#evaluateWithRules(tag, props, this.#extraRules) : _AriaPolicyEngine.evaluate(tag, props);
|
|
962
851
|
if (result.violations.length > 0) this.report(result.violations);
|
|
963
|
-
if (!
|
|
852
|
+
if (!isNull2(key)) {
|
|
964
853
|
const { removals, updates } = _AriaPolicyEngine.#computePlan(
|
|
965
854
|
props,
|
|
966
855
|
result.props
|
|
@@ -1243,7 +1132,7 @@ function normalizeChildRule(rule) {
|
|
|
1243
1132
|
};
|
|
1244
1133
|
}
|
|
1245
1134
|
function getChildType(child) {
|
|
1246
|
-
if (!
|
|
1135
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
1247
1136
|
return child.type;
|
|
1248
1137
|
}
|
|
1249
1138
|
function buildPartialIndex(rules) {
|
|
@@ -1553,7 +1442,7 @@ function landmarkRoleRule({ tag, props, implicitRole }) {
|
|
|
1553
1442
|
var HTML_ARIA_RULES = [landmarkRoleRule];
|
|
1554
1443
|
function isOpenContent(...blockedTags) {
|
|
1555
1444
|
const set = new Set(blockedTags);
|
|
1556
|
-
return (child) =>
|
|
1445
|
+
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set.has(child.type));
|
|
1557
1446
|
}
|
|
1558
1447
|
var METADATA_TAGS = ["script", "template"];
|
|
1559
1448
|
var metadataMatch = isTag(...METADATA_TAGS);
|
|
@@ -1721,7 +1610,7 @@ function enforceAllowedAs(tag, allowedAs, strict, displayName) {
|
|
|
1721
1610
|
}
|
|
1722
1611
|
}
|
|
1723
1612
|
|
|
1724
|
-
// ../core/dist/chunk-
|
|
1613
|
+
// ../core/dist/chunk-3T4EM5FG.js
|
|
1725
1614
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
1726
1615
|
var cx = clsx;
|
|
1727
1616
|
var cva = (base, config) => (props) => {
|
|
@@ -1798,18 +1687,18 @@ var StaticClassResolver = class {
|
|
|
1798
1687
|
};
|
|
1799
1688
|
var VariantClassResolver = class _VariantClassResolver {
|
|
1800
1689
|
#cvaFn;
|
|
1801
|
-
#
|
|
1690
|
+
#recipeMap;
|
|
1802
1691
|
#variantKeys;
|
|
1803
1692
|
#precomputedClasses;
|
|
1804
1693
|
#cache = /* @__PURE__ */ new Map();
|
|
1805
|
-
constructor(cvaFn,
|
|
1694
|
+
constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
|
|
1806
1695
|
this.#cvaFn = cvaFn ?? null;
|
|
1807
|
-
this.#
|
|
1696
|
+
this.#recipeMap = Object.freeze(recipeMap ?? {});
|
|
1808
1697
|
this.#variantKeys = variantKeys ?? null;
|
|
1809
1698
|
this.#precomputedClasses = precomputedClasses ?? null;
|
|
1810
1699
|
}
|
|
1811
|
-
resolve({ props,
|
|
1812
|
-
const normalizedKey =
|
|
1700
|
+
resolve({ props, recipe }) {
|
|
1701
|
+
const normalizedKey = recipe ?? "__none__";
|
|
1813
1702
|
const cacheKey = this.#createCacheKey(props, normalizedKey);
|
|
1814
1703
|
if (this.#precomputedClasses !== null) {
|
|
1815
1704
|
const precomputed = this.#precomputedClasses[cacheKey];
|
|
@@ -1821,7 +1710,7 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1821
1710
|
this.#cache.set(cacheKey, cached);
|
|
1822
1711
|
return cached;
|
|
1823
1712
|
}
|
|
1824
|
-
const result = this.#compute(props,
|
|
1713
|
+
const result = this.#compute(props, recipe);
|
|
1825
1714
|
this.#cache.set(cacheKey, result);
|
|
1826
1715
|
if (this.#cache.size > 1e3) {
|
|
1827
1716
|
const lru = this.#cache.keys().next().value;
|
|
@@ -1829,10 +1718,10 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1829
1718
|
}
|
|
1830
1719
|
return result;
|
|
1831
1720
|
}
|
|
1832
|
-
#compute(props,
|
|
1721
|
+
#compute(props, recipe) {
|
|
1833
1722
|
if (!this.#cvaFn) return "";
|
|
1834
|
-
if (!
|
|
1835
|
-
const preset = this.#
|
|
1723
|
+
if (!recipe) return this.#cvaFn(props);
|
|
1724
|
+
const preset = this.#recipeMap[recipe];
|
|
1836
1725
|
if (!preset) return this.#cvaFn(props);
|
|
1837
1726
|
return this.#cvaFn({ ...preset, ...props });
|
|
1838
1727
|
}
|
|
@@ -1840,15 +1729,15 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1840
1729
|
// props (className, id, etc.) produce identical CVA output and must not fragment the cache.
|
|
1841
1730
|
// Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
|
|
1842
1731
|
// String is built incrementally to avoid a parts[] array allocation on every render.
|
|
1843
|
-
#createCacheKey(props,
|
|
1732
|
+
#createCacheKey(props, recipe) {
|
|
1844
1733
|
if (this.#variantKeys !== null) {
|
|
1845
|
-
let key2 =
|
|
1734
|
+
let key2 = recipe;
|
|
1846
1735
|
for (const k of this.#variantKeys) {
|
|
1847
1736
|
if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1848
1737
|
}
|
|
1849
1738
|
return key2;
|
|
1850
1739
|
}
|
|
1851
|
-
let key =
|
|
1740
|
+
let key = recipe;
|
|
1852
1741
|
for (const k of Object.keys(props).sort()) {
|
|
1853
1742
|
key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1854
1743
|
}
|
|
@@ -1873,13 +1762,13 @@ function createClassPipeline(resolved) {
|
|
|
1873
1762
|
const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
|
|
1874
1763
|
const variantResolver = new VariantClassResolver(
|
|
1875
1764
|
cvaFn,
|
|
1876
|
-
resolved.
|
|
1765
|
+
resolved.recipeMap,
|
|
1877
1766
|
variantKeys,
|
|
1878
1767
|
resolved.precomputedClasses
|
|
1879
1768
|
);
|
|
1880
|
-
return function resolveClasses(tag, props, className,
|
|
1881
|
-
const staticClasses = staticResolver.resolve(tag,
|
|
1882
|
-
const variantClasses = variantResolver.resolve({ props,
|
|
1769
|
+
return function resolveClasses(tag, props, className, recipe) {
|
|
1770
|
+
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
1771
|
+
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
1883
1772
|
if (!className)
|
|
1884
1773
|
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
1885
1774
|
return cn(staticClasses, variantClasses, className);
|
|
@@ -1951,6 +1840,30 @@ var SlotValidator = class extends StrictBase {
|
|
|
1951
1840
|
}
|
|
1952
1841
|
};
|
|
1953
1842
|
|
|
1843
|
+
// ../../lib/primitive/src/utils/is-object.ts
|
|
1844
|
+
function isNull3(value) {
|
|
1845
|
+
return value === null;
|
|
1846
|
+
}
|
|
1847
|
+
function isObject2(value) {
|
|
1848
|
+
return !isNull3(value) && typeof value === "object";
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
// ../../lib/primitive/src/merge/constants.ts
|
|
1852
|
+
var EVENT_HANDLER_RE = /^on[A-Z]/;
|
|
1853
|
+
|
|
1854
|
+
// ../../lib/primitive/src/merge/predicates.ts
|
|
1855
|
+
function isFunction(value) {
|
|
1856
|
+
return typeof value === "function";
|
|
1857
|
+
}
|
|
1858
|
+
function isPlainObject(value) {
|
|
1859
|
+
if (!isObject2(value)) return false;
|
|
1860
|
+
const proto = Object.getPrototypeOf(value);
|
|
1861
|
+
return proto === Object.prototype || proto === null;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
// ../shared/src/constants/primitive/slot-name.ts
|
|
1865
|
+
var SLOT_NAME = "Slot";
|
|
1866
|
+
|
|
1954
1867
|
// ../../lib/adapter-utils/src/slot/policies.ts
|
|
1955
1868
|
import { clsx as clsx2 } from "clsx";
|
|
1956
1869
|
function chainHandlers(childHandler, slotHandler) {
|
|
@@ -1995,6 +1908,98 @@ function applyMergePolicy(key, slotVal, childVal) {
|
|
|
1995
1908
|
return policyHandlers[classifyProp(key, slotVal, childVal)](slotVal, childVal);
|
|
1996
1909
|
}
|
|
1997
1910
|
|
|
1911
|
+
// ../../adapters/react/src/shared/merge-refs.ts
|
|
1912
|
+
function mergeRefs(...refs) {
|
|
1913
|
+
const active = refs.filter((r2) => r2 != null);
|
|
1914
|
+
if (active.length === 0) return null;
|
|
1915
|
+
if (active.length === 1) return active[0];
|
|
1916
|
+
return (value) => {
|
|
1917
|
+
for (const ref of active) {
|
|
1918
|
+
if (typeof ref === "function") {
|
|
1919
|
+
ref(value);
|
|
1920
|
+
} else {
|
|
1921
|
+
ref.current = value;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
// ../../adapters/react/src/shared/slot/Slottable.tsx
|
|
1928
|
+
import { Fragment } from "react";
|
|
1929
|
+
import { jsx } from "react/jsx-runtime";
|
|
1930
|
+
function Slottable({ children }) {
|
|
1931
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
// ../../adapters/react/src/shared/slot/clone.ts
|
|
1935
|
+
import { cloneElement } from "react";
|
|
1936
|
+
function cloneWithProps(child, props, ref) {
|
|
1937
|
+
return cloneElement(child, ref !== null ? { ...props, ref } : props);
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
// ../../adapters/react/src/shared/slot/invariant.ts
|
|
1941
|
+
function panic2(message) {
|
|
1942
|
+
throw new Error(message);
|
|
1943
|
+
}
|
|
1944
|
+
function invariant(condition, message) {
|
|
1945
|
+
if (!condition) panic2(message);
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
// ../../adapters/react/src/shared/slot/applySlot.ts
|
|
1949
|
+
import { isValidElement as isValidElement3 } from "react";
|
|
1950
|
+
|
|
1951
|
+
// ../../adapters/react/src/shared/slot/extractSlottable.ts
|
|
1952
|
+
import { createElement, Fragment as Fragment2, isValidElement as isValidElement2 } from "react";
|
|
1953
|
+
|
|
1954
|
+
// ../../adapters/react/src/shared/slot/predicates.ts
|
|
1955
|
+
import { isValidElement } from "react";
|
|
1956
|
+
function isSlottableElement(value) {
|
|
1957
|
+
return isValidElement(value) && value.type === Slottable;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
// ../../adapters/react/src/shared/slot/extractSlottable.ts
|
|
1961
|
+
function extractSlottable(children) {
|
|
1962
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
1963
|
+
const slottables = childrenArray.filter(isSlottableElement);
|
|
1964
|
+
invariant(slottables.length <= 1, "Slot: multiple Slottable children are not allowed");
|
|
1965
|
+
if (slottables.length === 0) {
|
|
1966
|
+
return null;
|
|
1967
|
+
}
|
|
1968
|
+
const [slottable] = slottables;
|
|
1969
|
+
invariant(slottable, "Missing Slottable element");
|
|
1970
|
+
const child = slottable.props.children;
|
|
1971
|
+
invariant(
|
|
1972
|
+
child !== null && child !== void 0,
|
|
1973
|
+
"Slottable expects exactly one React element child, received null"
|
|
1974
|
+
);
|
|
1975
|
+
invariant(
|
|
1976
|
+
typeof child !== "string" && typeof child !== "number",
|
|
1977
|
+
"Slottable expects exactly one React element child, received text content"
|
|
1978
|
+
);
|
|
1979
|
+
invariant(isValidElement2(child), "Slottable expects exactly one React element child");
|
|
1980
|
+
invariant(child.type !== Fragment2, "Slottable child cannot be a Fragment");
|
|
1981
|
+
const index = childrenArray.indexOf(slottable);
|
|
1982
|
+
return {
|
|
1983
|
+
child,
|
|
1984
|
+
// Fragment wrapper: Slot owns no DOM node; ref composition happens only on the merge target.
|
|
1985
|
+
rebuild(merged) {
|
|
1986
|
+
const out = childrenArray.map((node, i) => i === index ? merged : node);
|
|
1987
|
+
return createElement(Fragment2, null, ...out);
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
// ../../adapters/react/src/shared/slot/applySlot.ts
|
|
1993
|
+
function applySlot(children, slotProps, ref, cloneSlotChild) {
|
|
1994
|
+
const extraction = extractSlottable(children);
|
|
1995
|
+
if (extraction) {
|
|
1996
|
+
const merged = cloneSlotChild({ child: extraction.child, slotProps, ref });
|
|
1997
|
+
return extraction.rebuild(merged);
|
|
1998
|
+
}
|
|
1999
|
+
invariant(isValidElement3(children), "Slot: child must be a valid React element");
|
|
2000
|
+
return cloneSlotChild({ child: children, slotProps, ref });
|
|
2001
|
+
}
|
|
2002
|
+
|
|
1998
2003
|
// ../../adapters/react/src/shared/slot/slot-validator.ts
|
|
1999
2004
|
var SlotValidator2 = class extends SlotValidator {
|
|
2000
2005
|
constructor(name, strict) {
|
|
@@ -2058,7 +2063,7 @@ function buildRenderState(tag, directives, props, className, children) {
|
|
|
2058
2063
|
return state;
|
|
2059
2064
|
}
|
|
2060
2065
|
function resolveRenderState(runtime, props, filterProps) {
|
|
2061
|
-
const { as, asChild, render: _render, children, className,
|
|
2066
|
+
const { as, asChild, render: _render, children, className, recipe, ...rest } = props;
|
|
2062
2067
|
const tag = runtime.resolveTag(as);
|
|
2063
2068
|
if (runtime.options.allowedAs !== void 0 && as !== void 0) {
|
|
2064
2069
|
enforceAllowedAs(
|
|
@@ -2072,7 +2077,7 @@ function resolveRenderState(runtime, props, filterProps) {
|
|
|
2072
2077
|
const baseProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(mergedProps) : mergedProps;
|
|
2073
2078
|
const htmlNormalizers = runtime.options.htmlPropNormalizersFn?.(tag);
|
|
2074
2079
|
const normalizedProps = htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), baseProps) : baseProps;
|
|
2075
|
-
const resolvedClass = runtime.resolveClasses(tag, normalizedProps, className,
|
|
2080
|
+
const resolvedClass = runtime.resolveClasses(tag, normalizedProps, className, recipe);
|
|
2076
2081
|
const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
|
|
2077
2082
|
return buildRenderState(tag, buildDirectives(as, asChild), filteredProps, resolvedClass, children);
|
|
2078
2083
|
}
|
|
@@ -2186,6 +2191,7 @@ function createContractedPolymorphic(options = {}) {
|
|
|
2186
2191
|
export {
|
|
2187
2192
|
createPolymorphic,
|
|
2188
2193
|
createContractedPolymorphic,
|
|
2194
|
+
defineContractComponent,
|
|
2189
2195
|
buildEngines,
|
|
2190
2196
|
composeFilter,
|
|
2191
2197
|
isFunction,
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
|
11
11
|
|
|
12
12
|
type AriaRole = KnownAriaRole | (string & {});
|
|
13
13
|
|
|
14
|
+
type Booleanish = boolean | 'true' | 'false';
|
|
15
|
+
|
|
14
16
|
type ClassName = string | string[];
|
|
15
17
|
|
|
16
18
|
type EmptyRecord = Record<never, never>;
|
|
@@ -21,6 +23,10 @@ type IntrinsicProps = AnyRecord & {
|
|
|
21
23
|
|
|
22
24
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
23
25
|
|
|
26
|
+
type Numberish = number | `${number}`;
|
|
27
|
+
|
|
28
|
+
type Primitive = string | number | boolean;
|
|
29
|
+
|
|
24
30
|
type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
|
|
25
31
|
|
|
26
32
|
type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
|
|
@@ -53,9 +59,9 @@ type ValidResult = {
|
|
|
53
59
|
|
|
54
60
|
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
55
61
|
|
|
56
|
-
type VariantValue = string | string[];
|
|
62
|
+
type VariantValue$1 = string | string[];
|
|
57
63
|
|
|
58
|
-
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
64
|
+
type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
|
|
59
65
|
|
|
60
66
|
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
61
67
|
|
|
@@ -69,19 +75,16 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
|
69
75
|
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
70
76
|
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
71
77
|
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
72
|
-
class: VariantValue;
|
|
78
|
+
class: VariantValue$1;
|
|
73
79
|
};
|
|
74
80
|
|
|
75
81
|
interface CVACompounds<V extends VariantMap> {
|
|
76
82
|
compoundVariants?: readonly CompoundVariant<V>[];
|
|
77
83
|
}
|
|
78
84
|
|
|
79
|
-
|
|
80
|
-
type VariantProps<V extends VariantMap> = {
|
|
81
|
-
[K in keyof V]?: VariantKey<V, K>;
|
|
82
|
-
};
|
|
85
|
+
type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
83
86
|
type DefaultVariants<V extends VariantMap> = {
|
|
84
|
-
[K in keyof V]?:
|
|
87
|
+
[K in keyof V]?: VariantValue<keyof V[K] & string>;
|
|
85
88
|
};
|
|
86
89
|
|
|
87
90
|
interface CVADefaults<V extends VariantMap> {
|
|
@@ -108,25 +111,25 @@ type VariantSelection<V extends VariantMap> = {
|
|
|
108
111
|
* Presets are named bundles of variant props that callers activate by key,
|
|
109
112
|
* avoiding the need to repeat variant combinations at each call site.
|
|
110
113
|
*/
|
|
111
|
-
type
|
|
114
|
+
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
112
115
|
|
|
113
|
-
type
|
|
116
|
+
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
114
117
|
|
|
115
118
|
interface BaseClassOptions {
|
|
116
119
|
baseClassName?: ClassName;
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName,
|
|
122
|
+
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
|
|
120
123
|
|
|
121
|
-
interface
|
|
122
|
-
|
|
124
|
+
interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
|
|
125
|
+
recipeMap?: Record<string, RecipeTarget<TVariants>>;
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
interface TagMapOptions {
|
|
126
129
|
tagMap?: TagMap;
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions &
|
|
132
|
+
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
|
|
130
133
|
|
|
131
134
|
type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
|
|
132
135
|
|
|
@@ -201,10 +204,10 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
201
204
|
readonly allowedAs?: readonly TAllowed[];
|
|
202
205
|
};
|
|
203
206
|
|
|
204
|
-
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
207
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
|
|
205
208
|
readonly base?: ClassName;
|
|
206
209
|
readonly variants?: V;
|
|
207
|
-
readonly defaults?: Partial<
|
|
210
|
+
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
208
211
|
readonly compounds?: readonly CompoundVariant<V>[];
|
|
209
212
|
readonly presets?: TPreset;
|
|
210
213
|
readonly tags?: Readonly<TagMap>;
|
|
@@ -215,8 +218,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
215
218
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
216
219
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
217
220
|
}['normalize'];
|
|
218
|
-
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap,
|
|
219
|
-
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
221
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyRecord>;
|
|
222
|
+
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
|
|
220
223
|
readonly tag?: TDefault;
|
|
221
224
|
readonly name?: string;
|
|
222
225
|
readonly defaults?: Partial<NoInfer<Props>>;
|
package/dist/contract/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../core/dist/chunk-
|
|
1
|
+
// ../core/dist/chunk-KKSHJDE7.js
|
|
2
2
|
function assertNever(value) {
|
|
3
3
|
throw new Error(`Unexpected value: ${String(value)}`);
|
|
4
4
|
}
|
|
@@ -321,7 +321,7 @@ function isStandaloneTag(tag) {
|
|
|
321
321
|
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
// ../core/dist/chunk-
|
|
324
|
+
// ../core/dist/chunk-BNVYTMYV.js
|
|
325
325
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
326
326
|
article: "article",
|
|
327
327
|
aside: "complementary",
|