handsontable 14.0.0-next-23212d5-20231127 → 14.0.0-next-477622d-20231128

Sign up to get free protection for your applications and to get access to all the features.
package/tableView.js CHANGED
@@ -11,11 +11,13 @@ var _mouseEventHandler = require("./selection/mouseEventHandler");
11
11
  var _rootInstance = require("./utils/rootInstance");
12
12
  var _a11y = require("./helpers/a11y");
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
14
15
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
15
16
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
16
17
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
18
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
19
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
19
21
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
20
22
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
21
23
  function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
@@ -32,11 +34,25 @@ var _mouseDown = /*#__PURE__*/new WeakMap();
32
34
  var _table = /*#__PURE__*/new WeakMap();
33
35
  var _lastWidth = /*#__PURE__*/new WeakMap();
34
36
  var _lastHeight = /*#__PURE__*/new WeakMap();
37
+ var _getAriaColcount = /*#__PURE__*/new WeakSet();
38
+ var _updateAriaColcount = /*#__PURE__*/new WeakSet();
35
39
  class TableView {
36
40
  /**
37
41
  * @param {Hanstontable} hotInstance Instance of {@link Handsontable}.
38
42
  */
39
43
  constructor(hotInstance) {
44
+ /**
45
+ * Update the `aria-colcount` attribute by the provided value.
46
+ *
47
+ * @param {number} delta The number of columns to add or remove to the aria tag.
48
+ */
49
+ _classPrivateMethodInitSpec(this, _updateAriaColcount);
50
+ /**
51
+ * Return the value of the `aria-colcount` attribute.
52
+ *
53
+ * @returns {number} The value of the `aria-colcount` attribute.
54
+ */
55
+ _classPrivateMethodInitSpec(this, _getAriaColcount);
40
56
  /**
41
57
  * Instance of {@link Handsontable}.
42
58
  *
@@ -273,7 +289,7 @@ class TableView {
273
289
  }
274
290
  if (this.settings.ariaTags) {
275
291
  (0, _element.setAttribute)(_classPrivateFieldGet(this, _table), [(0, _a11y.A11Y_PRESENTATION)()]);
276
- (0, _element.setAttribute)(rootElement, [(0, _a11y.A11Y_TREEGRID)(), (0, _a11y.A11Y_ROWCOUNT)(this.hot.countRows()), (0, _a11y.A11Y_COLCOUNT)(this.hot.countCols()), (0, _a11y.A11Y_MULTISELECTABLE)()]);
292
+ (0, _element.setAttribute)(rootElement, [(0, _a11y.A11Y_TREEGRID)(), (0, _a11y.A11Y_ROWCOUNT)(-1), (0, _a11y.A11Y_COLCOUNT)(this.hot.countCols()), (0, _a11y.A11Y_MULTISELECTABLE)()]);
277
293
  }
278
294
  this.THEAD = rootDocument.createElement('THEAD');
279
295
  _classPrivateFieldGet(this, _table).appendChild(this.THEAD);
@@ -666,6 +682,13 @@ class TableView {
666
682
  }
667
683
  this.hot.runHooks('afterGetRowHeaderRenderers', headerRenderers);
668
684
  _classPrivateFieldSet(this, _rowHeadersCount, headerRenderers.length);
685
+ if (this.hot.getSettings().ariaTags) {
686
+ // Update the aria-colcount attribute.
687
+ // Only needs to be done once after initialization/data update.
688
+ if (_classPrivateMethodGet(this, _getAriaColcount, _getAriaColcount2).call(this) === this.hot.countCols()) {
689
+ _classPrivateMethodGet(this, _updateAriaColcount, _updateAriaColcount2).call(this, _classPrivateFieldGet(this, _rowHeadersCount));
690
+ }
691
+ }
669
692
  return headerRenderers;
670
693
  },
671
694
  columnHeaders: () => {
@@ -1305,7 +1328,6 @@ class TableView {
1305
1328
  getRowHeadersCount() {
1306
1329
  return _classPrivateFieldGet(this, _rowHeadersCount);
1307
1330
  }
1308
-
1309
1331
  /**
1310
1332
  * Destroys internal WalkOnTable's instance. Detaches all of the bonded listeners.
1311
1333
  *
@@ -1316,4 +1338,11 @@ class TableView {
1316
1338
  this.eventManager.destroy();
1317
1339
  }
1318
1340
  }
1341
+ function _getAriaColcount2() {
1342
+ return parseInt(this.hot.rootElement.getAttribute((0, _a11y.A11Y_COLCOUNT)()[0]), 10);
1343
+ }
1344
+ function _updateAriaColcount2(delta) {
1345
+ const colCount = _classPrivateMethodGet(this, _getAriaColcount, _getAriaColcount2).call(this) + delta;
1346
+ (0, _element.setAttribute)(this.hot.rootElement, ...(0, _a11y.A11Y_COLCOUNT)(colCount));
1347
+ }
1319
1348
  var _default = exports.default = TableView;
package/tableView.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  import "core-js/modules/es.array.push.js";
2
2
  import "core-js/modules/es.error.cause.js";
3
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
3
4
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
4
5
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
5
6
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
7
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
8
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
8
10
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
9
11
  function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
10
12
  function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
@@ -28,11 +30,25 @@ var _mouseDown = /*#__PURE__*/new WeakMap();
28
30
  var _table = /*#__PURE__*/new WeakMap();
29
31
  var _lastWidth = /*#__PURE__*/new WeakMap();
30
32
  var _lastHeight = /*#__PURE__*/new WeakMap();
33
+ var _getAriaColcount = /*#__PURE__*/new WeakSet();
34
+ var _updateAriaColcount = /*#__PURE__*/new WeakSet();
31
35
  class TableView {
32
36
  /**
33
37
  * @param {Hanstontable} hotInstance Instance of {@link Handsontable}.
34
38
  */
35
39
  constructor(hotInstance) {
40
+ /**
41
+ * Update the `aria-colcount` attribute by the provided value.
42
+ *
43
+ * @param {number} delta The number of columns to add or remove to the aria tag.
44
+ */
45
+ _classPrivateMethodInitSpec(this, _updateAriaColcount);
46
+ /**
47
+ * Return the value of the `aria-colcount` attribute.
48
+ *
49
+ * @returns {number} The value of the `aria-colcount` attribute.
50
+ */
51
+ _classPrivateMethodInitSpec(this, _getAriaColcount);
36
52
  /**
37
53
  * Instance of {@link Handsontable}.
38
54
  *
@@ -269,7 +285,7 @@ class TableView {
269
285
  }
270
286
  if (this.settings.ariaTags) {
271
287
  setAttribute(_classPrivateFieldGet(this, _table), [A11Y_PRESENTATION()]);
272
- setAttribute(rootElement, [A11Y_TREEGRID(), A11Y_ROWCOUNT(this.hot.countRows()), A11Y_COLCOUNT(this.hot.countCols()), A11Y_MULTISELECTABLE()]);
288
+ setAttribute(rootElement, [A11Y_TREEGRID(), A11Y_ROWCOUNT(-1), A11Y_COLCOUNT(this.hot.countCols()), A11Y_MULTISELECTABLE()]);
273
289
  }
274
290
  this.THEAD = rootDocument.createElement('THEAD');
275
291
  _classPrivateFieldGet(this, _table).appendChild(this.THEAD);
@@ -662,6 +678,13 @@ class TableView {
662
678
  }
663
679
  this.hot.runHooks('afterGetRowHeaderRenderers', headerRenderers);
664
680
  _classPrivateFieldSet(this, _rowHeadersCount, headerRenderers.length);
681
+ if (this.hot.getSettings().ariaTags) {
682
+ // Update the aria-colcount attribute.
683
+ // Only needs to be done once after initialization/data update.
684
+ if (_classPrivateMethodGet(this, _getAriaColcount, _getAriaColcount2).call(this) === this.hot.countCols()) {
685
+ _classPrivateMethodGet(this, _updateAriaColcount, _updateAriaColcount2).call(this, _classPrivateFieldGet(this, _rowHeadersCount));
686
+ }
687
+ }
665
688
  return headerRenderers;
666
689
  },
667
690
  columnHeaders: () => {
@@ -1301,7 +1324,6 @@ class TableView {
1301
1324
  getRowHeadersCount() {
1302
1325
  return _classPrivateFieldGet(this, _rowHeadersCount);
1303
1326
  }
1304
-
1305
1327
  /**
1306
1328
  * Destroys internal WalkOnTable's instance. Detaches all of the bonded listeners.
1307
1329
  *
@@ -1312,4 +1334,11 @@ class TableView {
1312
1334
  this.eventManager.destroy();
1313
1335
  }
1314
1336
  }
1337
+ function _getAriaColcount2() {
1338
+ return parseInt(this.hot.rootElement.getAttribute(A11Y_COLCOUNT()[0]), 10);
1339
+ }
1340
+ function _updateAriaColcount2(delta) {
1341
+ const colCount = _classPrivateMethodGet(this, _getAriaColcount, _getAriaColcount2).call(this) + delta;
1342
+ setAttribute(this.hot.rootElement, ...A11Y_COLCOUNT(colCount));
1343
+ }
1315
1344
  export default TableView;