@semcore/data-table 16.5.3 → 17.0.0-prerelease.18

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