@taocompany/magic-grid 0.7.8 → 0.9.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.
- package/README.md +93 -40
- package/dist/components/MagicGrid/MagicGrid.vue.d.ts +12 -20
- package/dist/components/MagicGrid/MagicGrid.vue.d.ts.map +1 -1
- package/dist/core/api/gridApi.d.ts +155 -35
- package/dist/core/api/gridApi.d.ts.map +1 -1
- package/dist/core/grid/grid.d.ts +39 -12
- package/dist/core/grid/grid.d.ts.map +1 -1
- package/dist/core/grid/gridInteraction/rowDragSession.d.ts +3 -3
- package/dist/core/grid/gridInteraction/rowDragSession.d.ts.map +1 -1
- package/dist/core/grid/gridInteraction/types.d.ts +4 -3
- package/dist/core/grid/gridInteraction/types.d.ts.map +1 -1
- package/dist/core/grid/gridRowMutation.d.ts +10 -3
- package/dist/core/grid/gridRowMutation.d.ts.map +1 -1
- package/dist/core/indexColumn/indexLoadingVisual.d.ts +4 -0
- package/dist/core/indexColumn/indexLoadingVisual.d.ts.map +1 -0
- package/dist/core/overlay/resolveOverlayType.d.ts +1 -1
- package/dist/core/overlay/resolveOverlayType.d.ts.map +1 -1
- package/dist/core/pipeline/refreshModel.d.ts +1 -0
- package/dist/core/pipeline/refreshModel.d.ts.map +1 -1
- package/dist/core/pipeline/stages/groupStage.d.ts +2 -0
- package/dist/core/pipeline/stages/groupStage.d.ts.map +1 -1
- package/dist/core/pipeline/stages/sortStage.d.ts +2 -0
- package/dist/core/pipeline/stages/sortStage.d.ts.map +1 -1
- package/dist/core/renderer/rowRenderer.d.ts +5 -2
- package/dist/core/renderer/rowRenderer.d.ts.map +1 -1
- package/dist/core/row/cellComp.d.ts +2 -0
- package/dist/core/row/cellComp.d.ts.map +1 -1
- package/dist/core/row/getRowByIndex.d.ts +7 -0
- package/dist/core/row/getRowByIndex.d.ts.map +1 -0
- package/dist/core/row/getRowDragCommitHierarchy.d.ts +15 -11
- package/dist/core/row/getRowDragCommitHierarchy.d.ts.map +1 -1
- package/dist/core/row/getRowIndex.d.ts +11 -0
- package/dist/core/row/getRowIndex.d.ts.map +1 -0
- package/dist/core/row/getRowIndexes.d.ts +9 -0
- package/dist/core/row/getRowIndexes.d.ts.map +1 -0
- package/dist/core/row/getRowKind.d.ts +6 -0
- package/dist/core/row/getRowKind.d.ts.map +1 -0
- package/dist/core/row/getSiblingRowsByRowId.d.ts +32 -18
- package/dist/core/row/getSiblingRowsByRowId.d.ts.map +1 -1
- package/dist/core/row/index.d.ts +2 -1
- package/dist/core/row/index.d.ts.map +1 -1
- package/dist/core/row/planRowMoveStep.d.ts +31 -0
- package/dist/core/row/planRowMoveStep.d.ts.map +1 -0
- package/dist/core/row/resolveDisplayRowById.d.ts +23 -0
- package/dist/core/row/resolveDisplayRowById.d.ts.map +1 -1
- package/dist/core/row/rowComp.d.ts +5 -5
- package/dist/core/row/rowComp.d.ts.map +1 -1
- package/dist/core/row/rowDragCommitService.d.ts +11 -3
- package/dist/core/row/rowDragCommitService.d.ts.map +1 -1
- package/dist/core/row/rowMoveService.d.ts +15 -0
- package/dist/core/row/rowMoveService.d.ts.map +1 -1
- package/dist/core/rowExpansion/rowExpansionService.d.ts.map +1 -1
- package/dist/core/rowGrouping/createGroupDisplayRows.d.ts.map +1 -1
- package/dist/core/rowGrouping/groupSortKey.d.ts +11 -0
- package/dist/core/rowGrouping/groupSortKey.d.ts.map +1 -0
- package/dist/core/rowGrouping/index.d.ts +3 -0
- package/dist/core/rowGrouping/index.d.ts.map +1 -1
- package/dist/core/rowGrouping/reorderGroupedSourceRows.d.ts +25 -0
- package/dist/core/rowGrouping/reorderGroupedSourceRows.d.ts.map +1 -0
- package/dist/core/rowGrouping/validateGroupedRowMove.d.ts +1 -1
- package/dist/core/rowGrouping/validateGroupedRowMove.d.ts.map +1 -1
- package/dist/core/rowModel/clientSideRowModel.d.ts +5 -0
- package/dist/core/rowModel/clientSideRowModel.d.ts.map +1 -1
- package/dist/core/rowModel/createRowNodes.d.ts.map +1 -1
- package/dist/core/rowModel/index.d.ts +1 -0
- package/dist/core/rowModel/index.d.ts.map +1 -1
- package/dist/core/rowModel/positionRows.d.ts +4 -1
- package/dist/core/rowModel/positionRows.d.ts.map +1 -1
- package/dist/core/rowModel/syncSourceRowIndexes.d.ts +14 -0
- package/dist/core/rowModel/syncSourceRowIndexes.d.ts.map +1 -0
- package/dist/core/rowMutation/asyncRowMutation.d.ts +35 -0
- package/dist/core/rowMutation/asyncRowMutation.d.ts.map +1 -1
- package/dist/core/rowMutation/index.d.ts +1 -1
- package/dist/core/rowMutation/index.d.ts.map +1 -1
- package/dist/core/rowMutation/resolveRowIndex.d.ts +4 -2
- package/dist/core/rowMutation/resolveRowIndex.d.ts.map +1 -1
- package/dist/core/rowMutation/rowMutationService.d.ts +2 -1
- package/dist/core/rowMutation/rowMutationService.d.ts.map +1 -1
- package/dist/core/types/cellComment.d.ts +1 -1
- package/dist/core/types/cellDisable.d.ts +1 -1
- package/dist/core/types/cellRangeSelection.d.ts +2 -2
- package/dist/core/types/cellRangeSelection.d.ts.map +1 -1
- package/dist/core/types/events.d.ts +3 -3
- package/dist/core/types/events.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +6 -7
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/types/indexColumn.d.ts +10 -0
- package/dist/core/types/indexColumn.d.ts.map +1 -1
- package/dist/core/types/rowComp.d.ts +2 -2
- package/dist/core/types/rowComp.d.ts.map +1 -1
- package/dist/core/types/rowDrag.d.ts +31 -41
- package/dist/core/types/rowDrag.d.ts.map +1 -1
- package/dist/core/types/rowExpansion.d.ts +14 -1
- package/dist/core/types/rowExpansion.d.ts.map +1 -1
- package/dist/core/types/rowGrouping.d.ts +7 -1
- package/dist/core/types/rowGrouping.d.ts.map +1 -1
- package/dist/core/types/rowMutation.d.ts +18 -3
- package/dist/core/types/rowMutation.d.ts.map +1 -1
- package/dist/core/types/rowMutationAsync.d.ts +100 -5
- package/dist/core/types/rowMutationAsync.d.ts.map +1 -1
- package/dist/core/types/rowNode.d.ts +4 -2
- package/dist/core/types/rowNode.d.ts.map +1 -1
- package/dist/core/types/selectedRowSnapshot.d.ts +24 -10
- package/dist/core/types/selectedRowSnapshot.d.ts.map +1 -1
- package/dist/{getRowDragCommitHierarchy-Bty3JIsM.js → getRowDragCommitHierarchy-CyevnkCp.js} +48 -42
- package/dist/getRowDragCommitHierarchy-CyevnkCp.js.map +1 -0
- package/dist/getRowDragCommitHierarchy-Dpx6g4Xs.cjs +2 -0
- package/dist/getRowDragCommitHierarchy-Dpx6g4Xs.cjs.map +1 -0
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +4629 -4034
- package/dist/index.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/core.cjs.js +1 -1
- package/dist/types/core.d.ts +418 -124
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.es.js +2 -2
- package/dist/types/magic-grid.d.ts +10 -12
- package/dist/types/magic-grid.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/core/row/getRowType.d.ts +0 -9
- package/dist/core/row/getRowType.d.ts.map +0 -1
- package/dist/getRowDragCommitHierarchy-Bdhm-T66.cjs +0 -2
- package/dist/getRowDragCommitHierarchy-Bdhm-T66.cjs.map +0 -1
- package/dist/getRowDragCommitHierarchy-Bty3JIsM.js.map +0 -1
package/dist/types/core.d.ts
CHANGED
|
@@ -14,7 +14,11 @@ export declare interface AddRowPayload {
|
|
|
14
14
|
|
|
15
15
|
export declare interface AddRowsOptions {
|
|
16
16
|
rows: AddRowItem[];
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* 插入起始下标;省略 = 末尾 append。
|
|
19
|
+
* 默认 `indexMode: 'source'` — 即 **source 下标**(`getData()` / 分组 collation 归一化后的存储序)。
|
|
20
|
+
* 分组开启时:全量 refresh 前会按分组键重排 source;无 index 时先 append,再由归一化落入对应组块。
|
|
21
|
+
*/
|
|
18
22
|
index?: number;
|
|
19
23
|
/** 下标基准,默认 'source' */
|
|
20
24
|
indexMode?: RowIndexMode;
|
|
@@ -26,6 +30,7 @@ export declare interface AsyncRowMutationAddParams {
|
|
|
26
30
|
}>;
|
|
27
31
|
index?: number;
|
|
28
32
|
indexMode?: RowIndexMode;
|
|
33
|
+
/** 可用于监听取消(如 Grid destroy 或新一轮 commit) */
|
|
29
34
|
signal: AbortSignal;
|
|
30
35
|
}
|
|
31
36
|
|
|
@@ -40,14 +45,105 @@ export declare interface AsyncRowMutationAddResultRow {
|
|
|
40
45
|
data?: RowData;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* 异步行变更持久化钩子(GridOptions / MagicGrid `asyncRowMutation`)。
|
|
50
|
+
*
|
|
51
|
+
* ## 消费端怎么用
|
|
52
|
+
*
|
|
53
|
+
* 配置任意钩子后,对应 API **先 await 钩子成功**,再改本地 source;钩子 `throw RowMutationPersistError` 则本地不变。
|
|
54
|
+
*
|
|
55
|
+
* | 钩子 | 触发的 API / 交互 |
|
|
56
|
+
* |------|-------------------|
|
|
57
|
+
* | `add` | `addRows` |
|
|
58
|
+
* | `update` | `updateRows` / `applyTransaction({ update })` |
|
|
59
|
+
* | `remove` | `removeRows` |
|
|
60
|
+
* | `move` | `moveRow` / `moveRows` / `moveUp` / `moveDown` / `moveUps` / `moveDowns` / **索引列拖拽**(见下) |
|
|
61
|
+
*
|
|
62
|
+
* ## move 与拖拽
|
|
63
|
+
*
|
|
64
|
+
* - **编程式 move**(`source: 'api'`):有 `move` 钩子时 await 后再改序;await 期间索引列 loading。
|
|
65
|
+
* - **索引列拖拽**:有 `move` 钩子时 mouseup 后 await;索引列白底 + 居中 spinner(与 API move 一致)。
|
|
66
|
+
* - **updateRows / removeRows**:有对应钩子时 await 期间索引列 loading。
|
|
67
|
+
* - **索引列 loading 前提**:须 `showIndexColumn: true`(建议 `indexColumn.showRowDragHandle: true` 若需拖拽演示)。
|
|
68
|
+
* - 无需额外配置 `rowDragCommitMode`(已移除);是否 async 只看有没有 `move`。
|
|
69
|
+
*
|
|
70
|
+
* @example 平铺表 · 拖拽与 API 共用一套持久化
|
|
71
|
+
* ```ts
|
|
72
|
+
* asyncRowMutation: {
|
|
73
|
+
* move: async ({ rowIds, moves, source, signal }) => {
|
|
74
|
+
* await api.reorder({ rowIds, moves, fromDrag: source === 'uiRowDrag' })
|
|
75
|
+
* },
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example 树形 · hierarchyChanges 持久化(`moves` 可能为空)
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { getRowDragCommitHierarchy, RowMutationPersistError } from '@taocompany/magic-grid/types/core'
|
|
82
|
+
*
|
|
83
|
+
* move: async (params) => {
|
|
84
|
+
* if (params.hierarchyChanges?.length) {
|
|
85
|
+
* const changes = getRowDragCommitHierarchy(params, 'noLevel')
|
|
86
|
+
* await api.saveTreeOrder({ changes })
|
|
87
|
+
* return
|
|
88
|
+
* }
|
|
89
|
+
* await api.reorder({ moves: params.moves })
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
44
93
|
export declare interface AsyncRowMutationHandlers {
|
|
45
|
-
/**
|
|
94
|
+
/** 新增:成功后 apply 本地;reject 则不写入 */
|
|
46
95
|
add?: (params: AsyncRowMutationAddParams) => Promise<AsyncRowMutationAddResult | void>;
|
|
47
|
-
/**
|
|
96
|
+
/** 更新:成功后 apply 本地;reject 则不写入 */
|
|
48
97
|
update?: (params: AsyncRowMutationUpdateParams) => Promise<void>;
|
|
49
|
-
/**
|
|
98
|
+
/** 删除:成功后 apply 本地;reject 则不删除 */
|
|
50
99
|
remove?: (params: AsyncRowMutationRemoveParams) => Promise<void>;
|
|
100
|
+
/** 行序移动:见模块顶部的 move / 拖拽说明 */
|
|
101
|
+
move?: (params: AsyncRowMutationMoveParams) => Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* `asyncRowMutation.move` 入参。
|
|
106
|
+
*
|
|
107
|
+
* `source` 区分调用来源:
|
|
108
|
+
* - `'api'`:`moveRow` / `moveRows` / `moveUp` / `moveDown` / `moveUps` / `moveDowns`
|
|
109
|
+
* - `'uiRowDrag'`:索引列 drag handle(配置了 `move` 时 mouseup 后触发)
|
|
110
|
+
*
|
|
111
|
+
* 树形 / 分组场景请同时阅读 `moves` 与 `hierarchyChanges`(见 {@link RowHierarchyChange})。
|
|
112
|
+
*/
|
|
113
|
+
export declare interface AsyncRowMutationMoveParams {
|
|
114
|
+
/** 本次移动涉及的全部 rowId(含 leader 与 cascade 子树) */
|
|
115
|
+
rowIds: readonly string[];
|
|
116
|
+
/** 拖拽 leader 或 API 指定的主行 */
|
|
117
|
+
leaderRowId: string;
|
|
118
|
+
/** leader 在 source 数组的目标下标(API 入参或从 moves 推导) */
|
|
119
|
+
toIndex: number;
|
|
120
|
+
indexMode?: RowIndexMode;
|
|
121
|
+
/**
|
|
122
|
+
* source 平铺数组下标位移;**不含**树 parent 信息。
|
|
123
|
+
* 平铺 / 分组同级换序时为主要依据;树形仅改 parent 时可能为空数组。
|
|
124
|
+
*/
|
|
125
|
+
moves: readonly RowMoveItem[];
|
|
126
|
+
/** 移动行的 data 快照(持久化时可直接用,无需再 getData) */
|
|
127
|
+
rows: ReadonlyArray<{
|
|
128
|
+
rowId: string;
|
|
129
|
+
data: RowData;
|
|
130
|
+
}>;
|
|
131
|
+
source: RowMoveSource;
|
|
132
|
+
signal: AbortSignal;
|
|
133
|
+
/** 仅 uiRowDrag:指针落在 display 的插入位(与 toIndex 可能不同) */
|
|
134
|
+
displayIndex?: number;
|
|
135
|
+
/**
|
|
136
|
+
* 仅 uiRowDrag / 树形:parentRowId、siblingIndex 相对变更前发生变化的行。
|
|
137
|
+
* 持久化树序时优先用 {@link getRowDragCommitHierarchy} 过滤。
|
|
138
|
+
*/
|
|
139
|
+
hierarchyChanges?: readonly RowHierarchyChange[];
|
|
140
|
+
/** 仅 uiRowDrag:leader apply 后的父节点;根层 null */
|
|
141
|
+
parentRowId?: string | null;
|
|
142
|
+
/** 仅 uiRowDrag:leader 在新父下的同级序号(0-based,≠ 业务字段 order) */
|
|
143
|
+
siblingIndex?: number;
|
|
144
|
+
treeLevel?: number;
|
|
145
|
+
/** 仅 uiRowDrag:drop 意图(子级缩进区 / Alt);≠ apply 后的 parentRowId */
|
|
146
|
+
nestUnderRowId?: string | null;
|
|
51
147
|
}
|
|
52
148
|
|
|
53
149
|
export declare interface AsyncRowMutationRemoveParams {
|
|
@@ -1232,17 +1328,20 @@ export declare interface FirstRenderedEvent {
|
|
|
1232
1328
|
* @example
|
|
1233
1329
|
* ```ts
|
|
1234
1330
|
* gridApi.on('indexFocusChanged', (event) => {
|
|
1235
|
-
* api.moveRows({
|
|
1331
|
+
* api.moveRows({
|
|
1332
|
+
* rowIds: generateFocusedRowIds(event.focusedRows),
|
|
1333
|
+
* toIndex: 0, // 默认 source 下标;也可用 event.focusedRows[0].sourceIndex
|
|
1334
|
+
* })
|
|
1236
1335
|
* })
|
|
1237
1336
|
* ```
|
|
1238
1337
|
*/
|
|
1239
|
-
export declare function generateFocusedRowIds(rows:
|
|
1338
|
+
export declare function generateFocusedRowIds(rows: RowSnapshot | readonly RowSnapshot[], options?: RowListOptions): RowId[];
|
|
1240
1339
|
|
|
1241
1340
|
/** 索引 focus:`generateFocusedRowIds` 入参(与 {@link GenerateSelectedRowIdsOptions} 相同) */
|
|
1242
1341
|
export declare type GenerateFocusedRowIdsOptions = RowListOptions;
|
|
1243
1342
|
|
|
1244
1343
|
/**
|
|
1245
|
-
* 单行快照 → `removeRows` / `moveRows` / `
|
|
1344
|
+
* 单行快照 → `removeRows` / `moveRows` / `getRowIndex` / `getRowKind` 等 API 可用的 id。
|
|
1246
1345
|
*
|
|
1247
1346
|
* - 持久化行 → 业务 `rowId`
|
|
1248
1347
|
* - 临时行 → `internalRowId`(`__MG_TMP__::*`)
|
|
@@ -1250,12 +1349,14 @@ export declare type GenerateFocusedRowIdsOptions = RowListOptions;
|
|
|
1250
1349
|
* @example
|
|
1251
1350
|
* ```ts
|
|
1252
1351
|
* api.on('indexFocusChanged', (event) => {
|
|
1253
|
-
* const
|
|
1254
|
-
*
|
|
1352
|
+
* const row = event.focusedRows[0]
|
|
1353
|
+
* if (!row) return
|
|
1354
|
+
* // row.rowIndex 即 display 下标;ensureIndexVisible 亦需 display
|
|
1355
|
+
* api.ensureIndexVisible(row.rowIndex)
|
|
1255
1356
|
* })
|
|
1256
1357
|
* ```
|
|
1257
1358
|
*/
|
|
1258
|
-
export declare function generateRowId(row:
|
|
1359
|
+
export declare function generateRowId(row: RowSnapshot): RowId;
|
|
1259
1360
|
|
|
1260
1361
|
/**
|
|
1261
1362
|
* checkbox 选中行 → `removeRows` / `moveRows` 可用的 id 列表。
|
|
@@ -1267,7 +1368,7 @@ export declare function generateRowId(row: SelectedRowSnapshot): RowId;
|
|
|
1267
1368
|
* })
|
|
1268
1369
|
* ```
|
|
1269
1370
|
*/
|
|
1270
|
-
export declare function generateSelectedRowIds(rows:
|
|
1371
|
+
export declare function generateSelectedRowIds(rows: RowSnapshot | readonly RowSnapshot[], options?: RowListOptions): RowId[];
|
|
1271
1372
|
|
|
1272
1373
|
/** checkbox 选中:`generateSelectedRowIds` 入参 */
|
|
1273
1374
|
export declare type GenerateSelectedRowIdsOptions = RowListOptions;
|
|
@@ -1294,25 +1395,29 @@ export declare interface GetDetailRowDataParams {
|
|
|
1294
1395
|
}
|
|
1295
1396
|
|
|
1296
1397
|
/**
|
|
1297
|
-
* 从
|
|
1398
|
+
* 从 `asyncRowMutation.move` 的树形字段中提取待持久化的层级变更。
|
|
1298
1399
|
*
|
|
1299
|
-
*
|
|
1300
|
-
* - `noLevel`:仅保留 **parentRowId 或 siblingIndex** 相对变更前发生变化的项,
|
|
1301
|
-
* 排除「parent / sibling 均未变、仅 treeLevel 不同」的条目。
|
|
1400
|
+
* 传入 `params` 或任意含 `hierarchyChanges` 的对象即可(通常 `move` 钩子的 `params`)。
|
|
1302
1401
|
*
|
|
1303
|
-
*
|
|
1402
|
+
* - `default`:返回全部 `hierarchyChanges`(含仅 treeLevel 变化的项)。
|
|
1403
|
+
* - `noLevel`:仅 parent / sibling 真正变化的行(对接后端 parentId + order 时推荐)。
|
|
1304
1404
|
*
|
|
1305
1405
|
* @example
|
|
1306
1406
|
* ```ts
|
|
1307
|
-
* import { getRowDragCommitHierarchy } from '@taocompany/magic-grid'
|
|
1407
|
+
* import { getRowDragCommitHierarchy, RowMutationPersistError } from '@taocompany/magic-grid/types/core'
|
|
1308
1408
|
*
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1409
|
+
* asyncRowMutation: {
|
|
1410
|
+
* move: async (params) => {
|
|
1411
|
+
* const changes = getRowDragCommitHierarchy(params, 'noLevel')
|
|
1412
|
+
* if (changes.length === 0 && params.moves.length === 0) return
|
|
1413
|
+
* await api.saveOrder({ changes, moves: params.moves })
|
|
1414
|
+
* },
|
|
1312
1415
|
* }
|
|
1313
1416
|
* ```
|
|
1314
1417
|
*/
|
|
1315
|
-
export declare function getRowDragCommitHierarchy(context:
|
|
1418
|
+
export declare function getRowDragCommitHierarchy(context: {
|
|
1419
|
+
hierarchyChanges?: readonly RowHierarchyChange[];
|
|
1420
|
+
}, option?: GetRowDragCommitHierarchyOption): RowHierarchyChange[];
|
|
1316
1421
|
|
|
1317
1422
|
/** {@link getRowDragCommitHierarchy} 过滤模式 */
|
|
1318
1423
|
export declare type GetRowDragCommitHierarchyOption = 'default' | 'noLevel';
|
|
@@ -1326,15 +1431,31 @@ export declare interface GetRowHeightParams {
|
|
|
1326
1431
|
rowIndex: number;
|
|
1327
1432
|
}
|
|
1328
1433
|
|
|
1434
|
+
/** `getRowIndex` / `getRowIndexes` 选项;`type` 与 `removeRows({ indexMode })` / `moveRows({ indexMode })` 同语义 */
|
|
1435
|
+
export declare interface GetRowIndexOptions {
|
|
1436
|
+
/** @default 'source' */
|
|
1437
|
+
type?: RowIndexMode;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
export declare interface GetSiblingRowByIteratorOptions<TData = RowData> {
|
|
1441
|
+
direction: SiblingRowDirection;
|
|
1442
|
+
/** 必填;`next(false)` 时返回当前候选行 */
|
|
1443
|
+
iterator: SiblingRowIterator<TData>;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1329
1446
|
export declare interface GetSiblingRowsByRowIdOptions<TData = RowData> {
|
|
1330
1447
|
direction: SiblingRowDirection;
|
|
1331
1448
|
/**
|
|
1332
|
-
*
|
|
1333
|
-
* `-1` =
|
|
1449
|
+
* 最多收集几条。默认 `1`。
|
|
1450
|
+
* `-1` = 该方向全部可见相邻行(仍会被 iterator 提前终止)。
|
|
1334
1451
|
*/
|
|
1335
1452
|
length?: number;
|
|
1336
|
-
/**
|
|
1453
|
+
/** 可选过滤;省略时所有候选均纳入(仅受 `length` 限制) */
|
|
1337
1454
|
iterator?: SiblingRowIterator<TData>;
|
|
1455
|
+
/**
|
|
1456
|
+
* `next(false)` 终止时是否纳入终止行。默认 `false`(只返回此前 `next()` 通过的行)。
|
|
1457
|
+
*/
|
|
1458
|
+
includeStop?: boolean;
|
|
1338
1459
|
}
|
|
1339
1460
|
|
|
1340
1461
|
/** Grid 验收阈值 */
|
|
@@ -1361,7 +1482,7 @@ export declare interface GridApi extends RowMutationGridApi {
|
|
|
1361
1482
|
* 增量事务:add / update / remove。
|
|
1362
1483
|
*
|
|
1363
1484
|
* - `update` / `remove` 项可通过 `data[rowKey]` 或字符串 rowId 定位行。
|
|
1364
|
-
* - 与 `addRows` / `removeRows` 共用同一刷新管线;大量连续操作建议包在 `beginUpdate` / `endUpdate` 中。
|
|
1485
|
+
* - 与 `addRows` / `updateRows` / `removeRows` 共用同一刷新管线;大量连续操作建议包在 `beginUpdate` / `endUpdate` 中。
|
|
1365
1486
|
* - 配置 `asyncRowMutation` 时 await 对应钩子成功后再写入本地。
|
|
1366
1487
|
*
|
|
1367
1488
|
* @returns 本次事务影响的 RowNode 快照
|
|
@@ -1505,53 +1626,105 @@ export declare interface GridApi extends RowMutationGridApi {
|
|
|
1505
1626
|
*/
|
|
1506
1627
|
getRowNode(id: RowId): RowNode | undefined;
|
|
1507
1628
|
/**
|
|
1508
|
-
* 按行 id
|
|
1629
|
+
* 按行 id 获取相邻可见行快照(`rowsToDisplay` 顺序;**不含锚点**)。
|
|
1630
|
+
*
|
|
1631
|
+
* 快照结构同 `getSelectedRows` / `focusedRows`。rowId 规则同 {@link getRowIndex}。
|
|
1509
1632
|
*
|
|
1510
1633
|
* | 选项 | 说明 |
|
|
1511
1634
|
* |------|------|
|
|
1512
1635
|
* | `direction` | `'prev'` 上一行 · `'next'` 下一行 |
|
|
1513
|
-
* | `length` | 默认 `1`;`-1`
|
|
1514
|
-
* | `iterator` | `({ currentRow, row })
|
|
1636
|
+
* | `length` | 默认 `1`;`-1` 取该方向全部(iterator 可提前终止) |
|
|
1637
|
+
* | `iterator` | `({ currentRow, row, next })`;每步须 `next()` 或 `next(false)`,未调用视为终止 |
|
|
1638
|
+
* | `includeStop` | 默认 `false`;`next(false)` 时是否纳入终止行 |
|
|
1515
1639
|
*
|
|
1516
|
-
*
|
|
1640
|
+
* 锚点不可见时返回 `[]`。
|
|
1517
1641
|
*
|
|
1518
1642
|
* @example
|
|
1519
1643
|
* ```ts
|
|
1520
1644
|
* const [nextRow] = api.getSiblingRowsByRowId(2, { direction: 'next' })
|
|
1521
1645
|
*
|
|
1522
|
-
*
|
|
1523
|
-
*
|
|
1524
|
-
* // 向上取同部门相邻行,遇到其他部门停止(不含该行)
|
|
1525
|
-
* api.getSiblingRowsByRowId(5, {
|
|
1646
|
+
* // 向上收集同部门行(含首个不同部门行)
|
|
1647
|
+
* api.getSiblingRowsByRowId(anchorId, {
|
|
1526
1648
|
* direction: 'prev',
|
|
1527
1649
|
* length: -1,
|
|
1528
|
-
*
|
|
1529
|
-
*
|
|
1650
|
+
* includeStop: true,
|
|
1651
|
+
* iterator: ({ currentRow, row, next }) => {
|
|
1652
|
+
* if (String(currentRow.data.dept) !== String(row.data.dept)) {
|
|
1653
|
+
* next(false)
|
|
1654
|
+
* return
|
|
1655
|
+
* }
|
|
1656
|
+
* next()
|
|
1657
|
+
* },
|
|
1658
|
+
* })
|
|
1659
|
+
* ```
|
|
1660
|
+
*/
|
|
1661
|
+
getSiblingRowsByRowId(rowId: RowId, options: GetSiblingRowsByRowIdOptions): RowSnapshot[];
|
|
1662
|
+
/**
|
|
1663
|
+
* 沿 `direction` 遍历相邻行,返回 **`next(false)` 终止时** 的 `currentRow` 快照。
|
|
1664
|
+
*
|
|
1665
|
+
* 与 {@link getSiblingRowsByRowId} 共用 iterator 签名;差异在于终止时**返回**该行而非收集数组。
|
|
1666
|
+
* 每个候选行须调用 `next()` 或 `next(false)`,未调用视为终止。
|
|
1667
|
+
*
|
|
1668
|
+
* | 场景 | 返回值 |
|
|
1669
|
+
* |------|--------|
|
|
1670
|
+
* | 某候选行上 `next(false)` | 该行 `RowSnapshot` |
|
|
1671
|
+
* | 遍历结束仍未终止 | `null` |
|
|
1672
|
+
* | 锚点不可见 | `null` |
|
|
1673
|
+
*
|
|
1674
|
+
* @example
|
|
1675
|
+
* ```ts
|
|
1676
|
+
* const boundary = api.getSiblingRowByIterator(anchorId, {
|
|
1677
|
+
* direction: 'next',
|
|
1678
|
+
* iterator: ({ currentRow, row, next }) => {
|
|
1679
|
+
* if (String(currentRow.data.dept) !== String(row.data.dept)) {
|
|
1680
|
+
* next(false)
|
|
1681
|
+
* return
|
|
1682
|
+
* }
|
|
1683
|
+
* next()
|
|
1684
|
+
* },
|
|
1530
1685
|
* })
|
|
1531
1686
|
* ```
|
|
1532
1687
|
*/
|
|
1533
|
-
|
|
1688
|
+
getSiblingRowByIterator(rowId: RowId, options: GetSiblingRowByIteratorOptions): RowSnapshot | null;
|
|
1534
1689
|
/**
|
|
1535
|
-
*
|
|
1690
|
+
* 解析行的展示种类({@link RowKind})。
|
|
1536
1691
|
*
|
|
1537
1692
|
* | 返回值 | 含义 |
|
|
1538
1693
|
* |--------|------|
|
|
1539
|
-
* | `'BUSINESS'` |
|
|
1540
|
-
* | `'GROUP_HEADER'` / `'GROUP_FOOTER'`
|
|
1694
|
+
* | `'BUSINESS'` | 用户业务数据行(含 `__MG_TMP__::*` 临时行) |
|
|
1695
|
+
* | `'GROUP_HEADER'` / `'GROUP_FOOTER'` | 分组合成行 |
|
|
1696
|
+
* | `'DETAIL'` | 主从详情 overlay |
|
|
1697
|
+
* | `null` | 行不存在或当前不可见 |
|
|
1541
1698
|
*
|
|
1542
|
-
* **rowId
|
|
1699
|
+
* **rowId**:业务 id 或内核 id;从 {@link RowSnapshot} 取 id 时用 `generateRowId(row)`。
|
|
1700
|
+
* 快照本身**不含** `rowKind`,需调用本 API。
|
|
1543
1701
|
*
|
|
1544
1702
|
* @example
|
|
1545
1703
|
* ```ts
|
|
1546
|
-
* import { generateRowId } from '@taocompany/magic-grid'
|
|
1704
|
+
* import { generateRowId, type RowKind } from '@taocompany/magic-grid'
|
|
1547
1705
|
*
|
|
1548
1706
|
* api.on('indexFocusChanged', (event) => {
|
|
1549
1707
|
* const row = event.focusedRows[0]
|
|
1550
|
-
* if (row)
|
|
1708
|
+
* if (!row) return
|
|
1709
|
+
* const kind: RowKind | null = api.getRowKind(generateRowId(row))
|
|
1710
|
+
* if (kind !== 'BUSINESS') return
|
|
1711
|
+
* // 仅对业务数据行执行业务逻辑
|
|
1551
1712
|
* })
|
|
1552
1713
|
* ```
|
|
1553
1714
|
*/
|
|
1554
|
-
|
|
1715
|
+
getRowKind(rowId: RowId): RowKind | null;
|
|
1716
|
+
/**
|
|
1717
|
+
* 按 rowId 查下标。完整说明(source vs display、与快照字段对齐)见 `src/core/row/getRowIndex.ts`。
|
|
1718
|
+
*
|
|
1719
|
+
* @see getRowIndexes — 批量版
|
|
1720
|
+
*/
|
|
1721
|
+
getRowIndex(rowId: RowId, options?: GetRowIndexOptions): number | null;
|
|
1722
|
+
/** 批量 {@link getRowIndex};返回 `RowIndexMap`(id 原样作 key) */
|
|
1723
|
+
getRowIndexes(rowIds: readonly RowId[], options?: GetRowIndexOptions): RowIndexMap;
|
|
1724
|
+
/** display 下标 → 快照;与 `getRowIndex(id, { type: 'display' })` 互逆。越界 → `null` */
|
|
1725
|
+
getRowByIndex(index: number): RowSnapshot | null;
|
|
1726
|
+
/** 批量 {@link getRowByIndex};跳过无效下标 */
|
|
1727
|
+
getRowsByIndexes(indexes: readonly number[]): RowSnapshot[];
|
|
1555
1728
|
/**
|
|
1556
1729
|
* 读取当前渲染与滚动指标(验收 / 调试用途)。
|
|
1557
1730
|
*
|
|
@@ -1703,10 +1876,13 @@ export declare interface GridApi extends RowMutationGridApi {
|
|
|
1703
1876
|
/**
|
|
1704
1877
|
* 读取当前 checkbox 选中的完整快照。
|
|
1705
1878
|
*
|
|
1706
|
-
* 含 `internalRowId`(临时行 `__MG_TMP__
|
|
1879
|
+
* 含 `internalRowId`(临时行 `__MG_TMP__::*`)、`sourceIndex`(source 下标)、
|
|
1880
|
+
* `rowIndex`(display 下标),删除临时行、展示选中项时推荐使用。
|
|
1707
1881
|
* 配合 {@link generateSelectedRowIds} 可转为 `removeRows({ rowIds })` 入参。
|
|
1882
|
+
*
|
|
1883
|
+
* @see {@link getRowIndex} 下标主文档
|
|
1708
1884
|
*/
|
|
1709
|
-
getSelectedRows():
|
|
1885
|
+
getSelectedRows(): RowSnapshot[];
|
|
1710
1886
|
/**
|
|
1711
1887
|
* 读取索引列 focus 行 id,可直接传给 `moveRows({ rowIds })`。
|
|
1712
1888
|
*
|
|
@@ -1726,7 +1902,7 @@ export declare interface GridApi extends RowMutationGridApi {
|
|
|
1726
1902
|
* 读取索引列 focus 行快照(结构同 {@link getSelectedRows})。
|
|
1727
1903
|
*
|
|
1728
1904
|
* `options.mode` 与 {@link getIndexFocusedRowIds} 相同。每项含
|
|
1729
|
-
* `rowId`、`internalRowId`、`isTransient`、`rowIndex
|
|
1905
|
+
* `rowId`、`internalRowId`、`isTransient`、`sourceIndex`(source 下标)、`rowIndex`(display 下标)、`data`。
|
|
1730
1906
|
*
|
|
1731
1907
|
* @example
|
|
1732
1908
|
* ```ts
|
|
@@ -1737,7 +1913,7 @@ export declare interface GridApi extends RowMutationGridApi {
|
|
|
1737
1913
|
* api.moveRows({ rowIds: api.getIndexFocusedRowIds(), toIndex: 0 })
|
|
1738
1914
|
* ```
|
|
1739
1915
|
*/
|
|
1740
|
-
getIndexFocusedRows(options?: RowListOptions):
|
|
1916
|
+
getIndexFocusedRows(options?: RowListOptions): RowSnapshot[];
|
|
1741
1917
|
/**
|
|
1742
1918
|
* 设置索引列辅助定位(`IndexFocusService`),不触发鼠标拖拉。
|
|
1743
1919
|
*
|
|
@@ -1971,9 +2147,6 @@ export declare interface GridReadyEvent {
|
|
|
1971
2147
|
/** 圆角:false/0 无圆角;true 跟随 size;number 自定义 px。默认 false */
|
|
1972
2148
|
export declare type GridRounded = number | boolean;
|
|
1973
2149
|
|
|
1974
|
-
/** 行类型枚举(全大写) */
|
|
1975
|
-
export declare type GridRowType = 'BUSINESS' | 'GROUP_HEADER' | 'GROUP_FOOTER' | 'DETAIL';
|
|
1976
|
-
|
|
1977
2150
|
/** 表格尺寸 preset(与 CSS `magic-grid--size-*` 对齐) */
|
|
1978
2151
|
export declare type GridSize = 'mini' | 'small' | 'default' | 'large';
|
|
1979
2152
|
|
|
@@ -2012,7 +2185,7 @@ export declare interface GroupCellRendererMountContext {
|
|
|
2012
2185
|
|
|
2013
2186
|
/** 分组单元格渲染入参(auto group 列 / groupCellRenderer) */
|
|
2014
2187
|
export declare interface GroupCellRendererParams {
|
|
2015
|
-
rowKind: '
|
|
2188
|
+
rowKind: 'GROUP_HEADER' | 'GROUP_FOOTER';
|
|
2016
2189
|
groupId: string;
|
|
2017
2190
|
groupField: string;
|
|
2018
2191
|
groupKey: string;
|
|
@@ -2145,7 +2318,7 @@ export declare interface IndexFocusChangedEvent<TData = RowData> {
|
|
|
2145
2318
|
/** 业务 id;临时行 `null` */
|
|
2146
2319
|
focusedRowIds: BusinessRowId[];
|
|
2147
2320
|
/** 完整行快照(含 internalRowId;推荐用于展示与 moveRows 入参) */
|
|
2148
|
-
focusedRows:
|
|
2321
|
+
focusedRows: RowSnapshot<TData>[];
|
|
2149
2322
|
}
|
|
2150
2323
|
|
|
2151
2324
|
export declare type InvalidEditValueMode = 'block' | 'revert' | 'keep';
|
|
@@ -2368,7 +2541,16 @@ export declare interface MagicGridProps<TData = RowData> {
|
|
|
2368
2541
|
invalidEditValueMode?: InvalidEditValueMode;
|
|
2369
2542
|
/** 行编辑跨字段校验 */
|
|
2370
2543
|
rowValidator?: RowValidator;
|
|
2371
|
-
/**
|
|
2544
|
+
/**
|
|
2545
|
+
* 异步行 CRUD / 行序持久化钩子。
|
|
2546
|
+
*
|
|
2547
|
+
* - 有 `move`:编程式 move API 与索引列拖拽均 await 成功后再改本地;拖拽 mouseup 前仅视觉预览。
|
|
2548
|
+
* - 无 `move`:拖拽 mouseup 立刻改序(sync);编程式 move 亦 sync。
|
|
2549
|
+
* - update / remove / move await 期间:受影响行**索引列**显示 loading(须 `showIndexColumn: true`)。
|
|
2550
|
+
* - 失败:`throw RowMutationPersistError(message)`,本地不变。
|
|
2551
|
+
*
|
|
2552
|
+
* @see AsyncRowMutationHandlers · AsyncRowMutationMoveParams(types/core)
|
|
2553
|
+
*/
|
|
2372
2554
|
asyncRowMutation?: AsyncRowMutationHandlers;
|
|
2373
2555
|
/** 容器高度 */
|
|
2374
2556
|
height?: string | number;
|
|
@@ -2435,15 +2617,6 @@ export declare interface MagicGridProps<TData = RowData> {
|
|
|
2435
2617
|
* 对标 AG Grid `rowDragManaged`。
|
|
2436
2618
|
*/
|
|
2437
2619
|
rowDragManaged?: boolean;
|
|
2438
|
-
/**
|
|
2439
|
-
* managed 模式 commit 策略:`sync`(默认 live move)| `deferred`(mouseup 后 await onRowDragCommit)。
|
|
2440
|
-
*/
|
|
2441
|
-
rowDragCommitMode?: RowDragCommitMode;
|
|
2442
|
-
/**
|
|
2443
|
-
* deferred 模式:mouseup 后、apply 前调用;返回 false 则不写 source。
|
|
2444
|
-
* MagicGrid 亦支持 `:on-row-drag-commit` prop(与 Grid option 等价)。
|
|
2445
|
-
*/
|
|
2446
|
-
onRowDragCommit?: RowDragCommitHandler;
|
|
2447
2620
|
/**
|
|
2448
2621
|
* 行级动态高度(无 DOM);优先于默认 rowHeight,低于手动 setRowHeight。
|
|
2449
2622
|
* 对标 AG Grid `getRowHeight`。
|
|
@@ -2657,12 +2830,14 @@ export declare interface MagicValidationRule {
|
|
|
2657
2830
|
export declare interface MoveRowOptions {
|
|
2658
2831
|
/** 内部 rowId */
|
|
2659
2832
|
rowId: string;
|
|
2660
|
-
/**
|
|
2833
|
+
/** 目标下标(由 indexMode 解释;最终写入 source) */
|
|
2661
2834
|
toIndex: number;
|
|
2662
|
-
/** 下标基准,默认 `source` */
|
|
2835
|
+
/** 下标基准,默认 `'source'` */
|
|
2663
2836
|
indexMode?: RowIndexMode;
|
|
2664
2837
|
/** live drag 中间态为 false;mouseup 收尾为 true(默认 true) */
|
|
2665
2838
|
finished?: boolean;
|
|
2839
|
+
/** @internal asyncRowMutation.move:plan-only,不写 source、不 emit */
|
|
2840
|
+
deferCommit?: boolean;
|
|
2666
2841
|
}
|
|
2667
2842
|
|
|
2668
2843
|
/**
|
|
@@ -2673,9 +2848,9 @@ export declare interface MoveRowOptions {
|
|
|
2673
2848
|
export declare interface MoveRowsGridApiOptions {
|
|
2674
2849
|
/** 待移动 rowId(保持 source 内相对顺序) */
|
|
2675
2850
|
rowIds: readonly RowId[];
|
|
2676
|
-
/**
|
|
2851
|
+
/** 目标下标(indexMode 解释;最终写入 source;默认针对 leader 行) */
|
|
2677
2852
|
toIndex: number;
|
|
2678
|
-
/** 下标基准,默认 `source` */
|
|
2853
|
+
/** 下标基准,默认 `'source'` */
|
|
2679
2854
|
indexMode?: RowIndexMode;
|
|
2680
2855
|
/**
|
|
2681
2856
|
* 块 anchor 行;省略时取 `rowIds` 在 source 中最早出现的行。
|
|
@@ -2874,17 +3049,18 @@ export declare interface RowDoubleClickedEvent<TData = RowData> {
|
|
|
2874
3049
|
}
|
|
2875
3050
|
|
|
2876
3051
|
/**
|
|
2877
|
-
*
|
|
3052
|
+
* 内核组装的拖拽 commit 上下文(Grid 内部使用)。
|
|
3053
|
+
*
|
|
3054
|
+
* 消费端在 `asyncRowMutation.move` 中收到的是 {@link AsyncRowMutationMoveParams},
|
|
3055
|
+
* 树形字段与本文档一致。本类型仍导出,供 `getRowDragCommitHierarchy` 等工具的类型引用。
|
|
2878
3056
|
*
|
|
2879
3057
|
* ### 持久化怎么选字段
|
|
2880
3058
|
*
|
|
2881
3059
|
* | 场景 | 主用字段 |
|
|
2882
3060
|
* |------|----------|
|
|
2883
3061
|
* | 平铺 / 纯同级换序 | `moves` |
|
|
2884
|
-
* | 树形改父、上移一级、下移一级、挂到子级 | `hierarchyChanges
|
|
2885
|
-
* | leader 落点快捷读 | `parentRowId` / `siblingIndex` / `treeLevel
|
|
2886
|
-
*
|
|
2887
|
-
* `nestUnderRowId` 为 **drop 意图**(指针落在子级缩进区 / Alt);`parentRowId` 为 **apply 后结果**。
|
|
3062
|
+
* | 树形改父、上移一级、下移一级、挂到子级 | `hierarchyChanges` |
|
|
3063
|
+
* | leader 落点快捷读 | `parentRowId` / `siblingIndex` / `treeLevel` |
|
|
2888
3064
|
*/
|
|
2889
3065
|
export declare interface RowDragCommitContext {
|
|
2890
3066
|
signal: AbortSignal;
|
|
@@ -2918,7 +3094,7 @@ export declare interface RowDragCommitContext {
|
|
|
2918
3094
|
nestUnderRowId?: string | null;
|
|
2919
3095
|
}
|
|
2920
3096
|
|
|
2921
|
-
/**
|
|
3097
|
+
/** await 持久化结束;`committed: true` 时随后 emit `rowMoved` + `rowDragEnd` */
|
|
2922
3098
|
export declare interface RowDragCommitFinishedEvent {
|
|
2923
3099
|
commitId: number;
|
|
2924
3100
|
rowId: BusinessRowId;
|
|
@@ -2928,17 +3104,7 @@ export declare interface RowDragCommitFinishedEvent {
|
|
|
2928
3104
|
reason?: string;
|
|
2929
3105
|
}
|
|
2930
3106
|
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
export declare type RowDragCommitHandlerResult = boolean | void | {
|
|
2934
|
-
ok: boolean;
|
|
2935
|
-
reason?: string;
|
|
2936
|
-
};
|
|
2937
|
-
|
|
2938
|
-
/** managed 行拖拽 commit 策略 */
|
|
2939
|
-
export declare type RowDragCommitMode = 'sync' | 'deferred';
|
|
2940
|
-
|
|
2941
|
-
/** deferred row drag · commit 开始(公开事件会投影 rowId 为 BusinessRowId) */
|
|
3107
|
+
/** 配置了 asyncRowMutation.move 时,拖拽 mouseup 后开始 await 持久化(公开事件会投影 rowId 为 BusinessRowId) */
|
|
2942
3108
|
export declare interface RowDragCommitStartedEvent {
|
|
2943
3109
|
rowId: BusinessRowId;
|
|
2944
3110
|
rowIds: readonly BusinessRowId[];
|
|
@@ -3056,7 +3222,7 @@ export declare type RowHeightChangeSource = 'api' | 'uiRowResized' | 'autoHeight
|
|
|
3056
3222
|
* 对接后端 `parentId` + `order` 时使用;`siblingIndex` 为 Grid 内部 0-based 同级序,≠ 业务字段 `order`。
|
|
3057
3223
|
*/
|
|
3058
3224
|
export declare interface RowHierarchyChange {
|
|
3059
|
-
/** 内部 rowId(
|
|
3225
|
+
/** 内部 rowId(async move 钩子内为 string;公开事件会投影为 BusinessRowId) */
|
|
3060
3226
|
rowId: string;
|
|
3061
3227
|
/** 变更前父节点 rowId;根层为 null */
|
|
3062
3228
|
previousParentRowId: string | null;
|
|
@@ -3094,10 +3260,25 @@ export declare interface RowIdPromotedEvent {
|
|
|
3094
3260
|
data: RowData;
|
|
3095
3261
|
}
|
|
3096
3262
|
|
|
3097
|
-
/**
|
|
3263
|
+
/** key = 入参 id;value = 下标或 `null` */
|
|
3264
|
+
export declare type RowIndexMap = Partial<Record<RowId, number | null>>;
|
|
3265
|
+
|
|
3266
|
+
/** 行插入/删除下标基准:source = 存储顺序;display = 当前可见顺序(含 sort/filter)。详见 `src/core/row/getRowIndex.ts` */
|
|
3098
3267
|
export declare type RowIndexMode = 'source' | 'display';
|
|
3099
3268
|
|
|
3100
|
-
|
|
3269
|
+
/**
|
|
3270
|
+
* 行的展示种类(Grid 全表统一枚举,与 `GridApi.getRowKind` 返回值一致)。
|
|
3271
|
+
*
|
|
3272
|
+
* | 值 | 含义 |
|
|
3273
|
+
* |----|------|
|
|
3274
|
+
* | `'BUSINESS'` | 用户业务数据行(含临时行);`RowNode.rowKind` 缺省时视同此项 |
|
|
3275
|
+
* | `'GROUP_HEADER'` | 分组标题(display 合成行) |
|
|
3276
|
+
* | `'GROUP_FOOTER'` | 分组小计(display 合成行) |
|
|
3277
|
+
* | `'DETAIL'` | 主从展开的详情 overlay |
|
|
3278
|
+
*
|
|
3279
|
+
* 类型导出:`import type { RowKind } from '@taocompany/magic-grid'`
|
|
3280
|
+
*/
|
|
3281
|
+
export declare type RowKind = 'BUSINESS' | 'GROUP_HEADER' | 'GROUP_FOOTER' | 'DETAIL';
|
|
3101
3282
|
|
|
3102
3283
|
/** 行列表过滤模式(选中 / focus 共用) */
|
|
3103
3284
|
export declare type RowListMode = 'all' | 'business' | 'temp';
|
|
@@ -3107,6 +3288,15 @@ export declare interface RowListOptions {
|
|
|
3107
3288
|
mode?: RowListMode;
|
|
3108
3289
|
}
|
|
3109
3290
|
|
|
3291
|
+
/** async defer commit 计划(内核用);`RowMoveResult.commitPlan` 在 GridApi 返回前通常已剥离 */
|
|
3292
|
+
export declare interface RowMoveCommitPlan {
|
|
3293
|
+
rows: RowNode[];
|
|
3294
|
+
moves: readonly RowMoveItem[];
|
|
3295
|
+
source: RowMoveSource;
|
|
3296
|
+
finished: boolean;
|
|
3297
|
+
treeDisplayInsertIndex?: number;
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3110
3300
|
/** rowMoved 事件 */
|
|
3111
3301
|
export declare interface RowMovedEvent {
|
|
3112
3302
|
rowId: BusinessRowId;
|
|
@@ -3143,6 +3333,8 @@ export declare interface RowMoveResult {
|
|
|
3143
3333
|
toIndex?: number;
|
|
3144
3334
|
reason?: string;
|
|
3145
3335
|
moves?: readonly RowMoveItem[];
|
|
3336
|
+
/** plan-only(deferCommit)时携带,供 async 持久化后 commit;GridApi 返回前通常已剥离 */
|
|
3337
|
+
commitPlan?: RowMoveCommitPlan;
|
|
3146
3338
|
}
|
|
3147
3339
|
|
|
3148
3340
|
export declare type RowMoveSource = 'api' | 'uiRowDrag';
|
|
@@ -3161,8 +3353,11 @@ export declare interface RowMutationGridApi {
|
|
|
3161
3353
|
* - 省略 `data[rowKey]` 或值为 `null` 时生成**临时行**(`RowNode.id = __MG_TMP__::*`);
|
|
3162
3354
|
* `getData()` 导出时对应字段为 `null`。
|
|
3163
3355
|
* - 带有效 `rowKey` 的新增行视为持久化行,须保证主键唯一。
|
|
3356
|
+
* - `index` / `indexMode` 语义同 {@link getRowIndex}(默认 source);最终写入 source 存储。
|
|
3164
3357
|
* - 配置 `asyncRowMutation.add` 时 await 服务端成功后再写入本地。
|
|
3165
3358
|
*
|
|
3359
|
+
* @see {@link getRowIndex} 下标主文档(source / display · `sourceIndex` / `rowIndex`)
|
|
3360
|
+
*
|
|
3166
3361
|
* @returns 本次变更涉及的 RowNode 快照(add / remove / update)
|
|
3167
3362
|
*/
|
|
3168
3363
|
addRows(options: AddRowsOptions): Promise<RowNodeTransaction>;
|
|
@@ -3170,13 +3365,25 @@ export declare interface RowMutationGridApi {
|
|
|
3170
3365
|
* 按 rowId 和/或行下标删除行。
|
|
3171
3366
|
*
|
|
3172
3367
|
* - `rowIds`:内核 id 或业务主键值(number / string 均可)。
|
|
3173
|
-
* - `indexes`:配合 `indexMode
|
|
3368
|
+
* - `indexes`:配合 `indexMode`(默认 `'source'`);语义同 {@link getRowIndex}。
|
|
3174
3369
|
* - 删除正在编辑的行会先取消编辑;选区 / 索引定位 / 校验反馈会同步清理。
|
|
3175
3370
|
* - 配置 `asyncRowMutation.remove` 时 await 服务端成功后再删除本地。
|
|
3371
|
+
* - await 期间受影响行索引列 loading(须 `showIndexColumn: true`)。
|
|
3176
3372
|
*
|
|
3177
3373
|
* @returns 本次删除的 RowNode 快照
|
|
3178
3374
|
*/
|
|
3179
3375
|
removeRows(options: RemoveRowsOptions): Promise<RowNodeTransaction>;
|
|
3376
|
+
/**
|
|
3377
|
+
* 按 rowKey 批量更新行字段。
|
|
3378
|
+
*
|
|
3379
|
+
* - 每项 `data` 须含 `rowKey` 以定位持久化行;字段与现有 `row.data` 合并(Object.assign)。
|
|
3380
|
+
* - 等价于 `applyTransaction({ update })`,语义更贴近 {@link addRows} / {@link removeRows}。
|
|
3381
|
+
* - 配置 `asyncRowMutation.update` 时 await 服务端成功后再写入本地。
|
|
3382
|
+
* - await 期间受影响行索引列 loading(须 `showIndexColumn: true`)。
|
|
3383
|
+
*
|
|
3384
|
+
* @returns 本次更新的 RowNode 快照
|
|
3385
|
+
*/
|
|
3386
|
+
updateRows(options: UpdateRowsOptions): Promise<RowNodeTransaction>;
|
|
3180
3387
|
/**
|
|
3181
3388
|
* 删除当前 checkbox 选中的行。
|
|
3182
3389
|
*
|
|
@@ -3184,6 +3391,7 @@ export declare interface RowMutationGridApi {
|
|
|
3184
3391
|
* - 等价于 `removeRows({ rowIds: generateSelectedRowIds(getSelectedRows()) })`,但更简洁。
|
|
3185
3392
|
* - `scope: 'all'`(默认)含离屏选中;`'current'` 仅当前 display 可见选中。
|
|
3186
3393
|
* - 配置 `asyncRowMutation.remove` 时 await 服务端成功后再删除本地。
|
|
3394
|
+
* - await 期间受影响行索引列 loading(须 `showIndexColumn: true`)。
|
|
3187
3395
|
*/
|
|
3188
3396
|
removeSelectedRows(options?: ClearRowSelectionOptions): Promise<RowNodeTransaction>;
|
|
3189
3397
|
/**
|
|
@@ -3206,23 +3414,79 @@ export declare interface RowMutationGridApi {
|
|
|
3206
3414
|
*/
|
|
3207
3415
|
promoteRowId(options: PromoteRowIdOptions): PromoteRowIdResult;
|
|
3208
3416
|
/**
|
|
3209
|
-
*
|
|
3417
|
+
* 编程式移动行。始终改写 **source** 存储顺序;`indexMode` 仅解释 `toIndex` 入参。
|
|
3418
|
+
*
|
|
3419
|
+
* **sort 或 filter(含 quick filter)激活时**:与 {@link moveRows}、{@link moveUp}、managed 拖拽一样 **全部拒绝**。
|
|
3210
3420
|
*
|
|
3211
|
-
* - `
|
|
3212
|
-
* -
|
|
3213
|
-
*
|
|
3421
|
+
* - 配置 `asyncRowMutation.move` 时 await 服务端成功后再改本地行序。
|
|
3422
|
+
* - await 期间受影响行索引列 loading(须 `showIndexColumn: true`)。
|
|
3423
|
+
*
|
|
3424
|
+
* @see docs/43-move-rows-api.md
|
|
3425
|
+
* @see src/core/row/getRowIndex.ts — source / display 下标说明
|
|
3214
3426
|
*/
|
|
3215
|
-
moveRow(rowId: RowId, toIndex: number, indexMode?: RowIndexMode): RowMoveResult
|
|
3427
|
+
moveRow(rowId: RowId, toIndex: number, indexMode?: RowIndexMode): Promise<RowMoveResult>;
|
|
3216
3428
|
/**
|
|
3217
3429
|
* 编程式批量移动行(保持 source 内相对顺序)。
|
|
3218
3430
|
*
|
|
3431
|
+
* **sort 或 filter 激活时**全部拒绝(见 {@link moveRow})。
|
|
3432
|
+
*
|
|
3219
3433
|
* - `rowIds.length === 1` 时等价于 {@link moveRow}。
|
|
3220
3434
|
* - `leaderRowId` 省略时取 `rowIds` 在 source 中最早出现的行。
|
|
3221
|
-
* -
|
|
3435
|
+
* - 配置 `asyncRowMutation.move` 时 await 服务端成功后再改本地行序。
|
|
3436
|
+
* - await 期间受影响行索引列 loading(须 `showIndexColumn: true`)。
|
|
3222
3437
|
*
|
|
3223
3438
|
* @see docs/43-move-rows-api.md
|
|
3224
3439
|
*/
|
|
3225
|
-
moveRows(options: MoveRowsGridApiOptions): RowMoveResult
|
|
3440
|
+
moveRows(options: MoveRowsGridApiOptions): Promise<RowMoveResult>;
|
|
3441
|
+
/**
|
|
3442
|
+
* 在存储顺序中将行上移一位。
|
|
3443
|
+
*
|
|
3444
|
+
* | 表形态 | 步进范围 | 内部坐标 |
|
|
3445
|
+
* |--------|----------|----------|
|
|
3446
|
+
* | 平铺表 | 全局 source 邻居 | `indexMode: 'source'` |
|
|
3447
|
+
* | 分组表 | 同 `leafGroupPathKey` 组内 leaf | `indexMode: 'source'`(collation 归一化后的子序列) |
|
|
3448
|
+
* | 树形表 | 同父兄弟 | `indexMode: 'display'`(可见兄弟邻居) |
|
|
3449
|
+
*
|
|
3450
|
+
* **rowId**:业务 id 或内核 id(含 `__MG_TMP__::*` 临时行)。
|
|
3451
|
+
*
|
|
3452
|
+
* sort 或 filter 激活时与 {@link moveRow} 相同,全部拒绝。
|
|
3453
|
+
*
|
|
3454
|
+
* - 配置 `asyncRowMutation.move` 时 await 服务端成功后再改本地行序。
|
|
3455
|
+
* - await 期间受影响行索引列 loading(须 `showIndexColumn: true`)。
|
|
3456
|
+
*
|
|
3457
|
+
* @returns 移动后的行快照;行不存在、已在边界或 sort/filter 激活时 `null`
|
|
3458
|
+
*/
|
|
3459
|
+
moveUp(rowId: RowId): Promise< RowSnapshot | null>;
|
|
3460
|
+
/**
|
|
3461
|
+
* 在存储顺序中将行下移一位(语义同 {@link moveUp})。
|
|
3462
|
+
*/
|
|
3463
|
+
moveDown(rowId: RowId): Promise< RowSnapshot | null>;
|
|
3464
|
+
/**
|
|
3465
|
+
* 批量步进上移(保持块内相对顺序)。
|
|
3466
|
+
*
|
|
3467
|
+
* - `rowIds` 接受业务 id 或内核 id(含 `__MG_TMP__::*` 临时行)。
|
|
3468
|
+
* - `rowIds.length === 1` 时语义同 {@link moveUp},返回单元素数组或 `[]`。
|
|
3469
|
+
* - sort 或 filter 激活时与 {@link moveUp} 相同,全部拒绝并返回 `[]`。
|
|
3470
|
+
* - 配置 `asyncRowMutation.move` 时 await 服务端成功后再改本地行序(内部走 {@link moveRows})。
|
|
3471
|
+
* - await 期间受影响行索引列 loading(须 `showIndexColumn: true`)。
|
|
3472
|
+
*
|
|
3473
|
+
* @returns 移动后的行快照(source 序);行不存在、已在边界或 sort/filter 激活时 `[]`
|
|
3474
|
+
*/
|
|
3475
|
+
moveUps(rowIds: readonly RowId[]): Promise< RowSnapshot[]>;
|
|
3476
|
+
/**
|
|
3477
|
+
* 批量步进下移(语义同 {@link moveUps})。
|
|
3478
|
+
* 配置 `asyncRowMutation.move` 时同样 await 持久化后再 apply;await 期间索引列 loading(须 `showIndexColumn: true`)。
|
|
3479
|
+
*/
|
|
3480
|
+
moveDowns(rowIds: readonly RowId[]): Promise< RowSnapshot[]>;
|
|
3481
|
+
}
|
|
3482
|
+
|
|
3483
|
+
/**
|
|
3484
|
+
* 异步持久化失败时在 move/add/update/remove 钩子中 throw。
|
|
3485
|
+
* Grid 不会 apply 本地变更;拖拽场景还会 emit `rowDragCommitFinished(committed: false)`。
|
|
3486
|
+
*/
|
|
3487
|
+
export declare class RowMutationPersistError extends Error {
|
|
3488
|
+
readonly cause?: unknown | undefined;
|
|
3489
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
3226
3490
|
}
|
|
3227
3491
|
|
|
3228
3492
|
export declare interface RowMutationRemovedSnapshot {
|
|
@@ -3235,9 +3499,10 @@ export declare interface RowMutationRowSnapshot {
|
|
|
3235
3499
|
/**
|
|
3236
3500
|
* 当前 `RowNode.id`。
|
|
3237
3501
|
* 持久化行等于 `String(data[rowKey])`;临时行为 `__MG_TMP__::*`(**不是**业务 null)。
|
|
3238
|
-
* 与 {@link
|
|
3502
|
+
* 与 {@link RowSnapshot.rowId}(业务投影)语义不同,请注意区分。
|
|
3239
3503
|
*/
|
|
3240
3504
|
rowId: BusinessRowId;
|
|
3505
|
+
/** source 下标(与 {@link RowSnapshot.sourceIndex} 同语义,事件专用字段名) */
|
|
3241
3506
|
rowIndex: number;
|
|
3242
3507
|
data: RowData;
|
|
3243
3508
|
isTransient: boolean;
|
|
@@ -3257,9 +3522,11 @@ export declare interface RowNode {
|
|
|
3257
3522
|
rowHeight: number;
|
|
3258
3523
|
/** 行高是否为估算值(v1 固定行高时为 false) */
|
|
3259
3524
|
estimated: boolean;
|
|
3260
|
-
/**
|
|
3525
|
+
/** display 下标:在 rowsToDisplay 中的位置(positionRows 写入;sort/filter 后会变) */
|
|
3261
3526
|
rowIndex: number;
|
|
3262
|
-
/**
|
|
3527
|
+
/** source 下标:在 sourceRows 中的存储位置(syncSourceRowIndexes 写入;move/add/remove 后会变) */
|
|
3528
|
+
sourceIndex: number;
|
|
3529
|
+
/** 行种类;缺省 `'BUSINESS'`。公开查询请用 `GridApi.getRowKind` */
|
|
3263
3530
|
rowKind?: RowKind;
|
|
3264
3531
|
/** Phase 17 · detail 行:指向主行 id */
|
|
3265
3532
|
masterRowId?: string;
|
|
@@ -3338,6 +3605,30 @@ export declare type RowSelectionInput = RowSelectionMode | false | RowSelectionC
|
|
|
3338
3605
|
|
|
3339
3606
|
export declare type RowSelectionMode = 'single' | 'multiple';
|
|
3340
3607
|
|
|
3608
|
+
/**
|
|
3609
|
+
* 行快照——`getSelectedRows` / `getIndexFocusedRows` /
|
|
3610
|
+
* `selectionChanged.selectedRows` / `indexFocusChanged.focusedRows` 共用。
|
|
3611
|
+
*/
|
|
3612
|
+
export declare interface RowSnapshot<TData = RowData> {
|
|
3613
|
+
/** 业务主键;临时行恒 `null` */
|
|
3614
|
+
rowId: BusinessRowId;
|
|
3615
|
+
/** 内核 rowId;临时行为 `__MG_TMP__::*` */
|
|
3616
|
+
internalRowId: string;
|
|
3617
|
+
isTransient: boolean;
|
|
3618
|
+
/**
|
|
3619
|
+
* 行在 **source 数据**中的下标(`RowNode.sourceIndex`)。
|
|
3620
|
+
* 与 `api.getRowIndex(id)`(默认 `type: 'source'`)一致;非 source 行恒 `-1`。
|
|
3621
|
+
*/
|
|
3622
|
+
sourceIndex: number;
|
|
3623
|
+
/**
|
|
3624
|
+
* 行在 **rowsToDisplay** 中的下标(`RowNode.rowIndex`)。
|
|
3625
|
+
* 与 `api.getRowIndex(id, { type: 'display' })` 一致。
|
|
3626
|
+
*/
|
|
3627
|
+
rowIndex: number;
|
|
3628
|
+
/** 与 `api.getData()` 导出规则一致 */
|
|
3629
|
+
data: TData;
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3341
3632
|
/** 纵向合并行数(≥1);缺省视为 1;仅表体 */
|
|
3342
3633
|
export declare type RowSpanFn = (params: CellSpanParams) => number;
|
|
3343
3634
|
|
|
@@ -3449,21 +3740,6 @@ export declare interface SelectableParams {
|
|
|
3449
3740
|
isTransient: boolean;
|
|
3450
3741
|
}
|
|
3451
3742
|
|
|
3452
|
-
/**
|
|
3453
|
-
* 行快照——`getSelectedRows` / `getIndexFocusedRows` /
|
|
3454
|
-
* `selectionChanged.selectedRows` / `indexFocusChanged.focusedRows` 共用。
|
|
3455
|
-
*/
|
|
3456
|
-
export declare interface SelectedRowSnapshot<TData = RowData> {
|
|
3457
|
-
/** 业务主键;临时行恒 `null` */
|
|
3458
|
-
rowId: BusinessRowId;
|
|
3459
|
-
/** 内核 rowId;临时行为 `__MG_TMP__::*` */
|
|
3460
|
-
internalRowId: string;
|
|
3461
|
-
isTransient: boolean;
|
|
3462
|
-
rowIndex: number;
|
|
3463
|
-
/** 与 `api.getData()` 导出规则一致 */
|
|
3464
|
-
data: TData;
|
|
3465
|
-
}
|
|
3466
|
-
|
|
3467
3743
|
/**
|
|
3468
3744
|
* 行选择列 checkbox 选中集变化时触发。MagicGrid:`@selection-changed`。
|
|
3469
3745
|
*
|
|
@@ -3481,7 +3757,7 @@ export declare interface SelectionChangedEvent<TData = RowData> {
|
|
|
3481
3757
|
/** 当前选中的业务 row id(临时行为 null;不可单独用于删除临时行) */
|
|
3482
3758
|
selectedRowIds: BusinessRowId[];
|
|
3483
3759
|
/** 当前选中的完整行快照(含 internalRowId;推荐用于删除与展示) */
|
|
3484
|
-
selectedRows:
|
|
3760
|
+
selectedRows: RowSnapshot<TData>[];
|
|
3485
3761
|
}
|
|
3486
3762
|
|
|
3487
3763
|
/** 行选择列配置 */
|
|
@@ -3540,23 +3816,29 @@ export declare interface SetRowHeightChange {
|
|
|
3540
3816
|
height: number;
|
|
3541
3817
|
}
|
|
3542
3818
|
|
|
3543
|
-
/**
|
|
3819
|
+
/** 相邻方向:相对锚点在 `rowsToDisplay` 中的上一行 / 下一行 */
|
|
3544
3820
|
export declare type SiblingRowDirection = 'prev' | 'next';
|
|
3545
3821
|
|
|
3546
|
-
/**
|
|
3547
|
-
|
|
3548
|
-
* 返回 `false` 时立即停止,且**不包含** `currentRow`。
|
|
3549
|
-
*/
|
|
3550
|
-
export declare type SiblingRowIterator<TData = RowData> = (params: SiblingRowIteratorParams<TData>) => boolean;
|
|
3822
|
+
/** 逐条过滤候选相邻行;须在每步调用 `next()` 或 `next(false)` */
|
|
3823
|
+
export declare type SiblingRowIterator<TData = RowData> = (params: SiblingRowIteratorParams<TData>) => void;
|
|
3551
3824
|
|
|
3552
|
-
/**
|
|
3825
|
+
/** iterator 回调入参;快照结构与 `getSelectedRows` / `focusedRows` 一致 */
|
|
3553
3826
|
export declare interface SiblingRowIteratorParams<TData = RowData> {
|
|
3554
3827
|
/** 当前正在考察的候选相邻行 */
|
|
3555
|
-
currentRow:
|
|
3556
|
-
/**
|
|
3557
|
-
row:
|
|
3828
|
+
currentRow: RowSnapshot<TData>;
|
|
3829
|
+
/** 锚点行(调用 API 时传入的 `rowId` 对应行,全程不变) */
|
|
3830
|
+
row: RowSnapshot<TData>;
|
|
3831
|
+
/** 步进控制;每个候选行必须调用一次 */
|
|
3832
|
+
next: SiblingRowNext;
|
|
3558
3833
|
}
|
|
3559
3834
|
|
|
3835
|
+
/**
|
|
3836
|
+
* iterator 步进控制。
|
|
3837
|
+
* - `next()` 或 `next(true)`:接受当前候选行
|
|
3838
|
+
* - `next(false)`:在此行终止
|
|
3839
|
+
*/
|
|
3840
|
+
export declare type SiblingRowNext = (continueIteration?: boolean) => void;
|
|
3841
|
+
|
|
3560
3842
|
export declare interface SizeColumnsToContentColumnLimit {
|
|
3561
3843
|
colId: string;
|
|
3562
3844
|
minWidth?: number;
|
|
@@ -3800,6 +4082,18 @@ export declare interface UpdateRowDimensionsParams {
|
|
|
3800
4082
|
rowHeightMax?: number;
|
|
3801
4083
|
}
|
|
3802
4084
|
|
|
4085
|
+
export declare interface UpdateRowItem {
|
|
4086
|
+
/**
|
|
4087
|
+
* 要合并的字段;须含 `rowKey` 以定位持久化行。
|
|
4088
|
+
* 临时行可省略 rowKey,由 apply 层按 data 引用匹配(与 applyTransaction 一致)。
|
|
4089
|
+
*/
|
|
4090
|
+
data: RowData;
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4093
|
+
export declare interface UpdateRowsOptions {
|
|
4094
|
+
rows: UpdateRowItem[];
|
|
4095
|
+
}
|
|
4096
|
+
|
|
3803
4097
|
export declare interface ValidateCellsOptions {
|
|
3804
4098
|
/** 待校验的单元格列表 */
|
|
3805
4099
|
cells: GridCellPosition[];
|