UNPKG

rynex

Version:

A minimalist TypeScript framework for building reactive web applications with no virtual DOM

65 lines 2.6 kB
/** * Rynex Utility Helpers * Utility functions for conditional rendering, fragments, etc. */ import { DOMChildren } from '../dom.js'; /** * Fragment - render children without wrapper */ export declare function fragment(...children: DOMChildren[]): HTMLElement[]; /** * Conditional rendering - show content when condition is true */ export declare function when(condition: boolean, content: () => HTMLElement | DOMChildren): HTMLElement | null; /** * Show/hide based on condition with reactive support * Usage: show(state.visible, element) or show(() => state.count > 0, element) * Properly toggles DOM presence (not just display:none) */ export declare function show(condition: boolean | (() => boolean), content: HTMLElement): HTMLElement; /** * Iterate over array and render items */ export declare function each<T>(items: T[], renderFn: (item: T, index: number) => HTMLElement, keyFn?: (item: T, index: number) => string | number): HTMLElement[]; /** * Switch case rendering */ export declare function switchCase<T>(value: T, cases: Record<string, () => HTMLElement>, defaultCase?: () => HTMLElement): HTMLElement | null; /** * Dynamic component - render component based on type */ export declare function dynamic(component: Function | string, props: any, ...children: DOMChildren[]): HTMLElement; /** * Portal - render content in a different DOM location */ export declare function portal(children: DOMChildren[], target: string | HTMLElement): HTMLElement; export declare function css(selector: string, styles: Partial<CSSStyleDeclaration> | string): void; /** * Lazy load component * Loads component dynamically when needed */ export declare function lazy<T>(loader: () => Promise<{ default: T; }>): () => Promise<T>; /** * Suspense boundary for async components * Shows fallback while loading */ export declare function suspense(props: { fallback: HTMLElement; onError?: (error: Error) => void; }, children: () => Promise<HTMLElement> | HTMLElement): HTMLElement; /** * Error boundary component * Catches errors in child components */ export declare function errorBoundary(props: { fallback: (error: Error) => HTMLElement; onError?: (error: Error) => void; }, children: HTMLElement | (() => HTMLElement)): HTMLElement; /** * Memoize component to prevent unnecessary re-renders * Caches result based on props equality */ export declare function memo<P extends Record<string, any>>(component: (props: P) => HTMLElement, areEqual?: (prevProps: P, nextProps: P) => boolean): (props: P) => HTMLElement; //# sourceMappingURL=utilities.d.ts.map