@visactor/vtable 1.26.7 → 1.26.8

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.
Files changed (183) hide show
  1. package/cjs/ListTable.d.ts +1 -1
  2. package/cjs/ListTable.js +21 -13
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotChart.js +16 -16
  5. package/cjs/PivotChart.js.map +1 -1
  6. package/cjs/PivotTable.d.ts +1 -1
  7. package/cjs/PivotTable.js +65 -63
  8. package/cjs/PivotTable.js.map +1 -1
  9. package/cjs/body-helper/body-helper.js +2 -1
  10. package/cjs/components/index.js +1 -2
  11. package/cjs/core/BaseTable.js +2 -2
  12. package/cjs/core/BaseTable.js.map +1 -1
  13. package/cjs/core/record-helper.d.ts +1 -1
  14. package/cjs/core/record-helper.js +60 -12
  15. package/cjs/core/record-helper.js.map +1 -1
  16. package/cjs/core/tableHelper.js +2 -1
  17. package/cjs/data/DataSource.d.ts +3 -1
  18. package/cjs/data/DataSource.js +71 -23
  19. package/cjs/data/DataSource.js.map +1 -1
  20. package/cjs/dataset/dataset.d.ts +9 -1
  21. package/cjs/dataset/dataset.js +344 -187
  22. package/cjs/dataset/dataset.js.map +1 -1
  23. package/cjs/event/event.d.ts +94 -8
  24. package/cjs/event/event.js +698 -191
  25. package/cjs/event/event.js.map +1 -1
  26. package/cjs/event/helper.js +1 -1
  27. package/cjs/event/media-click.js +4 -1
  28. package/cjs/event/media-click.js.map +1 -1
  29. package/cjs/event/scroll.js +1 -1
  30. package/cjs/event/sparkline-event.js +1 -2
  31. package/cjs/event/util.js +2 -2
  32. package/cjs/event/util.js.map +1 -1
  33. package/cjs/index.d.ts +1 -1
  34. package/cjs/index.js +1 -1
  35. package/cjs/index.js.map +1 -1
  36. package/cjs/layout/pivot-header-layout.js +33 -17
  37. package/cjs/layout/pivot-header-layout.js.map +1 -1
  38. package/cjs/plugins/custom-cell-style.js +1 -1
  39. package/cjs/plugins/index.js +2 -1
  40. package/cjs/plugins/interface.js +1 -1
  41. package/cjs/plugins/invert-highlight.js +1 -1
  42. package/cjs/plugins/list-tree-stick-cell.js +1 -1
  43. package/cjs/plugins/plugin-manager.js +1 -1
  44. package/cjs/scenegraph/group-creater/cell-helper.js +27 -10
  45. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  46. package/cjs/scenegraph/group-creater/cell-type/text-cell.d.ts +1 -1
  47. package/cjs/scenegraph/group-creater/cell-type/text-cell.js +14 -10
  48. package/cjs/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
  49. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js +17 -4
  50. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  51. package/cjs/scenegraph/layout/compute-col-width.js +6 -1
  52. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  53. package/cjs/scenegraph/layout/compute-row-height.js +11 -3
  54. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  55. package/cjs/scenegraph/layout/update-height.d.ts +4 -3
  56. package/cjs/scenegraph/layout/update-height.js +43 -29
  57. package/cjs/scenegraph/layout/update-height.js.map +1 -1
  58. package/cjs/scenegraph/layout/update-width.d.ts +2 -1
  59. package/cjs/scenegraph/layout/update-width.js +49 -37
  60. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  61. package/cjs/scenegraph/scenegraph.d.ts +2 -2
  62. package/cjs/scenegraph/scenegraph.js +6 -5
  63. package/cjs/scenegraph/scenegraph.js.map +1 -1
  64. package/cjs/scenegraph/utils/corner-custom-merge.d.ts +10 -0
  65. package/cjs/scenegraph/utils/corner-custom-merge.js +68 -0
  66. package/cjs/scenegraph/utils/corner-custom-merge.js.map +1 -0
  67. package/cjs/state/resize/update-resize-column.js +25 -13
  68. package/cjs/state/resize/update-resize-column.js.map +1 -1
  69. package/cjs/state/resize/update-resize-row.js +24 -12
  70. package/cjs/state/resize/update-resize-row.js.map +1 -1
  71. package/cjs/themes.d.ts +4 -2
  72. package/cjs/themes.js +12 -4
  73. package/cjs/themes.js.map +1 -1
  74. package/cjs/tools/get-data-path/create-dataset.js +4 -4
  75. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  76. package/cjs/tools/get-data-path/index.js +4 -4
  77. package/cjs/tools/get-data-path/index.js.map +1 -1
  78. package/cjs/tools/style.d.ts +3 -1
  79. package/cjs/tools/style.js +2 -2
  80. package/cjs/tools/style.js.map +1 -1
  81. package/cjs/ts-types/common.d.ts +1 -0
  82. package/cjs/ts-types/common.js.map +1 -1
  83. package/cjs/ts-types/dataset/aggregation.d.ts +1 -0
  84. package/cjs/ts-types/dataset/aggregation.js +21 -3
  85. package/cjs/ts-types/dataset/aggregation.js.map +1 -1
  86. package/cjs/ts-types/new-data-set.d.ts +1 -0
  87. package/cjs/ts-types/new-data-set.js.map +1 -1
  88. package/cjs/ts-types/table-engine.d.ts +3 -2
  89. package/cjs/ts-types/table-engine.js.map +1 -1
  90. package/cjs/vrender.js.map +1 -1
  91. package/dist/vtable.js +2224 -779
  92. package/dist/vtable.min.js +1 -1
  93. package/es/ListTable.d.ts +1 -1
  94. package/es/ListTable.js +21 -15
  95. package/es/ListTable.js.map +1 -1
  96. package/es/PivotChart.js +16 -16
  97. package/es/PivotChart.js.map +1 -1
  98. package/es/PivotTable.d.ts +1 -1
  99. package/es/PivotTable.js +65 -63
  100. package/es/PivotTable.js.map +1 -1
  101. package/es/body-helper/body-helper.js +2 -1
  102. package/es/components/index.js +1 -2
  103. package/es/core/BaseTable.js +2 -2
  104. package/es/core/BaseTable.js.map +1 -1
  105. package/es/core/record-helper.d.ts +1 -1
  106. package/es/core/record-helper.js +60 -12
  107. package/es/core/record-helper.js.map +1 -1
  108. package/es/core/tableHelper.js +2 -1
  109. package/es/data/DataSource.d.ts +3 -1
  110. package/es/data/DataSource.js +70 -23
  111. package/es/data/DataSource.js.map +1 -1
  112. package/es/dataset/dataset.d.ts +9 -1
  113. package/es/dataset/dataset.js +341 -187
  114. package/es/dataset/dataset.js.map +1 -1
  115. package/es/event/event.d.ts +94 -8
  116. package/es/event/event.js +696 -191
  117. package/es/event/event.js.map +1 -1
  118. package/es/event/helper.js +1 -1
  119. package/es/event/media-click.js +4 -1
  120. package/es/event/media-click.js.map +1 -1
  121. package/es/event/scroll.js +1 -1
  122. package/es/event/sparkline-event.js +1 -2
  123. package/es/event/util.js +2 -2
  124. package/es/event/util.js.map +1 -1
  125. package/es/index.d.ts +1 -1
  126. package/es/index.js +1 -1
  127. package/es/index.js.map +1 -1
  128. package/es/layout/pivot-header-layout.js +29 -17
  129. package/es/layout/pivot-header-layout.js.map +1 -1
  130. package/es/plugins/custom-cell-style.js +1 -1
  131. package/es/plugins/index.js +2 -1
  132. package/es/plugins/interface.js +1 -1
  133. package/es/plugins/invert-highlight.js +1 -1
  134. package/es/plugins/list-tree-stick-cell.js +1 -1
  135. package/es/plugins/plugin-manager.js +1 -1
  136. package/es/scenegraph/group-creater/cell-helper.js +23 -9
  137. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  138. package/es/scenegraph/group-creater/cell-type/text-cell.d.ts +1 -1
  139. package/es/scenegraph/group-creater/cell-type/text-cell.js +13 -8
  140. package/es/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
  141. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js +17 -5
  142. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  143. package/es/scenegraph/layout/compute-col-width.js +6 -1
  144. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  145. package/es/scenegraph/layout/compute-row-height.js +11 -3
  146. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  147. package/es/scenegraph/layout/update-height.d.ts +4 -3
  148. package/es/scenegraph/layout/update-height.js +40 -26
  149. package/es/scenegraph/layout/update-height.js.map +1 -1
  150. package/es/scenegraph/layout/update-width.d.ts +2 -1
  151. package/es/scenegraph/layout/update-width.js +46 -34
  152. package/es/scenegraph/layout/update-width.js.map +1 -1
  153. package/es/scenegraph/scenegraph.d.ts +2 -2
  154. package/es/scenegraph/scenegraph.js +7 -5
  155. package/es/scenegraph/scenegraph.js.map +1 -1
  156. package/es/scenegraph/utils/corner-custom-merge.d.ts +10 -0
  157. package/es/scenegraph/utils/corner-custom-merge.js +59 -0
  158. package/es/scenegraph/utils/corner-custom-merge.js.map +1 -0
  159. package/es/state/resize/update-resize-column.js +19 -10
  160. package/es/state/resize/update-resize-column.js.map +1 -1
  161. package/es/state/resize/update-resize-row.js +19 -9
  162. package/es/state/resize/update-resize-row.js.map +1 -1
  163. package/es/themes.d.ts +4 -2
  164. package/es/themes.js +11 -3
  165. package/es/themes.js.map +1 -1
  166. package/es/tools/get-data-path/create-dataset.js +4 -4
  167. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  168. package/es/tools/get-data-path/index.js +4 -4
  169. package/es/tools/get-data-path/index.js.map +1 -1
  170. package/es/tools/style.d.ts +3 -1
  171. package/es/tools/style.js +2 -2
  172. package/es/tools/style.js.map +1 -1
  173. package/es/ts-types/common.d.ts +1 -0
  174. package/es/ts-types/common.js.map +1 -1
  175. package/es/ts-types/dataset/aggregation.d.ts +1 -0
  176. package/es/ts-types/dataset/aggregation.js +21 -3
  177. package/es/ts-types/dataset/aggregation.js.map +1 -1
  178. package/es/ts-types/new-data-set.d.ts +1 -0
  179. package/es/ts-types/new-data-set.js.map +1 -1
  180. package/es/ts-types/table-engine.d.ts +3 -2
  181. package/es/ts-types/table-engine.js.map +1 -1
  182. package/es/vrender.js.map +1 -1
  183. package/package.json +9 -9
@@ -1,7 +1,7 @@
1
1
  import type { ListTable } from '../ListTable';
2
2
  import type { CellRange } from '../ts-types';
3
3
  export declare function listTableChangeCellValue(col: number, row: number, value: string | number | null, workOnEditableCell: boolean, triggerEvent: boolean, table: ListTable, noTriggerChangeCellValuesEvent?: boolean): void;
4
- export declare function listTableChangeCellValues(startCol: number, startRow: number, values: (string | number)[][], workOnEditableCell: boolean, triggerEvent: boolean, table: ListTable, noTriggerChangeCellValuesEvent?: boolean): Promise<boolean[][]>;
4
+ export declare function listTableChangeCellValues(startCol: number, startRow: number, values: (string | number)[][], workOnEditableCell: boolean, triggerEvent: boolean, table: ListTable, noTriggerChangeCellValuesEvent?: boolean, shouldCancel?: () => boolean): Promise<boolean[][]>;
5
5
  export declare function listTableChangeCellValuesByRanges(ranges: CellRange[], value: string | number | null, workOnEditableCell: boolean, triggerEvent: boolean, table: ListTable, noTriggerChangeCellValuesEvent?: boolean): Promise<void>;
6
6
  export declare function sortRecords(table: ListTable): void;
7
7
  export declare function listTableAddRecord(record: any, recordIndex: number | number[], table: ListTable): boolean;
@@ -49,6 +49,22 @@ function refreshCustomMergeCellGroups(table) {
49
49
  }
50
50
  }
51
51
 
52
+ function isSameRecordIndex(sourceRecordIndex, currentRecordIndex) {
53
+ return Array.isArray(sourceRecordIndex) || Array.isArray(currentRecordIndex) ? Array.isArray(sourceRecordIndex) && Array.isArray(currentRecordIndex) && sourceRecordIndex.length === currentRecordIndex.length && sourceRecordIndex.every(((value, index) => value === currentRecordIndex[index])) : sourceRecordIndex === currentRecordIndex;
54
+ }
55
+
56
+ function isTargetCellSnapshotCurrent(table, snapshot) {
57
+ if (table.isHeader(snapshot.col, snapshot.row) !== snapshot.isHeader) return !1;
58
+ if (snapshot.isHeader) return !0;
59
+ const recordShowIndex = table.getRecordShowIndexByCell(snapshot.col, snapshot.row), recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0, {field: field} = table.internalProps.layoutMap.getBody(snapshot.col, snapshot.row);
60
+ return isSameRecordIndex(snapshot.recordIndex, recordIndex) && snapshot.field === field;
61
+ }
62
+
63
+ function areTargetCellSnapshotsCurrent(table, snapshots) {
64
+ for (let i = 0; i < snapshots.length; i++) for (let j = 0; j < snapshots[i].length; j++) if (!isTargetCellSnapshotCurrent(table, snapshots[i][j])) return !1;
65
+ return !0;
66
+ }
67
+
52
68
  export function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
53
69
  var _a, _b;
54
70
  if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
@@ -96,25 +112,53 @@ export function listTableChangeCellValue(col, row, value, workOnEditableCell, tr
96
112
  }
97
113
  }
98
114
 
99
- export function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
100
- var _a, _b;
115
+ export function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent, shouldCancel) {
116
+ var _a, _b, _c, _d, _e;
101
117
  return __awaiter(this, void 0, void 0, (function*() {
102
118
  const changedCellResults = [];
103
119
  let pasteColEnd = startCol, pasteRowEnd = startRow;
104
- const beforeChangeValues = [], oldValues = [];
120
+ const beforeChangeValues = [], oldValues = [], targetSnapshots = [];
105
121
  let cellUpdateType;
106
122
  for (let i = 0; i < values.length && !(startRow + i > table.rowCount - 1); i++) {
107
- const rowValues = values[i], rawRowValues = [], oldRowValues = [];
108
- beforeChangeValues.push(rawRowValues), oldValues.push(oldRowValues);
123
+ const rowValues = values[i], rawRowValues = [], oldRowValues = [], rowTargetSnapshots = [];
124
+ beforeChangeValues.push(rawRowValues), oldValues.push(oldRowValues), targetSnapshots.push(rowTargetSnapshots);
109
125
  for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
126
+ const col = startCol + j, row = startRow + i;
110
127
  cellUpdateType = getCellUpdateType(startCol + j, startRow + i, table, cellUpdateType);
111
- const beforeChangeValue = table.getCellRawValue(startCol + j, startRow + i);
128
+ const beforeChangeValue = table.getCellRawValue(col, row);
112
129
  rawRowValues.push(beforeChangeValue);
113
- const oldValue = table.getCellOriginValue(startCol + j, startRow + i);
130
+ const oldValue = table.getCellOriginValue(col, row);
114
131
  oldRowValues.push(oldValue);
132
+ const isHeader = table.isHeader(col, row), recordShowIndex = table.getRecordShowIndexByCell(col, row), recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0, {field: field} = table.internalProps.layoutMap.getBody(col, row);
133
+ rowTargetSnapshots.push({
134
+ col: col,
135
+ row: row,
136
+ isHeader: isHeader,
137
+ recordIndex: recordIndex,
138
+ field: field
139
+ });
115
140
  }
116
141
  }
117
- const resultChangeValues = [];
142
+ const resultChangeValues = [], preValidatedCellResults = shouldCancel && workOnEditableCell ? [] : null;
143
+ if (preValidatedCellResults) for (let i = 0; i < values.length; i++) {
144
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
145
+ if (startRow + i > table.rowCount - 1) break;
146
+ preValidatedCellResults[i] = [];
147
+ const rowValues = values[i];
148
+ for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
149
+ let isCanChange = !1;
150
+ if (table.isHasEditorDefine(startCol + j, startRow + i)) {
151
+ const editor = table.getEditor(startCol + j, startRow + i), oldValue = oldValues[i][j], value = rowValues[j], maybePromiseOrValue = null === (_b = null === (_a = null == editor ? void 0 : editor.validateValue) || void 0 === _a ? void 0 : _a.call(editor, value, oldValue, {
152
+ col: startCol + j,
153
+ row: startRow + i
154
+ }, table)) || void 0 === _b || _b, validateResult = isPromise(maybePromiseOrValue) ? yield maybePromiseOrValue : maybePromiseOrValue;
155
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
156
+ isCanChange = !0 === validateResult || "validate-exit" === validateResult || "validate-not-exit" === validateResult;
157
+ }
158
+ preValidatedCellResults[i][j] = isCanChange;
159
+ }
160
+ }
161
+ if ((null == shouldCancel ? void 0 : shouldCancel()) || !areTargetCellSnapshotsCurrent(table, targetSnapshots)) return changedCellResults;
118
162
  for (let i = 0; i < values.length && !(startRow + i > table.rowCount - 1); i++) {
119
163
  changedCellResults[i] = [], pasteRowEnd = startRow + i;
120
164
  const rowValues = values[i];
@@ -122,20 +166,24 @@ export function listTableChangeCellValues(startCol, startRow, values, workOnEdit
122
166
  for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
123
167
  thisRowPasteColEnd = startCol + j;
124
168
  let isCanChange = !1;
125
- if (!1 === workOnEditableCell) isCanChange = !0; else if (table.isHasEditorDefine(startCol + j, startRow + i)) {
126
- const editor = table.getEditor(startCol + j, startRow + i), oldValue = oldValues[i][j], value = rowValues[j], maybePromiseOrValue = null === (_b = null === (_a = null == editor ? void 0 : editor.validateValue) || void 0 === _a ? void 0 : _a.call(editor, value, oldValue, {
169
+ if (preValidatedCellResults) isCanChange = !0 === (null === (_c = preValidatedCellResults[i]) || void 0 === _c ? void 0 : _c[j]); else if (!1 === workOnEditableCell) isCanChange = !0; else if (table.isHasEditorDefine(startCol + j, startRow + i)) {
170
+ const editor = table.getEditor(startCol + j, startRow + i), oldValue = oldValues[i][j], value = rowValues[j], maybePromiseOrValue = null === (_e = null === (_d = null == editor ? void 0 : editor.validateValue) || void 0 === _d ? void 0 : _d.call(editor, value, oldValue, {
127
171
  col: startCol + j,
128
172
  row: startRow + i
129
- }, table)) || void 0 === _b || _b;
173
+ }, table)) || void 0 === _e || _e;
130
174
  if (isPromise(maybePromiseOrValue)) {
131
175
  const validateResult = yield maybePromiseOrValue;
176
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
132
177
  isCanChange = !0 === validateResult || "validate-exit" === validateResult || "validate-not-exit" === validateResult;
133
178
  } else isCanChange = !0 === maybePromiseOrValue || "validate-exit" === maybePromiseOrValue || "validate-not-exit" === maybePromiseOrValue;
134
179
  }
135
180
  if (isCanChange) {
136
181
  changedCellResults[i][j] = !0;
137
182
  const value = rowValues[j], recordShowIndex = table.getRecordShowIndexByCell(startCol + j, startRow + i), recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0, {field: field} = table.internalProps.layoutMap.getBody(startCol + j, startRow + i), beforeChangeValue = beforeChangeValues[i][j], oldValue = oldValues[i][j];
138
- table.isHeader(startCol + j, startRow + i) ? table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
183
+ if (table.isHeader(startCol + j, startRow + i)) table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value); else {
184
+ const changeResult = table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
185
+ isPromise(changeResult) && (yield changeResult);
186
+ }
139
187
  const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
140
188
  if (oldValue !== changedValue && triggerEvent) {
141
189
  const changeValue = {