/** * 单元格框选器(Excel 式 rubber band): * 设计态在 box/dytable/gridtable 容器上拖拽框选单元格,自动计算选中的行列。 * 依赖单元格 DOM 标记:data-cell-id / data-row-index / data-col-index(由 box-col/dytable-col/gridtable-col 提供), * 以及容器根标记 data-container-id(由 group-container 提供)。框选范围限定在目标容器内: * 只收集"最近的 data-container-id 祖先即目标容器"的单元格,嵌套容器(单元格里的子容器)互不影响。 * 连续模式(continuous):单次框选,松开鼠标即结束并回调命中行列。 * 非连续模式(discrete):按单元格精确记忆(Excel 语义,每次框选只累积自己覆盖的格子), * 按住 Ctrl 多次框选累积(不按 Ctrl 为重选),点击"完成"结束。 * 操作模式(action):与非连续相同的累积选择,提示条展示调用方自定义的操作按钮 * (如合并单元格/拆分单元格/删除区域组件),点击操作后结束框选并回调 onAction。 */ export interface RubberBandCell { row: number; col: number; } export interface RubberBandAction { key: string; label: string; icon?: string; primary?: boolean; } export interface RubberBandOptions { containerId: string; mode: "continuous" | "discrete" | "action"; initialCells?: Array; actions?: Array; onFinish?: (rows: Array, cols: Array, cells: Array) => void; onAction?: (key: string, cells: Array) => void; onCancel?: () => void; } export declare class CellRubberBand { private static active; private opts; private cells; private overlay; private tipBar; private box; private dragging; private ctrlDrag; private startX; private startY; private selected; private finished; private constructor(); /**注入全局样式(选框/高亮/提示条),仅注入一次*/ private static injectStyle; /** * 启动框选;若已有活动实例先取消。返回是否成功启动(容器 DOM 找不到时返回 false)。 */ static start(opts: RubberBandOptions): boolean; /**取消当前框选(若无活动实例则忽略)*/ static cancelActive(): void; /**收集属于目标容器的单元格:向上找到最近的 data-container-id 祖先必须就是目标容器, * 从而排除嵌套在单元格内的子容器(其行列坐标相对于子容器,不属于本容器)*/ private collectCells; private run; private buildOverlay; /** * 构建提示条:视口顶部居中。工具栏行 = 操作说明 + 操作按钮(带图标); * 已选单元格描述(rb-desc)独立显示在工具栏行下方,不与按钮同行、不撑宽工具栏。 */ private buildTipBar; /**构建带图标的操作按钮(图标取自内置图标库)*/ private buildBtn; /**更新提示条中的已选单元格统计(内部 0-based,展示 +1),按行分组精确显示*/ private renderInfo; private onKeyDown; private onMouseDown; private onMouseMove; private onMouseUp; /**矩形与单元格相交:交集面积须超过单元格自身面积的一半才算选中(防止拖拽路径擦边误选)*/ private hitCells; private highlightSelected; private currentRect; private updateBox; /**操作模式:执行指定操作(先结束框选再回调,操作可能引起 DOM 结构变化)*/ private runAction; /**非连续模式点击"完成"*/ private finish; private finishWith; /**由选中的格子 key 集合提取行列集合与精确单元格列表*/ private extractResult; private cancel; private cleanup; }