import { Schema, PlainObject, FunctionPropertyNames } from '../types'; import { IIRendererStore } from '../store'; import { autobindMethod } from './autobind'; export declare function createObject(superProps?: { [propName: string]: any; }, props?: { [propName: string]: any; }, properties?: any): object; export declare function cloneObject(target: any, persistOwnProps?: boolean): any; /** * 给目标对象添加其他属性,可读取但是不会被遍历。 * @param target * @param props */ export declare function injectPropsToObject(target: any, props: any): any; export declare function extendObject(target: any, src?: any, persistOwnProps?: boolean): any; export declare function syncDataFromSuper(data: any, superObject: any, prevSuperObject: any, store: IIRendererStore, force: boolean): any; /** * 生成 8 位随机数字。 * * @return {string} 8位随机数字 */ export declare function guid(): string; export declare function findIndex(arr: Array, detect: (item?: any, index?: number) => boolean): number; export declare function getVariable(data: { [propName: string]: any; }, key: string, canAccessSuper?: boolean): any; export declare function setVariable(data: { [propName: string]: any; }, key: string, value: any): void; export declare function deleteVariable(data: { [propName: string]: any; }, key: string): void; export declare function hasOwnProperty(data: { [propName: string]: any; }, key: string): boolean; export declare function noop(): void; export declare function anyChanged(attrs: string | Array, from: { [propName: string]: any; }, to: { [propName: string]: any; }, strictMode?: boolean): boolean; export declare function rmUndefined(obj: PlainObject): PlainObject; export declare function isObjectShallowModified(prev: any, next: any, strictMode?: boolean, ignoreUndefined?: boolean): boolean; export declare function isArrayChildrenModified(prev: Array, next: Array, strictMode?: boolean): boolean; export declare function immutableExtends(to: any, from: any, deep?: boolean): any; export declare function makeColumnClassBuild(steps: number, classNameTpl?: string): (schema: Schema) => any; export declare function hasVisibleExpression(schema: { visibleOn?: string; hiddenOn?: string; visible?: boolean; hidden?: boolean; }): string | undefined; export declare function isVisible(schema: { visibleOn?: string; hiddenOn?: string; visible?: boolean; hidden?: boolean; }, data?: object): boolean; export declare function isUnfolded(node: any, config: { foldedField?: string; unfoldedField?: string; }): boolean; /** * 过滤掉被隐藏的数组元素 */ export declare function visibilityFilter(items: any, data?: object): any; export declare function isDisabled(schema: { disabledOn?: string; disabled?: boolean; }, data?: object): boolean | "" | undefined; export declare function hasAbility(schema: any, ability: string, data?: object, defaultValue?: boolean): boolean; export declare function makeHorizontalDeeper(horizontal: { left: string; right: string; offset: string; leftFixed?: any; }, count: number): { left: string | number; right: string | number; offset: string | number; leftFixed?: any; }; export declare function promisify(fn: T): (...args: Array) => Promise & { raw: T; }; export declare function getScrollParent(node: HTMLElement): HTMLElement | null; /** * Deep diff between two object, using lodash * @param {Object} object Object compared * @param {Object} base Object to compare with * @return {Object} Return a new object who represent the diff */ export declare function difference(object: T, base: U, keepProps?: Array): { [propName: string]: any; }; export declare const padArr: (arr: Array, size?: number) => Array>; export declare function __uri(id: string): string; export declare function isObject(obj: any): any; export declare function isBreakpoint(str: string): boolean; export declare function until(fn: () => Promise, when: (ret: any) => boolean, getCanceler: (fn: () => any) => void, interval?: number): Promise; export declare function omitControls(controls: Array, omitItems: Array): Array; export declare function isEmpty(thing: any): boolean; /** * 基于时间戳的 uuid * * @returns uniqueId */ export declare const uuid: () => string; export declare const uuidv4: () => string; export interface TreeItem { children?: TreeArray; [propName: string]: any; } export interface TreeArray extends Array { } /** * 类似于 arr.map 方法,此方法主要针对类似下面示例的树形结构。 * [ * { * children: [] * }, * // 其他成员 * ] * * @param {Tree} tree 树形数据 * @param {Function} iterator 处理函数,返回的数据会被替换成新的。 * @return {Tree} 返回处理过的 tree */ export declare function mapTree(tree: Array, iterator: (item: T, key: number, level: number, paths: Array) => T, level?: number, depthFirst?: boolean, paths?: Array): any[]; /** * 遍历树 * @param tree * @param iterator */ export declare function eachTree(tree: Array, iterator: (item: T, key: number, level: number) => any, level?: number): void; /** * 在树中查找节点。 * @param tree * @param iterator */ export declare function findTree(tree: Array, iterator: (item: T, key: number, level: number, paths: Array) => any): T | null; /** * 在树中查找节点, 返回下标数组。 * @param tree * @param iterator */ export declare function findTreeIndex(tree: Array, iterator: (item: T, key: number, level: number, paths: Array) => any): Array | undefined; export declare function getTree(tree: Array, idx: Array | number): T | undefined | null; /** * 过滤树节点 * * @param tree * @param iterator */ export declare function filterTree(tree: Array, iterator: (item: T, key: number, level: number) => any, level?: number, depthFirst?: boolean): T[]; /** * 判断树中每个节点是否满足某个条件。 * @param tree * @param iterator */ export declare function everyTree(tree: Array, iterator: (item: T, key: number, level: number, paths: Array, indexes: Array) => boolean, level?: number, paths?: Array, indexes?: Array): boolean; /** * 判断树中是否有某些节点满足某个条件。 * @param tree * @param iterator */ export declare function someTree(tree: Array, iterator: (item: T, key: number, level: number, paths: Array) => boolean): boolean; /** * 将树打平变成一维数组,可以传入第二个参数实现打平节点中的其他属性。 * * 比如: * * flattenTree([ * { * id: 1, * children: [ * { id: 2 }, * { id: 3 }, * ] * } * ], item => item.id); // 输出位 [1, 2, 3] * * @param tree * @param mapper */ export declare function flattenTree(tree: Array): Array; export declare function flattenTree(tree: Array, mapper: (value: T, index: number) => U): Array; /** * 操作树,遵循 imutable, 每次返回一个新的树。 * 类似数组的 splice 不同的地方这个方法不修改原始数据, * 同时第二个参数不是下标,而是下标数组,分别代表每一层的下标。 * * 至于如何获取下标数组,请查看 findTreeIndex * * @param tree * @param idx * @param deleteCount * @param ...items */ export declare function spliceTree(tree: Array, idx: Array | number, deleteCount?: number, ...items: Array): Array; /** * 计算树的深度 * @param tree */ export declare function getTreeDepth(tree: Array): number; /** * 从树中获取某个值的所有祖先 * @param tree * @param value */ export declare function getTreeAncestors(tree: Array, value: T, includeSelf?: boolean): Array | null; /** * 从树中获取某个值的上级 * @param tree * @param value */ export declare function getTreeParent(tree: Array, value: T): T | null; export declare function ucFirst(str?: string): string; export declare function lcFirst(str?: string): string; export declare function camel(str?: string): string; export declare function getWidthRate(value: any, strictMode?: boolean): number; export declare function getLevelFromClassName(value: string, defaultValue?: string): string; export declare function string2regExp(value: string, caseSensitive?: boolean): RegExp; export declare function pickEventsProps(props: any): any; export declare const autobind: typeof autobindMethod; export declare const bulkBindFunctions: (context: T, funNames: FunctionPropertyNames[]) => void; export declare function sortArray(items: Array, field: string, dir: -1 | 1): Array; export declare function hasFile(object: any): boolean; export declare function qsstringify(data: any, options?: any, keepEmptyArray?: boolean): string; export declare function object2formData(data: any, options?: any, fd?: FormData): any; export declare function chainFunctions(...fns: Array<(...args: Array) => void>): (...args: Array) => void; export declare function chainEvents(props: any, schema: any): any; export declare function mapObject(value: any, fn: Function): any; export declare function loadScript(src: string): Promise; export declare class SkipOperation extends Error { } /** * 将例如像 a.b.c 或 a[1].b 的字符串转换为路径数组 * * @param string 要转换的字符串 */ export declare const keyToPath: (string: string) => string[]; /** * 深度查找具有某个 key 名字段的对象,实际实现是 internalFindObjectsWithKey,这里包一层是为了做循环引用检测 * @param obj * @param key */ export declare function findObjectsWithKey(obj: any, key: string): any[]; /** * 获取浏览器滚动条宽度 https://stackoverflow.com/a/13382873 */ export declare function getScrollbarWidth(): number;