clava 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # clava
2
2
 
3
+ ## 0.1.14
4
+
5
+ ### Patch Changes
6
+
7
+ - fee9f84: Fixed `computed` method not receiving default variants set by an intermediate component.
8
+
3
9
  ## 0.1.13
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -20198,10 +20198,10 @@ interface StyleProps {
20198
20198
  }
20199
20199
  type ComponentResult = JSXProps | HTMLProps | HTMLObjProps;
20200
20200
  type AllComponentResultKeys = keyof JSXProps | keyof HTMLProps | keyof HTMLObjProps;
20201
- type ComponentResultValue<K$1 extends AllComponentResultKeys> = K$1 extends "style" ? StyleProperty : K$1 extends "className" ? string : K$1 extends "class" ? string : never;
20201
+ type ComponentResultValue<K extends AllComponentResultKeys> = K extends "style" ? StyleProperty : K extends "className" ? string : K extends "class" ? string : never;
20202
20202
  type NullableComponentResult = { [K in AllComponentResultKeys]?: ComponentResultValue<K> | null };
20203
- type ComponentProps<V$1 = {}> = VariantValues<V$1> & NullableComponentResult;
20204
- type GetVariants<V$1> = (variants?: VariantValues<V$1>) => VariantValues<V$1>;
20203
+ type ComponentProps<V = {}> = VariantValues<V> & NullableComponentResult;
20204
+ type GetVariants<V> = (variants?: VariantValues<V>) => VariantValues<V>;
20205
20205
  type KeySourceArray = readonly string[];
20206
20206
  type KeySourceComponent = {
20207
20207
  keys: readonly (string | number | symbol)[];
@@ -20226,48 +20226,48 @@ type SourceResultWithoutStyling<T, S> = IsComponent<S> extends true ? Pick<T, Ex
20226
20226
  type BuildSourceResults<T, Sources extends readonly KeySource[], StylingClaimed extends boolean, UsedKeys> = Sources extends readonly [infer Current extends KeySource, ...infer Rest extends readonly KeySource[]] ? [StylingClaimed extends true ? SourceResultWithoutStyling<T, Current> : SourceResultWithStyling<T, Current>, ...BuildSourceResults<T, Rest, StylingClaimed extends true ? true : IsComponent<Current>, UsedKeys | SourceKeys<Current>>] : [Omit<T, UsedKeys & (string | number | symbol)>];
20227
20227
  type SplitPropsFunction = <T, const S1 extends KeySource, const Sources extends readonly KeySource[]>(props: T, source1: S1, ...sources: Sources) => SplitPropsFunctionResult<T, S1, Sources>;
20228
20228
  type SplitPropsFunctionResult<T, S1 extends KeySource, Sources extends readonly KeySource[]> = [SourceResultWithStyling<T, S1>, ...BuildSourceResults<T, Sources, IsComponent<S1>, SourceKeys<S1>>];
20229
- interface ModalComponent<V$1, R extends ComponentResult> {
20230
- (props?: ComponentProps<V$1>): R;
20231
- class: (props?: ComponentProps<V$1>) => string;
20232
- style: (props?: ComponentProps<V$1>) => R["style"];
20233
- getVariants: GetVariants<V$1>;
20234
- keys: (keyof V$1 | keyof R)[];
20235
- variantKeys: (keyof V$1)[];
20236
- propKeys: (keyof V$1 | keyof R)[];
20229
+ interface ModalComponent<V, R extends ComponentResult> {
20230
+ (props?: ComponentProps<V>): R;
20231
+ class: (props?: ComponentProps<V>) => string;
20232
+ style: (props?: ComponentProps<V>) => R["style"];
20233
+ getVariants: GetVariants<V>;
20234
+ keys: (keyof V | keyof R)[];
20235
+ variantKeys: (keyof V)[];
20236
+ propKeys: (keyof V | keyof R)[];
20237
20237
  }
20238
- interface CVComponent<V$1 extends Variants = {}, CV$1 extends ComputedVariants = {}, E$1 extends AnyComponent[] = [], R extends ComponentResult = ComponentResult> extends ModalComponent<MergeVariants<V$1, CV$1, E$1>, R> {
20239
- jsx: ModalComponent<MergeVariants<V$1, CV$1, E$1>, JSXProps>;
20240
- html: ModalComponent<MergeVariants<V$1, CV$1, E$1>, HTMLProps>;
20241
- htmlObj: ModalComponent<MergeVariants<V$1, CV$1, E$1>, HTMLObjProps>;
20238
+ interface CVComponent<V extends Variants = {}, CV extends ComputedVariants = {}, E extends AnyComponent[] = [], R extends ComponentResult = ComponentResult> extends ModalComponent<MergeVariants<V, CV, E>, R> {
20239
+ jsx: ModalComponent<MergeVariants<V, CV, E>, JSXProps>;
20240
+ html: ModalComponent<MergeVariants<V, CV, E>, HTMLProps>;
20241
+ htmlObj: ModalComponent<MergeVariants<V, CV, E>, HTMLObjProps>;
20242
20242
  }
20243
20243
  type AnyComponent = CVComponent<any, any, any, any> | ModalComponent<any, any>;
20244
20244
  type MergeExtendedVariants<T> = T extends readonly [infer First, ...infer Rest] ? ExtractVariants<First> & MergeExtendedVariants<Rest> : {};
20245
20245
  type MergeExtendedComputedVariants<T> = T extends readonly [infer First, ...infer Rest] ? ExtractComputedVariants<First> & MergeExtendedComputedVariants<Rest> : {};
20246
20246
  type ExtractVariants<T> = T extends CVComponent<infer V, any, infer E, any> ? V & MergeExtendedVariants<E> : {};
20247
20247
  type ExtractComputedVariants<T> = T extends CVComponent<any, infer CV, infer E, any> ? CV & Omit<MergeExtendedComputedVariants<E>, keyof CV> : {};
20248
- type MergeVariants<V$1, CV$1, E$1 extends AnyComponent[]> = NoInfer<CV$1> & Omit<NoInfer<V$1>, keyof CV$1> & Omit<MergeExtendedVariants<E$1>, keyof CV$1> & Omit<MergeExtendedComputedVariants<E$1>, keyof CV$1>;
20248
+ type MergeVariants<V, CV, E extends AnyComponent[]> = NoInfer<CV> & Omit<NoInfer<V>, keyof CV> & Omit<MergeExtendedVariants<E>, keyof CV> & Omit<MergeExtendedComputedVariants<E>, keyof CV>;
20249
20249
  type StringToBoolean<T> = T extends "true" | "false" ? boolean : T;
20250
20250
  type VariantValue = ClassValue | StyleClassValue;
20251
20251
  type ExtractVariantValue<T> = T extends ((value: infer V) => any) ? V : T extends ClassValue ? boolean : T extends Record<infer K, any> ? StringToBoolean<K> : never;
20252
- type VariantValues<V$1> = { [K in keyof V$1]?: ExtractVariantValue<V$1[K]> };
20252
+ type VariantValues<V> = { [K in keyof V]?: ExtractVariantValue<V[K]> };
20253
20253
  type StyleValue = Properties & {
20254
20254
  [key: `--${string}`]: string;
20255
20255
  };
20256
20256
  type StyleClassValue = StyleValue & {
20257
20257
  class?: ClassValue;
20258
20258
  };
20259
- interface ComputedContext<V$1> {
20260
- variants: VariantValues<V$1>;
20261
- setVariants: (variants: VariantValues<V$1>) => void;
20262
- setDefaultVariants: (variants: VariantValues<V$1>) => void;
20259
+ interface ComputedContext<V> {
20260
+ variants: VariantValues<V>;
20261
+ setVariants: (variants: VariantValues<V>) => void;
20262
+ setDefaultVariants: (variants: VariantValues<V>) => void;
20263
20263
  }
20264
- type Computed<V$1> = (context: ComputedContext<V$1>) => VariantValue;
20264
+ type Computed<V> = (context: ComputedContext<V>) => VariantValue;
20265
20265
  type ComputedVariant = (value: any) => VariantValue;
20266
20266
  type ComputedVariants = Record<string, ComputedVariant>;
20267
20267
  type Variant = ClassValue | Record<string, VariantValue>;
20268
20268
  type Variants = Record<string, Variant>;
20269
- type ExtendedVariants<E$1 extends AnyComponent[]> = MergeExtendedVariants<E$1> & MergeExtendedComputedVariants<E$1>;
20270
- type ExtendableVariants<V$1 extends Variants, E$1 extends AnyComponent[]> = V$1 & { [K in keyof ExtendedVariants<E$1>]?: Partial<ExtendedVariants<E$1>[K]> | Variant };
20269
+ type ExtendedVariants<E extends AnyComponent[]> = MergeExtendedVariants<E> & MergeExtendedComputedVariants<E>;
20270
+ type ExtendableVariants<V extends Variants, E extends AnyComponent[]> = V & { [K in keyof ExtendedVariants<E>]?: Partial<ExtendedVariants<E>[K]> | Variant };
20271
20271
  //#endregion
20272
20272
  //#region src/utils.d.ts
20273
20273
  declare const MODES: readonly ["jsx", "html", "htmlObj"];
@@ -20275,14 +20275,14 @@ type Mode = (typeof MODES)[number];
20275
20275
  //#endregion
20276
20276
  //#region src/index.d.ts
20277
20277
  type VariantProps<T extends Pick<AnyComponent, "getVariants">> = ReturnType<T["getVariants"]>;
20278
- interface CVConfig<V$1 extends Variants = {}, CV$1 extends ComputedVariants = {}, E$1 extends AnyComponent[] = []> {
20279
- extend?: E$1;
20278
+ interface CVConfig<V extends Variants = {}, CV extends ComputedVariants = {}, E extends AnyComponent[] = []> {
20279
+ extend?: E;
20280
20280
  class?: ClassValue;
20281
20281
  style?: StyleValue;
20282
- variants?: ExtendableVariants<V$1, E$1>;
20283
- computedVariants?: CV$1;
20284
- defaultVariants?: VariantValues<MergeVariants<V$1, CV$1, E$1>>;
20285
- computed?: Computed<MergeVariants<V$1, CV$1, E$1>>;
20282
+ variants?: ExtendableVariants<V, E>;
20283
+ computedVariants?: CV;
20284
+ defaultVariants?: VariantValues<MergeVariants<V, CV, E>>;
20285
+ computed?: Computed<MergeVariants<V, CV, E>>;
20286
20286
  }
20287
20287
  interface CreateParams<M extends Mode> {
20288
20288
  defaultMode?: M;
@@ -20314,10 +20314,10 @@ declare function create<M extends Mode = "jsx">({
20314
20314
  defaultMode,
20315
20315
  transformClass
20316
20316
  }?: CreateParams<M>): {
20317
- cv: <V$1 extends Variants = {}, CV$1 extends ComputedVariants = {}, const E$1 extends AnyComponent[] = []>(config?: CVConfig<V$1, CV$1, E$1>) => CVComponent<V$1, CV$1, E$1, StyleProps[M]>;
20317
+ cv: <V extends Variants = {}, CV extends ComputedVariants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, CV, E>) => CVComponent<V, CV, E, StyleProps[M]>;
20318
20318
  cx: (...classes: ClassValue$1[]) => string;
20319
20319
  };
20320
- declare const cv: <V$1 extends Variants = {}, CV$1 extends ComputedVariants = {}, const E$1 extends AnyComponent[] = []>(config?: CVConfig<V$1, CV$1, E$1>) => CVComponent<V$1, CV$1, E$1, JSXProps>, cx: (...classes: ClassValue$1[]) => string;
20320
+ declare const cv: <V extends Variants = {}, CV extends ComputedVariants = {}, const E extends AnyComponent[] = []>(config?: CVConfig<V, CV, E>) => CVComponent<V, CV, E, JSXProps>, cx: (...classes: ClassValue$1[]) => string;
20321
20321
  //#endregion
20322
20322
  export { type CVComponent, CVConfig, type ClassValue, type HTMLObjProps, type HTMLProps, type JSXProps, type StyleClassValue, type StyleValue, VariantProps, create, cv, cx, splitProps };
20323
20323
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -254,11 +254,10 @@ function collectStaticDefaults(config) {
254
254
  function collectDefaultVariants(config, propsVariants = {}) {
255
255
  const defaults = collectStaticDefaults(config);
256
256
  if (!config.extend) return defaults;
257
- const childStaticDefaults = config.defaultVariants || {};
258
257
  for (const ext of config.extend) {
259
258
  const meta = getComponentMeta(ext);
260
259
  if (!meta) continue;
261
- Object.assign(defaults, meta.resolveDefaults(childStaticDefaults, propsVariants));
260
+ Object.assign(defaults, meta.resolveDefaults(defaults, propsVariants));
262
261
  }
263
262
  return defaults;
264
263
  }
@@ -513,8 +512,8 @@ function createResolveDefaults(config) {
513
512
  * Creates the cv and cx functions.
514
513
  */
515
514
  function create({ defaultMode = "jsx", transformClass = (className) => className } = {}) {
516
- const cx$1 = (...classes) => transformClass(clsx_default(...classes));
517
- const cv$1 = (config = {}) => {
515
+ const cx = (...classes) => transformClass(clsx_default(...classes));
516
+ const cv = (config = {}) => {
518
517
  const variantKeys = collectVariantKeys(config);
519
518
  const getPropsKeys = (mode) => [
520
519
  getClassPropertyName(mode),
@@ -547,13 +546,13 @@ function create({ defaultMode = "jsx", transformClass = (className) => className
547
546
  if ("className" in props) allClasses.push(props.className);
548
547
  if (props.style != null) assign(allStyle, normalizeStyle(props.style));
549
548
  return {
550
- className: cx$1(...allClasses),
549
+ className: cx(...allClasses),
551
550
  style: allStyle
552
551
  };
553
552
  };
554
553
  const createModalComponent = (mode) => {
555
554
  const propsKeys = getPropsKeys(mode);
556
- const component$1 = ((props = {}) => {
555
+ const component = ((props = {}) => {
557
556
  const { className, style } = computeResult(props);
558
557
  if (mode === "jsx") return {
559
558
  className,
@@ -568,32 +567,32 @@ function create({ defaultMode = "jsx", transformClass = (className) => className
568
567
  style: styleValueToHTMLObjStyle(style)
569
568
  };
570
569
  });
571
- component$1.class = (props = {}) => {
570
+ component.class = (props = {}) => {
572
571
  return computeResult(props).className;
573
572
  };
574
- component$1.style = ((props = {}) => {
573
+ component.style = ((props = {}) => {
575
574
  const { style } = computeResult(props);
576
575
  if (mode === "jsx") return styleValueToJSXStyle(style);
577
576
  if (mode === "html") return styleValueToHTMLStyle(style);
578
577
  return styleValueToHTMLObjStyle(style);
579
578
  });
580
- component$1.getVariants = (variants) => {
579
+ component.getVariants = (variants) => {
581
580
  return resolveVariants(config, variants);
582
581
  };
583
- component$1.keys = propsKeys;
584
- component$1.variantKeys = variantKeys;
585
- component$1.propKeys = propsKeys;
582
+ component.keys = propsKeys;
583
+ component.variantKeys = variantKeys;
584
+ component.propKeys = propsKeys;
586
585
  const extendedBaseClasses = [];
587
586
  if (config.extend) for (const ext of config.extend) {
588
587
  const meta = getComponentMeta(ext);
589
588
  extendedBaseClasses.push(meta?.baseClass ?? "");
590
589
  }
591
- setComponentMeta(component$1, {
592
- baseClass: cx$1(...extendedBaseClasses, config.class),
590
+ setComponentMeta(component, {
591
+ baseClass: cx(...extendedBaseClasses, config.class),
593
592
  staticDefaults: collectStaticDefaults(config),
594
593
  resolveDefaults: createResolveDefaults(config)
595
594
  });
596
- return component$1;
595
+ return component;
597
596
  };
598
597
  const defaultComponent = createModalComponent(defaultMode);
599
598
  const jsxComponent = createModalComponent("jsx");
@@ -606,8 +605,8 @@ function create({ defaultMode = "jsx", transformClass = (className) => className
606
605
  return component;
607
606
  };
608
607
  return {
609
- cv: cv$1,
610
- cx: cx$1
608
+ cv,
609
+ cx
611
610
  };
612
611
  }
613
612
  const { cv, cx } = create();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["cx","clsx","cv","component"],"sources":["../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../src/utils.ts","../src/index.ts"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import type * as CSS from \"csstype\";\nimport type {\n HTMLCSSProperties,\n JSXCSSProperties,\n StyleValue,\n} from \"./types.ts\";\n\nexport const MODES = [\"jsx\", \"html\", \"htmlObj\"] as const;\nexport type Mode = (typeof MODES)[number];\n\n/**\n * Returns the appropriate class property name based on the mode.\n * @example\n * getClassPropertyName(\"jsx\") // \"className\"\n * getClassPropertyName(\"html\") // \"class\"\n */\nexport function getClassPropertyName(mode: Mode) {\n return mode === \"jsx\" ? \"className\" : \"class\";\n}\n\n/**\n * Converts a hyphenated CSS property name to camelCase.\n * @example\n * hyphenToCamel(\"background-color\") // \"backgroundColor\"\n * hyphenToCamel(\"--custom-var\") // \"--custom-var\" (CSS variables are preserved)\n */\nexport function hyphenToCamel(str: string) {\n // CSS custom properties (variables) should not be converted\n if (str.startsWith(\"--\")) {\n return str;\n }\n return str.replace(/-([a-z])/gi, (_, letter) => letter.toUpperCase());\n}\n\n/**\n * Converts a camelCase CSS property name to hyphenated form.\n * @example\n * camelToHyphen(\"backgroundColor\") // \"background-color\"\n * camelToHyphen(\"--customVar\") // \"--customVar\" (CSS variables are preserved)\n */\nexport function camelToHyphen(str: string) {\n // CSS custom properties (variables) should not be converted\n if (str.startsWith(\"--\")) {\n return str;\n }\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Parses a length value, adding \"px\" if it's a number.\n * @example\n * parseLengthValue(16); // \"16px\"\n * parseLengthValue(\"2em\"); // \"2em\"\n */\nexport function parseLengthValue(value: string | number) {\n if (typeof value === \"string\") return value;\n return `${value}px`;\n}\n\n/**\n * Parses a CSS style string into a StyleValue object.\n * @example\n * htmlStyleToStyleValue(\"background-color: red; font-size: 16px;\");\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlStyleToStyleValue(styleString: string) {\n if (!styleString) return {};\n\n const result: StyleValue = {};\n const declarations = styleString.split(\";\");\n\n for (const declaration of declarations) {\n const trimmed = declaration.trim();\n if (!trimmed) continue;\n\n const colonIndex = trimmed.indexOf(\":\");\n if (colonIndex === -1) continue;\n\n const property = trimmed.slice(0, colonIndex).trim();\n const value = trimmed.slice(colonIndex + 1).trim();\n if (!property) continue;\n if (!value) continue;\n\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[hyphenToCamel(property)] = value;\n }\n\n return result;\n}\n\n/**\n * Converts a hyphenated style object to a camelCase StyleValue object.\n * @example\n * htmlObjStyleToStyleValue({ \"background-color\": \"red\", \"font-size\": \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlObjStyleToStyleValue(style: HTMLCSSProperties) {\n const result: StyleValue = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[hyphenToCamel(key)] =\n parseLengthValue(value);\n }\n return result;\n}\n\n/**\n * Converts a camelCase style object to a StyleValue object.\n * @example\n * jsxStyleToStyleValue({ backgroundColor: \"red\", fontSize: 16 });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function jsxStyleToStyleValue(style: JSXCSSProperties) {\n const result: StyleValue = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[key] = parseLengthValue(value);\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a CSS style string.\n * @example\n * styleValueToHTMLStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // \"background-color: red; font-size: 16px;\"\n */\nexport function styleValueToHTMLStyle(style: StyleValue): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n parts.push(`${camelToHyphen(key)}: ${value}`);\n }\n if (!parts.length) return \"\";\n return `${parts.join(\"; \")};`;\n}\n\n/**\n * Converts a StyleValue object to a hyphenated style object.\n * @example\n * styleValueToHTMLObjStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { \"background-color\": \"red\", \"font-size\": \"16px\" }\n */\nexport function styleValueToHTMLObjStyle(style: StyleValue) {\n const result: CSS.PropertiesHyphen = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n const property = camelToHyphen(key) as keyof HTMLCSSProperties;\n result[property] = value;\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a camelCase style object.\n * @example\n * styleValueToJSXStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function styleValueToJSXStyle(style: StyleValue) {\n return style as JSXCSSProperties;\n}\n\n/**\n * Type guard to check if a style object has hyphenated keys.\n * @example\n * isHTMLObjStyle({ \"background-color\": \"red\" }); // true\n * isHTMLObjStyle({ backgroundColor: \"red\" }); // false\n */\nexport function isHTMLObjStyle(\n style: CSS.Properties<any> | CSS.PropertiesHyphen<any>,\n): style is CSS.PropertiesHyphen {\n return Object.keys(style).some(\n (key) => key.includes(\"-\") && !key.startsWith(\"--\"),\n );\n}\n","import clsx, { type ClassValue as ClsxClassValue } from \"clsx\";\nimport type {\n AnyComponent,\n CVComponent,\n ClassValue,\n ComponentProps,\n ComponentResult,\n Computed,\n ComputedVariants,\n ExtendableVariants,\n HTMLObjProps,\n HTMLProps,\n JSXProps,\n MergeVariants,\n ModalComponent,\n SplitPropsFunction,\n StyleClassValue,\n StyleProps,\n StyleValue,\n VariantValues,\n Variants,\n} from \"./types.ts\";\nimport {\n type Mode,\n getClassPropertyName,\n htmlObjStyleToStyleValue,\n htmlStyleToStyleValue,\n isHTMLObjStyle,\n jsxStyleToStyleValue,\n styleValueToHTMLObjStyle,\n styleValueToHTMLStyle,\n styleValueToJSXStyle,\n} from \"./utils.ts\";\n\n// Internal metadata stored on components but hidden from public types\ninterface ComponentMeta {\n baseClass: string;\n staticDefaults: Record<string, unknown>;\n resolveDefaults: (\n childDefaults: Record<string, unknown>,\n userProps?: Record<string, unknown>,\n ) => Record<string, unknown>;\n}\n\nconst META_KEY = \"__meta\";\n\n// Symbol property used to pass skip keys through the props object without\n// polluting the actual variant values. This allows the computed function to\n// see actual variant values while still skipping styling for overridden keys.\nconst SKIP_STYLE_KEYS = Symbol(\"skipStyleKeys\");\n\n// Dynamic property access on function requires cast through unknown\nfunction getComponentMeta(component: AnyComponent): ComponentMeta | undefined {\n return (component as unknown as Record<string, unknown>)[META_KEY] as\n | ComponentMeta\n | undefined;\n}\n\nfunction setComponentMeta(component: AnyComponent, meta: ComponentMeta): void {\n (component as unknown as Record<string, unknown>)[META_KEY] = meta;\n}\n\n/**\n * Mutates target by assigning all properties from source. Avoids object spread\n * overhead in hot paths where we're building up a result object.\n */\nfunction assign<T extends object>(target: T, source: T): void {\n for (const key of Object.keys(source)) {\n (target as Record<string, unknown>)[key] = (\n source as Record<string, unknown>\n )[key];\n }\n}\n\nexport type {\n ClassValue,\n StyleValue,\n StyleClassValue,\n JSXProps,\n HTMLProps,\n HTMLObjProps,\n CVComponent,\n};\n\nexport type VariantProps<T extends Pick<AnyComponent, \"getVariants\">> =\n ReturnType<T[\"getVariants\"]>;\n\nexport interface CVConfig<\n V extends Variants = {},\n CV extends ComputedVariants = {},\n E extends AnyComponent[] = [],\n> {\n extend?: E;\n class?: ClassValue;\n style?: StyleValue;\n variants?: ExtendableVariants<V, E>;\n computedVariants?: CV;\n defaultVariants?: VariantValues<MergeVariants<V, CV, E>>;\n computed?: Computed<MergeVariants<V, CV, E>>;\n}\n\ninterface CreateParams<M extends Mode> {\n defaultMode?: M;\n transformClass?: (className: string) => string;\n}\n\n/**\n * Checks if a value is a style-class object (has style properties, not just a\n * class value).\n */\nfunction isStyleClassValue(value: unknown): value is StyleClassValue {\n if (typeof value !== \"object\") return false;\n if (value == null) return false;\n if (Array.isArray(value)) return false;\n return true;\n}\n\n/**\n * Converts any style input (string, JSX object, or HTML object) to a normalized\n * StyleValue.\n */\nfunction normalizeStyle(style: unknown): StyleValue {\n if (typeof style === \"string\") {\n return htmlStyleToStyleValue(style);\n }\n if (typeof style === \"object\" && style != null) {\n if (isHTMLObjStyle(style as Record<string, unknown>)) {\n return htmlObjStyleToStyleValue(style as Record<string, string | number>);\n }\n return jsxStyleToStyleValue(style as Record<string, string | number>);\n }\n return {};\n}\n\n/**\n * Extracts class and style from a style-class value object.\n */\nfunction extractStyleClass(value: StyleClassValue): {\n class: ClassValue;\n style: StyleValue;\n} {\n const { class: cls, ...style } = value;\n return { class: cls, style };\n}\n\n/**\n * Extracts class and style from a variant value (either a class value or a\n * style-class object).\n */\nfunction extractClassAndStyle(value: unknown): {\n class: ClassValue;\n style: StyleValue;\n} {\n if (isStyleClassValue(value)) {\n return extractStyleClass(value);\n }\n return { class: value as ClassValue, style: {} };\n}\n\n/**\n * Gets all variant keys from a component's config, including extended\n * components.\n */\nfunction collectVariantKeys(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): string[] {\n const keys = new Set<string>();\n\n // Collect from extended components\n if (config.extend) {\n for (const ext of config.extend) {\n for (const key of ext.variantKeys) {\n keys.add(key as string);\n }\n }\n }\n\n // Collect from variants\n if (config.variants) {\n for (const key of Object.keys(config.variants)) {\n keys.add(key);\n }\n }\n\n // Collect from computedVariants\n if (config.computedVariants) {\n for (const key of Object.keys(config.computedVariants)) {\n keys.add(key);\n }\n }\n\n return Array.from(keys);\n}\n\n/**\n * Collects static default variants from extended components and the current\n * config. Also handles implicit boolean defaults (when only `false` key\n * exists). This does NOT trigger computed functions - use collectDefaultVariants\n * for that.\n */\nfunction collectStaticDefaults(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): Record<string, unknown> {\n const defaults: Record<string, unknown> = {};\n\n // Collect static defaults from extended components (via metadata to avoid\n // triggering computed functions)\n if (config.extend) {\n for (const ext of config.extend) {\n const meta = getComponentMeta(ext);\n if (meta) {\n Object.assign(defaults, meta.staticDefaults);\n }\n }\n }\n\n // Handle implicit boolean defaults from variants\n // If a variant has a `false` key, default to false when no value is provided\n if (config.variants) {\n for (const [variantName, variantDef] of Object.entries(config.variants)) {\n if (!isStyleClassValue(variantDef)) continue;\n const keys = Object.keys(variantDef);\n const hasFalse = keys.includes(\"false\");\n if (hasFalse && !defaults[variantName]) {\n defaults[variantName] = false;\n }\n }\n }\n\n // Override with current config's static defaults\n if (config.defaultVariants) {\n Object.assign(defaults, config.defaultVariants);\n }\n\n return defaults;\n}\n\n/**\n * Collects default variants from extended components and the current config.\n * This includes both static defaults and computed defaults (from\n * setDefaultVariants in extended components' computed functions). Priority:\n * parent static < child static < parent computed < child computed.\n */\nfunction collectDefaultVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n propsVariants: Record<string, unknown> = {},\n): Record<string, unknown> {\n // Start with static defaults (parent static < child static)\n const defaults = collectStaticDefaults(config);\n\n // Apply computed defaults from extended components\n // Parent's setDefaultVariants should override child's static defaults\n if (!config.extend) return defaults;\n\n const childStaticDefaults = config.defaultVariants || {};\n for (const ext of config.extend) {\n const meta = getComponentMeta(ext);\n if (!meta) continue;\n Object.assign(\n defaults,\n meta.resolveDefaults(childStaticDefaults, propsVariants),\n );\n }\n\n return defaults;\n}\n\n/**\n * Filters out keys with undefined values from an object.\n */\nfunction filterUndefined(\n obj: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value === undefined) continue;\n result[key] = value;\n }\n return result;\n}\n\n/**\n * Resolves variant values by merging defaults with provided props. Props with\n * undefined values are filtered out so they don't override defaults.\n */\nfunction resolveVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n props: Record<string, unknown> = {},\n): Record<string, unknown> {\n const defaults = collectDefaultVariants(config, props);\n return { ...defaults, ...filterUndefined(props) };\n}\n\n/**\n * Gets the value for a single variant based on the variant definition and the\n * selected value.\n */\nfunction getVariantResult(\n variantDef: unknown,\n selectedValue: unknown,\n): { class: ClassValue; style: StyleValue } {\n // Shorthand variant: `disabled: \"disabled-class\"` means { true: \"...\" }\n if (!isStyleClassValue(variantDef)) {\n if (selectedValue === true) {\n return extractClassAndStyle(variantDef);\n }\n return { class: null, style: {} };\n }\n\n // Object variant: { sm: \"...\", lg: \"...\" }\n const key = String(selectedValue);\n const value = (variantDef as Record<string, unknown>)[key];\n if (value === undefined) return { class: null, style: {} };\n\n return extractClassAndStyle(value);\n}\n\n/**\n * Extracts classes from fullClass that are not in baseClass. Uses string\n * comparison optimization: if fullClass starts with baseClass, just take the\n * suffix.\n */\nfunction extractVariantClasses(fullClass: string, baseClass: string): string {\n if (!fullClass) return \"\";\n if (!baseClass) return fullClass;\n\n // Fast path: fullClass starts with baseClass (common case)\n if (fullClass.startsWith(baseClass)) {\n return fullClass.slice(baseClass.length).trim();\n }\n\n // Slow path: need to diff the class sets\n const baseClassSet = new Set(baseClass.split(\" \").filter(Boolean));\n return fullClass\n .split(\" \")\n .filter((c) => c && !baseClassSet.has(c))\n .join(\" \");\n}\n\nfunction computeExtendedStyles(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n overrideVariantKeys: Set<string> = new Set(),\n): {\n baseClasses: ClassValue[];\n variantClasses: ClassValue[];\n style: StyleValue;\n} {\n const baseClasses: ClassValue[] = [];\n const variantClasses: ClassValue[] = [];\n const style: StyleValue = {};\n\n if (!config.extend) return { baseClasses, variantClasses, style };\n\n for (const ext of config.extend) {\n // Pass actual variant values but mark which keys should skip styling.\n // Using a Symbol property keeps variant values clean for computed functions\n // while still allowing us to skip styling for overridden keys.\n const propsForExt: Record<string | symbol, unknown> = {\n ...resolvedVariants,\n };\n if (overrideVariantKeys.size > 0) {\n propsForExt[SKIP_STYLE_KEYS] = overrideVariantKeys;\n }\n\n const extResult = ext(propsForExt);\n assign(style, normalizeStyle(extResult.style));\n\n // Get base class from internal metadata (no variants)\n const meta = getComponentMeta(ext);\n const baseClass = meta?.baseClass ?? \"\";\n baseClasses.push(baseClass);\n\n // Get full class with variants\n const fullClass =\n \"className\" in extResult ? extResult.className : extResult.class;\n\n const variantPortion = extractVariantClasses(fullClass, baseClass);\n if (variantPortion) {\n variantClasses.push(variantPortion);\n }\n }\n\n return { baseClasses, variantClasses, style };\n}\n\n/**\n * Computes class and style from the component's own variants and\n * computedVariants (not extended components).\n */\nfunction computeVariantStyles(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string | symbol, unknown>,\n skipStyleKeys: Set<string> = new Set(),\n): { classes: ClassValue[]; style: StyleValue } {\n const classes: ClassValue[] = [];\n const style: StyleValue = {};\n\n // Process current component's variants\n if (config.variants) {\n for (const [variantName, variantDef] of Object.entries(config.variants)) {\n // Skip styling for variants that are overridden by child's computedVariants\n if (skipStyleKeys.has(variantName)) continue;\n\n const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n\n const result = getVariantResult(variantDef, selectedValue);\n classes.push(result.class);\n assign(style, result.style);\n }\n }\n\n // Process computedVariants\n if (config.computedVariants) {\n for (const [variantName, computeFn] of Object.entries(\n config.computedVariants,\n )) {\n // Skip styling for variants that are overridden by child's computedVariants\n if (skipStyleKeys.has(variantName)) continue;\n\n const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n\n const computedResult = computeFn(selectedValue);\n const result = extractClassAndStyle(computedResult);\n classes.push(result.class);\n assign(style, result.style);\n }\n }\n\n return { classes, style };\n}\n\n/**\n * Runs the computed function if present, returning classes, styles, and updated\n * variants.\n */\nfunction runComputedFunction(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n propsVariants: Record<string, unknown>,\n): {\n classes: ClassValue[];\n style: StyleValue;\n updatedVariants: Record<string, unknown>;\n} {\n const classes: ClassValue[] = [];\n const style: StyleValue = {};\n const updatedVariants = { ...resolvedVariants };\n\n if (!config.computed) {\n return { classes, style, updatedVariants };\n }\n\n const context = {\n variants: resolvedVariants,\n setVariants: (newVariants: VariantValues<Record<string, unknown>>) => {\n Object.assign(updatedVariants, newVariants);\n },\n setDefaultVariants: (\n newDefaults: VariantValues<Record<string, unknown>>,\n ) => {\n // Only apply defaults for variants not explicitly set in props\n for (const [key, value] of Object.entries(newDefaults)) {\n if (propsVariants[key] === undefined) {\n updatedVariants[key] = value;\n }\n }\n },\n };\n\n const computedResult = config.computed(context);\n if (computedResult != null) {\n const result = extractClassAndStyle(computedResult);\n classes.push(result.class);\n assign(style, result.style);\n }\n\n return { classes, style, updatedVariants };\n}\n\ninterface NormalizedSource {\n keys: string[];\n variantKeys: string[];\n defaults: Record<string, unknown>;\n isComponent: boolean;\n}\n\nconst EMPTY_SOURCE: NormalizedSource = {\n keys: [],\n variantKeys: [],\n defaults: {},\n isComponent: false,\n};\n\n/**\n * Normalizes a key source (array or component) to an object with keys,\n * variantKeys, defaults, and isComponent flag.\n */\nfunction normalizeKeySource(source: unknown): NormalizedSource {\n if (Array.isArray(source)) {\n return {\n keys: source as string[],\n variantKeys: source as string[],\n defaults: {},\n isComponent: false,\n };\n }\n\n if (!source) return EMPTY_SOURCE;\n if (typeof source !== \"object\" && typeof source !== \"function\") {\n return EMPTY_SOURCE;\n }\n if (!(\"keys\" in source)) return EMPTY_SOURCE;\n if (!(\"variantKeys\" in source)) return EMPTY_SOURCE;\n\n // Source is a component with keys and variantKeys properties\n const typed = source as {\n keys: string[];\n variantKeys: string[];\n getVariants?: () => Record<string, unknown>;\n };\n return {\n keys: [...typed.keys],\n variantKeys: [...typed.variantKeys],\n defaults: typed.getVariants?.() ?? {},\n isComponent: true,\n };\n}\n\n/**\n * Splits props into multiple groups based on key sources. Only the first\n * component claims styling props (class/className/style). Subsequent components\n * only receive variant props. Arrays always receive their listed keys but don't\n * claim styling props.\n */\nfunction splitPropsImpl(\n selfKeys: string[],\n selfIsComponent: boolean,\n props: Record<string, unknown>,\n sources: NormalizedSource[],\n): Record<string, unknown>[] {\n const allUsedKeys = new Set<string>(selfKeys);\n const results: Record<string, unknown>[] = [];\n\n // Track if styling has been claimed by a component\n let stylingClaimed = selfIsComponent;\n\n // Self result\n const selfResult: Record<string, unknown> = {};\n for (const key of selfKeys) {\n if (key in props) {\n selfResult[key] = props[key];\n }\n }\n results.push(selfResult);\n\n // Process each source\n for (const source of sources) {\n const sourceResult: Record<string, unknown> = {};\n\n // Determine which keys this source should use\n // Components use variantKeys if styling has already been claimed\n // Arrays always use their listed keys\n const effectiveKeys =\n source.isComponent && stylingClaimed ? source.variantKeys : source.keys;\n\n for (const key of effectiveKeys) {\n allUsedKeys.add(key);\n if (key in props) {\n sourceResult[key] = props[key];\n }\n }\n results.push(sourceResult);\n\n // If this is a component that hasn't claimed styling yet, mark styling as claimed\n if (source.isComponent && !stylingClaimed) {\n stylingClaimed = true;\n }\n }\n\n // Rest - keys not used by anyone\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (!allUsedKeys.has(key)) {\n rest[key] = value;\n }\n }\n results.push(rest);\n\n return results;\n}\n\n/**\n * Splits props into multiple groups based on key sources. Each source gets its\n * own result object containing all its matching keys. The first component\n * source claims styling props (class/className/style). Subsequent components\n * only receive variant props. Arrays receive their listed keys but don't claim\n * styling props. The last element is always the \"rest\" containing keys not\n * claimed by any source.\n * @example\n * ```ts\n * const [buttonProps, inputProps, rest] = splitProps(\n * props,\n * buttonComponent,\n * inputComponent,\n * );\n * // buttonProps has class/style + button variants\n * // inputProps has only input variants (no class/style)\n * ```\n */\nexport const splitProps: SplitPropsFunction = ((\n props: Record<string, unknown>,\n source1: unknown,\n ...sources: unknown[]\n) => {\n const normalizedSource1 = normalizeKeySource(source1);\n const normalizedSources = sources.map(normalizeKeySource);\n return splitPropsImpl(\n normalizedSource1.keys,\n normalizedSource1.isComponent,\n props,\n normalizedSources,\n );\n}) as SplitPropsFunction;\n\n/**\n * Creates the resolveDefaults function for a component. This function returns\n * only the variants set via setDefaultVariants in the computed function. Used\n * by child components to get parent's computed defaults.\n */\nfunction createResolveDefaults(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): ComponentMeta[\"resolveDefaults\"] {\n return (childDefaults, userProps = {}) => {\n // Get static defaults (including from extended components)\n const staticDefaults = collectStaticDefaults(config);\n\n // Merge: parent static < child static < user props\n // This is what parent's computed will see in `variants`\n const resolvedVariants = {\n ...staticDefaults,\n ...filterUndefined(childDefaults),\n ...filterUndefined(userProps),\n };\n\n // Track which keys are set via setDefaultVariants\n const computedDefaults: Record<string, unknown> = {};\n\n // Propagate to extended components so their computed functions can run\n // This allows grandparent computed functions to see grandchild defaults\n if (config.extend) {\n for (const ext of config.extend) {\n const meta = getComponentMeta(ext);\n if (!meta) continue;\n Object.assign(\n computedDefaults,\n meta.resolveDefaults(childDefaults, userProps),\n );\n }\n }\n\n if (config.computed) {\n config.computed({\n variants: resolvedVariants as VariantValues<Record<string, unknown>>,\n setVariants: () => {\n // Not relevant for collecting defaults\n },\n setDefaultVariants: (newDefaults) => {\n // Only apply defaults for variants not explicitly set by user\n // (child's static defaults should not block setDefaultVariants)\n for (const [key, value] of Object.entries(newDefaults)) {\n if (userProps[key] === undefined) {\n computedDefaults[key] = value;\n }\n }\n },\n });\n }\n\n return computedDefaults;\n };\n}\n\n/**\n * Creates the cv and cx functions.\n */\nexport function create<M extends Mode = \"jsx\">({\n defaultMode = \"jsx\" as M,\n transformClass = (className) => className,\n}: CreateParams<M> = {}) {\n const cx = (...classes: ClsxClassValue[]) => transformClass(clsx(...classes));\n\n const cv = <\n V extends Variants = {},\n CV extends ComputedVariants = {},\n const E extends AnyComponent[] = [],\n >(\n config: CVConfig<V, CV, E> = {},\n ): CVComponent<V, CV, E, StyleProps[M]> => {\n type MergedVariants = MergeVariants<V, CV, E>;\n\n const variantKeys = collectVariantKeys(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n );\n\n const getPropsKeys = (mode: Mode) => [\n getClassPropertyName(mode),\n \"style\",\n ...variantKeys,\n ];\n\n const computeResult = (\n props: ComponentProps<MergedVariants> = {},\n ): { className: string; style: StyleValue } => {\n const allClasses: ClassValue[] = [];\n const allStyle: StyleValue = {};\n\n // Extract skip style keys from props (set by child's computedVariants)\n const skipStyleKeys =\n ((props as Record<symbol, unknown>)[SKIP_STYLE_KEYS] as\n | Set<string>\n | undefined) ?? new Set<string>();\n\n // Extract variant props from input\n const variantProps: Record<string, unknown> = {};\n for (const key of variantKeys) {\n if (key in props) {\n variantProps[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n // Resolve variants with defaults\n let resolvedVariants = resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variantProps,\n );\n\n // Process computed first to potentially update variants\n const computedResult = runComputedFunction(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n variantProps,\n );\n resolvedVariants = computedResult.updatedVariants;\n\n // Collect computedVariants keys that will override extended variants.\n // Combine with incoming skip keys to propagate through the extend chain.\n const computedVariantKeys = new Set<string>(skipStyleKeys);\n if (config.computedVariants) {\n for (const key of Object.keys(config.computedVariants)) {\n computedVariantKeys.add(key);\n }\n }\n\n // Process extended components (separates base and variant classes)\n const extendedResult = computeExtendedStyles(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n computedVariantKeys,\n );\n\n // 1. Extended base classes first\n allClasses.push(...extendedResult.baseClasses);\n assign(allStyle, extendedResult.style);\n\n // 2. Current component's base class\n allClasses.push(config.class);\n\n // 3. Add base style\n if (config.style) {\n assign(allStyle, config.style);\n }\n\n // 4. Extended variant classes\n allClasses.push(...extendedResult.variantClasses);\n\n // 5. Current component's variants (skip keys that are overridden)\n const variantsResult = computeVariantStyles(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n skipStyleKeys,\n );\n allClasses.push(...variantsResult.classes);\n assign(allStyle, variantsResult.style);\n\n // Add computed results\n allClasses.push(...computedResult.classes);\n assign(allStyle, computedResult.style);\n\n // Merge class from props\n if (\"class\" in props) {\n allClasses.push(props.class);\n }\n if (\"className\" in props) {\n allClasses.push(props.className);\n }\n\n // Merge style from props\n if (props.style != null) {\n assign(allStyle, normalizeStyle(props.style));\n }\n\n return {\n className: cx(...(allClasses as ClsxClassValue[])),\n style: allStyle,\n };\n };\n\n const createModalComponent = <R extends ComponentResult>(\n mode: Mode,\n ): ModalComponent<MergedVariants, R> => {\n const propsKeys = getPropsKeys(mode);\n\n const component = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n\n if (mode === \"jsx\") {\n return { className, style: styleValueToJSXStyle(style) } as R;\n }\n if (mode === \"html\") {\n return {\n class: className,\n style: styleValueToHTMLStyle(style),\n } as R;\n }\n // htmlObj\n return {\n class: className,\n style: styleValueToHTMLObjStyle(style),\n } as R;\n }) as ModalComponent<MergedVariants, R>;\n\n component.class = (props: ComponentProps<MergedVariants> = {}) => {\n return computeResult(props).className;\n };\n\n component.style = ((props: ComponentProps<MergedVariants> = {}) => {\n const { style } = computeResult(props);\n if (mode === \"jsx\") return styleValueToJSXStyle(style);\n if (mode === \"html\") return styleValueToHTMLStyle(style);\n return styleValueToHTMLObjStyle(style);\n }) as ModalComponent<MergedVariants, R>[\"style\"];\n\n component.getVariants = (\n variants?: VariantValues<MergedVariants>,\n ): VariantValues<MergedVariants> => {\n return resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variants as VariantValues<Record<string, unknown>>,\n ) as VariantValues<MergedVariants>;\n };\n\n component.keys = propsKeys as (keyof MergedVariants | keyof R)[];\n\n component.variantKeys = variantKeys as (keyof MergedVariants)[];\n\n component.propKeys = propsKeys as (keyof MergedVariants | keyof R)[];\n\n // Compute base class (without variants) - includes extended base classes\n const extendedBaseClasses: ClassValue[] = [];\n if (config.extend) {\n for (const ext of config.extend) {\n const meta = getComponentMeta(ext);\n extendedBaseClasses.push(meta?.baseClass ?? \"\");\n }\n }\n const baseClass = cx(\n ...(extendedBaseClasses as ClsxClassValue[]),\n config.class as ClsxClassValue,\n );\n\n // Compute static defaults once at creation time (without triggering\n // computed functions)\n const staticDefaults = collectStaticDefaults(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n );\n\n // Store internal metadata hidden from public types\n setComponentMeta(component, {\n baseClass,\n staticDefaults,\n resolveDefaults: createResolveDefaults(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n ),\n });\n\n return component;\n };\n\n // Create the default modal component\n const defaultComponent = createModalComponent<StyleProps[M]>(defaultMode);\n\n // Create all modal variants\n const jsxComponent = createModalComponent<JSXProps>(\"jsx\");\n const htmlComponent = createModalComponent<HTMLProps>(\"html\");\n const htmlObjComponent = createModalComponent<HTMLObjProps>(\"htmlObj\");\n\n // Build the final component\n const component = defaultComponent as CVComponent<V, CV, E, StyleProps[M]>;\n component.jsx = jsxComponent;\n component.html = htmlComponent;\n component.htmlObj = htmlObjComponent;\n\n return component;\n };\n\n return { cv, cx };\n}\n\nexport const { cv, cx } = create();\n"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;AAAG,KAAG,YAAU,OAAO,KAAG,YAAU,OAAO,EAAE,MAAG;UAAU,YAAU,OAAO,EAAE,KAAG,MAAM,QAAQ,EAAE,EAAC;EAAC,IAAI,IAAE,EAAE;AAAO,OAAI,IAAE,GAAE,IAAE,GAAE,IAAI,GAAE,OAAK,IAAE,EAAE,EAAE,GAAG,MAAI,MAAI,KAAG,MAAK,KAAG;OAAQ,MAAI,KAAK,EAAE,GAAE,OAAK,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,SAAgB,OAAM;AAAC,MAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,IAAI,EAAC,IAAE,UAAU,QAAM,IAAE,EAAE,EAAE,MAAI,MAAI,KAAG,MAAK,KAAG;AAAG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AAGxC,eAAU,eACR,aACkC;AAClC,WAAO,gBACL,QACA,SACD;;AAGH,eAAU,OAAO;AAEjB,eAAU,cAAc;AAExB,eAAU,WAAW;GAGrB,MAAM,sBAAoC,EAAE;AAC5C,OAAI,OAAO,OACT,MAAK,MAAM,OAAO,OAAO,QAAQ;IAC/B,MAAM,OAAO,iBAAiB,IAAI;AAClC,wBAAoB,KAAK,MAAM,aAAa,GAAG;;AAenD,oBAAiBA,aAAW;IAC1B,WAbgBH,KAChB,GAAI,qBACJ,OAAO,MACR;IAWC,gBAPqB,sBACrB,OACD;IAMC,iBAAiB,sBACf,OACD;IACF,CAAC;AAEF,UAAOG;;EAIT,MAAM,mBAAmB,qBAAoC,YAAY;EAGzE,MAAM,eAAe,qBAA+B,MAAM;EAC1D,MAAM,gBAAgB,qBAAgC,OAAO;EAC7D,MAAM,mBAAmB,qBAAmC,UAAU;EAGtE,MAAM,YAAY;AAClB,YAAU,MAAM;AAChB,YAAU,OAAO;AACjB,YAAU,UAAU;AAEpB,SAAO;;AAGT,QAAO;EAAE;EAAI;EAAI;;AAGnB,MAAa,EAAE,IAAI,OAAO,QAAQ"}
1
+ {"version":3,"file":"index.js","names":["clsx"],"sources":["../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../src/utils.ts","../src/index.ts"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import type * as CSS from \"csstype\";\nimport type {\n HTMLCSSProperties,\n JSXCSSProperties,\n StyleValue,\n} from \"./types.ts\";\n\nexport const MODES = [\"jsx\", \"html\", \"htmlObj\"] as const;\nexport type Mode = (typeof MODES)[number];\n\n/**\n * Returns the appropriate class property name based on the mode.\n * @example\n * getClassPropertyName(\"jsx\") // \"className\"\n * getClassPropertyName(\"html\") // \"class\"\n */\nexport function getClassPropertyName(mode: Mode) {\n return mode === \"jsx\" ? \"className\" : \"class\";\n}\n\n/**\n * Converts a hyphenated CSS property name to camelCase.\n * @example\n * hyphenToCamel(\"background-color\") // \"backgroundColor\"\n * hyphenToCamel(\"--custom-var\") // \"--custom-var\" (CSS variables are preserved)\n */\nexport function hyphenToCamel(str: string) {\n // CSS custom properties (variables) should not be converted\n if (str.startsWith(\"--\")) {\n return str;\n }\n return str.replace(/-([a-z])/gi, (_, letter) => letter.toUpperCase());\n}\n\n/**\n * Converts a camelCase CSS property name to hyphenated form.\n * @example\n * camelToHyphen(\"backgroundColor\") // \"background-color\"\n * camelToHyphen(\"--customVar\") // \"--customVar\" (CSS variables are preserved)\n */\nexport function camelToHyphen(str: string) {\n // CSS custom properties (variables) should not be converted\n if (str.startsWith(\"--\")) {\n return str;\n }\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Parses a length value, adding \"px\" if it's a number.\n * @example\n * parseLengthValue(16); // \"16px\"\n * parseLengthValue(\"2em\"); // \"2em\"\n */\nexport function parseLengthValue(value: string | number) {\n if (typeof value === \"string\") return value;\n return `${value}px`;\n}\n\n/**\n * Parses a CSS style string into a StyleValue object.\n * @example\n * htmlStyleToStyleValue(\"background-color: red; font-size: 16px;\");\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlStyleToStyleValue(styleString: string) {\n if (!styleString) return {};\n\n const result: StyleValue = {};\n const declarations = styleString.split(\";\");\n\n for (const declaration of declarations) {\n const trimmed = declaration.trim();\n if (!trimmed) continue;\n\n const colonIndex = trimmed.indexOf(\":\");\n if (colonIndex === -1) continue;\n\n const property = trimmed.slice(0, colonIndex).trim();\n const value = trimmed.slice(colonIndex + 1).trim();\n if (!property) continue;\n if (!value) continue;\n\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[hyphenToCamel(property)] = value;\n }\n\n return result;\n}\n\n/**\n * Converts a hyphenated style object to a camelCase StyleValue object.\n * @example\n * htmlObjStyleToStyleValue({ \"background-color\": \"red\", \"font-size\": \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlObjStyleToStyleValue(style: HTMLCSSProperties) {\n const result: StyleValue = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[hyphenToCamel(key)] =\n parseLengthValue(value);\n }\n return result;\n}\n\n/**\n * Converts a camelCase style object to a StyleValue object.\n * @example\n * jsxStyleToStyleValue({ backgroundColor: \"red\", fontSize: 16 });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function jsxStyleToStyleValue(style: JSXCSSProperties) {\n const result: StyleValue = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[key] = parseLengthValue(value);\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a CSS style string.\n * @example\n * styleValueToHTMLStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // \"background-color: red; font-size: 16px;\"\n */\nexport function styleValueToHTMLStyle(style: StyleValue): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n parts.push(`${camelToHyphen(key)}: ${value}`);\n }\n if (!parts.length) return \"\";\n return `${parts.join(\"; \")};`;\n}\n\n/**\n * Converts a StyleValue object to a hyphenated style object.\n * @example\n * styleValueToHTMLObjStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { \"background-color\": \"red\", \"font-size\": \"16px\" }\n */\nexport function styleValueToHTMLObjStyle(style: StyleValue) {\n const result: CSS.PropertiesHyphen = {};\n for (const [key, value] of Object.entries(style)) {\n if (value == null) continue;\n const property = camelToHyphen(key) as keyof HTMLCSSProperties;\n result[property] = value;\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a camelCase style object.\n * @example\n * styleValueToJSXStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function styleValueToJSXStyle(style: StyleValue) {\n return style as JSXCSSProperties;\n}\n\n/**\n * Type guard to check if a style object has hyphenated keys.\n * @example\n * isHTMLObjStyle({ \"background-color\": \"red\" }); // true\n * isHTMLObjStyle({ backgroundColor: \"red\" }); // false\n */\nexport function isHTMLObjStyle(\n style: CSS.Properties<any> | CSS.PropertiesHyphen<any>,\n): style is CSS.PropertiesHyphen {\n return Object.keys(style).some(\n (key) => key.includes(\"-\") && !key.startsWith(\"--\"),\n );\n}\n","import clsx, { type ClassValue as ClsxClassValue } from \"clsx\";\nimport type {\n AnyComponent,\n CVComponent,\n ClassValue,\n ComponentProps,\n ComponentResult,\n Computed,\n ComputedVariants,\n ExtendableVariants,\n HTMLObjProps,\n HTMLProps,\n JSXProps,\n MergeVariants,\n ModalComponent,\n SplitPropsFunction,\n StyleClassValue,\n StyleProps,\n StyleValue,\n VariantValues,\n Variants,\n} from \"./types.ts\";\nimport {\n type Mode,\n getClassPropertyName,\n htmlObjStyleToStyleValue,\n htmlStyleToStyleValue,\n isHTMLObjStyle,\n jsxStyleToStyleValue,\n styleValueToHTMLObjStyle,\n styleValueToHTMLStyle,\n styleValueToJSXStyle,\n} from \"./utils.ts\";\n\n// Internal metadata stored on components but hidden from public types\ninterface ComponentMeta {\n baseClass: string;\n staticDefaults: Record<string, unknown>;\n resolveDefaults: (\n childDefaults: Record<string, unknown>,\n userProps?: Record<string, unknown>,\n ) => Record<string, unknown>;\n}\n\nconst META_KEY = \"__meta\";\n\n// Symbol property used to pass skip keys through the props object without\n// polluting the actual variant values. This allows the computed function to\n// see actual variant values while still skipping styling for overridden keys.\nconst SKIP_STYLE_KEYS = Symbol(\"skipStyleKeys\");\n\n// Dynamic property access on function requires cast through unknown\nfunction getComponentMeta(component: AnyComponent): ComponentMeta | undefined {\n return (component as unknown as Record<string, unknown>)[META_KEY] as\n | ComponentMeta\n | undefined;\n}\n\nfunction setComponentMeta(component: AnyComponent, meta: ComponentMeta): void {\n (component as unknown as Record<string, unknown>)[META_KEY] = meta;\n}\n\n/**\n * Mutates target by assigning all properties from source. Avoids object spread\n * overhead in hot paths where we're building up a result object.\n */\nfunction assign<T extends object>(target: T, source: T): void {\n for (const key of Object.keys(source)) {\n (target as Record<string, unknown>)[key] = (\n source as Record<string, unknown>\n )[key];\n }\n}\n\nexport type {\n ClassValue,\n StyleValue,\n StyleClassValue,\n JSXProps,\n HTMLProps,\n HTMLObjProps,\n CVComponent,\n};\n\nexport type VariantProps<T extends Pick<AnyComponent, \"getVariants\">> =\n ReturnType<T[\"getVariants\"]>;\n\nexport interface CVConfig<\n V extends Variants = {},\n CV extends ComputedVariants = {},\n E extends AnyComponent[] = [],\n> {\n extend?: E;\n class?: ClassValue;\n style?: StyleValue;\n variants?: ExtendableVariants<V, E>;\n computedVariants?: CV;\n defaultVariants?: VariantValues<MergeVariants<V, CV, E>>;\n computed?: Computed<MergeVariants<V, CV, E>>;\n}\n\ninterface CreateParams<M extends Mode> {\n defaultMode?: M;\n transformClass?: (className: string) => string;\n}\n\n/**\n * Checks if a value is a style-class object (has style properties, not just a\n * class value).\n */\nfunction isStyleClassValue(value: unknown): value is StyleClassValue {\n if (typeof value !== \"object\") return false;\n if (value == null) return false;\n if (Array.isArray(value)) return false;\n return true;\n}\n\n/**\n * Converts any style input (string, JSX object, or HTML object) to a normalized\n * StyleValue.\n */\nfunction normalizeStyle(style: unknown): StyleValue {\n if (typeof style === \"string\") {\n return htmlStyleToStyleValue(style);\n }\n if (typeof style === \"object\" && style != null) {\n if (isHTMLObjStyle(style as Record<string, unknown>)) {\n return htmlObjStyleToStyleValue(style as Record<string, string | number>);\n }\n return jsxStyleToStyleValue(style as Record<string, string | number>);\n }\n return {};\n}\n\n/**\n * Extracts class and style from a style-class value object.\n */\nfunction extractStyleClass(value: StyleClassValue): {\n class: ClassValue;\n style: StyleValue;\n} {\n const { class: cls, ...style } = value;\n return { class: cls, style };\n}\n\n/**\n * Extracts class and style from a variant value (either a class value or a\n * style-class object).\n */\nfunction extractClassAndStyle(value: unknown): {\n class: ClassValue;\n style: StyleValue;\n} {\n if (isStyleClassValue(value)) {\n return extractStyleClass(value);\n }\n return { class: value as ClassValue, style: {} };\n}\n\n/**\n * Gets all variant keys from a component's config, including extended\n * components.\n */\nfunction collectVariantKeys(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): string[] {\n const keys = new Set<string>();\n\n // Collect from extended components\n if (config.extend) {\n for (const ext of config.extend) {\n for (const key of ext.variantKeys) {\n keys.add(key as string);\n }\n }\n }\n\n // Collect from variants\n if (config.variants) {\n for (const key of Object.keys(config.variants)) {\n keys.add(key);\n }\n }\n\n // Collect from computedVariants\n if (config.computedVariants) {\n for (const key of Object.keys(config.computedVariants)) {\n keys.add(key);\n }\n }\n\n return Array.from(keys);\n}\n\n/**\n * Collects static default variants from extended components and the current\n * config. Also handles implicit boolean defaults (when only `false` key\n * exists). This does NOT trigger computed functions - use collectDefaultVariants\n * for that.\n */\nfunction collectStaticDefaults(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): Record<string, unknown> {\n const defaults: Record<string, unknown> = {};\n\n // Collect static defaults from extended components (via metadata to avoid\n // triggering computed functions)\n if (config.extend) {\n for (const ext of config.extend) {\n const meta = getComponentMeta(ext);\n if (meta) {\n Object.assign(defaults, meta.staticDefaults);\n }\n }\n }\n\n // Handle implicit boolean defaults from variants\n // If a variant has a `false` key, default to false when no value is provided\n if (config.variants) {\n for (const [variantName, variantDef] of Object.entries(config.variants)) {\n if (!isStyleClassValue(variantDef)) continue;\n const keys = Object.keys(variantDef);\n const hasFalse = keys.includes(\"false\");\n if (hasFalse && !defaults[variantName]) {\n defaults[variantName] = false;\n }\n }\n }\n\n // Override with current config's static defaults\n if (config.defaultVariants) {\n Object.assign(defaults, config.defaultVariants);\n }\n\n return defaults;\n}\n\n/**\n * Collects default variants from extended components and the current config.\n * This includes both static defaults and computed defaults (from\n * setDefaultVariants in extended components' computed functions). Priority:\n * parent static < child static < parent computed < child computed.\n */\nfunction collectDefaultVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n propsVariants: Record<string, unknown> = {},\n): Record<string, unknown> {\n // Start with static defaults (parent static < child static)\n const defaults = collectStaticDefaults(config);\n\n // Apply computed defaults from extended components\n // Parent's setDefaultVariants should override child's static defaults\n if (!config.extend) return defaults;\n\n // Pass full static defaults (not just this config's defaultVariants)\n // so that intermediate components' defaults are visible to ancestors\n for (const ext of config.extend) {\n const meta = getComponentMeta(ext);\n if (!meta) continue;\n Object.assign(defaults, meta.resolveDefaults(defaults, propsVariants));\n }\n\n return defaults;\n}\n\n/**\n * Filters out keys with undefined values from an object.\n */\nfunction filterUndefined(\n obj: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value === undefined) continue;\n result[key] = value;\n }\n return result;\n}\n\n/**\n * Resolves variant values by merging defaults with provided props. Props with\n * undefined values are filtered out so they don't override defaults.\n */\nfunction resolveVariants(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n props: Record<string, unknown> = {},\n): Record<string, unknown> {\n const defaults = collectDefaultVariants(config, props);\n return { ...defaults, ...filterUndefined(props) };\n}\n\n/**\n * Gets the value for a single variant based on the variant definition and the\n * selected value.\n */\nfunction getVariantResult(\n variantDef: unknown,\n selectedValue: unknown,\n): { class: ClassValue; style: StyleValue } {\n // Shorthand variant: `disabled: \"disabled-class\"` means { true: \"...\" }\n if (!isStyleClassValue(variantDef)) {\n if (selectedValue === true) {\n return extractClassAndStyle(variantDef);\n }\n return { class: null, style: {} };\n }\n\n // Object variant: { sm: \"...\", lg: \"...\" }\n const key = String(selectedValue);\n const value = (variantDef as Record<string, unknown>)[key];\n if (value === undefined) return { class: null, style: {} };\n\n return extractClassAndStyle(value);\n}\n\n/**\n * Extracts classes from fullClass that are not in baseClass. Uses string\n * comparison optimization: if fullClass starts with baseClass, just take the\n * suffix.\n */\nfunction extractVariantClasses(fullClass: string, baseClass: string): string {\n if (!fullClass) return \"\";\n if (!baseClass) return fullClass;\n\n // Fast path: fullClass starts with baseClass (common case)\n if (fullClass.startsWith(baseClass)) {\n return fullClass.slice(baseClass.length).trim();\n }\n\n // Slow path: need to diff the class sets\n const baseClassSet = new Set(baseClass.split(\" \").filter(Boolean));\n return fullClass\n .split(\" \")\n .filter((c) => c && !baseClassSet.has(c))\n .join(\" \");\n}\n\nfunction computeExtendedStyles(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n overrideVariantKeys: Set<string> = new Set(),\n): {\n baseClasses: ClassValue[];\n variantClasses: ClassValue[];\n style: StyleValue;\n} {\n const baseClasses: ClassValue[] = [];\n const variantClasses: ClassValue[] = [];\n const style: StyleValue = {};\n\n if (!config.extend) return { baseClasses, variantClasses, style };\n\n for (const ext of config.extend) {\n // Pass actual variant values but mark which keys should skip styling.\n // Using a Symbol property keeps variant values clean for computed functions\n // while still allowing us to skip styling for overridden keys.\n const propsForExt: Record<string | symbol, unknown> = {\n ...resolvedVariants,\n };\n if (overrideVariantKeys.size > 0) {\n propsForExt[SKIP_STYLE_KEYS] = overrideVariantKeys;\n }\n\n const extResult = ext(propsForExt);\n assign(style, normalizeStyle(extResult.style));\n\n // Get base class from internal metadata (no variants)\n const meta = getComponentMeta(ext);\n const baseClass = meta?.baseClass ?? \"\";\n baseClasses.push(baseClass);\n\n // Get full class with variants\n const fullClass =\n \"className\" in extResult ? extResult.className : extResult.class;\n\n const variantPortion = extractVariantClasses(fullClass, baseClass);\n if (variantPortion) {\n variantClasses.push(variantPortion);\n }\n }\n\n return { baseClasses, variantClasses, style };\n}\n\n/**\n * Computes class and style from the component's own variants and\n * computedVariants (not extended components).\n */\nfunction computeVariantStyles(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string | symbol, unknown>,\n skipStyleKeys: Set<string> = new Set(),\n): { classes: ClassValue[]; style: StyleValue } {\n const classes: ClassValue[] = [];\n const style: StyleValue = {};\n\n // Process current component's variants\n if (config.variants) {\n for (const [variantName, variantDef] of Object.entries(config.variants)) {\n // Skip styling for variants that are overridden by child's computedVariants\n if (skipStyleKeys.has(variantName)) continue;\n\n const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n\n const result = getVariantResult(variantDef, selectedValue);\n classes.push(result.class);\n assign(style, result.style);\n }\n }\n\n // Process computedVariants\n if (config.computedVariants) {\n for (const [variantName, computeFn] of Object.entries(\n config.computedVariants,\n )) {\n // Skip styling for variants that are overridden by child's computedVariants\n if (skipStyleKeys.has(variantName)) continue;\n\n const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n\n const computedResult = computeFn(selectedValue);\n const result = extractClassAndStyle(computedResult);\n classes.push(result.class);\n assign(style, result.style);\n }\n }\n\n return { classes, style };\n}\n\n/**\n * Runs the computed function if present, returning classes, styles, and updated\n * variants.\n */\nfunction runComputedFunction(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants: Record<string, unknown>,\n propsVariants: Record<string, unknown>,\n): {\n classes: ClassValue[];\n style: StyleValue;\n updatedVariants: Record<string, unknown>;\n} {\n const classes: ClassValue[] = [];\n const style: StyleValue = {};\n const updatedVariants = { ...resolvedVariants };\n\n if (!config.computed) {\n return { classes, style, updatedVariants };\n }\n\n const context = {\n variants: resolvedVariants,\n setVariants: (newVariants: VariantValues<Record<string, unknown>>) => {\n Object.assign(updatedVariants, newVariants);\n },\n setDefaultVariants: (\n newDefaults: VariantValues<Record<string, unknown>>,\n ) => {\n // Only apply defaults for variants not explicitly set in props\n for (const [key, value] of Object.entries(newDefaults)) {\n if (propsVariants[key] === undefined) {\n updatedVariants[key] = value;\n }\n }\n },\n };\n\n const computedResult = config.computed(context);\n if (computedResult != null) {\n const result = extractClassAndStyle(computedResult);\n classes.push(result.class);\n assign(style, result.style);\n }\n\n return { classes, style, updatedVariants };\n}\n\ninterface NormalizedSource {\n keys: string[];\n variantKeys: string[];\n defaults: Record<string, unknown>;\n isComponent: boolean;\n}\n\nconst EMPTY_SOURCE: NormalizedSource = {\n keys: [],\n variantKeys: [],\n defaults: {},\n isComponent: false,\n};\n\n/**\n * Normalizes a key source (array or component) to an object with keys,\n * variantKeys, defaults, and isComponent flag.\n */\nfunction normalizeKeySource(source: unknown): NormalizedSource {\n if (Array.isArray(source)) {\n return {\n keys: source as string[],\n variantKeys: source as string[],\n defaults: {},\n isComponent: false,\n };\n }\n\n if (!source) return EMPTY_SOURCE;\n if (typeof source !== \"object\" && typeof source !== \"function\") {\n return EMPTY_SOURCE;\n }\n if (!(\"keys\" in source)) return EMPTY_SOURCE;\n if (!(\"variantKeys\" in source)) return EMPTY_SOURCE;\n\n // Source is a component with keys and variantKeys properties\n const typed = source as {\n keys: string[];\n variantKeys: string[];\n getVariants?: () => Record<string, unknown>;\n };\n return {\n keys: [...typed.keys],\n variantKeys: [...typed.variantKeys],\n defaults: typed.getVariants?.() ?? {},\n isComponent: true,\n };\n}\n\n/**\n * Splits props into multiple groups based on key sources. Only the first\n * component claims styling props (class/className/style). Subsequent components\n * only receive variant props. Arrays always receive their listed keys but don't\n * claim styling props.\n */\nfunction splitPropsImpl(\n selfKeys: string[],\n selfIsComponent: boolean,\n props: Record<string, unknown>,\n sources: NormalizedSource[],\n): Record<string, unknown>[] {\n const allUsedKeys = new Set<string>(selfKeys);\n const results: Record<string, unknown>[] = [];\n\n // Track if styling has been claimed by a component\n let stylingClaimed = selfIsComponent;\n\n // Self result\n const selfResult: Record<string, unknown> = {};\n for (const key of selfKeys) {\n if (key in props) {\n selfResult[key] = props[key];\n }\n }\n results.push(selfResult);\n\n // Process each source\n for (const source of sources) {\n const sourceResult: Record<string, unknown> = {};\n\n // Determine which keys this source should use\n // Components use variantKeys if styling has already been claimed\n // Arrays always use their listed keys\n const effectiveKeys =\n source.isComponent && stylingClaimed ? source.variantKeys : source.keys;\n\n for (const key of effectiveKeys) {\n allUsedKeys.add(key);\n if (key in props) {\n sourceResult[key] = props[key];\n }\n }\n results.push(sourceResult);\n\n // If this is a component that hasn't claimed styling yet, mark styling as claimed\n if (source.isComponent && !stylingClaimed) {\n stylingClaimed = true;\n }\n }\n\n // Rest - keys not used by anyone\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if (!allUsedKeys.has(key)) {\n rest[key] = value;\n }\n }\n results.push(rest);\n\n return results;\n}\n\n/**\n * Splits props into multiple groups based on key sources. Each source gets its\n * own result object containing all its matching keys. The first component\n * source claims styling props (class/className/style). Subsequent components\n * only receive variant props. Arrays receive their listed keys but don't claim\n * styling props. The last element is always the \"rest\" containing keys not\n * claimed by any source.\n * @example\n * ```ts\n * const [buttonProps, inputProps, rest] = splitProps(\n * props,\n * buttonComponent,\n * inputComponent,\n * );\n * // buttonProps has class/style + button variants\n * // inputProps has only input variants (no class/style)\n * ```\n */\nexport const splitProps: SplitPropsFunction = ((\n props: Record<string, unknown>,\n source1: unknown,\n ...sources: unknown[]\n) => {\n const normalizedSource1 = normalizeKeySource(source1);\n const normalizedSources = sources.map(normalizeKeySource);\n return splitPropsImpl(\n normalizedSource1.keys,\n normalizedSource1.isComponent,\n props,\n normalizedSources,\n );\n}) as SplitPropsFunction;\n\n/**\n * Creates the resolveDefaults function for a component. This function returns\n * only the variants set via setDefaultVariants in the computed function. Used\n * by child components to get parent's computed defaults.\n */\nfunction createResolveDefaults(\n config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n): ComponentMeta[\"resolveDefaults\"] {\n return (childDefaults, userProps = {}) => {\n // Get static defaults (including from extended components)\n const staticDefaults = collectStaticDefaults(config);\n\n // Merge: parent static < child static < user props\n // This is what parent's computed will see in `variants`\n const resolvedVariants = {\n ...staticDefaults,\n ...filterUndefined(childDefaults),\n ...filterUndefined(userProps),\n };\n\n // Track which keys are set via setDefaultVariants\n const computedDefaults: Record<string, unknown> = {};\n\n // Propagate to extended components so their computed functions can run\n // This allows grandparent computed functions to see grandchild defaults\n if (config.extend) {\n for (const ext of config.extend) {\n const meta = getComponentMeta(ext);\n if (!meta) continue;\n Object.assign(\n computedDefaults,\n meta.resolveDefaults(childDefaults, userProps),\n );\n }\n }\n\n if (config.computed) {\n config.computed({\n variants: resolvedVariants as VariantValues<Record<string, unknown>>,\n setVariants: () => {\n // Not relevant for collecting defaults\n },\n setDefaultVariants: (newDefaults) => {\n // Only apply defaults for variants not explicitly set by user\n // (child's static defaults should not block setDefaultVariants)\n for (const [key, value] of Object.entries(newDefaults)) {\n if (userProps[key] === undefined) {\n computedDefaults[key] = value;\n }\n }\n },\n });\n }\n\n return computedDefaults;\n };\n}\n\n/**\n * Creates the cv and cx functions.\n */\nexport function create<M extends Mode = \"jsx\">({\n defaultMode = \"jsx\" as M,\n transformClass = (className) => className,\n}: CreateParams<M> = {}) {\n const cx = (...classes: ClsxClassValue[]) => transformClass(clsx(...classes));\n\n const cv = <\n V extends Variants = {},\n CV extends ComputedVariants = {},\n const E extends AnyComponent[] = [],\n >(\n config: CVConfig<V, CV, E> = {},\n ): CVComponent<V, CV, E, StyleProps[M]> => {\n type MergedVariants = MergeVariants<V, CV, E>;\n\n const variantKeys = collectVariantKeys(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n );\n\n const getPropsKeys = (mode: Mode) => [\n getClassPropertyName(mode),\n \"style\",\n ...variantKeys,\n ];\n\n const computeResult = (\n props: ComponentProps<MergedVariants> = {},\n ): { className: string; style: StyleValue } => {\n const allClasses: ClassValue[] = [];\n const allStyle: StyleValue = {};\n\n // Extract skip style keys from props (set by child's computedVariants)\n const skipStyleKeys =\n ((props as Record<symbol, unknown>)[SKIP_STYLE_KEYS] as\n | Set<string>\n | undefined) ?? new Set<string>();\n\n // Extract variant props from input\n const variantProps: Record<string, unknown> = {};\n for (const key of variantKeys) {\n if (key in props) {\n variantProps[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n // Resolve variants with defaults\n let resolvedVariants = resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variantProps,\n );\n\n // Process computed first to potentially update variants\n const computedResult = runComputedFunction(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n variantProps,\n );\n resolvedVariants = computedResult.updatedVariants;\n\n // Collect computedVariants keys that will override extended variants.\n // Combine with incoming skip keys to propagate through the extend chain.\n const computedVariantKeys = new Set<string>(skipStyleKeys);\n if (config.computedVariants) {\n for (const key of Object.keys(config.computedVariants)) {\n computedVariantKeys.add(key);\n }\n }\n\n // Process extended components (separates base and variant classes)\n const extendedResult = computeExtendedStyles(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n computedVariantKeys,\n );\n\n // 1. Extended base classes first\n allClasses.push(...extendedResult.baseClasses);\n assign(allStyle, extendedResult.style);\n\n // 2. Current component's base class\n allClasses.push(config.class);\n\n // 3. Add base style\n if (config.style) {\n assign(allStyle, config.style);\n }\n\n // 4. Extended variant classes\n allClasses.push(...extendedResult.variantClasses);\n\n // 5. Current component's variants (skip keys that are overridden)\n const variantsResult = computeVariantStyles(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\n skipStyleKeys,\n );\n allClasses.push(...variantsResult.classes);\n assign(allStyle, variantsResult.style);\n\n // Add computed results\n allClasses.push(...computedResult.classes);\n assign(allStyle, computedResult.style);\n\n // Merge class from props\n if (\"class\" in props) {\n allClasses.push(props.class);\n }\n if (\"className\" in props) {\n allClasses.push(props.className);\n }\n\n // Merge style from props\n if (props.style != null) {\n assign(allStyle, normalizeStyle(props.style));\n }\n\n return {\n className: cx(...(allClasses as ClsxClassValue[])),\n style: allStyle,\n };\n };\n\n const createModalComponent = <R extends ComponentResult>(\n mode: Mode,\n ): ModalComponent<MergedVariants, R> => {\n const propsKeys = getPropsKeys(mode);\n\n const component = ((props: ComponentProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n\n if (mode === \"jsx\") {\n return { className, style: styleValueToJSXStyle(style) } as R;\n }\n if (mode === \"html\") {\n return {\n class: className,\n style: styleValueToHTMLStyle(style),\n } as R;\n }\n // htmlObj\n return {\n class: className,\n style: styleValueToHTMLObjStyle(style),\n } as R;\n }) as ModalComponent<MergedVariants, R>;\n\n component.class = (props: ComponentProps<MergedVariants> = {}) => {\n return computeResult(props).className;\n };\n\n component.style = ((props: ComponentProps<MergedVariants> = {}) => {\n const { style } = computeResult(props);\n if (mode === \"jsx\") return styleValueToJSXStyle(style);\n if (mode === \"html\") return styleValueToHTMLStyle(style);\n return styleValueToHTMLObjStyle(style);\n }) as ModalComponent<MergedVariants, R>[\"style\"];\n\n component.getVariants = (\n variants?: VariantValues<MergedVariants>,\n ): VariantValues<MergedVariants> => {\n return resolveVariants(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n variants as VariantValues<Record<string, unknown>>,\n ) as VariantValues<MergedVariants>;\n };\n\n component.keys = propsKeys as (keyof MergedVariants | keyof R)[];\n\n component.variantKeys = variantKeys as (keyof MergedVariants)[];\n\n component.propKeys = propsKeys as (keyof MergedVariants | keyof R)[];\n\n // Compute base class (without variants) - includes extended base classes\n const extendedBaseClasses: ClassValue[] = [];\n if (config.extend) {\n for (const ext of config.extend) {\n const meta = getComponentMeta(ext);\n extendedBaseClasses.push(meta?.baseClass ?? \"\");\n }\n }\n const baseClass = cx(\n ...(extendedBaseClasses as ClsxClassValue[]),\n config.class as ClsxClassValue,\n );\n\n // Compute static defaults once at creation time (without triggering\n // computed functions)\n const staticDefaults = collectStaticDefaults(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n );\n\n // Store internal metadata hidden from public types\n setComponentMeta(component, {\n baseClass,\n staticDefaults,\n resolveDefaults: createResolveDefaults(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n ),\n });\n\n return component;\n };\n\n // Create the default modal component\n const defaultComponent = createModalComponent<StyleProps[M]>(defaultMode);\n\n // Create all modal variants\n const jsxComponent = createModalComponent<JSXProps>(\"jsx\");\n const htmlComponent = createModalComponent<HTMLProps>(\"html\");\n const htmlObjComponent = createModalComponent<HTMLObjProps>(\"htmlObj\");\n\n // Build the final component\n const component = defaultComponent as CVComponent<V, CV, E, StyleProps[M]>;\n component.jsx = jsxComponent;\n component.html = htmlComponent;\n component.htmlObj = htmlObjComponent;\n\n return component;\n };\n\n return { cv, cx };\n}\n\nexport const { cv, cx } = create();\n"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;AAAG,KAAG,YAAU,OAAO,KAAG,YAAU,OAAO,EAAE,MAAG;UAAU,YAAU,OAAO,EAAE,KAAG,MAAM,QAAQ,EAAE,EAAC;EAAC,IAAI,IAAE,EAAE;AAAO,OAAI,IAAE,GAAE,IAAE,GAAE,IAAI,GAAE,OAAK,IAAE,EAAE,EAAE,GAAG,MAAI,MAAI,KAAG,MAAK,KAAG;OAAQ,MAAI,KAAK,EAAE,GAAE,OAAK,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,SAAgB,OAAM;AAAC,MAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,IAAI,EAAC,IAAE,UAAU,QAAM,IAAE,EAAE,EAAE,MAAI,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,mBAAe;;;;;;;;;;ACgB/X,SAAgB,qBAAqB,MAAY;AAC/C,QAAO,SAAS,QAAQ,cAAc;;;;;;;;AASxC,SAAgB,cAAc,KAAa;AAEzC,KAAI,IAAI,WAAW,KAAK,CACtB,QAAO;AAET,QAAO,IAAI,QAAQ,eAAe,GAAG,WAAW,OAAO,aAAa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oBAAiB,WAAW;IAC1B,WAbgB,GAChB,GAAI,qBACJ,OAAO,MACR;IAWC,gBAPqB,sBACrB,OACD;IAMC,iBAAiB,sBACf,OACD;IACF,CAAC;AAEF,UAAO;;EAIT,MAAM,mBAAmB,qBAAoC,YAAY;EAGzE,MAAM,eAAe,qBAA+B,MAAM;EAC1D,MAAM,gBAAgB,qBAAgC,OAAO;EAC7D,MAAM,mBAAmB,qBAAmC,UAAU;EAGtE,MAAM,YAAY;AAClB,YAAU,MAAM;AAChB,YAAU,OAAO;AACjB,YAAU,UAAU;AAEpB,SAAO;;AAGT,QAAO;EAAE;EAAI;EAAI;;AAGnB,MAAa,EAAE,IAAI,OAAO,QAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clava",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Clava library",
5
5
  "keywords": [
6
6
  "class variance",
package/src/index.ts CHANGED
@@ -252,14 +252,12 @@ function collectDefaultVariants(
252
252
  // Parent's setDefaultVariants should override child's static defaults
253
253
  if (!config.extend) return defaults;
254
254
 
255
- const childStaticDefaults = config.defaultVariants || {};
255
+ // Pass full static defaults (not just this config's defaultVariants)
256
+ // so that intermediate components' defaults are visible to ancestors
256
257
  for (const ext of config.extend) {
257
258
  const meta = getComponentMeta(ext);
258
259
  if (!meta) continue;
259
- Object.assign(
260
- defaults,
261
- meta.resolveDefaults(childStaticDefaults, propsVariants),
262
- );
260
+ Object.assign(defaults, meta.resolveDefaults(defaults, propsVariants));
263
261
  }
264
262
 
265
263
  return defaults;
package/src/test.ts CHANGED
@@ -1262,6 +1262,21 @@ for (const config of Object.values(CONFIGS)) {
1262
1262
  expect(getStyleClass(props)).toEqual({ class: cls("lg red") });
1263
1263
  });
1264
1264
 
1265
+ test("computed receives default variants from intermediate component", () => {
1266
+ const parent = cv({
1267
+ variants: { size: { sm: "sm", lg: "lg" } },
1268
+ computed: ({ variants, setDefaultVariants }) => {
1269
+ if (!variants.size) {
1270
+ setDefaultVariants({ size: "lg" });
1271
+ }
1272
+ },
1273
+ });
1274
+ const child = cv({ extend: [parent], defaultVariants: { size: "sm" } });
1275
+ const component = getModalComponent(mode, cv({ extend: [child] }));
1276
+ const props = component();
1277
+ expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1278
+ });
1279
+
1265
1280
  test("child computed setDefaultVariants overrides parent computed setDefaultVariants", () => {
1266
1281
  const base = cv({
1267
1282
  variants: { size: { sm: "sm", lg: "lg" } },