praxis-kit 2.0.2 → 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.
@@ -112,25 +112,25 @@ type VariantSelection<V extends VariantMap> = {
112
112
  * Presets are named bundles of variant props that callers activate by key,
113
113
  * avoiding the need to repeat variant combinations at each call site.
114
114
  */
115
- type PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
115
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
116
116
 
117
- type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
117
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
118
118
 
119
119
  interface BaseClassOptions {
120
120
  baseClassName?: ClassName;
121
121
  }
122
122
 
123
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
123
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
124
124
 
125
- interface PresetOptions<TVariants extends VariantMap = VariantMap> {
126
- presetMap?: Record<string, PresetTarget<TVariants>>;
125
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
126
+ recipeMap?: Record<string, RecipeTarget<TVariants>>;
127
127
  }
128
128
 
129
129
  interface TagMapOptions {
130
130
  tagMap?: TagMap;
131
131
  }
132
132
 
133
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
133
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
134
134
 
135
135
  type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
136
136
 
@@ -205,7 +205,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
205
205
  readonly allowedAs?: readonly TAllowed[];
206
206
  };
207
207
 
208
- type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
208
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
209
209
  readonly base?: ClassName;
210
210
  readonly variants?: V;
211
211
  readonly defaults?: Partial<DefaultVariants<V>>;
@@ -219,8 +219,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
219
219
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
220
220
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
221
221
  }['normalize'];
222
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
223
- type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
222
+ type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyRecord>;
223
+ 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> = {
224
224
  readonly tag?: TDefault;
225
225
  readonly name?: string;
226
226
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -231,6 +231,8 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
231
231
 
232
232
  type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolean;
233
233
 
234
+ declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
235
+
234
236
  /**
235
237
  * Options accepted by createContractComponent in the Lit adapter.
236
238
  *
@@ -242,7 +244,7 @@ type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolea
242
244
  * Note: this adapter targets Light DOM composition only. Shadow DOM slot
243
245
  * protocol is intentionally out of scope.
244
246
  */
245
- type LitFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = FactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps> & {
247
+ type LitFactoryOptions<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> & {
246
248
  readonly filterProps?: FilterPredicate;
247
249
  };
248
250
 
@@ -257,7 +259,7 @@ type UnknownProps = AnyRecord;
257
259
  type LitContractComponent<TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>> = {
258
260
  new (): LitElement & {
259
261
  as: string | undefined;
260
- variantKey: string | undefined;
262
+ recipe: string | undefined;
261
263
  praxisClass: string | undefined;
262
264
  } & {
263
265
  [K in Extract<keyof TVariants, string>]?: string | null;
@@ -284,9 +286,7 @@ type LitContractComponent<TVariants extends Readonly<VariantMap> = Readonly<Empt
284
286
  * customElements.define('praxis-button', Button)
285
287
  * ```
286
288
  */
287
- declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: LitFactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps>): LitContractComponent<TVariants>;
288
-
289
- declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
289
+ 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: LitFactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps>): LitContractComponent<TVariants>;
290
290
 
291
291
  /**
292
292
  * Renders a praxis-kit Lit component to an HTML string without requiring a DOM.
package/dist/lit/index.js CHANGED
@@ -12,7 +12,12 @@ function applyFilter(props, filterProps, variantKeys) {
12
12
  return out;
13
13
  }
14
14
 
15
- // ../core/dist/chunk-XFCAUPVZ.js
15
+ // ../../lib/adapter-utils/src/define-component.ts
16
+ function defineContractComponent(options) {
17
+ return (factory) => factory(options);
18
+ }
19
+
20
+ // ../core/dist/chunk-KKSHJDE7.js
16
21
  function makeResolveTag(defaultTag) {
17
22
  return function tag(as) {
18
23
  return as ?? defaultTag;
@@ -81,7 +86,7 @@ function resolveFactoryOptions(options = {}) {
81
86
  ...whenDefined("defaultProps", options.defaults),
82
87
  ...whenDefined("baseClassName", styling?.base),
83
88
  ...whenDefined("tagMap", styling?.tags),
84
- ...whenDefined("presetMap", styling?.presets),
89
+ ...whenDefined("recipeMap", styling?.presets),
85
90
  ...whenDefined("variants", styling?.variants),
86
91
  ...whenDefined("defaultVariants", styling?.defaults),
87
92
  ...whenDefined("compoundVariants", styling?.compounds),
@@ -122,10 +127,10 @@ function validateFactoryOptions(resolved) {
122
127
  }
123
128
  }
124
129
  };
125
- const { presetMap } = resolved;
126
- if (presetMap) {
127
- for (const presetKey in presetMap) {
128
- checkSelection(`preset "${presetKey}"`, presetMap[presetKey]);
130
+ const { recipeMap } = resolved;
131
+ if (recipeMap) {
132
+ for (const recipeKey in recipeMap) {
133
+ checkSelection(`preset "${recipeKey}"`, recipeMap[recipeKey]);
129
134
  }
130
135
  }
131
136
  if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
@@ -161,12 +166,12 @@ function report2(strict, message) {
161
166
  function label(name) {
162
167
  return name ? `[${name}]` : "[createContractComponent]";
163
168
  }
164
- function validateRenderProps(options, props, presetKey) {
165
- const { strict, presetMap, variants, displayName } = options;
169
+ function validateRenderProps(options, props, recipeKey) {
170
+ const { strict, recipeMap, variants, displayName } = options;
166
171
  if (!strict) return;
167
172
  const tag = label(displayName);
168
- if (presetKey !== void 0 && (!presetMap || !Object.hasOwn(presetMap, presetKey))) {
169
- report2(strict, `${tag} Unknown presetKey "${presetKey}" \u2014 no preset with that name exists.`);
173
+ if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
174
+ report2(strict, `${tag} Unknown recipeKey "${recipeKey}" \u2014 no preset with that name exists.`);
170
175
  }
171
176
  if (variants) {
172
177
  for (const key in variants) {
@@ -204,8 +209,8 @@ function assertPluginShape(result) {
204
209
  }
205
210
  function guardPipeline(pipeline) {
206
211
  if (process.env.NODE_ENV === "production") return pipeline;
207
- return function guardedPipeline(tag, props, className, variantKey) {
208
- const result = pipeline(tag, props, className, variantKey);
212
+ return function guardedPipeline(tag, props, className, recipe) {
213
+ const result = pipeline(tag, props, className, recipe);
209
214
  if (typeof result !== "string")
210
215
  panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
211
216
  return result;
@@ -230,11 +235,11 @@ function createRuntimeMethods(resolved, classPipeline, engine) {
230
235
  resolveProps(props) {
231
236
  return mergeProps(resolved.defaultProps, props);
232
237
  },
233
- resolveClasses(tag, props, className, variantKey) {
238
+ resolveClasses(tag, props, className, recipe) {
234
239
  if (process.env.NODE_ENV !== "production") {
235
- validateRenderProps(resolved, props, variantKey);
240
+ validateRenderProps(resolved, props, recipe);
236
241
  }
237
- return classPipeline(tag, props, className, variantKey);
242
+ return classPipeline(tag, props, className, recipe);
238
243
  },
239
244
  resolveAria(tag, props) {
240
245
  if (!engine) return { props };
@@ -580,7 +585,7 @@ function isStandaloneTag(tag) {
580
585
  return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
581
586
  }
582
587
 
583
- // ../core/dist/chunk-VU44HAB7.js
588
+ // ../core/dist/chunk-BNVYTMYV.js
584
589
  var IMPLICIT_ROLE_RECORD2 = {
585
590
  article: "article",
586
591
  aside: "complementary",
@@ -1515,7 +1520,7 @@ function getHtmlPropNormalizers(tag) {
1515
1520
  return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
1516
1521
  }
1517
1522
 
1518
- // ../core/dist/chunk-EHCOMLJ4.js
1523
+ // ../core/dist/chunk-3T4EM5FG.js
1519
1524
  var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
1520
1525
  var cx = clsx;
1521
1526
  var cva = (base, config) => (props) => {
@@ -1592,18 +1597,18 @@ var StaticClassResolver = class {
1592
1597
  };
1593
1598
  var VariantClassResolver = class _VariantClassResolver {
1594
1599
  #cvaFn;
1595
- #presetMap;
1600
+ #recipeMap;
1596
1601
  #variantKeys;
1597
1602
  #precomputedClasses;
1598
1603
  #cache = /* @__PURE__ */ new Map();
1599
- constructor(cvaFn, presetMap, variantKeys, precomputedClasses) {
1604
+ constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
1600
1605
  this.#cvaFn = cvaFn ?? null;
1601
- this.#presetMap = Object.freeze(presetMap ?? {});
1606
+ this.#recipeMap = Object.freeze(recipeMap ?? {});
1602
1607
  this.#variantKeys = variantKeys ?? null;
1603
1608
  this.#precomputedClasses = precomputedClasses ?? null;
1604
1609
  }
1605
- resolve({ props, variantKey }) {
1606
- const normalizedKey = variantKey ?? "__none__";
1610
+ resolve({ props, recipe }) {
1611
+ const normalizedKey = recipe ?? "__none__";
1607
1612
  const cacheKey = this.#createCacheKey(props, normalizedKey);
1608
1613
  if (this.#precomputedClasses !== null) {
1609
1614
  const precomputed = this.#precomputedClasses[cacheKey];
@@ -1615,7 +1620,7 @@ var VariantClassResolver = class _VariantClassResolver {
1615
1620
  this.#cache.set(cacheKey, cached);
1616
1621
  return cached;
1617
1622
  }
1618
- const result = this.#compute(props, variantKey);
1623
+ const result = this.#compute(props, recipe);
1619
1624
  this.#cache.set(cacheKey, result);
1620
1625
  if (this.#cache.size > 1e3) {
1621
1626
  const lru = this.#cache.keys().next().value;
@@ -1623,10 +1628,10 @@ var VariantClassResolver = class _VariantClassResolver {
1623
1628
  }
1624
1629
  return result;
1625
1630
  }
1626
- #compute(props, variantKey) {
1631
+ #compute(props, recipe) {
1627
1632
  if (!this.#cvaFn) return "";
1628
- if (!variantKey) return this.#cvaFn(props);
1629
- const preset = this.#presetMap[variantKey];
1633
+ if (!recipe) return this.#cvaFn(props);
1634
+ const preset = this.#recipeMap[recipe];
1630
1635
  if (!preset) return this.#cvaFn(props);
1631
1636
  return this.#cvaFn({ ...preset, ...props });
1632
1637
  }
@@ -1634,15 +1639,15 @@ var VariantClassResolver = class _VariantClassResolver {
1634
1639
  // props (className, id, etc.) produce identical CVA output and must not fragment the cache.
1635
1640
  // Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
1636
1641
  // String is built incrementally to avoid a parts[] array allocation on every render.
1637
- #createCacheKey(props, variantKey) {
1642
+ #createCacheKey(props, recipe) {
1638
1643
  if (this.#variantKeys !== null) {
1639
- let key2 = variantKey;
1644
+ let key2 = recipe;
1640
1645
  for (const k of this.#variantKeys) {
1641
1646
  if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
1642
1647
  }
1643
1648
  return key2;
1644
1649
  }
1645
- let key = variantKey;
1650
+ let key = recipe;
1646
1651
  for (const k of Object.keys(props).sort()) {
1647
1652
  key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
1648
1653
  }
@@ -1667,13 +1672,13 @@ function createClassPipeline(resolved) {
1667
1672
  const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
1668
1673
  const variantResolver = new VariantClassResolver(
1669
1674
  cvaFn,
1670
- resolved.presetMap,
1675
+ resolved.recipeMap,
1671
1676
  variantKeys,
1672
1677
  resolved.precomputedClasses
1673
1678
  );
1674
- return function resolveClasses(tag, props, className, variantKey) {
1675
- const staticClasses = staticResolver.resolve(tag, variantKey !== void 0);
1676
- const variantClasses = variantResolver.resolve({ props, variantKey });
1679
+ return function resolveClasses(tag, props, className, recipe) {
1680
+ const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
1681
+ const variantClasses = variantResolver.resolve({ props, recipe });
1677
1682
  if (!className)
1678
1683
  return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
1679
1684
  return cn(staticClasses, variantClasses, className);
@@ -1776,7 +1781,7 @@ function renderToString(component, props = {}, innerHTML = "") {
1776
1781
  );
1777
1782
  }
1778
1783
  const { bundle } = entry;
1779
- const { as, className, variantKey, class: classAttr, ...rest } = props;
1784
+ const { as, className, recipe, class: classAttr, ...rest } = props;
1780
1785
  const tag = bundle.runtime.resolveTag(as);
1781
1786
  const mergedProps = bundle.runtime.resolveProps(rest);
1782
1787
  const resolvedClass = bundle.runtime.resolveClasses(
@@ -1784,7 +1789,7 @@ function renderToString(component, props = {}, innerHTML = "") {
1784
1789
  mergedProps,
1785
1790
  // Accept both React-style className and HTML-native class
1786
1791
  className ?? classAttr,
1787
- variantKey
1792
+ recipe
1788
1793
  );
1789
1794
  const ariaResult = bundle.runtime.resolveAria(tag, mergedProps);
1790
1795
  const filtered = applyFilter(
@@ -1820,7 +1825,7 @@ function toLooseBundle(bundle) {
1820
1825
  return bundle;
1821
1826
  }
1822
1827
  function resolveHostState(bundle, props) {
1823
- const { as, className, variantKey, ...rest } = props;
1828
+ const { as, className, recipe, ...rest } = props;
1824
1829
  const tag = bundle.runtime.resolveTag(as);
1825
1830
  const mergedProps = bundle.runtime.resolveProps(rest);
1826
1831
  const baseProps = bundle.runtime.options.normalizeFn ? bundle.runtime.options.normalizeFn(mergedProps) : mergedProps;
@@ -1830,7 +1835,7 @@ function resolveHostState(bundle, props) {
1830
1835
  tag,
1831
1836
  normalizedProps,
1832
1837
  className,
1833
- variantKey
1838
+ recipe
1834
1839
  );
1835
1840
  const ariaResult = bundle.runtime.resolveAria(tag, normalizedProps);
1836
1841
  const attributes = applyFilter(
@@ -1871,10 +1876,10 @@ function createContractComponent(options) {
1871
1876
  const bundle = buildRuntime(options);
1872
1877
  const looseBundle = toLooseBundle(bundle);
1873
1878
  const variantKeys = options.styling?.variants ? Object.keys(options.styling.variants) : [];
1874
- const praxisProps = /* @__PURE__ */ new Set(["as", "variantKey", "praxisClass", ...variantKeys]);
1879
+ const praxisProps = /* @__PURE__ */ new Set(["as", "recipe", "praxisClass", ...variantKeys]);
1875
1880
  const staticProps = {
1876
1881
  as: { type: String, attribute: "as" },
1877
- variantKey: { type: String, attribute: "variant-key" },
1882
+ recipe: { type: String, attribute: "variant-key" },
1878
1883
  // External className input — separate from the pipeline-output `class`
1879
1884
  // attribute so _applyPraxis can read it without a circular class→pipeline→class loop.
1880
1885
  praxisClass: { type: String, attribute: "praxis-class" }
@@ -1927,7 +1932,7 @@ function createContractComponent(options) {
1927
1932
  if (attr.name !== "class") props[attr.name] = attr.value;
1928
1933
  }
1929
1934
  props["as"] = self.as;
1930
- props["variantKey"] = self.variantKey;
1935
+ props["recipe"] = self.recipe;
1931
1936
  props["className"] = self.praxisClass;
1932
1937
  for (const key of variantKeys) {
1933
1938
  const val = self[key];
@@ -1948,11 +1953,6 @@ function createContractComponent(options) {
1948
1953
  registerForSsr(PolymorphicLitElement, looseBundle);
1949
1954
  return PolymorphicLitElement;
1950
1955
  }
1951
-
1952
- // ../../adapters/lit/src/define-contract-component.ts
1953
- function defineContractComponent(options) {
1954
- return (factory) => factory(options);
1955
- }
1956
1956
  export {
1957
1957
  createContractComponent,
1958
1958
  defineContractComponent,
@@ -116,9 +116,9 @@ type VariantSelection<V extends VariantMap> = {
116
116
  * Presets are named bundles of variant props that callers activate by key,
117
117
  * avoiding the need to repeat variant combinations at each call site.
118
118
  */
119
- type PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
119
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
120
120
 
121
- interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props extends AnyRecord = AnyRecord, Variants extends Readonly<VariantMap> = Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TAllowed extends ElementType = ElementType> {
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> {
122
122
  default: TDefault;
123
123
  props: Props;
124
124
  variants: Variants;
@@ -126,26 +126,26 @@ interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props
126
126
  allowed: TAllowed;
127
127
  }
128
128
  type VariantsOf<T extends PolymorphicGenerics> = T['variants'];
129
- type PresetOf<T extends PolymorphicGenerics> = T['preset'];
129
+ type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
130
130
  type AllowedOf<T extends PolymorphicGenerics> = T['allowed'];
131
131
 
132
- type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
132
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
133
133
 
134
134
  interface BaseClassOptions {
135
135
  baseClassName?: ClassName;
136
136
  }
137
137
 
138
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
138
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
139
139
 
140
- interface PresetOptions<TVariants extends VariantMap = VariantMap> {
141
- presetMap?: Record<string, PresetTarget<TVariants>>;
140
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
141
+ recipeMap?: Record<string, RecipeTarget<TVariants>>;
142
142
  }
143
143
 
144
144
  interface TagMapOptions {
145
145
  tagMap?: TagMap;
146
146
  }
147
147
 
148
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
148
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
149
149
 
150
150
  type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
151
151
 
@@ -220,7 +220,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
220
220
  readonly allowedAs?: readonly TAllowed[];
221
221
  };
222
222
 
223
- type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
223
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
224
224
  readonly base?: ClassName;
225
225
  readonly variants?: V;
226
226
  readonly defaults?: Partial<DefaultVariants<V>>;
@@ -234,8 +234,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
234
234
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
235
235
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
236
236
  }['normalize'];
237
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
238
- type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
237
+ type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyRecord>;
238
+ 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> = {
239
239
  readonly tag?: TDefault;
240
240
  readonly name?: string;
241
241
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -247,6 +247,8 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
247
247
  type DefaultOf<T extends PolymorphicGenerics> = T['default'];
248
248
  type PropsOf<T extends PolymorphicGenerics> = T['props'];
249
249
 
250
+ declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
251
+
250
252
  type UnknownProps = Record<string, unknown>;
251
253
  type SlotComponent = ComponentType<UnknownProps>;
252
254
 
@@ -262,7 +264,7 @@ type RenderCallbackProps = Readonly<Record<string, unknown>>;
262
264
  * Extends FactoryOptions with React-specific configuration.
263
265
  * slotComponent is intentionally not in core — it is a React rendering concern.
264
266
  */
265
- type ReactFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = FactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps, TAllowed> & {
267
+ type ReactFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = FactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps, TAllowed> & {
266
268
  /** Component used to render the asChild slot. Defaults to the built-in Slot. */
267
269
  slotComponent?: SlotComponent;
268
270
  /**
@@ -305,7 +307,7 @@ type OwnedProps<G extends PolymorphicGenerics> = ComponentProps<G> & ComponentVa
305
307
  type PolymorphicControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = {
306
308
  as?: TAs & AllowedOf<G>;
307
309
  className?: ClassName | undefined;
308
- variantKey?: keyof PresetOf<G>;
310
+ recipe?: keyof RecipeOf<G>;
309
311
  ref?: Ref<ElementRef<TAs>>;
310
312
  };
311
313
  /** @internal Full set of props owned by the component — used as the Omit key in IntrinsicPropsWithoutOwned. */
@@ -375,4 +377,4 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
375
377
 
376
378
  declare function mergeRefs<T>(...refs: (Ref<T> | null | undefined)[]): Ref<T> | null;
377
379
 
378
- export { type AnyRecord as A, type ElementType as E, type FactoryOptions as F, type PresetMap as P, type ReactFactoryOptions as R, Slottable as S, type UnknownProps as U, type VariantMap as V, type EmptyRecord as a, type PolymorphicComponent as b, type PolymorphicGenerics as c, type AnyFactoryOptions as d, type ElementRef as e, type PolymorphicProps as f, type PolymorphicWithAsChild as g, type PolymorphicWithRender as h, type RenderCallbackProps as i, type SlottableProps as j, mergeRefs as m };
380
+ export { type AnyRecord as A, type ElementType as E, type FactoryOptions as F, type PolymorphicComponent as P, type RecipeMap as R, Slottable as S, type UnknownProps as U, type VariantMap as V, type EmptyRecord as a, type ReactFactoryOptions as b, type PolymorphicGenerics as c, type AnyFactoryOptions as d, type ElementRef as e, type PolymorphicProps as f, type PolymorphicWithAsChild as g, type PolymorphicWithRender as h, type RenderCallbackProps as i, type SlottableProps as j, defineContractComponent as k, mergeRefs as m };
@@ -116,9 +116,9 @@ type VariantSelection<V extends VariantMap> = {
116
116
  * Presets are named bundles of variant props that callers activate by key,
117
117
  * avoiding the need to repeat variant combinations at each call site.
118
118
  */
119
- type PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
119
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
120
120
 
121
- interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props extends AnyRecord = AnyRecord, Variants extends Readonly<VariantMap> = Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TAllowed extends ElementType = ElementType> {
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> {
122
122
  default: TDefault;
123
123
  props: Props;
124
124
  variants: Variants;
@@ -126,25 +126,25 @@ interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props
126
126
  allowed: TAllowed;
127
127
  }
128
128
  type VariantsOf<T extends PolymorphicGenerics> = T['variants'];
129
- type PresetOf<T extends PolymorphicGenerics> = T['preset'];
129
+ type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
130
130
 
131
- type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
131
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
132
132
 
133
133
  interface BaseClassOptions {
134
134
  baseClassName?: ClassName;
135
135
  }
136
136
 
137
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
137
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
138
138
 
139
- interface PresetOptions<TVariants extends VariantMap = VariantMap> {
140
- presetMap?: Record<string, PresetTarget<TVariants>>;
139
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
140
+ recipeMap?: Record<string, RecipeTarget<TVariants>>;
141
141
  }
142
142
 
143
143
  interface TagMapOptions {
144
144
  tagMap?: TagMap;
145
145
  }
146
146
 
147
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
147
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
148
148
 
149
149
  type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
150
150
 
@@ -219,7 +219,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
219
219
  readonly allowedAs?: readonly TAllowed[];
220
220
  };
221
221
 
222
- type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
222
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
223
223
  readonly base?: ClassName;
224
224
  readonly variants?: V;
225
225
  readonly defaults?: Partial<DefaultVariants<V>>;
@@ -233,8 +233,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
233
233
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
234
234
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
235
235
  }['normalize'];
236
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
237
- type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
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> = {
238
238
  readonly tag?: TDefault;
239
239
  readonly name?: string;
240
240
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -246,11 +246,13 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
246
246
  type DefaultOf<T extends PolymorphicGenerics> = T['default'];
247
247
  type PropsOf<T extends PolymorphicGenerics> = T['props'];
248
248
 
249
+ declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
250
+
249
251
  type UnknownProps = Record<string, unknown>;
250
252
  type SlotComponent = ComponentType<UnknownProps>;
251
253
  type AnyVNode = VNode<any>;
252
254
 
253
- type PreactFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = FactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps> & {
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> & {
254
256
  /** Component used to render the asChild slot. Defaults to the built-in Slot. */
255
257
  slotComponent?: SlotComponent;
256
258
  /**
@@ -265,7 +267,7 @@ type IntrinsicJSXProps<T extends ElementType> = T extends IntrinsicTag ? JSX.Int
265
267
  type ControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = OmitIndexSignature<PropsOf<G>> & OmitIndexSignature<VariantProps<VariantsOf<G>>> & {
266
268
  as?: TAs;
267
269
  className?: ClassName | undefined;
268
- variantKey?: keyof PresetOf<G>;
270
+ recipe?: keyof RecipeOf<G>;
269
271
  ref?: Ref<ElementRef<TAs>>;
270
272
  };
271
273
  type SharedProps<G extends PolymorphicGenerics, TAs extends ElementType> = Omit<IntrinsicJSXProps<TAs>, keyof ControlProps<G, TAs> | 'children'> & ControlProps<G, TAs>;
@@ -284,9 +286,7 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
284
286
  displayName?: string;
285
287
  };
286
288
 
287
- declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: PreactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
288
-
289
- 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>>;
290
290
 
291
291
  type SlottableProps = {
292
292
  children?: ComponentChildren;