import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'; import type { FlexTokens } from '../flex/tokens.types'; import type { ThemeState } from '../flex/themeState.types'; type AnyStyle = ViewStyle | ImageStyle | TextStyle; /** * Ordered hierarchy levels. Each level contains mutually exclusive states in * precedence order. */ export type StateLevels = readonly (readonly string[])[]; /** * Every state declared in a hierarchy. */ export type StateNames = Levels[number][number]; type StateEntries = Levels extends readonly [ infer Head extends readonly string[], ...infer Tail extends StateLevels ] ? Partial>> & StateEntries : unknown; /** * Every valid ordered state path, including paths that skip hierarchy levels * to provide fallback styles. */ export type StatePath = Levels extends readonly [ infer Head extends readonly string[], ...infer Tail extends StateLevels ] ? Head[number] | StatePath | `${Head[number]}.${StatePath & string}` : never; /** * A flattened style set containing the base style and every explicitly * defined state path. */ export type BranchedStyles = { base: StyleType; } & Partial, StyleType>>; /** * A hierarchical style definition. A state can contain states from any later * hierarchy level, while later-level states can also appear at the base as * fallbacks. */ export type StyleDefinition = StyleType & StateEntries; /** * Source of active states, either an array of names or an object whose truthy * properties indicate active states. */ export type StateSource = Partial> | readonly States[]; /** * Factory function for generating a style definition from theme tokens. */ export type StyleDefFromTokens = (tokens: FlexTokens) => StyleDefinition; /** * Picks the first active state according to the supplied precedence order. */ export declare function getActiveState(source: StateSource, states?: readonly States[]): States | undefined; /** * Selects the most specific defined state path. Paths with more active states * win, followed by paths containing states from deeper hierarchy levels. */ export declare function pickActiveStyle(state: StateSource>, stateLevels: Levels, styles: BranchedStyles): StyleType; /** * Creates a state-to-level lookup and rejects ambiguous hierarchies. */ export declare function createStateLevelMap(stateLevels: StateLevels): ReadonlyMap; /** * Flattens a hierarchical style definition and applies ancestor inheritance * to every explicitly defined state path. */ export declare function styleDefinitionToBranchedStyles(styles: StyleDefinition, stateLevels: Levels): BranchedStyles; /** * Creates a state style getter that lazily flattens and caches one definition. */ export declare function getStateStyleFactory(definition: StyleDefinition, stateLevels: Levels): (source: StateSource>) => StyleType; /** * Creates a state style getter that resolves and caches one definition per * ThemeState. */ export declare function getThemedStateStyleFactory(name: string, factory: StyleDefFromTokens, stateLevels: Levels): (state: ThemeState, source: StateSource>) => StyleType; export {}; //# sourceMappingURL=branchedStyle.d.ts.map