d-render
Version:
基于 Element Plus 二次封装的数据驱动渲染组件库 - 表单、搜索表单、表格配置化渲染
16 lines (15 loc) • 1.11 kB
TypeScript
import { type IAnyObject } from '@d-render/shared';
import type { ITreeProps } from './table-props';
export type TRowKeyGetter = (row: IAnyObject) => unknown;
/** 兼容 rowKey 为 string 或 function(el-table 原生 row-key 支持两种形式) */
export declare const resolveRowKeyGetter: (rowKey: unknown) => TRowKeyGetter | undefined;
export type TRowMatcher = (row: IAnyObject) => boolean;
/**
* 基于 model 预建 Set 索引,返回一个 O(1) 的行匹配函数。
* 避免对每一行都在 model 上做线性扫描(model 在 reserveSelection 场景下是跨页累计的选中列表,可能很大),
* 将整体匹配复杂度从 O(pageSize * modelSize) 降为 O(pageSize + modelSize)。
* 匹配优先级:对象引用相同;其次按 rowKey 匹配。
*/
export declare const createRowMatcher: (model: IAnyObject[], rowKeyGetter?: TRowKeyGetter) => TRowMatcher;
/** 展开 treeProps.children 的所有层级行,非树形表格(未配置 children)时原样返回 */
export declare const flattenTreeRows: (data?: IAnyObject[], treeProps?: ITreeProps) => IAnyObject[];