handsontable 0.0.0-next-44acfea-20231127 → 0.0.0-next-301795f-20231127

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.

package/focusManager.js CHANGED
@@ -33,7 +33,6 @@ var _hot = /*#__PURE__*/new WeakMap();
33
33
  var _focusMode = /*#__PURE__*/new WeakMap();
34
34
  var _refocusDelay = /*#__PURE__*/new WeakMap();
35
35
  var _refocusElementGetter = /*#__PURE__*/new WeakMap();
36
- var _getCurrentHighlightCoords = /*#__PURE__*/new WeakSet();
37
36
  var _getSelectedCell = /*#__PURE__*/new WeakSet();
38
37
  var _manageFocus = /*#__PURE__*/new WeakSet();
39
38
  var _onUpdateSettings = /*#__PURE__*/new WeakSet();
@@ -57,15 +56,9 @@ class FocusManager {
57
56
  * Get and return the currently selected and highlighted cell/header element.
58
57
  *
59
58
  * @private
60
- * @returns {HTMLTableCellElement}
59
+ * @param {Function} [callback] Callback function to be called after the cell element is retrieved.
61
60
  */
62
61
  _classPrivateMethodInitSpec(this, _getSelectedCell);
63
- /**
64
- * Get the coordinates of the highlight of the currently selected cell/header.
65
- *
66
- * @returns {CellCoords}
67
- */
68
- _classPrivateMethodInitSpec(this, _getCurrentHighlightCoords);
69
62
  /**
70
63
  * The Handsontable instance.
71
64
  */
@@ -195,17 +188,26 @@ class FocusManager {
195
188
  * @param {HTMLTableCellElement} [selectedCell] The highlighted cell/header element.
196
189
  */
197
190
  focusOnHighlightedCell(selectedCell) {
198
- var _classPrivateFieldGet3;
199
- const currentHighlightCoords = _classPrivateMethodGet(this, _getCurrentHighlightCoords, _getCurrentHighlightCoords2).call(this);
200
- const currentlySelectedHighlight = selectedCell || _classPrivateMethodGet(this, _getSelectedCell, _getSelectedCell2).call(this);
201
- let elementToBeFocused = _classPrivateFieldGet(this, _hot).runHooks('modifyFocusedElement', currentHighlightCoords.row, currentHighlightCoords.col, currentlySelectedHighlight);
202
- if (!(elementToBeFocused instanceof HTMLElement)) {
203
- elementToBeFocused = currentlySelectedHighlight;
204
- }
205
- if (elementToBeFocused && !((_classPrivateFieldGet3 = _classPrivateFieldGet(this, _hot).getActiveEditor()) !== null && _classPrivateFieldGet3 !== void 0 && _classPrivateFieldGet3.isOpened())) {
206
- elementToBeFocused.focus({
207
- preventScroll: true
208
- });
191
+ const focusElement = element => {
192
+ var _classPrivateFieldGet3, _classPrivateFieldGet4;
193
+ const currentHighlightCoords = (_classPrivateFieldGet3 = _classPrivateFieldGet(this, _hot).getSelectedRangeLast()) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.highlight;
194
+ if (!currentHighlightCoords || !element) {
195
+ return;
196
+ }
197
+ let elementToBeFocused = _classPrivateFieldGet(this, _hot).runHooks('modifyFocusedElement', currentHighlightCoords.row, currentHighlightCoords.col, element);
198
+ if (!(elementToBeFocused instanceof HTMLElement)) {
199
+ elementToBeFocused = element;
200
+ }
201
+ if (elementToBeFocused && !((_classPrivateFieldGet4 = _classPrivateFieldGet(this, _hot).getActiveEditor()) !== null && _classPrivateFieldGet4 !== void 0 && _classPrivateFieldGet4.isOpened())) {
202
+ elementToBeFocused.focus({
203
+ preventScroll: true
204
+ });
205
+ }
206
+ };
207
+ if (selectedCell) {
208
+ focusElement(selectedCell);
209
+ } else {
210
+ _classPrivateMethodGet(this, _getSelectedCell, _getSelectedCell2).call(this, element => focusElement(element));
209
211
  }
210
212
  }
211
213
 
@@ -216,12 +218,12 @@ class FocusManager {
216
218
  * @param {number} delay Delay in milliseconds.
217
219
  */
218
220
  refocusToEditorTextarea() {
219
- var _classPrivateFieldGet4;
221
+ var _classPrivateFieldGet5;
220
222
  let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _classPrivateFieldGet(this, _refocusDelay);
221
223
  const refocusElement = this.getRefocusElement();
222
224
 
223
225
  // Re-focus on the editor's `TEXTAREA` element (or a predefined element) if the `imeFastEdit` option is enabled.
224
- if (_classPrivateFieldGet(this, _hot).getSettings().imeFastEdit && !((_classPrivateFieldGet4 = _classPrivateFieldGet(this, _hot).getActiveEditor()) !== null && _classPrivateFieldGet4 !== void 0 && _classPrivateFieldGet4.isOpened()) && !!refocusElement) {
226
+ if (_classPrivateFieldGet(this, _hot).getSettings().imeFastEdit && !((_classPrivateFieldGet5 = _classPrivateFieldGet(this, _hot).getActiveEditor()) !== null && _classPrivateFieldGet5 !== void 0 && _classPrivateFieldGet5.isOpened()) && !!refocusElement) {
225
227
  _classPrivateFieldGet(this, _hot)._registerTimeout(() => {
226
228
  refocusElement.select();
227
229
  }, delay);
@@ -229,34 +231,44 @@ class FocusManager {
229
231
  }
230
232
  }
231
233
  exports.FocusManager = FocusManager;
232
- function _getCurrentHighlightCoords2() {
233
- const lastSelectedRange = _classPrivateFieldGet(this, _hot).getSelectedRangeLast();
234
- return lastSelectedRange.highlight;
235
- }
236
234
  function _getSelectedCell2() {
237
- const selectedCellCoords = _classPrivateMethodGet(this, _getCurrentHighlightCoords, _getCurrentHighlightCoords2).call(this);
238
- return _classPrivateFieldGet(this, _hot).getCell(selectedCellCoords.row, selectedCellCoords.col, true);
239
- }
240
- function _manageFocus2() {
241
- const selectedCell = _classPrivateMethodGet(this, _getSelectedCell, _getSelectedCell2).call(this);
242
- const {
243
- activeElement
244
- } = _classPrivateFieldGet(this, _hot).rootDocument;
245
-
246
- // Blurring the `activeElement` removes the unwanted border around the focusable element (#6877)
247
- // and resets the `document.activeElement` property. The blurring should happen only when the
248
- // previously selected input element has not belonged to the Handsontable editor. If blurring is
249
- // triggered for all elements, there is a problem with the disappearing IME editor (#9672).
250
- if (activeElement && (0, _element.isOutsideInput)(activeElement)) {
251
- activeElement.blur();
235
+ var _classPrivateFieldGet6;
236
+ let callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
237
+ const highlight = (_classPrivateFieldGet6 = _classPrivateFieldGet(this, _hot).getSelectedRangeLast()) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.highlight;
238
+ if (!highlight) {
239
+ _classPrivateFieldGet(this, _hot)._registerTimeout(() => callback(null));
240
+ return;
252
241
  }
253
- this.focusOnHighlightedCell(selectedCell);
254
- if (this.getFocusMode() === FOCUS_MODES.MIXED && selectedCell.nodeName === 'TD') {
255
- _classPrivateFieldGet(this, _hot).addHookOnce('afterSelectionEnd', () => {
256
- this.refocusToEditorTextarea();
242
+ const cell = _classPrivateFieldGet(this, _hot).getCell(highlight.row, highlight.col, true);
243
+ if (cell === null) {
244
+ _classPrivateFieldGet(this, _hot).addHookOnce('afterScroll', () => {
245
+ callback(_classPrivateFieldGet(this, _hot).getCell(highlight.row, highlight.col, true));
257
246
  });
247
+ } else {
248
+ callback(cell);
258
249
  }
259
250
  }
251
+ function _manageFocus2() {
252
+ _classPrivateMethodGet(this, _getSelectedCell, _getSelectedCell2).call(this, selectedCell => {
253
+ const {
254
+ activeElement
255
+ } = _classPrivateFieldGet(this, _hot).rootDocument;
256
+
257
+ // Blurring the `activeElement` removes the unwanted border around the focusable element (#6877)
258
+ // and resets the `document.activeElement` property. The blurring should happen only when the
259
+ // previously selected input element has not belonged to the Handsontable editor. If blurring is
260
+ // triggered for all elements, there is a problem with the disappearing IME editor (#9672).
261
+ if (activeElement && (0, _element.isOutsideInput)(activeElement)) {
262
+ activeElement.blur();
263
+ }
264
+ this.focusOnHighlightedCell(selectedCell);
265
+ if (this.getFocusMode() === FOCUS_MODES.MIXED && selectedCell.nodeName === 'TD') {
266
+ _classPrivateFieldGet(this, _hot).addHookOnce('afterSelectionEnd', () => {
267
+ this.refocusToEditorTextarea();
268
+ });
269
+ }
270
+ });
271
+ }
260
272
  function _onUpdateSettings2(newSettings) {
261
273
  if (newSettings.imeFastEdit && this.getFocusMode() !== FOCUS_MODES.MIXED) {
262
274
  this.setFocusMode(FOCUS_MODES.MIXED);
package/focusManager.mjs CHANGED
@@ -30,7 +30,6 @@ var _hot = /*#__PURE__*/new WeakMap();
30
30
  var _focusMode = /*#__PURE__*/new WeakMap();
31
31
  var _refocusDelay = /*#__PURE__*/new WeakMap();
32
32
  var _refocusElementGetter = /*#__PURE__*/new WeakMap();
33
- var _getCurrentHighlightCoords = /*#__PURE__*/new WeakSet();
34
33
  var _getSelectedCell = /*#__PURE__*/new WeakSet();
35
34
  var _manageFocus = /*#__PURE__*/new WeakSet();
36
35
  var _onUpdateSettings = /*#__PURE__*/new WeakSet();
@@ -54,15 +53,9 @@ export class FocusManager {
54
53
  * Get and return the currently selected and highlighted cell/header element.
55
54
  *
56
55
  * @private
57
- * @returns {HTMLTableCellElement}
56
+ * @param {Function} [callback] Callback function to be called after the cell element is retrieved.
58
57
  */
59
58
  _classPrivateMethodInitSpec(this, _getSelectedCell);
60
- /**
61
- * Get the coordinates of the highlight of the currently selected cell/header.
62
- *
63
- * @returns {CellCoords}
64
- */
65
- _classPrivateMethodInitSpec(this, _getCurrentHighlightCoords);
66
59
  /**
67
60
  * The Handsontable instance.
68
61
  */
@@ -192,17 +185,26 @@ export class FocusManager {
192
185
  * @param {HTMLTableCellElement} [selectedCell] The highlighted cell/header element.
193
186
  */
194
187
  focusOnHighlightedCell(selectedCell) {
195
- var _classPrivateFieldGet3;
196
- const currentHighlightCoords = _classPrivateMethodGet(this, _getCurrentHighlightCoords, _getCurrentHighlightCoords2).call(this);
197
- const currentlySelectedHighlight = selectedCell || _classPrivateMethodGet(this, _getSelectedCell, _getSelectedCell2).call(this);
198
- let elementToBeFocused = _classPrivateFieldGet(this, _hot).runHooks('modifyFocusedElement', currentHighlightCoords.row, currentHighlightCoords.col, currentlySelectedHighlight);
199
- if (!(elementToBeFocused instanceof HTMLElement)) {
200
- elementToBeFocused = currentlySelectedHighlight;
201
- }
202
- if (elementToBeFocused && !((_classPrivateFieldGet3 = _classPrivateFieldGet(this, _hot).getActiveEditor()) !== null && _classPrivateFieldGet3 !== void 0 && _classPrivateFieldGet3.isOpened())) {
203
- elementToBeFocused.focus({
204
- preventScroll: true
205
- });
188
+ const focusElement = element => {
189
+ var _classPrivateFieldGet3, _classPrivateFieldGet4;
190
+ const currentHighlightCoords = (_classPrivateFieldGet3 = _classPrivateFieldGet(this, _hot).getSelectedRangeLast()) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.highlight;
191
+ if (!currentHighlightCoords || !element) {
192
+ return;
193
+ }
194
+ let elementToBeFocused = _classPrivateFieldGet(this, _hot).runHooks('modifyFocusedElement', currentHighlightCoords.row, currentHighlightCoords.col, element);
195
+ if (!(elementToBeFocused instanceof HTMLElement)) {
196
+ elementToBeFocused = element;
197
+ }
198
+ if (elementToBeFocused && !((_classPrivateFieldGet4 = _classPrivateFieldGet(this, _hot).getActiveEditor()) !== null && _classPrivateFieldGet4 !== void 0 && _classPrivateFieldGet4.isOpened())) {
199
+ elementToBeFocused.focus({
200
+ preventScroll: true
201
+ });
202
+ }
203
+ };
204
+ if (selectedCell) {
205
+ focusElement(selectedCell);
206
+ } else {
207
+ _classPrivateMethodGet(this, _getSelectedCell, _getSelectedCell2).call(this, element => focusElement(element));
206
208
  }
207
209
  }
208
210
 
@@ -213,46 +215,56 @@ export class FocusManager {
213
215
  * @param {number} delay Delay in milliseconds.
214
216
  */
215
217
  refocusToEditorTextarea() {
216
- var _classPrivateFieldGet4;
218
+ var _classPrivateFieldGet5;
217
219
  let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _classPrivateFieldGet(this, _refocusDelay);
218
220
  const refocusElement = this.getRefocusElement();
219
221
 
220
222
  // Re-focus on the editor's `TEXTAREA` element (or a predefined element) if the `imeFastEdit` option is enabled.
221
- if (_classPrivateFieldGet(this, _hot).getSettings().imeFastEdit && !((_classPrivateFieldGet4 = _classPrivateFieldGet(this, _hot).getActiveEditor()) !== null && _classPrivateFieldGet4 !== void 0 && _classPrivateFieldGet4.isOpened()) && !!refocusElement) {
223
+ if (_classPrivateFieldGet(this, _hot).getSettings().imeFastEdit && !((_classPrivateFieldGet5 = _classPrivateFieldGet(this, _hot).getActiveEditor()) !== null && _classPrivateFieldGet5 !== void 0 && _classPrivateFieldGet5.isOpened()) && !!refocusElement) {
222
224
  _classPrivateFieldGet(this, _hot)._registerTimeout(() => {
223
225
  refocusElement.select();
224
226
  }, delay);
225
227
  }
226
228
  }
227
229
  }
228
- function _getCurrentHighlightCoords2() {
229
- const lastSelectedRange = _classPrivateFieldGet(this, _hot).getSelectedRangeLast();
230
- return lastSelectedRange.highlight;
231
- }
232
230
  function _getSelectedCell2() {
233
- const selectedCellCoords = _classPrivateMethodGet(this, _getCurrentHighlightCoords, _getCurrentHighlightCoords2).call(this);
234
- return _classPrivateFieldGet(this, _hot).getCell(selectedCellCoords.row, selectedCellCoords.col, true);
235
- }
236
- function _manageFocus2() {
237
- const selectedCell = _classPrivateMethodGet(this, _getSelectedCell, _getSelectedCell2).call(this);
238
- const {
239
- activeElement
240
- } = _classPrivateFieldGet(this, _hot).rootDocument;
241
-
242
- // Blurring the `activeElement` removes the unwanted border around the focusable element (#6877)
243
- // and resets the `document.activeElement` property. The blurring should happen only when the
244
- // previously selected input element has not belonged to the Handsontable editor. If blurring is
245
- // triggered for all elements, there is a problem with the disappearing IME editor (#9672).
246
- if (activeElement && isOutsideInput(activeElement)) {
247
- activeElement.blur();
231
+ var _classPrivateFieldGet6;
232
+ let callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
233
+ const highlight = (_classPrivateFieldGet6 = _classPrivateFieldGet(this, _hot).getSelectedRangeLast()) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.highlight;
234
+ if (!highlight) {
235
+ _classPrivateFieldGet(this, _hot)._registerTimeout(() => callback(null));
236
+ return;
248
237
  }
249
- this.focusOnHighlightedCell(selectedCell);
250
- if (this.getFocusMode() === FOCUS_MODES.MIXED && selectedCell.nodeName === 'TD') {
251
- _classPrivateFieldGet(this, _hot).addHookOnce('afterSelectionEnd', () => {
252
- this.refocusToEditorTextarea();
238
+ const cell = _classPrivateFieldGet(this, _hot).getCell(highlight.row, highlight.col, true);
239
+ if (cell === null) {
240
+ _classPrivateFieldGet(this, _hot).addHookOnce('afterScroll', () => {
241
+ callback(_classPrivateFieldGet(this, _hot).getCell(highlight.row, highlight.col, true));
253
242
  });
243
+ } else {
244
+ callback(cell);
254
245
  }
255
246
  }
247
+ function _manageFocus2() {
248
+ _classPrivateMethodGet(this, _getSelectedCell, _getSelectedCell2).call(this, selectedCell => {
249
+ const {
250
+ activeElement
251
+ } = _classPrivateFieldGet(this, _hot).rootDocument;
252
+
253
+ // Blurring the `activeElement` removes the unwanted border around the focusable element (#6877)
254
+ // and resets the `document.activeElement` property. The blurring should happen only when the
255
+ // previously selected input element has not belonged to the Handsontable editor. If blurring is
256
+ // triggered for all elements, there is a problem with the disappearing IME editor (#9672).
257
+ if (activeElement && isOutsideInput(activeElement)) {
258
+ activeElement.blur();
259
+ }
260
+ this.focusOnHighlightedCell(selectedCell);
261
+ if (this.getFocusMode() === FOCUS_MODES.MIXED && selectedCell.nodeName === 'TD') {
262
+ _classPrivateFieldGet(this, _hot).addHookOnce('afterSelectionEnd', () => {
263
+ this.refocusToEditorTextarea();
264
+ });
265
+ }
266
+ });
267
+ }
256
268
  function _onUpdateSettings2(newSettings) {
257
269
  if (newSettings.imeFastEdit && this.getFocusMode() !== FOCUS_MODES.MIXED) {
258
270
  this.setFocusMode(FOCUS_MODES.MIXED);
package/helpers/mixed.js CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
134
134
  function _injectProductInfo(key, element) {
135
135
  const hasValidType = !isEmpty(key);
136
136
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
137
- const hotVersion = "0.0.0-next-44acfea-20231127";
137
+ const hotVersion = "0.0.0-next-301795f-20231127";
138
138
  let keyValidityDate;
139
139
  let consoleMessageState = 'invalid';
140
140
  let domMessageState = 'invalid';
package/helpers/mixed.mjs CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
124
124
  export function _injectProductInfo(key, element) {
125
125
  const hasValidType = !isEmpty(key);
126
126
  const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
127
- const hotVersion = "0.0.0-next-44acfea-20231127";
127
+ const hotVersion = "0.0.0-next-301795f-20231127";
128
128
  let keyValidityDate;
129
129
  let consoleMessageState = 'invalid';
130
130
  let domMessageState = 'invalid';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/handsontable/handsontable/issues"
11
11
  },
12
12
  "author": "Handsoncode <hello@handsontable.com>",
13
- "version": "0.0.0-next-44acfea-20231127",
13
+ "version": "0.0.0-next-301795f-20231127",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",