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
package/dist/preact/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
|
12
12
|
|
|
13
13
|
type AriaRole = KnownAriaRole | (string & {});
|
|
14
14
|
|
|
15
|
+
type Booleanish = boolean | 'true' | 'false';
|
|
16
|
+
|
|
15
17
|
type ClassName = string | string[];
|
|
16
18
|
|
|
17
19
|
type EmptyRecord = Record<never, never>;
|
|
@@ -22,6 +24,10 @@ type IntrinsicProps = AnyRecord & {
|
|
|
22
24
|
|
|
23
25
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
24
26
|
|
|
27
|
+
type Numberish = number | `${number}`;
|
|
28
|
+
|
|
29
|
+
type Primitive = string | number | boolean;
|
|
30
|
+
|
|
25
31
|
type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
|
|
26
32
|
|
|
27
33
|
type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
|
|
@@ -54,9 +60,9 @@ type ValidResult = {
|
|
|
54
60
|
|
|
55
61
|
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
56
62
|
|
|
57
|
-
type VariantValue = string | string[];
|
|
63
|
+
type VariantValue$1 = string | string[];
|
|
58
64
|
|
|
59
|
-
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
65
|
+
type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
|
|
60
66
|
|
|
61
67
|
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
62
68
|
|
|
@@ -70,7 +76,7 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
|
70
76
|
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
71
77
|
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
72
78
|
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
73
|
-
class: VariantValue;
|
|
79
|
+
class: VariantValue$1;
|
|
74
80
|
};
|
|
75
81
|
|
|
76
82
|
interface CVACompounds<V extends VariantMap> {
|
|
@@ -81,8 +87,9 @@ interface CVACompounds<V extends VariantMap> {
|
|
|
81
87
|
type VariantProps<V extends VariantMap> = {
|
|
82
88
|
[K in keyof V]?: VariantKey<V, K>;
|
|
83
89
|
};
|
|
90
|
+
type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
84
91
|
type DefaultVariants<V extends VariantMap> = {
|
|
85
|
-
[K in keyof V]?:
|
|
92
|
+
[K in keyof V]?: VariantValue<keyof V[K] & string>;
|
|
86
93
|
};
|
|
87
94
|
|
|
88
95
|
interface CVADefaults<V extends VariantMap> {
|
|
@@ -109,9 +116,9 @@ type VariantSelection<V extends VariantMap> = {
|
|
|
109
116
|
* Presets are named bundles of variant props that callers activate by key,
|
|
110
117
|
* avoiding the need to repeat variant combinations at each call site.
|
|
111
118
|
*/
|
|
112
|
-
type
|
|
119
|
+
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
113
120
|
|
|
114
|
-
interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props extends AnyRecord = AnyRecord, Variants extends Readonly<VariantMap> = Readonly<VariantMap>, TPreset extends
|
|
121
|
+
interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props extends AnyRecord = AnyRecord, Variants extends Readonly<VariantMap> = Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TAllowed extends ElementType = ElementType> {
|
|
115
122
|
default: TDefault;
|
|
116
123
|
props: Props;
|
|
117
124
|
variants: Variants;
|
|
@@ -119,25 +126,25 @@ interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props
|
|
|
119
126
|
allowed: TAllowed;
|
|
120
127
|
}
|
|
121
128
|
type VariantsOf<T extends PolymorphicGenerics> = T['variants'];
|
|
122
|
-
type
|
|
129
|
+
type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
|
|
123
130
|
|
|
124
|
-
type
|
|
131
|
+
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
125
132
|
|
|
126
133
|
interface BaseClassOptions {
|
|
127
134
|
baseClassName?: ClassName;
|
|
128
135
|
}
|
|
129
136
|
|
|
130
|
-
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName,
|
|
137
|
+
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
|
|
131
138
|
|
|
132
|
-
interface
|
|
133
|
-
|
|
139
|
+
interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
|
|
140
|
+
recipeMap?: Record<string, RecipeTarget<TVariants>>;
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
interface TagMapOptions {
|
|
137
144
|
tagMap?: TagMap;
|
|
138
145
|
}
|
|
139
146
|
|
|
140
|
-
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions &
|
|
147
|
+
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
|
|
141
148
|
|
|
142
149
|
type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
|
|
143
150
|
|
|
@@ -212,10 +219,10 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
212
219
|
readonly allowedAs?: readonly TAllowed[];
|
|
213
220
|
};
|
|
214
221
|
|
|
215
|
-
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
222
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
|
|
216
223
|
readonly base?: ClassName;
|
|
217
224
|
readonly variants?: V;
|
|
218
|
-
readonly defaults?: Partial<
|
|
225
|
+
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
219
226
|
readonly compounds?: readonly CompoundVariant<V>[];
|
|
220
227
|
readonly presets?: TPreset;
|
|
221
228
|
readonly tags?: Readonly<TagMap>;
|
|
@@ -226,8 +233,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
226
233
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
227
234
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
228
235
|
}['normalize'];
|
|
229
|
-
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap,
|
|
230
|
-
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
236
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyRecord>;
|
|
237
|
+
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> = {
|
|
231
238
|
readonly tag?: TDefault;
|
|
232
239
|
readonly name?: string;
|
|
233
240
|
readonly defaults?: Partial<NoInfer<Props>>;
|
|
@@ -239,11 +246,13 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
|
|
|
239
246
|
type DefaultOf<T extends PolymorphicGenerics> = T['default'];
|
|
240
247
|
type PropsOf<T extends PolymorphicGenerics> = T['props'];
|
|
241
248
|
|
|
249
|
+
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
250
|
+
|
|
242
251
|
type UnknownProps = Record<string, unknown>;
|
|
243
252
|
type SlotComponent = ComponentType<UnknownProps>;
|
|
244
253
|
type AnyVNode = VNode<any>;
|
|
245
254
|
|
|
246
|
-
type PreactFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends
|
|
255
|
+
type PreactFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = FactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps> & {
|
|
247
256
|
/** Component used to render the asChild slot. Defaults to the built-in Slot. */
|
|
248
257
|
slotComponent?: SlotComponent;
|
|
249
258
|
/**
|
|
@@ -258,7 +267,7 @@ type IntrinsicJSXProps<T extends ElementType> = T extends IntrinsicTag ? JSX.Int
|
|
|
258
267
|
type ControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = OmitIndexSignature<PropsOf<G>> & OmitIndexSignature<VariantProps<VariantsOf<G>>> & {
|
|
259
268
|
as?: TAs;
|
|
260
269
|
className?: ClassName | undefined;
|
|
261
|
-
|
|
270
|
+
recipe?: keyof RecipeOf<G>;
|
|
262
271
|
ref?: Ref<ElementRef<TAs>>;
|
|
263
272
|
};
|
|
264
273
|
type SharedProps<G extends PolymorphicGenerics, TAs extends ElementType> = Omit<IntrinsicJSXProps<TAs>, keyof ControlProps<G, TAs> | 'children'> & ControlProps<G, TAs>;
|
|
@@ -277,9 +286,7 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
|
|
|
277
286
|
displayName?: string;
|
|
278
287
|
};
|
|
279
288
|
|
|
280
|
-
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
281
|
-
|
|
282
|
-
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
289
|
+
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: PreactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
283
290
|
|
|
284
291
|
type SlottableProps = {
|
|
285
292
|
children?: ComponentChildren;
|
package/dist/preact/index.js
CHANGED
|
@@ -49,7 +49,12 @@ function applyFilter(props, filterProps, variantKeys) {
|
|
|
49
49
|
return out;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
//
|
|
52
|
+
// ../../lib/adapter-utils/src/define-component.ts
|
|
53
|
+
function defineContractComponent(options) {
|
|
54
|
+
return (factory) => factory(options);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ../core/dist/chunk-KKSHJDE7.js
|
|
53
58
|
function makeResolveTag(defaultTag) {
|
|
54
59
|
return function tag(as) {
|
|
55
60
|
return as ?? defaultTag;
|
|
@@ -118,7 +123,7 @@ function resolveFactoryOptions(options = {}) {
|
|
|
118
123
|
...whenDefined("defaultProps", options.defaults),
|
|
119
124
|
...whenDefined("baseClassName", styling?.base),
|
|
120
125
|
...whenDefined("tagMap", styling?.tags),
|
|
121
|
-
...whenDefined("
|
|
126
|
+
...whenDefined("recipeMap", styling?.presets),
|
|
122
127
|
...whenDefined("variants", styling?.variants),
|
|
123
128
|
...whenDefined("defaultVariants", styling?.defaults),
|
|
124
129
|
...whenDefined("compoundVariants", styling?.compounds),
|
|
@@ -159,10 +164,10 @@ function validateFactoryOptions(resolved) {
|
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
166
|
};
|
|
162
|
-
const {
|
|
163
|
-
if (
|
|
164
|
-
for (const
|
|
165
|
-
checkSelection(`preset "${
|
|
167
|
+
const { recipeMap } = resolved;
|
|
168
|
+
if (recipeMap) {
|
|
169
|
+
for (const recipeKey in recipeMap) {
|
|
170
|
+
checkSelection(`preset "${recipeKey}"`, recipeMap[recipeKey]);
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
173
|
if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
|
|
@@ -198,12 +203,12 @@ function report2(strict, message) {
|
|
|
198
203
|
function label(name) {
|
|
199
204
|
return name ? `[${name}]` : "[createContractComponent]";
|
|
200
205
|
}
|
|
201
|
-
function validateRenderProps(options, props,
|
|
202
|
-
const { strict,
|
|
206
|
+
function validateRenderProps(options, props, recipeKey) {
|
|
207
|
+
const { strict, recipeMap, variants, displayName } = options;
|
|
203
208
|
if (!strict) return;
|
|
204
209
|
const tag = label(displayName);
|
|
205
|
-
if (
|
|
206
|
-
report2(strict, `${tag} Unknown
|
|
210
|
+
if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
|
|
211
|
+
report2(strict, `${tag} Unknown recipeKey "${recipeKey}" \u2014 no preset with that name exists.`);
|
|
207
212
|
}
|
|
208
213
|
if (variants) {
|
|
209
214
|
for (const key in variants) {
|
|
@@ -241,8 +246,8 @@ function assertPluginShape(result) {
|
|
|
241
246
|
}
|
|
242
247
|
function guardPipeline(pipeline) {
|
|
243
248
|
if (process.env.NODE_ENV === "production") return pipeline;
|
|
244
|
-
return function guardedPipeline(tag, props, className,
|
|
245
|
-
const result = pipeline(tag, props, className,
|
|
249
|
+
return function guardedPipeline(tag, props, className, recipe) {
|
|
250
|
+
const result = pipeline(tag, props, className, recipe);
|
|
246
251
|
if (typeof result !== "string")
|
|
247
252
|
panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
|
|
248
253
|
return result;
|
|
@@ -267,11 +272,11 @@ function createRuntimeMethods(resolved, classPipeline, engine) {
|
|
|
267
272
|
resolveProps(props) {
|
|
268
273
|
return mergeProps(resolved.defaultProps, props);
|
|
269
274
|
},
|
|
270
|
-
resolveClasses(tag, props, className,
|
|
275
|
+
resolveClasses(tag, props, className, recipe) {
|
|
271
276
|
if (process.env.NODE_ENV !== "production") {
|
|
272
|
-
validateRenderProps(resolved, props,
|
|
277
|
+
validateRenderProps(resolved, props, recipe);
|
|
273
278
|
}
|
|
274
|
-
return classPipeline(tag, props, className,
|
|
279
|
+
return classPipeline(tag, props, className, recipe);
|
|
275
280
|
},
|
|
276
281
|
resolveAria(tag, props) {
|
|
277
282
|
if (!engine) return { props };
|
|
@@ -620,7 +625,7 @@ function isKnownAriaRole(value) {
|
|
|
620
625
|
return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
|
|
621
626
|
}
|
|
622
627
|
|
|
623
|
-
// ../core/dist/chunk-
|
|
628
|
+
// ../core/dist/chunk-BNVYTMYV.js
|
|
624
629
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
625
630
|
article: "article",
|
|
626
631
|
aside: "complementary",
|
|
@@ -1555,7 +1560,7 @@ function getHtmlPropNormalizers(tag) {
|
|
|
1555
1560
|
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
1556
1561
|
}
|
|
1557
1562
|
|
|
1558
|
-
// ../core/dist/chunk-
|
|
1563
|
+
// ../core/dist/chunk-3T4EM5FG.js
|
|
1559
1564
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
1560
1565
|
var cx = clsx;
|
|
1561
1566
|
var cva = (base, config) => (props) => {
|
|
@@ -1632,18 +1637,18 @@ var StaticClassResolver = class {
|
|
|
1632
1637
|
};
|
|
1633
1638
|
var VariantClassResolver = class _VariantClassResolver {
|
|
1634
1639
|
#cvaFn;
|
|
1635
|
-
#
|
|
1640
|
+
#recipeMap;
|
|
1636
1641
|
#variantKeys;
|
|
1637
1642
|
#precomputedClasses;
|
|
1638
1643
|
#cache = /* @__PURE__ */ new Map();
|
|
1639
|
-
constructor(cvaFn,
|
|
1644
|
+
constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
|
|
1640
1645
|
this.#cvaFn = cvaFn ?? null;
|
|
1641
|
-
this.#
|
|
1646
|
+
this.#recipeMap = Object.freeze(recipeMap ?? {});
|
|
1642
1647
|
this.#variantKeys = variantKeys ?? null;
|
|
1643
1648
|
this.#precomputedClasses = precomputedClasses ?? null;
|
|
1644
1649
|
}
|
|
1645
|
-
resolve({ props,
|
|
1646
|
-
const normalizedKey =
|
|
1650
|
+
resolve({ props, recipe }) {
|
|
1651
|
+
const normalizedKey = recipe ?? "__none__";
|
|
1647
1652
|
const cacheKey = this.#createCacheKey(props, normalizedKey);
|
|
1648
1653
|
if (this.#precomputedClasses !== null) {
|
|
1649
1654
|
const precomputed = this.#precomputedClasses[cacheKey];
|
|
@@ -1655,7 +1660,7 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1655
1660
|
this.#cache.set(cacheKey, cached);
|
|
1656
1661
|
return cached;
|
|
1657
1662
|
}
|
|
1658
|
-
const result = this.#compute(props,
|
|
1663
|
+
const result = this.#compute(props, recipe);
|
|
1659
1664
|
this.#cache.set(cacheKey, result);
|
|
1660
1665
|
if (this.#cache.size > 1e3) {
|
|
1661
1666
|
const lru = this.#cache.keys().next().value;
|
|
@@ -1663,10 +1668,10 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1663
1668
|
}
|
|
1664
1669
|
return result;
|
|
1665
1670
|
}
|
|
1666
|
-
#compute(props,
|
|
1671
|
+
#compute(props, recipe) {
|
|
1667
1672
|
if (!this.#cvaFn) return "";
|
|
1668
|
-
if (!
|
|
1669
|
-
const preset = this.#
|
|
1673
|
+
if (!recipe) return this.#cvaFn(props);
|
|
1674
|
+
const preset = this.#recipeMap[recipe];
|
|
1670
1675
|
if (!preset) return this.#cvaFn(props);
|
|
1671
1676
|
return this.#cvaFn({ ...preset, ...props });
|
|
1672
1677
|
}
|
|
@@ -1674,15 +1679,15 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1674
1679
|
// props (className, id, etc.) produce identical CVA output and must not fragment the cache.
|
|
1675
1680
|
// Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
|
|
1676
1681
|
// String is built incrementally to avoid a parts[] array allocation on every render.
|
|
1677
|
-
#createCacheKey(props,
|
|
1682
|
+
#createCacheKey(props, recipe) {
|
|
1678
1683
|
if (this.#variantKeys !== null) {
|
|
1679
|
-
let key2 =
|
|
1684
|
+
let key2 = recipe;
|
|
1680
1685
|
for (const k of this.#variantKeys) {
|
|
1681
1686
|
if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1682
1687
|
}
|
|
1683
1688
|
return key2;
|
|
1684
1689
|
}
|
|
1685
|
-
let key =
|
|
1690
|
+
let key = recipe;
|
|
1686
1691
|
for (const k of Object.keys(props).sort()) {
|
|
1687
1692
|
key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1688
1693
|
}
|
|
@@ -1707,13 +1712,13 @@ function createClassPipeline(resolved) {
|
|
|
1707
1712
|
const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
|
|
1708
1713
|
const variantResolver = new VariantClassResolver(
|
|
1709
1714
|
cvaFn,
|
|
1710
|
-
resolved.
|
|
1715
|
+
resolved.recipeMap,
|
|
1711
1716
|
variantKeys,
|
|
1712
1717
|
resolved.precomputedClasses
|
|
1713
1718
|
);
|
|
1714
|
-
return function resolveClasses(tag, props, className,
|
|
1715
|
-
const staticClasses = staticResolver.resolve(tag,
|
|
1716
|
-
const variantClasses = variantResolver.resolve({ props,
|
|
1719
|
+
return function resolveClasses(tag, props, className, recipe) {
|
|
1720
|
+
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
1721
|
+
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
1717
1722
|
if (!className)
|
|
1718
1723
|
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
1719
1724
|
return cn(staticClasses, variantClasses, className);
|
|
@@ -1992,13 +1997,13 @@ function buildRenderState(tag, directives, props, className, children) {
|
|
|
1992
1997
|
return state;
|
|
1993
1998
|
}
|
|
1994
1999
|
function resolveRenderState(runtime, props, filterProps) {
|
|
1995
|
-
const { as, asChild, children, className,
|
|
2000
|
+
const { as, asChild, children, className, recipe, ...rest } = props;
|
|
1996
2001
|
const tag = runtime.resolveTag(as);
|
|
1997
2002
|
const mergedProps = runtime.resolveProps(rest);
|
|
1998
2003
|
const baseProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(mergedProps) : mergedProps;
|
|
1999
2004
|
const htmlNormalizers = runtime.options.htmlPropNormalizersFn?.(tag);
|
|
2000
2005
|
const normalizedProps = htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), baseProps) : baseProps;
|
|
2001
|
-
const resolvedClass = runtime.resolveClasses(tag, normalizedProps, className,
|
|
2006
|
+
const resolvedClass = runtime.resolveClasses(tag, normalizedProps, className, recipe);
|
|
2002
2007
|
const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
|
|
2003
2008
|
return buildRenderState(tag, buildDirectives(as, asChild), filteredProps, resolvedClass, children);
|
|
2004
2009
|
}
|
|
@@ -2099,11 +2104,6 @@ function createContractComponent(options) {
|
|
|
2099
2104
|
}
|
|
2100
2105
|
return Component;
|
|
2101
2106
|
}
|
|
2102
|
-
|
|
2103
|
-
// ../../adapters/preact/src/define-contract-component.ts
|
|
2104
|
-
function defineContractComponent(options) {
|
|
2105
|
-
return (factory) => factory(options);
|
|
2106
|
-
}
|
|
2107
2107
|
export {
|
|
2108
2108
|
Slottable,
|
|
2109
2109
|
createContractComponent,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { E as ElementType, U as UnknownProps, V as VariantMap,
|
|
2
|
-
export { d as AnyFactoryOptions, e as ElementRef, f as PolymorphicProps, g as PolymorphicWithAsChild, h as PolymorphicWithRender, i as RenderCallbackProps, S as Slottable, j as SlottableProps, m as mergeRefs } from '../merge-refs-
|
|
1
|
+
import { E as ElementType, U as UnknownProps, V as VariantMap, R as RecipeMap, a as EmptyRecord, A as AnyRecord, b as ReactFactoryOptions, P as PolymorphicComponent, c as PolymorphicGenerics } from '../merge-refs-CfAbwCKz.js';
|
|
2
|
+
export { d as AnyFactoryOptions, e as ElementRef, F as FactoryOptions, f as PolymorphicProps, g as PolymorphicWithAsChild, h as PolymorphicWithRender, i as RenderCallbackProps, S as Slottable, j as SlottableProps, k as defineContractComponent, m as mergeRefs } from '../merge-refs-CfAbwCKz.js';
|
|
3
3
|
import { Ref, ReactElement } from 'react';
|
|
4
4
|
import 'type-fest';
|
|
5
5
|
|
|
6
|
-
declare function createAriaEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends
|
|
6
|
+
declare function createAriaEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
7
7
|
|
|
8
|
-
declare function
|
|
8
|
+
declare function createChildrenEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
9
9
|
|
|
10
|
-
declare function
|
|
10
|
+
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps, TAllowed>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset, TAllowed>>;
|
|
11
11
|
|
|
12
|
-
declare function
|
|
12
|
+
declare function createContractedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
13
13
|
|
|
14
|
-
declare function
|
|
15
|
-
|
|
16
|
-
declare function createPolymorphicComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
14
|
+
declare function createPolymorphicComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
17
15
|
|
|
18
16
|
type SlotProps = {
|
|
19
17
|
ref?: Ref<unknown> | null;
|
|
@@ -24,4 +22,4 @@ declare namespace Slot {
|
|
|
24
22
|
var displayName: string;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
export { ElementType, EmptyRecord,
|
|
25
|
+
export { ElementType, EmptyRecord, PolymorphicComponent, PolymorphicGenerics, ReactFactoryOptions, Slot, createAriaEnforcedComponent, createChildrenEnforcedComponent, createContractComponent, createContractedComponent, createPolymorphicComponent };
|
package/dist/react/index.js
CHANGED
|
@@ -11,12 +11,13 @@ import {
|
|
|
11
11
|
composeFilter,
|
|
12
12
|
createContractedPolymorphic,
|
|
13
13
|
createPolymorphic,
|
|
14
|
+
defineContractComponent,
|
|
14
15
|
isFunction,
|
|
15
16
|
isPlainObject,
|
|
16
17
|
mergeRefs,
|
|
17
18
|
mergeSlotProps,
|
|
18
19
|
render
|
|
19
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-PBBPAHMV.js";
|
|
20
21
|
|
|
21
22
|
// ../../adapters/react/src/current/slot/cloneSlotChild.ts
|
|
22
23
|
import { Fragment } from "react";
|
|
@@ -87,11 +88,6 @@ function createAriaEnforcedComponent(options) {
|
|
|
87
88
|
return Component;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
// ../../adapters/react/src/current/define-contract-component.ts
|
|
91
|
-
function defineContractComponent(options) {
|
|
92
|
-
return (factory) => factory(options);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
91
|
// ../../adapters/react/src/current/create-children-enforced-component.ts
|
|
96
92
|
function createChildrenEnforcedComponent(options) {
|
|
97
93
|
const name = options.name ?? "PolymorphicComponent";
|
package/dist/react/legacy.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { E as ElementType, U as UnknownProps, V as VariantMap,
|
|
2
|
-
export { d as AnyFactoryOptions, e as ElementRef, F as FactoryOptions, f as PolymorphicProps, g as PolymorphicWithAsChild, h as PolymorphicWithRender, i as RenderCallbackProps, S as Slottable, j as SlottableProps, m as mergeRefs } from '../merge-refs-
|
|
1
|
+
import { E as ElementType, U as UnknownProps, V as VariantMap, R as RecipeMap, a as EmptyRecord, A as AnyRecord, b as ReactFactoryOptions, P as PolymorphicComponent, c as PolymorphicGenerics } from '../merge-refs-CfAbwCKz.js';
|
|
2
|
+
export { d as AnyFactoryOptions, e as ElementRef, F as FactoryOptions, f as PolymorphicProps, g as PolymorphicWithAsChild, h as PolymorphicWithRender, i as RenderCallbackProps, S as Slottable, j as SlottableProps, k as defineContractComponent, m as mergeRefs } from '../merge-refs-CfAbwCKz.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import 'type-fest';
|
|
5
5
|
|
|
6
|
-
declare function createAriaEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends
|
|
6
|
+
declare function createAriaEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
7
7
|
|
|
8
|
-
declare function createChildrenEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends
|
|
8
|
+
declare function createChildrenEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
9
9
|
|
|
10
|
-
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
10
|
+
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps, TAllowed>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset, TAllowed>>;
|
|
11
11
|
|
|
12
|
-
declare function createContractedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends
|
|
12
|
+
declare function createContractedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
13
13
|
|
|
14
|
-
declare function createPolymorphicComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends
|
|
14
|
+
declare function createPolymorphicComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
15
15
|
|
|
16
16
|
type SlotProps = {
|
|
17
17
|
[key: string]: unknown;
|
package/dist/react/legacy.js
CHANGED
|
@@ -11,12 +11,13 @@ import {
|
|
|
11
11
|
composeFilter,
|
|
12
12
|
createContractedPolymorphic,
|
|
13
13
|
createPolymorphic,
|
|
14
|
+
defineContractComponent,
|
|
14
15
|
isFunction,
|
|
15
16
|
isPlainObject,
|
|
16
17
|
mergeRefs,
|
|
17
18
|
mergeSlotProps,
|
|
18
19
|
render
|
|
19
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-PBBPAHMV.js";
|
|
20
21
|
|
|
21
22
|
// ../../adapters/react/src/legacy/create-aria-enforced-component.ts
|
|
22
23
|
import { forwardRef as forwardRef2 } from "react";
|
|
@@ -201,5 +202,6 @@ export {
|
|
|
201
202
|
createContractComponent,
|
|
202
203
|
createContractedComponent,
|
|
203
204
|
createPolymorphicComponent,
|
|
205
|
+
defineContractComponent,
|
|
204
206
|
mergeRefs
|
|
205
207
|
};
|