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.
@@ -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,19 +76,16 @@ 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> {
77
83
  compoundVariants?: readonly CompoundVariant<V>[];
78
84
  }
79
85
 
80
- /** The full optional prop surface exposed to callers for a given variant map. */
81
- type VariantProps<V extends VariantMap> = {
82
- [K in keyof V]?: VariantKey<V, K>;
83
- };
86
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
84
87
  type DefaultVariants<V extends VariantMap> = {
85
- [K in keyof V]?: VariantKey<V, K>;
88
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
86
89
  };
87
90
 
88
91
  interface CVADefaults<V extends VariantMap> {
@@ -109,25 +112,25 @@ type VariantSelection<V extends VariantMap> = {
109
112
  * Presets are named bundles of variant props that callers activate by key,
110
113
  * avoiding the need to repeat variant combinations at each call site.
111
114
  */
112
- type PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
115
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
113
116
 
114
- type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
117
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
115
118
 
116
119
  interface BaseClassOptions {
117
120
  baseClassName?: ClassName;
118
121
  }
119
122
 
120
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
123
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
121
124
 
122
- interface PresetOptions<TVariants extends VariantMap = VariantMap> {
123
- presetMap?: Record<string, PresetTarget<TVariants>>;
125
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
126
+ recipeMap?: Record<string, RecipeTarget<TVariants>>;
124
127
  }
125
128
 
126
129
  interface TagMapOptions {
127
130
  tagMap?: TagMap;
128
131
  }
129
132
 
130
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
133
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
131
134
 
132
135
  type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
133
136
 
@@ -202,10 +205,10 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
202
205
  readonly allowedAs?: readonly TAllowed[];
203
206
  };
204
207
 
205
- 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> = {
206
209
  readonly base?: ClassName;
207
210
  readonly variants?: V;
208
- readonly defaults?: Partial<VariantProps<V>>;
211
+ readonly defaults?: Partial<DefaultVariants<V>>;
209
212
  readonly compounds?: readonly CompoundVariant<V>[];
210
213
  readonly presets?: TPreset;
211
214
  readonly tags?: Readonly<TagMap>;
@@ -216,8 +219,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
216
219
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
217
220
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
218
221
  }['normalize'];
219
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
220
- 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> = {
221
224
  readonly tag?: TDefault;
222
225
  readonly name?: string;
223
226
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -228,6 +231,8 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
228
231
 
229
232
  type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolean;
230
233
 
234
+ declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
235
+
231
236
  /**
232
237
  * Options accepted by createContractComponent in the Lit adapter.
233
238
  *
@@ -239,7 +244,7 @@ type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolea
239
244
  * Note: this adapter targets Light DOM composition only. Shadow DOM slot
240
245
  * protocol is intentionally out of scope.
241
246
  */
242
- 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> & {
243
248
  readonly filterProps?: FilterPredicate;
244
249
  };
245
250
 
@@ -254,7 +259,7 @@ type UnknownProps = AnyRecord;
254
259
  type LitContractComponent<TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>> = {
255
260
  new (): LitElement & {
256
261
  as: string | undefined;
257
- variantKey: string | undefined;
262
+ recipe: string | undefined;
258
263
  praxisClass: string | undefined;
259
264
  } & {
260
265
  [K in Extract<keyof TVariants, string>]?: string | null;
@@ -281,9 +286,7 @@ type LitContractComponent<TVariants extends Readonly<VariantMap> = Readonly<Empt
281
286
  * customElements.define('praxis-button', Button)
282
287
  * ```
283
288
  */
284
- 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>;
285
-
286
- 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>;
287
290
 
288
291
  /**
289
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,
@@ -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]?: VariantKey<V, K>;
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 PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
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 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> {
115
122
  default: TDefault;
116
123
  props: Props;
117
124
  variants: Variants;
@@ -119,26 +126,26 @@ interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props
119
126
  allowed: TAllowed;
120
127
  }
121
128
  type VariantsOf<T extends PolymorphicGenerics> = T['variants'];
122
- type PresetOf<T extends PolymorphicGenerics> = T['preset'];
129
+ type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
123
130
  type AllowedOf<T extends PolymorphicGenerics> = T['allowed'];
124
131
 
125
- type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
132
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
126
133
 
127
134
  interface BaseClassOptions {
128
135
  baseClassName?: ClassName;
129
136
  }
130
137
 
131
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
138
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
132
139
 
133
- interface PresetOptions<TVariants extends VariantMap = VariantMap> {
134
- presetMap?: Record<string, PresetTarget<TVariants>>;
140
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
141
+ recipeMap?: Record<string, RecipeTarget<TVariants>>;
135
142
  }
136
143
 
137
144
  interface TagMapOptions {
138
145
  tagMap?: TagMap;
139
146
  }
140
147
 
141
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
148
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
142
149
 
143
150
  type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
144
151
 
@@ -213,10 +220,10 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
213
220
  readonly allowedAs?: readonly TAllowed[];
214
221
  };
215
222
 
216
- 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> = {
217
224
  readonly base?: ClassName;
218
225
  readonly variants?: V;
219
- readonly defaults?: Partial<VariantProps<V>>;
226
+ readonly defaults?: Partial<DefaultVariants<V>>;
220
227
  readonly compounds?: readonly CompoundVariant<V>[];
221
228
  readonly presets?: TPreset;
222
229
  readonly tags?: Readonly<TagMap>;
@@ -227,8 +234,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
227
234
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
228
235
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
229
236
  }['normalize'];
230
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
231
- 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> = {
232
239
  readonly tag?: TDefault;
233
240
  readonly name?: string;
234
241
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -240,6 +247,8 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
240
247
  type DefaultOf<T extends PolymorphicGenerics> = T['default'];
241
248
  type PropsOf<T extends PolymorphicGenerics> = T['props'];
242
249
 
250
+ declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
251
+
243
252
  type UnknownProps = Record<string, unknown>;
244
253
  type SlotComponent = ComponentType<UnknownProps>;
245
254
 
@@ -255,7 +264,7 @@ type RenderCallbackProps = Readonly<Record<string, unknown>>;
255
264
  * Extends FactoryOptions with React-specific configuration.
256
265
  * slotComponent is intentionally not in core — it is a React rendering concern.
257
266
  */
258
- 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> & {
259
268
  /** Component used to render the asChild slot. Defaults to the built-in Slot. */
260
269
  slotComponent?: SlotComponent;
261
270
  /**
@@ -298,7 +307,7 @@ type OwnedProps<G extends PolymorphicGenerics> = ComponentProps<G> & ComponentVa
298
307
  type PolymorphicControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = {
299
308
  as?: TAs & AllowedOf<G>;
300
309
  className?: ClassName | undefined;
301
- variantKey?: keyof PresetOf<G>;
310
+ recipe?: keyof RecipeOf<G>;
302
311
  ref?: Ref<ElementRef<TAs>>;
303
312
  };
304
313
  /** @internal Full set of props owned by the component — used as the Omit key in IntrinsicPropsWithoutOwned. */
@@ -368,4 +377,4 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
368
377
 
369
378
  declare function mergeRefs<T>(...refs: (Ref<T> | null | undefined)[]): Ref<T> | null;
370
379
 
371
- 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 };