use-styled
Version:
A powerful library for creating React/React Native components
34 lines • 1.98 kB
TypeScript
import type { Component, Config, ComponentProps } from './types';
import { type ClassValue } from 'clsx';
type AnyObject = Record<string, any>;
type StyleValue = object | undefined | null;
type StyleObject = AnyObject;
/**
* Merges multiple style objects (plain objects).
* Later objects in the list overwrite earlier keys.
* Returns a single object or undefined if merging results in an empty object or only null/undefined entries.
* NOTE: In React Native, if you need support for arrays/IDs,
* use StyleSheet.flatten BEFORE passing to this function.
*/
export declare const mergeStyles: (...styles: Array<StyleValue>) => StyleObject | undefined;
/**
* Merges CSS classes using clsx and tailwind-merge. Essential for Tailwind/NativeWind.
*/
export declare function cn(...inputs: ClassValue[]): string | undefined;
/**
* Extracts and merges props defined for active variants.
* Optimized version merging style/className iteratively.
*/
export declare const resolveVariantProps: <T extends Component, C extends Config>(configVariants: C["variants"], activeVariants: Record<string, string | boolean | undefined>) => Partial<ComponentProps<T>>;
/**
* Extracts and merges props defined for active compound variants.
*/
export declare const resolveCompoundVariantProps: <T extends Component, C extends Config>(compoundVariantsConfig: C["compoundVariants"], activeVariants: Record<string, string | boolean | undefined>) => Partial<ComponentProps<T>>;
/**
* Main function to merge all prop sources in the correct priority order.
* V2 Feature: Automatically composes functions instead of overwriting them.
* Execution order: base → variants → compounds → direct props
*/
export declare const mergeFinalProps: <T extends Component>(base: Partial<ComponentProps<T>> | undefined, variants: Partial<ComponentProps<T>>, compounds: Partial<ComponentProps<T>>, direct: Partial<ComponentProps<T>>) => ComponentProps<T>;
export {};
//# sourceMappingURL=utils.d.ts.map