@semcore/data-table 16.5.3-prerelease.4 → 17.0.0-prerelease.17

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 (72) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/cjs/components/AccordionRows/AccordionRows.js +144 -157
  3. package/lib/cjs/components/AccordionRows/AccordionRows.js.map +1 -1
  4. package/lib/cjs/components/Body/Body.js +373 -395
  5. package/lib/cjs/components/Body/Body.js.map +1 -1
  6. package/lib/cjs/components/Body/Cell.js +135 -151
  7. package/lib/cjs/components/Body/Cell.js.map +1 -1
  8. package/lib/cjs/components/Body/LimitOverlay.js +142 -158
  9. package/lib/cjs/components/Body/LimitOverlay.js.map +1 -1
  10. package/lib/cjs/components/Body/MergedCells.js +25 -23
  11. package/lib/cjs/components/Body/MergedCells.js.map +1 -1
  12. package/lib/cjs/components/Body/Row.js +498 -539
  13. package/lib/cjs/components/Body/Row.js.map +1 -1
  14. package/lib/cjs/components/DataTable/DataTable.js +867 -938
  15. package/lib/cjs/components/DataTable/DataTable.js.map +1 -1
  16. package/lib/cjs/components/Head/Column.js +208 -234
  17. package/lib/cjs/components/Head/Column.js.map +1 -1
  18. package/lib/cjs/components/Head/Group.js +79 -92
  19. package/lib/cjs/components/Head/Group.js.map +1 -1
  20. package/lib/cjs/components/Head/Head.js +229 -263
  21. package/lib/cjs/components/Head/Head.js.map +1 -1
  22. package/lib/cjs/enhancers/focusableCell.js +6 -14
  23. package/lib/cjs/enhancers/focusableCell.js.map +1 -1
  24. package/lib/cjs/index.js +7 -14
  25. package/lib/cjs/index.js.map +1 -1
  26. package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
  27. package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
  28. package/lib/es6/components/AccordionRows/AccordionRows.js +142 -156
  29. package/lib/es6/components/AccordionRows/AccordionRows.js.map +1 -1
  30. package/lib/es6/components/Body/Body.js +370 -392
  31. package/lib/es6/components/Body/Body.js.map +1 -1
  32. package/lib/es6/components/Body/Cell.js +131 -147
  33. package/lib/es6/components/Body/Cell.js.map +1 -1
  34. package/lib/es6/components/Body/LimitOverlay.js +138 -154
  35. package/lib/es6/components/Body/LimitOverlay.js.map +1 -1
  36. package/lib/es6/components/Body/MergedCells.js +22 -22
  37. package/lib/es6/components/Body/MergedCells.js.map +1 -1
  38. package/lib/es6/components/Body/Row.js +493 -535
  39. package/lib/es6/components/Body/Row.js.map +1 -1
  40. package/lib/es6/components/DataTable/DataTable.js +861 -932
  41. package/lib/es6/components/DataTable/DataTable.js.map +1 -1
  42. package/lib/es6/components/Head/Column.js +201 -228
  43. package/lib/es6/components/Head/Column.js.map +1 -1
  44. package/lib/es6/components/Head/Group.js +74 -88
  45. package/lib/es6/components/Head/Group.js.map +1 -1
  46. package/lib/es6/components/Head/Head.js +228 -262
  47. package/lib/es6/components/Head/Head.js.map +1 -1
  48. package/lib/es6/enhancers/focusableCell.js +6 -14
  49. package/lib/es6/enhancers/focusableCell.js.map +1 -1
  50. package/lib/es6/index.js +3 -9
  51. package/lib/es6/index.js.map +1 -1
  52. package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
  53. package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
  54. package/lib/esm/components/AccordionRows/AccordionRows.mjs +143 -134
  55. package/lib/esm/components/Body/Body.mjs +377 -343
  56. package/lib/esm/components/Body/Cell.mjs +136 -135
  57. package/lib/esm/components/Body/LimitOverlay.mjs +141 -144
  58. package/lib/esm/components/Body/MergedCells.mjs +22 -22
  59. package/lib/esm/components/Body/Row.mjs +498 -458
  60. package/lib/esm/components/DataTable/DataTable.mjs +866 -842
  61. package/lib/esm/components/Head/Column.mjs +208 -201
  62. package/lib/esm/components/Head/Group.mjs +76 -84
  63. package/lib/esm/components/Head/Head.mjs +231 -216
  64. package/lib/esm/enhancers/focusableCell.mjs +7 -14
  65. package/lib/esm/index.mjs +2 -5
  66. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
  67. package/lib/types/components/Body/Cell.d.ts +1 -3
  68. package/lib/types/components/Body/Row.d.ts +1 -1
  69. package/lib/types/components/Head/Column.d.ts +2 -2
  70. package/lib/types/components/Head/Group.d.ts +1 -1
  71. package/lib/types/index.d.ts +2 -6
  72. package/package.json +20 -22
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.UNIQ_ROW_KEY = exports.SELECT_ALL = exports.ROW_INDEX = exports.ROW_GROUP = exports.IS_EMPTY_DATA_ROW = exports.GRID_ROW_INDEX = exports.DataTable = exports.ACCORDION = void 0;
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
- var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
13
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
- var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
10
  var _core = require("@semcore/core");
19
11
  var _baseComponents = require("@semcore/base-components");
@@ -22,7 +14,7 @@ var _i18nEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhan
22
14
  var _findComponent = _interopRequireDefault(require("@semcore/core/lib/utils/findComponent"));
23
15
  var _hasParent = require("@semcore/core/lib/utils/hasParent");
24
16
  var _rafTrottle = _interopRequireDefault(require("@semcore/core/lib/utils/rafTrottle"));
25
- var _ref9 = require("@semcore/core/lib/utils/ref");
17
+ var _ref3 = require("@semcore/core/lib/utils/ref");
26
18
  var _uniqueID = _interopRequireDefault(require("@semcore/core/lib/utils/uniqueID"));
27
19
  var _useFocusLock = require("@semcore/core/lib/utils/use/useFocusLock");
28
20
  var _widgetEmpty = require("@semcore/widget-empty");
@@ -32,96 +24,103 @@ var _Body = require("../Body/Body");
32
24
  var _MergedCells = require("../Body/MergedCells");
33
25
  var _Head = require("../Head/Head");
34
26
  /*!__reshadow-styles__:"./dataTable.shadow.css"*/
35
- var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SDataTable_236d0_gg_{display:grid;align-items:start;min-width:-moz-fit-content;min-width:fit-content;grid-auto-rows:min-content}.___SDataTable_236d0_gg_.__isDataEmpty_236d0_gg_{display:block;align-items:initial;min-width:initial}.___SDataTable_236d0_gg_.__gridTemplateColumns_236d0_gg_{grid-template-columns:var(--gridTemplateColumns_236d0)}.___SDataTable_236d0_gg_.__gridTemplateAreas_236d0_gg_{grid-template-areas:var(--gridTemplateAreas_236d0)}.___SDataTable_236d0_gg_.__gridTemplateRows_236d0_gg_{grid-template-rows:var(--gridTemplateRows_236d0)}", /*__inner_css_end__*/"236d0_gg_"),
27
+ const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SDataTable_wo0cb_gg_{display:grid;align-items:start;min-width:-moz-fit-content;min-width:fit-content;grid-auto-rows:min-content}.___SDataTable_wo0cb_gg_.__isDataEmpty_wo0cb_gg_{display:block;align-items:initial;min-width:initial}.___SDataTable_wo0cb_gg_.__gridTemplateColumns_wo0cb_gg_{grid-template-columns:var(--gridTemplateColumns_wo0cb)}.___SDataTable_wo0cb_gg_.__gridTemplateAreas_wo0cb_gg_{grid-template-areas:var(--gridTemplateAreas_wo0cb)}.___SDataTable_wo0cb_gg_.__gridTemplateRows_wo0cb_gg_{grid-template-rows:var(--gridTemplateRows_wo0cb)}", /*__inner_css_end__*/"wo0cb_gg_"),
36
28
  /*__reshadow_css_end__*/
37
29
  {
38
- "__SDataTable": "___SDataTable_236d0_gg_",
39
- "_isDataEmpty": "__isDataEmpty_236d0_gg_",
40
- "_gridTemplateColumns": "__gridTemplateColumns_236d0_gg_",
41
- "--gridTemplateColumns": "--gridTemplateColumns_236d0",
42
- "_gridTemplateAreas": "__gridTemplateAreas_236d0_gg_",
43
- "--gridTemplateAreas": "--gridTemplateAreas_236d0",
44
- "_gridTemplateRows": "__gridTemplateRows_236d0_gg_",
45
- "--gridTemplateRows": "--gridTemplateRows_236d0"
30
+ "__SDataTable": "___SDataTable_wo0cb_gg_",
31
+ "_isDataEmpty": "__isDataEmpty_wo0cb_gg_",
32
+ "_gridTemplateColumns": "__gridTemplateColumns_wo0cb_gg_",
33
+ "--gridTemplateColumns": "--gridTemplateColumns_wo0cb",
34
+ "_gridTemplateAreas": "__gridTemplateAreas_wo0cb_gg_",
35
+ "--gridTemplateAreas": "--gridTemplateAreas_wo0cb",
36
+ "_gridTemplateRows": "__gridTemplateRows_wo0cb_gg_",
37
+ "--gridTemplateRows": "--gridTemplateRows_wo0cb"
46
38
  });
47
39
  /*!__reshadow-styles__:"../../style/scroll-shadows.shadow.css"*/
48
- var scrollStyles = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SScrollArea_1m51n_gg_{width:-moz-fit-content;width:fit-content}.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_{overflow:visible;overflow:initial}.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_._scrollDirection_both_1m51n_gg_{overflow:auto}.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_._scrollDirection_both_1m51n_gg_.__loading_1m51n_gg_,.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_._scrollDirection_horizontal_1m51n_gg_.__loading_1m51n_gg_,.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_._scrollDirection_vertical_1m51n_gg_.__loading_1m51n_gg_{overflow:hidden}.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_._scrollDirection_horizontal_1m51n_gg_{overflow-x:auto;overflow-y:initial}.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_._scrollDirection_vertical_1m51n_gg_{overflow-x:initial;overflow-y:auto}.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_.__headerHeight_1m51n_gg_{scroll-padding-top:var(--headerHeight_1m51n)}.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_.__leftScrollPadding_1m51n_gg_{scroll-padding-left:var(--leftScrollPadding_1m51n)}.___SScrollArea_1m51n_gg_ .___SContainer_1m51n_gg_.__rightScrollPadding_1m51n_gg_{scroll-padding-right:var(--rightScrollPadding_1m51n)}.___SScrollArea_1m51n_gg_ .___SShadowHorizontal_1m51n_gg_::before,.___SScrollArea_1m51n_gg_ .___SShadowHorizontal_1m51n_gg_:after,.___SScrollArea_1m51n_gg_ .___SShadowVertical_1m51n_gg_::after{z-index:20}.___SScrollArea_1m51n_gg_ .___SShadowHorizontal_1m51n_gg_.__leftOffset_1m51n_gg_::before,.___SScrollArea_1m51n_gg_ .___SShadowHorizontal_1m51n_gg_.__rightOffset_1m51n_gg_::after,.___SScrollArea_1m51n_gg_ .___SShadowVertical_1m51n_gg_::before{display:none}", /*__inner_css_end__*/"1m51n_gg_"),
40
+ const scrollStyles = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SScrollArea_j4820_gg_{width:-moz-fit-content;width:fit-content}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_{overflow:visible;overflow:initial}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_both_j4820_gg_{overflow:auto}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_both_j4820_gg_.__loading_j4820_gg_,.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_horizontal_j4820_gg_.__loading_j4820_gg_,.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_vertical_j4820_gg_.__loading_j4820_gg_{overflow:hidden}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_horizontal_j4820_gg_{overflow-x:auto;overflow-y:initial}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_vertical_j4820_gg_{overflow-x:initial;overflow-y:auto}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_.__headerHeight_j4820_gg_{scroll-padding-top:var(--headerHeight_j4820)}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_.__leftScrollPadding_j4820_gg_{scroll-padding-left:var(--leftScrollPadding_j4820)}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_.__rightScrollPadding_j4820_gg_{scroll-padding-right:var(--rightScrollPadding_j4820)}.___SScrollArea_j4820_gg_ .___SShadowHorizontal_j4820_gg_::before,.___SScrollArea_j4820_gg_ .___SShadowHorizontal_j4820_gg_:after,.___SScrollArea_j4820_gg_ .___SShadowVertical_j4820_gg_::after{z-index:20}.___SScrollArea_j4820_gg_ .___SShadowHorizontal_j4820_gg_.__leftOffset_j4820_gg_::before,.___SScrollArea_j4820_gg_ .___SShadowHorizontal_j4820_gg_.__rightOffset_j4820_gg_::after,.___SScrollArea_j4820_gg_ .___SShadowVertical_j4820_gg_::before{display:none}", /*__inner_css_end__*/"j4820_gg_"),
49
41
  /*__reshadow_css_end__*/
50
42
  {
51
- "__SScrollArea": "___SScrollArea_1m51n_gg_",
52
- "__SContainer": "___SContainer_1m51n_gg_",
53
- "_scrollDirection_both": "_scrollDirection_both_1m51n_gg_",
54
- "_loading": "__loading_1m51n_gg_",
55
- "_scrollDirection_horizontal": "_scrollDirection_horizontal_1m51n_gg_",
56
- "_scrollDirection_vertical": "_scrollDirection_vertical_1m51n_gg_",
57
- "_headerHeight": "__headerHeight_1m51n_gg_",
58
- "--headerHeight": "--headerHeight_1m51n",
59
- "_leftScrollPadding": "__leftScrollPadding_1m51n_gg_",
60
- "--leftScrollPadding": "--leftScrollPadding_1m51n",
61
- "_rightScrollPadding": "__rightScrollPadding_1m51n_gg_",
62
- "--rightScrollPadding": "--rightScrollPadding_1m51n",
63
- "__SShadowVertical": "___SShadowVertical_1m51n_gg_",
64
- "__SShadowHorizontal": "___SShadowHorizontal_1m51n_gg_",
65
- "_leftOffset": "__leftOffset_1m51n_gg_",
66
- "_rightOffset": "__rightOffset_1m51n_gg_"
43
+ "__SScrollArea": "___SScrollArea_j4820_gg_",
44
+ "__SContainer": "___SContainer_j4820_gg_",
45
+ "_scrollDirection_both": "_scrollDirection_both_j4820_gg_",
46
+ "_loading": "__loading_j4820_gg_",
47
+ "_scrollDirection_horizontal": "_scrollDirection_horizontal_j4820_gg_",
48
+ "_scrollDirection_vertical": "_scrollDirection_vertical_j4820_gg_",
49
+ "_headerHeight": "__headerHeight_j4820_gg_",
50
+ "--headerHeight": "--headerHeight_j4820",
51
+ "_leftScrollPadding": "__leftScrollPadding_j4820_gg_",
52
+ "--leftScrollPadding": "--leftScrollPadding_j4820",
53
+ "_rightScrollPadding": "__rightScrollPadding_j4820_gg_",
54
+ "--rightScrollPadding": "--rightScrollPadding_j4820",
55
+ "__SShadowVertical": "___SShadowVertical_j4820_gg_",
56
+ "__SShadowHorizontal": "___SShadowHorizontal_j4820_gg_",
57
+ "_leftOffset": "__leftOffset_j4820_gg_",
58
+ "_rightOffset": "__rightOffset_j4820_gg_"
67
59
  });
68
- var ACCORDION = exports.ACCORDION = Symbol('accordion');
69
- var ROW_GROUP = exports.ROW_GROUP = Symbol('ROW_GROUP');
70
- var UNIQ_ROW_KEY = exports.UNIQ_ROW_KEY = Symbol('UNIQ_ROW_KEY');
71
- var IS_EMPTY_DATA_ROW = exports.IS_EMPTY_DATA_ROW = Symbol('IS_EMPTY_DATA_ROW');
72
- var SELECT_ALL = exports.SELECT_ALL = Symbol('SELECT_ALL');
73
- var ROW_INDEX = exports.ROW_INDEX = Symbol('ROW_INDEX');
74
- var GRID_ROW_INDEX = exports.GRID_ROW_INDEX = Symbol('GRID_ROW_INDEX');
75
- var SCROLL_BAR_HEIGHT = 12;
76
- var DataTableRoot = /*#__PURE__*/function (_Component) {
77
- function DataTableRoot(props) {
78
- var _this;
79
- (0, _classCallCheck2["default"])(this, DataTableRoot);
80
- _this = (0, _callSuper2["default"])(this, DataTableRoot, [props]);
81
- (0, _defineProperty2["default"])(_this, "columns", []);
82
- (0, _defineProperty2["default"])(_this, "treeColumns", []);
83
- (0, _defineProperty2["default"])(_this, "hasGroups", false);
84
- (0, _defineProperty2["default"])(_this, "hasFixedColumn", false);
85
- (0, _defineProperty2["default"])(_this, "focusedCell", [-1, -1]);
86
- (0, _defineProperty2["default"])(_this, "scrollAreaRef", /*#__PURE__*/React.createRef());
87
- (0, _defineProperty2["default"])(_this, "tableContainerRef", /*#__PURE__*/React.createRef());
88
- (0, _defineProperty2["default"])(_this, "tableRef", /*#__PURE__*/React.createRef());
89
- (0, _defineProperty2["default"])(_this, "headerRef", /*#__PURE__*/React.createRef());
90
- (0, _defineProperty2["default"])(_this, "spinnerRef", /*#__PURE__*/React.createRef());
91
- (0, _defineProperty2["default"])(_this, "containerResizeEndTimeoutId", null);
92
- (0, _defineProperty2["default"])(_this, "gridAreaGroupMap", new Map());
93
- (0, _defineProperty2["default"])(_this, "columnsSplitter", '/');
94
- (0, _defineProperty2["default"])(_this, "tmpData", void 0);
95
- (0, _defineProperty2["default"])(_this, "calculatedRows", void 0);
96
- (0, _defineProperty2["default"])(_this, "flatRows", void 0);
97
- (0, _defineProperty2["default"])(_this, "gridSettings", {
60
+ const ACCORDION = exports.ACCORDION = Symbol('accordion');
61
+ const ROW_GROUP = exports.ROW_GROUP = Symbol('ROW_GROUP');
62
+ const UNIQ_ROW_KEY = exports.UNIQ_ROW_KEY = Symbol('UNIQ_ROW_KEY');
63
+ const IS_EMPTY_DATA_ROW = exports.IS_EMPTY_DATA_ROW = Symbol('IS_EMPTY_DATA_ROW');
64
+ const SELECT_ALL = exports.SELECT_ALL = Symbol('SELECT_ALL');
65
+ const ROW_INDEX = exports.ROW_INDEX = Symbol('ROW_INDEX');
66
+ const GRID_ROW_INDEX = exports.GRID_ROW_INDEX = Symbol('GRID_ROW_INDEX');
67
+ const SCROLL_BAR_HEIGHT = 12;
68
+ class DataTableRoot extends _core.Component {
69
+ static getDerivedStateFromProps(props, state) {
70
+ if (props.expandedRows === state.expandedRows || props.expandedRows === undefined) {
71
+ return null;
72
+ }
73
+ return {
74
+ expandedRows: props.expandedRows
75
+ };
76
+ }
77
+ constructor(props) {
78
+ super(props);
79
+ (0, _defineProperty2.default)(this, "columns", []);
80
+ (0, _defineProperty2.default)(this, "treeColumns", []);
81
+ (0, _defineProperty2.default)(this, "hasGroups", false);
82
+ (0, _defineProperty2.default)(this, "hasFixedColumn", false);
83
+ (0, _defineProperty2.default)(this, "focusedCell", [-1, -1]);
84
+ (0, _defineProperty2.default)(this, "scrollAreaRef", /*#__PURE__*/React.createRef());
85
+ (0, _defineProperty2.default)(this, "tableContainerRef", /*#__PURE__*/React.createRef());
86
+ (0, _defineProperty2.default)(this, "tableRef", /*#__PURE__*/React.createRef());
87
+ (0, _defineProperty2.default)(this, "headerRef", /*#__PURE__*/React.createRef());
88
+ (0, _defineProperty2.default)(this, "spinnerRef", /*#__PURE__*/React.createRef());
89
+ (0, _defineProperty2.default)(this, "containerResizeEndTimeoutId", null);
90
+ (0, _defineProperty2.default)(this, "gridAreaGroupMap", new Map());
91
+ (0, _defineProperty2.default)(this, "columnsSplitter", '/');
92
+ (0, _defineProperty2.default)(this, "tmpData", void 0);
93
+ (0, _defineProperty2.default)(this, "calculatedRows", void 0);
94
+ (0, _defineProperty2.default)(this, "flatRows", void 0);
95
+ (0, _defineProperty2.default)(this, "gridSettings", {
98
96
  gridTemplateColumns: [],
99
97
  gridTemplateAreas: []
100
98
  });
101
- (0, _defineProperty2["default"])(_this, "selectAllMessageTimer", 0);
102
- (0, _defineProperty2["default"])(_this, "headerNodesMap", new Map());
103
- (0, _defineProperty2["default"])(_this, "isPressedShift", false);
104
- (0, _defineProperty2["default"])(_this, "lastSelectedRowKey", void 0);
105
- (0, _defineProperty2["default"])(_this, "state", {
99
+ (0, _defineProperty2.default)(this, "selectAllMessageTimer", 0);
100
+ (0, _defineProperty2.default)(this, "headerNodesMap", new Map());
101
+ (0, _defineProperty2.default)(this, "isPressedShift", false);
102
+ (0, _defineProperty2.default)(this, "lastSelectedRowKey", void 0);
103
+ (0, _defineProperty2.default)(this, "state", {
106
104
  scrollTop: 0,
107
105
  scrollDirection: 'down',
108
106
  selectAllMessage: '',
109
107
  shadowVertical: '',
110
108
  expandedRows: new Set()
111
109
  });
112
- (0, _defineProperty2["default"])(_this, "handleDocumentScroll", (0, _rafTrottle["default"])(function () {
113
- var _headerProps$top, _this$scrollAreaRef$c;
114
- var tableContainer = _this.tableContainerRef.current;
110
+ (0, _defineProperty2.default)(this, "handleDocumentScroll", (0, _rafTrottle.default)(() => {
111
+ const tableContainer = this.tableContainerRef.current;
115
112
  if (!tableContainer) return;
116
- var tableContainerTop = tableContainer.getBoundingClientRect().top;
117
- var headerProps = _this.asProps.headerProps;
118
- var headerContainer = _this.headerRef.current;
119
- var elements = headerContainer === null || headerContainer === void 0 ? void 0 : headerContainer.querySelectorAll('[role="columnheader"], [data-ui-name="Head.Group"]');
120
- var top = tableContainerTop - ((_headerProps$top = headerProps === null || headerProps === void 0 ? void 0 : headerProps.top) !== null && _headerProps$top !== void 0 ? _headerProps$top : 0);
121
- var headerScrollBar = headerProps !== null && headerProps !== void 0 && headerProps.withScrollBar ? (_this$scrollAreaRef$c = _this.scrollAreaRef.current) === null || _this$scrollAreaRef$c === void 0 ? void 0 : _this$scrollAreaRef$c.querySelector("[role=scrollbar][aria-orientation=horizontal]") : undefined;
113
+ const tableContainerTop = tableContainer.getBoundingClientRect().top;
114
+ const {
115
+ headerProps
116
+ } = this.asProps;
117
+ const headerContainer = this.headerRef.current;
118
+ const elements = headerContainer?.querySelectorAll('[role="columnheader"], [data-ui-name="Head.Group"]');
119
+ const top = tableContainerTop - (headerProps?.top ?? 0);
120
+ const headerScrollBar = headerProps?.withScrollBar ? this.scrollAreaRef.current?.querySelector(`[role=scrollbar][aria-orientation=horizontal]`) : undefined;
122
121
  if (top && top < 0) {
123
- var translate = "translateY(".concat(Math.abs(top), "px)");
124
- elements === null || elements === void 0 || elements.forEach(function (column) {
122
+ const translate = `translateY(${Math.abs(top)}px)`;
123
+ elements?.forEach(column => {
125
124
  if (column instanceof HTMLElement) {
126
125
  column.style.setProperty('transform', translate);
127
126
  }
@@ -130,7 +129,7 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
130
129
  headerScrollBar.style.setProperty('transform', translate);
131
130
  }
132
131
  } else {
133
- elements === null || elements === void 0 || elements.forEach(function (column) {
132
+ elements?.forEach(column => {
134
133
  if (column instanceof HTMLElement) {
135
134
  column.style.removeProperty('transform');
136
135
  }
@@ -140,175 +139,165 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
140
139
  }
141
140
  }
142
141
  }));
143
- (0, _defineProperty2["default"])(_this, "handleCellClick", function (e, opt) {
142
+ (0, _defineProperty2.default)(this, "handleCellClick", (e, opt) => {
144
143
  if (_core.lastInteraction.isMouse()) {
145
- _this.initFocusableCell([_this.hasFocusableInHeader() ? opt.rowIndex + 1 : opt.rowIndex, opt.colIndex]);
144
+ this.initFocusableCell([this.hasFocusableInHeader() ? opt.rowIndex + 1 : opt.rowIndex, opt.colIndex]);
146
145
  }
147
146
  });
148
- (0, _defineProperty2["default"])(_this, "handleSelectRow", function (isSelected, selectedRowIndex, row, event) {
149
- var _this$asProps = _this.asProps,
150
- selectedRows = _this$asProps.selectedRows,
151
- onSelectedRowsChange = _this$asProps.onSelectedRowsChange;
147
+ (0, _defineProperty2.default)(this, "handleSelectRow", (isSelected, selectedRowIndex, row, event) => {
148
+ const {
149
+ selectedRows,
150
+ onSelectedRowsChange
151
+ } = this.asProps;
152
152
  if (!selectedRows || !onSelectedRowsChange) return;
153
- var selectedRowsSet = new Set(selectedRows);
154
- if (_this.isPressedShift && selectedRowsSet.size > 0 && _this.lastSelectedRowKey && (isSelected ? selectedRowsSet.has(_this.lastSelectedRowKey) : true)) {
155
- var select = false;
156
- var firstColumnKey = _this.columns[0].name;
157
- var isMerged = _this.flatRows.some(function (item) {
158
- return item[firstColumnKey] instanceof _MergedCells.MergedRowsCell;
159
- });
160
- var _iterator = (0, _createForOfIteratorHelper2["default"])(_this.flatRows),
161
- _step;
162
- try {
163
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
164
- var item = _step.value;
165
- if (isMerged && !item[firstColumnKey]) continue;
166
- if (!select && (item[UNIQ_ROW_KEY] === row[UNIQ_ROW_KEY] || item[UNIQ_ROW_KEY] === _this.lastSelectedRowKey)) {
167
- select = true;
168
- if (isSelected) {
169
- selectedRowsSet.add(item[UNIQ_ROW_KEY]);
170
- } else {
171
- selectedRowsSet["delete"](item[UNIQ_ROW_KEY]);
172
- }
173
- continue;
174
- }
175
- if (select) {
176
- if (isSelected) {
177
- selectedRowsSet.add(item[UNIQ_ROW_KEY]);
178
- } else {
179
- selectedRowsSet["delete"](item[UNIQ_ROW_KEY]);
180
- }
153
+ const selectedRowsSet = new Set(selectedRows);
154
+ if (this.isPressedShift && selectedRowsSet.size > 0 && this.lastSelectedRowKey && (isSelected ? selectedRowsSet.has(this.lastSelectedRowKey) : true)) {
155
+ let select = false;
156
+ const firstColumnKey = this.columns[0].name;
157
+ const isMerged = this.flatRows.some(item => item[firstColumnKey] instanceof _MergedCells.MergedRowsCell);
158
+ for (const item of this.flatRows) {
159
+ if (isMerged && !item[firstColumnKey]) continue;
160
+ if (!select && (item[UNIQ_ROW_KEY] === row[UNIQ_ROW_KEY] || item[UNIQ_ROW_KEY] === this.lastSelectedRowKey)) {
161
+ select = true;
162
+ if (isSelected) {
163
+ selectedRowsSet.add(item[UNIQ_ROW_KEY]);
164
+ } else {
165
+ selectedRowsSet.delete(item[UNIQ_ROW_KEY]);
181
166
  }
182
- if (select && (item[UNIQ_ROW_KEY] === row[UNIQ_ROW_KEY] || item[UNIQ_ROW_KEY] === _this.lastSelectedRowKey)) {
183
- break;
167
+ continue;
168
+ }
169
+ if (select) {
170
+ if (isSelected) {
171
+ selectedRowsSet.add(item[UNIQ_ROW_KEY]);
172
+ } else {
173
+ selectedRowsSet.delete(item[UNIQ_ROW_KEY]);
184
174
  }
185
175
  }
186
- } catch (err) {
187
- _iterator.e(err);
188
- } finally {
189
- _iterator.f();
176
+ if (select && (item[UNIQ_ROW_KEY] === row[UNIQ_ROW_KEY] || item[UNIQ_ROW_KEY] === this.lastSelectedRowKey)) {
177
+ break;
178
+ }
190
179
  }
191
180
  } else {
192
181
  if (selectedRowsSet.has(row[UNIQ_ROW_KEY])) {
193
- selectedRowsSet["delete"](row[UNIQ_ROW_KEY]);
182
+ selectedRowsSet.delete(row[UNIQ_ROW_KEY]);
194
183
  } else {
195
184
  selectedRowsSet.add(row[UNIQ_ROW_KEY]);
196
185
  }
197
186
  }
198
- _this.lastSelectedRowKey = row[UNIQ_ROW_KEY];
187
+ this.lastSelectedRowKey = row[UNIQ_ROW_KEY];
199
188
  onSelectedRowsChange(Array.from(selectedRowsSet), event, {
200
- selectedRowIndex: selectedRowIndex,
201
- isSelected: isSelected,
202
- row: row
189
+ selectedRowIndex,
190
+ isSelected,
191
+ row
203
192
  });
204
193
  });
205
- (0, _defineProperty2["default"])(_this, "setSelectAllMessage", function (selectedAll) {
206
- if (_this.selectAllMessageTimer) {
207
- clearTimeout(_this.selectAllMessageTimer);
194
+ (0, _defineProperty2.default)(this, "setSelectAllMessage", selectedAll => {
195
+ if (this.selectAllMessageTimer) {
196
+ clearTimeout(this.selectAllMessageTimer);
208
197
  }
209
- var getI18nText = _this.asProps.getI18nText;
210
- var message = getI18nText(selectedAll ? 'DataTable.allItemsSelected:aria-live' : 'DataTable.allItemsDeselected:aria-live');
211
- _this.setState({
198
+ const {
199
+ getI18nText
200
+ } = this.asProps;
201
+ const message = getI18nText(selectedAll ? 'DataTable.allItemsSelected:aria-live' : 'DataTable.allItemsDeselected:aria-live');
202
+ this.setState({
212
203
  selectAllMessage: message
213
204
  });
214
- _this.selectAllMessageTimer = window.setTimeout(function () {
215
- _this.setState({
205
+ this.selectAllMessageTimer = window.setTimeout(() => {
206
+ this.setState({
216
207
  selectAllMessage: ''
217
208
  });
218
209
  }, 5000);
219
210
  });
220
- (0, _defineProperty2["default"])(_this, "getRow", function (index) {
221
- var _this$tableRef$curren;
222
- return (_this$tableRef$curren = _this.tableRef.current) === null || _this$tableRef$curren === void 0 ? void 0 : _this$tableRef$curren.querySelector(":scope [aria-rowindex=\"".concat(index + 1, "\"]:not([aria-hidden=\"true\"]):not(:scope [data-ui-name=\"DataTable\"] [aria-rowindex=\"").concat(index + 1, "\"]:not([aria-hidden=\"true\"])"));
211
+ (0, _defineProperty2.default)(this, "getRow", index => {
212
+ return this.tableRef.current?.querySelector(`:scope [aria-rowindex="${index + 1}"]:not([aria-hidden="true"]):not(:scope [data-ui-name="DataTable"] [aria-rowindex="${index + 1}"]:not([aria-hidden="true"])`);
223
213
  });
224
- (0, _defineProperty2["default"])(_this, "hasFocusableInHeader", function () {
225
- return _this.headerRef.current && (0, _useFocusLock.hasFocusableIn)(_this.headerRef.current) || _this.columns.some(function (column) {
226
- return column.sortable;
227
- });
214
+ (0, _defineProperty2.default)(this, "hasFocusableInHeader", () => {
215
+ return this.headerRef.current && (0, _useFocusLock.hasFocusableIn)(this.headerRef.current) || this.columns.some(column => column.sortable);
228
216
  });
229
- (0, _defineProperty2["default"])(_this, "onExpandRow", function (expandedRow) {
230
- var _this$asProps2 = _this.asProps,
231
- onAccordionToggle = _this$asProps2.onAccordionToggle,
232
- accordionMode = _this$asProps2.accordionMode;
233
- var expandedRows = _this.state.expandedRows;
217
+ (0, _defineProperty2.default)(this, "onExpandRow", expandedRow => {
218
+ const {
219
+ onAccordionToggle,
220
+ accordionMode
221
+ } = this.asProps;
222
+ const expandedRows = this.state.expandedRows;
234
223
  if (expandedRows.has(expandedRow[UNIQ_ROW_KEY])) {
235
- expandedRows["delete"](expandedRow[UNIQ_ROW_KEY]);
236
- onAccordionToggle === null || onAccordionToggle === void 0 || onAccordionToggle('close', expandedRow[UNIQ_ROW_KEY], expandedRow[ROW_INDEX]);
224
+ expandedRows.delete(expandedRow[UNIQ_ROW_KEY]);
225
+ onAccordionToggle?.('close', expandedRow[UNIQ_ROW_KEY], expandedRow[ROW_INDEX]);
237
226
  } else {
238
227
  expandedRows.add(expandedRow[UNIQ_ROW_KEY]);
239
- onAccordionToggle === null || onAccordionToggle === void 0 || onAccordionToggle('open', expandedRow[UNIQ_ROW_KEY], expandedRow[ROW_INDEX]);
228
+ onAccordionToggle?.('open', expandedRow[UNIQ_ROW_KEY], expandedRow[ROW_INDEX]);
240
229
  if (accordionMode === 'toggle') {
241
- var rowIndex = expandedRow[ROW_INDEX];
242
- var colIndex = _this.focusedCell[1];
243
- _this.initFocusableCell([_this.hasFocusableInHeader() ? rowIndex + 1 : rowIndex, colIndex]);
230
+ const rowIndex = expandedRow[ROW_INDEX];
231
+ const colIndex = this.focusedCell[1];
232
+ this.initFocusableCell([this.hasFocusableInHeader() ? rowIndex + 1 : rowIndex, colIndex]);
244
233
  }
245
234
  }
246
235
  });
247
- (0, _defineProperty2["default"])(_this, "changeFocusCell", function (rowIndex, colIndex, direction) {
248
- var _this$tableRef$curren2, _this$tableRef$curren3;
249
- var limit = _this.asProps.limit;
250
- var hasFocusable = _this.hasFocusableInHeader();
251
- var maxCol = _this.columns.length - 1;
252
- var maxRow = _this.totalRows || 1;
253
- var currentRow = (_this$tableRef$curren2 = _this.tableRef.current) === null || _this$tableRef$curren2 === void 0 ? void 0 : _this$tableRef$curren2.querySelector("[aria-rowindex=\"".concat(_this.focusedCell[0] + 1, "\"]"));
254
- var headerCells = (_this$tableRef$curren3 = _this.tableRef.current) === null || _this$tableRef$curren3 === void 0 ? void 0 : _this$tableRef$curren3.querySelectorAll('[role=columnheader]');
255
- var currentCell = currentRow === null || currentRow === void 0 ? void 0 : currentRow.querySelector("[role=gridcell][aria-colindex='".concat(_this.focusedCell[1] + 1, "']"));
256
- var currentHeaderCell = headerCells === null || headerCells === void 0 ? void 0 : headerCells.item(_this.focusedCell[1]);
257
- var changed = true;
258
- var newRow = _this.focusedCell[0] + rowIndex;
259
- var newCol = _this.focusedCell[1] + colIndex;
260
- if ((hasFocusable && newRow < 0 || !hasFocusable && newRow < 1 || newRow > maxRow) && newRow !== _this.focusedCell[0]) {
236
+ (0, _defineProperty2.default)(this, "changeFocusCell", (rowIndex, colIndex, direction) => {
237
+ const {
238
+ limit
239
+ } = this.asProps;
240
+ const hasFocusable = this.hasFocusableInHeader();
241
+ const maxCol = this.columns.length - 1;
242
+ const maxRow = this.totalRows || 1;
243
+ const currentRow = this.tableRef.current?.querySelector(`[aria-rowindex="${this.focusedCell[0] + 1}"]`);
244
+ const headerCells = this.tableRef.current?.querySelectorAll('[role=columnheader]');
245
+ const currentCell = currentRow?.querySelector(`[role=gridcell][aria-colindex='${this.focusedCell[1] + 1}']`);
246
+ const currentHeaderCell = headerCells?.item(this.focusedCell[1]);
247
+ let changed = true;
248
+ const newRow = this.focusedCell[0] + rowIndex;
249
+ const newCol = this.focusedCell[1] + colIndex;
250
+ if ((hasFocusable && newRow < 0 || !hasFocusable && newRow < 1 || newRow > maxRow) && newRow !== this.focusedCell[0]) {
261
251
  changed = false;
262
252
  }
263
- if ((newCol < 0 || newCol > maxCol) && newCol !== _this.focusedCell[1]) {
253
+ if ((newCol < 0 || newCol > maxCol) && newCol !== this.focusedCell[1]) {
264
254
  changed = false;
265
255
  }
266
256
  if (!changed) return;
267
- var row = _this.getRow(newRow);
268
- var cell = row === null || row === void 0 ? void 0 : row.querySelector(":scope > div > [role=gridcell][aria-colindex=\"".concat(newCol + 1, "\"]:not([aria-hidden=\"true\"]), :scope > [role=columnheader][aria-colindex=\"").concat(newCol + 1, "\"]:not([aria-hidden=\"true\"]), :scope > div > [role=columnheader][aria-colindex=\"").concat(newCol + 1, "\"]:not([aria-hidden=\"true\"])"));
257
+ const row = this.getRow(newRow);
258
+ const cell = row?.querySelector(`:scope > div > [role=gridcell][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"]), :scope > [role=columnheader][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"]), :scope > div > [role=columnheader][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"])`);
269
259
  if (cell instanceof HTMLElement && currentCell !== cell) {
270
- _this.focusedCell = [newRow, newCol];
271
- currentCell === null || currentCell === void 0 || currentCell.setAttribute('inert', '');
260
+ this.focusedCell = [newRow, newCol];
261
+ currentCell?.setAttribute('inert', '');
272
262
  if (currentCell !== currentHeaderCell) {
273
- currentCell === null || currentCell === void 0 || currentCell.removeAttribute('aria-describedby');
263
+ currentCell?.removeAttribute('aria-describedby');
274
264
  }
275
- var headerCell = headerCells === null || headerCells === void 0 ? void 0 : headerCells.item(newCol);
276
- var describedBy = headerCell === null || headerCell === void 0 ? void 0 : headerCell.getAttribute('aria-describedby');
265
+ const headerCell = headerCells?.item(newCol);
266
+ const describedBy = headerCell?.getAttribute('aria-describedby');
277
267
  cell.removeAttribute('inert');
278
268
  if (headerCell !== cell && describedBy) {
279
269
  cell.setAttribute('aria-describedby', describedBy);
280
270
  }
281
- cell === null || cell === void 0 || cell.focus({
271
+ cell?.focus({
282
272
  focusVisible: true
283
273
  });
284
274
  if (newRow !== 0) {
285
- currentHeaderCell === null || currentHeaderCell === void 0 || currentHeaderCell.setAttribute('inert', '');
286
- var _headerCell = headerCells === null || headerCells === void 0 ? void 0 : headerCells.item(newCol);
287
- _headerCell === null || _headerCell === void 0 || _headerCell.removeAttribute('inert');
275
+ currentHeaderCell?.setAttribute('inert', '');
276
+ const headerCell = headerCells?.item(newCol);
277
+ headerCell?.removeAttribute('inert');
288
278
  }
289
279
  } else if (cell === null && currentCell instanceof HTMLElement) {
290
- var rowI = rowIndex;
291
- var colI = colIndex;
292
- var colspan = Number(currentCell.getAttribute('aria-colspan'));
293
- var rowspan = Number(currentCell.getAttribute('aria-rowspan'));
280
+ let rowI = rowIndex;
281
+ let colI = colIndex;
282
+ const colspan = Number(currentCell.getAttribute('aria-colspan'));
283
+ const rowspan = Number(currentCell.getAttribute('aria-rowspan'));
294
284
  if (direction === 'left' || direction === 'right') {
295
- var _currentCell$parentEl;
296
285
  // we need to skip Collapse Element with one big component from keyboard left/right pressing
297
- if (((_currentCell$parentEl = currentCell.parentElement) === null || _currentCell$parentEl === void 0 || (_currentCell$parentEl = _currentCell$parentEl.parentElement) === null || _currentCell$parentEl === void 0 ? void 0 : _currentCell$parentEl.dataset.uiName) === 'Collapse') {
286
+ if (currentCell.parentElement?.parentElement?.dataset.uiName === 'Collapse') {
298
287
  return;
299
288
  }
300
289
  // skipping x-axis movement of the focus within limit overlay and there is only limit by rows
301
- if ((limit === null || limit === void 0 ? void 0 : limit.fromRow) !== undefined && limit.fromColumn === undefined && newCol === limit.fromRow) {
290
+ if (limit?.fromRow !== undefined && limit.fromColumn === undefined && newCol === limit.fromRow) {
302
291
  return;
303
292
  }
304
- var hasRowSpanUpper = row instanceof HTMLElement && Number(row.dataset.filledColumns) < _this.columns.length;
293
+ const hasRowSpanUpper = row instanceof HTMLElement && Number(row.dataset.filledColumns) < this.columns.length;
305
294
  if (colspan > 0) {
306
- if (direction === 'right' && (limit === null || limit === void 0 ? void 0 : limit.fromColumn) !== undefined && newCol === limit.fromColumn) {
295
+ if (direction === 'right' && limit?.fromColumn !== undefined && newCol === limit.fromColumn) {
307
296
  rowI = rowI - 1;
308
297
  } else {
309
298
  colI = direction === 'left' ? colI - colspan + 1 : colI + colspan - 1;
310
299
  }
311
- } else if (hasRowSpanUpper || direction === 'right' && ((limit === null || limit === void 0 ? void 0 : limit.fromColumn) !== undefined || (limit === null || limit === void 0 ? void 0 : limit.fromRow) !== undefined)) {
300
+ } else if (hasRowSpanUpper || direction === 'right' && (limit?.fromColumn !== undefined || limit?.fromRow !== undefined)) {
312
301
  rowI = rowI - 1;
313
302
  } else {
314
303
  colI = direction === 'left' ? colI - 1 : colI + 1;
@@ -320,92 +309,92 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
320
309
  } else if (Number(currentCell.getAttribute('aria-colindex')) === 1) {
321
310
  rowI = direction === 'up' ? rowI - 1 : rowI + 1;
322
311
  } else {
323
- var _limit$fromRow;
324
- var areLimitsDefined = (limit === null || limit === void 0 ? void 0 : limit.fromRow) !== undefined || (limit === null || limit === void 0 ? void 0 : limit.fromColumn) !== undefined;
325
- if (areLimitsDefined && newRow > ((_limit$fromRow = limit === null || limit === void 0 ? void 0 : limit.fromRow) !== null && _limit$fromRow !== void 0 ? _limit$fromRow : 0) + 1) {
312
+ const areLimitsDefined = limit?.fromRow !== undefined || limit?.fromColumn !== undefined;
313
+ if (areLimitsDefined && newRow > (limit?.fromRow ?? 0) + 1) {
326
314
  return;
327
315
  }
328
- var _hasRowSpanUpper = row instanceof HTMLElement && currentRow instanceof HTMLElement && row.dataset.filledColumns !== currentRow.dataset.filledColumns;
329
- if (direction === 'up' && _hasRowSpanUpper) {
316
+ const hasRowSpanUpper = row instanceof HTMLElement && currentRow instanceof HTMLElement && row.dataset.filledColumns !== currentRow.dataset.filledColumns;
317
+ if (direction === 'up' && hasRowSpanUpper) {
330
318
  rowI = rowI - 1;
331
319
  } else {
332
320
  colI = colI - 1;
333
321
  }
334
322
  }
335
323
  }
336
- _this.changeFocusCell(rowI, colI, direction);
324
+ this.changeFocusCell(rowI, colI, direction);
337
325
  } else if (cell === null && currentHeaderCell instanceof HTMLElement && direction === 'down') {
338
- var _colI = colIndex - 1;
339
- _this.changeFocusCell(rowIndex, _colI, direction);
340
- } else if (row === null && _this.focusedCell[0] === 0 && direction === 'down' && _this.asProps.virtualScroll) {
341
- _this.changeFocusCell(rowIndex + 1, colIndex, direction);
326
+ const colI = colIndex - 1;
327
+ this.changeFocusCell(rowIndex, colI, direction);
328
+ } else if (row === null && this.focusedCell[0] === 0 && direction === 'down' && this.asProps.virtualScroll) {
329
+ this.changeFocusCell(rowIndex + 1, colIndex, direction);
342
330
  }
343
331
  });
344
- (0, _defineProperty2["default"])(_this, "handleKeyDown", function (e) {
332
+ (0, _defineProperty2.default)(this, "handleKeyDown", e => {
345
333
  switch (e.key) {
346
334
  case 'Tab':
347
335
  {
348
- _this.setInert(true);
336
+ this.setInert(true);
349
337
  break;
350
338
  }
351
339
  case 'ArrowLeft':
352
340
  {
353
341
  e.preventDefault();
354
- _this.changeFocusCell(0, -1, 'left');
342
+ this.changeFocusCell(0, -1, 'left');
355
343
  break;
356
344
  }
357
345
  case 'ArrowRight':
358
346
  {
359
347
  e.preventDefault();
360
- _this.changeFocusCell(0, 1, 'right');
348
+ this.changeFocusCell(0, 1, 'right');
361
349
  break;
362
350
  }
363
351
  case 'ArrowUp':
364
352
  {
365
353
  e.preventDefault();
366
- _this.changeFocusCell(-1, 0, 'up');
354
+ this.changeFocusCell(-1, 0, 'up');
367
355
  break;
368
356
  }
369
357
  case 'ArrowDown':
370
358
  {
371
359
  e.preventDefault();
372
- _this.changeFocusCell(1, 0, 'down');
360
+ this.changeFocusCell(1, 0, 'down');
373
361
  break;
374
362
  }
375
363
  case 'Shift':
376
364
  {
377
- _this.isPressedShift = true;
365
+ this.isPressedShift = true;
378
366
  }
379
367
  }
380
368
  });
381
- (0, _defineProperty2["default"])(_this, "handleKeyUp", function (e) {
369
+ (0, _defineProperty2.default)(this, "handleKeyUp", e => {
382
370
  if (e.key === 'Shift') {
383
- _this.isPressedShift = false;
371
+ this.isPressedShift = false;
384
372
  }
385
373
  });
386
- (0, _defineProperty2["default"])(_this, "handleScroll", (0, _rafTrottle["default"])(function (e) {
387
- if (_this.asProps.virtualScroll) {
388
- var scrollTop = e.target.scrollTop;
389
- var scrollDirection = scrollTop > _this.state.scrollTop ? 'down' : 'up';
390
- _this.setState({
391
- scrollTop: scrollTop,
392
- scrollDirection: scrollDirection
374
+ (0, _defineProperty2.default)(this, "handleScroll", (0, _rafTrottle.default)(e => {
375
+ if (this.asProps.virtualScroll) {
376
+ const scrollTop = e.target.scrollTop;
377
+ const scrollDirection = scrollTop > this.state.scrollTop ? 'down' : 'up';
378
+ this.setState({
379
+ scrollTop,
380
+ scrollDirection
393
381
  });
394
382
  }
395
- if (_this.hasFixedColumn) {
396
- _this.calculateVerticalShadow();
383
+ if (this.hasFixedColumn) {
384
+ this.calculateVerticalShadow();
397
385
  }
398
386
  }));
399
- (0, _defineProperty2["default"])(_this, "calculateVerticalShadow", function () {
400
- if (!_this.tableContainerRef.current) return;
401
- var _this$tableContainerR = _this.tableContainerRef.current,
402
- scrollWidth = _this$tableContainerR.scrollWidth,
403
- clientWidth = _this$tableContainerR.clientWidth,
404
- scrollLeft = _this$tableContainerR.scrollLeft;
405
- var maxScrollRight = scrollWidth - clientWidth;
406
- var roundedScroll = Math.round(scrollLeft);
407
- var roundedMaxScroll = Math.round(maxScrollRight);
408
- var shadow = '';
387
+ (0, _defineProperty2.default)(this, "calculateVerticalShadow", () => {
388
+ if (!this.tableContainerRef.current) return;
389
+ const {
390
+ scrollWidth,
391
+ clientWidth,
392
+ scrollLeft
393
+ } = this.tableContainerRef.current;
394
+ const maxScrollRight = scrollWidth - clientWidth;
395
+ const roundedScroll = Math.round(scrollLeft);
396
+ const roundedMaxScroll = Math.round(maxScrollRight);
397
+ let shadow = '';
409
398
  // not scroll
410
399
  if (roundedMaxScroll <= 0) {
411
400
  // start scroll
@@ -418,46 +407,41 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
418
407
  } else if (roundedScroll > 0) {
419
408
  shadow = 'median';
420
409
  }
421
- _this.setState({
410
+ this.setState({
422
411
  shadowVertical: shadow
423
412
  });
424
413
  });
425
- (0, _defineProperty2["default"])(_this, "handleFocus", function (e) {
426
- if (_this.asProps.loading) {
427
- var _this$spinnerRef$curr;
428
- (_this$spinnerRef$curr = _this.spinnerRef.current) === null || _this$spinnerRef$curr === void 0 || _this$spinnerRef$curr.focus();
414
+ (0, _defineProperty2.default)(this, "handleFocus", e => {
415
+ if (this.asProps.loading) {
416
+ this.spinnerRef.current?.focus();
429
417
  e.currentTarget.setAttribute('tabIndex', '-1');
430
- if (_this.isDataEmpty) {
431
- var _this$headerRef$curre;
432
- (_this$headerRef$curre = _this.headerRef.current) === null || _this$headerRef$curre === void 0 || _this$headerRef$curre.setAttribute('tabIndex', '-1');
418
+ if (this.isDataEmpty) {
419
+ this.headerRef.current?.setAttribute('tabIndex', '-1');
433
420
  }
434
421
  } else if ((!e.relatedTarget || !(0, _useFocusLock.isFocusInside)(e.currentTarget, e.relatedTarget)) && _core.lastInteraction.isKeyboard()) {
435
- var _row;
436
- if (_this.focusedCell[0] === -1 && _this.focusedCell[1] === -1) {
437
- _this.initFocusableCell();
422
+ if (this.focusedCell[0] === -1 && this.focusedCell[1] === -1) {
423
+ this.initFocusableCell();
438
424
  }
439
- _this.setInert(true);
440
- var row = _this.getRow(_this.focusedCell[0]);
425
+ this.setInert(true);
426
+ let row = this.getRow(this.focusedCell[0]);
441
427
  if (!row) {
442
- _this.initFocusableCell();
443
- row = _this.getRow(_this.focusedCell[0]);
428
+ this.initFocusableCell();
429
+ row = this.getRow(this.focusedCell[0]);
444
430
  }
445
- if (!row && _this.asProps.virtualScroll) {
446
- var _this$tableRef$curren4, _firstAvailableCell$p;
447
- var firstAvailableCell = (_this$tableRef$curren4 = _this.tableRef.current) === null || _this$tableRef$curren4 === void 0 ? void 0 : _this$tableRef$curren4.querySelector("[role=\"gridcell\"]");
448
- var firstAvailableRow = firstAvailableCell === null || firstAvailableCell === void 0 || (_firstAvailableCell$p = firstAvailableCell.parentElement) === null || _firstAvailableCell$p === void 0 ? void 0 : _firstAvailableCell$p.parentElement;
431
+ if (!row && this.asProps.virtualScroll) {
432
+ const firstAvailableCell = this.tableRef.current?.querySelector(`[role="gridcell"]`);
433
+ const firstAvailableRow = firstAvailableCell?.parentElement?.parentElement;
449
434
  if (firstAvailableCell && firstAvailableRow) {
450
- var _firstAvailableCell$g, _firstAvailableRow$ge;
451
- var colIndex = Number((_firstAvailableCell$g = firstAvailableCell.getAttribute('aria-colindex')) !== null && _firstAvailableCell$g !== void 0 ? _firstAvailableCell$g : 1) - 1;
452
- var rowIndex = Number((_firstAvailableRow$ge = firstAvailableRow.getAttribute('aria-rowindex')) !== null && _firstAvailableRow$ge !== void 0 ? _firstAvailableRow$ge : 1) - 1;
453
- _this.focusedCell[0] = rowIndex;
454
- _this.focusedCell[1] = colIndex;
435
+ const colIndex = Number(firstAvailableCell.getAttribute('aria-colindex') ?? 1) - 1;
436
+ const rowIndex = Number(firstAvailableRow.getAttribute('aria-rowindex') ?? 1) - 1;
437
+ this.focusedCell[0] = rowIndex;
438
+ this.focusedCell[1] = colIndex;
455
439
  row = firstAvailableRow;
456
440
  }
457
441
  }
458
- var colindex = _this.focusedCell[1];
459
- var cell = colindex > -1 ? (_row = row) === null || _row === void 0 ? void 0 : _row.querySelector("[role=gridcell][aria-colindex=\"".concat(colindex + 1, "\"]:not([aria-hidden=\"true\"]), [role=columnheader][aria-colindex=\"").concat(colindex + 1, "\"]:not([aria-hidden=\"true\"])")) : undefined;
460
- cell === null || cell === void 0 || cell.removeAttribute('inert');
442
+ const colindex = this.focusedCell[1];
443
+ const cell = colindex > -1 ? row?.querySelector(`[role=gridcell][aria-colindex="${colindex + 1}"]:not([aria-hidden="true"]), [role=columnheader][aria-colindex="${colindex + 1}"]:not([aria-hidden="true"])`) : undefined;
444
+ cell?.removeAttribute('inert');
461
445
  if (cell instanceof HTMLElement) {
462
446
  if ((0, _hasParent.hasParent)(e.target, cell) && !e.target.dataset.skipTargetFocus) {
463
447
  e.target.focus({
@@ -469,58 +453,53 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
469
453
  });
470
454
  }
471
455
  }
472
- if (_this.isDataEmpty) {
473
- var _this$headerRef$curre2;
474
- (_this$headerRef$curre2 = _this.headerRef.current) === null || _this$headerRef$curre2 === void 0 || _this$headerRef$curre2.setAttribute('tabIndex', '-1');
456
+ if (this.isDataEmpty) {
457
+ this.headerRef.current?.setAttribute('tabIndex', '-1');
475
458
  }
476
459
  e.currentTarget.setAttribute('tabIndex', '-1');
477
460
  }
478
461
  });
479
- (0, _defineProperty2["default"])(_this, "handleBlur", function (e) {
480
- var relatedTarget = e.relatedTarget;
481
- var tableElement = _this.tableRef.current;
462
+ (0, _defineProperty2.default)(this, "handleBlur", e => {
463
+ const relatedTarget = e.relatedTarget;
464
+ const tableElement = this.tableRef.current;
482
465
  if (tableElement && (!relatedTarget || !(0, _useFocusLock.isFocusInside)(tableElement, relatedTarget) || !_core.lastInteraction.isKeyboard())) {
483
- _this.setInert(false);
466
+ this.setInert(false);
484
467
  tableElement.setAttribute('tabIndex', '0');
485
- if (_this.isDataEmpty) {
486
- var _this$headerRef$curre3;
487
- (_this$headerRef$curre3 = _this.headerRef.current) === null || _this$headerRef$curre3 === void 0 || _this$headerRef$curre3.setAttribute('tabIndex', '0');
468
+ if (this.isDataEmpty) {
469
+ this.headerRef.current?.setAttribute('tabIndex', '0');
488
470
  }
489
471
  }
490
472
  });
491
- (0, _defineProperty2["default"])(_this, "handleMouseMove", function () {
492
- _this.setInert(false);
473
+ (0, _defineProperty2.default)(this, "handleMouseMove", () => {
474
+ this.setInert(false);
493
475
  });
494
- (0, _defineProperty2["default"])(_this, "handleBackFromAccordion", function (key) {
495
- var cellIndex = _this.columns.findIndex(function (c) {
496
- return c.name === key;
497
- });
498
- _this.changeFocusCell(-1, cellIndex === -1 ? 0 : cellIndex, 'up');
476
+ (0, _defineProperty2.default)(this, "handleBackFromAccordion", key => {
477
+ const cellIndex = this.columns.findIndex(c => c.name === key);
478
+ this.changeFocusCell(-1, cellIndex === -1 ? 0 : cellIndex, 'up');
499
479
  });
500
- (0, _defineProperty2["default"])(_this, "handleContainerResizeEnd", function (entries, observer) {
501
- var _this$asProps$onResiz, _this$asProps3;
502
- if (_this.containerResizeEndTimeoutId) {
503
- clearTimeout(_this.containerResizeEndTimeoutId);
480
+ (0, _defineProperty2.default)(this, "handleContainerResizeEnd", (entries, observer) => {
481
+ if (this.containerResizeEndTimeoutId) {
482
+ clearTimeout(this.containerResizeEndTimeoutId);
504
483
  }
505
- _this.containerResizeEndTimeoutId = setTimeout(_this.calculateVerticalShadow, 0);
506
- (_this$asProps$onResiz = (_this$asProps3 = _this.asProps).onResize) === null || _this$asProps$onResiz === void 0 || _this$asProps$onResiz.call(_this$asProps3, entries, observer);
484
+ this.containerResizeEndTimeoutId = setTimeout(this.calculateVerticalShadow, 0);
485
+ this.asProps.onResize?.(entries, observer);
507
486
  });
508
- (0, _defineProperty2["default"])(_this, "getScrollOffsetValue", function () {
509
- if (!_this.headerRef.current) {
487
+ (0, _defineProperty2.default)(this, "getScrollOffsetValue", () => {
488
+ if (!this.headerRef.current) {
510
489
  return [0, 0];
511
490
  }
512
- var setToMap = function setToMap(element) {
491
+ const setToMap = element => {
513
492
  if (element.getAttribute('name') && element.dataset.uiName === 'Head.Column') {
514
- var name = element.getAttribute('name');
493
+ const name = element.getAttribute('name');
515
494
  if (name) {
516
- _this.headerNodesMap.set(name, element);
495
+ this.headerNodesMap.set(name, element);
517
496
  }
518
497
  }
519
498
  };
520
- _this.headerRef.current.childNodes.forEach(function (node) {
499
+ this.headerRef.current.childNodes.forEach(node => {
521
500
  if (node instanceof HTMLElement) {
522
501
  if (node.classList.value.includes('SGroupContainer')) {
523
- node.childNodes.forEach(function (columnNode) {
502
+ node.childNodes.forEach(columnNode => {
524
503
  if (columnNode instanceof HTMLElement) {
525
504
  setToMap(columnNode);
526
505
  }
@@ -530,387 +509,362 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
530
509
  }
531
510
  }
532
511
  });
533
- return _this.columns.reduce(function (acc, column) {
512
+ return this.columns.reduce((acc, column) => {
534
513
  if (column.fixed === 'left') {
535
- var _this$headerNodesMap$, _this$headerNodesMap$2;
536
- acc[0] += (_this$headerNodesMap$ = (_this$headerNodesMap$2 = _this.headerNodesMap.get(column.name)) === null || _this$headerNodesMap$2 === void 0 ? void 0 : _this$headerNodesMap$2.getBoundingClientRect().width) !== null && _this$headerNodesMap$ !== void 0 ? _this$headerNodesMap$ : 0;
514
+ acc[0] += this.headerNodesMap.get(column.name)?.getBoundingClientRect().width ?? 0;
537
515
  }
538
516
  if (column.fixed === 'right') {
539
- var _this$headerNodesMap$3, _this$headerNodesMap$4;
540
- acc[1] += (_this$headerNodesMap$3 = (_this$headerNodesMap$4 = _this.headerNodesMap.get(column.name)) === null || _this$headerNodesMap$4 === void 0 ? void 0 : _this$headerNodesMap$4.getBoundingClientRect().width) !== null && _this$headerNodesMap$3 !== void 0 ? _this$headerNodesMap$3 : 0;
517
+ acc[1] += this.headerNodesMap.get(column.name)?.getBoundingClientRect().width ?? 0;
541
518
  }
542
519
  return acc;
543
520
  }, [0, 0]);
544
521
  });
545
- (0, _defineProperty2["default"])(_this, "getFixedStyle", function (cell) {
546
- var side = cell.fixed;
522
+ (0, _defineProperty2.default)(this, "getFixedStyle", cell => {
523
+ const side = cell.fixed;
547
524
  if (!side) return [undefined, undefined];
548
- var names = cell.name.split('/');
549
- var nameSideMap = {
525
+ const names = cell.name.split('/');
526
+ const nameSideMap = {
550
527
  left: names[0],
551
528
  right: names[names.length - 1]
552
529
  };
553
- var name = nameSideMap[side];
554
- var index = _this.columns.findIndex(function (column) {
555
- return column.name === name;
556
- });
530
+ const name = nameSideMap[side];
531
+ const index = this.columns.findIndex(column => column.name === name);
557
532
  if (index === -1) return [undefined, undefined];
558
- var startIndexSideMap = {
533
+ const startIndexSideMap = {
559
534
  left: 0,
560
535
  right: index + 1
561
536
  };
562
- var endIndexSideMap = {
537
+ const endIndexSideMap = {
563
538
  left: index,
564
- right: _this.columns.length
539
+ right: this.columns.length
565
540
  };
566
- var columnsFixed = _this.columns.slice(startIndexSideMap[side], endIndexSideMap[side]);
541
+ const columnsFixed = this.columns.slice(startIndexSideMap[side], endIndexSideMap[side]);
567
542
  if (columnsFixed.length < 1) return [side, 0];
568
- var sum = columnsFixed.reduce(function (acc, column) {
569
- var _this$headerNodesMap$5;
570
- return acc + ((_this$headerNodesMap$5 = _this.headerNodesMap.get(column.name)) === null || _this$headerNodesMap$5 === void 0 ? void 0 : _this$headerNodesMap$5.getBoundingClientRect().width);
571
- }, 0);
572
- return [side, "".concat(sum, "px")];
543
+ const sum = columnsFixed.reduce((acc, column) => acc + this.headerNodesMap.get(column.name)?.getBoundingClientRect().width, 0);
544
+ return [side, `${sum}px`];
573
545
  });
574
- var cols = _this.calculateColumnsFromConfig();
575
- _this.columns = cols[0];
576
- _this.treeColumns = cols[1];
577
- _this.calculatedRows = _this.getRows();
578
- _this.flatRows = _this.calculatedRows.flat();
579
- _this.tmpData = props.data;
580
- return _this;
546
+ const cols = this.calculateColumnsFromConfig();
547
+ this.columns = cols[0];
548
+ this.treeColumns = cols[1];
549
+ this.calculatedRows = this.getRows();
550
+ this.flatRows = this.calculatedRows.flat();
551
+ this.tmpData = props.data;
581
552
  }
582
- (0, _inherits2["default"])(DataTableRoot, _Component);
583
- return (0, _createClass2["default"])(DataTableRoot, [{
584
- key: "componentDidMount",
585
- value: function componentDidMount() {
586
- var _this2 = this;
587
- var _this$asProps4 = this.asProps,
588
- headerProps = _this$asProps4.headerProps,
589
- loading = _this$asProps4.loading;
590
- if (headerProps !== null && headerProps !== void 0 && headerProps.sticky && !headerProps.h || loading || this.hasFixedColumn) {
591
- requestAnimationFrame(function () {
592
- _this2.forceUpdate();
593
- _this2.calculateVerticalShadow();
594
- });
595
- }
596
- if (headerProps !== null && headerProps !== void 0 && headerProps.sticky && (0, _canUseDOM["default"])() && this.scrollDirection === 'horizontal') {
597
- document.addEventListener('scroll', this.handleDocumentScroll);
598
- }
599
- }
600
- }, {
601
- key: "componentDidUpdate",
602
- value: function componentDidUpdate(prevProps) {
603
- var _this$asProps5 = this.asProps,
604
- data = _this$asProps5.data,
605
- selectedRows = _this$asProps5.selectedRows,
606
- columns = _this$asProps5.columns;
607
- if (prevProps.columns !== columns) {
608
- var cols = this.calculateColumnsFromConfig();
609
- this.columns = cols[0];
610
- this.treeColumns = cols[1];
553
+ componentDidMount() {
554
+ const {
555
+ headerProps,
556
+ loading
557
+ } = this.asProps;
558
+ if (headerProps?.sticky && !headerProps.h || loading || this.hasFixedColumn) {
559
+ requestAnimationFrame(() => {
611
560
  this.forceUpdate();
612
- }
613
- if (prevProps.data !== data || prevProps.columns !== columns) {
614
- if (this.hasFixedColumn) {
615
- this.calculateVerticalShadow();
616
- }
617
- }
618
- if (prevProps.selectedRows !== selectedRows && selectedRows !== undefined) {
619
- var selectedRowsSet = new Set(selectedRows);
620
- var allChecked = [];
621
- var allUnchecked = [];
622
- this.flatRows.forEach(function (row) {
623
- if (selectedRowsSet.has(row[UNIQ_ROW_KEY])) {
624
- allChecked.push(row[UNIQ_ROW_KEY]);
625
- } else {
626
- allUnchecked.push(row[UNIQ_ROW_KEY]);
627
- }
628
- });
629
- if (allChecked.length === data.length) {
630
- this.setSelectAllMessage(true);
631
- } else if (allUnchecked.length === data.length) {
632
- this.setSelectAllMessage(false);
633
- }
634
- }
561
+ this.calculateVerticalShadow();
562
+ });
635
563
  }
636
- }, {
637
- key: "componentWillUnmount",
638
- value: function componentWillUnmount() {
639
- var _this$state$expandedR;
640
- if ((0, _canUseDOM["default"])()) {
641
- document.removeEventListener('scroll', this.handleDocumentScroll);
642
- }
643
- (_this$state$expandedR = this.state.expandedRows) === null || _this$state$expandedR === void 0 || _this$state$expandedR.clear();
564
+ if (headerProps?.sticky && (0, _canUseDOM.default)() && this.scrollDirection === 'horizontal') {
565
+ document.addEventListener('scroll', this.handleDocumentScroll);
644
566
  }
645
- }, {
646
- key: "totalRows",
647
- get: function get() {
648
- var totalRows = this.asProps.totalRows;
649
- var flatRows = this.getFlatRows();
650
- var expandedRows = this.state.expandedRows;
651
- var expandedRowsCount = Array.from(expandedRows).reduce(function (acc, rowKey) {
652
- var dtRow = flatRows.find(function (el) {
653
- return el[UNIQ_ROW_KEY] === rowKey;
654
- });
655
- if (dtRow) {
656
- var _expandedRows = dtRow[ACCORDION];
657
- if (Array.isArray(_expandedRows)) {
658
- acc = acc + _expandedRows.length;
659
- } else {
660
- acc = acc + 1;
661
- }
662
- }
663
- return acc;
664
- }, 0);
665
- if (totalRows !== undefined) {
666
- return totalRows + expandedRowsCount;
667
- }
668
- var rows = this.getRows().reduce(function (acc, item) {
669
- if (Array.isArray(item)) {
670
- acc = acc + item.length;
671
- } else {
672
- acc = acc + 1;
673
- }
674
- return acc;
675
- }, 0);
676
- return rows + expandedRowsCount;
567
+ }
568
+ componentDidUpdate(prevProps) {
569
+ const {
570
+ data,
571
+ selectedRows,
572
+ columns
573
+ } = this.asProps;
574
+ if (prevProps.columns !== columns) {
575
+ const cols = this.calculateColumnsFromConfig();
576
+ this.columns = cols[0];
577
+ this.treeColumns = cols[1];
578
+ this.forceUpdate();
677
579
  }
678
- }, {
679
- key: "scrollDirection",
680
- get: function get() {
681
- var _this$asProps6 = this.asProps,
682
- w = _this$asProps6.w,
683
- wMax = _this$asProps6.wMax,
684
- h = _this$asProps6.h,
685
- hMax = _this$asProps6.hMax;
686
- var scrollDirection = undefined;
687
- var hasWidthSettings = Boolean(w) || Boolean(wMax);
688
- var hasHeightSettings = Boolean(h) && h !== 'fit-content' || Boolean(hMax);
689
- if (hasWidthSettings && !hasHeightSettings) {
690
- scrollDirection = 'horizontal';
691
- } else if (hasHeightSettings && !hasWidthSettings) {
692
- scrollDirection = 'vertical';
693
- } else if (hasWidthSettings && hasHeightSettings) {
694
- scrollDirection = 'both';
580
+ if (prevProps.data !== data || prevProps.columns !== columns) {
581
+ if (this.hasFixedColumn) {
582
+ this.calculateVerticalShadow();
695
583
  }
696
- return scrollDirection;
697
- }
698
- }, {
699
- key: "isDataEmpty",
700
- get: function get() {
701
- return this.asProps.data.length === 0;
702
584
  }
703
- }, {
704
- key: "getHeadProps",
705
- value: function getHeadProps() {
706
- var _this$asProps7 = this.asProps,
707
- use = _this$asProps7.use,
708
- compact = _this$asProps7.compact,
709
- sort = _this$asProps7.sort,
710
- onSortChange = _this$asProps7.onSortChange,
711
- getI18nText = _this$asProps7.getI18nText,
712
- uid = _this$asProps7.uid,
713
- headerProps = _this$asProps7.headerProps,
714
- onSelectedRowsChange = _this$asProps7.onSelectedRowsChange,
715
- selectedRows = _this$asProps7.selectedRows,
716
- sideIndents = _this$asProps7.sideIndents,
717
- variant = _this$asProps7.variant;
718
- var _this$gridSettings = this.gridSettings,
719
- gridTemplateColumns = _this$gridSettings.gridTemplateColumns,
720
- gridTemplateAreas = _this$gridSettings.gridTemplateAreas;
721
- var shadowVertical = this.state.shadowVertical;
722
- var sideIndentsValue = variant === 'card' ? 'wide' : sideIndents;
723
- return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, headerProps), {}, {
724
- columns: this.columns,
725
- treeColumns: this.treeColumns,
726
- use: use,
727
- tableRef: this.tableRef,
728
- compact: Boolean(compact),
729
- sort: sort,
730
- onSortChange: onSortChange,
731
- getI18nText: getI18nText,
732
- uid: uid,
733
- ref: headerProps !== null && headerProps !== void 0 && headerProps.ref ? (0, _ref9.forkRef)(this.headerRef, headerProps.ref) : this.headerRef,
734
- gridAreaGroupMap: this.gridAreaGroupMap,
735
- gridTemplateColumns: gridTemplateColumns,
736
- gridTemplateAreas: gridTemplateAreas,
737
- sideIndents: sideIndentsValue,
738
- totalRows: this.totalRows,
739
- selectedRows: selectedRows,
740
- flatRows: this.getFlatRows(),
741
- onChangeSelectAll: onSelectedRowsChange,
742
- getFixedStyle: this.getFixedStyle,
743
- onCellClick: this.handleCellClick,
744
- shadowVertical: shadowVertical,
745
- scrollDirection: this.scrollDirection,
746
- isDataEmpty: this.isDataEmpty
585
+ if (prevProps.selectedRows !== selectedRows && selectedRows !== undefined) {
586
+ const selectedRowsSet = new Set(selectedRows);
587
+ const allChecked = [];
588
+ const allUnchecked = [];
589
+ this.flatRows.forEach(row => {
590
+ if (selectedRowsSet.has(row[UNIQ_ROW_KEY])) {
591
+ allChecked.push(row[UNIQ_ROW_KEY]);
592
+ } else {
593
+ allUnchecked.push(row[UNIQ_ROW_KEY]);
594
+ }
747
595
  });
596
+ if (allChecked.length === data.length) {
597
+ this.setSelectAllMessage(true);
598
+ } else if (allUnchecked.length === data.length) {
599
+ this.setSelectAllMessage(false);
600
+ }
748
601
  }
749
- }, {
750
- key: "getBodyProps",
751
- value: function getBodyProps() {
752
- var _this$asProps8 = this.asProps,
753
- use = _this$asProps8.use,
754
- compact = _this$asProps8.compact,
755
- loading = _this$asProps8.loading,
756
- getI18nText = _this$asProps8.getI18nText,
757
- virtualScroll = _this$asProps8.virtualScroll,
758
- uid = _this$asProps8.uid,
759
- rowProps = _this$asProps8.rowProps,
760
- renderCell = _this$asProps8.renderCell,
761
- headerProps = _this$asProps8.headerProps,
762
- renderEmptyData = _this$asProps8.renderEmptyData,
763
- sideIndents = _this$asProps8.sideIndents,
764
- selectedRows = _this$asProps8.selectedRows,
765
- accordionDuration = _this$asProps8.accordionDuration,
766
- accordionMode = _this$asProps8.accordionMode,
767
- rawData = _this$asProps8.data,
768
- renderCellOverlay = _this$asProps8.renderCellOverlay,
769
- limit = _this$asProps8.limit,
770
- variant = _this$asProps8.variant,
771
- totalRows = _this$asProps8.totalRows,
772
- accordionAnimationRows = _this$asProps8.accordionAnimationRows;
773
- var _this$gridSettings2 = this.gridSettings,
774
- gridTemplateColumns = _this$gridSettings2.gridTemplateColumns,
775
- gridTemplateAreas = _this$gridSettings2.gridTemplateAreas;
776
- var shadowVertical = this.state.shadowVertical;
777
- return {
778
- accordionDuration: accordionDuration,
779
- accordionAnimationRows: accordionAnimationRows,
780
- accordionMode: accordionMode,
781
- columns: this.columns,
782
- rows: this.getRows(),
783
- flatRows: this.getFlatRows(),
784
- use: use,
785
- compact: Boolean(compact),
786
- gridTemplateColumns: gridTemplateColumns,
787
- gridTemplateAreas: gridTemplateAreas,
788
- loading: loading,
789
- headerHeight: this.getHeaderHeight(),
790
- stickyHeader: headerProps === null || headerProps === void 0 ? void 0 : headerProps.sticky,
791
- getI18nText: getI18nText,
792
- expandedRows: this.state.expandedRows,
793
- onExpandRow: this.onExpandRow,
794
- spinnerRef: this.spinnerRef,
795
- scrollTop: this.state.scrollTop,
796
- scrollDirection: this.state.scrollDirection,
797
- tableContainerRef: this.tableContainerRef,
798
- tableRef: this.tableRef,
799
- scrollAreaRef: this.scrollAreaRef,
800
- onBackFromAccordion: this.handleBackFromAccordion,
801
- virtualScroll: virtualScroll,
802
- hasGroups: this.hasGroups,
803
- uid: uid,
804
- rowProps: this.getRows().length > 0 ? rowProps : undefined,
805
- renderCell: this.getRows().length > 0 ? renderCell : undefined,
806
- renderEmptyData: renderEmptyData,
807
- sideIndents: sideIndents,
808
- selectedRows: selectedRows,
809
- onSelectRow: this.handleSelectRow,
810
- getFixedStyle: this.getFixedStyle,
811
- onCellClick: this.handleCellClick,
812
- rawData: rawData,
813
- shadowVertical: shadowVertical,
814
- renderCellOverlay: renderCellOverlay,
815
- limit: limit,
816
- variant: variant,
817
- totalRows: totalRows
818
- };
602
+ }
603
+ componentWillUnmount() {
604
+ if ((0, _canUseDOM.default)()) {
605
+ document.removeEventListener('scroll', this.handleDocumentScroll);
819
606
  }
820
- }, {
821
- key: "setInert",
822
- value: function setInert(value) {
823
- var _this$tableRef$curren5;
824
- var cells = (_this$tableRef$curren5 = this.tableRef.current) === null || _this$tableRef$curren5 === void 0 ? void 0 : _this$tableRef$curren5.querySelectorAll('[role=gridcell], [role=columnheader]');
825
- cells === null || cells === void 0 || cells.forEach(function (cell) {
826
- if (value === true) {
827
- cell.setAttribute('inert', '');
607
+ this.state.expandedRows?.clear();
608
+ }
609
+ get totalRows() {
610
+ const {
611
+ totalRows
612
+ } = this.asProps;
613
+ const flatRows = this.getFlatRows();
614
+ const expandedRows = this.state.expandedRows;
615
+ const expandedRowsCount = Array.from(expandedRows).reduce((acc, rowKey) => {
616
+ const dtRow = flatRows.find(el => el[UNIQ_ROW_KEY] === rowKey);
617
+ if (dtRow) {
618
+ const expandedRows = dtRow[ACCORDION];
619
+ if (Array.isArray(expandedRows)) {
620
+ acc = acc + expandedRows.length;
828
621
  } else {
829
- cell.removeAttribute('inert');
622
+ acc = acc + 1;
830
623
  }
831
- });
624
+ }
625
+ return acc;
626
+ }, 0);
627
+ if (totalRows !== undefined) {
628
+ return totalRows + expandedRowsCount;
832
629
  }
833
- }, {
834
- key: "initFocusableCell",
835
- value: function initFocusableCell(initCell) {
836
- var _initCell$, _initCell$2;
837
- var hasFocusable = this.hasFocusableInHeader();
838
- var initRow = (_initCell$ = initCell === null || initCell === void 0 ? void 0 : initCell[0]) !== null && _initCell$ !== void 0 ? _initCell$ : 0;
839
- var initCol = (_initCell$2 = initCell === null || initCell === void 0 ? void 0 : initCell[1]) !== null && _initCell$2 !== void 0 ? _initCell$2 : 0;
840
- if (hasFocusable) {
841
- this.focusedCell = [initRow, initCol];
630
+ const rows = this.getRows().reduce((acc, item) => {
631
+ if (Array.isArray(item)) {
632
+ acc = acc + item.length;
842
633
  } else {
843
- this.focusedCell = [initRow + 1, initCol];
634
+ acc = acc + 1;
844
635
  }
636
+ return acc;
637
+ }, 0);
638
+ return rows + expandedRowsCount;
639
+ }
640
+ get scrollDirection() {
641
+ const {
642
+ w,
643
+ wMax,
644
+ h,
645
+ hMax
646
+ } = this.asProps;
647
+ let scrollDirection = undefined;
648
+ const hasWidthSettings = Boolean(w) || Boolean(wMax);
649
+ const hasHeightSettings = Boolean(h) && h !== 'fit-content' || Boolean(hMax);
650
+ if (hasWidthSettings && !hasHeightSettings) {
651
+ scrollDirection = 'horizontal';
652
+ } else if (hasHeightSettings && !hasWidthSettings) {
653
+ scrollDirection = 'vertical';
654
+ } else if (hasWidthSettings && hasHeightSettings) {
655
+ scrollDirection = 'both';
845
656
  }
846
- }, {
847
- key: "render",
848
- value: function render() {
849
- var _ref = this.asProps,
850
- _ref2;
851
- var SDataTable = _baseComponents.Box;
852
- var _this$asProps9 = this.asProps,
853
- Children = _this$asProps9.Children,
854
- styles = _this$asProps9.styles,
855
- w = _this$asProps9.w,
856
- wMax = _this$asProps9.wMax,
857
- wMin = _this$asProps9.wMin,
858
- h = _this$asProps9.h,
859
- hMax = _this$asProps9.hMax,
860
- hMin = _this$asProps9.hMin,
861
- virtualScroll = _this$asProps9.virtualScroll,
862
- children = _this$asProps9.children,
863
- headerProps = _this$asProps9.headerProps,
864
- loading = _this$asProps9.loading,
865
- selectedRows = _this$asProps9.selectedRows;
866
- var _this$getScrollOffset = this.getScrollOffsetValue(),
867
- _this$getScrollOffset2 = (0, _slicedToArray2["default"])(_this$getScrollOffset, 2),
868
- offsetLeftSum = _this$getScrollOffset2[0],
869
- offsetRightSum = _this$getScrollOffset2[1];
870
- var _this$gridSettings3 = this.gridSettings,
871
- gridTemplateColumns = _this$gridSettings3.gridTemplateColumns,
872
- gridTemplateAreas = _this$gridSettings3.gridTemplateAreas;
873
- var Head = (0, _findComponent["default"])(Children, ['DataTable.Head']);
874
- var headerPropsToCheck = headerProps !== null && headerProps !== void 0 ? headerProps : Head === null || Head === void 0 ? void 0 : Head.props;
875
- var headerHeight = (headerProps === null || headerProps === void 0 ? void 0 : headerProps.h) || this.getHeaderHeight();
876
- var topOffset = headerPropsToCheck !== null && headerPropsToCheck !== void 0 && headerPropsToCheck.sticky || headerPropsToCheck !== null && headerPropsToCheck !== void 0 && headerPropsToCheck.withScrollBar ? headerHeight : undefined;
877
- var width = w !== null && w !== void 0 ? w : this.columns.some(function (c) {
878
- return c.gtcWidth === 'auto' || c.gtcWidth === '1fr';
879
- }) ? '100%' : undefined;
880
- var gridTemplateRows = undefined;
881
- if (virtualScroll && typeof virtualScroll !== 'boolean' && 'rowHeight' in virtualScroll) {
882
- gridTemplateRows = "auto auto repeat(".concat(this.totalRows, ", minmax(").concat(virtualScroll.rowHeight, "px, auto)");
657
+ return scrollDirection;
658
+ }
659
+ get isDataEmpty() {
660
+ return this.asProps.data.length === 0;
661
+ }
662
+ getHeadProps() {
663
+ const {
664
+ use,
665
+ compact,
666
+ sort,
667
+ onSortChange,
668
+ getI18nText,
669
+ uid,
670
+ headerProps,
671
+ onSelectedRowsChange,
672
+ selectedRows,
673
+ sideIndents,
674
+ variant
675
+ } = this.asProps;
676
+ const {
677
+ gridTemplateColumns,
678
+ gridTemplateAreas
679
+ } = this.gridSettings;
680
+ const {
681
+ shadowVertical
682
+ } = this.state;
683
+ const sideIndentsValue = variant === 'card' ? 'wide' : sideIndents;
684
+ return {
685
+ ...headerProps,
686
+ columns: this.columns,
687
+ treeColumns: this.treeColumns,
688
+ use,
689
+ tableRef: this.tableRef,
690
+ compact: Boolean(compact),
691
+ sort,
692
+ onSortChange,
693
+ getI18nText,
694
+ uid,
695
+ ref: headerProps?.ref ? (0, _ref3.forkRef)(this.headerRef, headerProps.ref) : this.headerRef,
696
+ gridAreaGroupMap: this.gridAreaGroupMap,
697
+ gridTemplateColumns,
698
+ gridTemplateAreas,
699
+ sideIndents: sideIndentsValue,
700
+ totalRows: this.totalRows,
701
+ selectedRows,
702
+ flatRows: this.getFlatRows(),
703
+ onChangeSelectAll: onSelectedRowsChange,
704
+ getFixedStyle: this.getFixedStyle,
705
+ onCellClick: this.handleCellClick,
706
+ shadowVertical,
707
+ scrollDirection: this.scrollDirection,
708
+ isDataEmpty: this.isDataEmpty
709
+ };
710
+ }
711
+ getBodyProps() {
712
+ const {
713
+ use,
714
+ compact,
715
+ loading,
716
+ getI18nText,
717
+ virtualScroll,
718
+ uid,
719
+ rowProps,
720
+ renderCell,
721
+ headerProps,
722
+ renderEmptyData,
723
+ sideIndents,
724
+ selectedRows,
725
+ accordionDuration,
726
+ accordionMode,
727
+ data: rawData,
728
+ renderCellOverlay,
729
+ limit,
730
+ variant,
731
+ totalRows,
732
+ accordionAnimationRows
733
+ } = this.asProps;
734
+ const {
735
+ gridTemplateColumns,
736
+ gridTemplateAreas
737
+ } = this.gridSettings;
738
+ const {
739
+ shadowVertical
740
+ } = this.state;
741
+ return {
742
+ accordionDuration,
743
+ accordionAnimationRows,
744
+ accordionMode,
745
+ columns: this.columns,
746
+ rows: this.getRows(),
747
+ flatRows: this.getFlatRows(),
748
+ use,
749
+ compact: Boolean(compact),
750
+ gridTemplateColumns,
751
+ gridTemplateAreas,
752
+ loading,
753
+ headerHeight: this.getHeaderHeight(),
754
+ stickyHeader: headerProps?.sticky,
755
+ getI18nText,
756
+ expandedRows: this.state.expandedRows,
757
+ onExpandRow: this.onExpandRow,
758
+ spinnerRef: this.spinnerRef,
759
+ scrollTop: this.state.scrollTop,
760
+ scrollDirection: this.state.scrollDirection,
761
+ tableContainerRef: this.tableContainerRef,
762
+ tableRef: this.tableRef,
763
+ scrollAreaRef: this.scrollAreaRef,
764
+ onBackFromAccordion: this.handleBackFromAccordion,
765
+ virtualScroll,
766
+ hasGroups: this.hasGroups,
767
+ uid,
768
+ rowProps: this.getRows().length > 0 ? rowProps : undefined,
769
+ renderCell: this.getRows().length > 0 ? renderCell : undefined,
770
+ renderEmptyData,
771
+ sideIndents,
772
+ selectedRows,
773
+ onSelectRow: this.handleSelectRow,
774
+ getFixedStyle: this.getFixedStyle,
775
+ onCellClick: this.handleCellClick,
776
+ rawData,
777
+ shadowVertical,
778
+ renderCellOverlay,
779
+ limit,
780
+ variant,
781
+ totalRows
782
+ };
783
+ }
784
+ setInert(value) {
785
+ const cells = this.tableRef.current?.querySelectorAll('[role=gridcell], [role=columnheader]');
786
+ cells?.forEach(cell => {
787
+ if (value === true) {
788
+ cell.setAttribute('inert', '');
789
+ } else {
790
+ cell.removeAttribute('inert');
883
791
  }
884
- return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea, _ref2.cn("ScrollArea", {
885
- "leftOffset": offsetLeftSum,
886
- "rightOffset": offsetRightSum,
887
- "topOffset": topOffset,
888
- "w": width,
889
- "wMax": wMax,
890
- "wMin": wMin,
891
- "h": h,
892
- "hMax": hMax,
893
- "hMin": hMin,
894
- "shadow": true,
895
- "ref": this.scrollAreaRef,
896
- "container": this.tableContainerRef,
897
- "styles": scrollStyles,
898
- "onScroll": this.handleScroll,
899
- "disableAutofocusToContent": true,
900
- "onResize": this.handleContainerResizeEnd
901
- }), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Container, {
902
- tabIndex: -1
903
- // @ts-ignore
904
- ,
905
- scrollDirection: this.scrollDirection
906
- // @ts-ignore
907
- ,
908
- loading: loading,
909
- headerHeight: "".concat(headerHeight, "px"),
910
- leftScrollPadding: "".concat(offsetLeftSum, "px"),
911
- rightScrollPadding: "".concat(offsetRightSum, "px")
912
- }, /*#__PURE__*/React.createElement(SDataTable, _ref2.cn("SDataTable", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
913
- "ref": (0, _ref9.forkRef)(this.tableRef, this.tableContainerRef),
792
+ });
793
+ }
794
+ initFocusableCell(initCell) {
795
+ const hasFocusable = this.hasFocusableInHeader();
796
+ const initRow = initCell?.[0] ?? 0;
797
+ const initCol = initCell?.[1] ?? 0;
798
+ if (hasFocusable) {
799
+ this.focusedCell = [initRow, initCol];
800
+ } else {
801
+ this.focusedCell = [initRow + 1, initCol];
802
+ }
803
+ }
804
+ render() {
805
+ var _ref = this.asProps,
806
+ _ref2;
807
+ const SDataTable = _baseComponents.Box;
808
+ const {
809
+ Children,
810
+ styles,
811
+ w,
812
+ wMax,
813
+ wMin,
814
+ h,
815
+ hMax,
816
+ hMin,
817
+ virtualScroll,
818
+ children,
819
+ headerProps,
820
+ loading,
821
+ selectedRows
822
+ } = this.asProps;
823
+ const [offsetLeftSum, offsetRightSum] = this.getScrollOffsetValue();
824
+ const {
825
+ gridTemplateColumns,
826
+ gridTemplateAreas
827
+ } = this.gridSettings;
828
+ const Head = (0, _findComponent.default)(Children, ['DataTable.Head']);
829
+ const headerPropsToCheck = headerProps ?? Head?.props;
830
+ const headerHeight = headerProps?.h || this.getHeaderHeight();
831
+ const topOffset = headerPropsToCheck?.sticky || headerPropsToCheck?.withScrollBar ? headerHeight : undefined;
832
+ const width = w ?? (this.columns.some(c => c.gtcWidth === 'auto' || c.gtcWidth === '1fr') ? '100%' : undefined);
833
+ let gridTemplateRows = undefined;
834
+ if (virtualScroll && typeof virtualScroll !== 'boolean' && 'rowHeight' in virtualScroll) {
835
+ gridTemplateRows = `auto auto repeat(${this.totalRows}, minmax(${virtualScroll.rowHeight}px, auto)`;
836
+ }
837
+ return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea, _ref2.cn("ScrollArea", {
838
+ "leftOffset": offsetLeftSum,
839
+ "rightOffset": offsetRightSum,
840
+ "topOffset": topOffset,
841
+ "w": width,
842
+ "wMax": wMax,
843
+ "wMin": wMin,
844
+ "h": h,
845
+ "hMax": hMax,
846
+ "hMin": hMin,
847
+ "shadow": true,
848
+ "ref": this.scrollAreaRef,
849
+ "container": this.tableContainerRef,
850
+ "styles": scrollStyles,
851
+ "onScroll": this.handleScroll,
852
+ "disableAutofocusToContent": true,
853
+ "onResize": this.handleContainerResizeEnd
854
+ }), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Container, {
855
+ tabIndex: -1
856
+ // @ts-ignore
857
+ ,
858
+ scrollDirection: this.scrollDirection
859
+ // @ts-ignore
860
+ ,
861
+ loading: loading,
862
+ headerHeight: `${headerHeight}px`,
863
+ leftScrollPadding: `${offsetLeftSum}px`,
864
+ rightScrollPadding: `${offsetRightSum}px`
865
+ }, /*#__PURE__*/React.createElement(SDataTable, _ref2.cn("SDataTable", {
866
+ ...(0, _core.assignProps)({
867
+ "ref": (0, _ref3.forkRef)(this.tableRef, this.tableContainerRef),
914
868
  "role": 'grid',
915
869
  "onKeyDown": this.handleKeyDown,
916
870
  "onKeyUp": this.handleKeyUp,
@@ -932,345 +886,320 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
932
886
  "use:h": undefined,
933
887
  "use:hMax": undefined,
934
888
  "use:hMin": undefined
935
- }, _ref))), children ? /*#__PURE__*/React.createElement(Children, _ref2.cn("Children", {})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataTable.Head, null), /*#__PURE__*/React.createElement(DataTable.Body, null)))), (headerPropsToCheck === null || headerPropsToCheck === void 0 ? void 0 : headerPropsToCheck.withScrollBar) && topOffset && !loading && /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
936
- orientation: "horizontal",
937
- top: topOffset - SCROLL_BAR_HEIGHT,
938
- zIndex: 20
939
- }), !loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
940
- orientation: "horizontal",
941
- zIndex: 20
942
- }), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
943
- orientation: "vertical",
944
- zIndex: 20
945
- })), selectedRows !== undefined && /*#__PURE__*/React.createElement(_baseComponents.ScreenReaderOnly, _ref2.cn("ScreenReaderOnly", {
946
- "aria-live": 'polite',
947
- "role": 'status'
948
- }), this.state.selectAllMessage));
949
- }
950
- }, {
951
- key: "calculateColumnsFromConfig",
952
- value: function calculateColumnsFromConfig() {
953
- var _this3 = this;
954
- var _this$props = this.props,
955
- columns = _this$props.columns,
956
- data = _this$props.data,
957
- selectedRows = _this$props.selectedRows;
958
- this.hasGroups = columns.some(function (column) {
959
- return 'columns' in column && column.columns.some(function (col) {
960
- return col.children !== null;
961
- });
889
+ }, _ref)
890
+ }), children ? /*#__PURE__*/React.createElement(Children, _ref2.cn("Children", {})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataTable.Head, null), /*#__PURE__*/React.createElement(DataTable.Body, null)))), headerPropsToCheck?.withScrollBar && topOffset && !loading && /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
891
+ orientation: "horizontal",
892
+ top: topOffset - SCROLL_BAR_HEIGHT,
893
+ zIndex: 20
894
+ }), !loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
895
+ orientation: "horizontal",
896
+ zIndex: 20
897
+ }), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
898
+ orientation: "vertical",
899
+ zIndex: 20
900
+ })), selectedRows !== undefined && /*#__PURE__*/React.createElement(_baseComponents.ScreenReaderOnly, _ref2.cn("ScreenReaderOnly", {
901
+ "aria-live": 'polite',
902
+ "role": 'status'
903
+ }), this.state.selectAllMessage));
904
+ }
905
+ calculateColumnsFromConfig() {
906
+ const {
907
+ columns,
908
+ data,
909
+ selectedRows
910
+ } = this.props;
911
+ this.hasGroups = columns.some(column => {
912
+ return 'columns' in column && column.columns.some(col => {
913
+ return col.children !== null;
962
914
  });
963
- var groupIndex = 0;
964
- var gridColumnIndex = selectedRows ? 2 : 1;
965
- var calculateGridTemplateColumn = this.calculateGridTemplateColumn.bind(this);
966
- var calculatedColumns = [];
967
- var treeColumns = [];
968
- if (selectedRows) {
969
- var column = {
970
- name: SELECT_ALL.toString(),
971
- gtcWidth: 'min-content',
972
- alignItems: 'flex-start',
973
- children: ''
974
- };
975
- calculatedColumns.push(column);
976
- }
977
- var makeColumn = function makeColumn(columnElement, parent, isFirst, isLast, hasGroups) {
978
- var _columnElement$fixed, _ref3, _columnElement$border;
979
- var leftBordersFromParent = isFirst && ((parent === null || parent === void 0 ? void 0 : parent.borders) === 'both' || (parent === null || parent === void 0 ? void 0 : parent.borders) === 'left') ? 'left' : undefined;
980
- var rightBordersFromParent = isLast && ((parent === null || parent === void 0 ? void 0 : parent.borders) === 'both' || (parent === null || parent === void 0 ? void 0 : parent.borders) === 'right') ? 'right' : undefined;
981
- var column = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, columnElement), {}, {
982
- name: childIsColumn(columnElement) ? columnElement.name : '',
983
- gtcWidth: childIsColumn(columnElement) ? calculateGridTemplateColumn(columnElement) : '',
984
- fixed: (_columnElement$fixed = columnElement.fixed) !== null && _columnElement$fixed !== void 0 ? _columnElement$fixed : hasGroups ? parent === null || parent === void 0 ? void 0 : parent.fixed : undefined,
985
- borders: (_ref3 = (_columnElement$border = columnElement.borders) !== null && _columnElement$border !== void 0 ? _columnElement$border : leftBordersFromParent) !== null && _ref3 !== void 0 ? _ref3 : rightBordersFromParent,
986
- parent: parent
987
- });
988
- if (column.fixed) {
989
- _this3.hasFixedColumn = true;
990
- }
991
- return column;
992
- };
993
- var childIsColumn = function childIsColumn(child) {
994
- return !('columns' in child);
915
+ });
916
+ let groupIndex = 0;
917
+ let gridColumnIndex = selectedRows ? 2 : 1;
918
+ const calculateGridTemplateColumn = this.calculateGridTemplateColumn.bind(this);
919
+ const calculatedColumns = [];
920
+ const treeColumns = [];
921
+ if (selectedRows) {
922
+ const column = {
923
+ name: SELECT_ALL.toString(),
924
+ gtcWidth: 'min-content',
925
+ alignItems: 'flex-start',
926
+ children: ''
995
927
  };
996
- var childIsGroup = function childIsGroup(child) {
997
- return 'columns' in child;
928
+ calculatedColumns.push(column);
929
+ }
930
+ const makeColumn = (columnElement, parent, isFirst, isLast, hasGroups) => {
931
+ const leftBordersFromParent = isFirst && (parent?.borders === 'both' || parent?.borders === 'left') ? 'left' : undefined;
932
+ const rightBordersFromParent = isLast && (parent?.borders === 'both' || parent?.borders === 'right') ? 'right' : undefined;
933
+ const column = {
934
+ ...columnElement,
935
+ name: childIsColumn(columnElement) ? columnElement.name : '',
936
+ gtcWidth: childIsColumn(columnElement) ? calculateGridTemplateColumn(columnElement) : '',
937
+ fixed: columnElement.fixed ?? (hasGroups ? parent?.fixed : undefined),
938
+ borders: columnElement.borders ?? leftBordersFromParent ?? rightBordersFromParent,
939
+ parent
998
940
  };
999
- var setShowShadows = function setShowShadows(col, i) {
1000
- var prevCol = treeColumns[i - 1];
1001
- if ('columns' in prevCol && prevCol.columns) {
1002
- prevCol = prevCol.columns[prevCol.columns.length - 1];
1003
- }
1004
- if (prevCol.fixed && !col.fixed) {
1005
- prevCol.showShadowVertical = true;
1006
- } else if (!prevCol.fixed && col.fixed) {
1007
- col.showShadowVertical = true;
941
+ if (column.fixed) {
942
+ this.hasFixedColumn = true;
943
+ }
944
+ return column;
945
+ };
946
+ const childIsColumn = child => {
947
+ return !('columns' in child);
948
+ };
949
+ const childIsGroup = child => {
950
+ return 'columns' in child;
951
+ };
952
+ const setShowShadows = (col, i) => {
953
+ let prevCol = treeColumns[i - 1];
954
+ if ('columns' in prevCol && prevCol.columns) {
955
+ prevCol = prevCol.columns[prevCol.columns.length - 1];
956
+ }
957
+ if (prevCol.fixed && !col.fixed) {
958
+ prevCol.showShadowVertical = true;
959
+ } else if (!prevCol.fixed && col.fixed) {
960
+ col.showShadowVertical = true;
961
+ }
962
+ };
963
+ columns.forEach((child, i) => {
964
+ if (childIsColumn(child)) {
965
+ const col = makeColumn(child);
966
+ col.gridArea = `1 / ${gridColumnIndex} / ${this.hasGroups ? '3' : '2'} / ${gridColumnIndex + 1}`;
967
+ gridColumnIndex++;
968
+ calculatedColumns.push(col);
969
+ treeColumns.push(col);
970
+ if (i > 0) {
971
+ setShowShadows(col, i);
1008
972
  }
1009
- };
1010
- columns.forEach(function (child, i) {
1011
- if (childIsColumn(child)) {
1012
- var col = makeColumn(child);
1013
- col.gridArea = "1 / ".concat(gridColumnIndex, " / ").concat(_this3.hasGroups ? '3' : '2', " / ").concat(gridColumnIndex + 1);
973
+ } else if (childIsGroup(child)) {
974
+ const Group = makeColumn(child);
975
+ const childCount = child.columns.length;
976
+ const initGridColumn = gridColumnIndex;
977
+ const groupedRow = this.hasGroups ? 2 : 1;
978
+ Group.columns = [];
979
+ Group.children = child.children;
980
+ child.columns.forEach((child, j) => {
981
+ const isFirst = j === 0;
982
+ const isLast = j === childCount - 1;
983
+ const col = makeColumn(child, Group, isFirst, isLast, this.hasGroups);
984
+ if (i === 0 && j === 0 && data.some(d => d[ACCORDION])) {
985
+ gridColumnIndex++;
986
+ col.gridArea = `${groupedRow} / ${gridColumnIndex - 1} / ${groupedRow + 1} / ${gridColumnIndex + 1}`;
987
+ } else {
988
+ col.gridArea = `${groupedRow} / ${gridColumnIndex} / ${groupedRow + 1} / ${gridColumnIndex + 1}`;
989
+ }
990
+ col.gridArea = `${groupedRow} / ${gridColumnIndex} / ${groupedRow + 1} / ${gridColumnIndex + 1}`;
1014
991
  gridColumnIndex++;
1015
992
  calculatedColumns.push(col);
1016
- treeColumns.push(col);
1017
- if (i > 0) {
993
+ if (isFirst && i > 0) {
1018
994
  setShowShadows(col, i);
1019
995
  }
1020
- } else if (childIsGroup(child)) {
1021
- var Group = makeColumn(child);
1022
- var childCount = child.columns.length;
1023
- var initGridColumn = gridColumnIndex;
1024
- var groupedRow = _this3.hasGroups ? 2 : 1;
1025
- Group.columns = [];
1026
- Group.children = child.children;
1027
- child.columns.forEach(function (child, j) {
1028
- var _Group$columns;
1029
- var isFirst = j === 0;
1030
- var isLast = j === childCount - 1;
1031
- var col = makeColumn(child, Group, isFirst, isLast, _this3.hasGroups);
1032
- if (i === 0 && j === 0 && data.some(function (d) {
1033
- return d[ACCORDION];
1034
- })) {
1035
- gridColumnIndex++;
1036
- col.gridArea = "".concat(groupedRow, " / ").concat(gridColumnIndex - 1, " / ").concat(groupedRow + 1, " / ").concat(gridColumnIndex + 1);
1037
- } else {
1038
- col.gridArea = "".concat(groupedRow, " / ").concat(gridColumnIndex, " / ").concat(groupedRow + 1, " / ").concat(gridColumnIndex + 1);
1039
- }
1040
- col.gridArea = "".concat(groupedRow, " / ").concat(gridColumnIndex, " / ").concat(groupedRow + 1, " / ").concat(gridColumnIndex + 1);
1041
- gridColumnIndex++;
1042
- calculatedColumns.push(col);
1043
- if (isFirst && i > 0) {
1044
- setShowShadows(col, i);
1045
- }
1046
- (_Group$columns = Group.columns) === null || _Group$columns === void 0 || _Group$columns.push(col);
1047
- });
1048
- treeColumns.push(Group);
1049
- _this3.gridAreaGroupMap.set(groupIndex, "1 / ".concat(initGridColumn, " / 2 / ").concat(gridColumnIndex));
1050
- groupIndex++;
1051
- }
1052
- });
1053
- var gridTemplateColumns = calculatedColumns.map(function (c) {
1054
- return c.gtcWidth;
1055
- });
1056
- var gridTemplateAreas = calculatedColumns.map(function (c) {
1057
- return c.name;
1058
- });
1059
- this.gridSettings = {
1060
- gridTemplateColumns: gridTemplateColumns,
1061
- gridTemplateAreas: gridTemplateAreas
1062
- };
1063
- return [calculatedColumns, treeColumns];
1064
- }
1065
- }, {
1066
- key: "getFlatRows",
1067
- value: function getFlatRows() {
1068
- var data = this.props.data;
1069
- if (this.tmpData === data && this.flatRows) {
1070
- return this.flatRows;
996
+ Group.columns?.push(col);
997
+ });
998
+ treeColumns.push(Group);
999
+ this.gridAreaGroupMap.set(groupIndex, `1 / ${initGridColumn} / 2 / ${gridColumnIndex}`);
1000
+ groupIndex++;
1071
1001
  }
1072
- this.flatRows = this.getRows().flat();
1002
+ });
1003
+ const gridTemplateColumns = calculatedColumns.map(c => c.gtcWidth);
1004
+ const gridTemplateAreas = calculatedColumns.map(c => c.name);
1005
+ this.gridSettings = {
1006
+ gridTemplateColumns,
1007
+ gridTemplateAreas
1008
+ };
1009
+ return [calculatedColumns, treeColumns];
1010
+ }
1011
+ getFlatRows() {
1012
+ const {
1013
+ data
1014
+ } = this.props;
1015
+ if (this.tmpData === data && this.flatRows) {
1073
1016
  return this.flatRows;
1074
1017
  }
1075
- }, {
1076
- key: "getRows",
1077
- value: function getRows() {
1078
- var _this4 = this;
1079
- var columns = this.columns;
1080
- // @ts-ignore
1081
- var _this$props2 = this.props,
1082
- data = _this$props2.data,
1083
- uid = _this$props2.uid,
1084
- uniqueRowKey = _this$props2.uniqueRowKey;
1085
- if (this.tmpData === data) {
1086
- return this.calculatedRows;
1087
- }
1088
- this.tmpData = data;
1089
- var rows = [];
1090
- var columnNames = columns.map(function (column) {
1091
- return column.name;
1092
- });
1093
- var rowIndex = 0;
1094
- var gridRowIndex = 0;
1095
- var id = 100000000; // need this for gen keys by toString(36)
1018
+ this.flatRows = this.getRows().flat();
1019
+ return this.flatRows;
1020
+ }
1021
+ getRows() {
1022
+ const columns = this.columns;
1023
+ // @ts-ignore
1024
+ const {
1025
+ data,
1026
+ uid,
1027
+ uniqueRowKey
1028
+ } = this.props;
1029
+ if (this.tmpData === data) {
1030
+ return this.calculatedRows;
1031
+ }
1032
+ this.tmpData = data;
1033
+ const rows = [];
1034
+ const columnNames = columns.map(column => column.name);
1035
+ let rowIndex = 0;
1036
+ let gridRowIndex = 0;
1037
+ const id = 100000000; // need this for gen keys by toString(36)
1096
1038
 
1097
- var _makeDtRow = function makeDtRow(row, excludeColumns) {
1098
- var columns = new Set(columnNames);
1099
- var accordionInCell = null;
1100
- var rowKey = row[UNIQ_ROW_KEY];
1101
- if (!rowKey) {
1102
- if (uniqueRowKey) {
1103
- // @ts-ignore
1104
- var keyValue = row[uniqueRowKey];
1105
- if (keyValue instanceof _MergedCells.MergedRowsCell) {
1106
- rowKey = keyValue.value;
1107
- } else {
1108
- rowKey = keyValue;
1109
- }
1039
+ const makeDtRow = (row, excludeColumns) => {
1040
+ const columns = new Set(columnNames);
1041
+ let accordionInCell = null;
1042
+ let rowKey = row[UNIQ_ROW_KEY];
1043
+ if (!rowKey) {
1044
+ if (uniqueRowKey) {
1045
+ // @ts-ignore
1046
+ const keyValue = row[uniqueRowKey];
1047
+ if (keyValue instanceof _MergedCells.MergedRowsCell) {
1048
+ rowKey = keyValue.value;
1110
1049
  } else {
1111
- rowKey = "".concat(uid, "_").concat((rowIndex + id).toString(36));
1050
+ rowKey = keyValue;
1112
1051
  }
1052
+ } else {
1053
+ rowKey = `${uid}_${(rowIndex + id).toString(36)}`;
1054
+ }
1055
+ }
1056
+ const initData = {
1057
+ /*
1058
+ row -> DataRowItem
1059
+ uniqueRowKey is a `keyof Data[number]` -> `keyof DataRowItem`
1060
+ */
1061
+ // @ts-ignore
1062
+ [UNIQ_ROW_KEY]: rowKey,
1063
+ [ROW_INDEX]: rowIndex,
1064
+ [GRID_ROW_INDEX]: gridRowIndex
1065
+ };
1066
+ const dtRow = Object.entries(row).reduce((acc, [key, value]) => {
1067
+ const columnsToRow = key.split(this.columnsSplitter);
1068
+ if (columnsToRow.length === 1) {
1069
+ acc[key] = value ?? '';
1070
+ columns.delete(key);
1071
+ } else {
1072
+ acc[columnsToRow[0]] = new _MergedCells.MergedColumnsCell(value, {
1073
+ dataKey: key,
1074
+ size: columnsToRow.length
1075
+ });
1076
+ columnsToRow.forEach(value => {
1077
+ columns.delete(value);
1078
+ });
1079
+ }
1080
+ if (value?.[ACCORDION]) {
1081
+ accordionInCell = value[ACCORDION];
1082
+ }
1083
+ return acc;
1084
+ }, initData);
1085
+ gridRowIndex++;
1086
+ if (row[ACCORDION]) {
1087
+ if (Array.isArray(row[ACCORDION])) {
1088
+ dtRow[ACCORDION] = row[ACCORDION].map(item => makeDtRow(item));
1089
+ } else if (/*#__PURE__*/React.isValidElement(row[ACCORDION])) {
1090
+ dtRow[ACCORDION] = row[ACCORDION];
1091
+ gridRowIndex++;
1113
1092
  }
1114
- var initData = (0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, UNIQ_ROW_KEY, rowKey), ROW_INDEX, rowIndex), GRID_ROW_INDEX, gridRowIndex);
1115
- var dtRow = Object.entries(row).reduce(function (acc, _ref4) {
1116
- var _ref5 = (0, _slicedToArray2["default"])(_ref4, 2),
1117
- key = _ref5[0],
1118
- value = _ref5[1];
1119
- var columnsToRow = key.split(_this4.columnsSplitter);
1093
+ } else if (accordionInCell) {
1094
+ gridRowIndex++;
1095
+ }
1096
+ excludeColumns?.forEach(value => {
1097
+ columns.delete(value);
1098
+ });
1099
+ if (columns.size > 0) {
1100
+ columns.forEach(value => {
1101
+ dtRow[value] = '';
1102
+ });
1103
+ }
1104
+ return dtRow;
1105
+ };
1106
+ data.forEach(row => {
1107
+ const groupedRows = row[ROW_GROUP];
1108
+ if (groupedRows && groupedRows.length > 1) {
1109
+ const innerRows = [];
1110
+ const groupedKeys = [];
1111
+ const groupedRowData = Object.entries(row).reduce((acc, [key, value]) => {
1112
+ const accordion = Array.isArray(row[ACCORDION]) ? row[ACCORDION].map(item => makeDtRow(item)) : row[ACCORDION];
1113
+ acc[key] = new _MergedCells.MergedRowsCell(value, groupedRows.length, accordion);
1114
+ const columnsToRow = key.split(this.columnsSplitter);
1120
1115
  if (columnsToRow.length === 1) {
1121
- acc[key] = value !== null && value !== void 0 ? value : '';
1122
- columns["delete"](key);
1116
+ groupedKeys.push(key);
1123
1117
  } else {
1124
- acc[columnsToRow[0]] = new _MergedCells.MergedColumnsCell(value, {
1125
- dataKey: key,
1126
- size: columnsToRow.length
1127
- });
1128
- columnsToRow.forEach(function (value) {
1129
- columns["delete"](value);
1130
- });
1131
- }
1132
- if (value !== null && value !== void 0 && value[ACCORDION]) {
1133
- accordionInCell = value[ACCORDION];
1118
+ groupedKeys.push(...columnsToRow);
1134
1119
  }
1135
1120
  return acc;
1136
- }, initData);
1137
- gridRowIndex++;
1138
- if (row[ACCORDION]) {
1139
- if (Array.isArray(row[ACCORDION])) {
1140
- dtRow[ACCORDION] = row[ACCORDION].map(function (item) {
1141
- return _makeDtRow(item);
1142
- });
1143
- } else if (/*#__PURE__*/React.isValidElement(row[ACCORDION])) {
1144
- dtRow[ACCORDION] = row[ACCORDION];
1145
- gridRowIndex++;
1146
- }
1147
- } else if (accordionInCell) {
1148
- gridRowIndex++;
1149
- }
1150
- excludeColumns === null || excludeColumns === void 0 || excludeColumns.forEach(function (value) {
1151
- columns["delete"](value);
1121
+ }, {
1122
+ [UNIQ_ROW_KEY]: '',
1123
+ // will fill in makeDtRow
1124
+ [ROW_INDEX]: -1
1152
1125
  });
1153
- if (columns.size > 0) {
1154
- columns.forEach(function (value) {
1155
- dtRow[value] = '';
1156
- });
1157
- }
1158
- return dtRow;
1159
- };
1160
- data.forEach(function (row) {
1161
- var groupedRows = row[ROW_GROUP];
1162
- if (groupedRows && groupedRows.length > 1) {
1163
- var innerRows = [];
1164
- var groupedKeys = [];
1165
- var groupedRowData = Object.entries(row).reduce(function (acc, _ref6) {
1166
- var _ref7 = (0, _slicedToArray2["default"])(_ref6, 2),
1167
- key = _ref7[0],
1168
- value = _ref7[1];
1169
- var accordion = Array.isArray(row[ACCORDION]) ? row[ACCORDION].map(function (item) {
1170
- return _makeDtRow(item);
1171
- }) : row[ACCORDION];
1172
- acc[key] = new _MergedCells.MergedRowsCell(value, groupedRows.length, accordion);
1173
- var columnsToRow = key.split(_this4.columnsSplitter);
1174
- if (columnsToRow.length === 1) {
1175
- groupedKeys.push(key);
1176
- } else {
1177
- groupedKeys.push.apply(groupedKeys, (0, _toConsumableArray2["default"])(columnsToRow));
1178
- }
1179
- return acc;
1180
- }, (0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, UNIQ_ROW_KEY, ''), ROW_INDEX, -1));
1181
- groupedRows.forEach(function (childRow, index) {
1182
- var dtRow;
1183
- if (index === 0) {
1184
- var rowData = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, childRow), groupedRowData);
1185
- dtRow = _makeDtRow(rowData);
1186
- dtRow[ROW_GROUP] = new Set();
1187
- } else {
1188
- var _innerRows$;
1189
- dtRow = _makeDtRow(childRow, groupedKeys);
1190
- (_innerRows$ = innerRows[0]) === null || _innerRows$ === void 0 || (_innerRows$ = _innerRows$[ROW_GROUP]) === null || _innerRows$ === void 0 || _innerRows$.add(dtRow[UNIQ_ROW_KEY]);
1191
- }
1192
- innerRows.push(dtRow);
1193
- if (index === groupedRows.length - 1 && row[ACCORDION]) {
1194
- gridRowIndex = Array.isArray(row[ACCORDION]) ? gridRowIndex + row[ACCORDION].length : gridRowIndex + 1;
1195
- }
1196
- rowIndex++;
1197
- });
1198
- rows.push(innerRows);
1199
- } else if ((groupedRows === null || groupedRows === void 0 ? void 0 : groupedRows.length) === 1) {
1200
- var dtRow = _makeDtRow((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, groupedRows[0]), row));
1201
- rows.push(dtRow);
1202
- rowIndex++;
1203
- } else {
1204
- var _dtRow = _makeDtRow(row);
1205
- rows.push(_dtRow);
1126
+ groupedRows.forEach((childRow, index) => {
1127
+ let dtRow;
1128
+ if (index === 0) {
1129
+ const rowData = {
1130
+ ...childRow,
1131
+ ...groupedRowData
1132
+ };
1133
+ dtRow = makeDtRow(rowData);
1134
+ dtRow[ROW_GROUP] = new Set();
1135
+ } else {
1136
+ dtRow = makeDtRow(childRow, groupedKeys);
1137
+ innerRows[0]?.[ROW_GROUP]?.add(dtRow[UNIQ_ROW_KEY]);
1138
+ }
1139
+ innerRows.push(dtRow);
1140
+ if (index === groupedRows.length - 1 && row[ACCORDION]) {
1141
+ gridRowIndex = Array.isArray(row[ACCORDION]) ? gridRowIndex + row[ACCORDION].length : gridRowIndex + 1;
1142
+ }
1206
1143
  rowIndex++;
1207
- }
1208
- });
1209
- this.calculatedRows = rows;
1210
- return rows;
1211
- }
1212
- }, {
1213
- key: "calculateGridTemplateColumn",
1214
- value: function calculateGridTemplateColumn(c) {
1215
- var _ref8;
1216
- return (_ref8 = /*#__PURE__*/React.isValidElement(c) ? c.props.gtcWidth : c.gtcWidth) !== null && _ref8 !== void 0 ? _ref8 : this.props.defaultGridTemplateColumnWidth;
1217
- }
1218
- }, {
1219
- key: "getHeaderHeight",
1220
- value: function getHeaderHeight() {
1221
- var _this$headerRef$curre4;
1222
- var header = (_this$headerRef$curre4 = this.headerRef.current) === null || _this$headerRef$curre4 === void 0 ? void 0 : _this$headerRef$curre4.children;
1223
- var height = 0;
1224
- for (var i = 0; i < ((_header$length = header === null || header === void 0 ? void 0 : header.length) !== null && _header$length !== void 0 ? _header$length : 0); i++) {
1225
- var _header$length;
1226
- var item = header === null || header === void 0 ? void 0 : header.item(i);
1227
- var columnHeight = item === null || item === void 0 ? void 0 : item.getBoundingClientRect().height;
1228
- if (item instanceof HTMLElement && item.dataset.groupContainer) {
1229
- var _item$children$item$g, _item$children$item, _item$children$item$g2, _item$children$item2;
1230
- var groupHeight = (_item$children$item$g = (_item$children$item = item.children.item(0)) === null || _item$children$item === void 0 ? void 0 : _item$children$item.getBoundingClientRect().height) !== null && _item$children$item$g !== void 0 ? _item$children$item$g : 0;
1231
- var cellHeight = (_item$children$item$g2 = (_item$children$item2 = item.children.item(1)) === null || _item$children$item2 === void 0 ? void 0 : _item$children$item2.getBoundingClientRect().height) !== null && _item$children$item$g2 !== void 0 ? _item$children$item$g2 : 0;
1232
- columnHeight = groupHeight + cellHeight;
1233
- }
1234
- if (columnHeight) {
1235
- height = columnHeight;
1236
- break;
1237
- }
1144
+ });
1145
+ rows.push(innerRows);
1146
+ } else if (groupedRows?.length === 1) {
1147
+ const dtRow = makeDtRow({
1148
+ ...groupedRows[0],
1149
+ ...row
1150
+ });
1151
+ rows.push(dtRow);
1152
+ rowIndex++;
1153
+ } else {
1154
+ const dtRow = makeDtRow(row);
1155
+ rows.push(dtRow);
1156
+ rowIndex++;
1238
1157
  }
1239
- return height;
1240
- }
1241
- }], [{
1242
- key: "getDerivedStateFromProps",
1243
- value: function getDerivedStateFromProps(props, state) {
1244
- if (props.expandedRows === state.expandedRows || props.expandedRows === undefined) {
1245
- return null;
1158
+ });
1159
+ this.calculatedRows = rows;
1160
+ return rows;
1161
+ }
1162
+ calculateGridTemplateColumn(c) {
1163
+ return (/*#__PURE__*/React.isValidElement(c) ? c.props.gtcWidth : c.gtcWidth) ?? this.props.defaultGridTemplateColumnWidth;
1164
+ }
1165
+ getHeaderHeight() {
1166
+ const header = this.headerRef.current?.children;
1167
+ let height = 0;
1168
+ for (let i = 0; i < (header?.length ?? 0); i++) {
1169
+ const item = header?.item(i);
1170
+ let columnHeight = item?.getBoundingClientRect().height;
1171
+ if (item instanceof HTMLElement && item.dataset.groupContainer) {
1172
+ const groupHeight = item.children.item(0)?.getBoundingClientRect().height ?? 0;
1173
+ const cellHeight = item.children.item(1)?.getBoundingClientRect().height ?? 0;
1174
+ columnHeight = groupHeight + cellHeight;
1175
+ }
1176
+ if (columnHeight) {
1177
+ height = columnHeight;
1178
+ break;
1246
1179
  }
1247
- return {
1248
- expandedRows: props.expandedRows
1249
- };
1250
1180
  }
1251
- }]);
1252
- }(_core.Component);
1253
- (0, _defineProperty2["default"])(DataTableRoot, "displayName", 'DataTable');
1254
- (0, _defineProperty2["default"])(DataTableRoot, "style", style);
1255
- (0, _defineProperty2["default"])(DataTableRoot, "enhance", [(0, _uniqueID["default"])(), (0, _i18nEnhance["default"])(_intergalacticDynamicLocales.localizedMessages)]);
1256
- (0, _defineProperty2["default"])(DataTableRoot, "defaultProps", {
1181
+ return height;
1182
+ }
1183
+ }
1184
+ (0, _defineProperty2.default)(DataTableRoot, "displayName", 'DataTable');
1185
+ (0, _defineProperty2.default)(DataTableRoot, "style", style);
1186
+ (0, _defineProperty2.default)(DataTableRoot, "enhance", [(0, _uniqueID.default)(), (0, _i18nEnhance.default)(_intergalacticDynamicLocales.localizedMessages)]);
1187
+ (0, _defineProperty2.default)(DataTableRoot, "defaultProps", {
1257
1188
  use: 'primary',
1258
1189
  defaultGridTemplateColumnWidth: 'auto',
1259
1190
  defaultSelectedRows: undefined,
1260
1191
  h: 'fit-content',
1261
- renderEmptyData: function renderEmptyData() {
1262
- return /*#__PURE__*/React.createElement(_widgetEmpty.NoData, {
1263
- py: 10,
1264
- type: "nothing-found",
1265
- description: "",
1266
- w: "100%"
1267
- });
1268
- },
1192
+ renderEmptyData: () => /*#__PURE__*/React.createElement(_widgetEmpty.NoData, {
1193
+ py: 10,
1194
+ type: "nothing-found",
1195
+ description: "",
1196
+ w: "100%"
1197
+ }),
1269
1198
  variant: 'default',
1270
1199
  accordionAnimationRows: 40,
1271
1200
  accordionDuration: 200
1272
1201
  });
1273
- var DataTable = exports.DataTable = (0, _core.createComponent)(DataTableRoot, {
1202
+ const DataTable = exports.DataTable = (0, _core.createComponent)(DataTableRoot, {
1274
1203
  Head: _Head.Head,
1275
1204
  Body: _Body.Body
1276
1205
  });