{"version":3,"file":"ComponentTheme.cjs","sources":["../../../../../../src/components/ui/theme/common/ComponentTheme.tsx"],"sourcesContent":["import React from \"react\";\nimport { BaseClassMapper } from \"./BaseClassMapper\";\nimport { ComponentCategoryKey } from \"../../props\";\nimport { ComponentKeys } from \"../../props\";\nimport { HideClassMapper } from \"../layout/hideClassMapper\";\nimport { ItemsClassMapper } from \"../layout/itemsClassMapper\";\nimport { JustifyClassMapper } from \"../layout/justifyClassMapper\";\nimport { PositionClassMapper } from \"../layout/positionClassMapper\";\nimport { FontStyleClassMapper } from \"../typography/fontStyleClassMapper\";\nimport { FontFamilyClassMapper } from \"../typography/fontFamilyClassMapper\";\nimport { FontWeightClassMapper } from \"../typography/fontWeightClassMapper\";\nimport { TextDecorationClassMapper } from \"../typography/textDecorationClassMapper\";\nimport { TextTransformClassMapper } from \"../typography/textTransformClassMapper\";\nimport { TextAlignClassMapper } from \"../typography/textAlignClassMapper\";\nimport { TruncateClassMapper } from \"../typography/truncateClassMapper\";\nimport { DeepPartial } from \"../../../utils/deepPartial\";\nimport { DisplayClassMapper } from \"../layout/displayClassMapper\";\nimport { twMerge } from \"tailwind-merge\";\nimport { OverflowClassMapper } from \"../layout/overflowClassMapper\";\nimport { WidthClassMapper } from \"../layout/widthClassMapper\";\nimport { HeightClassMapper } from \"../layout/heightClassMapper\";\nimport { pickFirstTruthyKeyByCategory, collectTruthyKeysByCategory, MULTI_VALUE_CATEGORIES, resetConflictKey } from \"../../../utils/componentUtils\";\n\ntype ComponentProps = { className?: string; children?: React.ReactNode; tag?: React.ElementType; };\ntype ThemeNode<P> = BaseClassMapper | ThemeMap<P>;\n\n// HTML tags where the native disabled attribute is valid and desired\nconst NATIVE_DISABLED_TAGS = new Set([\n  'button', 'input', 'select', 'textarea', 'fieldset', 'optgroup', 'option',\n]);\n\n// props consumed by the theme engine itself — never forwarded to the DOM\n// (boolean category props are stripped separately via ResolutionState.omitKeys)\nconst INTERNAL_PROPS = new Set(['className', 'tag', 'children', 'theme']);\n\n// attributes that are invalid on a given resolved tag — stripped so a wrong-tag\n// HTML attribute can't leak through a tag-switching component (e.g. type/form\n// reaching a rendered <a>, or href/target/download/rel reaching a rendered\n// <button>). Components like Button/NavLink/Badge union button + anchor attrs.\nconst TAG_INVALID_ATTRS: Record<string, readonly string[]> = {\n  a: ['type', 'form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget'],\n  button: ['href', 'target', 'download', 'rel', 'hrefLang', 'ping'],\n};\n\nexport type VaneComponentType = 'ui' | 'layout';\n\nexport type ThemeMap<P> = {\n  [key: string]: ThemeNode<P>;\n};\n\nexport interface DefaultLayoutClassMappers {\n  hide: HideClassMapper;\n  items: ItemsClassMapper;\n  justify: JustifyClassMapper;\n  position: PositionClassMapper;\n  display: DisplayClassMapper;\n  overflow: OverflowClassMapper;\n}\n\nexport interface DefaultTypographyClassMappers {\n  fontFamily: FontFamilyClassMapper;\n  fontWeight: FontWeightClassMapper;\n  fontStyle: FontStyleClassMapper;\n  textDecoration: TextDecorationClassMapper;\n  textTransform: TextTransformClassMapper;\n  textAlign: TextAlignClassMapper;\n  truncate: TruncateClassMapper;\n}\n\nexport interface BaseComponentTheme {\n  layout: DefaultLayoutClassMappers;\n}\n\nexport interface BaseTypographyComponentTheme extends BaseComponentTheme {\n  typography: DefaultTypographyClassMappers;\n}\n\nexport const defaultLayoutClassMappers: DefaultLayoutClassMappers = {\n  hide: new HideClassMapper(),\n  items: new ItemsClassMapper(),\n  justify: new JustifyClassMapper(),\n  position: new PositionClassMapper(),\n  display: new DisplayClassMapper(),\n  overflow: new OverflowClassMapper(),\n};\n\nexport interface DefaultSizedLayoutClassMappers extends DefaultLayoutClassMappers {\n  width: WidthClassMapper;\n  height: HeightClassMapper;\n}\n\nexport const defaultSizedLayoutClassMappers: DefaultSizedLayoutClassMappers = {\n  ...defaultLayoutClassMappers,\n  width: new WidthClassMapper(),\n  height: new HeightClassMapper(),\n};\n\nexport const defaultTypographyClassMappers: DefaultTypographyClassMappers = {\n  fontFamily: new FontFamilyClassMapper(),\n  fontWeight: new FontWeightClassMapper(),\n  fontStyle: new FontStyleClassMapper(),\n  textDecoration: new TextDecorationClassMapper(),\n  textTransform: new TextTransformClassMapper(),\n  textAlign: new TextAlignClassMapper(),\n  truncate: new TruncateClassMapper(),\n};\n\n/* Per-instance derived state: constant omitKeys/baseClasses + walkCache (memoizes the tree walk per extracted-keys signature; defaults only affect the cache key, extraClasses applied per call). */\ninterface ResolutionState {\n  /** boolean prop names consumed by the theme system (union of all category keys) — stripped from DOM props */\n  omitKeys: ReadonlySet<string>;\n  /** `base` pre-split on whitespace, empty entries removed */\n  baseClasses: readonly string[];\n  /** extracted-keys signature → theme-tree walk output (pre-filtered, treated as immutable) */\n  walkCache: Map<string, readonly string[]>;\n}\n\n/* Resolution state keyed by instance identity in a module-level WeakMap, not on the instance: deepClone/deepMerge copy instances generically, so instance state would leak into clones or break (Set/Map slots don't survive). Every clone/withDefaults() starts cold. */\nconst resolutionStateMap = new WeakMap<object, ResolutionState>();\n\nexport class ComponentTheme<P extends ComponentProps, TTheme extends object> {\n  readonly tag: React.ElementType;\n  // writable so `themeOverride` can append always-on classes on the cloned tree\n  // (e.g. `theme.button.main.base += ' uppercase'`), matching the writable\n  // `defaults`/`extraClasses` and the mapper-node `base` fields. Mutation is\n  // safe only on ThemeProvider's pre-render clone (see the class doc-comment).\n  base: string;\n  readonly themes: TTheme;\n  readonly vaneType?: VaneComponentType;\n  // fallback for pickFirstTruthyKeyByCategory when props omit a category; merged via ThemeProvider\n  defaults: Partial<P>;\n  extraClasses: Partial<Record<keyof P, string>>;\n  private readonly categories: readonly ComponentCategoryKey[];\n  // base type decoupled from P so ComponentTheme<SpecificProps, T> stays structurally compatible\n  private readonly tagFunction?: (props: ComponentProps, defaults: Partial<ComponentProps>) => React.ElementType;\n\n  constructor(\n    tag: React.ElementType,\n    base: string,\n    themes: DeepPartial<TTheme>,\n    defaults: Partial<P> = {},\n    categories: readonly ComponentCategoryKey[],\n    tagFunction?: (props: P, defaults: Partial<P>) => React.ElementType,\n    vaneType?: VaneComponentType\n  ) {\n    this.tag = tag;\n    this.base = base;\n    this.defaults = defaults;\n    this.extraClasses = {};\n    this.categories = categories;\n    // safe: existing tagFunctions only access optional props (e.g. href)\n    this.tagFunction = tagFunction as typeof this.tagFunction;\n    this.vaneType = vaneType;\n    this.themes = themes as TTheme;\n  }\n\n  withDefaults(defaults: Partial<P>): ComponentTheme<P, TTheme> {\n    return new ComponentTheme<P, TTheme>(\n      this.tag,\n      this.base,\n      this.themes,\n      defaults,\n      this.categories,\n      this.tagFunction as ((props: P, defaults: Partial<P>) => React.ElementType) | undefined,\n      this.vaneType,\n    );\n  }\n\n  private resolutionState(): ResolutionState {\n    let state = resolutionStateMap.get(this);\n    if (state === undefined) {\n      state = {\n        omitKeys: new Set<string>(this.categories.flatMap(category => ComponentKeys[category])),\n        baseClasses: this.base ? this.base.split(/\\s+/).filter(Boolean) : [],\n        walkCache: new Map(),\n      };\n      resolutionStateMap.set(this, state);\n    }\n    return state;\n  }\n\n  /* Resolve the active key per category (props win over defaults) and expand `inherit` into inheritColor/Bg/Border. Shared by getClasses + getComponentConfig so both see the same key set. */\n  private resolveExtractedKeys(props: P): Record<string, string> {\n    const componentProps = props as unknown as Record<string, boolean>;\n    const defaults = this.defaults as Record<string, boolean>;\n\n    const extractedKeys: Record<string, string> = {};\n    for (const category of this.categories) {\n      if (MULTI_VALUE_CATEGORIES.has(category)) {\n        // border/margin compose: store all active side keys space-joined for the mapper to union\n        const collected = collectTruthyKeysByCategory(componentProps, defaults, category);\n        if (collected.length > 0) {\n          extractedKeys[category] = collected.join(' ');\n        }\n        continue;\n      }\n      const key = pickFirstTruthyKeyByCategory(componentProps, defaults, category);\n      if (key !== undefined) {\n        extractedKeys[category] = key;\n      }\n    }\n\n    // expand `inheritAppearance` shorthand into COLOR/BG/BORDER only (size inheritance is opt-in via inheritSize)\n    if (extractedKeys.appearance === 'inheritAppearance') {\n      if (!extractedKeys.inheritColor) {\n        extractedKeys.inheritColor = 'inheritColor';\n      }\n      if (!extractedKeys.inheritBg) {\n        extractedKeys.inheritBg = 'inheritBg';\n      }\n      if (!extractedKeys.inheritBorder) {\n        extractedKeys.inheritBorder = 'inheritBorder';\n      }\n    }\n\n    return extractedKeys;\n  }\n\n  getClasses(props: P, precomputedKeys?: Record<string, string>): string[] {\n    const extractedKeys = precomputedKeys ?? this.resolveExtractedKeys(props);\n    const state = this.resolutionState();\n\n    const classes: string[] = state.baseClasses.slice();\n\n    // Signature of the resolved keys. for...in (not Object.keys) so any\n    // enumerable inherited key on a caller-supplied precomputedKeys object is\n    // captured too — mappers read keys via plain property access, which also\n    // sees the prototype chain, and the signature must cover everything the\n    // walk can observe. Both internal paths build plain objects in stable\n    // `categories` order, so signatures are stable per instance.\n    let signature = '';\n    for (const category in extractedKeys) {\n      signature += category;\n      signature += ':';\n      signature += extractedKeys[category];\n      signature += '|';\n    }\n\n    let walkClasses = state.walkCache.get(signature);\n    if (walkClasses === undefined) {\n      const collected: string[] = [];\n      const walk = (map: object) => {\n        for (const key of Object.keys(map)) {\n          const node = (map as ThemeMap<P>)[key];\n\n          if (node instanceof BaseClassMapper) {\n            collected.push(...node.getClasses(extractedKeys));\n          } else if (node && typeof node === \"object\" && !Array.isArray(node)) {\n            walk(node);\n          }\n        }\n      };\n      walk(this.themes);\n      walkClasses = collected.filter(Boolean);\n      state.walkCache.set(signature, walkClasses);\n    }\n    classes.push(...walkClasses);\n\n    // extraClasses are applied per call (never cached) so the cached walk\n    // output stays valid even if extraClasses are replaced on this instance\n    for (const [, value] of Object.entries(extractedKeys)) {\n      if (value && this.extraClasses[value as keyof P]) {\n        const existingClasses = this.extraClasses[value as keyof P];\n        if (existingClasses !== undefined) {\n          classes.push(...existingClasses.split(/\\s+/));\n        }\n      }\n    }\n\n    return classes.filter(Boolean);\n  }\n\n  getTag(props: P): React.ElementType {\n    if (this.tagFunction) {\n      return this.tagFunction(props, this.defaults);\n    }\n    return this.tag;\n  }\n\n  getComponentConfig(props: P) {\n    const componentProps = props as unknown as Record<string, boolean>;\n    const extractedKeys = this.resolveExtractedKeys(props);\n\n    // dev-only: categories are mutually exclusive, but the boolean-props API\n    // can't express that in types — when 2+ props of one category are\n    // explicitly true, the winner is ComponentKeys array order (NOT JSX\n    // order), which is undiscoverable without a warning\n    if (process.env.NODE_ENV !== 'production') {\n      for (const category of this.categories) {\n        const truthyKeys = ComponentKeys[category].filter(k => componentProps[k] === true);\n        if (MULTI_VALUE_CATEGORIES.has(category)) {\n          const reset = resetConflictKey(truthyKeys);\n          if (reset) {\n            const tagName = typeof this.tag === 'string' ? `<${this.tag}>` : 'component';\n            console.warn(\n              `VaneUI: conflicting ${category} props on ${tagName}: ${truthyKeys.join(', ')} — \"${reset}\" resets and wins over the side toggles. Pass either side toggles or a reset, not both.`\n            );\n          }\n          continue;\n        }\n        if (truthyKeys.length > 1) {\n          const tagName = typeof this.tag === 'string' ? `<${this.tag}>` : 'component';\n          console.warn(\n            `VaneUI: conflicting ${category} props on ${tagName}: ${truthyKeys.join(', ')} — \"${truthyKeys[0]}\" wins (canonical key order, not JSX order). Pass only one prop per category.`\n          );\n        }\n      }\n    }\n\n    const { omitKeys } = this.resolutionState();\n\n    // Build the DOM-props object in a single pass over the props actually\n    // present, skipping theme-consumed keys via the precomputed omit set.\n    // (Previously: spread the props, then issue one `delete` per possible\n    // category key — 150+ deletes per render regardless of how few props the\n    // element actually has.)\n    const rawProps = props as Record<PropertyKey, unknown>;\n    const other: Record<PropertyKey, unknown> = {};\n    for (const key of Object.keys(rawProps)) {\n      if (omitKeys.has(key) || INTERNAL_PROPS.has(key)) {\n        continue;\n      }\n      other[key] = rawProps[key];\n    }\n    // parity with the previous spread-based copy: enumerable symbol-keyed\n    // props were forwarded too, and Object.keys only yields string keys\n    for (const sym of Object.getOwnPropertySymbols(rawProps)) {\n      if (Object.prototype.propertyIsEnumerable.call(rawProps, sym)) {\n        other[sym] = rawProps[sym];\n      }\n    }\n\n    const { className, tag } = props;\n    const componentTag: React.ElementType = tag ?? this.getTag(props) ?? \"div\";\n\n    // preserve the HTML-native disabled attr (it overlaps with a category\n    // key), but only on tags that support it — a placeholder link rendered\n    // for disabled href-switching must stay focusable per the aria-disabled\n    // pattern, and native disabled would pull it out of the tab order\n    const supportsNativeDisabled =\n      typeof componentTag !== 'string' || NATIVE_DISABLED_TAGS.has(componentTag);\n    if (rawProps.disabled !== undefined && supportsNativeDisabled) {\n      other.disabled = rawProps.disabled;\n    } else if (!supportsNativeDisabled && 'disabled' in other) {\n      // a tag that doesn't support native disabled (e.g. <a>, <span>) must not\n      // carry a leaked `disabled` attribute — the state is exposed via\n      // data-disabled / aria-disabled instead\n      delete other.disabled;\n    }\n\n    // `readOnly` is now a category (so the ReadOnlyClassMapper can style it),\n    // which means omitKeys strips it. Re-add the native attribute on the tags\n    // that support it so the field stays read-only; data-readonly (below)\n    // carries the non-class CSS bits (caret-color / hover neutralization).\n    if (rawProps.readOnly !== undefined &&\n        (typeof componentTag !== 'string' || componentTag === 'input' || componentTag === 'textarea')) {\n      other.readOnly = rawProps.readOnly;\n    }\n\n    // drop attributes that don't belong on the resolved tag\n    if (typeof componentTag === 'string') {\n      const invalidAttrs = TAG_INVALID_ATTRS[componentTag];\n      if (invalidAttrs) {\n        for (const attr of invalidAttrs) {\n          if (attr in other) delete other[attr];\n        }\n      }\n    }\n\n    const themeGeneratedClasses = this.getClasses(props, extractedKeys);\n    const finalClasses = twMerge(...themeGeneratedClasses, className);\n\n    const dataAttributes: Record<string, string> = {};\n    if (this.vaneType) {\n      dataAttributes['data-vane-type'] = this.vaneType;\n    }\n    if (extractedKeys.size) {\n      dataAttributes['data-size'] = extractedKeys.size;\n    }\n    if (extractedKeys.responsiveSizing === 'responsiveSizing') {\n      dataAttributes['data-responsive'] = '';\n    }\n    // data-appearance suppressed when inheritColor is active (lets colors cascade from ancestor).\n    // data-variant emitted when appearance is present OR variant != outline (so `<Row filled>` works without explicit appearance).\n    const hasAppearance = extractedKeys.appearance && extractedKeys.inheritColor !== 'inheritColor';\n    if (hasAppearance) {\n      dataAttributes['data-appearance'] = extractedKeys.appearance;\n    }\n    if (extractedKeys.variant && (hasAppearance || extractedKeys.variant !== 'outline')) {\n      dataAttributes['data-variant'] = extractedKeys.variant;\n    }\n    if (rawProps.disabled) {\n      dataAttributes['data-disabled'] = 'true';\n    }\n    if (rawProps.readOnly) {\n      dataAttributes['data-readonly'] = 'true';\n      if (rawProps['aria-readonly'] === undefined) {\n        dataAttributes['aria-readonly'] = 'true';\n      }\n    }\n    // error state must be AT-perceivable, not color-only: emit aria-invalid\n    // (unless the consumer set it explicitly) alongside a data-status hook\n    if (extractedKeys.validity === 'invalid') {\n      dataAttributes['data-status'] = 'error';\n      if (rawProps['aria-invalid'] === undefined) {\n        dataAttributes['aria-invalid'] = 'true';\n      }\n    }\n\n    return {\n      Tag: componentTag,\n      finalClasses,\n      finalProps: { ...other, ...dataAttributes },\n    };\n  }\n}\n"],"names":["HideClassMapper","ItemsClassMapper","JustifyClassMapper","PositionClassMapper","DisplayClassMapper","OverflowClassMapper","WidthClassMapper","HeightClassMapper","FontFamilyClassMapper","FontWeightClassMapper","FontStyleClassMapper","TextDecorationClassMapper","TextTransformClassMapper","TextAlignClassMapper","TruncateClassMapper","ComponentKeys","MULTI_VALUE_CATEGORIES","collectTruthyKeysByCategory","pickFirstTruthyKeyByCategory","BaseClassMapper","resetConflictKey","twMerge"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,oBAAA,uBAA2B,GAAA,CAAI;AAAA,EACnC,QAAA;AAAA,EAAU,OAAA;AAAA,EAAS,QAAA;AAAA,EAAU,UAAA;AAAA,EAAY,UAAA;AAAA,EAAY,UAAA;AAAA,EAAY;AACnE,CAAC,CAAA;AAID,MAAM,cAAA,uBAAqB,GAAA,CAAI,CAAC,aAAa,KAAA,EAAO,UAAA,EAAY,OAAO,CAAC,CAAA;AAMxE,MAAM,iBAAA,GAAuD;AA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