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/vue/index.js
CHANGED
|
@@ -20,7 +20,12 @@ function applyFilter(props, filterProps, variantKeys) {
|
|
|
20
20
|
return out;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
//
|
|
23
|
+
// ../../lib/adapter-utils/src/define-component.ts
|
|
24
|
+
function defineContractComponent(options) {
|
|
25
|
+
return (factory) => factory(options);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ../core/dist/chunk-KKSHJDE7.js
|
|
24
29
|
function makeResolveTag(defaultTag) {
|
|
25
30
|
return function tag(as) {
|
|
26
31
|
return as ?? defaultTag;
|
|
@@ -89,7 +94,7 @@ function resolveFactoryOptions(options = {}) {
|
|
|
89
94
|
...whenDefined("defaultProps", options.defaults),
|
|
90
95
|
...whenDefined("baseClassName", styling?.base),
|
|
91
96
|
...whenDefined("tagMap", styling?.tags),
|
|
92
|
-
...whenDefined("
|
|
97
|
+
...whenDefined("recipeMap", styling?.presets),
|
|
93
98
|
...whenDefined("variants", styling?.variants),
|
|
94
99
|
...whenDefined("defaultVariants", styling?.defaults),
|
|
95
100
|
...whenDefined("compoundVariants", styling?.compounds),
|
|
@@ -130,10 +135,10 @@ function validateFactoryOptions(resolved) {
|
|
|
130
135
|
}
|
|
131
136
|
}
|
|
132
137
|
};
|
|
133
|
-
const {
|
|
134
|
-
if (
|
|
135
|
-
for (const
|
|
136
|
-
checkSelection(`preset "${
|
|
138
|
+
const { recipeMap } = resolved;
|
|
139
|
+
if (recipeMap) {
|
|
140
|
+
for (const recipeKey in recipeMap) {
|
|
141
|
+
checkSelection(`preset "${recipeKey}"`, recipeMap[recipeKey]);
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
144
|
if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
|
|
@@ -169,12 +174,12 @@ function report2(strict, message) {
|
|
|
169
174
|
function label(name) {
|
|
170
175
|
return name ? `[${name}]` : "[createContractComponent]";
|
|
171
176
|
}
|
|
172
|
-
function validateRenderProps(options, props,
|
|
173
|
-
const { strict,
|
|
177
|
+
function validateRenderProps(options, props, recipeKey) {
|
|
178
|
+
const { strict, recipeMap, variants, displayName } = options;
|
|
174
179
|
if (!strict) return;
|
|
175
180
|
const tag = label(displayName);
|
|
176
|
-
if (
|
|
177
|
-
report2(strict, `${tag} Unknown
|
|
181
|
+
if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
|
|
182
|
+
report2(strict, `${tag} Unknown recipeKey "${recipeKey}" \u2014 no preset with that name exists.`);
|
|
178
183
|
}
|
|
179
184
|
if (variants) {
|
|
180
185
|
for (const key in variants) {
|
|
@@ -212,8 +217,8 @@ function assertPluginShape(result) {
|
|
|
212
217
|
}
|
|
213
218
|
function guardPipeline(pipeline) {
|
|
214
219
|
if (process.env.NODE_ENV === "production") return pipeline;
|
|
215
|
-
return function guardedPipeline(tag, props, className,
|
|
216
|
-
const result = pipeline(tag, props, className,
|
|
220
|
+
return function guardedPipeline(tag, props, className, recipe) {
|
|
221
|
+
const result = pipeline(tag, props, className, recipe);
|
|
217
222
|
if (typeof result !== "string")
|
|
218
223
|
panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
|
|
219
224
|
return result;
|
|
@@ -238,11 +243,11 @@ function createRuntimeMethods(resolved, classPipeline, engine) {
|
|
|
238
243
|
resolveProps(props) {
|
|
239
244
|
return mergeProps(resolved.defaultProps, props);
|
|
240
245
|
},
|
|
241
|
-
resolveClasses(tag, props, className,
|
|
246
|
+
resolveClasses(tag, props, className, recipe) {
|
|
242
247
|
if (process.env.NODE_ENV !== "production") {
|
|
243
|
-
validateRenderProps(resolved, props,
|
|
248
|
+
validateRenderProps(resolved, props, recipe);
|
|
244
249
|
}
|
|
245
|
-
return classPipeline(tag, props, className,
|
|
250
|
+
return classPipeline(tag, props, className, recipe);
|
|
246
251
|
},
|
|
247
252
|
resolveAria(tag, props) {
|
|
248
253
|
if (!engine) return { props };
|
|
@@ -591,7 +596,7 @@ function isKnownAriaRole(value) {
|
|
|
591
596
|
return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
|
|
592
597
|
}
|
|
593
598
|
|
|
594
|
-
// ../core/dist/chunk-
|
|
599
|
+
// ../core/dist/chunk-BNVYTMYV.js
|
|
595
600
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
596
601
|
article: "article",
|
|
597
602
|
aside: "complementary",
|
|
@@ -1526,7 +1531,7 @@ function getHtmlPropNormalizers(tag) {
|
|
|
1526
1531
|
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
1527
1532
|
}
|
|
1528
1533
|
|
|
1529
|
-
// ../core/dist/chunk-
|
|
1534
|
+
// ../core/dist/chunk-3T4EM5FG.js
|
|
1530
1535
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
1531
1536
|
var cx = clsx;
|
|
1532
1537
|
var cva = (base, config) => (props) => {
|
|
@@ -1603,18 +1608,18 @@ var StaticClassResolver = class {
|
|
|
1603
1608
|
};
|
|
1604
1609
|
var VariantClassResolver = class _VariantClassResolver {
|
|
1605
1610
|
#cvaFn;
|
|
1606
|
-
#
|
|
1611
|
+
#recipeMap;
|
|
1607
1612
|
#variantKeys;
|
|
1608
1613
|
#precomputedClasses;
|
|
1609
1614
|
#cache = /* @__PURE__ */ new Map();
|
|
1610
|
-
constructor(cvaFn,
|
|
1615
|
+
constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
|
|
1611
1616
|
this.#cvaFn = cvaFn ?? null;
|
|
1612
|
-
this.#
|
|
1617
|
+
this.#recipeMap = Object.freeze(recipeMap ?? {});
|
|
1613
1618
|
this.#variantKeys = variantKeys ?? null;
|
|
1614
1619
|
this.#precomputedClasses = precomputedClasses ?? null;
|
|
1615
1620
|
}
|
|
1616
|
-
resolve({ props,
|
|
1617
|
-
const normalizedKey =
|
|
1621
|
+
resolve({ props, recipe }) {
|
|
1622
|
+
const normalizedKey = recipe ?? "__none__";
|
|
1618
1623
|
const cacheKey = this.#createCacheKey(props, normalizedKey);
|
|
1619
1624
|
if (this.#precomputedClasses !== null) {
|
|
1620
1625
|
const precomputed = this.#precomputedClasses[cacheKey];
|
|
@@ -1626,7 +1631,7 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1626
1631
|
this.#cache.set(cacheKey, cached);
|
|
1627
1632
|
return cached;
|
|
1628
1633
|
}
|
|
1629
|
-
const result = this.#compute(props,
|
|
1634
|
+
const result = this.#compute(props, recipe);
|
|
1630
1635
|
this.#cache.set(cacheKey, result);
|
|
1631
1636
|
if (this.#cache.size > 1e3) {
|
|
1632
1637
|
const lru = this.#cache.keys().next().value;
|
|
@@ -1634,10 +1639,10 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1634
1639
|
}
|
|
1635
1640
|
return result;
|
|
1636
1641
|
}
|
|
1637
|
-
#compute(props,
|
|
1642
|
+
#compute(props, recipe) {
|
|
1638
1643
|
if (!this.#cvaFn) return "";
|
|
1639
|
-
if (!
|
|
1640
|
-
const preset = this.#
|
|
1644
|
+
if (!recipe) return this.#cvaFn(props);
|
|
1645
|
+
const preset = this.#recipeMap[recipe];
|
|
1641
1646
|
if (!preset) return this.#cvaFn(props);
|
|
1642
1647
|
return this.#cvaFn({ ...preset, ...props });
|
|
1643
1648
|
}
|
|
@@ -1645,15 +1650,15 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1645
1650
|
// props (className, id, etc.) produce identical CVA output and must not fragment the cache.
|
|
1646
1651
|
// Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
|
|
1647
1652
|
// String is built incrementally to avoid a parts[] array allocation on every render.
|
|
1648
|
-
#createCacheKey(props,
|
|
1653
|
+
#createCacheKey(props, recipe) {
|
|
1649
1654
|
if (this.#variantKeys !== null) {
|
|
1650
|
-
let key2 =
|
|
1655
|
+
let key2 = recipe;
|
|
1651
1656
|
for (const k of this.#variantKeys) {
|
|
1652
1657
|
if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1653
1658
|
}
|
|
1654
1659
|
return key2;
|
|
1655
1660
|
}
|
|
1656
|
-
let key =
|
|
1661
|
+
let key = recipe;
|
|
1657
1662
|
for (const k of Object.keys(props).sort()) {
|
|
1658
1663
|
key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1659
1664
|
}
|
|
@@ -1678,13 +1683,13 @@ function createClassPipeline(resolved) {
|
|
|
1678
1683
|
const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
|
|
1679
1684
|
const variantResolver = new VariantClassResolver(
|
|
1680
1685
|
cvaFn,
|
|
1681
|
-
resolved.
|
|
1686
|
+
resolved.recipeMap,
|
|
1682
1687
|
variantKeys,
|
|
1683
1688
|
resolved.precomputedClasses
|
|
1684
1689
|
);
|
|
1685
|
-
return function resolveClasses(tag, props, className,
|
|
1686
|
-
const staticClasses = staticResolver.resolve(tag,
|
|
1687
|
-
const variantClasses = variantResolver.resolve({ props,
|
|
1690
|
+
return function resolveClasses(tag, props, className, recipe) {
|
|
1691
|
+
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
1692
|
+
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
1688
1693
|
if (!className)
|
|
1689
1694
|
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
1690
1695
|
return cn(staticClasses, variantClasses, className);
|
|
@@ -1850,7 +1855,7 @@ function buildDirectives(as, asChild) {
|
|
|
1850
1855
|
};
|
|
1851
1856
|
}
|
|
1852
1857
|
function resolveRenderState(runtime, attrs, filterProps) {
|
|
1853
|
-
const { as, asChild, class: className,
|
|
1858
|
+
const { as, asChild, class: className, recipe, ...rest } = attrs;
|
|
1854
1859
|
const tag = runtime.resolveTag(as);
|
|
1855
1860
|
const mergedProps = runtime.resolveProps(rest);
|
|
1856
1861
|
const baseProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(mergedProps) : mergedProps;
|
|
@@ -1860,7 +1865,7 @@ function resolveRenderState(runtime, attrs, filterProps) {
|
|
|
1860
1865
|
tag,
|
|
1861
1866
|
normalizedProps,
|
|
1862
1867
|
typeof className === "string" ? className : void 0,
|
|
1863
|
-
typeof
|
|
1868
|
+
typeof recipe === "string" ? recipe : void 0
|
|
1864
1869
|
);
|
|
1865
1870
|
const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
|
|
1866
1871
|
return {
|
|
@@ -1959,11 +1964,6 @@ function createContractComponent(options) {
|
|
|
1959
1964
|
}
|
|
1960
1965
|
return Component;
|
|
1961
1966
|
}
|
|
1962
|
-
|
|
1963
|
-
// ../../adapters/vue/src/define-contract-component.ts
|
|
1964
|
-
function defineContractComponent(options) {
|
|
1965
|
-
return (factory) => factory(options);
|
|
1966
|
-
}
|
|
1967
1967
|
export {
|
|
1968
1968
|
Slottable,
|
|
1969
1969
|
createContractComponent,
|
package/dist/web/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>>;
|
|
@@ -227,13 +230,15 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
|
|
|
227
230
|
|
|
228
231
|
type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolean;
|
|
229
232
|
|
|
233
|
+
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
234
|
+
|
|
230
235
|
/**
|
|
231
236
|
* Options accepted by createContractComponent in the web adapter.
|
|
232
237
|
*
|
|
233
238
|
* Identical shape to LitFactoryOptions — a plain HTMLElement subclass with
|
|
234
239
|
* no framework dependency. Light DOM only; Shadow DOM is out of scope.
|
|
235
240
|
*/
|
|
236
|
-
type WebFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
241
|
+
type WebFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = FactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps> & {
|
|
237
242
|
readonly filterProps?: FilterPredicate;
|
|
238
243
|
};
|
|
239
244
|
|
|
@@ -247,7 +252,7 @@ type UnknownProps = Record<string, unknown>;
|
|
|
247
252
|
type WebContractComponent<TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>> = {
|
|
248
253
|
new (): HTMLElement & {
|
|
249
254
|
as: string | undefined;
|
|
250
|
-
|
|
255
|
+
recipe: string | undefined;
|
|
251
256
|
praxisClass: string | undefined;
|
|
252
257
|
/** Re-runs the pipeline — call after setting non-reactive attributes (aria-*, role, data-*). */
|
|
253
258
|
update(): void;
|
|
@@ -285,9 +290,7 @@ type WebContractComponent<TVariants extends Readonly<VariantMap> = Readonly<Empt
|
|
|
285
290
|
* For non-reactive attributes (`aria-*`, `role`, `data-*`) call `element.update()`
|
|
286
291
|
* after setting them to trigger an explicit pipeline re-run.
|
|
287
292
|
*/
|
|
288
|
-
declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
289
|
-
|
|
290
|
-
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
293
|
+
declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: WebFactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps>): WebContractComponent<TVariants>;
|
|
291
294
|
|
|
292
295
|
/**
|
|
293
296
|
* Renders a praxis-kit web component to an HTML string without requiring a DOM.
|
package/dist/web/index.js
CHANGED
|
@@ -9,7 +9,12 @@ function applyFilter(props, filterProps, variantKeys) {
|
|
|
9
9
|
return out;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// ../../lib/adapter-utils/src/define-component.ts
|
|
13
|
+
function defineContractComponent(options) {
|
|
14
|
+
return (factory) => factory(options);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ../core/dist/chunk-KKSHJDE7.js
|
|
13
18
|
function makeResolveTag(defaultTag) {
|
|
14
19
|
return function tag(as) {
|
|
15
20
|
return as ?? defaultTag;
|
|
@@ -78,7 +83,7 @@ function resolveFactoryOptions(options = {}) {
|
|
|
78
83
|
...whenDefined("defaultProps", options.defaults),
|
|
79
84
|
...whenDefined("baseClassName", styling?.base),
|
|
80
85
|
...whenDefined("tagMap", styling?.tags),
|
|
81
|
-
...whenDefined("
|
|
86
|
+
...whenDefined("recipeMap", styling?.presets),
|
|
82
87
|
...whenDefined("variants", styling?.variants),
|
|
83
88
|
...whenDefined("defaultVariants", styling?.defaults),
|
|
84
89
|
...whenDefined("compoundVariants", styling?.compounds),
|
|
@@ -119,10 +124,10 @@ function validateFactoryOptions(resolved) {
|
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
126
|
};
|
|
122
|
-
const {
|
|
123
|
-
if (
|
|
124
|
-
for (const
|
|
125
|
-
checkSelection(`preset "${
|
|
127
|
+
const { recipeMap } = resolved;
|
|
128
|
+
if (recipeMap) {
|
|
129
|
+
for (const recipeKey in recipeMap) {
|
|
130
|
+
checkSelection(`preset "${recipeKey}"`, recipeMap[recipeKey]);
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
133
|
if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
|
|
@@ -158,12 +163,12 @@ function report2(strict, message) {
|
|
|
158
163
|
function label(name) {
|
|
159
164
|
return name ? `[${name}]` : "[createContractComponent]";
|
|
160
165
|
}
|
|
161
|
-
function validateRenderProps(options, props,
|
|
162
|
-
const { strict,
|
|
166
|
+
function validateRenderProps(options, props, recipeKey) {
|
|
167
|
+
const { strict, recipeMap, variants, displayName } = options;
|
|
163
168
|
if (!strict) return;
|
|
164
169
|
const tag = label(displayName);
|
|
165
|
-
if (
|
|
166
|
-
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.`);
|
|
167
172
|
}
|
|
168
173
|
if (variants) {
|
|
169
174
|
for (const key in variants) {
|
|
@@ -201,8 +206,8 @@ function assertPluginShape(result) {
|
|
|
201
206
|
}
|
|
202
207
|
function guardPipeline(pipeline) {
|
|
203
208
|
if (process.env.NODE_ENV === "production") return pipeline;
|
|
204
|
-
return function guardedPipeline(tag, props, className,
|
|
205
|
-
const result = pipeline(tag, props, className,
|
|
209
|
+
return function guardedPipeline(tag, props, className, recipe) {
|
|
210
|
+
const result = pipeline(tag, props, className, recipe);
|
|
206
211
|
if (typeof result !== "string")
|
|
207
212
|
panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
|
|
208
213
|
return result;
|
|
@@ -227,11 +232,11 @@ function createRuntimeMethods(resolved, classPipeline, engine) {
|
|
|
227
232
|
resolveProps(props) {
|
|
228
233
|
return mergeProps(resolved.defaultProps, props);
|
|
229
234
|
},
|
|
230
|
-
resolveClasses(tag, props, className,
|
|
235
|
+
resolveClasses(tag, props, className, recipe) {
|
|
231
236
|
if (process.env.NODE_ENV !== "production") {
|
|
232
|
-
validateRenderProps(resolved, props,
|
|
237
|
+
validateRenderProps(resolved, props, recipe);
|
|
233
238
|
}
|
|
234
|
-
return classPipeline(tag, props, className,
|
|
239
|
+
return classPipeline(tag, props, className, recipe);
|
|
235
240
|
},
|
|
236
241
|
resolveAria(tag, props) {
|
|
237
242
|
if (!engine) return { props };
|
|
@@ -577,7 +582,7 @@ function isStandaloneTag(tag) {
|
|
|
577
582
|
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
578
583
|
}
|
|
579
584
|
|
|
580
|
-
// ../core/dist/chunk-
|
|
585
|
+
// ../core/dist/chunk-BNVYTMYV.js
|
|
581
586
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
582
587
|
article: "article",
|
|
583
588
|
aside: "complementary",
|
|
@@ -1512,7 +1517,7 @@ function getHtmlPropNormalizers(tag) {
|
|
|
1512
1517
|
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
1513
1518
|
}
|
|
1514
1519
|
|
|
1515
|
-
// ../core/dist/chunk-
|
|
1520
|
+
// ../core/dist/chunk-3T4EM5FG.js
|
|
1516
1521
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
1517
1522
|
var cx = clsx;
|
|
1518
1523
|
var cva = (base, config) => (props) => {
|
|
@@ -1589,18 +1594,18 @@ var StaticClassResolver = class {
|
|
|
1589
1594
|
};
|
|
1590
1595
|
var VariantClassResolver = class _VariantClassResolver {
|
|
1591
1596
|
#cvaFn;
|
|
1592
|
-
#
|
|
1597
|
+
#recipeMap;
|
|
1593
1598
|
#variantKeys;
|
|
1594
1599
|
#precomputedClasses;
|
|
1595
1600
|
#cache = /* @__PURE__ */ new Map();
|
|
1596
|
-
constructor(cvaFn,
|
|
1601
|
+
constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
|
|
1597
1602
|
this.#cvaFn = cvaFn ?? null;
|
|
1598
|
-
this.#
|
|
1603
|
+
this.#recipeMap = Object.freeze(recipeMap ?? {});
|
|
1599
1604
|
this.#variantKeys = variantKeys ?? null;
|
|
1600
1605
|
this.#precomputedClasses = precomputedClasses ?? null;
|
|
1601
1606
|
}
|
|
1602
|
-
resolve({ props,
|
|
1603
|
-
const normalizedKey =
|
|
1607
|
+
resolve({ props, recipe }) {
|
|
1608
|
+
const normalizedKey = recipe ?? "__none__";
|
|
1604
1609
|
const cacheKey = this.#createCacheKey(props, normalizedKey);
|
|
1605
1610
|
if (this.#precomputedClasses !== null) {
|
|
1606
1611
|
const precomputed = this.#precomputedClasses[cacheKey];
|
|
@@ -1612,7 +1617,7 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1612
1617
|
this.#cache.set(cacheKey, cached);
|
|
1613
1618
|
return cached;
|
|
1614
1619
|
}
|
|
1615
|
-
const result = this.#compute(props,
|
|
1620
|
+
const result = this.#compute(props, recipe);
|
|
1616
1621
|
this.#cache.set(cacheKey, result);
|
|
1617
1622
|
if (this.#cache.size > 1e3) {
|
|
1618
1623
|
const lru = this.#cache.keys().next().value;
|
|
@@ -1620,10 +1625,10 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1620
1625
|
}
|
|
1621
1626
|
return result;
|
|
1622
1627
|
}
|
|
1623
|
-
#compute(props,
|
|
1628
|
+
#compute(props, recipe) {
|
|
1624
1629
|
if (!this.#cvaFn) return "";
|
|
1625
|
-
if (!
|
|
1626
|
-
const preset = this.#
|
|
1630
|
+
if (!recipe) return this.#cvaFn(props);
|
|
1631
|
+
const preset = this.#recipeMap[recipe];
|
|
1627
1632
|
if (!preset) return this.#cvaFn(props);
|
|
1628
1633
|
return this.#cvaFn({ ...preset, ...props });
|
|
1629
1634
|
}
|
|
@@ -1631,15 +1636,15 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1631
1636
|
// props (className, id, etc.) produce identical CVA output and must not fragment the cache.
|
|
1632
1637
|
// Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
|
|
1633
1638
|
// String is built incrementally to avoid a parts[] array allocation on every render.
|
|
1634
|
-
#createCacheKey(props,
|
|
1639
|
+
#createCacheKey(props, recipe) {
|
|
1635
1640
|
if (this.#variantKeys !== null) {
|
|
1636
|
-
let key2 =
|
|
1641
|
+
let key2 = recipe;
|
|
1637
1642
|
for (const k of this.#variantKeys) {
|
|
1638
1643
|
if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1639
1644
|
}
|
|
1640
1645
|
return key2;
|
|
1641
1646
|
}
|
|
1642
|
-
let key =
|
|
1647
|
+
let key = recipe;
|
|
1643
1648
|
for (const k of Object.keys(props).sort()) {
|
|
1644
1649
|
key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1645
1650
|
}
|
|
@@ -1664,13 +1669,13 @@ function createClassPipeline(resolved) {
|
|
|
1664
1669
|
const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
|
|
1665
1670
|
const variantResolver = new VariantClassResolver(
|
|
1666
1671
|
cvaFn,
|
|
1667
|
-
resolved.
|
|
1672
|
+
resolved.recipeMap,
|
|
1668
1673
|
variantKeys,
|
|
1669
1674
|
resolved.precomputedClasses
|
|
1670
1675
|
);
|
|
1671
|
-
return function resolveClasses(tag, props, className,
|
|
1672
|
-
const staticClasses = staticResolver.resolve(tag,
|
|
1673
|
-
const variantClasses = variantResolver.resolve({ props,
|
|
1676
|
+
return function resolveClasses(tag, props, className, recipe) {
|
|
1677
|
+
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
1678
|
+
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
1674
1679
|
if (!className)
|
|
1675
1680
|
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
1676
1681
|
return cn(staticClasses, variantClasses, className);
|
|
@@ -1771,14 +1776,14 @@ function renderToString(component, props = {}, innerHTML = "") {
|
|
|
1771
1776
|
);
|
|
1772
1777
|
}
|
|
1773
1778
|
const { bundle } = entry;
|
|
1774
|
-
const { as, className,
|
|
1779
|
+
const { as, className, recipe, class: classAttr, ...rest } = props;
|
|
1775
1780
|
const tag = bundle.runtime.resolveTag(as);
|
|
1776
1781
|
const mergedProps = bundle.runtime.resolveProps(rest);
|
|
1777
1782
|
const resolvedClass = bundle.runtime.resolveClasses(
|
|
1778
1783
|
tag,
|
|
1779
1784
|
mergedProps,
|
|
1780
1785
|
className ?? classAttr,
|
|
1781
|
-
|
|
1786
|
+
recipe
|
|
1782
1787
|
);
|
|
1783
1788
|
const ariaResult = bundle.runtime.resolveAria(tag, mergedProps);
|
|
1784
1789
|
const filtered = applyFilter(
|
|
@@ -1814,7 +1819,7 @@ function toLooseBundle(bundle) {
|
|
|
1814
1819
|
return bundle;
|
|
1815
1820
|
}
|
|
1816
1821
|
function resolveHostState(bundle, props) {
|
|
1817
|
-
const { as, className,
|
|
1822
|
+
const { as, className, recipe, ...rest } = props;
|
|
1818
1823
|
const tag = bundle.runtime.resolveTag(as);
|
|
1819
1824
|
const mergedProps = bundle.runtime.resolveProps(rest);
|
|
1820
1825
|
const baseProps = bundle.runtime.options.normalizeFn ? bundle.runtime.options.normalizeFn(mergedProps) : mergedProps;
|
|
@@ -1824,7 +1829,7 @@ function resolveHostState(bundle, props) {
|
|
|
1824
1829
|
tag,
|
|
1825
1830
|
normalizedProps,
|
|
1826
1831
|
className,
|
|
1827
|
-
|
|
1832
|
+
recipe
|
|
1828
1833
|
);
|
|
1829
1834
|
const ariaResult = bundle.runtime.resolveAria(tag, normalizedProps);
|
|
1830
1835
|
const attributes = applyFilter(
|
|
@@ -1904,7 +1909,7 @@ function createContractComponent(options) {
|
|
|
1904
1909
|
props[attr.name] = attr.value;
|
|
1905
1910
|
}
|
|
1906
1911
|
props["as"] = self.as ?? this.getAttribute("as") ?? void 0;
|
|
1907
|
-
props["
|
|
1912
|
+
props["recipe"] = self.recipe ?? this.getAttribute("variant-key") ?? void 0;
|
|
1908
1913
|
props["className"] = self.praxisClass ?? this.getAttribute("praxis-class") ?? void 0;
|
|
1909
1914
|
for (const key of variantKeys) {
|
|
1910
1915
|
const val = self[key] ?? this.getAttribute(key);
|
|
@@ -1920,11 +1925,6 @@ function createContractComponent(options) {
|
|
|
1920
1925
|
registerForSsr(PolymorphicWebElement, looseBundle);
|
|
1921
1926
|
return PolymorphicWebElement;
|
|
1922
1927
|
}
|
|
1923
|
-
|
|
1924
|
-
// ../../adapters/web/src/define-contract-component.ts
|
|
1925
|
-
function defineContractComponent(options) {
|
|
1926
|
-
return (factory) => factory(options);
|
|
1927
|
-
}
|
|
1928
1928
|
export {
|
|
1929
1929
|
createContractComponent,
|
|
1930
1930
|
defineContractComponent,
|