@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;
@@ -43,6 +43,22 @@ function refreshCustomMergeCellGroups(table) {
43
43
  }
44
44
  }
45
45
 
46
+ function isSameRecordIndex(sourceRecordIndex, currentRecordIndex) {
47
+ 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;
48
+ }
49
+
50
+ function isTargetCellSnapshotCurrent(table, snapshot) {
51
+ if (table.isHeader(snapshot.col, snapshot.row) !== snapshot.isHeader) return !1;
52
+ if (snapshot.isHeader) return !0;
53
+ 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);
54
+ return isSameRecordIndex(snapshot.recordIndex, recordIndex) && snapshot.field === field;
55
+ }
56
+
57
+ function areTargetCellSnapshotsCurrent(table, snapshots) {
58
+ 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;
59
+ return !0;
60
+ }
61
+
46
62
  function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
47
63
  var _a, _b;
48
64
  if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
@@ -91,25 +107,53 @@ function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEv
91
107
  }
92
108
  }
93
109
 
94
- function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
95
- var _a, _b;
110
+ function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent, shouldCancel) {
111
+ var _a, _b, _c, _d, _e;
96
112
  return __awaiter(this, void 0, void 0, (function*() {
97
113
  const changedCellResults = [];
98
114
  let pasteColEnd = startCol, pasteRowEnd = startRow;
99
- const beforeChangeValues = [], oldValues = [];
115
+ const beforeChangeValues = [], oldValues = [], targetSnapshots = [];
100
116
  let cellUpdateType;
101
117
  for (let i = 0; i < values.length && !(startRow + i > table.rowCount - 1); i++) {
102
- const rowValues = values[i], rawRowValues = [], oldRowValues = [];
103
- beforeChangeValues.push(rawRowValues), oldValues.push(oldRowValues);
118
+ const rowValues = values[i], rawRowValues = [], oldRowValues = [], rowTargetSnapshots = [];
119
+ beforeChangeValues.push(rawRowValues), oldValues.push(oldRowValues), targetSnapshots.push(rowTargetSnapshots);
104
120
  for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
121
+ const col = startCol + j, row = startRow + i;
105
122
  cellUpdateType = getCellUpdateType(startCol + j, startRow + i, table, cellUpdateType);
106
- const beforeChangeValue = table.getCellRawValue(startCol + j, startRow + i);
123
+ const beforeChangeValue = table.getCellRawValue(col, row);
107
124
  rawRowValues.push(beforeChangeValue);
108
- const oldValue = table.getCellOriginValue(startCol + j, startRow + i);
125
+ const oldValue = table.getCellOriginValue(col, row);
109
126
  oldRowValues.push(oldValue);
127
+ 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);
128
+ rowTargetSnapshots.push({
129
+ col: col,
130
+ row: row,
131
+ isHeader: isHeader,
132
+ recordIndex: recordIndex,
133
+ field: field
134
+ });
110
135
  }
111
136
  }
112
- const resultChangeValues = [];
137
+ const resultChangeValues = [], preValidatedCellResults = shouldCancel && workOnEditableCell ? [] : null;
138
+ if (preValidatedCellResults) for (let i = 0; i < values.length; i++) {
139
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
140
+ if (startRow + i > table.rowCount - 1) break;
141
+ preValidatedCellResults[i] = [];
142
+ const rowValues = values[i];
143
+ for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
144
+ let isCanChange = !1;
145
+ if (table.isHasEditorDefine(startCol + j, startRow + i)) {
146
+ 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, {
147
+ col: startCol + j,
148
+ row: startRow + i
149
+ }, table)) || void 0 === _b || _b, validateResult = (0, helper_1.isPromise)(maybePromiseOrValue) ? yield maybePromiseOrValue : maybePromiseOrValue;
150
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
151
+ isCanChange = !0 === validateResult || "validate-exit" === validateResult || "validate-not-exit" === validateResult;
152
+ }
153
+ preValidatedCellResults[i][j] = isCanChange;
154
+ }
155
+ }
156
+ if ((null == shouldCancel ? void 0 : shouldCancel()) || !areTargetCellSnapshotsCurrent(table, targetSnapshots)) return changedCellResults;
113
157
  for (let i = 0; i < values.length && !(startRow + i > table.rowCount - 1); i++) {
114
158
  changedCellResults[i] = [], pasteRowEnd = startRow + i;
115
159
  const rowValues = values[i];
@@ -117,20 +161,24 @@ function listTableChangeCellValues(startCol, startRow, values, workOnEditableCel
117
161
  for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
118
162
  thisRowPasteColEnd = startCol + j;
119
163
  let isCanChange = !1;
120
- if (!1 === workOnEditableCell) isCanChange = !0; else if (table.isHasEditorDefine(startCol + j, startRow + i)) {
121
- 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, {
164
+ 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)) {
165
+ 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, {
122
166
  col: startCol + j,
123
167
  row: startRow + i
124
- }, table)) || void 0 === _b || _b;
168
+ }, table)) || void 0 === _e || _e;
125
169
  if ((0, helper_1.isPromise)(maybePromiseOrValue)) {
126
170
  const validateResult = yield maybePromiseOrValue;
171
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
127
172
  isCanChange = !0 === validateResult || "validate-exit" === validateResult || "validate-not-exit" === validateResult;
128
173
  } else isCanChange = !0 === maybePromiseOrValue || "validate-exit" === maybePromiseOrValue || "validate-not-exit" === maybePromiseOrValue;
129
174
  }
130
175
  if (isCanChange) {
131
176
  changedCellResults[i][j] = !0;
132
177
  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];
133
- 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);
178
+ if (table.isHeader(startCol + j, startRow + i)) table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value); else {
179
+ const changeResult = table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
180
+ (0, helper_1.isPromise)(changeResult) && (yield changeResult);
181
+ }
134
182
  const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
135
183
  if (oldValue !== changedValue && triggerEvent) {
136
184
  const changeValue = {