@hanamura/react-containers
Version:
Flexible container components for React
36 lines (35 loc) • 1.63 kB
TypeScript
import { Queries, AdaptiveOptions, SpacingValue } from './types';
/**
* Normalizes spacing values to CSS-compatible string format
*
* @param value - A spacing value that can be a single value or an array of values
* @returns A CSS-compatible string with proper units
*
* Examples:
* - normalizeSpacingValue(16) => "16px"
* - normalizeSpacingValue("1rem") => "1rem"
* - normalizeSpacingValue([16]) => "16px"
* - normalizeSpacingValue([8, 16]) => "8px 16px"
* - normalizeSpacingValue(["1rem"]) => "1rem"
* - normalizeSpacingValue(["1rem", 8]) => "1rem 8px"
*/
export declare function normalizeSpacingValue<S extends string | number>(value: SpacingValue<S> | undefined): string | undefined;
/**
* Hook for creating responsive container components that adapt to breakpoints
*
* This hook handles media query matching and option merging to enable
* responsive behavior in container components.
*
* @param options - Base options applied to all breakpoints
* @param queries - Array of media query definitions with associated keys
* @param adaptiveOptions - Context-specific options that override defaults at different breakpoints
* @returns Object containing active context key and merged options
*
* @typeParam K - Type for breakpoint keys (e.g. 'mobile', 'tablet', 'desktop')
* @typeParam O - Type for component-specific options
*/
export declare function useAdaptiveContainer<K extends string = string, O extends Record<string, any> = Record<string, any>>(options?: O, queries?: Queries<K>, adaptiveOptions?: AdaptiveOptions<K, O>): {
activeContext: K | null;
options: O;
initialized: boolean;
};