cva 1.0.0-beta.10 → 1.0.0-beta.11

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.
@@ -66,19 +66,7 @@ type DefaultsOf<Component> = Component extends {
66
66
  };
67
67
  } ? D extends undefined ? {} : D : {};
68
68
  type MergedDefaultVariants<T extends readonly unknown[]> = T extends readonly [infer Head, ...infer Rest] ? RightMerge<DefaultsOf<Head>, MergedDefaultVariants<Rest>> : {};
69
- type ComponentProps<Component extends (...args: any) => any> = Omit<OmitUndefined<Parameters<Component>[0]>, "class" | "className">;
70
69
  type VariantProps<Component extends (...args: any) => any> = Omit<OmitUndefined<Parameters<Component>[0]>, "class" | "className" | InternalVariantKey>;
71
- /**
72
- * @deprecated Use the `composes` property inside `cva` instead.
73
- * @example
74
- * // Before
75
- * const card = compose(box, stack)
76
- * // After
77
- * const card = cva({ composes: [box, stack] })
78
- */
79
- interface Compose<T extends ClassValue = ClassValue> {
80
- <Components extends readonly unknown[]>(...components: Components & (Components[number] extends CVAComponentShape ? unknown : never)): (props?: (UnionToIntersection<{ [K in keyof Components]: Components[K] extends CVAComponentShape ? ComponentProps<Components[K]> : never; }[number]> | undefined) & CVAClassProp<T>) => string;
81
- }
82
70
  interface CX<T extends ClassValue = ClassValue> {
83
71
  (...inputs: T[]): string;
84
72
  }
@@ -115,8 +103,8 @@ interface CVA<T extends ClassValue = ClassValue> {
115
103
  }
116
104
  interface DefineConfigOptions<TCX extends AnyCX = CX> {
117
105
  /**
118
- * The class name concatenator used by `cva`, `cx`, and `compose`. It owns
119
- * the class name grammar entirely: cva assembles the authored values
106
+ * The class name concatenator used by `cva` and `cx`. It owns the class
107
+ * name grammar entirely: cva assembles the authored values
120
108
  * (composed component outputs, `base`, matched variant and compound
121
109
  * variant values, `class`/`className`) and passes them through verbatim,
122
110
  * one argument each, without interpreting them.
@@ -128,33 +116,14 @@ interface DefineConfigOptions<TCX extends AnyCX = CX> {
128
116
  * full clsx-flavored `ClassValue` grammar.
129
117
  */
130
118
  cx: TCX & CXConstraint<TCX>;
131
- hooks?: {
132
- /**
133
- * @deprecated please use the `cx` option instead
134
- */
135
- "cx:done"?: (className: string) => string;
136
- /**
137
- * @deprecated please use the `cx` option instead
138
- */
139
- onComplete?: (className: string) => string;
140
- };
141
119
  }
142
120
  interface DefineConfig {
143
121
  <TCX extends AnyCX>(options: DefineConfigOptions<TCX>): {
144
- /**
145
- * @deprecated Use the `composes` property inside `cva` instead.
146
- * @example
147
- * // Before
148
- * const card = compose(box, stack)
149
- * // After
150
- * const card = cva({ composes: [box, stack] })
151
- */
152
- compose: Compose<CXInput<TCX>>;
153
122
  cx: CX<CXInput<TCX>>;
154
123
  cva: CVA<CXInput<TCX>>;
155
124
  };
156
125
  }
157
126
  declare const defineConfig: DefineConfig;
158
127
  //#endregion
159
- export { defineConfig as _, CVAVariantShape as a, InternalVariantKey as b, CXOptions as c, ClassDictionary as d, ClassValue as f, VariantProps as g, DefineConfigOptions as h, CVAComponentShape as i, CXReturn as l, DefineConfig as m, CVA as n, CX as o, Compose as p, CVAComponent as r, CXInput as s, AnyCX as t, ClassArray as u, CVAComponentConfig as v, StringToBoolean as x, InternalOnlyWarning as y };
160
- //# sourceMappingURL=config-CE5oXWBq.d.cts.map
128
+ export { CVAComponentConfig as _, CVAVariantShape as a, StringToBoolean as b, CXOptions as c, ClassDictionary as d, ClassValue as f, defineConfig as g, VariantProps as h, CVAComponentShape as i, CXReturn as l, DefineConfigOptions as m, CVA as n, CX as o, DefineConfig as p, CVAComponent as r, CXInput as s, AnyCX as t, ClassArray as u, InternalOnlyWarning as v, InternalVariantKey as y };
129
+ //# sourceMappingURL=config-BnHlj-cB.d.cts.map
@@ -66,19 +66,7 @@ type DefaultsOf<Component> = Component extends {
66
66
  };
67
67
  } ? D extends undefined ? {} : D : {};
68
68
  type MergedDefaultVariants<T extends readonly unknown[]> = T extends readonly [infer Head, ...infer Rest] ? RightMerge<DefaultsOf<Head>, MergedDefaultVariants<Rest>> : {};
69
- type ComponentProps<Component extends (...args: any) => any> = Omit<OmitUndefined<Parameters<Component>[0]>, "class" | "className">;
70
69
  type VariantProps<Component extends (...args: any) => any> = Omit<OmitUndefined<Parameters<Component>[0]>, "class" | "className" | InternalVariantKey>;
71
- /**
72
- * @deprecated Use the `composes` property inside `cva` instead.
73
- * @example
74
- * // Before
75
- * const card = compose(box, stack)
76
- * // After
77
- * const card = cva({ composes: [box, stack] })
78
- */
79
- interface Compose<T extends ClassValue = ClassValue> {
80
- <Components extends readonly unknown[]>(...components: Components & (Components[number] extends CVAComponentShape ? unknown : never)): (props?: (UnionToIntersection<{ [K in keyof Components]: Components[K] extends CVAComponentShape ? ComponentProps<Components[K]> : never; }[number]> | undefined) & CVAClassProp<T>) => string;
81
- }
82
70
  interface CX<T extends ClassValue = ClassValue> {
83
71
  (...inputs: T[]): string;
84
72
  }
@@ -115,8 +103,8 @@ interface CVA<T extends ClassValue = ClassValue> {
115
103
  }
116
104
  interface DefineConfigOptions<TCX extends AnyCX = CX> {
117
105
  /**
118
- * The class name concatenator used by `cva`, `cx`, and `compose`. It owns
119
- * the class name grammar entirely: cva assembles the authored values
106
+ * The class name concatenator used by `cva` and `cx`. It owns the class
107
+ * name grammar entirely: cva assembles the authored values
120
108
  * (composed component outputs, `base`, matched variant and compound
121
109
  * variant values, `class`/`className`) and passes them through verbatim,
122
110
  * one argument each, without interpreting them.
@@ -128,33 +116,14 @@ interface DefineConfigOptions<TCX extends AnyCX = CX> {
128
116
  * full clsx-flavored `ClassValue` grammar.
129
117
  */
130
118
  cx: TCX & CXConstraint<TCX>;
131
- hooks?: {
132
- /**
133
- * @deprecated please use the `cx` option instead
134
- */
135
- "cx:done"?: (className: string) => string;
136
- /**
137
- * @deprecated please use the `cx` option instead
138
- */
139
- onComplete?: (className: string) => string;
140
- };
141
119
  }
142
120
  interface DefineConfig {
143
121
  <TCX extends AnyCX>(options: DefineConfigOptions<TCX>): {
144
- /**
145
- * @deprecated Use the `composes` property inside `cva` instead.
146
- * @example
147
- * // Before
148
- * const card = compose(box, stack)
149
- * // After
150
- * const card = cva({ composes: [box, stack] })
151
- */
152
- compose: Compose<CXInput<TCX>>;
153
122
  cx: CX<CXInput<TCX>>;
154
123
  cva: CVA<CXInput<TCX>>;
155
124
  };
156
125
  }
157
126
  declare const defineConfig: DefineConfig;
158
127
  //#endregion
159
- export { defineConfig as _, CVAVariantShape as a, InternalVariantKey as b, CXOptions as c, ClassDictionary as d, ClassValue as f, VariantProps as g, DefineConfigOptions as h, CVAComponentShape as i, CXReturn as l, DefineConfig as m, CVA as n, CX as o, Compose as p, CVAComponent as r, CXInput as s, AnyCX as t, ClassArray as u, CVAComponentConfig as v, StringToBoolean as x, InternalOnlyWarning as y };
160
- //# sourceMappingURL=config-CE5oXWBq.d.mts.map
128
+ export { CVAComponentConfig as _, CVAVariantShape as a, StringToBoolean as b, CXOptions as c, ClassDictionary as d, ClassValue as f, defineConfig as g, VariantProps as h, CVAComponentShape as i, CXReturn as l, DefineConfigOptions as m, CVA as n, CX as o, DefineConfig as p, CVAComponent as r, CXInput as s, AnyCX as t, ClassArray as u, InternalOnlyWarning as v, InternalVariantKey as y };
129
+ //# sourceMappingURL=config-BnHlj-cB.d.mts.map
package/dist/config.cjs CHANGED
@@ -59,16 +59,16 @@ const prepareVariants = (localVariants, defaults) => {
59
59
  names.push(key);
60
60
  maps.push(localVariants[key]);
61
61
  }
62
- if (!names.length) return {
63
- variantKeys: noValues,
64
- variantMaps: noValues,
65
- defaultClasses: noValues
66
- };
67
- return {
68
- variantKeys: names.slice(),
69
- variantMaps: maps.slice(),
70
- defaultClasses: names.map((key, i) => maps[i][falsyToString(defaults[key])])
71
- };
62
+ if (!names.length) return [
63
+ noValues,
64
+ noValues,
65
+ noValues
66
+ ];
67
+ return [
68
+ names.slice(),
69
+ maps.slice(),
70
+ names.map((key, i) => maps[i][falsyToString(defaults[key])])
71
+ ];
72
72
  };
73
73
  const compoundMatches = (compound, indexes, selectors, values) => {
74
74
  for (let i = compound.start; i < compound.end; i++) {
@@ -108,13 +108,13 @@ const prepareCompounds = (compoundVariants, variantKeys, defaults) => {
108
108
  }
109
109
  const defaultValues = keys.map((key) => defaults[key]);
110
110
  for (let i = 0; i < compounds.length; i++) compounds[i].matchesDefaults = compoundMatches(compounds[i], indexes, selectors, defaultValues);
111
- return {
112
- keys: keys.slice(),
111
+ return [
112
+ keys.slice(),
113
113
  defaultValues,
114
- compounds: compounds.slice(),
115
- indexes: indexes.slice(),
116
- selectors: selectors.slice()
117
- };
114
+ compounds.slice(),
115
+ indexes.slice(),
116
+ selectors.slice()
117
+ ];
118
118
  };
119
119
  const createPlainComponent = (cxArray, defaultOut, singleDefaultClass) => (input) => {
120
120
  const props = input || empty;
@@ -127,13 +127,7 @@ const createPlainComponent = (cxArray, defaultOut, singleDefaultClass) => (input
127
127
  return cxArray(out);
128
128
  };
129
129
  const defineConfig = ((options) => {
130
- const cxArray = (inputs) => {
131
- const className = Reflect.apply(options.cx, options, inputs);
132
- const hooks = options.hooks || empty;
133
- let hook = hooks["cx:done"];
134
- if (hook == null) hook = hooks.onComplete;
135
- return hook ? hook(className) : className;
136
- };
130
+ const cxArray = (inputs) => Reflect.apply(options.cx, options, inputs);
137
131
  const cx = (...inputs) => cxArray(inputs.filter((input) => input !== void 0));
138
132
  const cva = ((config) => {
139
133
  const definition = config || empty;
@@ -142,16 +136,19 @@ const defineConfig = ((options) => {
142
136
  const children = composes == null ? noValues : Array.isArray(composes) ? composes.slice() : [composes];
143
137
  const childCount = children.length;
144
138
  const { variants: mergedVariants, defaults } = mergeConfig(children, definition);
145
- const { variantKeys, variantMaps, defaultClasses } = prepareVariants(definition.variants, defaults);
139
+ const preparedVariants = prepareVariants(definition.variants, defaults);
140
+ const variantKeys = preparedVariants[0];
141
+ const variantMaps = preparedVariants[1];
142
+ const defaultClasses = preparedVariants[2];
146
143
  const variantCount = variantKeys.length;
147
144
  const prepared = definition.compoundVariants ? prepareCompounds(definition.compoundVariants, variantKeys, defaults) : void 0;
148
- const keys = prepared ? prepared.keys : variantKeys;
145
+ const keys = prepared ? prepared[0] : variantKeys;
146
+ const defaultValues = prepared ? prepared[1] : noValues;
147
+ const compounds = prepared ? prepared[2] : noValues;
148
+ const indexes = prepared ? prepared[3] : noValues;
149
+ const selectors = prepared ? prepared[4] : noValues;
149
150
  const keyCount = keys.length;
150
- const compounds = prepared ? prepared.compounds : noValues;
151
151
  const compoundCount = compounds.length;
152
- const indexes = prepared ? prepared.indexes : noValues;
153
- const selectors = prepared ? prepared.selectors : noValues;
154
- const defaultValues = prepared ? prepared.defaultValues : noValues;
155
152
  const onlyBase = !variantCount && !compoundCount;
156
153
  const assembled = onlyBase && base !== void 0 ? [base] : [];
157
154
  if (!onlyBase) pushDefined(assembled, base);
@@ -227,34 +224,7 @@ const defineConfig = ((options) => {
227
224
  };
228
225
  return component;
229
226
  });
230
- const compose = (...components) => {
231
- const composed = components;
232
- const config = {};
233
- for (let i = 0; i < composed.length; i++) {
234
- const source = composed[i].config;
235
- for (const key in source) if (hasOwn.call(source, key)) {
236
- const value = source[key];
237
- config[key] = value && typeof value === "object" && !Array.isArray(value) ? {
238
- ...config[key],
239
- ...value
240
- } : value;
241
- }
242
- }
243
- const component = (input) => {
244
- const props = input || empty;
245
- const forwarded = definedProps(props);
246
- const out = [];
247
- for (let i = 0; i < composed.length; i++) {
248
- const child = composed[i];
249
- pushDefined(out, child(forwarded));
250
- }
251
- return cxArray(pushClassProps(out, props));
252
- };
253
- component.config = config;
254
- return component;
255
- };
256
227
  return {
257
- compose,
258
228
  cva,
259
229
  cx
260
230
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Copyright 2022-present Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n\nimport type {\n CVAClassProp,\n CVAComponentConfig,\n CVAVariantSchema,\n InternalOnlyWarning,\n InternalVariantKey,\n} from \"./types.js\";\n\n/* Types\n ============================================ */\n\n/* ClassValue\n ---------------------------------- */\n\n// Mirrors clsx's `ClassValue`; local to keep `cva/config` dependency-free\n// (TS2742).\n\nexport type ClassValue =\n | ClassArray\n | ClassDictionary\n | string\n | number\n | bigint\n | null\n | boolean\n | undefined;\nexport type ClassDictionary = Record<string, any>;\nexport type ClassArray = ClassValue[];\n\n/* CXInput\n ---------------------------------- */\n\n/**\n * Any function usable as a `cx` concatenator.\n */\nexport type AnyCX = (...inputs: any[]) => string;\n\n// Infer directly from a readonly rest pattern instead of `Parameters<T>[number]`:\n// the latter is `never` for zero-argument callbacks and loses readonly rest\n// element types.\ntype CXInputs<TCX extends AnyCX> = TCX extends (\n ...inputs: readonly [...infer Inputs]\n) => string\n ? Inputs\n : never;\ntype CXInputElement<TCX extends AnyCX> = CXInputs<TCX>[number];\n\n// cva may call `cx` with no values, or with any number of authored values and\n// composed component strings. A constant callback is safe; every other\n// callback must accept arbitrary lists of its own grammar plus strings.\ntype CXHasSafeArity<TCX extends AnyCX> =\n CXInputs<TCX> extends infer Inputs\n ? Inputs extends readonly unknown[]\n ? Inputs extends []\n ? true\n : [] extends Inputs\n ? number extends Inputs[\"length\"]\n ? true\n : false\n : false\n : false\n : false;\ntype CXConstraint<TCX extends AnyCX> =\n false extends CXHasSafeArity<TCX>\n ? \"cva's cx must accept zero arguments and an unbounded rest parameter.\"\n : [TCX] extends [(...inputs: (string | CXInput<TCX>)[]) => string]\n ? unknown\n : \"cva's cx must accept its inferred class values and composed strings.\";\n\n/**\n * The class value type a concatenator accepts, inferred from its\n * parameters — `defineConfig` uses this to type the authoring surface\n * (`base`, variant values, `class`/`className`) against the configured\n * concatenator's own input grammar.\n */\nexport type CXInput<TCX extends AnyCX> =\n CXInputElement<TCX> extends infer P\n ? // `0 extends 1 & P` detects `any`; `any`/`never` use `ClassValue`.\n 0 extends 1 & P\n ? ClassValue\n : [P] extends [never]\n ? ClassValue\n : [P] extends [ClassValue]\n ? P\n : // A concatenator accepting more than cva's grammar (e.g. `string |\n // URL`) narrows to the subset it shares with it, since the surface\n // can't widen beyond what the concatenator accepts; when nothing is\n // shared (e.g. `unknown`), the full grammar applies.\n [Extract<P, ClassValue>] extends [never]\n ? ClassValue\n : Extract<P, ClassValue>\n : ClassValue;\n\n/* Utils\n ---------------------------------- */\n\ntype OmitUndefined<T> = T extends undefined ? never : T;\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\n// `composes` accepts either a single component or a list of components. A\n// plain union (`CVAComponentShape | CVAComponentShape[]`) collapses an array\n// literal's element type to a union, silently dropping components whose\n// variants are a structural subtype of another composed component's (e.g.\n// `composes: [a, b]` where `b`'s variants are a superset of `a`'s). Splitting\n// inference across two type parameters preserves the array as a real tuple.\ntype ComposedTuple<\n S extends CVAComponentShape | undefined,\n L extends readonly CVAComponentShape[],\n> = [S] extends [CVAComponentShape] ? [S] : L;\n\ntype MergedVariants<T extends readonly unknown[]> = UnionToIntersection<\n {\n [K in keyof T]: T[K] extends {\n config: { variants?: infer V extends CVAVariantShape };\n }\n ? V\n : never;\n }[number]\n>;\n\n// Right-biased merge (`B`'s keys win on conflicts) implemented as a mapped\n// type rather than `Omit<A, keyof B> & B`: the latter stays an unresolved\n// deferred type when `A`/`B` are themselves generic (as they are here, via\n// `ReturnType<CVA>` with no concrete `Config`), which then breaks downstream\n// `any`-narrowing in unrelated code that consumes `ReturnType<CVA>` (e.g.\n// the deprecated `compose`). A mapped type resolves eagerly instead.\ntype RightMerge<A, B> = {\n [K in keyof A | keyof B]: K extends keyof B\n ? B[K]\n : K extends keyof A\n ? A[K]\n : never;\n};\n\n// `D` infers as `undefined` (not absent) when a component declares no\n// `defaultVariants` at all. `NonNullable<undefined>` would give `never`,\n// and `keyof never` is `string | number | symbol` (not `never`) — poisoning\n// `RightMerge`'s key union with every possible key. Normalize to `{}` instead,\n// matching a component that contributes nothing to the merge.\ntype DefaultsOf<Component> = Component extends {\n config: { defaultVariants?: infer D };\n}\n ? D extends undefined\n ? {}\n : D\n : {};\n\ntype MergedDefaultVariants<T extends readonly unknown[]> = T extends readonly [\n infer Head,\n ...infer Rest,\n]\n ? RightMerge<DefaultsOf<Head>, MergedDefaultVariants<Rest>>\n : {};\n\ntype ComponentProps<Component extends (...args: any) => any> = Omit<\n OmitUndefined<Parameters<Component>[0]>,\n \"class\" | \"className\"\n>;\n\n// One `Omit`: nesting it inside `ComponentProps` builds the props twice.\nexport type VariantProps<Component extends (...args: any) => any> = Omit<\n OmitUndefined<Parameters<Component>[0]>,\n \"class\" | \"className\" | InternalVariantKey\n>;\n\n/* compose\n ---------------------------------- */\n\n/**\n * @deprecated Use the `composes` property inside `cva` instead.\n * @example\n * // Before\n * const card = compose(box, stack)\n * // After\n * const card = cva({ composes: [box, stack] })\n */\nexport interface Compose<T extends ClassValue = ClassValue> {\n <Components extends readonly unknown[]>(\n ...components: Components &\n (Components[number] extends CVAComponentShape ? unknown : never)\n ): (\n props?: (\n | UnionToIntersection<\n {\n [K in keyof Components]: Components[K] extends CVAComponentShape\n ? ComponentProps<Components[K]>\n : never;\n }[number]\n >\n | undefined\n ) &\n CVAClassProp<T>,\n ) => string;\n}\n\n/* cx\n ---------------------------------- */\n\nexport interface CX<T extends ClassValue = ClassValue> {\n (...inputs: T[]): string;\n}\n\nexport type CXOptions = Parameters<CX>;\nexport type CXReturn = ReturnType<CX>;\n\n/* cva\n ============================================ */\n\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport type CVAVariantShape = Record<string, Record<string, ClassValue>>;\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport interface CVAComponent<\n Config,\n Variants,\n T extends ClassValue = ClassValue,\n> {\n (\n props?: Variants extends CVAVariantShape\n ? CVAVariantSchema<Variants> & CVAClassProp<T>\n : CVAClassProp<T>,\n ): string;\n /** @internal */\n config: Config;\n}\n\n// The loosest form a composable component can take, constraining `composes`\n// and the composition merge helpers above. Deriving it from `CVAComponent`\n// keeps the two from drifting: instantiated with `any`, the props conditional\n// and `config` both collapse to `any` (mapped types over `any` are `any`),\n// i.e. `{ (props?: any): string; config: any }`. The required `config`\n// property is what rejects plain functions and (deprecated) `compose`\n// results.\n//\n// The `any` arguments are deliberate, not lazy typing — a shaped `config`\n// (e.g. `{ variants?: CVAVariantShape }`) was tried and verifiably breaks:\n// a variant-less `cva({ base })` carries `variants: unknown`, and\n// `ReturnType<CVA>` instantiates this constraint inside the\n// `Compose`/`GetSchema` guards, where the shaped form rejects every real\n// component via props contravariance.\n//\n// Its class-value parameter must be `any`: narrowed components otherwise fail\n// props contravariance in `composes` and `getSchema`.\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport type CVAComponentShape = CVAComponent<any, any, any>;\n\ntype CVADefaultVariants<Config> = Config extends { defaultVariants?: infer D }\n ? D\n : {};\n\n// Nothing composed is the common case: answer with `Variants` and skip the\n// merge machinery.\ntype AllVariants<\n Variants,\n ComposedSingle extends CVAComponentShape | undefined,\n ComposedList extends readonly CVAComponentShape[],\n> = [ComposedSingle] extends [undefined]\n ? [ComposedList] extends [readonly []]\n ? Variants\n : Variants & MergedVariants<ComposedList>\n : Variants & MergedVariants<ComposedTuple<ComposedSingle, ComposedList>>;\n\nexport interface CVA<T extends ClassValue = ClassValue> {\n <\n _ extends InternalOnlyWarning,\n Config,\n Variants,\n ComposedSingle extends CVAComponentShape | undefined = undefined,\n ComposedList extends readonly CVAComponentShape[] = [],\n >(\n config: CVAComponentConfig<\n Config,\n Variants,\n ComposedSingle,\n ComposedList,\n T,\n AllVariants<Variants, ComposedSingle, ComposedList>\n >,\n ): CVAComponent<\n Omit<Config, \"defaultVariants\"> & {\n variants: AllVariants<Variants, ComposedSingle, ComposedList>;\n // Local `defaultVariants` win over composed ones on key conflicts,\n // matching the runtime spread order. A plain intersection would collapse\n // a conflicting key's value to `never` (e.g. `\"sm\" & \"lg\"`), which then\n // silently drops the variant from `getSchema`'s inferred type.\n defaultVariants: Omit<\n MergedDefaultVariants<ComposedTuple<ComposedSingle, ComposedList>>,\n keyof CVADefaultVariants<Config>\n > &\n CVADefaultVariants<Config>;\n },\n AllVariants<Variants, ComposedSingle, ComposedList>,\n T\n >;\n}\n\n/* defineConfig\n ---------------------------------- */\n\nexport interface DefineConfigOptions<TCX extends AnyCX = CX> {\n /**\n * The class name concatenator used by `cva`, `cx`, and `compose`. It owns\n * the class name grammar entirely: cva assembles the authored values\n * (composed component outputs, `base`, matched variant and compound\n * variant values, `class`/`className`) and passes them through verbatim,\n * one argument each, without interpreting them.\n *\n * The authoring surface adopts the concatenator's own input type\n * automatically (see {@link CXInput}): pass `twMerge` and your variants\n * are checked against tailwind-merge's `ClassNameValue`; pass `clsx` (or\n * any function whose parameters don't narrow further) and you keep the\n * full clsx-flavored `ClassValue` grammar.\n */\n cx: TCX & CXConstraint<TCX>;\n hooks?: {\n /**\n * @deprecated please use the `cx` option instead\n */\n \"cx:done\"?: (className: string) => string;\n /**\n * @deprecated please use the `cx` option instead\n */\n onComplete?: (className: string) => string;\n };\n}\n\nexport interface DefineConfig {\n <TCX extends AnyCX>(\n options: DefineConfigOptions<TCX>,\n ): {\n /**\n * @deprecated Use the `composes` property inside `cva` instead.\n * @example\n * // Before\n * const card = compose(box, stack)\n * // After\n * const card = cva({ composes: [box, stack] })\n */\n compose: Compose<CXInput<TCX>>;\n cx: CX<CXInput<TCX>>;\n cva: CVA<CXInput<TCX>>;\n };\n}\n\n/* Exports\n ============================================ */\n\nconst falsyToString = <T extends unknown>(value: T) =>\n typeof value === \"boolean\" ? `${value}` : value === 0 ? \"0\" : value;\n\n// Absent objects normalise to this: `x?.y` costs a temporary at ES2019.\nconst empty: Record<string, any> = {};\n\n// The table for a component that has none. Never written to.\nconst noValues: readonly never[] = [];\n\nconst hasOwn = Object.prototype.hasOwnProperty;\n\nconst ownEnumerable = Object.prototype.propertyIsEnumerable;\n\n// The caller's own defined props, minus the class props, over `seed`. An\n// explicit `undefined` keeps the default; an inherited getter is never read.\nconst definedProps = (\n props: Record<string, unknown>,\n seed?: Record<string, unknown>,\n): Record<string, unknown> => {\n let merged: Record<string, unknown> = { ...seed };\n for (const key in props) {\n if (hasOwn.call(props, key)) {\n const value = props[key];\n if (key !== \"class\" && key !== \"className\" && value !== undefined) {\n // A computed key creates a data property; `merged.__proto__ =` would\n // hit `Object.prototype`'s setter and reparent the object.\n if (key === \"__proto__\") merged = { ...merged, [key]: value };\n else merged[key] = value;\n }\n }\n }\n return merged;\n};\n\nconst pushDefined = (out: ClassValue[], value: ClassValue) => {\n if (value !== undefined) out.push(value);\n};\n\nconst pushClassProps = (\n out: ClassValue[],\n source: { class?: ClassValue; className?: ClassValue },\n) => {\n pushDefined(out, source.class);\n pushDefined(out, source.className);\n return out;\n};\n\n// A compound's selectors live in the shared arrays, bounded by start and end.\n// `mask` has a bit per key it selects on: a call whose supplied keys miss it\n// reuses `matchesDefaults`, and a hit only means the selectors are compared,\n// since keys past the 31st share bits.\ninterface PreparedCompound {\n start: number;\n end: number;\n mask: number;\n matchesDefaults: boolean;\n class: ClassValue;\n className: ClassValue;\n}\n\ninterface MergedConfig {\n variants: CVAVariantShape;\n defaults: Record<string, unknown>;\n}\n\n// One source folded into the accumulator, so a later source wins.\nconst mergeInto = (\n merged: MergedConfig,\n source: Record<string, any> | undefined,\n) => {\n const variants: CVAVariantShape | undefined = source && source.variants;\n for (const key in variants) {\n if (hasOwn.call(variants, key)) {\n const values = { ...merged.variants[key], ...variants[key] };\n if (key === \"__proto__\") {\n merged.variants = { ...merged.variants, [key]: values };\n } else {\n merged.variants[key] = values;\n }\n }\n }\n merged.defaults = {\n ...merged.defaults,\n ...(source && source.defaultVariants),\n };\n};\n\nconst mergeConfig = (\n children: readonly CVAComponentShape[],\n definition: Record<string, any>,\n) => {\n const merged: MergedConfig = { variants: {}, defaults: {} };\n for (let i = 0; i < children.length; i++) {\n mergeInto(merged, children[i].config);\n }\n mergeInto(merged, definition);\n return merged;\n};\n\nconst prepareVariants = (\n localVariants: CVAVariantShape | undefined,\n defaults: Record<string, unknown>,\n) => {\n const names: string[] = [];\n const maps: Record<string, ClassValue>[] = [];\n for (const key in localVariants) {\n if (hasOwn.call(localVariants, key)) {\n names.push(key);\n maps.push(localVariants[key]);\n }\n }\n // No variants, no retained tables; the rest are copied to their exact size.\n if (!names.length) {\n return {\n variantKeys: noValues,\n variantMaps: noValues,\n defaultClasses: noValues,\n };\n }\n return {\n variantKeys: names.slice(),\n variantMaps: maps.slice(),\n defaultClasses: names.map(\n (key, i) => maps[i][falsyToString(defaults[key]) as string],\n ),\n };\n};\n\nconst compoundMatches = (\n compound: PreparedCompound,\n indexes: readonly number[],\n selectors: readonly unknown[],\n values: readonly unknown[],\n) => {\n for (let i = compound.start; i < compound.end; i++) {\n const selector = selectors[i];\n const value = values[indexes[i]];\n if (\n Array.isArray(selector) ? !selector.includes(value) : value !== selector\n ) {\n return false;\n }\n }\n return true;\n};\n\n// A compound may select on a name no variant declares: the key list ends here.\nconst prepareCompounds = (\n compoundVariants: readonly (CVAClassProp & Record<string, unknown>)[],\n variantKeys: readonly string[],\n defaults: Record<string, unknown>,\n) => {\n const keys = variantKeys.slice();\n const compounds: PreparedCompound[] = [];\n const indexes: number[] = [];\n const selectors: unknown[] = [];\n for (let i = 0; i < compoundVariants.length; i++) {\n const compound = compoundVariants[i];\n const start = indexes.length;\n let mask = 0;\n for (const key in compound) {\n if (hasOwn.call(compound, key)) {\n const selector = compound[key];\n if (key !== \"class\" && key !== \"className\") {\n let index = keys.indexOf(key);\n if (index === -1) index = keys.push(key) - 1;\n indexes.push(index);\n selectors.push(selector);\n mask |= 1 << index;\n }\n }\n }\n compounds.push({\n start,\n end: indexes.length,\n mask,\n matchesDefaults: false,\n class: compound.class,\n className: compound.className,\n });\n }\n const defaultValues = keys.map((key) => defaults[key]);\n for (let i = 0; i < compounds.length; i++) {\n compounds[i].matchesDefaults = compoundMatches(\n compounds[i],\n indexes,\n selectors,\n defaultValues,\n );\n }\n return {\n keys: keys.slice(),\n defaultValues,\n compounds: compounds.slice(),\n indexes: indexes.slice(),\n selectors: selectors.slice(),\n };\n};\n\n// The body of a component with no prop names to read and no children. At\n// module scope, so it captures three values rather than all of `cva`'s.\nconst createPlainComponent =\n (\n cxArray: (inputs: readonly ClassValue[]) => string,\n defaultOut: readonly ClassValue[],\n singleDefaultClass: ClassValue,\n ) =>\n (input?: Record<string, unknown>) => {\n const props: Record<string, unknown> = input || empty;\n const classValue = props.class as ClassValue;\n const classNameValue = props.className as ClassValue;\n // Rebuilding the list as a literal measures faster than sharing one.\n if (classValue === undefined && singleDefaultClass !== undefined) {\n return cxArray(\n classNameValue === undefined\n ? [singleDefaultClass]\n : [singleDefaultClass, classNameValue],\n );\n }\n const out = defaultOut.slice();\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n };\n\n// Cast to `DefineConfig`: runtime uses `ClassValue`; `CXInput` is type-only.\nexport const defineConfig = ((options: DefineConfigOptions) => {\n // `Reflect.apply` hands over the assembled values as separate arguments and\n // keeps `options` as the receiver, whatever `cx`'s own `call`/`apply` say.\n const cxArray = (inputs: readonly ClassValue[]): string => {\n const className: string = Reflect.apply(options.cx, options, inputs);\n const hooks = options.hooks || empty;\n // `??` semantics, spelled out because it downlevels to a temporary.\n let hook: ((className: string) => string) | undefined = hooks[\"cx:done\"];\n if (hook == null) hook = hooks.onComplete;\n return hook ? hook(className) : className;\n };\n\n const cx: CX = (...inputs) =>\n // Drop absent values so a narrower concatenator never receives `undefined`.\n cxArray(inputs.filter((input) => input !== undefined));\n\n const cva = (<\n _ extends InternalOnlyWarning,\n Config,\n Variants,\n ComposedSingle extends CVAComponentShape | undefined = undefined,\n ComposedList extends readonly CVAComponentShape[] = [],\n >(\n config: CVAComponentConfig<Config, Variants, ComposedSingle, ComposedList>,\n ) => {\n // The configuration is read here, when the component is created; a call\n // reads only the caller's props and `options`. By contract it is\n // immutable afterwards: a change means a new component.\n const definition: Record<string, any> = config || empty;\n const composes = definition.composes;\n const base: ClassValue = definition.base;\n // A copy, so the merge and every call see the same children.\n const children: readonly CVAComponentShape[] =\n composes == null\n ? noValues\n : Array.isArray(composes)\n ? composes.slice()\n : [composes];\n const childCount = children.length;\n\n const { variants: mergedVariants, defaults } = mergeConfig(\n children,\n definition,\n );\n const { variantKeys, variantMaps, defaultClasses } = prepareVariants(\n definition.variants,\n defaults,\n );\n const variantCount = variantKeys.length;\n const prepared = definition.compoundVariants\n ? prepareCompounds(definition.compoundVariants, variantKeys, defaults)\n : undefined;\n // Every prop name a call reads: the variant names first, so one index\n // addresses a value map and a default class too, then compound-only names.\n const keys: readonly string[] = prepared ? prepared.keys : variantKeys;\n const keyCount = keys.length;\n const compounds: readonly PreparedCompound[] = prepared\n ? prepared.compounds\n : noValues;\n const compoundCount = compounds.length;\n const indexes: readonly number[] = prepared ? prepared.indexes : noValues;\n const selectors: readonly unknown[] = prepared\n ? prepared.selectors\n : noValues;\n const defaultValues: readonly unknown[] = prepared\n ? prepared.defaultValues\n : noValues;\n\n // The arguments for a call that supplies no known prop and no class prop,\n // and has no child to run. `Reflect.apply` copies it, so it never escapes.\n const onlyBase = !variantCount && !compoundCount;\n const assembled: ClassValue[] =\n onlyBase && base !== undefined ? [base] : [];\n if (!onlyBase) pushDefined(assembled, base);\n for (let i = 0; i < variantCount; i++) {\n pushDefined(assembled, defaultClasses[i]);\n }\n for (let i = 0; i < compoundCount; i++) {\n const compound = compounds[i];\n if (compound.matchesDefaults) pushClassProps(assembled, compound);\n }\n const defaultOut: ClassValue[] = onlyBase ? assembled : assembled.slice();\n // Every element is defined, so `undefined` means \"not a one-element list\".\n const singleDefaultClass: ClassValue =\n defaultOut.length === 1 ? defaultOut[0] : undefined;\n\n const component = (\n !keyCount && !childCount\n ? createPlainComponent(cxArray, defaultOut, singleDefaultClass)\n : (input?: Record<string, unknown>) => {\n const props: Record<string, unknown> = input || empty;\n const classValue = props.class as ClassValue;\n const classNameValue = props.className as ClassValue;\n\n let supplied = 0;\n const variantClasses = variantCount\n ? new Array<ClassValue>(variantCount)\n : undefined;\n const resolved = compoundCount\n ? new Array<unknown>(keyCount)\n : undefined;\n for (let i = 0; i < keyCount; i++) {\n const key = keys[i];\n // A variant name is read straight off `props`; a compound-only\n // name must be an own enumerable prop to count.\n const own = compoundCount !== 0 && ownEnumerable.call(props, key);\n const value = i < variantCount || own ? props[key] : undefined;\n // Past the 31st key, saturate: every compound with selectors is\n // compared.\n if (value !== undefined) supplied |= i < 31 ? 1 << i : -1;\n if (variantClasses && i < variantCount) {\n const variantKey = falsyToString(value);\n variantClasses[i] = variantKey\n ? variantMaps[i][variantKey as string]\n : defaultClasses[i];\n }\n if (resolved) {\n resolved[i] =\n own && value !== undefined ? value : defaultValues[i];\n }\n }\n\n if (!childCount && !supplied) {\n if (classValue === undefined) {\n if (singleDefaultClass !== undefined) {\n return cxArray(\n classNameValue === undefined\n ? [singleDefaultClass]\n : [singleDefaultClass, classNameValue],\n );\n }\n if (classNameValue === undefined) return cxArray(defaultOut);\n }\n const out = defaultOut.slice();\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n }\n\n const out: ClassValue[] = [];\n if (childCount) {\n // A fresh object per child, and the child read out of the array\n // before the call, or it arrives as that child's `this`.\n const forwarded = definedProps(props, defaults);\n for (let i = 0; i < childCount; i++) {\n const child = children[i];\n pushDefined(out, child({ ...forwarded }));\n }\n }\n\n pushDefined(out, base);\n if (variantClasses) {\n for (let i = 0; i < variantCount; i++) {\n pushDefined(out, variantClasses[i]);\n }\n }\n if (resolved) {\n for (let i = 0; i < compoundCount; i++) {\n const compound = compounds[i];\n let matched = compound.matchesDefaults;\n if (supplied & compound.mask) {\n matched = true;\n for (let j = compound.start; j < compound.end; j++) {\n const selector = selectors[j];\n const value = resolved[indexes[j]];\n if (\n Array.isArray(selector)\n ? !selector.includes(value)\n : value !== selector\n ) {\n matched = false;\n break;\n }\n }\n }\n if (matched) pushClassProps(out, compound);\n }\n }\n\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n }\n ) as CVAComponent<typeof config, typeof config.variants>;\n\n component.config = {\n ...config,\n variants: mergedVariants,\n defaultVariants: defaults,\n };\n\n return component as ReturnType<CVA>;\n }) as CVA;\n\n const compose: Compose = (...components) => {\n const composed = components as CVAComponentShape[];\n const config: Record<string, any> = {};\n for (let i = 0; i < composed.length; i++) {\n const source = composed[i].config;\n for (const key in source) {\n if (hasOwn.call(source, key)) {\n const value = source[key];\n config[key] =\n value && typeof value === \"object\" && !Array.isArray(value)\n ? { ...config[key], ...value }\n : value;\n }\n }\n }\n\n const component: CVAComponent<typeof config, typeof config.variants> = (\n input,\n ) => {\n const props: Record<string, unknown> = input || empty;\n const forwarded = definedProps(props);\n const out: ClassValue[] = [];\n for (let i = 0; i < composed.length; i++) {\n const child = composed[i];\n pushDefined(out, child(forwarded));\n }\n return cxArray(pushClassProps(out, props));\n };\n\n component.config = config;\n\n return component;\n };\n\n return {\n compose,\n cva,\n cx,\n };\n}) as DefineConfig;\n"],"mappings":";;AAuXA,MAAM,iBAAoC,UACxC,OAAO,UAAU,YAAY,GAAG,UAAU,UAAU,IAAI,MAAM;AAGhE,MAAM,QAA6B,CAAC;AAGpC,MAAM,WAA6B,CAAC;AAEpC,MAAM,SAAS,OAAO,UAAU;AAEhC,MAAM,gBAAgB,OAAO,UAAU;AAIvC,MAAM,gBACJ,OACA,SAC4B;CAC5B,IAAI,SAAkC,EAAE,GAAG,KAAK;CAChD,KA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,WAAW,UAAU;MAC3B,MAAM,QAAQ,SAAS,QAAQ;MAC/B,IACE,MAAM,QAAQ,QAAQ,IAClB,CAAC,SAAS,SAAS,KAAK,IACxB,UAAU,UACd;OACA,UAAU;OACV;MACF;KACF;IACF;IACA,IAAI,SAAS,eAAe,KAAK,QAAQ;GAC3C;GAGF,YAAY,KAAK,UAAU;GAC3B,YAAY,KAAK,cAAc;GAC/B,OAAO,QAAQ,GAAG;EACpB;EAGN,UAAU,SAAS;GACjB,GAAG;GACH,UAAU;GACV,iBAAiB;EACnB;EAEA,OAAO;CACT;CAEA,MAAM,WAAoB,GAAG,eAAe;EAC1C,MAAM,WAAW;EACjB,MAAM,SAA8B,CAAC;EACrC,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;GACxC,MAAM,SAAS,SAAS,EAAE,CAAC;GAC3B,KAAK,MAAM,OAAO,QAChB,IAAI,OAAO,KAAK,QAAQ,GAAG,GAAG;IAC5B,MAAM,QAAQ,OAAO;IACrB,OAAO,OACL,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IACtD;KAAE,GAAG,OAAO;KAAM,GAAG;IAAM,IAC3B;GACR;EAEJ;EAEA,MAAM,aACJ,UACG;GACH,MAAM,QAAiC,SAAS;GAChD,MAAM,YAAY,aAAa,KAAK;GACpC,MAAM,MAAoB,CAAC;GAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;IACxC,MAAM,QAAQ,SAAS;IACvB,YAAY,KAAK,MAAM,SAAS,CAAC;GACnC;GACA,OAAO,QAAQ,eAAe,KAAK,KAAK,CAAC;EAC3C;EAEA,UAAU,SAAS;EAEnB,OAAO;CACT;CAEA,OAAO;EACL;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"config.cjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Copyright 2022-present Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n\nimport type {\n CVAClassProp,\n CVAComponentConfig,\n CVAVariantSchema,\n InternalOnlyWarning,\n InternalVariantKey,\n} from \"./types.js\";\n\n/* Types\n ============================================ */\n\n/* ClassValue\n ---------------------------------- */\n\n// Mirrors clsx's `ClassValue`; local to keep `cva/config` dependency-free\n// (TS2742).\n\nexport type ClassValue =\n | ClassArray\n | ClassDictionary\n | string\n | number\n | bigint\n | null\n | boolean\n | undefined;\nexport type ClassDictionary = Record<string, any>;\nexport type ClassArray = ClassValue[];\n\n/* CXInput\n ---------------------------------- */\n\n/**\n * Any function usable as a `cx` concatenator.\n */\nexport type AnyCX = (...inputs: any[]) => string;\n\n// Infer directly from a readonly rest pattern instead of `Parameters<T>[number]`:\n// the latter is `never` for zero-argument callbacks and loses readonly rest\n// element types.\ntype CXInputs<TCX extends AnyCX> = TCX extends (\n ...inputs: readonly [...infer Inputs]\n) => string\n ? Inputs\n : never;\ntype CXInputElement<TCX extends AnyCX> = CXInputs<TCX>[number];\n\n// cva may call `cx` with no values, or with any number of authored values and\n// composed component strings. A constant callback is safe; every other\n// callback must accept arbitrary lists of its own grammar plus strings.\ntype CXHasSafeArity<TCX extends AnyCX> =\n CXInputs<TCX> extends infer Inputs\n ? Inputs extends readonly unknown[]\n ? Inputs extends []\n ? true\n : [] extends Inputs\n ? number extends Inputs[\"length\"]\n ? true\n : false\n : false\n : false\n : false;\ntype CXConstraint<TCX extends AnyCX> =\n false extends CXHasSafeArity<TCX>\n ? \"cva's cx must accept zero arguments and an unbounded rest parameter.\"\n : [TCX] extends [(...inputs: (string | CXInput<TCX>)[]) => string]\n ? unknown\n : \"cva's cx must accept its inferred class values and composed strings.\";\n\n/**\n * The class value type a concatenator accepts, inferred from its\n * parameters — `defineConfig` uses this to type the authoring surface\n * (`base`, variant values, `class`/`className`) against the configured\n * concatenator's own input grammar.\n */\nexport type CXInput<TCX extends AnyCX> =\n CXInputElement<TCX> extends infer P\n ? // `0 extends 1 & P` detects `any`; `any`/`never` use `ClassValue`.\n 0 extends 1 & P\n ? ClassValue\n : [P] extends [never]\n ? ClassValue\n : [P] extends [ClassValue]\n ? P\n : // A concatenator accepting more than cva's grammar (e.g. `string |\n // URL`) narrows to the subset it shares with it, since the surface\n // can't widen beyond what the concatenator accepts; when nothing is\n // shared (e.g. `unknown`), the full grammar applies.\n [Extract<P, ClassValue>] extends [never]\n ? ClassValue\n : Extract<P, ClassValue>\n : ClassValue;\n\n/* Utils\n ---------------------------------- */\n\ntype OmitUndefined<T> = T extends undefined ? never : T;\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\n// `composes` accepts either a single component or a list of components. A\n// plain union (`CVAComponentShape | CVAComponentShape[]`) collapses an array\n// literal's element type to a union, silently dropping components whose\n// variants are a structural subtype of another composed component's (e.g.\n// `composes: [a, b]` where `b`'s variants are a superset of `a`'s). Splitting\n// inference across two type parameters preserves the array as a real tuple.\ntype ComposedTuple<\n S extends CVAComponentShape | undefined,\n L extends readonly CVAComponentShape[],\n> = [S] extends [CVAComponentShape] ? [S] : L;\n\ntype MergedVariants<T extends readonly unknown[]> = UnionToIntersection<\n {\n [K in keyof T]: T[K] extends {\n config: { variants?: infer V extends CVAVariantShape };\n }\n ? V\n : never;\n }[number]\n>;\n\n// Right-biased merge (`B`'s keys win on conflicts) implemented as a mapped\n// type rather than `Omit<A, keyof B> & B`: the latter stays an unresolved\n// deferred type when `A`/`B` are themselves generic (as they are here, via\n// `ReturnType<CVA>` with no concrete `Config`), which then breaks downstream\n// `any`-narrowing in unrelated code that consumes `ReturnType<CVA>` (e.g. the\n// `composes` and `getSchema` guards). A mapped type resolves eagerly instead.\ntype RightMerge<A, B> = {\n [K in keyof A | keyof B]: K extends keyof B\n ? B[K]\n : K extends keyof A\n ? A[K]\n : never;\n};\n\n// `D` infers as `undefined` (not absent) when a component declares no\n// `defaultVariants` at all. `NonNullable<undefined>` would give `never`,\n// and `keyof never` is `string | number | symbol` (not `never`) — poisoning\n// `RightMerge`'s key union with every possible key. Normalize to `{}` instead,\n// matching a component that contributes nothing to the merge.\ntype DefaultsOf<Component> = Component extends {\n config: { defaultVariants?: infer D };\n}\n ? D extends undefined\n ? {}\n : D\n : {};\n\ntype MergedDefaultVariants<T extends readonly unknown[]> = T extends readonly [\n infer Head,\n ...infer Rest,\n]\n ? RightMerge<DefaultsOf<Head>, MergedDefaultVariants<Rest>>\n : {};\n\n// One `Omit`: nesting the class-prop removal in a helper builds the props twice.\nexport type VariantProps<Component extends (...args: any) => any> = Omit<\n OmitUndefined<Parameters<Component>[0]>,\n \"class\" | \"className\" | InternalVariantKey\n>;\n\n/* cx\n ---------------------------------- */\n\nexport interface CX<T extends ClassValue = ClassValue> {\n (...inputs: T[]): string;\n}\n\nexport type CXOptions = Parameters<CX>;\nexport type CXReturn = ReturnType<CX>;\n\n/* cva\n ============================================ */\n\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport type CVAVariantShape = Record<string, Record<string, ClassValue>>;\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport interface CVAComponent<\n Config,\n Variants,\n T extends ClassValue = ClassValue,\n> {\n (\n props?: Variants extends CVAVariantShape\n ? CVAVariantSchema<Variants> & CVAClassProp<T>\n : CVAClassProp<T>,\n ): string;\n /** @internal */\n config: Config;\n}\n\n// The loosest form a composable component can take, constraining `composes`\n// and the composition merge helpers above. Deriving it from `CVAComponent`\n// keeps the two from drifting: instantiated with `any`, the props conditional\n// and `config` both collapse to `any` (mapped types over `any` are `any`),\n// i.e. `{ (props?: any): string; config: any }`. The required `config`\n// property is what rejects plain functions.\n//\n// The `any` arguments are deliberate, not lazy typing — a shaped `config`\n// (e.g. `{ variants?: CVAVariantShape }`) was tried and verifiably breaks:\n// a variant-less `cva({ base })` carries `variants: unknown`, and\n// `ReturnType<CVA>` instantiates this constraint inside the `composes` and\n// `GetSchema` guards, where the shaped form rejects every real component via\n// props contravariance.\n//\n// Its class-value parameter must be `any`: narrowed components otherwise fail\n// props contravariance in `composes` and `getSchema`.\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport type CVAComponentShape = CVAComponent<any, any, any>;\n\ntype CVADefaultVariants<Config> = Config extends { defaultVariants?: infer D }\n ? D\n : {};\n\n// Nothing composed is the common case: answer with `Variants` and skip the\n// merge machinery.\ntype AllVariants<\n Variants,\n ComposedSingle extends CVAComponentShape | undefined,\n ComposedList extends readonly CVAComponentShape[],\n> = [ComposedSingle] extends [undefined]\n ? [ComposedList] extends [readonly []]\n ? Variants\n : Variants & MergedVariants<ComposedList>\n : Variants & MergedVariants<ComposedTuple<ComposedSingle, ComposedList>>;\n\nexport interface CVA<T extends ClassValue = ClassValue> {\n <\n _ extends InternalOnlyWarning,\n Config,\n Variants,\n ComposedSingle extends CVAComponentShape | undefined = undefined,\n ComposedList extends readonly CVAComponentShape[] = [],\n >(\n config: CVAComponentConfig<\n Config,\n Variants,\n ComposedSingle,\n ComposedList,\n T,\n AllVariants<Variants, ComposedSingle, ComposedList>\n >,\n ): CVAComponent<\n Omit<Config, \"defaultVariants\"> & {\n variants: AllVariants<Variants, ComposedSingle, ComposedList>;\n // Local `defaultVariants` win over composed ones on key conflicts,\n // matching the runtime spread order. A plain intersection would collapse\n // a conflicting key's value to `never` (e.g. `\"sm\" & \"lg\"`), which then\n // silently drops the variant from `getSchema`'s inferred type.\n defaultVariants: Omit<\n MergedDefaultVariants<ComposedTuple<ComposedSingle, ComposedList>>,\n keyof CVADefaultVariants<Config>\n > &\n CVADefaultVariants<Config>;\n },\n AllVariants<Variants, ComposedSingle, ComposedList>,\n T\n >;\n}\n\n/* defineConfig\n ---------------------------------- */\n\nexport interface DefineConfigOptions<TCX extends AnyCX = CX> {\n /**\n * The class name concatenator used by `cva` and `cx`. It owns the class\n * name grammar entirely: cva assembles the authored values\n * (composed component outputs, `base`, matched variant and compound\n * variant values, `class`/`className`) and passes them through verbatim,\n * one argument each, without interpreting them.\n *\n * The authoring surface adopts the concatenator's own input type\n * automatically (see {@link CXInput}): pass `twMerge` and your variants\n * are checked against tailwind-merge's `ClassNameValue`; pass `clsx` (or\n * any function whose parameters don't narrow further) and you keep the\n * full clsx-flavored `ClassValue` grammar.\n */\n cx: TCX & CXConstraint<TCX>;\n}\n\nexport interface DefineConfig {\n <TCX extends AnyCX>(\n options: DefineConfigOptions<TCX>,\n ): {\n cx: CX<CXInput<TCX>>;\n cva: CVA<CXInput<TCX>>;\n };\n}\n\n/* Exports\n ============================================ */\n\nconst falsyToString = <T extends unknown>(value: T) =>\n typeof value === \"boolean\" ? `${value}` : value === 0 ? \"0\" : value;\n\n// Absent objects normalise to this: `x?.y` costs a temporary at ES2019.\nconst empty: Record<string, any> = {};\n\n// The table for a component that has none. Never written to.\nconst noValues: readonly never[] = [];\n\nconst hasOwn = Object.prototype.hasOwnProperty;\n\nconst ownEnumerable = Object.prototype.propertyIsEnumerable;\n\n// The caller's own defined props, minus the class props, over `seed`. An\n// explicit `undefined` keeps the default; an inherited getter is never read.\nconst definedProps = (\n props: Record<string, unknown>,\n seed: Record<string, unknown>,\n): Record<string, unknown> => {\n let merged: Record<string, unknown> = { ...seed };\n for (const key in props) {\n if (hasOwn.call(props, key)) {\n const value = props[key];\n if (key !== \"class\" && key !== \"className\" && value !== undefined) {\n // A computed key creates a data property; `merged.__proto__ =` would\n // hit `Object.prototype`'s setter and reparent the object.\n if (key === \"__proto__\") merged = { ...merged, [key]: value };\n else merged[key] = value;\n }\n }\n }\n return merged;\n};\n\nconst pushDefined = (out: ClassValue[], value: ClassValue) => {\n if (value !== undefined) out.push(value);\n};\n\nconst pushClassProps = (\n out: ClassValue[],\n source: { class?: ClassValue; className?: ClassValue },\n) => {\n pushDefined(out, source.class);\n pushDefined(out, source.className);\n return out;\n};\n\n// A compound's selectors live in the shared arrays, bounded by start and end.\n// `mask` has a bit per key it selects on: a call whose supplied keys miss it\n// reuses `matchesDefaults`, and a hit only means the selectors are compared,\n// since keys past the 31st share bits.\ninterface PreparedCompound {\n start: number;\n end: number;\n mask: number;\n matchesDefaults: boolean;\n class: ClassValue;\n className: ClassValue;\n}\n\ninterface MergedConfig {\n variants: CVAVariantShape;\n defaults: Record<string, unknown>;\n}\n\n// One source folded into the accumulator, so a later source wins.\nconst mergeInto = (\n merged: MergedConfig,\n source: Record<string, any> | undefined,\n) => {\n const variants: CVAVariantShape | undefined = source && source.variants;\n for (const key in variants) {\n if (hasOwn.call(variants, key)) {\n const values = { ...merged.variants[key], ...variants[key] };\n if (key === \"__proto__\") {\n merged.variants = { ...merged.variants, [key]: values };\n } else {\n merged.variants[key] = values;\n }\n }\n }\n merged.defaults = {\n ...merged.defaults,\n ...(source && source.defaultVariants),\n };\n};\n\nconst mergeConfig = (\n children: readonly CVAComponentShape[],\n definition: Record<string, any>,\n) => {\n const merged: MergedConfig = { variants: {}, defaults: {} };\n for (let i = 0; i < children.length; i++) {\n mergeInto(merged, children[i].config);\n }\n mergeInto(merged, definition);\n return merged;\n};\n\ntype PreparedVariants = readonly [\n variantKeys: readonly string[],\n variantMaps: readonly Record<string, ClassValue>[],\n defaultClasses: readonly ClassValue[],\n];\n\nconst prepareVariants = (\n localVariants: CVAVariantShape | undefined,\n defaults: Record<string, unknown>,\n): PreparedVariants => {\n const names: string[] = [];\n const maps: Record<string, ClassValue>[] = [];\n for (const key in localVariants) {\n if (hasOwn.call(localVariants, key)) {\n names.push(key);\n maps.push(localVariants[key]);\n }\n }\n // No variants, no retained tables; the rest are copied to their exact size.\n if (!names.length) return [noValues, noValues, noValues];\n return [\n names.slice(),\n maps.slice(),\n names.map((key, i) => maps[i][falsyToString(defaults[key]) as string]),\n ];\n};\n\nconst compoundMatches = (\n compound: PreparedCompound,\n indexes: readonly number[],\n selectors: readonly unknown[],\n values: readonly unknown[],\n) => {\n for (let i = compound.start; i < compound.end; i++) {\n const selector = selectors[i];\n const value = values[indexes[i]];\n if (\n Array.isArray(selector) ? !selector.includes(value) : value !== selector\n ) {\n return false;\n }\n }\n return true;\n};\n\n// A compound may select on a name no variant declares: the key list ends here.\ntype PreparedCompounds = readonly [\n keys: readonly string[],\n defaultValues: readonly unknown[],\n compounds: readonly PreparedCompound[],\n indexes: readonly number[],\n selectors: readonly unknown[],\n];\n\nconst prepareCompounds = (\n compoundVariants: readonly (CVAClassProp & Record<string, unknown>)[],\n variantKeys: readonly string[],\n defaults: Record<string, unknown>,\n): PreparedCompounds => {\n const keys = variantKeys.slice();\n const compounds: PreparedCompound[] = [];\n const indexes: number[] = [];\n const selectors: unknown[] = [];\n for (let i = 0; i < compoundVariants.length; i++) {\n const compound = compoundVariants[i];\n const start = indexes.length;\n let mask = 0;\n for (const key in compound) {\n if (hasOwn.call(compound, key)) {\n const selector = compound[key];\n if (key !== \"class\" && key !== \"className\") {\n let index = keys.indexOf(key);\n if (index === -1) index = keys.push(key) - 1;\n indexes.push(index);\n selectors.push(selector);\n mask |= 1 << index;\n }\n }\n }\n compounds.push({\n start,\n end: indexes.length,\n mask,\n matchesDefaults: false,\n class: compound.class,\n className: compound.className,\n });\n }\n const defaultValues = keys.map((key) => defaults[key]);\n for (let i = 0; i < compounds.length; i++) {\n compounds[i].matchesDefaults = compoundMatches(\n compounds[i],\n indexes,\n selectors,\n defaultValues,\n );\n }\n return [\n keys.slice(),\n defaultValues,\n compounds.slice(),\n indexes.slice(),\n selectors.slice(),\n ];\n};\n\n// The body of a component with no prop names to read and no children. At\n// module scope, so it captures three values rather than all of `cva`'s.\nconst createPlainComponent =\n (\n cxArray: (inputs: readonly ClassValue[]) => string,\n defaultOut: readonly ClassValue[],\n singleDefaultClass: ClassValue,\n ) =>\n (input?: Record<string, unknown>) => {\n const props: Record<string, unknown> = input || empty;\n const classValue = props.class as ClassValue;\n const classNameValue = props.className as ClassValue;\n // Rebuilding the list as a literal measures faster than sharing one.\n if (classValue === undefined && singleDefaultClass !== undefined) {\n return cxArray(\n classNameValue === undefined\n ? [singleDefaultClass]\n : [singleDefaultClass, classNameValue],\n );\n }\n const out = defaultOut.slice();\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n };\n\n// Cast to `DefineConfig`: runtime uses `ClassValue`; `CXInput` is type-only.\nexport const defineConfig = ((options: DefineConfigOptions) => {\n // `Reflect.apply` hands over the assembled values as separate arguments and\n // keeps `options` as the receiver, whatever `cx`'s own `call`/`apply` say.\n const cxArray = (inputs: readonly ClassValue[]): string =>\n Reflect.apply(options.cx, options, inputs);\n\n const cx: CX = (...inputs) =>\n // Drop absent values so a narrower concatenator never receives `undefined`.\n cxArray(inputs.filter((input) => input !== undefined));\n\n const cva = (<\n _ extends InternalOnlyWarning,\n Config,\n Variants,\n ComposedSingle extends CVAComponentShape | undefined = undefined,\n ComposedList extends readonly CVAComponentShape[] = [],\n >(\n config: CVAComponentConfig<Config, Variants, ComposedSingle, ComposedList>,\n ) => {\n // The configuration is read here, when the component is created; a call\n // reads only the caller's props and `options`. By contract it is\n // immutable afterwards: a change means a new component.\n const definition: Record<string, any> = config || empty;\n const composes = definition.composes;\n const base: ClassValue = definition.base;\n // A copy, so the merge and every call see the same children.\n const children: readonly CVAComponentShape[] =\n composes == null\n ? noValues\n : Array.isArray(composes)\n ? composes.slice()\n : [composes];\n const childCount = children.length;\n\n const { variants: mergedVariants, defaults } = mergeConfig(\n children,\n definition,\n );\n const preparedVariants = prepareVariants(definition.variants, defaults);\n // Named locals keep the tuple readable; indexed access avoids iterator work.\n const variantKeys = preparedVariants[0];\n const variantMaps = preparedVariants[1];\n const defaultClasses = preparedVariants[2];\n const variantCount = variantKeys.length;\n const prepared = definition.compoundVariants\n ? prepareCompounds(definition.compoundVariants, variantKeys, defaults)\n : undefined;\n // Every prop name a call reads: the variant names first, so one index\n // addresses a value map and a default class too, then compound-only names.\n const keys = prepared ? prepared[0] : variantKeys;\n const defaultValues = prepared ? prepared[1] : noValues;\n const compounds = prepared ? prepared[2] : noValues;\n const indexes = prepared ? prepared[3] : noValues;\n const selectors = prepared ? prepared[4] : noValues;\n const keyCount = keys.length;\n const compoundCount = compounds.length;\n\n // The arguments for a call that supplies no known prop and no class prop,\n // and has no child to run. `Reflect.apply` copies it, so it never escapes.\n const onlyBase = !variantCount && !compoundCount;\n const assembled: ClassValue[] =\n onlyBase && base !== undefined ? [base] : [];\n if (!onlyBase) pushDefined(assembled, base);\n for (let i = 0; i < variantCount; i++) {\n pushDefined(assembled, defaultClasses[i]);\n }\n for (let i = 0; i < compoundCount; i++) {\n const compound = compounds[i];\n if (compound.matchesDefaults) pushClassProps(assembled, compound);\n }\n const defaultOut: ClassValue[] = onlyBase ? assembled : assembled.slice();\n // Every element is defined, so `undefined` means \"not a one-element list\".\n const singleDefaultClass: ClassValue =\n defaultOut.length === 1 ? defaultOut[0] : undefined;\n\n const component = (\n !keyCount && !childCount\n ? createPlainComponent(cxArray, defaultOut, singleDefaultClass)\n : (input?: Record<string, unknown>) => {\n const props: Record<string, unknown> = input || empty;\n const classValue = props.class as ClassValue;\n const classNameValue = props.className as ClassValue;\n\n let supplied = 0;\n const variantClasses = variantCount\n ? new Array<ClassValue>(variantCount)\n : undefined;\n const resolved = compoundCount\n ? new Array<unknown>(keyCount)\n : undefined;\n for (let i = 0; i < keyCount; i++) {\n const key = keys[i];\n // A variant name is read straight off `props`; a compound-only\n // name must be an own enumerable prop to count.\n const own = compoundCount !== 0 && ownEnumerable.call(props, key);\n const value = i < variantCount || own ? props[key] : undefined;\n // Past the 31st key, saturate: every compound with selectors is\n // compared.\n if (value !== undefined) supplied |= i < 31 ? 1 << i : -1;\n if (variantClasses && i < variantCount) {\n const variantKey = falsyToString(value);\n variantClasses[i] = variantKey\n ? variantMaps[i][variantKey as string]\n : defaultClasses[i];\n }\n if (resolved) {\n resolved[i] =\n own && value !== undefined ? value : defaultValues[i];\n }\n }\n\n if (!childCount && !supplied) {\n if (classValue === undefined) {\n if (singleDefaultClass !== undefined) {\n return cxArray(\n classNameValue === undefined\n ? [singleDefaultClass]\n : [singleDefaultClass, classNameValue],\n );\n }\n if (classNameValue === undefined) return cxArray(defaultOut);\n }\n const out = defaultOut.slice();\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n }\n\n const out: ClassValue[] = [];\n if (childCount) {\n // A fresh object per child, and the child read out of the array\n // before the call, or it arrives as that child's `this`.\n const forwarded = definedProps(props, defaults);\n for (let i = 0; i < childCount; i++) {\n const child = children[i];\n pushDefined(out, child({ ...forwarded }));\n }\n }\n\n pushDefined(out, base);\n if (variantClasses) {\n for (let i = 0; i < variantCount; i++) {\n pushDefined(out, variantClasses[i]);\n }\n }\n if (resolved) {\n for (let i = 0; i < compoundCount; i++) {\n const compound = compounds[i];\n let matched = compound.matchesDefaults;\n if (supplied & compound.mask) {\n matched = true;\n for (let j = compound.start; j < compound.end; j++) {\n const selector = selectors[j];\n const value = resolved[indexes[j]];\n if (\n Array.isArray(selector)\n ? !selector.includes(value)\n : value !== selector\n ) {\n matched = false;\n break;\n }\n }\n }\n if (matched) pushClassProps(out, compound);\n }\n }\n\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n }\n ) as CVAComponent<typeof config, typeof config.variants>;\n\n component.config = {\n ...config,\n variants: mergedVariants,\n defaultVariants: defaults,\n };\n\n return component as ReturnType<CVA>;\n }) as CVA;\n\n return {\n cva,\n cx,\n };\n}) as DefineConfig;\n"],"mappings":";;AAgUA,MAAM,iBAAoC,UACxC,OAAO,UAAU,YAAY,GAAG,UAAU,UAAU,IAAI,MAAM;AAGhE,MAAM,QAA6B,CAAC;AAGpC,MAAM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AClD,MAAM,WAAW,UAAU;MAC3B,MAAM,QAAQ,SAAS,QAAQ;MAC/B,IACE,MAAM,QAAQ,QAAQ,IAClB,CAAC,SAAS,SAAS,KAAK,IACxB,UAAU,UACd;OACA,UAAU;OACV;MACF;KACF;IACF;IACA,IAAI,SAAS,eAAe,KAAK,QAAQ;GAC3C;GAGF,YAAY,KAAK,UAAU;GAC3B,YAAY,KAAK,cAAc;GAC/B,OAAO,QAAQ,GAAG;EACpB;EAGN,UAAU,SAAS;GACjB,GAAG;GACH,UAAU;GACV,iBAAiB;EACnB;EAEA,OAAO;CACT;CAEA,OAAO;EACL;EACA;CACF;AACF"}
package/dist/config.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as defineConfig, a as CVAVariantShape, c as CXOptions, d as ClassDictionary, f as ClassValue, g as VariantProps, h as DefineConfigOptions, i as CVAComponentShape, l as CXReturn, m as DefineConfig, n as CVA, o as CX, p as Compose, r as CVAComponent, s as CXInput, t as AnyCX, u as ClassArray } from "./config-CE5oXWBq.cjs";
2
- export { AnyCX, CVA, CVAComponent, CVAComponentShape, CVAVariantShape, CX, CXInput, CXOptions, CXReturn, ClassArray, ClassDictionary, ClassValue, Compose, DefineConfig, DefineConfigOptions, VariantProps, defineConfig };
1
+ import { a as CVAVariantShape, c as CXOptions, d as ClassDictionary, f as ClassValue, g as defineConfig, h as VariantProps, i as CVAComponentShape, l as CXReturn, m as DefineConfigOptions, n as CVA, o as CX, p as DefineConfig, r as CVAComponent, s as CXInput, t as AnyCX, u as ClassArray } from "./config-BnHlj-cB.cjs";
2
+ export { AnyCX, CVA, CVAComponent, CVAComponentShape, CVAVariantShape, CX, CXInput, CXOptions, CXReturn, ClassArray, ClassDictionary, ClassValue, DefineConfig, DefineConfigOptions, VariantProps, defineConfig };
package/dist/config.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as defineConfig, a as CVAVariantShape, c as CXOptions, d as ClassDictionary, f as ClassValue, g as VariantProps, h as DefineConfigOptions, i as CVAComponentShape, l as CXReturn, m as DefineConfig, n as CVA, o as CX, p as Compose, r as CVAComponent, s as CXInput, t as AnyCX, u as ClassArray } from "./config-CE5oXWBq.mjs";
2
- export { AnyCX, CVA, CVAComponent, CVAComponentShape, CVAVariantShape, CX, CXInput, CXOptions, CXReturn, ClassArray, ClassDictionary, ClassValue, Compose, DefineConfig, DefineConfigOptions, VariantProps, defineConfig };
1
+ import { a as CVAVariantShape, c as CXOptions, d as ClassDictionary, f as ClassValue, g as defineConfig, h as VariantProps, i as CVAComponentShape, l as CXReturn, m as DefineConfigOptions, n as CVA, o as CX, p as DefineConfig, r as CVAComponent, s as CXInput, t as AnyCX, u as ClassArray } from "./config-BnHlj-cB.mjs";
2
+ export { AnyCX, CVA, CVAComponent, CVAComponentShape, CVAVariantShape, CX, CXInput, CXOptions, CXReturn, ClassArray, ClassDictionary, ClassValue, DefineConfig, DefineConfigOptions, VariantProps, defineConfig };
package/dist/config.mjs CHANGED
@@ -58,16 +58,16 @@ const prepareVariants = (localVariants, defaults) => {
58
58
  names.push(key);
59
59
  maps.push(localVariants[key]);
60
60
  }
61
- if (!names.length) return {
62
- variantKeys: noValues,
63
- variantMaps: noValues,
64
- defaultClasses: noValues
65
- };
66
- return {
67
- variantKeys: names.slice(),
68
- variantMaps: maps.slice(),
69
- defaultClasses: names.map((key, i) => maps[i][falsyToString(defaults[key])])
70
- };
61
+ if (!names.length) return [
62
+ noValues,
63
+ noValues,
64
+ noValues
65
+ ];
66
+ return [
67
+ names.slice(),
68
+ maps.slice(),
69
+ names.map((key, i) => maps[i][falsyToString(defaults[key])])
70
+ ];
71
71
  };
72
72
  const compoundMatches = (compound, indexes, selectors, values) => {
73
73
  for (let i = compound.start; i < compound.end; i++) {
@@ -107,13 +107,13 @@ const prepareCompounds = (compoundVariants, variantKeys, defaults) => {
107
107
  }
108
108
  const defaultValues = keys.map((key) => defaults[key]);
109
109
  for (let i = 0; i < compounds.length; i++) compounds[i].matchesDefaults = compoundMatches(compounds[i], indexes, selectors, defaultValues);
110
- return {
111
- keys: keys.slice(),
110
+ return [
111
+ keys.slice(),
112
112
  defaultValues,
113
- compounds: compounds.slice(),
114
- indexes: indexes.slice(),
115
- selectors: selectors.slice()
116
- };
113
+ compounds.slice(),
114
+ indexes.slice(),
115
+ selectors.slice()
116
+ ];
117
117
  };
118
118
  const createPlainComponent = (cxArray, defaultOut, singleDefaultClass) => (input) => {
119
119
  const props = input || empty;
@@ -126,13 +126,7 @@ const createPlainComponent = (cxArray, defaultOut, singleDefaultClass) => (input
126
126
  return cxArray(out);
127
127
  };
128
128
  const defineConfig = ((options) => {
129
- const cxArray = (inputs) => {
130
- const className = Reflect.apply(options.cx, options, inputs);
131
- const hooks = options.hooks || empty;
132
- let hook = hooks["cx:done"];
133
- if (hook == null) hook = hooks.onComplete;
134
- return hook ? hook(className) : className;
135
- };
129
+ const cxArray = (inputs) => Reflect.apply(options.cx, options, inputs);
136
130
  const cx = (...inputs) => cxArray(inputs.filter((input) => input !== void 0));
137
131
  const cva = ((config) => {
138
132
  const definition = config || empty;
@@ -141,16 +135,19 @@ const defineConfig = ((options) => {
141
135
  const children = composes == null ? noValues : Array.isArray(composes) ? composes.slice() : [composes];
142
136
  const childCount = children.length;
143
137
  const { variants: mergedVariants, defaults } = mergeConfig(children, definition);
144
- const { variantKeys, variantMaps, defaultClasses } = prepareVariants(definition.variants, defaults);
138
+ const preparedVariants = prepareVariants(definition.variants, defaults);
139
+ const variantKeys = preparedVariants[0];
140
+ const variantMaps = preparedVariants[1];
141
+ const defaultClasses = preparedVariants[2];
145
142
  const variantCount = variantKeys.length;
146
143
  const prepared = definition.compoundVariants ? prepareCompounds(definition.compoundVariants, variantKeys, defaults) : void 0;
147
- const keys = prepared ? prepared.keys : variantKeys;
144
+ const keys = prepared ? prepared[0] : variantKeys;
145
+ const defaultValues = prepared ? prepared[1] : noValues;
146
+ const compounds = prepared ? prepared[2] : noValues;
147
+ const indexes = prepared ? prepared[3] : noValues;
148
+ const selectors = prepared ? prepared[4] : noValues;
148
149
  const keyCount = keys.length;
149
- const compounds = prepared ? prepared.compounds : noValues;
150
150
  const compoundCount = compounds.length;
151
- const indexes = prepared ? prepared.indexes : noValues;
152
- const selectors = prepared ? prepared.selectors : noValues;
153
- const defaultValues = prepared ? prepared.defaultValues : noValues;
154
151
  const onlyBase = !variantCount && !compoundCount;
155
152
  const assembled = onlyBase && base !== void 0 ? [base] : [];
156
153
  if (!onlyBase) pushDefined(assembled, base);
@@ -226,34 +223,7 @@ const defineConfig = ((options) => {
226
223
  };
227
224
  return component;
228
225
  });
229
- const compose = (...components) => {
230
- const composed = components;
231
- const config = {};
232
- for (let i = 0; i < composed.length; i++) {
233
- const source = composed[i].config;
234
- for (const key in source) if (hasOwn.call(source, key)) {
235
- const value = source[key];
236
- config[key] = value && typeof value === "object" && !Array.isArray(value) ? {
237
- ...config[key],
238
- ...value
239
- } : value;
240
- }
241
- }
242
- const component = (input) => {
243
- const props = input || empty;
244
- const forwarded = definedProps(props);
245
- const out = [];
246
- for (let i = 0; i < composed.length; i++) {
247
- const child = composed[i];
248
- pushDefined(out, child(forwarded));
249
- }
250
- return cxArray(pushClassProps(out, props));
251
- };
252
- component.config = config;
253
- return component;
254
- };
255
226
  return {
256
- compose,
257
227
  cva,
258
228
  cx
259
229
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Copyright 2022-present Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n\nimport type {\n CVAClassProp,\n CVAComponentConfig,\n CVAVariantSchema,\n InternalOnlyWarning,\n InternalVariantKey,\n} from \"./types.js\";\n\n/* Types\n ============================================ */\n\n/* ClassValue\n ---------------------------------- */\n\n// Mirrors clsx's `ClassValue`; local to keep `cva/config` dependency-free\n// (TS2742).\n\nexport type ClassValue =\n | ClassArray\n | ClassDictionary\n | string\n | number\n | bigint\n | null\n | boolean\n | undefined;\nexport type ClassDictionary = Record<string, any>;\nexport type ClassArray = ClassValue[];\n\n/* CXInput\n ---------------------------------- */\n\n/**\n * Any function usable as a `cx` concatenator.\n */\nexport type AnyCX = (...inputs: any[]) => string;\n\n// Infer directly from a readonly rest pattern instead of `Parameters<T>[number]`:\n// the latter is `never` for zero-argument callbacks and loses readonly rest\n// element types.\ntype CXInputs<TCX extends AnyCX> = TCX extends (\n ...inputs: readonly [...infer Inputs]\n) => string\n ? Inputs\n : never;\ntype CXInputElement<TCX extends AnyCX> = CXInputs<TCX>[number];\n\n// cva may call `cx` with no values, or with any number of authored values and\n// composed component strings. A constant callback is safe; every other\n// callback must accept arbitrary lists of its own grammar plus strings.\ntype CXHasSafeArity<TCX extends AnyCX> =\n CXInputs<TCX> extends infer Inputs\n ? Inputs extends readonly unknown[]\n ? Inputs extends []\n ? true\n : [] extends Inputs\n ? number extends Inputs[\"length\"]\n ? true\n : false\n : false\n : false\n : false;\ntype CXConstraint<TCX extends AnyCX> =\n false extends CXHasSafeArity<TCX>\n ? \"cva's cx must accept zero arguments and an unbounded rest parameter.\"\n : [TCX] extends [(...inputs: (string | CXInput<TCX>)[]) => string]\n ? unknown\n : \"cva's cx must accept its inferred class values and composed strings.\";\n\n/**\n * The class value type a concatenator accepts, inferred from its\n * parameters — `defineConfig` uses this to type the authoring surface\n * (`base`, variant values, `class`/`className`) against the configured\n * concatenator's own input grammar.\n */\nexport type CXInput<TCX extends AnyCX> =\n CXInputElement<TCX> extends infer P\n ? // `0 extends 1 & P` detects `any`; `any`/`never` use `ClassValue`.\n 0 extends 1 & P\n ? ClassValue\n : [P] extends [never]\n ? ClassValue\n : [P] extends [ClassValue]\n ? P\n : // A concatenator accepting more than cva's grammar (e.g. `string |\n // URL`) narrows to the subset it shares with it, since the surface\n // can't widen beyond what the concatenator accepts; when nothing is\n // shared (e.g. `unknown`), the full grammar applies.\n [Extract<P, ClassValue>] extends [never]\n ? ClassValue\n : Extract<P, ClassValue>\n : ClassValue;\n\n/* Utils\n ---------------------------------- */\n\ntype OmitUndefined<T> = T extends undefined ? never : T;\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\n// `composes` accepts either a single component or a list of components. A\n// plain union (`CVAComponentShape | CVAComponentShape[]`) collapses an array\n// literal's element type to a union, silently dropping components whose\n// variants are a structural subtype of another composed component's (e.g.\n// `composes: [a, b]` where `b`'s variants are a superset of `a`'s). Splitting\n// inference across two type parameters preserves the array as a real tuple.\ntype ComposedTuple<\n S extends CVAComponentShape | undefined,\n L extends readonly CVAComponentShape[],\n> = [S] extends [CVAComponentShape] ? [S] : L;\n\ntype MergedVariants<T extends readonly unknown[]> = UnionToIntersection<\n {\n [K in keyof T]: T[K] extends {\n config: { variants?: infer V extends CVAVariantShape };\n }\n ? V\n : never;\n }[number]\n>;\n\n// Right-biased merge (`B`'s keys win on conflicts) implemented as a mapped\n// type rather than `Omit<A, keyof B> & B`: the latter stays an unresolved\n// deferred type when `A`/`B` are themselves generic (as they are here, via\n// `ReturnType<CVA>` with no concrete `Config`), which then breaks downstream\n// `any`-narrowing in unrelated code that consumes `ReturnType<CVA>` (e.g.\n// the deprecated `compose`). A mapped type resolves eagerly instead.\ntype RightMerge<A, B> = {\n [K in keyof A | keyof B]: K extends keyof B\n ? B[K]\n : K extends keyof A\n ? A[K]\n : never;\n};\n\n// `D` infers as `undefined` (not absent) when a component declares no\n// `defaultVariants` at all. `NonNullable<undefined>` would give `never`,\n// and `keyof never` is `string | number | symbol` (not `never`) — poisoning\n// `RightMerge`'s key union with every possible key. Normalize to `{}` instead,\n// matching a component that contributes nothing to the merge.\ntype DefaultsOf<Component> = Component extends {\n config: { defaultVariants?: infer D };\n}\n ? D extends undefined\n ? {}\n : D\n : {};\n\ntype MergedDefaultVariants<T extends readonly unknown[]> = T extends readonly [\n infer Head,\n ...infer Rest,\n]\n ? RightMerge<DefaultsOf<Head>, MergedDefaultVariants<Rest>>\n : {};\n\ntype ComponentProps<Component extends (...args: any) => any> = Omit<\n OmitUndefined<Parameters<Component>[0]>,\n \"class\" | \"className\"\n>;\n\n// One `Omit`: nesting it inside `ComponentProps` builds the props twice.\nexport type VariantProps<Component extends (...args: any) => any> = Omit<\n OmitUndefined<Parameters<Component>[0]>,\n \"class\" | \"className\" | InternalVariantKey\n>;\n\n/* compose\n ---------------------------------- */\n\n/**\n * @deprecated Use the `composes` property inside `cva` instead.\n * @example\n * // Before\n * const card = compose(box, stack)\n * // After\n * const card = cva({ composes: [box, stack] })\n */\nexport interface Compose<T extends ClassValue = ClassValue> {\n <Components extends readonly unknown[]>(\n ...components: Components &\n (Components[number] extends CVAComponentShape ? unknown : never)\n ): (\n props?: (\n | UnionToIntersection<\n {\n [K in keyof Components]: Components[K] extends CVAComponentShape\n ? ComponentProps<Components[K]>\n : never;\n }[number]\n >\n | undefined\n ) &\n CVAClassProp<T>,\n ) => string;\n}\n\n/* cx\n ---------------------------------- */\n\nexport interface CX<T extends ClassValue = ClassValue> {\n (...inputs: T[]): string;\n}\n\nexport type CXOptions = Parameters<CX>;\nexport type CXReturn = ReturnType<CX>;\n\n/* cva\n ============================================ */\n\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport type CVAVariantShape = Record<string, Record<string, ClassValue>>;\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport interface CVAComponent<\n Config,\n Variants,\n T extends ClassValue = ClassValue,\n> {\n (\n props?: Variants extends CVAVariantShape\n ? CVAVariantSchema<Variants> & CVAClassProp<T>\n : CVAClassProp<T>,\n ): string;\n /** @internal */\n config: Config;\n}\n\n// The loosest form a composable component can take, constraining `composes`\n// and the composition merge helpers above. Deriving it from `CVAComponent`\n// keeps the two from drifting: instantiated with `any`, the props conditional\n// and `config` both collapse to `any` (mapped types over `any` are `any`),\n// i.e. `{ (props?: any): string; config: any }`. The required `config`\n// property is what rejects plain functions and (deprecated) `compose`\n// results.\n//\n// The `any` arguments are deliberate, not lazy typing — a shaped `config`\n// (e.g. `{ variants?: CVAVariantShape }`) was tried and verifiably breaks:\n// a variant-less `cva({ base })` carries `variants: unknown`, and\n// `ReturnType<CVA>` instantiates this constraint inside the\n// `Compose`/`GetSchema` guards, where the shaped form rejects every real\n// component via props contravariance.\n//\n// Its class-value parameter must be `any`: narrowed components otherwise fail\n// props contravariance in `composes` and `getSchema`.\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport type CVAComponentShape = CVAComponent<any, any, any>;\n\ntype CVADefaultVariants<Config> = Config extends { defaultVariants?: infer D }\n ? D\n : {};\n\n// Nothing composed is the common case: answer with `Variants` and skip the\n// merge machinery.\ntype AllVariants<\n Variants,\n ComposedSingle extends CVAComponentShape | undefined,\n ComposedList extends readonly CVAComponentShape[],\n> = [ComposedSingle] extends [undefined]\n ? [ComposedList] extends [readonly []]\n ? Variants\n : Variants & MergedVariants<ComposedList>\n : Variants & MergedVariants<ComposedTuple<ComposedSingle, ComposedList>>;\n\nexport interface CVA<T extends ClassValue = ClassValue> {\n <\n _ extends InternalOnlyWarning,\n Config,\n Variants,\n ComposedSingle extends CVAComponentShape | undefined = undefined,\n ComposedList extends readonly CVAComponentShape[] = [],\n >(\n config: CVAComponentConfig<\n Config,\n Variants,\n ComposedSingle,\n ComposedList,\n T,\n AllVariants<Variants, ComposedSingle, ComposedList>\n >,\n ): CVAComponent<\n Omit<Config, \"defaultVariants\"> & {\n variants: AllVariants<Variants, ComposedSingle, ComposedList>;\n // Local `defaultVariants` win over composed ones on key conflicts,\n // matching the runtime spread order. A plain intersection would collapse\n // a conflicting key's value to `never` (e.g. `\"sm\" & \"lg\"`), which then\n // silently drops the variant from `getSchema`'s inferred type.\n defaultVariants: Omit<\n MergedDefaultVariants<ComposedTuple<ComposedSingle, ComposedList>>,\n keyof CVADefaultVariants<Config>\n > &\n CVADefaultVariants<Config>;\n },\n AllVariants<Variants, ComposedSingle, ComposedList>,\n T\n >;\n}\n\n/* defineConfig\n ---------------------------------- */\n\nexport interface DefineConfigOptions<TCX extends AnyCX = CX> {\n /**\n * The class name concatenator used by `cva`, `cx`, and `compose`. It owns\n * the class name grammar entirely: cva assembles the authored values\n * (composed component outputs, `base`, matched variant and compound\n * variant values, `class`/`className`) and passes them through verbatim,\n * one argument each, without interpreting them.\n *\n * The authoring surface adopts the concatenator's own input type\n * automatically (see {@link CXInput}): pass `twMerge` and your variants\n * are checked against tailwind-merge's `ClassNameValue`; pass `clsx` (or\n * any function whose parameters don't narrow further) and you keep the\n * full clsx-flavored `ClassValue` grammar.\n */\n cx: TCX & CXConstraint<TCX>;\n hooks?: {\n /**\n * @deprecated please use the `cx` option instead\n */\n \"cx:done\"?: (className: string) => string;\n /**\n * @deprecated please use the `cx` option instead\n */\n onComplete?: (className: string) => string;\n };\n}\n\nexport interface DefineConfig {\n <TCX extends AnyCX>(\n options: DefineConfigOptions<TCX>,\n ): {\n /**\n * @deprecated Use the `composes` property inside `cva` instead.\n * @example\n * // Before\n * const card = compose(box, stack)\n * // After\n * const card = cva({ composes: [box, stack] })\n */\n compose: Compose<CXInput<TCX>>;\n cx: CX<CXInput<TCX>>;\n cva: CVA<CXInput<TCX>>;\n };\n}\n\n/* Exports\n ============================================ */\n\nconst falsyToString = <T extends unknown>(value: T) =>\n typeof value === \"boolean\" ? `${value}` : value === 0 ? \"0\" : value;\n\n// Absent objects normalise to this: `x?.y` costs a temporary at ES2019.\nconst empty: Record<string, any> = {};\n\n// The table for a component that has none. Never written to.\nconst noValues: readonly never[] = [];\n\nconst hasOwn = Object.prototype.hasOwnProperty;\n\nconst ownEnumerable = Object.prototype.propertyIsEnumerable;\n\n// The caller's own defined props, minus the class props, over `seed`. An\n// explicit `undefined` keeps the default; an inherited getter is never read.\nconst definedProps = (\n props: Record<string, unknown>,\n seed?: Record<string, unknown>,\n): Record<string, unknown> => {\n let merged: Record<string, unknown> = { ...seed };\n for (const key in props) {\n if (hasOwn.call(props, key)) {\n const value = props[key];\n if (key !== \"class\" && key !== \"className\" && value !== undefined) {\n // A computed key creates a data property; `merged.__proto__ =` would\n // hit `Object.prototype`'s setter and reparent the object.\n if (key === \"__proto__\") merged = { ...merged, [key]: value };\n else merged[key] = value;\n }\n }\n }\n return merged;\n};\n\nconst pushDefined = (out: ClassValue[], value: ClassValue) => {\n if (value !== undefined) out.push(value);\n};\n\nconst pushClassProps = (\n out: ClassValue[],\n source: { class?: ClassValue; className?: ClassValue },\n) => {\n pushDefined(out, source.class);\n pushDefined(out, source.className);\n return out;\n};\n\n// A compound's selectors live in the shared arrays, bounded by start and end.\n// `mask` has a bit per key it selects on: a call whose supplied keys miss it\n// reuses `matchesDefaults`, and a hit only means the selectors are compared,\n// since keys past the 31st share bits.\ninterface PreparedCompound {\n start: number;\n end: number;\n mask: number;\n matchesDefaults: boolean;\n class: ClassValue;\n className: ClassValue;\n}\n\ninterface MergedConfig {\n variants: CVAVariantShape;\n defaults: Record<string, unknown>;\n}\n\n// One source folded into the accumulator, so a later source wins.\nconst mergeInto = (\n merged: MergedConfig,\n source: Record<string, any> | undefined,\n) => {\n const variants: CVAVariantShape | undefined = source && source.variants;\n for (const key in variants) {\n if (hasOwn.call(variants, key)) {\n const values = { ...merged.variants[key], ...variants[key] };\n if (key === \"__proto__\") {\n merged.variants = { ...merged.variants, [key]: values };\n } else {\n merged.variants[key] = values;\n }\n }\n }\n merged.defaults = {\n ...merged.defaults,\n ...(source && source.defaultVariants),\n };\n};\n\nconst mergeConfig = (\n children: readonly CVAComponentShape[],\n definition: Record<string, any>,\n) => {\n const merged: MergedConfig = { variants: {}, defaults: {} };\n for (let i = 0; i < children.length; i++) {\n mergeInto(merged, children[i].config);\n }\n mergeInto(merged, definition);\n return merged;\n};\n\nconst prepareVariants = (\n localVariants: CVAVariantShape | undefined,\n defaults: Record<string, unknown>,\n) => {\n const names: string[] = [];\n const maps: Record<string, ClassValue>[] = [];\n for (const key in localVariants) {\n if (hasOwn.call(localVariants, key)) {\n names.push(key);\n maps.push(localVariants[key]);\n }\n }\n // No variants, no retained tables; the rest are copied to their exact size.\n if (!names.length) {\n return {\n variantKeys: noValues,\n variantMaps: noValues,\n defaultClasses: noValues,\n };\n }\n return {\n variantKeys: names.slice(),\n variantMaps: maps.slice(),\n defaultClasses: names.map(\n (key, i) => maps[i][falsyToString(defaults[key]) as string],\n ),\n };\n};\n\nconst compoundMatches = (\n compound: PreparedCompound,\n indexes: readonly number[],\n selectors: readonly unknown[],\n values: readonly unknown[],\n) => {\n for (let i = compound.start; i < compound.end; i++) {\n const selector = selectors[i];\n const value = values[indexes[i]];\n if (\n Array.isArray(selector) ? !selector.includes(value) : value !== selector\n ) {\n return false;\n }\n }\n return true;\n};\n\n// A compound may select on a name no variant declares: the key list ends here.\nconst prepareCompounds = (\n compoundVariants: readonly (CVAClassProp & Record<string, unknown>)[],\n variantKeys: readonly string[],\n defaults: Record<string, unknown>,\n) => {\n const keys = variantKeys.slice();\n const compounds: PreparedCompound[] = [];\n const indexes: number[] = [];\n const selectors: unknown[] = [];\n for (let i = 0; i < compoundVariants.length; i++) {\n const compound = compoundVariants[i];\n const start = indexes.length;\n let mask = 0;\n for (const key in compound) {\n if (hasOwn.call(compound, key)) {\n const selector = compound[key];\n if (key !== \"class\" && key !== \"className\") {\n let index = keys.indexOf(key);\n if (index === -1) index = keys.push(key) - 1;\n indexes.push(index);\n selectors.push(selector);\n mask |= 1 << index;\n }\n }\n }\n compounds.push({\n start,\n end: indexes.length,\n mask,\n matchesDefaults: false,\n class: compound.class,\n className: compound.className,\n });\n }\n const defaultValues = keys.map((key) => defaults[key]);\n for (let i = 0; i < compounds.length; i++) {\n compounds[i].matchesDefaults = compoundMatches(\n compounds[i],\n indexes,\n selectors,\n defaultValues,\n );\n }\n return {\n keys: keys.slice(),\n defaultValues,\n compounds: compounds.slice(),\n indexes: indexes.slice(),\n selectors: selectors.slice(),\n };\n};\n\n// The body of a component with no prop names to read and no children. At\n// module scope, so it captures three values rather than all of `cva`'s.\nconst createPlainComponent =\n (\n cxArray: (inputs: readonly ClassValue[]) => string,\n defaultOut: readonly ClassValue[],\n singleDefaultClass: ClassValue,\n ) =>\n (input?: Record<string, unknown>) => {\n const props: Record<string, unknown> = input || empty;\n const classValue = props.class as ClassValue;\n const classNameValue = props.className as ClassValue;\n // Rebuilding the list as a literal measures faster than sharing one.\n if (classValue === undefined && singleDefaultClass !== undefined) {\n return cxArray(\n classNameValue === undefined\n ? [singleDefaultClass]\n : [singleDefaultClass, classNameValue],\n );\n }\n const out = defaultOut.slice();\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n };\n\n// Cast to `DefineConfig`: runtime uses `ClassValue`; `CXInput` is type-only.\nexport const defineConfig = ((options: DefineConfigOptions) => {\n // `Reflect.apply` hands over the assembled values as separate arguments and\n // keeps `options` as the receiver, whatever `cx`'s own `call`/`apply` say.\n const cxArray = (inputs: readonly ClassValue[]): string => {\n const className: string = Reflect.apply(options.cx, options, inputs);\n const hooks = options.hooks || empty;\n // `??` semantics, spelled out because it downlevels to a temporary.\n let hook: ((className: string) => string) | undefined = hooks[\"cx:done\"];\n if (hook == null) hook = hooks.onComplete;\n return hook ? hook(className) : className;\n };\n\n const cx: CX = (...inputs) =>\n // Drop absent values so a narrower concatenator never receives `undefined`.\n cxArray(inputs.filter((input) => input !== undefined));\n\n const cva = (<\n _ extends InternalOnlyWarning,\n Config,\n Variants,\n ComposedSingle extends CVAComponentShape | undefined = undefined,\n ComposedList extends readonly CVAComponentShape[] = [],\n >(\n config: CVAComponentConfig<Config, Variants, ComposedSingle, ComposedList>,\n ) => {\n // The configuration is read here, when the component is created; a call\n // reads only the caller's props and `options`. By contract it is\n // immutable afterwards: a change means a new component.\n const definition: Record<string, any> = config || empty;\n const composes = definition.composes;\n const base: ClassValue = definition.base;\n // A copy, so the merge and every call see the same children.\n const children: readonly CVAComponentShape[] =\n composes == null\n ? noValues\n : Array.isArray(composes)\n ? composes.slice()\n : [composes];\n const childCount = children.length;\n\n const { variants: mergedVariants, defaults } = mergeConfig(\n children,\n definition,\n );\n const { variantKeys, variantMaps, defaultClasses } = prepareVariants(\n definition.variants,\n defaults,\n );\n const variantCount = variantKeys.length;\n const prepared = definition.compoundVariants\n ? prepareCompounds(definition.compoundVariants, variantKeys, defaults)\n : undefined;\n // Every prop name a call reads: the variant names first, so one index\n // addresses a value map and a default class too, then compound-only names.\n const keys: readonly string[] = prepared ? prepared.keys : variantKeys;\n const keyCount = keys.length;\n const compounds: readonly PreparedCompound[] = prepared\n ? prepared.compounds\n : noValues;\n const compoundCount = compounds.length;\n const indexes: readonly number[] = prepared ? prepared.indexes : noValues;\n const selectors: readonly unknown[] = prepared\n ? prepared.selectors\n : noValues;\n const defaultValues: readonly unknown[] = prepared\n ? prepared.defaultValues\n : noValues;\n\n // The arguments for a call that supplies no known prop and no class prop,\n // and has no child to run. `Reflect.apply` copies it, so it never escapes.\n const onlyBase = !variantCount && !compoundCount;\n const assembled: ClassValue[] =\n onlyBase && base !== undefined ? [base] : [];\n if (!onlyBase) pushDefined(assembled, base);\n for (let i = 0; i < variantCount; i++) {\n pushDefined(assembled, defaultClasses[i]);\n }\n for (let i = 0; i < compoundCount; i++) {\n const compound = compounds[i];\n if (compound.matchesDefaults) pushClassProps(assembled, compound);\n }\n const defaultOut: ClassValue[] = onlyBase ? assembled : assembled.slice();\n // Every element is defined, so `undefined` means \"not a one-element list\".\n const singleDefaultClass: ClassValue =\n defaultOut.length === 1 ? defaultOut[0] : undefined;\n\n const component = (\n !keyCount && !childCount\n ? createPlainComponent(cxArray, defaultOut, singleDefaultClass)\n : (input?: Record<string, unknown>) => {\n const props: Record<string, unknown> = input || empty;\n const classValue = props.class as ClassValue;\n const classNameValue = props.className as ClassValue;\n\n let supplied = 0;\n const variantClasses = variantCount\n ? new Array<ClassValue>(variantCount)\n : undefined;\n const resolved = compoundCount\n ? new Array<unknown>(keyCount)\n : undefined;\n for (let i = 0; i < keyCount; i++) {\n const key = keys[i];\n // A variant name is read straight off `props`; a compound-only\n // name must be an own enumerable prop to count.\n const own = compoundCount !== 0 && ownEnumerable.call(props, key);\n const value = i < variantCount || own ? props[key] : undefined;\n // Past the 31st key, saturate: every compound with selectors is\n // compared.\n if (value !== undefined) supplied |= i < 31 ? 1 << i : -1;\n if (variantClasses && i < variantCount) {\n const variantKey = falsyToString(value);\n variantClasses[i] = variantKey\n ? variantMaps[i][variantKey as string]\n : defaultClasses[i];\n }\n if (resolved) {\n resolved[i] =\n own && value !== undefined ? value : defaultValues[i];\n }\n }\n\n if (!childCount && !supplied) {\n if (classValue === undefined) {\n if (singleDefaultClass !== undefined) {\n return cxArray(\n classNameValue === undefined\n ? [singleDefaultClass]\n : [singleDefaultClass, classNameValue],\n );\n }\n if (classNameValue === undefined) return cxArray(defaultOut);\n }\n const out = defaultOut.slice();\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n }\n\n const out: ClassValue[] = [];\n if (childCount) {\n // A fresh object per child, and the child read out of the array\n // before the call, or it arrives as that child's `this`.\n const forwarded = definedProps(props, defaults);\n for (let i = 0; i < childCount; i++) {\n const child = children[i];\n pushDefined(out, child({ ...forwarded }));\n }\n }\n\n pushDefined(out, base);\n if (variantClasses) {\n for (let i = 0; i < variantCount; i++) {\n pushDefined(out, variantClasses[i]);\n }\n }\n if (resolved) {\n for (let i = 0; i < compoundCount; i++) {\n const compound = compounds[i];\n let matched = compound.matchesDefaults;\n if (supplied & compound.mask) {\n matched = true;\n for (let j = compound.start; j < compound.end; j++) {\n const selector = selectors[j];\n const value = resolved[indexes[j]];\n if (\n Array.isArray(selector)\n ? !selector.includes(value)\n : value !== selector\n ) {\n matched = false;\n break;\n }\n }\n }\n if (matched) pushClassProps(out, compound);\n }\n }\n\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n }\n ) as CVAComponent<typeof config, typeof config.variants>;\n\n component.config = {\n ...config,\n variants: mergedVariants,\n defaultVariants: defaults,\n };\n\n return component as ReturnType<CVA>;\n }) as CVA;\n\n const compose: Compose = (...components) => {\n const composed = components as CVAComponentShape[];\n const config: Record<string, any> = {};\n for (let i = 0; i < composed.length; i++) {\n const source = composed[i].config;\n for (const key in source) {\n if (hasOwn.call(source, key)) {\n const value = source[key];\n config[key] =\n value && typeof value === \"object\" && !Array.isArray(value)\n ? { ...config[key], ...value }\n : value;\n }\n }\n }\n\n const component: CVAComponent<typeof config, typeof config.variants> = (\n input,\n ) => {\n const props: Record<string, unknown> = input || empty;\n const forwarded = definedProps(props);\n const out: ClassValue[] = [];\n for (let i = 0; i < composed.length; i++) {\n const child = composed[i];\n pushDefined(out, child(forwarded));\n }\n return cxArray(pushClassProps(out, props));\n };\n\n component.config = config;\n\n return component;\n };\n\n return {\n compose,\n cva,\n cx,\n };\n}) as DefineConfig;\n"],"mappings":";AAuXA,MAAM,iBAAoC,UACxC,OAAO,UAAU,YAAY,GAAG,UAAU,UAAU,IAAI,MAAM;AAGhE,MAAM,QAA6B,CAAC;AAGpC,MAAM,WAA6B,CAAC;AAEpC,MAAM,SAAS,OAAO,UAAU;AAEhC,MAAM,gBAAgB,OAAO,UAAU;AAIvC,MAAM,gBACJ,OACA,SAC4B;CAC5B,IAAI,SAAkC,EAAE,GAAG,KAAK;CAChD,KAAK,MAAM,OAAO,OAChB,IAAI,OAAO,KAAK,OAAO,GAAG,GAAG;EAC3B,MAAM,QAAQ,MAAM;EACpB,IAAI,QAAQ,WAAW,QAAQ,eAAe,UAAU,KAAA,GAGtD,IAAI,QAAQ,aAAa,SAAS;GAAE,GAAG;IAAS,MAAM;EA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AC3C;GAGF,YAAY,KAAK,UAAU;GAC3B,YAAY,KAAK,cAAc;GAC/B,OAAO,QAAQ,GAAG;EACpB;EAGN,UAAU,SAAS;GACjB,GAAG;GACH,UAAU;GACV,iBAAiB;EACnB;EAEA,OAAO;CACT;CAEA,MAAM,WAAoB,GAAG,eAAe;EAC1C,MAAM,WAAW;EACjB,MAAM,SAA8B,CAAC;EACrC,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;GACxC,MAAM,SAAS,SAAS,EAAE,CAAC;GAC3B,KAAK,MAAM,OAAO,QAChB,IAAI,OAAO,KAAK,QAAQ,GAAG,GAAG;IAC5B,MAAM,QAAQ,OAAO;IACrB,OAAO,OACL,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IACtD;KAAE,GAAG,OAAO;KAAM,GAAG;IAAM,IAC3B;GACR;EAEJ;EAEA,MAAM,aACJ,UACG;GACH,MAAM,QAAiC,SAAS;GAChD,MAAM,YAAY,aAAa,KAAK;GACpC,MAAM,MAAoB,CAAC;GAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;IACxC,MAAM,QAAQ,SAAS;IACvB,YAAY,KAAK,MAAM,SAAS,CAAC;GACnC;GACA,OAAO,QAAQ,eAAe,KAAK,KAAK,CAAC;EAC3C;EAEA,UAAU,SAAS;EAEnB,OAAO;CACT;CAEA,OAAO;EACL;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Copyright 2022-present Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n\nimport type {\n CVAClassProp,\n CVAComponentConfig,\n CVAVariantSchema,\n InternalOnlyWarning,\n InternalVariantKey,\n} from \"./types.js\";\n\n/* Types\n ============================================ */\n\n/* ClassValue\n ---------------------------------- */\n\n// Mirrors clsx's `ClassValue`; local to keep `cva/config` dependency-free\n// (TS2742).\n\nexport type ClassValue =\n | ClassArray\n | ClassDictionary\n | string\n | number\n | bigint\n | null\n | boolean\n | undefined;\nexport type ClassDictionary = Record<string, any>;\nexport type ClassArray = ClassValue[];\n\n/* CXInput\n ---------------------------------- */\n\n/**\n * Any function usable as a `cx` concatenator.\n */\nexport type AnyCX = (...inputs: any[]) => string;\n\n// Infer directly from a readonly rest pattern instead of `Parameters<T>[number]`:\n// the latter is `never` for zero-argument callbacks and loses readonly rest\n// element types.\ntype CXInputs<TCX extends AnyCX> = TCX extends (\n ...inputs: readonly [...infer Inputs]\n) => string\n ? Inputs\n : never;\ntype CXInputElement<TCX extends AnyCX> = CXInputs<TCX>[number];\n\n// cva may call `cx` with no values, or with any number of authored values and\n// composed component strings. A constant callback is safe; every other\n// callback must accept arbitrary lists of its own grammar plus strings.\ntype CXHasSafeArity<TCX extends AnyCX> =\n CXInputs<TCX> extends infer Inputs\n ? Inputs extends readonly unknown[]\n ? Inputs extends []\n ? true\n : [] extends Inputs\n ? number extends Inputs[\"length\"]\n ? true\n : false\n : false\n : false\n : false;\ntype CXConstraint<TCX extends AnyCX> =\n false extends CXHasSafeArity<TCX>\n ? \"cva's cx must accept zero arguments and an unbounded rest parameter.\"\n : [TCX] extends [(...inputs: (string | CXInput<TCX>)[]) => string]\n ? unknown\n : \"cva's cx must accept its inferred class values and composed strings.\";\n\n/**\n * The class value type a concatenator accepts, inferred from its\n * parameters — `defineConfig` uses this to type the authoring surface\n * (`base`, variant values, `class`/`className`) against the configured\n * concatenator's own input grammar.\n */\nexport type CXInput<TCX extends AnyCX> =\n CXInputElement<TCX> extends infer P\n ? // `0 extends 1 & P` detects `any`; `any`/`never` use `ClassValue`.\n 0 extends 1 & P\n ? ClassValue\n : [P] extends [never]\n ? ClassValue\n : [P] extends [ClassValue]\n ? P\n : // A concatenator accepting more than cva's grammar (e.g. `string |\n // URL`) narrows to the subset it shares with it, since the surface\n // can't widen beyond what the concatenator accepts; when nothing is\n // shared (e.g. `unknown`), the full grammar applies.\n [Extract<P, ClassValue>] extends [never]\n ? ClassValue\n : Extract<P, ClassValue>\n : ClassValue;\n\n/* Utils\n ---------------------------------- */\n\ntype OmitUndefined<T> = T extends undefined ? never : T;\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\n// `composes` accepts either a single component or a list of components. A\n// plain union (`CVAComponentShape | CVAComponentShape[]`) collapses an array\n// literal's element type to a union, silently dropping components whose\n// variants are a structural subtype of another composed component's (e.g.\n// `composes: [a, b]` where `b`'s variants are a superset of `a`'s). Splitting\n// inference across two type parameters preserves the array as a real tuple.\ntype ComposedTuple<\n S extends CVAComponentShape | undefined,\n L extends readonly CVAComponentShape[],\n> = [S] extends [CVAComponentShape] ? [S] : L;\n\ntype MergedVariants<T extends readonly unknown[]> = UnionToIntersection<\n {\n [K in keyof T]: T[K] extends {\n config: { variants?: infer V extends CVAVariantShape };\n }\n ? V\n : never;\n }[number]\n>;\n\n// Right-biased merge (`B`'s keys win on conflicts) implemented as a mapped\n// type rather than `Omit<A, keyof B> & B`: the latter stays an unresolved\n// deferred type when `A`/`B` are themselves generic (as they are here, via\n// `ReturnType<CVA>` with no concrete `Config`), which then breaks downstream\n// `any`-narrowing in unrelated code that consumes `ReturnType<CVA>` (e.g. the\n// `composes` and `getSchema` guards). A mapped type resolves eagerly instead.\ntype RightMerge<A, B> = {\n [K in keyof A | keyof B]: K extends keyof B\n ? B[K]\n : K extends keyof A\n ? A[K]\n : never;\n};\n\n// `D` infers as `undefined` (not absent) when a component declares no\n// `defaultVariants` at all. `NonNullable<undefined>` would give `never`,\n// and `keyof never` is `string | number | symbol` (not `never`) — poisoning\n// `RightMerge`'s key union with every possible key. Normalize to `{}` instead,\n// matching a component that contributes nothing to the merge.\ntype DefaultsOf<Component> = Component extends {\n config: { defaultVariants?: infer D };\n}\n ? D extends undefined\n ? {}\n : D\n : {};\n\ntype MergedDefaultVariants<T extends readonly unknown[]> = T extends readonly [\n infer Head,\n ...infer Rest,\n]\n ? RightMerge<DefaultsOf<Head>, MergedDefaultVariants<Rest>>\n : {};\n\n// One `Omit`: nesting the class-prop removal in a helper builds the props twice.\nexport type VariantProps<Component extends (...args: any) => any> = Omit<\n OmitUndefined<Parameters<Component>[0]>,\n \"class\" | \"className\" | InternalVariantKey\n>;\n\n/* cx\n ---------------------------------- */\n\nexport interface CX<T extends ClassValue = ClassValue> {\n (...inputs: T[]): string;\n}\n\nexport type CXOptions = Parameters<CX>;\nexport type CXReturn = ReturnType<CX>;\n\n/* cva\n ============================================ */\n\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport type CVAVariantShape = Record<string, Record<string, ClassValue>>;\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport interface CVAComponent<\n Config,\n Variants,\n T extends ClassValue = ClassValue,\n> {\n (\n props?: Variants extends CVAVariantShape\n ? CVAVariantSchema<Variants> & CVAClassProp<T>\n : CVAClassProp<T>,\n ): string;\n /** @internal */\n config: Config;\n}\n\n// The loosest form a composable component can take, constraining `composes`\n// and the composition merge helpers above. Deriving it from `CVAComponent`\n// keeps the two from drifting: instantiated with `any`, the props conditional\n// and `config` both collapse to `any` (mapped types over `any` are `any`),\n// i.e. `{ (props?: any): string; config: any }`. The required `config`\n// property is what rejects plain functions.\n//\n// The `any` arguments are deliberate, not lazy typing — a shaped `config`\n// (e.g. `{ variants?: CVAVariantShape }`) was tried and verifiably breaks:\n// a variant-less `cva({ base })` carries `variants: unknown`, and\n// `ReturnType<CVA>` instantiates this constraint inside the `composes` and\n// `GetSchema` guards, where the shaped form rejects every real component via\n// props contravariance.\n//\n// Its class-value parameter must be `any`: narrowed components otherwise fail\n// props contravariance in `composes` and `getSchema`.\n/**\n * Exported so TypeScript can name this type in your generated declarations\n * (`declaration: true`) — you shouldn't really use it directly.\n */\nexport type CVAComponentShape = CVAComponent<any, any, any>;\n\ntype CVADefaultVariants<Config> = Config extends { defaultVariants?: infer D }\n ? D\n : {};\n\n// Nothing composed is the common case: answer with `Variants` and skip the\n// merge machinery.\ntype AllVariants<\n Variants,\n ComposedSingle extends CVAComponentShape | undefined,\n ComposedList extends readonly CVAComponentShape[],\n> = [ComposedSingle] extends [undefined]\n ? [ComposedList] extends [readonly []]\n ? Variants\n : Variants & MergedVariants<ComposedList>\n : Variants & MergedVariants<ComposedTuple<ComposedSingle, ComposedList>>;\n\nexport interface CVA<T extends ClassValue = ClassValue> {\n <\n _ extends InternalOnlyWarning,\n Config,\n Variants,\n ComposedSingle extends CVAComponentShape | undefined = undefined,\n ComposedList extends readonly CVAComponentShape[] = [],\n >(\n config: CVAComponentConfig<\n Config,\n Variants,\n ComposedSingle,\n ComposedList,\n T,\n AllVariants<Variants, ComposedSingle, ComposedList>\n >,\n ): CVAComponent<\n Omit<Config, \"defaultVariants\"> & {\n variants: AllVariants<Variants, ComposedSingle, ComposedList>;\n // Local `defaultVariants` win over composed ones on key conflicts,\n // matching the runtime spread order. A plain intersection would collapse\n // a conflicting key's value to `never` (e.g. `\"sm\" & \"lg\"`), which then\n // silently drops the variant from `getSchema`'s inferred type.\n defaultVariants: Omit<\n MergedDefaultVariants<ComposedTuple<ComposedSingle, ComposedList>>,\n keyof CVADefaultVariants<Config>\n > &\n CVADefaultVariants<Config>;\n },\n AllVariants<Variants, ComposedSingle, ComposedList>,\n T\n >;\n}\n\n/* defineConfig\n ---------------------------------- */\n\nexport interface DefineConfigOptions<TCX extends AnyCX = CX> {\n /**\n * The class name concatenator used by `cva` and `cx`. It owns the class\n * name grammar entirely: cva assembles the authored values\n * (composed component outputs, `base`, matched variant and compound\n * variant values, `class`/`className`) and passes them through verbatim,\n * one argument each, without interpreting them.\n *\n * The authoring surface adopts the concatenator's own input type\n * automatically (see {@link CXInput}): pass `twMerge` and your variants\n * are checked against tailwind-merge's `ClassNameValue`; pass `clsx` (or\n * any function whose parameters don't narrow further) and you keep the\n * full clsx-flavored `ClassValue` grammar.\n */\n cx: TCX & CXConstraint<TCX>;\n}\n\nexport interface DefineConfig {\n <TCX extends AnyCX>(\n options: DefineConfigOptions<TCX>,\n ): {\n cx: CX<CXInput<TCX>>;\n cva: CVA<CXInput<TCX>>;\n };\n}\n\n/* Exports\n ============================================ */\n\nconst falsyToString = <T extends unknown>(value: T) =>\n typeof value === \"boolean\" ? `${value}` : value === 0 ? \"0\" : value;\n\n// Absent objects normalise to this: `x?.y` costs a temporary at ES2019.\nconst empty: Record<string, any> = {};\n\n// The table for a component that has none. Never written to.\nconst noValues: readonly never[] = [];\n\nconst hasOwn = Object.prototype.hasOwnProperty;\n\nconst ownEnumerable = Object.prototype.propertyIsEnumerable;\n\n// The caller's own defined props, minus the class props, over `seed`. An\n// explicit `undefined` keeps the default; an inherited getter is never read.\nconst definedProps = (\n props: Record<string, unknown>,\n seed: Record<string, unknown>,\n): Record<string, unknown> => {\n let merged: Record<string, unknown> = { ...seed };\n for (const key in props) {\n if (hasOwn.call(props, key)) {\n const value = props[key];\n if (key !== \"class\" && key !== \"className\" && value !== undefined) {\n // A computed key creates a data property; `merged.__proto__ =` would\n // hit `Object.prototype`'s setter and reparent the object.\n if (key === \"__proto__\") merged = { ...merged, [key]: value };\n else merged[key] = value;\n }\n }\n }\n return merged;\n};\n\nconst pushDefined = (out: ClassValue[], value: ClassValue) => {\n if (value !== undefined) out.push(value);\n};\n\nconst pushClassProps = (\n out: ClassValue[],\n source: { class?: ClassValue; className?: ClassValue },\n) => {\n pushDefined(out, source.class);\n pushDefined(out, source.className);\n return out;\n};\n\n// A compound's selectors live in the shared arrays, bounded by start and end.\n// `mask` has a bit per key it selects on: a call whose supplied keys miss it\n// reuses `matchesDefaults`, and a hit only means the selectors are compared,\n// since keys past the 31st share bits.\ninterface PreparedCompound {\n start: number;\n end: number;\n mask: number;\n matchesDefaults: boolean;\n class: ClassValue;\n className: ClassValue;\n}\n\ninterface MergedConfig {\n variants: CVAVariantShape;\n defaults: Record<string, unknown>;\n}\n\n// One source folded into the accumulator, so a later source wins.\nconst mergeInto = (\n merged: MergedConfig,\n source: Record<string, any> | undefined,\n) => {\n const variants: CVAVariantShape | undefined = source && source.variants;\n for (const key in variants) {\n if (hasOwn.call(variants, key)) {\n const values = { ...merged.variants[key], ...variants[key] };\n if (key === \"__proto__\") {\n merged.variants = { ...merged.variants, [key]: values };\n } else {\n merged.variants[key] = values;\n }\n }\n }\n merged.defaults = {\n ...merged.defaults,\n ...(source && source.defaultVariants),\n };\n};\n\nconst mergeConfig = (\n children: readonly CVAComponentShape[],\n definition: Record<string, any>,\n) => {\n const merged: MergedConfig = { variants: {}, defaults: {} };\n for (let i = 0; i < children.length; i++) {\n mergeInto(merged, children[i].config);\n }\n mergeInto(merged, definition);\n return merged;\n};\n\ntype PreparedVariants = readonly [\n variantKeys: readonly string[],\n variantMaps: readonly Record<string, ClassValue>[],\n defaultClasses: readonly ClassValue[],\n];\n\nconst prepareVariants = (\n localVariants: CVAVariantShape | undefined,\n defaults: Record<string, unknown>,\n): PreparedVariants => {\n const names: string[] = [];\n const maps: Record<string, ClassValue>[] = [];\n for (const key in localVariants) {\n if (hasOwn.call(localVariants, key)) {\n names.push(key);\n maps.push(localVariants[key]);\n }\n }\n // No variants, no retained tables; the rest are copied to their exact size.\n if (!names.length) return [noValues, noValues, noValues];\n return [\n names.slice(),\n maps.slice(),\n names.map((key, i) => maps[i][falsyToString(defaults[key]) as string]),\n ];\n};\n\nconst compoundMatches = (\n compound: PreparedCompound,\n indexes: readonly number[],\n selectors: readonly unknown[],\n values: readonly unknown[],\n) => {\n for (let i = compound.start; i < compound.end; i++) {\n const selector = selectors[i];\n const value = values[indexes[i]];\n if (\n Array.isArray(selector) ? !selector.includes(value) : value !== selector\n ) {\n return false;\n }\n }\n return true;\n};\n\n// A compound may select on a name no variant declares: the key list ends here.\ntype PreparedCompounds = readonly [\n keys: readonly string[],\n defaultValues: readonly unknown[],\n compounds: readonly PreparedCompound[],\n indexes: readonly number[],\n selectors: readonly unknown[],\n];\n\nconst prepareCompounds = (\n compoundVariants: readonly (CVAClassProp & Record<string, unknown>)[],\n variantKeys: readonly string[],\n defaults: Record<string, unknown>,\n): PreparedCompounds => {\n const keys = variantKeys.slice();\n const compounds: PreparedCompound[] = [];\n const indexes: number[] = [];\n const selectors: unknown[] = [];\n for (let i = 0; i < compoundVariants.length; i++) {\n const compound = compoundVariants[i];\n const start = indexes.length;\n let mask = 0;\n for (const key in compound) {\n if (hasOwn.call(compound, key)) {\n const selector = compound[key];\n if (key !== \"class\" && key !== \"className\") {\n let index = keys.indexOf(key);\n if (index === -1) index = keys.push(key) - 1;\n indexes.push(index);\n selectors.push(selector);\n mask |= 1 << index;\n }\n }\n }\n compounds.push({\n start,\n end: indexes.length,\n mask,\n matchesDefaults: false,\n class: compound.class,\n className: compound.className,\n });\n }\n const defaultValues = keys.map((key) => defaults[key]);\n for (let i = 0; i < compounds.length; i++) {\n compounds[i].matchesDefaults = compoundMatches(\n compounds[i],\n indexes,\n selectors,\n defaultValues,\n );\n }\n return [\n keys.slice(),\n defaultValues,\n compounds.slice(),\n indexes.slice(),\n selectors.slice(),\n ];\n};\n\n// The body of a component with no prop names to read and no children. At\n// module scope, so it captures three values rather than all of `cva`'s.\nconst createPlainComponent =\n (\n cxArray: (inputs: readonly ClassValue[]) => string,\n defaultOut: readonly ClassValue[],\n singleDefaultClass: ClassValue,\n ) =>\n (input?: Record<string, unknown>) => {\n const props: Record<string, unknown> = input || empty;\n const classValue = props.class as ClassValue;\n const classNameValue = props.className as ClassValue;\n // Rebuilding the list as a literal measures faster than sharing one.\n if (classValue === undefined && singleDefaultClass !== undefined) {\n return cxArray(\n classNameValue === undefined\n ? [singleDefaultClass]\n : [singleDefaultClass, classNameValue],\n );\n }\n const out = defaultOut.slice();\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n };\n\n// Cast to `DefineConfig`: runtime uses `ClassValue`; `CXInput` is type-only.\nexport const defineConfig = ((options: DefineConfigOptions) => {\n // `Reflect.apply` hands over the assembled values as separate arguments and\n // keeps `options` as the receiver, whatever `cx`'s own `call`/`apply` say.\n const cxArray = (inputs: readonly ClassValue[]): string =>\n Reflect.apply(options.cx, options, inputs);\n\n const cx: CX = (...inputs) =>\n // Drop absent values so a narrower concatenator never receives `undefined`.\n cxArray(inputs.filter((input) => input !== undefined));\n\n const cva = (<\n _ extends InternalOnlyWarning,\n Config,\n Variants,\n ComposedSingle extends CVAComponentShape | undefined = undefined,\n ComposedList extends readonly CVAComponentShape[] = [],\n >(\n config: CVAComponentConfig<Config, Variants, ComposedSingle, ComposedList>,\n ) => {\n // The configuration is read here, when the component is created; a call\n // reads only the caller's props and `options`. By contract it is\n // immutable afterwards: a change means a new component.\n const definition: Record<string, any> = config || empty;\n const composes = definition.composes;\n const base: ClassValue = definition.base;\n // A copy, so the merge and every call see the same children.\n const children: readonly CVAComponentShape[] =\n composes == null\n ? noValues\n : Array.isArray(composes)\n ? composes.slice()\n : [composes];\n const childCount = children.length;\n\n const { variants: mergedVariants, defaults } = mergeConfig(\n children,\n definition,\n );\n const preparedVariants = prepareVariants(definition.variants, defaults);\n // Named locals keep the tuple readable; indexed access avoids iterator work.\n const variantKeys = preparedVariants[0];\n const variantMaps = preparedVariants[1];\n const defaultClasses = preparedVariants[2];\n const variantCount = variantKeys.length;\n const prepared = definition.compoundVariants\n ? prepareCompounds(definition.compoundVariants, variantKeys, defaults)\n : undefined;\n // Every prop name a call reads: the variant names first, so one index\n // addresses a value map and a default class too, then compound-only names.\n const keys = prepared ? prepared[0] : variantKeys;\n const defaultValues = prepared ? prepared[1] : noValues;\n const compounds = prepared ? prepared[2] : noValues;\n const indexes = prepared ? prepared[3] : noValues;\n const selectors = prepared ? prepared[4] : noValues;\n const keyCount = keys.length;\n const compoundCount = compounds.length;\n\n // The arguments for a call that supplies no known prop and no class prop,\n // and has no child to run. `Reflect.apply` copies it, so it never escapes.\n const onlyBase = !variantCount && !compoundCount;\n const assembled: ClassValue[] =\n onlyBase && base !== undefined ? [base] : [];\n if (!onlyBase) pushDefined(assembled, base);\n for (let i = 0; i < variantCount; i++) {\n pushDefined(assembled, defaultClasses[i]);\n }\n for (let i = 0; i < compoundCount; i++) {\n const compound = compounds[i];\n if (compound.matchesDefaults) pushClassProps(assembled, compound);\n }\n const defaultOut: ClassValue[] = onlyBase ? assembled : assembled.slice();\n // Every element is defined, so `undefined` means \"not a one-element list\".\n const singleDefaultClass: ClassValue =\n defaultOut.length === 1 ? defaultOut[0] : undefined;\n\n const component = (\n !keyCount && !childCount\n ? createPlainComponent(cxArray, defaultOut, singleDefaultClass)\n : (input?: Record<string, unknown>) => {\n const props: Record<string, unknown> = input || empty;\n const classValue = props.class as ClassValue;\n const classNameValue = props.className as ClassValue;\n\n let supplied = 0;\n const variantClasses = variantCount\n ? new Array<ClassValue>(variantCount)\n : undefined;\n const resolved = compoundCount\n ? new Array<unknown>(keyCount)\n : undefined;\n for (let i = 0; i < keyCount; i++) {\n const key = keys[i];\n // A variant name is read straight off `props`; a compound-only\n // name must be an own enumerable prop to count.\n const own = compoundCount !== 0 && ownEnumerable.call(props, key);\n const value = i < variantCount || own ? props[key] : undefined;\n // Past the 31st key, saturate: every compound with selectors is\n // compared.\n if (value !== undefined) supplied |= i < 31 ? 1 << i : -1;\n if (variantClasses && i < variantCount) {\n const variantKey = falsyToString(value);\n variantClasses[i] = variantKey\n ? variantMaps[i][variantKey as string]\n : defaultClasses[i];\n }\n if (resolved) {\n resolved[i] =\n own && value !== undefined ? value : defaultValues[i];\n }\n }\n\n if (!childCount && !supplied) {\n if (classValue === undefined) {\n if (singleDefaultClass !== undefined) {\n return cxArray(\n classNameValue === undefined\n ? [singleDefaultClass]\n : [singleDefaultClass, classNameValue],\n );\n }\n if (classNameValue === undefined) return cxArray(defaultOut);\n }\n const out = defaultOut.slice();\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n }\n\n const out: ClassValue[] = [];\n if (childCount) {\n // A fresh object per child, and the child read out of the array\n // before the call, or it arrives as that child's `this`.\n const forwarded = definedProps(props, defaults);\n for (let i = 0; i < childCount; i++) {\n const child = children[i];\n pushDefined(out, child({ ...forwarded }));\n }\n }\n\n pushDefined(out, base);\n if (variantClasses) {\n for (let i = 0; i < variantCount; i++) {\n pushDefined(out, variantClasses[i]);\n }\n }\n if (resolved) {\n for (let i = 0; i < compoundCount; i++) {\n const compound = compounds[i];\n let matched = compound.matchesDefaults;\n if (supplied & compound.mask) {\n matched = true;\n for (let j = compound.start; j < compound.end; j++) {\n const selector = selectors[j];\n const value = resolved[indexes[j]];\n if (\n Array.isArray(selector)\n ? !selector.includes(value)\n : value !== selector\n ) {\n matched = false;\n break;\n }\n }\n }\n if (matched) pushClassProps(out, compound);\n }\n }\n\n pushDefined(out, classValue);\n pushDefined(out, classNameValue);\n return cxArray(out);\n }\n ) as CVAComponent<typeof config, typeof config.variants>;\n\n component.config = {\n ...config,\n variants: mergedVariants,\n defaultVariants: defaults,\n };\n\n return component as ReturnType<CVA>;\n }) as CVA;\n\n return {\n cva,\n cx,\n };\n}) as DefineConfig;\n"],"mappings":";AAgUA,MAAM,iBAAoC,UACxC,OAAO,UAAU,YAAY,GAAG,UAAU,UAAU,IAAI,MAAM;AAGhE,MAAM,QAA6B,CAAC;AAGpC,MAAM,WAA6B,CAAC;AAEpC,MAAM,SAAS,OAAO,UAAU;AAEhC,MAAM,gBAAgB,OAAO,UAAU;AAIvC,MAAM,gBACJ,OACA,SAC4B;CAC5B,IAAI,SAAkC,EAAE,GAAG,KAAK;CAChD,KAAK,MAAM,OAAO,OAChB,IAAI,OAAO,KA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QAAQ;GAC3C;GAGF,YAAY,KAAK,UAAU;GAC3B,YAAY,KAAK,cAAc;GAC/B,OAAO,QAAQ,GAAG;EACpB;EAGN,UAAU,SAAS;GACjB,GAAG;GACH,UAAU;GACV,iBAAiB;EACnB;EAEA,OAAO;CACT;CAEA,OAAO;EACL;EACA;CACF;AACF"}
package/dist/index.cjs CHANGED
@@ -1,6 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_config = require("./config.cjs");
3
- const require_tools = require("./tools.cjs");
4
3
  let clsx = require("clsx");
5
4
  //#region src/index.ts
6
5
  /**
@@ -18,29 +17,9 @@ let clsx = require("clsx");
18
17
  * License for the specific language governing permissions and limitations under
19
18
  * the License.
20
19
  */
21
- /** @deprecated Import `getSchema` from `cva/tools` instead. */
22
- const getSchema = require_tools.getSchema;
23
- /**
24
- * @deprecated Import `defineConfig` from `cva/config` instead — the `cva`
25
- * package is the clsx preset, while `cva/config` is where custom
26
- * configuration (your own `cx` concatenator, hooks) lives.
27
- */
28
- const defineConfig = ((options) => {
29
- var _options$cx;
30
- return require_config.defineConfig({
31
- ...options,
32
- cx: (_options$cx = options === null || options === void 0 ? void 0 : options.cx) !== null && _options$cx !== void 0 ? _options$cx : clsx.clsx
33
- });
34
- });
35
- const preset = require_config.defineConfig({ cx: clsx.clsx });
36
- /** @deprecated Use the `composes` property inside `cva` instead. */
37
- const compose = preset.compose;
38
- const { cva, cx } = preset;
20
+ const { cva, cx } = require_config.defineConfig({ cx: clsx.clsx });
39
21
  //#endregion
40
- exports.compose = compose;
41
22
  exports.cva = cva;
42
23
  exports.cx = cx;
43
- exports.defineConfig = defineConfig;
44
- exports.getSchema = getSchema;
45
24
 
46
25
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["getSchemaTool","defineCoreConfig"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Copyright 2022-present Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\nimport { clsx } from \"clsx\";\nimport {\n defineConfig as defineCoreConfig,\n type AnyCX,\n type CVA,\n type CXInput,\n type Compose,\n type CX,\n type DefineConfigOptions as CoreDefineConfigOptions,\n} from \"./config.js\";\nimport {\n getSchema as getSchemaTool,\n type GetSchema as ToolsGetSchema,\n} from \"./tools.js\";\n\nexport type {\n AnyCX,\n ClassValue,\n ClassDictionary,\n ClassArray,\n VariantProps,\n Compose,\n CX,\n CXInput,\n CXOptions,\n CXReturn,\n CVAVariantShape,\n CVAComponent,\n CVAComponentShape,\n CVA,\n} from \"./config.js\";\n\n/** @deprecated Import `GetSchema` from `cva/tools` instead. */\nexport type GetSchema = ToolsGetSchema;\n\n/** @deprecated Import `getSchema` from `cva/tools` instead. */\nexport const getSchema: GetSchema = getSchemaTool;\n\n/**\n * @deprecated Import `DefineConfigOptions` from `cva/config` instead and provide\n * the required `cx` concatenator (for example, `clsx`).\n */\nexport interface DefineConfigOptions<TCX extends AnyCX = CX> extends Omit<\n CoreDefineConfigOptions<TCX>,\n \"cx\"\n> {\n /** Defaults to `clsx`. */\n cx?: CoreDefineConfigOptions<TCX>[\"cx\"];\n}\n\n/**\n * @deprecated Import `DefineConfig` from `cva/config` instead. Its options require\n * a `cx` concatenator (for example, `clsx`).\n */\nexport interface DefineConfig {\n <TCX extends AnyCX = CX>(\n options?: DefineConfigOptions<TCX>,\n ): {\n /**\n * @deprecated Use the `composes` property inside `cva` instead.\n * @example\n * // Before\n * const card = compose(box, stack)\n * // After\n * const card = cva({ composes: [box, stack] })\n */\n compose: Compose<CXInput<TCX>>;\n cx: CX<CXInput<TCX>>;\n cva: CVA<CXInput<TCX>>;\n };\n}\n\n/**\n * @deprecated Import `defineConfig` from `cva/config` instead — the `cva`\n * package is the clsx preset, while `cva/config` is where custom\n * configuration (your own `cx` concatenator, hooks) lives.\n */\nexport const defineConfig = ((options?: DefineConfigOptions) =>\n defineCoreConfig({\n ...options,\n cx: options?.cx ?? clsx,\n })) as DefineConfig;\n\n// Pin the preset to config's `ClassValue` alias: inferring from `clsx` would\n// name clsx's own `ClassValue` in the declaration, which is not portable\n// (TS2883).\nconst preset = defineCoreConfig<CX>({ cx: clsx });\n\n/** @deprecated Use the `composes` property inside `cva` instead. */\nexport const compose = preset.compose;\nexport const { cva, cx } = preset;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,YAAuBA,cAAAA;;;;;;AAyCpC,MAAa,iBAAiB,YAC5B;;oCAAiB;EACf,GAAG;EACH,KAAA,cAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAI,QAAS,QAAA,QAAA,gBAAA,KAAA,IAAA,cAAM,KAAA;CACrB,CAAC;;AAKH,MAAM,SAASC,eAAAA,aAAqB,EAAE,IAAI,KAAA,KAAK,CAAC;;AAGhD,MAAa,UAAU,OAAO;AAC9B,MAAa,EAAE,KAAK,OAAO"}
1
+ {"version":3,"file":"index.cjs","names":["defineConfig"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Copyright 2022-present Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\nimport { clsx } from \"clsx\";\nimport { defineConfig, type CX } from \"./config.js\";\n\nexport type {\n AnyCX,\n ClassValue,\n ClassDictionary,\n ClassArray,\n VariantProps,\n CX,\n CXInput,\n CXOptions,\n CXReturn,\n CVAVariantShape,\n CVAComponent,\n CVAComponentShape,\n CVA,\n} from \"./config.js\";\n\n// Pin the preset to config's `ClassValue` alias: inferring from `clsx` would\n// name clsx's own `ClassValue` in the declaration, which is not portable\n// (TS2883).\nexport const { cva, cx } = defineConfig<CX>({ cx: clsx });\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAa,EAAE,KAAK,OAAOA,eAAAA,aAAiB,EAAE,IAAI,KAAA,KAAK,CAAC"}
package/dist/index.d.cts CHANGED
@@ -1,46 +1,6 @@
1
- import { a as CVAVariantShape, c as CXOptions, d as ClassDictionary, f as ClassValue, g as VariantProps, h as DefineConfigOptions$1, i as CVAComponentShape, l as CXReturn, n as CVA, o as CX, p as Compose, r as CVAComponent, s as CXInput, t as AnyCX, u as ClassArray } from "./config-CE5oXWBq.cjs";
2
- import { GetSchema as GetSchema$1 } from "./tools.cjs";
1
+ import { a as CVAVariantShape, c as CXOptions, d as ClassDictionary, f as ClassValue, h as VariantProps, i as CVAComponentShape, l as CXReturn, n as CVA, o as CX, r as CVAComponent, s as CXInput, t as AnyCX, u as ClassArray } from "./config-BnHlj-cB.cjs";
3
2
  //#region src/index.d.ts
4
- /** @deprecated Import `GetSchema` from `cva/tools` instead. */
5
- type GetSchema = GetSchema$1;
6
- /** @deprecated Import `getSchema` from `cva/tools` instead. */
7
- declare const getSchema: GetSchema;
8
- /**
9
- * @deprecated Import `DefineConfigOptions` from `cva/config` instead and provide
10
- * the required `cx` concatenator (for example, `clsx`).
11
- */
12
- interface DefineConfigOptions<TCX extends AnyCX = CX> extends Omit<DefineConfigOptions$1<TCX>, "cx"> {
13
- /** Defaults to `clsx`. */
14
- cx?: DefineConfigOptions$1<TCX>["cx"];
15
- }
16
- /**
17
- * @deprecated Import `DefineConfig` from `cva/config` instead. Its options require
18
- * a `cx` concatenator (for example, `clsx`).
19
- */
20
- interface DefineConfig {
21
- <TCX extends AnyCX = CX>(options?: DefineConfigOptions<TCX>): {
22
- /**
23
- * @deprecated Use the `composes` property inside `cva` instead.
24
- * @example
25
- * // Before
26
- * const card = compose(box, stack)
27
- * // After
28
- * const card = cva({ composes: [box, stack] })
29
- */
30
- compose: Compose<CXInput<TCX>>;
31
- cx: CX<CXInput<TCX>>;
32
- cva: CVA<CXInput<TCX>>;
33
- };
34
- }
35
- /**
36
- * @deprecated Import `defineConfig` from `cva/config` instead — the `cva`
37
- * package is the clsx preset, while `cva/config` is where custom
38
- * configuration (your own `cx` concatenator, hooks) lives.
39
- */
40
- declare const defineConfig: DefineConfig;
41
- /** @deprecated Use the `composes` property inside `cva` instead. */
42
- declare const compose: Compose<ClassValue>;
43
3
  declare const cva: CVA<ClassValue>, cx: CX<ClassValue>;
44
4
  //#endregion
45
- export { type AnyCX, type CVA, type CVAComponent, type CVAComponentShape, type CVAVariantShape, type CX, type CXInput, type CXOptions, type CXReturn, type ClassArray, type ClassDictionary, type ClassValue, type Compose, DefineConfig, DefineConfigOptions, GetSchema, type VariantProps, compose, cva, cx, defineConfig, getSchema };
5
+ export { type AnyCX, type CVA, type CVAComponent, type CVAComponentShape, type CVAVariantShape, type CX, type CXInput, type CXOptions, type CXReturn, type ClassArray, type ClassDictionary, type ClassValue, type VariantProps, cva, cx };
46
6
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,46 +1,6 @@
1
- import { a as CVAVariantShape, c as CXOptions, d as ClassDictionary, f as ClassValue, g as VariantProps, h as DefineConfigOptions$1, i as CVAComponentShape, l as CXReturn, n as CVA, o as CX, p as Compose, r as CVAComponent, s as CXInput, t as AnyCX, u as ClassArray } from "./config-CE5oXWBq.mjs";
2
- import { GetSchema as GetSchema$1 } from "./tools.mjs";
1
+ import { a as CVAVariantShape, c as CXOptions, d as ClassDictionary, f as ClassValue, h as VariantProps, i as CVAComponentShape, l as CXReturn, n as CVA, o as CX, r as CVAComponent, s as CXInput, t as AnyCX, u as ClassArray } from "./config-BnHlj-cB.mjs";
3
2
  //#region src/index.d.ts
4
- /** @deprecated Import `GetSchema` from `cva/tools` instead. */
5
- type GetSchema = GetSchema$1;
6
- /** @deprecated Import `getSchema` from `cva/tools` instead. */
7
- declare const getSchema: GetSchema;
8
- /**
9
- * @deprecated Import `DefineConfigOptions` from `cva/config` instead and provide
10
- * the required `cx` concatenator (for example, `clsx`).
11
- */
12
- interface DefineConfigOptions<TCX extends AnyCX = CX> extends Omit<DefineConfigOptions$1<TCX>, "cx"> {
13
- /** Defaults to `clsx`. */
14
- cx?: DefineConfigOptions$1<TCX>["cx"];
15
- }
16
- /**
17
- * @deprecated Import `DefineConfig` from `cva/config` instead. Its options require
18
- * a `cx` concatenator (for example, `clsx`).
19
- */
20
- interface DefineConfig {
21
- <TCX extends AnyCX = CX>(options?: DefineConfigOptions<TCX>): {
22
- /**
23
- * @deprecated Use the `composes` property inside `cva` instead.
24
- * @example
25
- * // Before
26
- * const card = compose(box, stack)
27
- * // After
28
- * const card = cva({ composes: [box, stack] })
29
- */
30
- compose: Compose<CXInput<TCX>>;
31
- cx: CX<CXInput<TCX>>;
32
- cva: CVA<CXInput<TCX>>;
33
- };
34
- }
35
- /**
36
- * @deprecated Import `defineConfig` from `cva/config` instead — the `cva`
37
- * package is the clsx preset, while `cva/config` is where custom
38
- * configuration (your own `cx` concatenator, hooks) lives.
39
- */
40
- declare const defineConfig: DefineConfig;
41
- /** @deprecated Use the `composes` property inside `cva` instead. */
42
- declare const compose: Compose<ClassValue>;
43
3
  declare const cva: CVA<ClassValue>, cx: CX<ClassValue>;
44
4
  //#endregion
45
- export { type AnyCX, type CVA, type CVAComponent, type CVAComponentShape, type CVAVariantShape, type CX, type CXInput, type CXOptions, type CXReturn, type ClassArray, type ClassDictionary, type ClassValue, type Compose, DefineConfig, DefineConfigOptions, GetSchema, type VariantProps, compose, cva, cx, defineConfig, getSchema };
5
+ export { type AnyCX, type CVA, type CVAComponent, type CVAComponentShape, type CVAVariantShape, type CX, type CXInput, type CXOptions, type CXReturn, type ClassArray, type ClassDictionary, type ClassValue, type VariantProps, cva, cx };
46
6
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { defineConfig as defineConfig$1 } from "./config.mjs";
2
- import { getSchema as getSchema$1 } from "./tools.mjs";
1
+ import { defineConfig } from "./config.mjs";
3
2
  import { clsx } from "clsx";
4
3
  //#region src/index.ts
5
4
  /**
@@ -17,25 +16,8 @@ import { clsx } from "clsx";
17
16
  * License for the specific language governing permissions and limitations under
18
17
  * the License.
19
18
  */
20
- /** @deprecated Import `getSchema` from `cva/tools` instead. */
21
- const getSchema = getSchema$1;
22
- /**
23
- * @deprecated Import `defineConfig` from `cva/config` instead — the `cva`
24
- * package is the clsx preset, while `cva/config` is where custom
25
- * configuration (your own `cx` concatenator, hooks) lives.
26
- */
27
- const defineConfig = ((options) => {
28
- var _options$cx;
29
- return defineConfig$1({
30
- ...options,
31
- cx: (_options$cx = options === null || options === void 0 ? void 0 : options.cx) !== null && _options$cx !== void 0 ? _options$cx : clsx
32
- });
33
- });
34
- const preset = defineConfig$1({ cx: clsx });
35
- /** @deprecated Use the `composes` property inside `cva` instead. */
36
- const compose = preset.compose;
37
- const { cva, cx } = preset;
19
+ const { cva, cx } = defineConfig({ cx: clsx });
38
20
  //#endregion
39
- export { compose, cva, cx, defineConfig, getSchema };
21
+ export { cva, cx };
40
22
 
41
23
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["getSchemaTool","defineCoreConfig"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Copyright 2022-present Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\nimport { clsx } from \"clsx\";\nimport {\n defineConfig as defineCoreConfig,\n type AnyCX,\n type CVA,\n type CXInput,\n type Compose,\n type CX,\n type DefineConfigOptions as CoreDefineConfigOptions,\n} from \"./config.js\";\nimport {\n getSchema as getSchemaTool,\n type GetSchema as ToolsGetSchema,\n} from \"./tools.js\";\n\nexport type {\n AnyCX,\n ClassValue,\n ClassDictionary,\n ClassArray,\n VariantProps,\n Compose,\n CX,\n CXInput,\n CXOptions,\n CXReturn,\n CVAVariantShape,\n CVAComponent,\n CVAComponentShape,\n CVA,\n} from \"./config.js\";\n\n/** @deprecated Import `GetSchema` from `cva/tools` instead. */\nexport type GetSchema = ToolsGetSchema;\n\n/** @deprecated Import `getSchema` from `cva/tools` instead. */\nexport const getSchema: GetSchema = getSchemaTool;\n\n/**\n * @deprecated Import `DefineConfigOptions` from `cva/config` instead and provide\n * the required `cx` concatenator (for example, `clsx`).\n */\nexport interface DefineConfigOptions<TCX extends AnyCX = CX> extends Omit<\n CoreDefineConfigOptions<TCX>,\n \"cx\"\n> {\n /** Defaults to `clsx`. */\n cx?: CoreDefineConfigOptions<TCX>[\"cx\"];\n}\n\n/**\n * @deprecated Import `DefineConfig` from `cva/config` instead. Its options require\n * a `cx` concatenator (for example, `clsx`).\n */\nexport interface DefineConfig {\n <TCX extends AnyCX = CX>(\n options?: DefineConfigOptions<TCX>,\n ): {\n /**\n * @deprecated Use the `composes` property inside `cva` instead.\n * @example\n * // Before\n * const card = compose(box, stack)\n * // After\n * const card = cva({ composes: [box, stack] })\n */\n compose: Compose<CXInput<TCX>>;\n cx: CX<CXInput<TCX>>;\n cva: CVA<CXInput<TCX>>;\n };\n}\n\n/**\n * @deprecated Import `defineConfig` from `cva/config` instead — the `cva`\n * package is the clsx preset, while `cva/config` is where custom\n * configuration (your own `cx` concatenator, hooks) lives.\n */\nexport const defineConfig = ((options?: DefineConfigOptions) =>\n defineCoreConfig({\n ...options,\n cx: options?.cx ?? clsx,\n })) as DefineConfig;\n\n// Pin the preset to config's `ClassValue` alias: inferring from `clsx` would\n// name clsx's own `ClassValue` in the declaration, which is not portable\n// (TS2883).\nconst preset = defineCoreConfig<CX>({ cx: clsx });\n\n/** @deprecated Use the `composes` property inside `cva` instead. */\nexport const compose = preset.compose;\nexport const { cva, cx } = preset;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,YAAuBA;;;;;;AAyCpC,MAAa,iBAAiB,YAC5B;;uBAAiB;EACf,GAAG;EACH,KAAA,cAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAI,QAAS,QAAA,QAAA,gBAAA,KAAA,IAAA,cAAM;CACrB,CAAC;;AAKH,MAAM,SAASC,eAAqB,EAAE,IAAI,KAAK,CAAC;;AAGhD,MAAa,UAAU,OAAO;AAC9B,MAAa,EAAE,KAAK,OAAO"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Copyright 2022-present Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\nimport { clsx } from \"clsx\";\nimport { defineConfig, type CX } from \"./config.js\";\n\nexport type {\n AnyCX,\n ClassValue,\n ClassDictionary,\n ClassArray,\n VariantProps,\n CX,\n CXInput,\n CXOptions,\n CXReturn,\n CVAVariantShape,\n CVAComponent,\n CVAComponentShape,\n CVA,\n} from \"./config.js\";\n\n// Pin the preset to config's `ClassValue` alias: inferring from `clsx` would\n// name clsx's own `ClassValue` in the declaration, which is not portable\n// (TS2883).\nexport const { cva, cx } = defineConfig<CX>({ cx: clsx });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqCA,MAAa,EAAE,KAAK,OAAO,aAAiB,EAAE,IAAI,KAAK,CAAC"}
package/dist/tools.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { b as InternalVariantKey, i as CVAComponentShape, v as CVAComponentConfig, x as StringToBoolean, y as InternalOnlyWarning } from "./config-CE5oXWBq.cjs";
1
+ import { _ as CVAComponentConfig, b as StringToBoolean, i as CVAComponentShape, v as InternalOnlyWarning, y as InternalVariantKey } from "./config-BnHlj-cB.cjs";
2
2
  //#region src/tools.d.ts
3
3
  type SchemaEntry<Config, Variants, Variant extends keyof Variants> = Config extends CVAComponentConfig<Config, Variants> ? Variant extends keyof Config["defaultVariants"] ? Config["defaultVariants"][Variant] extends undefined ? never : {
4
4
  values: ReadonlyArray<StringToBoolean<keyof Variants[Variant]>>;
package/dist/tools.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { b as InternalVariantKey, i as CVAComponentShape, v as CVAComponentConfig, x as StringToBoolean, y as InternalOnlyWarning } from "./config-CE5oXWBq.mjs";
1
+ import { _ as CVAComponentConfig, b as StringToBoolean, i as CVAComponentShape, v as InternalOnlyWarning, y as InternalVariantKey } from "./config-BnHlj-cB.mjs";
2
2
  //#region src/tools.d.ts
3
3
  type SchemaEntry<Config, Variants, Variant extends keyof Variants> = Config extends CVAComponentConfig<Config, Variants> ? Variant extends keyof Config["defaultVariants"] ? Config["defaultVariants"][Variant] extends undefined ? never : {
4
4
  values: ReadonlyArray<StringToBoolean<keyof Variants[Variant]>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cva",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.11",
4
4
  "description": "Class Variance Authority",
5
5
  "keywords": [
6
6
  "Class Variance Authority",
@@ -17,6 +17,10 @@
17
17
  "homepage": "https://github.com/joe-bell/cva#readme",
18
18
  "bugs": "https://github.com/joe-bell/cva/issues",
19
19
  "repository": "https://github.com/joe-bell/cva.git",
20
+ "funding": {
21
+ "type": "github",
22
+ "url": "https://github.com/sponsors/joe-bell"
23
+ },
20
24
  "license": "Apache-2.0",
21
25
  "author": "Joe Bell (https://joebell.studio)",
22
26
  "sideEffects": false,
@@ -75,11 +79,11 @@
75
79
  "size-limit": [
76
80
  {
77
81
  "path": "dist/index.cjs",
78
- "limit": "2.15KB"
82
+ "limit": "1.65KB"
79
83
  },
80
84
  {
81
85
  "path": "dist/config.cjs",
82
- "limit": "1.7KB"
86
+ "limit": "1.45KB"
83
87
  },
84
88
  {
85
89
  "path": "dist/tools.cjs",