- 产物替换为 funjiaui.es.js / funjiaui.cjs.js / funjiaui.umd.js - style.css 更新,新增 index.d.ts 与各组件类型声明目录 - 移除旧产物 um_table.es.js(1.0.0 的 ES 包,历史与 v1.0.0 标签仍可回溯) - package.json 补齐 module / types / unpkg / jsdelivr / files 字段, 并将 vue、element-plus、@element-plus/icons-vue 声明为 peerDependencies - 新增 README 说明产物清单与用法
81 lines
3.9 KiB
TypeScript
81 lines
3.9 KiB
TypeScript
import type { VNode } from "vue";
|
|
import type { IToolbar, TDecoratorKey, TEvent, TOperateType } from "../types";
|
|
import { type IEventTask, type TFireHook } from "./events";
|
|
/**
|
|
* 列 / 操作列 / 工具栏的装配逻辑。
|
|
*
|
|
* 改造前这段"扫描类元数据 -> 拼 h() 节点 -> 造事件闭包"的代码
|
|
* 全写在 UmByClass.vue 的 render() 里(200+ 行),
|
|
* 每次渲染都要重建一遍,且无法复用、无法单测。这里抽成纯函数。
|
|
*/
|
|
/** 收集数据列 VNode(按 sort 升序) */
|
|
export declare const collectDataColumns: (target: any) => VNode[];
|
|
/** 操作列分组:同一 id(缺省用 type)的多个方法会聚合到同一个按钮上 */
|
|
export interface IOperateGroup {
|
|
type: TOperateType;
|
|
sort: number;
|
|
title?: any;
|
|
isShow?: (rowData: any) => boolean;
|
|
tasks: IEventTask[];
|
|
}
|
|
/**
|
|
* 按 id(缺省用 type)聚合操作列配置。
|
|
*
|
|
* 说明:`@TableColumnMethodDecorator` 允许给多个方法配同一个 `type`,
|
|
* 分别声明 `es: "onBefore" / "onNow" / "onAfter"`,运行时串成一条链,
|
|
* 从而做到"先取详情 -> 再弹窗 -> 最后提交"。
|
|
*/
|
|
export declare const collectOperateGroups: (target: any) => IOperateGroup[];
|
|
/**
|
|
* 是否需要渲染操作列。
|
|
*
|
|
* 原判断:`(operates.length > 0 && !targetInstance.isShowOperate) || targetInstance?.isShowOperate?.()`
|
|
* - 存在操作按钮但 `isShowOperate()` 返回 false 时,因为 `!undefined` 为真仍会渲染出空操作列;
|
|
* - 没有操作按钮但 `isShowOperate()` 返回 true 时会渲染出一个空列。
|
|
* 这里改成明确的语义:有按钮 && (未配置 isShowOperate 或其为真)。
|
|
*/
|
|
export declare const resolveShowOperate: (target: any, hasOperate: boolean) => boolean;
|
|
/** 解析操作列宽度(支持实例属性与类静态属性两种写法) */
|
|
export declare const resolveOperateWidth: (target: any, fallback?: number | string) => number | string;
|
|
export interface IBuildOperateColumnOptions {
|
|
fire: TFireHook;
|
|
/** 透传给操作事件的行数据集合 */
|
|
tableData?: any[];
|
|
width?: number | string;
|
|
/** 需要延后执行 onAfter 的按钮类型,见 IDeferOptions */
|
|
deferAfterTypes?: string[];
|
|
}
|
|
/**
|
|
* 默认的"弹窗确认型"按钮类型。
|
|
*
|
|
* 这些按钮的 `onAfter` 会被摘出主事件链,由组件在弹窗给出结果后补跑。
|
|
* 单独抽成常量是为了让配置体检(`./diagnose`)和组件用同一份清单判断
|
|
* "这个按钮是不是应该有 onAfter" —— 两边各写一份字符串迟早会对不上。
|
|
*/
|
|
export declare const DEFAULT_DEFER_TYPES: string[];
|
|
/** 生成操作列 VNode;没有操作按钮时返回 null */
|
|
export declare const buildOperateColumn: (groups: IOperateGroup[], options: IBuildOperateColumnOptions) => VNode | null;
|
|
/** 工具栏收集结果 */
|
|
export interface IToolbarCollectResult {
|
|
toolbars: IToolbar[];
|
|
events: TEvent[];
|
|
}
|
|
/**
|
|
* 收集某个装饰器下、指定 `type` 的全部方法,按优先级降序返回。
|
|
*
|
|
* 用于"弹窗确定后补跑 onAfter"这类只需要部分阶段的场景:
|
|
* 同一个按钮的多个方法(不同 `es`)都要收进来,但只执行其中某几个阶段。
|
|
*/
|
|
export declare const collectTypedTasks: (target: any, decoratorKey: TDecoratorKey, type: string) => IEventTask[];
|
|
/**
|
|
* 收集工具栏按钮与对应事件。
|
|
*
|
|
* 关于 `rerunOnAfterFalsy`:原实现靠它实现"弹窗被取消 / 接口失败后重来一轮",
|
|
* 但事件链在 onAfter 返回假值时会用 `i -= 2` 回到第一阶段,若业务方法持续返回假值
|
|
* 就会把弹窗反复重开。改造后弹窗改为"挂起事件链、确认后再继续"(见 deferAfterTypes),
|
|
* 不再需要这个重跑机制,这里默认关闭,只在显式要求时启用。
|
|
*/
|
|
export declare const collectToolbar: (target: any, fire: TFireHook, options?: {
|
|
deferAfterTypes?: string[];
|
|
}) => IToolbarCollectResult;
|