handsontable 0.0.0-next-7b93b7d-20231107 → 0.0.0-next-5f253b5-20231108

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (42) hide show
  1. package/3rdparty/walkontable/src/cell/coords.js +7 -5
  2. package/3rdparty/walkontable/src/cell/coords.mjs +7 -5
  3. package/base.js +2 -2
  4. package/base.mjs +2 -2
  5. package/dist/handsontable.css +2 -2
  6. package/dist/handsontable.full.css +2 -2
  7. package/dist/handsontable.full.js +102 -51
  8. package/dist/handsontable.full.min.css +2 -2
  9. package/dist/handsontable.full.min.js +10 -10
  10. package/dist/handsontable.js +102 -51
  11. package/dist/handsontable.min.css +2 -2
  12. package/dist/handsontable.min.js +10 -10
  13. package/helpers/mixed.js +1 -1
  14. package/helpers/mixed.mjs +1 -1
  15. package/package.json +1 -1
  16. package/plugins/autofill/autofill.d.ts +0 -1
  17. package/plugins/autofill/autofill.js +1 -0
  18. package/plugins/autofill/autofill.mjs +1 -0
  19. package/plugins/base/base.js +4 -6
  20. package/plugins/base/base.mjs +4 -6
  21. package/plugins/columnSorting/columnSorting.js +2 -1
  22. package/plugins/columnSorting/columnSorting.mjs +2 -1
  23. package/plugins/contextMenu/contextMenu.js +5 -1
  24. package/plugins/contextMenu/contextMenu.mjs +5 -1
  25. package/plugins/contextMenu/predefinedItems/removeColumn.js +1 -1
  26. package/plugins/contextMenu/predefinedItems/removeColumn.mjs +1 -1
  27. package/plugins/contextMenu/predefinedItems/removeRow.js +1 -1
  28. package/plugins/contextMenu/predefinedItems/removeRow.mjs +1 -1
  29. package/plugins/customBorders/customBorders.js +8 -2
  30. package/plugins/customBorders/customBorders.mjs +8 -2
  31. package/plugins/dropdownMenu/dropdownMenu.js +4 -2
  32. package/plugins/dropdownMenu/dropdownMenu.mjs +4 -2
  33. package/plugins/multiColumnSorting/multiColumnSorting.js +2 -1
  34. package/plugins/multiColumnSorting/multiColumnSorting.mjs +2 -1
  35. package/plugins/nestedRows/nestedRows.js +12 -4
  36. package/plugins/nestedRows/nestedRows.mjs +12 -4
  37. package/selection/selection.js +25 -7
  38. package/selection/selection.mjs +25 -7
  39. package/selection/utils.js +24 -14
  40. package/selection/utils.mjs +25 -15
  41. package/shortcuts/manager.js +1 -1
  42. package/shortcuts/manager.mjs +1 -1
@@ -64,7 +64,9 @@ function detectSelectionType(selectionRanges) {
64
64
  * Factory function designed for normalization data schema from different data structures of the selection ranges.
65
65
  *
66
66
  * @param {number} type Selection type which will be processed.
67
- * @param {object} [options] The normalization options.
67
+ * @param {object} options The normalization options.
68
+ * @param {function(number, number): CellCoords} options.createCellCoords The factory function that returns an instance of the `CellCoords` class.
69
+ * @param {function(CellCoords, CellCoords, CellCoords): CellRange} options.createCellRange The factory function that returns an instance of the `CellRange` class.
68
70
  * @param {boolean} [options.keepDirection=false] If `true`, the coordinates which contain the direction of the
69
71
  * selected cells won't be changed. Otherwise, the selection will be
70
72
  * normalized to values starting from top-left to bottom-right.
@@ -74,6 +76,8 @@ function detectSelectionType(selectionRanges) {
74
76
  */
75
77
  function normalizeSelectionFactory(type) {
76
78
  let {
79
+ createCellCoords,
80
+ createCellRange,
77
81
  keepDirection = false,
78
82
  propToCol
79
83
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -110,9 +114,9 @@ function normalizeSelectionFactory(type) {
110
114
  rowEnd = Math.max(origRowStart, origRowEnd);
111
115
  columnEnd = Math.max(origColumnStart, origColumnEnd);
112
116
  }
113
- const from = new _src.CellCoords(rowStart, columnStart);
114
- const to = new _src.CellCoords(rowEnd, columnEnd);
115
- return new _src.CellRange(from, from, to);
117
+ const from = createCellCoords(rowStart, columnStart);
118
+ const to = createCellCoords(rowEnd, columnEnd);
119
+ return createCellRange(from, from, to);
116
120
  };
117
121
  }
118
122
 
@@ -122,22 +126,25 @@ function normalizeSelectionFactory(type) {
122
126
  * contains an array of arrays. The single item contains at index 0 visual column index from the selection was
123
127
  * started and at index 1 distance as a count of selected columns.
124
128
  *
125
- * @param {Array[]|CellRange[]} selectionRanges Selection ranges produced by Handsontable.
129
+ * @param {Core} hotInstance The Handsontable instance.
126
130
  * @returns {Array[]} Returns an array of arrays with ranges defines in that schema:
127
131
  * `[[visualColumnStart, distance], [visualColumnStart, distance], ...]`.
128
132
  * The column distances are always created starting from the left (zero index) to the
129
133
  * right (the latest column index).
130
134
  */
131
- function transformSelectionToColumnDistance(selectionRanges) {
132
- const selectionType = detectSelectionType(selectionRanges);
135
+ function transformSelectionToColumnDistance(hotInstance) {
136
+ const selectionType = detectSelectionType(hotInstance.getSelected());
133
137
  if (selectionType === SELECTION_TYPE_UNRECOGNIZED || selectionType === SELECTION_TYPE_EMPTY) {
134
138
  return [];
135
139
  }
136
- const selectionSchemaNormalizer = normalizeSelectionFactory(selectionType);
140
+ const selectionSchemaNormalizer = normalizeSelectionFactory(selectionType, {
141
+ createCellCoords: hotInstance._createCellCoords.bind(hotInstance),
142
+ createCellRange: hotInstance._createCellRange.bind(hotInstance)
143
+ });
137
144
  const unorderedIndexes = new Set();
138
145
 
139
146
  // Iterate through all ranges and collect all column indexes which are not saved yet.
140
- (0, _array.arrayEach)(selectionRanges, selection => {
147
+ (0, _array.arrayEach)(hotInstance.getSelected(), selection => {
141
148
  const {
142
149
  from,
143
150
  to
@@ -170,22 +177,25 @@ function transformSelectionToColumnDistance(selectionRanges) {
170
177
  * contains an array of arrays. The single item contains at index 0 visual column index from the selection was
171
178
  * started and at index 1 distance as a count of selected columns.
172
179
  *
173
- * @param {Array[]|CellRange[]} selectionRanges Selection ranges produced by Handsontable.
180
+ * @param {Core} hotInstance The Handsontable instance.
174
181
  * @returns {Array[]} Returns an array of arrays with ranges defines in that schema:
175
182
  * `[[visualColumnStart, distance], [visualColumnStart, distance], ...]`.
176
183
  * The column distances are always created starting from the left (zero index) to the
177
184
  * right (the latest column index).
178
185
  */
179
- function transformSelectionToRowDistance(selectionRanges) {
180
- const selectionType = detectSelectionType(selectionRanges);
186
+ function transformSelectionToRowDistance(hotInstance) {
187
+ const selectionType = detectSelectionType(hotInstance.getSelected());
181
188
  if (selectionType === SELECTION_TYPE_UNRECOGNIZED || selectionType === SELECTION_TYPE_EMPTY) {
182
189
  return [];
183
190
  }
184
- const selectionSchemaNormalizer = normalizeSelectionFactory(selectionType);
191
+ const selectionSchemaNormalizer = normalizeSelectionFactory(selectionType, {
192
+ createCellCoords: hotInstance._createCellCoords.bind(hotInstance),
193
+ createCellRange: hotInstance._createCellRange.bind(hotInstance)
194
+ });
185
195
  const unorderedIndexes = new Set();
186
196
 
187
197
  // Iterate through all ranges and collect all column indexes which are not saved yet.
188
- (0, _array.arrayEach)(selectionRanges, selection => {
198
+ (0, _array.arrayEach)(hotInstance.getSelected(), selection => {
189
199
  const {
190
200
  from,
191
201
  to
@@ -1,6 +1,6 @@
1
1
  import "core-js/modules/es.error.cause.js";
2
2
  import "core-js/modules/es.array.push.js";
3
- import { CellRange, CellCoords } from "./../3rdparty/walkontable/src/index.mjs";
3
+ import { CellRange } from "./../3rdparty/walkontable/src/index.mjs";
4
4
  import { arrayEach, arrayReduce } from "./../helpers/array.mjs";
5
5
  import { isUndefined } from "./../helpers/mixed.mjs";
6
6
  export const SELECTION_TYPE_UNRECOGNIZED = 0;
@@ -52,7 +52,9 @@ export function detectSelectionType(selectionRanges) {
52
52
  * Factory function designed for normalization data schema from different data structures of the selection ranges.
53
53
  *
54
54
  * @param {number} type Selection type which will be processed.
55
- * @param {object} [options] The normalization options.
55
+ * @param {object} options The normalization options.
56
+ * @param {function(number, number): CellCoords} options.createCellCoords The factory function that returns an instance of the `CellCoords` class.
57
+ * @param {function(CellCoords, CellCoords, CellCoords): CellRange} options.createCellRange The factory function that returns an instance of the `CellRange` class.
56
58
  * @param {boolean} [options.keepDirection=false] If `true`, the coordinates which contain the direction of the
57
59
  * selected cells won't be changed. Otherwise, the selection will be
58
60
  * normalized to values starting from top-left to bottom-right.
@@ -62,6 +64,8 @@ export function detectSelectionType(selectionRanges) {
62
64
  */
63
65
  export function normalizeSelectionFactory(type) {
64
66
  let {
67
+ createCellCoords,
68
+ createCellRange,
65
69
  keepDirection = false,
66
70
  propToCol
67
71
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -98,9 +102,9 @@ export function normalizeSelectionFactory(type) {
98
102
  rowEnd = Math.max(origRowStart, origRowEnd);
99
103
  columnEnd = Math.max(origColumnStart, origColumnEnd);
100
104
  }
101
- const from = new CellCoords(rowStart, columnStart);
102
- const to = new CellCoords(rowEnd, columnEnd);
103
- return new CellRange(from, from, to);
105
+ const from = createCellCoords(rowStart, columnStart);
106
+ const to = createCellCoords(rowEnd, columnEnd);
107
+ return createCellRange(from, from, to);
104
108
  };
105
109
  }
106
110
 
@@ -110,22 +114,25 @@ export function normalizeSelectionFactory(type) {
110
114
  * contains an array of arrays. The single item contains at index 0 visual column index from the selection was
111
115
  * started and at index 1 distance as a count of selected columns.
112
116
  *
113
- * @param {Array[]|CellRange[]} selectionRanges Selection ranges produced by Handsontable.
117
+ * @param {Core} hotInstance The Handsontable instance.
114
118
  * @returns {Array[]} Returns an array of arrays with ranges defines in that schema:
115
119
  * `[[visualColumnStart, distance], [visualColumnStart, distance], ...]`.
116
120
  * The column distances are always created starting from the left (zero index) to the
117
121
  * right (the latest column index).
118
122
  */
119
- export function transformSelectionToColumnDistance(selectionRanges) {
120
- const selectionType = detectSelectionType(selectionRanges);
123
+ export function transformSelectionToColumnDistance(hotInstance) {
124
+ const selectionType = detectSelectionType(hotInstance.getSelected());
121
125
  if (selectionType === SELECTION_TYPE_UNRECOGNIZED || selectionType === SELECTION_TYPE_EMPTY) {
122
126
  return [];
123
127
  }
124
- const selectionSchemaNormalizer = normalizeSelectionFactory(selectionType);
128
+ const selectionSchemaNormalizer = normalizeSelectionFactory(selectionType, {
129
+ createCellCoords: hotInstance._createCellCoords.bind(hotInstance),
130
+ createCellRange: hotInstance._createCellRange.bind(hotInstance)
131
+ });
125
132
  const unorderedIndexes = new Set();
126
133
 
127
134
  // Iterate through all ranges and collect all column indexes which are not saved yet.
128
- arrayEach(selectionRanges, selection => {
135
+ arrayEach(hotInstance.getSelected(), selection => {
129
136
  const {
130
137
  from,
131
138
  to
@@ -158,22 +165,25 @@ export function transformSelectionToColumnDistance(selectionRanges) {
158
165
  * contains an array of arrays. The single item contains at index 0 visual column index from the selection was
159
166
  * started and at index 1 distance as a count of selected columns.
160
167
  *
161
- * @param {Array[]|CellRange[]} selectionRanges Selection ranges produced by Handsontable.
168
+ * @param {Core} hotInstance The Handsontable instance.
162
169
  * @returns {Array[]} Returns an array of arrays with ranges defines in that schema:
163
170
  * `[[visualColumnStart, distance], [visualColumnStart, distance], ...]`.
164
171
  * The column distances are always created starting from the left (zero index) to the
165
172
  * right (the latest column index).
166
173
  */
167
- export function transformSelectionToRowDistance(selectionRanges) {
168
- const selectionType = detectSelectionType(selectionRanges);
174
+ export function transformSelectionToRowDistance(hotInstance) {
175
+ const selectionType = detectSelectionType(hotInstance.getSelected());
169
176
  if (selectionType === SELECTION_TYPE_UNRECOGNIZED || selectionType === SELECTION_TYPE_EMPTY) {
170
177
  return [];
171
178
  }
172
- const selectionSchemaNormalizer = normalizeSelectionFactory(selectionType);
179
+ const selectionSchemaNormalizer = normalizeSelectionFactory(selectionType, {
180
+ createCellCoords: hotInstance._createCellCoords.bind(hotInstance),
181
+ createCellRange: hotInstance._createCellRange.bind(hotInstance)
182
+ });
173
183
  const unorderedIndexes = new Set();
174
184
 
175
185
  // Iterate through all ranges and collect all column indexes which are not saved yet.
176
- arrayEach(selectionRanges, selection => {
186
+ arrayEach(hotInstance.getSelected(), selection => {
177
187
  const {
178
188
  from,
179
189
  to
@@ -131,7 +131,7 @@ const createShortcutManager = _ref => {
131
131
  captureCtrl,
132
132
  forwardToContext
133
133
  } = shortcuts[index];
134
- if (runOnlyIf(event) !== false) {
134
+ if (runOnlyIf(event) === true) {
135
135
  isCtrlKeySilenced = captureCtrl;
136
136
  isExecutionCancelled = callback(event, keys) === false;
137
137
  isCtrlKeySilenced = false;
@@ -128,7 +128,7 @@ export const createShortcutManager = _ref => {
128
128
  captureCtrl,
129
129
  forwardToContext
130
130
  } = shortcuts[index];
131
- if (runOnlyIf(event) !== false) {
131
+ if (runOnlyIf(event) === true) {
132
132
  isCtrlKeySilenced = captureCtrl;
133
133
  isExecutionCancelled = callback(event, keys) === false;
134
134
  isCtrlKeySilenced = false;