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,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,25 +126,25 @@ interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props
119
126
  allowed: TAllowed;
120
127
  }
121
128
  type VariantsOf<T extends PolymorphicGenerics> = T['variants'];
122
- type PresetOf<T extends PolymorphicGenerics> = T['preset'];
129
+ type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
123
130
 
124
- type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
131
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
125
132
 
126
133
  interface BaseClassOptions {
127
134
  baseClassName?: ClassName;
128
135
  }
129
136
 
130
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
137
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
131
138
 
132
- interface PresetOptions<TVariants extends VariantMap = VariantMap> {
133
- presetMap?: Record<string, PresetTarget<TVariants>>;
139
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
140
+ recipeMap?: Record<string, RecipeTarget<TVariants>>;
134
141
  }
135
142
 
136
143
  interface TagMapOptions {
137
144
  tagMap?: TagMap;
138
145
  }
139
146
 
140
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
147
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
141
148
 
142
149
  type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
143
150
 
@@ -212,10 +219,10 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
212
219
  readonly allowedAs?: readonly TAllowed[];
213
220
  };
214
221
 
215
- type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends 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> = {
216
223
  readonly base?: ClassName;
217
224
  readonly variants?: V;
218
- readonly defaults?: Partial<VariantProps<V>>;
225
+ readonly defaults?: Partial<DefaultVariants<V>>;
219
226
  readonly compounds?: readonly CompoundVariant<V>[];
220
227
  readonly presets?: TPreset;
221
228
  readonly tags?: Readonly<TagMap>;
@@ -226,8 +233,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
226
233
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
227
234
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
228
235
  }['normalize'];
229
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
230
- 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> = {
231
238
  readonly tag?: TDefault;
232
239
  readonly name?: string;
233
240
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -239,11 +246,13 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
239
246
  type DefaultOf<T extends PolymorphicGenerics> = T['default'];
240
247
  type PropsOf<T extends PolymorphicGenerics> = T['props'];
241
248
 
249
+ declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
250
+
242
251
  type UnknownProps = Record<string, unknown>;
243
252
  type SolidElement = JSX.Element;
244
253
  type SlotRenderFn = (props: UnknownProps) => SolidElement;
245
254
 
246
- type SolidFactoryOptions<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 SolidFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = FactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps> & {
247
256
  /**
248
257
  * Return true for any prop key that should be consumed but not forwarded to the DOM.
249
258
  * Receives `runtime.options.variantKeys` as a convenience if needed.
@@ -256,7 +265,7 @@ type IntrinsicJSXProps<T extends ElementType> = T extends IntrinsicTag ? JSX.Int
256
265
  type ControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = OmitIndexSignature<PropsOf<G>> & OmitIndexSignature<VariantProps<VariantsOf<G>>> & {
257
266
  as?: TAs;
258
267
  class?: ClassName | undefined;
259
- variantKey?: keyof PresetOf<G>;
268
+ recipe?: keyof RecipeOf<G>;
260
269
  ref?: (el: ElementRef<TAs>) => void;
261
270
  };
262
271
  type SharedProps<G extends PolymorphicGenerics, TAs extends ElementType> = Omit<IntrinsicJSXProps<TAs>, keyof ControlProps<G, TAs> | 'children' | 'ref'> & ControlProps<G, TAs>;
@@ -265,7 +274,7 @@ type AsChildProps<G extends PolymorphicGenerics> = Partial<OmitIndexSignature<Pr
265
274
  asChild: true;
266
275
  children: SlotRenderFn;
267
276
  class?: ClassName | undefined;
268
- variantKey?: keyof PresetOf<G>;
277
+ recipe?: keyof RecipeOf<G>;
269
278
  ref?: unknown;
270
279
  };
271
280
  type PolymorphicProps<G extends PolymorphicGenerics, TAs extends ElementType = DefaultOf<G>> = Simplify<(SharedProps<G, TAs> & {
@@ -277,8 +286,6 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
277
286
  displayName?: string;
278
287
  };
279
288
 
280
- declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: SolidFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
281
-
282
- declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
289
+ declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: SolidFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
283
290
 
284
291
  export { type AnyFactoryOptions, type ElementRef, type ElementType, type EmptyRecord, type PolymorphicComponent, type PolymorphicGenerics, type PolymorphicProps, type SolidFactoryOptions, createContractComponent, defineContractComponent };
@@ -17,7 +17,12 @@ function applyFilter(props, filterProps, variantKeys) {
17
17
  return out;
18
18
  }
19
19
 
20
- // ../core/dist/chunk-XFCAUPVZ.js
20
+ // ../../lib/adapter-utils/src/define-component.ts
21
+ function defineContractComponent(options) {
22
+ return (factory) => factory(options);
23
+ }
24
+
25
+ // ../core/dist/chunk-KKSHJDE7.js
21
26
  function makeResolveTag(defaultTag) {
22
27
  return function tag(as) {
23
28
  return as ?? defaultTag;
@@ -86,7 +91,7 @@ function resolveFactoryOptions(options = {}) {
86
91
  ...whenDefined("defaultProps", options.defaults),
87
92
  ...whenDefined("baseClassName", styling?.base),
88
93
  ...whenDefined("tagMap", styling?.tags),
89
- ...whenDefined("presetMap", styling?.presets),
94
+ ...whenDefined("recipeMap", styling?.presets),
90
95
  ...whenDefined("variants", styling?.variants),
91
96
  ...whenDefined("defaultVariants", styling?.defaults),
92
97
  ...whenDefined("compoundVariants", styling?.compounds),
@@ -127,10 +132,10 @@ function validateFactoryOptions(resolved) {
127
132
  }
128
133
  }
129
134
  };
130
- const { presetMap } = resolved;
131
- if (presetMap) {
132
- for (const presetKey in presetMap) {
133
- checkSelection(`preset "${presetKey}"`, presetMap[presetKey]);
135
+ const { recipeMap } = resolved;
136
+ if (recipeMap) {
137
+ for (const recipeKey in recipeMap) {
138
+ checkSelection(`preset "${recipeKey}"`, recipeMap[recipeKey]);
134
139
  }
135
140
  }
136
141
  if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
@@ -166,12 +171,12 @@ function report2(strict, message) {
166
171
  function label(name) {
167
172
  return name ? `[${name}]` : "[createContractComponent]";
168
173
  }
169
- function validateRenderProps(options, props, presetKey) {
170
- const { strict, presetMap, variants, displayName } = options;
174
+ function validateRenderProps(options, props, recipeKey) {
175
+ const { strict, recipeMap, variants, displayName } = options;
171
176
  if (!strict) return;
172
177
  const tag = label(displayName);
173
- if (presetKey !== void 0 && (!presetMap || !Object.hasOwn(presetMap, presetKey))) {
174
- report2(strict, `${tag} Unknown presetKey "${presetKey}" \u2014 no preset with that name exists.`);
178
+ if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
179
+ report2(strict, `${tag} Unknown recipeKey "${recipeKey}" \u2014 no preset with that name exists.`);
175
180
  }
176
181
  if (variants) {
177
182
  for (const key in variants) {
@@ -209,8 +214,8 @@ function assertPluginShape(result) {
209
214
  }
210
215
  function guardPipeline(pipeline) {
211
216
  if (process.env.NODE_ENV === "production") return pipeline;
212
- return function guardedPipeline(tag, props, className, variantKey) {
213
- const result = pipeline(tag, props, className, variantKey);
217
+ return function guardedPipeline(tag, props, className, recipe) {
218
+ const result = pipeline(tag, props, className, recipe);
214
219
  if (typeof result !== "string")
215
220
  panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
216
221
  return result;
@@ -235,11 +240,11 @@ function createRuntimeMethods(resolved, classPipeline, engine) {
235
240
  resolveProps(props) {
236
241
  return mergeProps(resolved.defaultProps, props);
237
242
  },
238
- resolveClasses(tag, props, className, variantKey) {
243
+ resolveClasses(tag, props, className, recipe) {
239
244
  if (process.env.NODE_ENV !== "production") {
240
- validateRenderProps(resolved, props, variantKey);
245
+ validateRenderProps(resolved, props, recipe);
241
246
  }
242
- return classPipeline(tag, props, className, variantKey);
247
+ return classPipeline(tag, props, className, recipe);
243
248
  },
244
249
  resolveAria(tag, props) {
245
250
  if (!engine) return { props };
@@ -588,7 +593,7 @@ function isKnownAriaRole(value) {
588
593
  return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
589
594
  }
590
595
 
591
- // ../core/dist/chunk-VU44HAB7.js
596
+ // ../core/dist/chunk-BNVYTMYV.js
592
597
  var IMPLICIT_ROLE_RECORD2 = {
593
598
  article: "article",
594
599
  aside: "complementary",
@@ -1523,7 +1528,7 @@ function getHtmlPropNormalizers(tag) {
1523
1528
  return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
1524
1529
  }
1525
1530
 
1526
- // ../core/dist/chunk-EHCOMLJ4.js
1531
+ // ../core/dist/chunk-3T4EM5FG.js
1527
1532
  var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
1528
1533
  var cx = clsx;
1529
1534
  var cva = (base, config) => (props) => {
@@ -1600,18 +1605,18 @@ var StaticClassResolver = class {
1600
1605
  };
1601
1606
  var VariantClassResolver = class _VariantClassResolver {
1602
1607
  #cvaFn;
1603
- #presetMap;
1608
+ #recipeMap;
1604
1609
  #variantKeys;
1605
1610
  #precomputedClasses;
1606
1611
  #cache = /* @__PURE__ */ new Map();
1607
- constructor(cvaFn, presetMap, variantKeys, precomputedClasses) {
1612
+ constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
1608
1613
  this.#cvaFn = cvaFn ?? null;
1609
- this.#presetMap = Object.freeze(presetMap ?? {});
1614
+ this.#recipeMap = Object.freeze(recipeMap ?? {});
1610
1615
  this.#variantKeys = variantKeys ?? null;
1611
1616
  this.#precomputedClasses = precomputedClasses ?? null;
1612
1617
  }
1613
- resolve({ props, variantKey }) {
1614
- const normalizedKey = variantKey ?? "__none__";
1618
+ resolve({ props, recipe }) {
1619
+ const normalizedKey = recipe ?? "__none__";
1615
1620
  const cacheKey = this.#createCacheKey(props, normalizedKey);
1616
1621
  if (this.#precomputedClasses !== null) {
1617
1622
  const precomputed = this.#precomputedClasses[cacheKey];
@@ -1623,7 +1628,7 @@ var VariantClassResolver = class _VariantClassResolver {
1623
1628
  this.#cache.set(cacheKey, cached);
1624
1629
  return cached;
1625
1630
  }
1626
- const result = this.#compute(props, variantKey);
1631
+ const result = this.#compute(props, recipe);
1627
1632
  this.#cache.set(cacheKey, result);
1628
1633
  if (this.#cache.size > 1e3) {
1629
1634
  const lru = this.#cache.keys().next().value;
@@ -1631,10 +1636,10 @@ var VariantClassResolver = class _VariantClassResolver {
1631
1636
  }
1632
1637
  return result;
1633
1638
  }
1634
- #compute(props, variantKey) {
1639
+ #compute(props, recipe) {
1635
1640
  if (!this.#cvaFn) return "";
1636
- if (!variantKey) return this.#cvaFn(props);
1637
- const preset = this.#presetMap[variantKey];
1641
+ if (!recipe) return this.#cvaFn(props);
1642
+ const preset = this.#recipeMap[recipe];
1638
1643
  if (!preset) return this.#cvaFn(props);
1639
1644
  return this.#cvaFn({ ...preset, ...props });
1640
1645
  }
@@ -1642,15 +1647,15 @@ var VariantClassResolver = class _VariantClassResolver {
1642
1647
  // props (className, id, etc.) produce identical CVA output and must not fragment the cache.
1643
1648
  // Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
1644
1649
  // String is built incrementally to avoid a parts[] array allocation on every render.
1645
- #createCacheKey(props, variantKey) {
1650
+ #createCacheKey(props, recipe) {
1646
1651
  if (this.#variantKeys !== null) {
1647
- let key2 = variantKey;
1652
+ let key2 = recipe;
1648
1653
  for (const k of this.#variantKeys) {
1649
1654
  if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
1650
1655
  }
1651
1656
  return key2;
1652
1657
  }
1653
- let key = variantKey;
1658
+ let key = recipe;
1654
1659
  for (const k of Object.keys(props).sort()) {
1655
1660
  key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
1656
1661
  }
@@ -1675,13 +1680,13 @@ function createClassPipeline(resolved) {
1675
1680
  const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
1676
1681
  const variantResolver = new VariantClassResolver(
1677
1682
  cvaFn,
1678
- resolved.presetMap,
1683
+ resolved.recipeMap,
1679
1684
  variantKeys,
1680
1685
  resolved.precomputedClasses
1681
1686
  );
1682
- return function resolveClasses(tag, props, className, variantKey) {
1683
- const staticClasses = staticResolver.resolve(tag, variantKey !== void 0);
1684
- const variantClasses = variantResolver.resolve({ props, variantKey });
1687
+ return function resolveClasses(tag, props, className, recipe) {
1688
+ const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
1689
+ const variantClasses = variantResolver.resolve({ props, recipe });
1685
1690
  if (!className)
1686
1691
  return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
1687
1692
  return cn(staticClasses, variantClasses, className);
@@ -1778,7 +1783,7 @@ function buildRuntime(options) {
1778
1783
  import { createEffect, createMemo, splitProps } from "solid-js";
1779
1784
  import { Dynamic } from "solid-js/web";
1780
1785
  import { jsx } from "solid-js/jsx-runtime";
1781
- var SPLIT_KEYS = ["as", "asChild", "children", "class", "variantKey", "ref"];
1786
+ var SPLIT_KEYS = ["as", "asChild", "children", "class", "recipe", "ref"];
1782
1787
  function toChildArray(children) {
1783
1788
  if (children === void 0 || children === null) return [];
1784
1789
  if (Array.isArray(children)) return children;
@@ -1842,7 +1847,7 @@ function render({
1842
1847
  tag(),
1843
1848
  normalizedProps(),
1844
1849
  known.class,
1845
- known.variantKey
1850
+ known.recipe
1846
1851
  )
1847
1852
  );
1848
1853
  const filteredProps = createMemo(
@@ -1875,11 +1880,6 @@ function createContractComponent(options) {
1875
1880
  }
1876
1881
  return Component;
1877
1882
  }
1878
-
1879
- // ../../adapters/solid/src/define-contract-component.ts
1880
- function defineContractComponent(options) {
1881
- return (factory) => factory(options);
1882
- }
1883
1883
  export {
1884
1884
  createContractComponent,
1885
1885
  defineContractComponent
@@ -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';
@@ -59,9 +65,9 @@ type ValidResult = {
59
65
 
60
66
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
61
67
 
62
- type VariantValue = string | string[];
68
+ type VariantValue$1 = string | string[];
63
69
 
64
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
70
+ type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
65
71
 
66
72
  type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
67
73
 
@@ -75,19 +81,16 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
75
81
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
76
82
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
77
83
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
78
- class: VariantValue;
84
+ class: VariantValue$1;
79
85
  };
80
86
 
81
87
  interface CVACompounds<V extends VariantMap> {
82
88
  compoundVariants?: readonly CompoundVariant<V>[];
83
89
  }
84
90
 
85
- /** The full optional prop surface exposed to callers for a given variant map. */
86
- type VariantProps<V extends VariantMap> = {
87
- [K in keyof V]?: VariantKey<V, K>;
88
- };
91
+ type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
89
92
  type DefaultVariants<V extends VariantMap> = {
90
- [K in keyof V]?: VariantKey<V, K>;
93
+ [K in keyof V]?: VariantValue<keyof V[K] & string>;
91
94
  };
92
95
 
93
96
  interface CVADefaults<V extends VariantMap> {
@@ -114,9 +117,9 @@ type VariantSelection<V extends VariantMap> = {
114
117
  * Presets are named bundles of variant props that callers activate by key,
115
118
  * avoiding the need to repeat variant combinations at each call site.
116
119
  */
117
- type PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
120
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
118
121
 
119
- 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> {
122
+ 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> {
120
123
  default: TDefault;
121
124
  props: Props;
122
125
  variants: Variants;
@@ -124,23 +127,23 @@ interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props
124
127
  allowed: TAllowed;
125
128
  }
126
129
 
127
- type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
130
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
128
131
 
129
132
  interface BaseClassOptions {
130
133
  baseClassName?: ClassName;
131
134
  }
132
135
 
133
- type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
136
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
134
137
 
135
- interface PresetOptions<TVariants extends VariantMap = VariantMap> {
136
- presetMap?: Record<string, PresetTarget<TVariants>>;
138
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
139
+ recipeMap?: Record<string, RecipeTarget<TVariants>>;
137
140
  }
138
141
 
139
142
  interface TagMapOptions {
140
143
  tagMap?: TagMap;
141
144
  }
142
145
 
143
- type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
146
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
144
147
 
145
148
  type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
146
149
 
@@ -215,10 +218,10 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
215
218
  readonly allowedAs?: readonly TAllowed[];
216
219
  };
217
220
 
218
- type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
221
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
219
222
  readonly base?: ClassName;
220
223
  readonly variants?: V;
221
- readonly defaults?: Partial<VariantProps<V>>;
224
+ readonly defaults?: Partial<DefaultVariants<V>>;
222
225
  readonly compounds?: readonly CompoundVariant<V>[];
223
226
  readonly presets?: TPreset;
224
227
  readonly tags?: Readonly<TagMap>;
@@ -229,8 +232,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
229
232
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
230
233
  normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
231
234
  }['normalize'];
232
- type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
233
- 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> = {
235
+ type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyRecord>;
236
+ 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> = {
234
237
  readonly tag?: TDefault;
235
238
  readonly name?: string;
236
239
  readonly defaults?: Partial<NoInfer<Props>>;
@@ -239,14 +242,14 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
239
242
  readonly enforcement?: EnforcementOptions<TAllowed>;
240
243
  };
241
244
 
242
- type ResolvedFactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>> = {
245
+ type ResolvedFactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>> = {
243
246
  readonly defaultTag: TDefault;
244
247
  readonly baseClassName?: ClassName;
245
248
  readonly defaultProps?: Partial<Props>;
246
249
  readonly tagMap?: Readonly<TagMap>;
247
- readonly presetMap?: TPreset;
250
+ readonly recipeMap?: TPreset;
248
251
  readonly variants?: V;
249
- readonly defaultVariants?: Partial<VariantProps<V>>;
252
+ readonly defaultVariants?: Partial<DefaultVariants<V>>;
250
253
  readonly compoundVariants?: readonly CompoundVariant<V>[];
251
254
  readonly displayName?: string;
252
255
  readonly strict: StrictMode;
@@ -263,7 +266,7 @@ type ResolveAriaFn = <P extends IntrinsicProps>(tag: ElementType, props: P) => {
263
266
  props: P;
264
267
  };
265
268
 
266
- type ResolveClassNameFn<Props extends AnyRecord, TSlot extends string = never> = (tag: ElementType, props: Props, className?: ClassName, variantKey?: TSlot) => string;
269
+ type ResolveClassNameFn<Props extends AnyRecord, TSlot extends string = never> = (tag: ElementType, props: Props, className?: ClassName, recipe?: TSlot) => string;
267
270
 
268
271
  type ResolvePropsFn<Props extends AnyRecord> = <P extends Partial<Props>>(props: P) => Simplify<Omit<Props, keyof P> & P>;
269
272
 
@@ -274,7 +277,7 @@ type RuntimePluginField<TPlugin extends ClassPlugin | undefined> = TPlugin exten
274
277
  readonly hasStyling: true;
275
278
  } : EmptyRecord;
276
279
 
277
- type PolymorphicRuntime<TDefault extends ElementType, Props extends AnyRecord, Variants extends VariantMap, TSlot extends string = never, TPreset extends PresetMap<Variants> = Readonly<Record<string, VariantSelection<Variants>>>, TPlugin extends ClassPlugin | undefined = ClassPlugin | undefined> = RuntimePluginField<TPlugin> & {
280
+ type PolymorphicRuntime<TDefault extends ElementType, Props extends AnyRecord, Variants extends VariantMap, TSlot extends string = never, TPreset extends RecipeMap<Variants> = Readonly<Record<string, VariantSelection<Variants>>>, TPlugin extends ClassPlugin | undefined = ClassPlugin | undefined> = RuntimePluginField<TPlugin> & {
278
281
  readonly options: Readonly<ResolvedFactoryOptions<TDefault, Props, Variants, TPreset>>;
279
282
  readonly resolveTag: ResolveTagFn<TDefault>;
280
283
  readonly resolveProps: ResolvePropsFn<Props>;
@@ -296,7 +299,7 @@ declare class ChildrenEvaluator extends StrictBase {
296
299
  evaluate(children: unknown[]): void;
297
300
  }
298
301
 
299
- declare function createPolymorphic<TDefault extends ElementType, Props extends AnyRecord, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>>(options?: FactoryOptions<TDefault, Props, Variants, TPreset>): PolymorphicRuntime<TDefault, Props, Variants, Extract<keyof TPreset, string>, TPreset>;
302
+ declare function createPolymorphic<TDefault extends ElementType, Props extends AnyRecord, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>>(options?: FactoryOptions<TDefault, Props, Variants, TPreset>): PolymorphicRuntime<TDefault, Props, Variants, Extract<keyof TPreset, string>, TPreset>;
300
303
 
301
304
  declare class SlotValidator extends StrictBase {
302
305
  #private;
@@ -316,9 +319,11 @@ type BuiltChildrenEvaluator<TOptions extends WithChildRules> = TOptions extends
316
319
  childrenEvaluator: ChildrenEvaluator;
317
320
  } : EmptyRecord;
318
321
 
322
+ declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
323
+
319
324
  type UnknownProps = Record<string, unknown>;
320
325
 
321
- type SvelteFactoryOptions<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> & {
326
+ type SvelteFactoryOptions<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> & {
322
327
  /**
323
328
  * Return true for any prop key that should be consumed but not forwarded to the DOM.
324
329
  * Receives `runtime.options.variantKeys` as a convenience if needed.
@@ -326,7 +331,7 @@ type SvelteFactoryOptions<TDefault extends ElementType, Props extends UnknownPro
326
331
  filterProps?: (key: string, variantKeys: ReadonlySet<string>) => boolean;
327
332
  };
328
333
 
329
- type TypedRuntime<G extends PolymorphicGenerics> = ReturnType<typeof createPolymorphic<DefaultOf<G>, PropsOf<G>, VariantsOf<G>, PresetOf<G>>>;
334
+ type TypedRuntime<G extends PolymorphicGenerics> = ReturnType<typeof createPolymorphic<DefaultOf<G>, PropsOf<G>, VariantsOf<G>, RecipeOf<G>>>;
330
335
 
331
336
  type BuiltRuntime<G extends PolymorphicGenerics = PolymorphicGenerics, TOptions extends WithChildRules = WithChildRules> = BuiltChildrenEvaluator<TOptions> & {
332
337
  runtime: TypedRuntime<G>;
@@ -334,8 +339,6 @@ type BuiltRuntime<G extends PolymorphicGenerics = PolymorphicGenerics, TOptions
334
339
  slotValidator: SlotValidator;
335
340
  };
336
341
 
337
- 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, TOptions extends WithChildRules = SvelteFactoryOptions<TDefault, Props & TPluginProps, Variants, TPreset>>(options: SvelteFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps> & TOptions): BuiltRuntime<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>, TOptions>;
338
-
339
- declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
342
+ 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, TOptions extends WithChildRules = SvelteFactoryOptions<TDefault, Props & TPluginProps, Variants, TPreset>>(options: SvelteFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps> & TOptions): BuiltRuntime<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>, TOptions>;
340
343
 
341
344
  export { type AnyFactoryOptions, type BuiltRuntime, type ElementType, type EmptyRecord, type FilterPredicate, type PolymorphicGenerics, type SvelteFactoryOptions, type UnknownProps, type WithChildRules, createContractComponent, defineContractComponent };