igniteui-theming
Version:
A set of Sass variables, mixins, and functions for generating palettes, typography, and elevations used by Ignite UI components.
135 lines (134 loc) • 6.11 kB
TypeScript
import { Platform } from './platforms/index.js';
/**
* Platform-specific selectors for a component.
* Use `null` to indicate a component is not available on a platform.
*/
export interface ComponentSelectors {
/** Angular selector(s) - can be single string, array, or null if not available on Angular */
angular: string | string[] | null;
/** Web Components selector(s) - can be single string, array, or null if not available on Web Components */
webcomponents: string | string[] | null;
}
/**
* Describes how a child component's token value is derived from a source token.
*/
export interface TokenDerivation {
/** Source token: 'componentName.tokenName' */
from: string;
/** Transform to apply to the source value */
transform: "identity" | "adaptive-contrast" | "dynamic-shade";
/** Optional transform arguments (e.g., shade amount for dynamic-shade) */
args?: Record<string, string | number>;
}
/**
* Information about a compound component (one that contains multiple themeable sub-components).
*/
export interface CompoundInfo {
/** Description of what the compound component contains */
description: string;
/** Related theme functions needed for full customization */
relatedThemes: string[];
/** Token derivation rules. Key: 'childTheme.childToken' */
tokenDerivations?: Record<string, TokenDerivation>;
/** Free-form guidance for edge cases */
guidance?: string;
/**
* When true, the framework internally generates themes for relatedThemes from the parent's primary tokens
* LLMs should NOT generate separate child themes for relatedThemes.
*/
composed?: boolean;
}
export interface ComponentMetadata {
/** Platform-specific CSS selectors. Optional for `childOf` entries (theming scope comes from the parent). */
selectors?: ComponentSelectors;
/** Optional theme alias for components that reuse another component theme */
theme?: string;
/** Optional synonym aliases for search (synonyms only, not word-order permutations). */
aliases?: string[];
/** Parent component name for child sub-components. When set, theming scope uses the parent's selector instead of the child's own. Mutually exclusive with `compound`. */
childOf?: string;
/** Present only for components with variant-specific themes (e.g., button) */
variants?: string[];
/** Present only for compound components */
compound?: CompoundInfo;
}
export declare const COMPONENT_METADATA: Record<string, ComponentMetadata>;
/**
* List of variant theme names (derived from COMPONENT_METADATA at init).
*/
export declare const VARIANT_THEME_NAMES: Set<string>;
/**
* Get the selector(s) for a component on a specific platform.
* @param componentName - The component name
* @param platform - The target platform
* @returns Array of selectors (normalized to always return array), empty array if component not found or not available on platform
*/
export declare function getComponentSelector(componentName: string, platform: Platform): string[];
/**
* Get the selector(s) to use for theming scope.
* For child components (with `childOf`), returns the parent's selectors.
* For all other components, returns the component's own selectors.
* @param componentName - The component name
* @param platform - The target platform
* @returns Array of selectors for theming scope, empty array if not found
*/
export declare function getThemingSelector(componentName: string, platform: Platform): string[];
/**
* Check if a component is available on a specific platform.
* @param componentName - The component name
* @param platform - The target platform ('angular' or 'webcomponents')
* @returns True if the component is available on the platform, false otherwise
*/
export declare function isComponentAvailable(componentName: string, platform: Platform): boolean;
/**
* Get all component names available on a specific platform.
* @param platform - The target platform ('angular' or 'webcomponents')
* @returns Array of component names available on the platform
*/
export declare function getComponentsForPlatform(platform: Platform): string[];
/**
* Get platform availability for a component.
* @param componentName - The component name
* @returns Object indicating availability on each platform, or undefined if component not found
*/
export declare function getComponentPlatformAvailability(componentName: string): {
angular: boolean;
webcomponents: boolean;
} | undefined;
/**
* Check if a component has variants.
* @param componentName - The component name (e.g., 'button')
* @returns True if the component has variant-specific themes
*/
export declare function hasVariants(componentName: string): boolean;
/**
* Get variants for a component.
* @param componentName - The component name (e.g., 'button')
* @returns Array of variant names or empty array
*/
export declare function getVariants(componentName: string): string[];
/**
* Check if a component name is a variant theme.
* @param themeName - The theme name to check
* @returns True if this is a variant theme (e.g., 'flat-button')
*/
export declare function isVariantTheme(themeName: string): boolean;
/**
* Get compound component info if applicable.
* @param componentName - The component name
* @returns CompoundInfo or undefined
*/
export declare function getCompoundComponentInfo(componentName: string): CompoundInfo | undefined;
/**
* Check if a component is a compound component.
* @param componentName - The component name
* @returns True if this is a compound component
*/
export declare function isCompoundComponent(componentName: string): boolean;
/**
* Get token derivations for a specific child theme within a compound component.
* @param compoundName - The compound component name
* @param childThemeName - The child theme name (e.g., 'flat-button')
* @returns Record of 'childToken' -> TokenDerivation, or empty record if none exist
*/
export declare function getTokenDerivationsForChild(compoundName: string, childThemeName: string): Record<string, TokenDerivation>;