clava 0.1.12 → 0.1.13

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.13
4
+
5
+ ### Patch Changes
6
+
7
+ - 5955334: Fixed `computed` method receiving updated variants when extending multiple levels of components.
8
+
3
9
  ## 0.1.12
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -158,7 +158,7 @@ function isHTMLObjStyle(style) {
158
158
  //#endregion
159
159
  //#region src/index.ts
160
160
  const META_KEY = "__meta";
161
- const SKIP_VARIANT = Symbol("skipVariant");
161
+ const SKIP_STYLE_KEYS = Symbol("skipStyleKeys");
162
162
  function getComponentMeta(component) {
163
163
  return component[META_KEY];
164
164
  }
@@ -229,11 +229,15 @@ function collectVariantKeys(config) {
229
229
  /**
230
230
  * Collects static default variants from extended components and the current
231
231
  * config. Also handles implicit boolean defaults (when only `false` key
232
- * exists).
232
+ * exists). This does NOT trigger computed functions - use collectDefaultVariants
233
+ * for that.
233
234
  */
234
235
  function collectStaticDefaults(config) {
235
236
  const defaults = {};
236
- if (config.extend) for (const ext of config.extend) Object.assign(defaults, ext.getVariants());
237
+ if (config.extend) for (const ext of config.extend) {
238
+ const meta = getComponentMeta(ext);
239
+ if (meta) Object.assign(defaults, meta.staticDefaults);
240
+ }
237
241
  if (config.variants) for (const [variantName, variantDef] of Object.entries(config.variants)) {
238
242
  if (!isStyleClassValue(variantDef)) continue;
239
243
  if (Object.keys(variantDef).includes("false") && !defaults[variantName]) defaults[variantName] = false;
@@ -320,9 +324,9 @@ function computeExtendedStyles(config, resolvedVariants, overrideVariantKeys = /
320
324
  style
321
325
  };
322
326
  for (const ext of config.extend) {
323
- const filteredVariants = { ...resolvedVariants };
324
- for (const key of overrideVariantKeys) filteredVariants[key] = SKIP_VARIANT;
325
- const extResult = ext(filteredVariants);
327
+ const propsForExt = { ...resolvedVariants };
328
+ if (overrideVariantKeys.size > 0) propsForExt[SKIP_STYLE_KEYS] = overrideVariantKeys;
329
+ const extResult = ext(propsForExt);
326
330
  assign(style, normalizeStyle(extResult.style));
327
331
  const baseClass = getComponentMeta(ext)?.baseClass ?? "";
328
332
  baseClasses.push(baseClass);
@@ -339,10 +343,11 @@ function computeExtendedStyles(config, resolvedVariants, overrideVariantKeys = /
339
343
  * Computes class and style from the component's own variants and
340
344
  * computedVariants (not extended components).
341
345
  */
342
- function computeVariantStyles(config, resolvedVariants) {
346
+ function computeVariantStyles(config, resolvedVariants, skipStyleKeys = /* @__PURE__ */ new Set()) {
343
347
  const classes = [];
344
348
  const style = {};
345
349
  if (config.variants) for (const [variantName, variantDef] of Object.entries(config.variants)) {
350
+ if (skipStyleKeys.has(variantName)) continue;
346
351
  const selectedValue = resolvedVariants[variantName];
347
352
  if (selectedValue === void 0) continue;
348
353
  const result = getVariantResult(variantDef, selectedValue);
@@ -350,9 +355,9 @@ function computeVariantStyles(config, resolvedVariants) {
350
355
  assign(style, result.style);
351
356
  }
352
357
  if (config.computedVariants) for (const [variantName, computeFn] of Object.entries(config.computedVariants)) {
358
+ if (skipStyleKeys.has(variantName)) continue;
353
359
  const selectedValue = resolvedVariants[variantName];
354
360
  if (selectedValue === void 0) continue;
355
- if (selectedValue === SKIP_VARIANT) continue;
356
361
  const result = extractClassAndStyle(computeFn(selectedValue));
357
362
  classes.push(result.class);
358
363
  assign(style, result.style);
@@ -375,11 +380,8 @@ function runComputedFunction(config, resolvedVariants, propsVariants) {
375
380
  style,
376
381
  updatedVariants
377
382
  };
378
- const variantsForComputed = { ...resolvedVariants };
379
- const defaults = collectStaticDefaults(config);
380
- for (const [key, value] of Object.entries(variantsForComputed)) if (value === SKIP_VARIANT) variantsForComputed[key] = defaults[key];
381
383
  const context = {
382
- variants: variantsForComputed,
384
+ variants: resolvedVariants,
383
385
  setVariants: (newVariants) => {
384
386
  Object.assign(updatedVariants, newVariants);
385
387
  },
@@ -522,19 +524,21 @@ function create({ defaultMode = "jsx", transformClass = (className) => className
522
524
  const computeResult = (props = {}) => {
523
525
  const allClasses = [];
524
526
  const allStyle = {};
527
+ const skipStyleKeys = props[SKIP_STYLE_KEYS] ?? /* @__PURE__ */ new Set();
525
528
  const variantProps = {};
526
529
  for (const key of variantKeys) if (key in props) variantProps[key] = props[key];
527
530
  let resolvedVariants = resolveVariants(config, variantProps);
528
531
  const computedResult = runComputedFunction(config, resolvedVariants, variantProps);
529
532
  resolvedVariants = computedResult.updatedVariants;
530
- const computedVariantKeys = new Set(config.computedVariants ? Object.keys(config.computedVariants) : []);
533
+ const computedVariantKeys = new Set(skipStyleKeys);
534
+ if (config.computedVariants) for (const key of Object.keys(config.computedVariants)) computedVariantKeys.add(key);
531
535
  const extendedResult = computeExtendedStyles(config, resolvedVariants, computedVariantKeys);
532
536
  allClasses.push(...extendedResult.baseClasses);
533
537
  assign(allStyle, extendedResult.style);
534
538
  allClasses.push(config.class);
535
539
  if (config.style) assign(allStyle, config.style);
536
540
  allClasses.push(...extendedResult.variantClasses);
537
- const variantsResult = computeVariantStyles(config, resolvedVariants);
541
+ const variantsResult = computeVariantStyles(config, resolvedVariants, skipStyleKeys);
538
542
  allClasses.push(...variantsResult.classes);
539
543
  assign(allStyle, variantsResult.style);
540
544
  allClasses.push(...computedResult.classes);
@@ -586,6 +590,7 @@ function create({ defaultMode = "jsx", transformClass = (className) => className
586
590
  }
587
591
  setComponentMeta(component$1, {
588
592
  baseClass: cx$1(...extendedBaseClasses, config.class),
593
+ staticDefaults: collectStaticDefaults(config),
589
594
  resolveDefaults: createResolveDefaults(config)
590
595
  });
591
596
  return component$1;
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 resolveDefaults: (\n childDefaults: Record<string, unknown>,\n userProps?: Record<string, unknown>,\n ) => Record<string, unknown>;\n}\n\nconst META_KEY = \"__meta\";\n\n// Sentinel value used to signal \"skip this variant\" when a child's\n// computedVariants overrides a parent's variant. Using a Symbol ensures it\n// can't conflict with any user-provided value (including null).\nconst SKIP_VARIANT = Symbol(\"skipVariant\");\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).\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\n if (config.extend) {\n for (const ext of config.extend) {\n Object.assign(defaults, ext.getVariants());\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 // Filter out variant keys that are being overridden by computedVariants\n // Set to SKIP_VARIANT sentinel (not delete) to prevent the parent from\n // applying its implicit boolean default\n const filteredVariants = { ...resolvedVariants };\n for (const key of overrideVariantKeys) {\n filteredVariants[key] = SKIP_VARIANT;\n }\n\n const extResult = ext(filteredVariants);\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, unknown>,\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 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 const selectedValue = resolvedVariants[variantName];\n if (selectedValue === undefined) continue;\n // Skip SKIP_VARIANT sentinel (used when a child's computedVariants\n // overrides a parent's variant)\n if (selectedValue === SKIP_VARIANT) 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 // For the computed function, replace SKIP_VARIANT with default values.\n // SKIP_VARIANT is used to prevent parent's variant styling when a child has\n // computedVariants that override the parent's variant, but the computed\n // function should still see valid values (the component's defaults).\n const variantsForComputed = { ...resolvedVariants };\n const defaults = collectStaticDefaults(config);\n for (const [key, value] of Object.entries(variantsForComputed)) {\n if (value === SKIP_VARIANT) {\n variantsForComputed[key] = defaults[key];\n }\n }\n\n const context = {\n variants: variantsForComputed,\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 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 const computedVariantKeys = new Set<string>(\n config.computedVariants ? Object.keys(config.computedVariants) : [],\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\n const variantsResult = computeVariantStyles(\n config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,\n resolvedVariants,\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 // Store internal metadata hidden from public types\n setComponentMeta(component, {\n baseClass,\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;AA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,iBAAiB,IAAI;AAClC,wBAAoB,KAAK,MAAM,aAAa,GAAG;;AASnD,oBAAiBA,aAAW;IAC1B,WAPgBH,KAChB,GAAI,qBACJ,OAAO,MACR;IAKC,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":["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,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,CAAC;;;;;;;;AASvE,SAAgB,cAAc,KAAa;AAEzC,KAAI,IAAI,WAAW,KAAK,CACtB,QAAO;AAET,QAAO,IAAI,QAAQ,WAAW,WAAW,IAAI,OAAO,aAAa,GAAG;;;;;;;;AAStE,SAAgB,iBAAiB,OAAwB;AACvD,KAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAO,GAAG,MAA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BAA+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.12",
3
+ "version": "0.1.13",
4
4
  "description": "Clava library",
5
5
  "keywords": [
6
6
  "class variance",
package/src/index.ts CHANGED
@@ -35,6 +35,7 @@ import {
35
35
  // Internal metadata stored on components but hidden from public types
36
36
  interface ComponentMeta {
37
37
  baseClass: string;
38
+ staticDefaults: Record<string, unknown>;
38
39
  resolveDefaults: (
39
40
  childDefaults: Record<string, unknown>,
40
41
  userProps?: Record<string, unknown>,
@@ -43,10 +44,10 @@ interface ComponentMeta {
43
44
 
44
45
  const META_KEY = "__meta";
45
46
 
46
- // Sentinel value used to signal "skip this variant" when a child's
47
- // computedVariants overrides a parent's variant. Using a Symbol ensures it
48
- // can't conflict with any user-provided value (including null).
49
- const SKIP_VARIANT = Symbol("skipVariant");
47
+ // Symbol property used to pass skip keys through the props object without
48
+ // polluting the actual variant values. This allows the computed function to
49
+ // see actual variant values while still skipping styling for overridden keys.
50
+ const SKIP_STYLE_KEYS = Symbol("skipStyleKeys");
50
51
 
51
52
  // Dynamic property access on function requires cast through unknown
52
53
  function getComponentMeta(component: AnyComponent): ComponentMeta | undefined {
@@ -194,17 +195,22 @@ function collectVariantKeys(
194
195
  /**
195
196
  * Collects static default variants from extended components and the current
196
197
  * config. Also handles implicit boolean defaults (when only `false` key
197
- * exists).
198
+ * exists). This does NOT trigger computed functions - use collectDefaultVariants
199
+ * for that.
198
200
  */
199
201
  function collectStaticDefaults(
200
202
  config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,
201
203
  ): Record<string, unknown> {
202
204
  const defaults: Record<string, unknown> = {};
203
205
 
204
- // Collect static defaults from extended components
206
+ // Collect static defaults from extended components (via metadata to avoid
207
+ // triggering computed functions)
205
208
  if (config.extend) {
206
209
  for (const ext of config.extend) {
207
- Object.assign(defaults, ext.getVariants());
210
+ const meta = getComponentMeta(ext);
211
+ if (meta) {
212
+ Object.assign(defaults, meta.staticDefaults);
213
+ }
208
214
  }
209
215
  }
210
216
 
@@ -347,15 +353,17 @@ function computeExtendedStyles(
347
353
  if (!config.extend) return { baseClasses, variantClasses, style };
348
354
 
349
355
  for (const ext of config.extend) {
350
- // Filter out variant keys that are being overridden by computedVariants
351
- // Set to SKIP_VARIANT sentinel (not delete) to prevent the parent from
352
- // applying its implicit boolean default
353
- const filteredVariants = { ...resolvedVariants };
354
- for (const key of overrideVariantKeys) {
355
- filteredVariants[key] = SKIP_VARIANT;
356
+ // Pass actual variant values but mark which keys should skip styling.
357
+ // Using a Symbol property keeps variant values clean for computed functions
358
+ // while still allowing us to skip styling for overridden keys.
359
+ const propsForExt: Record<string | symbol, unknown> = {
360
+ ...resolvedVariants,
361
+ };
362
+ if (overrideVariantKeys.size > 0) {
363
+ propsForExt[SKIP_STYLE_KEYS] = overrideVariantKeys;
356
364
  }
357
365
 
358
- const extResult = ext(filteredVariants);
366
+ const extResult = ext(propsForExt);
359
367
  assign(style, normalizeStyle(extResult.style));
360
368
 
361
369
  // Get base class from internal metadata (no variants)
@@ -382,7 +390,8 @@ function computeExtendedStyles(
382
390
  */
383
391
  function computeVariantStyles(
384
392
  config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,
385
- resolvedVariants: Record<string, unknown>,
393
+ resolvedVariants: Record<string | symbol, unknown>,
394
+ skipStyleKeys: Set<string> = new Set(),
386
395
  ): { classes: ClassValue[]; style: StyleValue } {
387
396
  const classes: ClassValue[] = [];
388
397
  const style: StyleValue = {};
@@ -390,6 +399,9 @@ function computeVariantStyles(
390
399
  // Process current component's variants
391
400
  if (config.variants) {
392
401
  for (const [variantName, variantDef] of Object.entries(config.variants)) {
402
+ // Skip styling for variants that are overridden by child's computedVariants
403
+ if (skipStyleKeys.has(variantName)) continue;
404
+
393
405
  const selectedValue = resolvedVariants[variantName];
394
406
  if (selectedValue === undefined) continue;
395
407
 
@@ -404,11 +416,11 @@ function computeVariantStyles(
404
416
  for (const [variantName, computeFn] of Object.entries(
405
417
  config.computedVariants,
406
418
  )) {
419
+ // Skip styling for variants that are overridden by child's computedVariants
420
+ if (skipStyleKeys.has(variantName)) continue;
421
+
407
422
  const selectedValue = resolvedVariants[variantName];
408
423
  if (selectedValue === undefined) continue;
409
- // Skip SKIP_VARIANT sentinel (used when a child's computedVariants
410
- // overrides a parent's variant)
411
- if (selectedValue === SKIP_VARIANT) continue;
412
424
 
413
425
  const computedResult = computeFn(selectedValue);
414
426
  const result = extractClassAndStyle(computedResult);
@@ -441,20 +453,8 @@ function runComputedFunction(
441
453
  return { classes, style, updatedVariants };
442
454
  }
443
455
 
444
- // For the computed function, replace SKIP_VARIANT with default values.
445
- // SKIP_VARIANT is used to prevent parent's variant styling when a child has
446
- // computedVariants that override the parent's variant, but the computed
447
- // function should still see valid values (the component's defaults).
448
- const variantsForComputed = { ...resolvedVariants };
449
- const defaults = collectStaticDefaults(config);
450
- for (const [key, value] of Object.entries(variantsForComputed)) {
451
- if (value === SKIP_VARIANT) {
452
- variantsForComputed[key] = defaults[key];
453
- }
454
- }
455
-
456
456
  const context = {
457
- variants: variantsForComputed,
457
+ variants: resolvedVariants,
458
458
  setVariants: (newVariants: VariantValues<Record<string, unknown>>) => {
459
459
  Object.assign(updatedVariants, newVariants);
460
460
  },
@@ -717,6 +717,12 @@ export function create<M extends Mode = "jsx">({
717
717
  const allClasses: ClassValue[] = [];
718
718
  const allStyle: StyleValue = {};
719
719
 
720
+ // Extract skip style keys from props (set by child's computedVariants)
721
+ const skipStyleKeys =
722
+ ((props as Record<symbol, unknown>)[SKIP_STYLE_KEYS] as
723
+ | Set<string>
724
+ | undefined) ?? new Set<string>();
725
+
720
726
  // Extract variant props from input
721
727
  const variantProps: Record<string, unknown> = {};
722
728
  for (const key of variantKeys) {
@@ -739,10 +745,14 @@ export function create<M extends Mode = "jsx">({
739
745
  );
740
746
  resolvedVariants = computedResult.updatedVariants;
741
747
 
742
- // Collect computedVariants keys that will override extended variants
743
- const computedVariantKeys = new Set<string>(
744
- config.computedVariants ? Object.keys(config.computedVariants) : [],
745
- );
748
+ // Collect computedVariants keys that will override extended variants.
749
+ // Combine with incoming skip keys to propagate through the extend chain.
750
+ const computedVariantKeys = new Set<string>(skipStyleKeys);
751
+ if (config.computedVariants) {
752
+ for (const key of Object.keys(config.computedVariants)) {
753
+ computedVariantKeys.add(key);
754
+ }
755
+ }
746
756
 
747
757
  // Process extended components (separates base and variant classes)
748
758
  const extendedResult = computeExtendedStyles(
@@ -766,10 +776,11 @@ export function create<M extends Mode = "jsx">({
766
776
  // 4. Extended variant classes
767
777
  allClasses.push(...extendedResult.variantClasses);
768
778
 
769
- // 5. Current component's variants
779
+ // 5. Current component's variants (skip keys that are overridden)
770
780
  const variantsResult = computeVariantStyles(
771
781
  config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
772
782
  resolvedVariants,
783
+ skipStyleKeys,
773
784
  );
774
785
  allClasses.push(...variantsResult.classes);
775
786
  assign(allStyle, variantsResult.style);
@@ -860,9 +871,16 @@ export function create<M extends Mode = "jsx">({
860
871
  config.class as ClsxClassValue,
861
872
  );
862
873
 
874
+ // Compute static defaults once at creation time (without triggering
875
+ // computed functions)
876
+ const staticDefaults = collectStaticDefaults(
877
+ config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
878
+ );
879
+
863
880
  // Store internal metadata hidden from public types
864
881
  setComponentMeta(component, {
865
882
  baseClass,
883
+ staticDefaults,
866
884
  resolveDefaults: createResolveDefaults(
867
885
  config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
868
886
  ),
package/src/test.ts CHANGED
@@ -1363,11 +1363,11 @@ for (const config of Object.values(CONFIGS)) {
1363
1363
  expect(getStyleClass(props)).toEqual({ class: cls("lg computed-lg") });
1364
1364
  });
1365
1365
 
1366
- test("computed from parent receives default boolean value from overridden variant in child", () => {
1366
+ test("computed from parent receives boolean default value from overridden variant in child", () => {
1367
1367
  const base = cv({
1368
1368
  variants: {
1369
1369
  size: { sm: "sm", lg: "lg" },
1370
- border: { default: "default", false: "" },
1370
+ border: { default: "default", true: "border", false: "" },
1371
1371
  },
1372
1372
  defaultVariants: { size: "lg" },
1373
1373
  computed: ({ variants, setVariants }) => {
@@ -1391,11 +1391,40 @@ for (const config of Object.values(CONFIGS)) {
1391
1391
  expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1392
1392
  });
1393
1393
 
1394
- test("computed from parent receives props boolean value from overridden variant in child", () => {
1394
+ test("computed from parent receives boolean default value from overridden variant in grandchild", () => {
1395
1395
  const base = cv({
1396
1396
  variants: {
1397
1397
  size: { sm: "sm", lg: "lg" },
1398
- border: { default: "default", false: "" },
1398
+ border: { default: "default", true: "border", false: "" },
1399
+ },
1400
+ defaultVariants: { size: "lg" },
1401
+ computed: ({ variants, setVariants }) => {
1402
+ expect(variants.border).toBe(false);
1403
+ if (!variants.border) {
1404
+ setVariants({ size: "sm" });
1405
+ }
1406
+ },
1407
+ });
1408
+ const base2 = cv({ extend: [base] });
1409
+ const component = getModalComponent(
1410
+ mode,
1411
+ cv({
1412
+ extend: [base2],
1413
+ computedVariants: {
1414
+ border: (_: boolean) => {},
1415
+ },
1416
+ defaultVariants: { border: false },
1417
+ }),
1418
+ );
1419
+ const props = component();
1420
+ expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1421
+ });
1422
+
1423
+ test("computed from parent receives false prop from overridden variant in child", () => {
1424
+ const base = cv({
1425
+ variants: {
1426
+ size: { sm: "sm", lg: "lg" },
1427
+ border: { default: "default", true: "border", false: "" },
1399
1428
  },
1400
1429
  defaultVariants: { size: "lg" },
1401
1430
  computed: ({ variants, setVariants }) => {
@@ -1418,6 +1447,61 @@ for (const config of Object.values(CONFIGS)) {
1418
1447
  expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1419
1448
  });
1420
1449
 
1450
+ test("computed from parent receives true prop from overridden variant in child", () => {
1451
+ const base = cv({
1452
+ variants: {
1453
+ size: { sm: "sm", lg: "lg" },
1454
+ border: { default: "default", true: "border", false: "" },
1455
+ },
1456
+ defaultVariants: { size: "lg" },
1457
+ computed: ({ variants, setVariants }) => {
1458
+ expect(variants.border).toBe(true);
1459
+ if (variants.border) {
1460
+ setVariants({ size: "sm" });
1461
+ }
1462
+ },
1463
+ });
1464
+ const component = getModalComponent(
1465
+ mode,
1466
+ cv({
1467
+ extend: [base],
1468
+ computedVariants: {
1469
+ border: (_: boolean) => {},
1470
+ },
1471
+ }),
1472
+ );
1473
+ const props = component({ border: true });
1474
+ expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1475
+ });
1476
+
1477
+ test("computed from parent receives true prop from overridden variant in grandchild", () => {
1478
+ const base = cv({
1479
+ variants: {
1480
+ size: { sm: "sm", lg: "lg" },
1481
+ border: { default: "default", true: "border", false: "" },
1482
+ },
1483
+ defaultVariants: { size: "lg" },
1484
+ computed: ({ variants, setVariants }) => {
1485
+ expect(variants.border).toBe(true);
1486
+ if (variants.border) {
1487
+ setVariants({ size: "sm" });
1488
+ }
1489
+ },
1490
+ });
1491
+ const base2 = cv({ extend: [base] });
1492
+ const component = getModalComponent(
1493
+ mode,
1494
+ cv({
1495
+ extend: [base2],
1496
+ computedVariants: {
1497
+ border: (_: boolean) => {},
1498
+ },
1499
+ }),
1500
+ );
1501
+ const props = component({ border: true });
1502
+ expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1503
+ });
1504
+
1421
1505
  test("computed with style", () => {
1422
1506
  const component = getModalComponent(
1423
1507
  mode,