@lidick/mt-react-view
Version:
A React component library
192 lines (191 loc) • 5.23 kB
TypeScript
/**
* 工具js
*/
/**
* 判断是否是数字
*
* @param value
*/
export declare const isNumber: (value: any) => boolean;
/**
* 是否是字符串
*
* @param str
*/
export declare const isString: (str: any) => boolean;
/**
* 是否是object
*
* @param obj
*/
export declare const isObject: (obj: any) => boolean;
/**
* 判断是否是数组
*
* @param arr
*/
export declare const isArray: (arr: any) => boolean;
/**
* 判断是否是方法
*
* @param arr
*/
export declare const isFunction: (arr: any) => boolean;
/**
* 判断是否是空|0|'0'|undefined
* @param str
*/
export declare const isZeroType: (str: any) => boolean;
/**
* 判断是否是空字符串
*
* @param str
*/
export declare const isStringEmpty: (str: string | null | undefined) => boolean;
/**
* 判断是否是空数字
*
* @param str
*/
export declare const isNumberEmpty: (str: number | undefined | null) => boolean;
/**
* 判断对象是否为空
*
* @param obj
*/
export declare const isEmptyObject: (obj: any) => boolean;
/**
* 判断对象是否为空
*
* @param obj
*/
export declare const isObjectEmpty: (obj: any) => boolean;
/**
* 判断是否是空数组
*
* @param arr
*/
export declare const isArrayEmpty: (arr: any) => boolean;
/**
* 判断一个对象的每个值是否都不为空 (空字符串、null、undefined 会被视为无效,0 会被视为有效) 满足为 true,否则为 false
*
* @param obj
*/
export declare const isObjectValuesValid: (obj: Record<string, any>) => boolean;
/**
* 清除字符串中的空字符串
*
* @param val
*/
export declare const clearEmpty: (val: string) => string;
/**
* mt防抖
*
* @param fn
* @param delay
*/
export declare const mtDebounce: (fn: Function, delay: number) => (this: any, ...args: any) => void;
/**
* mt节流
*
* @param fn
* @param delay
*/
export declare const mtThrottle: (fn: Function, delay: number) => (this: any, ...args: any) => void;
/**
* 文件uid 类型的唯一 ID
*/
export declare const genFileId: () => number;
/**
* 遍历出对象中的key
*
* @param arr
*/
export declare const keysOf: (arr: any[]) => string[];
/**
* 判断是否是浏览器环境
*/
export declare const checkIsBrowser: () => boolean;
/**
* 判断是浏览器客户端环境
*/
export declare const isClient: () => boolean;
/**
* 判断是否是火狐浏览器
* typeof InstallTrigger !== 'undefined' 是一个特定于火狐浏览器的标识符,它在火狐中存在,但在其他浏览器中不存在。
*/
export declare const isFirefox: () => boolean;
/**
* 检测是否是mobile
*/
export declare const checkIsMobile: (userAgent?: string) => boolean;
/**
* 判断是否是ios设备
*/
export declare const checkIsiOS: (userAgent?: string) => boolean;
/**
* 检测是否是安卓
*/
export declare const checkIsAndroid: (userAgent?: string) => boolean;
/**
* 检测是否是win
*/
export declare const checkIsWin: (userAgent?: string) => boolean;
/**
* 检测是否是mac
*/
export declare const checkIsMac: (userAgent?: string) => boolean;
/**
* 是否是浏览器环境
*/
export declare const isBrowser: boolean;
export declare const isWin: boolean;
export declare const isMac: boolean;
export declare const isMobile: boolean;
export declare const isAndroid: boolean;
export declare const isiOS: boolean;
export declare const isDesktop: boolean;
/**
* 创建自定义类的样式表
* 并返回样式类名和样式表
*
* @param vars 样式变量集合, 即css变量名和值的对象
* @param className 绑定的样式类名
*/
export declare function createCustomClassSheet(vars: Record<string, any>, className: string): {
className: string;
sheet?: CSSStyleSheet;
};
/**
* 设置指定class或者伪选择器下的css变量值
*
* @param keyAndValues 样式变量集合,即css变量名和值的对象
* @param cssSelectorText 指定的class选择器(比如.xxxx)或者伪选择器(比如:root) 默认是:root
* @param targetSheet 自定义样式表对象
*/
export declare const setAssignCssSelectorVariable: (keyAndValues: Record<string, any>, cssSelectorText?: string, targetSheet?: any) => void;
/**
* 移除指定class或者伪选择器下的css变量值
*
* @param varNames 样式变量集合,即css变量名数组
* @param cssSelectorText 指定的class选择器(比如.xxxx)或者伪选择器(比如:root) 默认是:root
* @param targetSheet 自定义样式表对象
*/
export declare const removeAssignCssSelectorVariable: (varNames: string[], cssSelectorText?: string, targetSheet?: any) => void;
/**
* 重置指定class或者伪选择器下的css变量
*
* @param cssSelectorText 指定的class选择器(比如.xxxx)或者伪选择器(比如:root) 默认是:root
* @param targetSheet 自定义样式表对象
*/
export declare function resetAssignCssSelectorVariable(cssSelectorText?: string, targetSheet?: any): void;
/**
* 获取可视窗口高度
*
* @param isBrowserView 是否是获取浏览器窗口内容区的高度 否则返回body或html的高度,取最小的
*/
export declare const getClientHeight: (isBrowserView?: boolean) => number;
/**
* 获取可视窗口宽度
*/
export declare const getClientWidth: () => number;