import { Ref, ReactNode, ElementType, ComponentProps } from 'react'; import { Id, Obj } from '../types'; /** * 获取随机ID */ export declare function getRandomId(length?: number): string; /** * 拼接元素的类名 * @param classes */ export declare function clsx(...classes: any[]): string; /** * 驼峰转分隔 * @param str * @param separator */ export declare function humpToSegmented(str: string, separator?: string): string; /** * 将某个值统一转换成数组或null * @param value */ export declare function toArray(value?: undefined | null): null; export declare function toArray(value: T): T extends any[] ? T : T extends undefined | null ? null : T[]; /** * 判断某个值是否为已选中 * @param value 需要判断的值 * @param selectedValue 已选中的值,可能为undefined | V | V[] */ export declare function isSelected(value: V | undefined, selectedValue: V | V[] | undefined): boolean; /** * 对象深复制 */ export declare function cloneDeep(target: T): T; /** * 深度合并对象 */ export declare function mergeDeep(target: T, source: U): T & U; export declare function mergeDeep(target: T, source: U, source2: V): T & U & V; export declare function mergeDeep(target: T, source: U, source2: V, source3: W): T & U & V & W; export declare function mergeDeep(target: T, source: U, source2: V, source3: W, source4: X): T & U & V & W & X; export declare function mergeDeep(target: T, source: U, source2: V, source3: W, source4: X, source5: Y): T & U & V & W & X & Y; export declare function mergeDeep(target: T, source: U, source2: V, source3: W, source4: X, source5: Y, source6: Z): T & U & V & W & X & Y & Z; export declare function mergeDeep(target: object, ...sources: any[]): any; export declare function arrayShallowEqual(a: any[], b: any[]): boolean; export type OverflowEdge = 'top' | 'bottom' | 'left' | 'right'; /** * 判断元素是否完全在目标容器内,用于Popper组件 * @param target 目标元素 * @param container 容器 * @returns 'top' | 'bottom' | 'left' | 'right' | false */ export declare function isElementOverflowed(target: Element, container?: Element | null): OverflowEdge | false; /** * 克隆Ref * @param refs */ export declare function cloneRef(...refs: (Ref | undefined)[]): (ref: T | null) => void; /** * 判断变量是否为undefined或null * @param it */ export declare function isUnset(it: any): it is undefined | null; /** * 判断变量是否为Promise * @param it */ export declare function isPromise(it: any): it is Promise; /** * 获取promise的状态 * @param promise */ export declare function getPromiseState(promise: Promise): Promise<'pending' | 'fulfilled' | 'rejected'>; /** * 判断表单控件是否为空值 * @param value */ export declare function isNoValue(value: any): boolean; /** * 将节点用某个分隔符拼接起来,通常用于渲染多选项 * @param arr * @param callback * @param separator */ export declare function joinNodes(arr: T[], callback: (item: T, index: number) => ReactNode, separator?: ReactNode): (string | number | bigint | boolean | import("react").ReactElement> | Iterable | import("react").ReactPortal | Promise> | Iterable | null | undefined> | null | undefined)[]; /** * 修复数字输入框的值,包括最大值最小值限制,以及小数点精度 * @param value * @param param */ export type FixInputNumberParam = { min?: number; max?: number; precision?: number; }; export declare function fixInputNumber(value: string, { min, max, precision }: FixInputNumberParam): string; /** * 判断某个元素是否为另一个元素的子元素 * @param target * @param container */ export declare function isChildOf(target: Element | null, container?: Element | null): boolean; /** * 从某个元素开始,一直向上查找 * @param target * @param callback 返回true表示找到,会停止递归 */ export declare function findPredecessor(target: Element, callback: (parent: HTMLElement) => any): HTMLElement | null; /** * 监听某个元素的所有祖先元素的滚动事件 * @param target * @param listener * @returns {() => void} 返回一个清除函数 */ export declare function listenAllPredecessorsScroll(target: Element | Document, listener: (e: Event) => void): () => void; /** * 将数值限制在某个范围内 */ export declare function range(value: number, min?: number, max?: number): number; /** * 对象深度查找,也可赋值 * @param obj * @param keyPath * @param setValue * @param separator 分隔符,默认为`.` */ export declare function queryDeep(obj: any, keyPath: PropertyKey | PropertyKey[], setValue?: (oldValue: any) => T, separator?: string): T; export declare function queryDeep(obj: any, keyPath: PropertyKey | PropertyKey[], separator?: string, setValue?: (oldValue: any) => T): T; /** * 过滤对象中值为undefined属性 * @param obj * @param undefinedValue 可传入该值,用于替换undefined以删除其他属性 */ export declare function filterProperties>(obj: T, undefinedValue?: any): T; /** * 合并属性 */ type ExtendableProps = (T extends ElementType ? ComponentProps : T) & Obj; export declare function mergeComponentProps(...props: (Partial> | null | false | undefined)[]): ExtendableProps; export {};