arthub-table 0.2.88 → 0.2.90-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,6 +76,18 @@ export interface DataGridInitOptions {
76
76
  theme?: string | Record<string, any>;
77
77
  /** WfState Viewer 显示样式:'icon'=图标+文字(默认),'tag'=色块标签 */
78
78
  wfStateStyle?: 'icon' | 'tag';
79
+ /**
80
+ * Reminder 蓝色三角的锚点位置(4 个角可选),默认 'top-right'(右上角)。
81
+ * 由业务侧按场景覆盖(例如 AssetMatrix 和平玩法传 'top-left' 把角标挪到左上角)。
82
+ * 三角形状会随 anchor 等效镜像翻转,保持视觉对称。
83
+ */
84
+ remindAnchor?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
85
+ /**
86
+ * Reminder 蓝色三角的点击命中热区边长(像素,正方形)。
87
+ * 默认沿用可视三角边长 18(保持历史行为),业务侧可放大到 20/24 以便用户命中触发弹窗。
88
+ * 命中区是以 anchor 对应角为起点、朝单元格内部延伸的 size×size 正方形(独立于可视三角)。
89
+ */
90
+ remindHitAreaSize?: number;
79
91
  /** 嵌套表格数据源字段名,默认 '$$pipelineView$$' */
80
92
  pipelineViewKey?: string;
81
93
  /** 嵌套表格折叠时默认显示行数,默认 3 */
@@ -3,6 +3,7 @@ import Validator from "./Validator";
3
3
  import NestedGrid from "./NestedGrid";
4
4
  import type DataGrid from "./DataGrid";
5
5
  import type { ColumnConfig } from "./types";
6
+ import { type RemindAnchor } from "./constants";
6
7
  import { type CellViewerData, type ViewerRenderContext } from "./viewers";
7
8
  interface Column extends ColumnConfig {
8
9
  [key: string]: any;
@@ -143,8 +144,14 @@ declare class Cell extends Context {
143
144
  [key: string]: any;
144
145
  } | null;
145
146
  /**
146
- * 判断鼠标坐标是否在蓝色提醒三角区域内(右上角 18x18 三角形)
147
- * 三角区域为:(right-18, top), (right, top), (right, top+18) 构成的直角三角形
147
+ * 判断鼠标坐标是否在蓝色提醒三角的命中热区内。
148
+ *
149
+ * 命中热区是以 anchor 对应角为起点、朝单元格内部延伸的 size×size 正方形。
150
+ * 热区尺寸由 grid.remindHitAreaSize 控制(默认与可视三角边长一致 18px),
151
+ * 业务侧可按场景放大到 20/24 以便用户点击触发弹窗。
152
+ *
153
+ * 注意:热区是矩形而非三角,这样热区放大时在整个角都可命中、点击体验更好。
154
+ *
148
155
  * @param mouseX 鼠标在 canvas 上的 x 坐标(已经过 scrollX 修正的坐标)
149
156
  * @param mouseY 鼠标在 canvas 上的 y 坐标(已经过 scrollY 修正的坐标)
150
157
  * @param cellX 单元格左上角 x(已含 scroll/fixed 偏移)
@@ -152,4 +159,34 @@ declare class Cell extends Context {
152
159
  */
153
160
  isInsideReminderTriangle(mouseX: number, mouseY: number, cellX: number, cellY: number): boolean;
154
161
  }
162
+ /**
163
+ * 计算 reminder 三角形在指定 anchor 下的 3 个顶点。
164
+ * 三角形是直角三角,直角始终贴在 anchor 对应的角上,斜边指向单元格内部(等效镜像翻转)。
165
+ *
166
+ * @param x 单元格左上角 x
167
+ * @param y 单元格左上角 y
168
+ * @param width 单元格宽
169
+ * @param height 单元格高
170
+ * @param size 三角边长
171
+ * @param anchor 锚点位置
172
+ */
173
+ declare function computeReminderTrianglePoints(x: number, y: number, width: number, height: number, size: number, anchor: RemindAnchor): number[][];
174
+ /**
175
+ * 计算 reminder 点击命中热区(正方形)。
176
+ * 热区以 anchor 对应角为起点、朝单元格内部延伸 size 长度。
177
+ *
178
+ * @param cellX 单元格左上角 x
179
+ * @param cellY 单元格左上角 y
180
+ * @param width 单元格宽
181
+ * @param height 单元格高
182
+ * @param size 热区边长
183
+ * @param anchor 锚点位置
184
+ */
185
+ declare function computeReminderHitRect(cellX: number, cellY: number, width: number, height: number, size: number, anchor: RemindAnchor): {
186
+ x: number;
187
+ y: number;
188
+ width: number;
189
+ height: number;
190
+ };
191
+ export { computeReminderTrianglePoints, computeReminderHitRect };
155
192
  export default Cell;
@@ -12,7 +12,8 @@ import Histories from "./History";
12
12
  import { StyleManager, type TableTheme } from "./StyleManager";
13
13
  import EdgeScroller from "./EdgeScroller";
14
14
  import { type HeaderConfig } from "./util";
15
- import { type FooterCellClickInfo, type FooterData, type FooterCellData, type GroupHeaderCellClickInfo, type GroupHeaderCellHoverInfo, type FooterStatRefreshInfo, type GroupHeaderStatRefreshInfo } from "./types";
15
+ import { type RemindAnchor } from "./constants";
16
+ import { type FooterCellClickInfo, type FooterData, type FooterCellData, type GroupHeaderCellClickInfo, type GroupHeaderCellHoverInfo, type FooterStatRefreshInfo, type GroupHeaderStatRefreshInfo, type ConditionalStyle, type ConditionalStylePatch, type ActiveCellInfo } from "./types";
16
17
  import { type PerformanceMonitor } from "./PerformanceMonitor";
17
18
  interface Column extends HeaderConfig {
18
19
  children?: Column[];
@@ -137,6 +138,8 @@ interface RowContextMenuInfo {
137
138
  clientX: number;
138
139
  /** 鼠标屏幕 Y 坐标 */
139
140
  clientY: number;
141
+ /** 右键发生时的不可变源单元格快照,供“快速生成规则”使用。 */
142
+ sourceCell?: ActiveCellInfo;
140
143
  /** Canvas 行索引(供外部通过 isRowCheckedByIndex 查询选中状态) */
141
144
  _canvasRowIndex?: number;
142
145
  /** 右键行是否处于选中(checked)状态 */
@@ -146,6 +149,20 @@ interface RowContextMenuInfo {
146
149
  /** Row 对象内部的 _rowId,和 selectedRowIds 中的 key 格式一致 */
147
150
  _internalRowId?: string;
148
151
  }
152
+ /** Row hover action context. sourceCell is limited to the hovered row. */
153
+ export interface RowHoverActionInfo {
154
+ rowData: RowData;
155
+ rowIndex: number;
156
+ sourceCell?: ActiveCellInfo;
157
+ position: {
158
+ x: number;
159
+ y: number;
160
+ width: number;
161
+ height: number;
162
+ };
163
+ clientX?: number;
164
+ clientY?: number;
165
+ }
149
166
  export interface DataGridOptions {
150
167
  width?: number | string;
151
168
  height?: number | string;
@@ -429,6 +446,10 @@ export interface DataGridOptions {
429
446
  }) => void;
430
447
  /** 行右键菜单回调:行区域右键时触发 */
431
448
  onRowContextMenu?: (info: RowContextMenuInfo) => void;
449
+ /** 行 hover 时是否展示通用“更多”操作。 */
450
+ rowHoverAction?: boolean;
451
+ /** 行 hover 操作点击回调。 */
452
+ onRowHoverActionClick?: (info: RowHoverActionInfo) => void;
432
453
  onModuleOverflowClick?: (modules: any[], rowData: any, rowIndex: number, colIndex: number) => void;
433
454
  onAddRow?: (groupInfo?: any) => void;
434
455
  /** 表头排序图标点击回调 */
@@ -673,6 +694,18 @@ export interface DataGridOptions {
673
694
  };
674
695
  rowData: Record<string, any>;
675
696
  }) => void;
697
+ /**
698
+ * Reminder 蓝色三角的锚点位置(4 个角可选),默认 'top-right'(右上角)。
699
+ * 由业务侧按场景覆盖(如 AssetMatrix 和平玩法传 'top-left' 把角标挪到左上角)。
700
+ * 三角形状会随 anchor 做等效镜像翻转,保持视觉对称。
701
+ */
702
+ remindAnchor?: RemindAnchor;
703
+ /**
704
+ * Reminder 蓝色三角的点击命中热区边长(像素,正方形)。
705
+ * 默认 18(与可视三角一致),业务侧可放大到 20/24 以便用户点击触发弹窗。
706
+ * 命中区是以 anchor 对应角为起点、朝单元格内部延伸的 size×size 正方形。
707
+ */
708
+ remindHitAreaSize?: number;
676
709
  /** 表头 Link icon hover 回调:鼠标悬停/离开引用字段表头 link icon 时触发 */
677
710
  onHeaderLinkIconHover?: (info: {
678
711
  show: boolean;
@@ -862,6 +895,8 @@ declare class DataGrid {
862
895
  private _customTokens;
863
896
  edgeScroller: EdgeScroller;
864
897
  rowIdMap: Map<string, number>;
898
+ private conditionalRowStyles;
899
+ private conditionalCellStyles;
865
900
  selectedRowIds: Set<string>;
866
901
  selectedGroupIds: Set<string>;
867
902
  lastSelectedRowIndex: number;
@@ -980,6 +1015,11 @@ declare class DataGrid {
980
1015
  }) => void;
981
1016
  /** 行右键菜单回调 */
982
1017
  onRowContextMenu?: (info: RowContextMenuInfo) => void;
1018
+ rowHoverAction?: DataGridOptions['rowHoverAction'];
1019
+ onRowHoverActionClick?: (info: RowHoverActionInfo) => void;
1020
+ private _rowHoverActionInfo;
1021
+ private _rowHoverActionIcon;
1022
+ private _rowHoverActionIconTheme;
983
1023
  onModuleOverflowClick?: (modules: any[], rowData: any, rowIndex: number, colIndex: number) => void;
984
1024
  onAddRow?: (groupInfo?: any) => void;
985
1025
  onScroll?: (scrollX: number, scrollY: number) => void;
@@ -1296,6 +1336,10 @@ declare class DataGrid {
1296
1336
  };
1297
1337
  rowData: Record<string, any>;
1298
1338
  }) => void;
1339
+ /** Reminder 蓝色三角的锚点位置(4 个角可选),默认 'top-right'。 */
1340
+ remindAnchor: RemindAnchor;
1341
+ /** Reminder 蓝色三角的点击命中热区边长(像素,正方形)。 */
1342
+ remindHitAreaSize: number;
1299
1343
  onHeaderLinkIconHover?: (info: {
1300
1344
  show: boolean;
1301
1345
  colKey: string;
@@ -1575,6 +1619,12 @@ declare class DataGrid {
1575
1619
  * Called when data changes, interaction state changes, etc.
1576
1620
  */
1577
1621
  markDirty(): void;
1622
+ private mergeConditionalStyle;
1623
+ /** Apply a Worker result in one batch and trigger at most one canvas repaint. */
1624
+ applyConditionalStylePatches(patches: ConditionalStylePatch[]): void;
1625
+ clearConditionalStyles(rowIds?: Array<string | number>): void;
1626
+ /** Resolve row style first, then cell style. Callers must treat the returned cache entry as read-only. */
1627
+ getConditionalStyle(rowId: string | number | null | undefined, columnKey?: string): ConditionalStyle | undefined;
1578
1628
  /**
1579
1629
  * [PERF] 反注册本实例向 ImageManager 单例注册过的回调。
1580
1630
  * Vue 组件 onUnmounted 时调用,避免每次组件卸载/重建累计泄漏 callback
@@ -1925,6 +1975,12 @@ declare class DataGrid {
1925
1975
  y: number;
1926
1976
  height: number;
1927
1977
  } | null;
1978
+ private getSelectedCellInfoForRow;
1979
+ private updateRowHoverAction;
1980
+ isRowHoverActionAt(x: number, y: number): boolean;
1981
+ private drawRowHoverAction;
1982
+ triggerRowHoverAction(clientX: number, clientY: number): void;
1983
+ setRowHoverAction(action: DataGridOptions['rowHoverAction']): void;
1928
1984
  /**
1929
1985
  * 根据列 key 获取列的布局信息(精确的 x 偏移、宽度、冻结状态)
1930
1986
  * @param key - 列配置中的 key 属性
@@ -1982,6 +2038,8 @@ declare class DataGrid {
1982
2038
  width: number;
1983
2039
  height: number;
1984
2040
  } | null;
2041
+ /** 将 Canvas viewer 的显示对象转换为可读文本,供右键等外部 UI 使用。 */
2042
+ getCellDisplayText(cell: any): string;
1985
2043
  /**
1986
2044
  * 根据 canvas 局部坐标命中可见 cell(外部文件拖拽 hit-test 入口)。
1987
2045
  *
@@ -0,0 +1,4 @@
1
+ /** Resolve the stable render row id used by both cell and row-header conditional styles. */
2
+ export declare function getConditionalStyleRowId(rowData: Record<string, unknown> | undefined, rowKey: string, rowId?: unknown): string | number | undefined;
3
+ /** Blend a translucent conditional background once before canvas text and icons are drawn. */
4
+ export declare function compositeConditionalBackground(foreground: string, background: string): string;
@@ -29,6 +29,21 @@ export declare const ERROR_TIP_COLOR: string;
29
29
  /** @deprecated 请使用 styleManager.getToken('reminderColor') */
30
30
  export declare const REMINDER_TIP_COLOR: string;
31
31
  export declare const REMINDER_TRIANGLE_SIZE = 18;
32
+ /**
33
+ * 蓝色提醒三角的锚点位置(4 个角可选)。
34
+ * 默认 'top-right'(右上角),与历史渲染行为保持一致。
35
+ * 由业务侧(如 AssetMatrix)按场景/玩法通过 DataGridOptions.remindAnchor 覆盖。
36
+ */
37
+ export type RemindAnchor = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
38
+ export declare const REMINDER_ANCHOR_DEFAULT: RemindAnchor;
39
+ /**
40
+ * 蓝色提醒三角的点击命中热区尺寸(像素,正方形边长)。
41
+ * 默认沿用 REMINDER_TRIANGLE_SIZE(18px)保持历史点击面积;
42
+ * 业务侧(如 AssetMatrix 和平玩法)可通过 DataGridOptions.remindHitAreaSize 放大为 20/24 等,
43
+ * 便于用户命中以触发外部 Reminder 弹窗(点击行为,非 hover)。
44
+ * 命中区是以 anchor 对应角为起点、朝单元格内部延伸的 size×size 正方形(独立于可视三角大小)。
45
+ */
46
+ export declare const REMINDER_HIT_AREA_SIZE_DEFAULT = 18;
32
47
  /** @deprecated 请使用 styleManager.getToken('textHeader') */
33
48
  export declare const HEADER_TEXT_COLOR: string;
34
49
  /** 表头图标尺寸常量 */
@@ -1,4 +1,26 @@
1
1
  import type { ViewerOption } from './viewers/types';
2
+ /** Runtime style produced by conditional-format rules. `null` clears an existing value. */
3
+ export interface ConditionalStyle {
4
+ backgroundColor?: string | null;
5
+ color?: string | null;
6
+ fontWeight?: 'normal' | 'bold' | null;
7
+ }
8
+ /** A batched conditional-format update addressed by the stable DataGrid row id. */
9
+ export interface ConditionalStylePatch {
10
+ rowId: string | number;
11
+ rowStyle?: ConditionalStyle | null;
12
+ cellStyles?: Record<string, ConditionalStyle | null>;
13
+ }
14
+ /** Immutable snapshot used by context-menu based rule creation. */
15
+ export interface ActiveCellInfo {
16
+ rowId: string;
17
+ rowIndex: number;
18
+ colIndex: number;
19
+ columnKey: string;
20
+ rawValue: unknown;
21
+ displayValue: string;
22
+ rowData: Record<string, any>;
23
+ }
2
24
  export interface CellData {
3
25
  value?: any;
4
26
  text?: string;
@@ -11,6 +11,8 @@ declare class PersonViewer implements CellViewer<PersonViewerData> {
11
11
  readonly type = "person";
12
12
  private imageManager;
13
13
  private _sm;
14
+ /** The active cell style is shared by the small person-card drawing helpers in one synchronous draw pass. */
15
+ private _cellStyle;
14
16
  /**
15
17
  * 每个 cell 内"被截断的 person 名称"几何缓存。
16
18
  * 二级结构 WeakMap<scope, Map<`${rowIndex}-${colIndex}`, PersonOverflowInfo[]>>:
@@ -23,6 +23,8 @@ declare class TaskNodeViewer implements CellViewer<TaskNodeViewerData> {
23
23
  /** 记录加载失败的图标 URL,避免反复重试 */
24
24
  private failedIcons;
25
25
  private _sm;
26
+ /** Conditional formatting is injected per draw and must never be cached in node data. */
27
+ private _cellStyle;
26
28
  private get NODE_ITEM_BG_COLOR();
27
29
  private get TEXT_COLOR();
28
30
  private get EMPTY_TEXT_COLOR();
@@ -8,7 +8,7 @@ import DataGrid from './components/index.vue';
8
8
  declare const install: (app: App) => void;
9
9
  export { install };
10
10
  export default DataGrid;
11
- export type { CellData, CellStyle, RowData, ColData, DataGridOptions, Position, Size, Rect, Range, CellRange, HistoryItem, ValidatorRule, ColumnType, ColumnConfig, SelectorState, EditorState, AutofillState, RangeState, DrawOptions, TextOptions, ClipboardState, EventHandlers, Direction, ScrollDirection, GroupLevel, SeparateLevel, BaseGroupedRowData, GroupRowData, SeparateRowData, NormalRowData, GroupedTableRowData, GroupRowStyle, SeparatorRowStyle, StatisticOption, FooterCellData, FooterData, FooterCellClickInfo, } from './core/types';
11
+ export type { CellData, CellStyle, RowData, ColData, DataGridOptions, Position, Size, Rect, Range, CellRange, HistoryItem, ValidatorRule, ColumnType, ColumnConfig, SelectorState, EditorState, AutofillState, RangeState, DrawOptions, TextOptions, ClipboardState, EventHandlers, ConditionalStyle, ConditionalStylePatch, ActiveCellInfo, Direction, ScrollDirection, GroupLevel, SeparateLevel, BaseGroupedRowData, GroupRowData, SeparateRowData, NormalRowData, GroupedTableRowData, GroupRowStyle, SeparatorRowStyle, StatisticOption, FooterCellData, FooterData, FooterCellClickInfo, } from './core/types';
12
12
  export { isGroupRow, isSeparateRow, isNormalRow, isRowSelectable, GROUP_TABLE_CONSTANTS, DEFAULT_GROUP_STYLES, DEFAULT_SEPARATOR_STYLES, } from './core/types';
13
13
  export type { CellBounds, ViewerRenderContext, ViewerDragState, CellViewer, CellViewerData, ViewerOption, ViewerStyle, TextViewerData, DropdownViewerData, ImageViewerData, PreImageViewerData, PersonViewerData, PersonInfo, ProgressViewerData, DatetimeViewerData, CaseTimeViewerData, BooleanViewerData, StatusViewerData, StatusOption, GroupHeaderViewerData, GroupNameViewerData, GroupNameTagItem, GroupNamePersonItem, SeparatorRowViewerData, PunchViewerData, PunchValue, ModuleInfo, ModuleViewerData, TextViewerChildCountTextPart, TextViewerChildCountIconPart, TextViewerChildCountRenderResult, TextViewerChildCountRenderer, TextViewerWithSwitcherData, FileItem, FileViewerData, HyperlinkTextViewerData, IUpstreamModule, IUpstreamReminderProperties, IUpstreamSyncProperty, IUpstreamFieldViewItem, UpstreamViewerData, TaskNodeItem, TaskNodeViewerData, NestedGridViewerData, NestedColumnConfig, ViewerConstructor, ViewerFactory, ViewerTypeMap, ViewerType, TypedCellData, TableActionButtonOption, TableActionButtonViewerData, } from './core/viewers/types';
14
14
  export { isTextViewerData, isDropdownViewerData, isPersonViewerData, isProgressViewerData, isNestedGridViewerData, } from './core/viewers/types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arthub-table",
3
- "version": "0.2.88",
3
+ "version": "0.2.90-next.0",
4
4
  "description": "High-performance canvas-based table/grid component for Vue 3 with TypeScript support, featuring virtual scrolling, cell viewers, grouped rows, and nested grids.",
5
5
  "main": "dist/arthub-table.common.js",
6
6
  "module": "dist/arthub-table.umd.min.js",