UNPKG

mithril-materialized

Version:
88 lines (87 loc) 3.29 kB
import { SortSelected } from './select'; import { InputOption } from '.'; /** * Create a unique ID * @see https://stackoverflow.com/a/2117523/319711 * * @returns id followed by 8 hexadecimal characters. */ export declare const uniqueId: () => string; /** * Create a GUID * @see https://stackoverflow.com/a/2117523/319711 * * @returns RFC4122 version 4 compliant GUID */ export declare const uuid4: () => string; /** Check if a string or number is numeric. @see https://stackoverflow.com/a/9716488/319711 */ export declare const isNumeric: (n: string | number) => boolean; /** * Sort options array based on sorting configuration * @param options - Array of options to sort * @param sortConfig - Sort configuration: 'asc', 'desc', 'none', or custom comparator function * @returns Sorted array (or original if 'none' or undefined) */ export declare const sortOptions: <T extends string | number>(options: InputOption<T>[], sortConfig?: SortSelected<T>) => { id: T; label?: string; }[]; /** * Pad left, default width 2 with a '0' * * @see http://stackoverflow.com/a/10073788/319711 * @param {(string | number)} n * @param {number} [width=2] * @param {string} [z='0'] * @returns */ export declare const padLeft: (n: string | number, width?: number, z?: string) => string; export declare const getDropdownStyles: (inputRef?: HTMLElement | null, overlap?: boolean, options?: { /** ID property of the selected item */ id?: string | number; /** Label to show in the dropdown */ label?: string; /** Optional group */ group?: string; /** Can we select the item */ disabled?: boolean; /** Add a divider */ divider?: boolean; }[], isDropDown?: boolean) => any; /** * Generate a range of numbers from a to and including b, i.e. [a, b] * @example: console.log(range(5, 10)); // [5, 6, 7, 8, 9, 10] */ export declare const range: (a: number, b: number) => number[]; /** * Creates or retrieves a portal container appended to document.body. * Uses reference counting to manage container lifecycle. * * @param id - Unique identifier for the portal container * @param zIndex - Z-index for the portal container (default: 1004, above modals at 1003) * @returns The portal container element */ export declare const getPortalContainer: (id: string, zIndex?: number) => HTMLElement; /** * Decrements reference count and removes portal container if no longer needed. * * @param id - Portal container identifier */ export declare const releasePortalContainer: (id: string) => void; /** * Renders a Mithril vnode into a portal container using m.render(). * This allows components to render outside their parent DOM hierarchy, * useful for modals and pickers that need to escape stacking contexts. * * @param containerId - Portal container identifier * @param vnode - Mithril vnode to render * @param zIndex - Z-index for portal container (default: 1004) */ export declare const renderToPortal: (containerId: string, vnode: any, zIndex?: number) => void; /** * Clears portal content and releases container reference. * If this is the last reference, the container will be removed from the DOM. * * @param containerId - Portal container identifier */ export declare const clearPortal: (containerId: string) => void;