@semcore/data-table 16.0.0-prerelease.2 → 16.0.0-prerelease.21

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 (152) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/lib/cjs/components/Body/Body.js +439 -0
  3. package/lib/cjs/components/Body/Body.js.map +1 -0
  4. package/lib/cjs/components/Body/Body.types.js +2 -0
  5. package/lib/cjs/components/Body/Body.types.js.map +1 -0
  6. package/lib/cjs/components/Body/Cell.js +195 -0
  7. package/lib/cjs/components/Body/Cell.js.map +1 -0
  8. package/lib/cjs/components/Body/Cell.types.js +2 -0
  9. package/lib/cjs/components/Body/Cell.types.js.map +1 -0
  10. package/lib/cjs/components/Body/MergedCells.js +29 -0
  11. package/lib/cjs/components/Body/MergedCells.js.map +1 -0
  12. package/lib/cjs/components/Body/Row.js +252 -0
  13. package/lib/cjs/components/Body/Row.js.map +1 -0
  14. package/lib/cjs/components/Body/Row.types.js +4 -0
  15. package/lib/cjs/components/Body/Row.types.js.map +1 -0
  16. package/lib/cjs/components/Body/style.shadow.css +263 -0
  17. package/lib/cjs/components/DataTable/DataTable.js +1025 -0
  18. package/lib/cjs/components/DataTable/DataTable.js.map +1 -0
  19. package/lib/cjs/{types.js → components/DataTable/DataTable.types.js} +1 -1
  20. package/lib/cjs/components/DataTable/DataTable.types.js.map +1 -0
  21. package/lib/cjs/components/DataTable/dataTable.shadow.css +17 -0
  22. package/lib/cjs/components/Head/Column.js +311 -0
  23. package/lib/cjs/components/Head/Column.js.map +1 -0
  24. package/lib/cjs/components/Head/Column.types.js +2 -0
  25. package/lib/cjs/components/Head/Column.types.js.map +1 -0
  26. package/lib/cjs/components/Head/Group.js +116 -0
  27. package/lib/cjs/components/Head/Group.js.map +1 -0
  28. package/lib/cjs/components/Head/Group.type.js +2 -0
  29. package/lib/cjs/components/Head/Group.type.js.map +1 -0
  30. package/lib/cjs/components/Head/Head.js +207 -0
  31. package/lib/cjs/components/Head/Head.js.map +1 -0
  32. package/lib/cjs/components/Head/Head.types.js +2 -0
  33. package/lib/cjs/components/Head/Head.types.js.map +1 -0
  34. package/lib/cjs/components/Head/style.shadow.css +180 -0
  35. package/lib/cjs/index.js +25 -15
  36. package/lib/cjs/index.js.map +1 -1
  37. package/lib/cjs/style/scroll-shadows.shadow.css +45 -5
  38. package/lib/cjs/translations/en.json +6 -1
  39. package/lib/es6/components/Body/Body.js +432 -0
  40. package/lib/es6/components/Body/Body.js.map +1 -0
  41. package/lib/es6/components/Body/Body.types.js +2 -0
  42. package/lib/es6/components/Body/Body.types.js.map +1 -0
  43. package/lib/es6/components/Body/Cell.js +188 -0
  44. package/lib/es6/components/Body/Cell.js.map +1 -0
  45. package/lib/es6/components/Body/Cell.types.js +2 -0
  46. package/lib/es6/components/Body/Cell.types.js.map +1 -0
  47. package/lib/es6/components/Body/MergedCells.js +20 -0
  48. package/lib/es6/components/Body/MergedCells.js.map +1 -0
  49. package/lib/es6/components/Body/Row.js +245 -0
  50. package/lib/es6/components/Body/Row.js.map +1 -0
  51. package/lib/es6/components/Body/Row.types.js +2 -0
  52. package/lib/es6/components/Body/Row.types.js.map +1 -0
  53. package/lib/es6/components/Body/style.shadow.css +263 -0
  54. package/lib/es6/components/DataTable/DataTable.js +1013 -0
  55. package/lib/es6/components/DataTable/DataTable.js.map +1 -0
  56. package/lib/es6/components/DataTable/DataTable.types.js +2 -0
  57. package/lib/es6/components/DataTable/DataTable.types.js.map +1 -0
  58. package/lib/es6/components/DataTable/dataTable.shadow.css +17 -0
  59. package/lib/es6/components/Head/Column.js +304 -0
  60. package/lib/es6/components/Head/Column.js.map +1 -0
  61. package/lib/es6/components/Head/Column.types.js +2 -0
  62. package/lib/es6/components/Head/Column.types.js.map +1 -0
  63. package/lib/es6/components/Head/Group.js +109 -0
  64. package/lib/es6/components/Head/Group.js.map +1 -0
  65. package/lib/es6/components/Head/Group.type.js +2 -0
  66. package/lib/es6/components/Head/Group.type.js.map +1 -0
  67. package/lib/es6/components/Head/Head.js +201 -0
  68. package/lib/es6/components/Head/Head.js.map +1 -0
  69. package/lib/es6/components/Head/Head.types.js +2 -0
  70. package/lib/es6/components/Head/Head.types.js.map +1 -0
  71. package/lib/es6/components/Head/style.shadow.css +180 -0
  72. package/lib/es6/index.js +5 -2
  73. package/lib/es6/index.js.map +1 -1
  74. package/lib/es6/style/scroll-shadows.shadow.css +45 -5
  75. package/lib/es6/translations/en.json +6 -1
  76. package/lib/esm/components/Body/Body.mjs +394 -0
  77. package/lib/esm/components/Body/Cell.mjs +186 -0
  78. package/lib/esm/components/Body/MergedCells.mjs +23 -0
  79. package/lib/esm/components/Body/Row.mjs +224 -0
  80. package/lib/esm/components/Body/style.shadow.css +263 -0
  81. package/lib/esm/components/DataTable/DataTable.mjs +944 -0
  82. package/lib/esm/components/DataTable/dataTable.shadow.css +17 -0
  83. package/lib/esm/components/Head/Column.mjs +296 -0
  84. package/lib/esm/components/Head/Group.mjs +103 -0
  85. package/lib/esm/components/Head/Head.mjs +181 -0
  86. package/lib/esm/components/Head/style.shadow.css +180 -0
  87. package/lib/esm/index.mjs +9 -6
  88. package/lib/esm/style/scroll-shadows.shadow.css +47 -0
  89. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
  90. package/lib/esm/translations/de.json.mjs +5 -4
  91. package/lib/esm/translations/en.json.mjs +10 -4
  92. package/lib/esm/translations/es.json.mjs +5 -4
  93. package/lib/esm/translations/fr.json.mjs +5 -4
  94. package/lib/esm/translations/it.json.mjs +5 -4
  95. package/lib/esm/translations/ja.json.mjs +5 -4
  96. package/lib/esm/translations/ko.json.mjs +5 -4
  97. package/lib/esm/translations/nl.json.mjs +5 -4
  98. package/lib/esm/translations/pl.json.mjs +5 -4
  99. package/lib/esm/translations/pt.json.mjs +5 -4
  100. package/lib/esm/translations/sv.json.mjs +5 -4
  101. package/lib/esm/translations/tr.json.mjs +5 -4
  102. package/lib/esm/translations/vi.json.mjs +5 -4
  103. package/lib/esm/translations/zh.json.mjs +5 -4
  104. package/lib/types/components/Body/Body.d.ts +8 -0
  105. package/lib/types/components/Body/Body.types.d.ts +57 -0
  106. package/lib/types/components/Body/Cell.d.ts +3 -0
  107. package/lib/types/components/Body/Cell.types.d.ts +20 -0
  108. package/lib/types/components/Body/MergedCells.d.ts +14 -0
  109. package/lib/types/components/Body/Row.d.ts +3 -0
  110. package/lib/types/components/Body/Row.types.d.ts +43 -0
  111. package/lib/types/components/DataTable/DataTable.d.ts +13 -0
  112. package/lib/types/components/DataTable/DataTable.types.d.ts +125 -0
  113. package/lib/types/components/Head/Column.d.ts +30 -0
  114. package/lib/types/components/Head/Column.types.d.ts +71 -0
  115. package/lib/types/components/Head/Group.d.ts +15 -0
  116. package/lib/types/components/Head/Group.type.d.ts +16 -0
  117. package/lib/types/components/Head/Head.d.ts +98 -0
  118. package/lib/types/components/Head/Head.types.d.ts +40 -0
  119. package/lib/types/index.d.ts +10 -2
  120. package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +5 -0
  121. package/package.json +11 -6
  122. package/vite.config.ts +0 -3
  123. package/lib/cjs/Body.js +0 -475
  124. package/lib/cjs/Body.js.map +0 -1
  125. package/lib/cjs/DataTable.js +0 -622
  126. package/lib/cjs/DataTable.js.map +0 -1
  127. package/lib/cjs/Head.js +0 -399
  128. package/lib/cjs/Head.js.map +0 -1
  129. package/lib/cjs/style/data-table.shadow.css +0 -394
  130. package/lib/cjs/types.js.map +0 -1
  131. package/lib/cjs/utils.js +0 -57
  132. package/lib/cjs/utils.js.map +0 -1
  133. package/lib/es6/Body.js +0 -468
  134. package/lib/es6/Body.js.map +0 -1
  135. package/lib/es6/DataTable.js +0 -614
  136. package/lib/es6/DataTable.js.map +0 -1
  137. package/lib/es6/Head.js +0 -391
  138. package/lib/es6/Head.js.map +0 -1
  139. package/lib/es6/style/data-table.shadow.css +0 -394
  140. package/lib/es6/types.js +0 -2
  141. package/lib/es6/types.js.map +0 -1
  142. package/lib/es6/utils.js +0 -48
  143. package/lib/es6/utils.js.map +0 -1
  144. package/lib/esm/Body.mjs +0 -320
  145. package/lib/esm/DataTable.mjs +0 -439
  146. package/lib/esm/Head.mjs +0 -258
  147. package/lib/esm/utils.mjs +0 -37
  148. package/lib/types/Body.d.ts +0 -61
  149. package/lib/types/DataTable.d.ts +0 -205
  150. package/lib/types/Head.d.ts +0 -45
  151. package/lib/types/types.d.ts +0 -73
  152. package/lib/types/utils.d.ts +0 -4
@@ -0,0 +1,1013 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
3
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
+ import _createClass from "@babel/runtime/helpers/createClass";
6
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
7
+ import _inherits from "@babel/runtime/helpers/inherits";
8
+ import _createSuper from "@babel/runtime/helpers/createSuper";
9
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
+ import { sstyled as _sstyled2 } from "@semcore/core";
11
+ import { sstyled as _sstyled } from "@semcore/core";
12
+ import { assignProps as _assignProps } from "@semcore/core";
13
+ import * as React from 'react';
14
+ import { Component, createComponent, lastInteraction, Root, sstyled } from '@semcore/core';
15
+ import { Box, ScreenReaderOnly, ScrollArea } from '@semcore/base-components';
16
+ import { Head } from '../Head/Head';
17
+ import { Body } from '../Body/Body';
18
+ /*!__reshadow-styles__:"./dataTable.shadow.css"*/
19
+ var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SDataTable_1iypx_gg_{display:grid;align-items:start;min-width:-moz-fit-content;min-width:fit-content}.___SDataTable_1iypx_gg_.__gridTemplateColumns_1iypx_gg_{grid-template-columns:var(--gridTemplateColumns_1iypx)}.___SDataTable_1iypx_gg_.__gridTemplateAreas_1iypx_gg_{grid-template-areas:var(--gridTemplateAreas_1iypx)}.___SDataTable_1iypx_gg_.__gridTemplateRows_1iypx_gg_{grid-template-rows:var(--gridTemplateRows_1iypx)}", /*__inner_css_end__*/"1iypx_gg_"),
20
+ /*__reshadow_css_end__*/
21
+ {
22
+ "__SDataTable": "___SDataTable_1iypx_gg_",
23
+ "_gridTemplateColumns": "__gridTemplateColumns_1iypx_gg_",
24
+ "--gridTemplateColumns": "--gridTemplateColumns_1iypx",
25
+ "_gridTemplateAreas": "__gridTemplateAreas_1iypx_gg_",
26
+ "--gridTemplateAreas": "--gridTemplateAreas_1iypx",
27
+ "_gridTemplateRows": "__gridTemplateRows_1iypx_gg_",
28
+ "--gridTemplateRows": "--gridTemplateRows_1iypx"
29
+ });
30
+ import { isFocusInside, hasFocusableIn } from '@semcore/core/lib/utils/use/useFocusLock';
31
+ import findComponent from '@semcore/core/lib/utils/findComponent';
32
+ import { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';
33
+ import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
34
+ import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
35
+ import { forkRef } from '@semcore/core/lib/utils/ref';
36
+ /*!__reshadow-styles__:"../../style/scroll-shadows.shadow.css"*/
37
+ var scrollStyles = ( /*__reshadow_css_start__*/_sstyled2.insert( /*__inner_css_start__*/".___SScrollArea_fowiu_gg_{width:-moz-fit-content;width:fit-content}.___SScrollArea_fowiu_gg_ .___SContainer_fowiu_gg_{overflow:visible;overflow:initial}.___SScrollArea_fowiu_gg_ .___SContainer_fowiu_gg_._scrollDirection_both_fowiu_gg_{overflow:auto}.___SScrollArea_fowiu_gg_ .___SContainer_fowiu_gg_._scrollDirection_horizontal_fowiu_gg_{overflow-x:auto;overflow-y:initial}.___SScrollArea_fowiu_gg_ .___SContainer_fowiu_gg_._scrollDirection_vertical_fowiu_gg_{overflow-x:initial;overflow-y:auto}.___SScrollArea_fowiu_gg_ .___SContainer_fowiu_gg_.__loading_fowiu_gg_{overflow:hidden}.___SScrollArea_fowiu_gg_ .___SContainer_fowiu_gg_.__headerHeight_fowiu_gg_{scroll-padding-top:var(--headerHeight_fowiu)}.___SScrollArea_fowiu_gg_ .___SContainer_fowiu_gg_.__leftScrollPadding_fowiu_gg_{scroll-padding-left:var(--leftScrollPadding_fowiu)}.___SScrollArea_fowiu_gg_ .___SContainer_fowiu_gg_.__rightScrollPadding_fowiu_gg_{scroll-padding-right:var(--rightScrollPadding_fowiu)}.___SScrollArea_fowiu_gg_ .___SShadowVertical_fowiu_gg_:before{display:none}.___SScrollArea_fowiu_gg_ .___SShadowHorizontal_fowiu_gg_:after,.___SScrollArea_fowiu_gg_ .___SShadowHorizontal_fowiu_gg_:before,.___SScrollArea_fowiu_gg_ .___SShadowVertical_fowiu_gg_:after{z-index:2}", /*__inner_css_end__*/"fowiu_gg_"),
38
+ /*__reshadow_css_end__*/
39
+ {
40
+ "__SScrollArea": "___SScrollArea_fowiu_gg_",
41
+ "__SContainer": "___SContainer_fowiu_gg_",
42
+ "_scrollDirection_both": "_scrollDirection_both_fowiu_gg_",
43
+ "_scrollDirection_horizontal": "_scrollDirection_horizontal_fowiu_gg_",
44
+ "_scrollDirection_vertical": "_scrollDirection_vertical_fowiu_gg_",
45
+ "_loading": "__loading_fowiu_gg_",
46
+ "_headerHeight": "__headerHeight_fowiu_gg_",
47
+ "--headerHeight": "--headerHeight_fowiu",
48
+ "_leftScrollPadding": "__leftScrollPadding_fowiu_gg_",
49
+ "--leftScrollPadding": "--leftScrollPadding_fowiu",
50
+ "_rightScrollPadding": "__rightScrollPadding_fowiu_gg_",
51
+ "--rightScrollPadding": "--rightScrollPadding_fowiu",
52
+ "__SShadowVertical": "___SShadowVertical_fowiu_gg_",
53
+ "__SShadowHorizontal": "___SShadowHorizontal_fowiu_gg_"
54
+ });
55
+ import { hasParent } from '@semcore/core/lib/utils/hasParent';
56
+ import trottle from '@semcore/core/lib/utils/rafTrottle';
57
+ import { MergedColumnsCell, MergedRowsCell } from '../Body/MergedCells';
58
+ import { NoData } from '@semcore/widget-empty';
59
+ export var ACCORDION = Symbol('accordion');
60
+ export var ROW_GROUP = Symbol('ROW_GROUP');
61
+ export var UNIQ_ROW_KEY = Symbol('UNIQ_ROW_KEY');
62
+ export var SELECT_ALL = Symbol('SELECT_ALL');
63
+ export var ROW_INDEX = Symbol('ROW_INDEX');
64
+ var SCROLL_BAR_HEIGHT = 12;
65
+ var DataTableRoot = /*#__PURE__*/function (_Component) {
66
+ _inherits(DataTableRoot, _Component);
67
+ var _super = _createSuper(DataTableRoot);
68
+ function DataTableRoot(props) {
69
+ var _this;
70
+ _classCallCheck(this, DataTableRoot);
71
+ _this = _super.call(this, props);
72
+ _defineProperty(_assertThisInitialized(_this), "columns", []);
73
+ _defineProperty(_assertThisInitialized(_this), "treeColumns", []);
74
+ _defineProperty(_assertThisInitialized(_this), "hasGroups", false);
75
+ _defineProperty(_assertThisInitialized(_this), "focusedCell", [-1, -1]);
76
+ _defineProperty(_assertThisInitialized(_this), "scrollAreaRef", /*#__PURE__*/React.createRef());
77
+ _defineProperty(_assertThisInitialized(_this), "tableContainerRef", /*#__PURE__*/React.createRef());
78
+ _defineProperty(_assertThisInitialized(_this), "tableRef", /*#__PURE__*/React.createRef());
79
+ _defineProperty(_assertThisInitialized(_this), "headerRef", /*#__PURE__*/React.createRef());
80
+ _defineProperty(_assertThisInitialized(_this), "spinnerRef", /*#__PURE__*/React.createRef());
81
+ _defineProperty(_assertThisInitialized(_this), "gridAreaGroupMap", new Map());
82
+ _defineProperty(_assertThisInitialized(_this), "columnsSplitter", '/');
83
+ _defineProperty(_assertThisInitialized(_this), "rows", []);
84
+ _defineProperty(_assertThisInitialized(_this), "flatRows", []);
85
+ _defineProperty(_assertThisInitialized(_this), "selectAllMessageTimer", 0);
86
+ _defineProperty(_assertThisInitialized(_this), "headerNodesMap", new Map());
87
+ _defineProperty(_assertThisInitialized(_this), "state", {
88
+ scrollTop: 0,
89
+ scrollDirection: 'down',
90
+ selectAllMessage: ''
91
+ });
92
+ _defineProperty(_assertThisInitialized(_this), "handleSelectRow", function (isSelected, selectedRowIndex, row, event) {
93
+ var _this$asProps = _this.asProps,
94
+ selectedRows = _this$asProps.selectedRows,
95
+ onSelectedRowsChange = _this$asProps.onSelectedRowsChange,
96
+ data = _this$asProps.data;
97
+ if (selectedRows && onSelectedRowsChange) {
98
+ var newSelectedRows = new Set(selectedRows);
99
+ if (isSelected && !newSelectedRows.has(selectedRowIndex)) {
100
+ newSelectedRows.add(selectedRowIndex);
101
+ } else if (!isSelected && newSelectedRows.has(selectedRowIndex)) {
102
+ newSelectedRows["delete"](selectedRowIndex);
103
+ }
104
+ onSelectedRowsChange(_toConsumableArray(newSelectedRows), event, {
105
+ selectedRowIndex: selectedRowIndex,
106
+ isSelected: isSelected,
107
+ row: row
108
+ });
109
+ }
110
+ });
111
+ _defineProperty(_assertThisInitialized(_this), "setSelectAllMessage", function (selectedAll) {
112
+ if (_this.selectAllMessageTimer) {
113
+ clearTimeout(_this.selectAllMessageTimer);
114
+ }
115
+ var getI18nText = _this.asProps.getI18nText;
116
+ var message = getI18nText(selectedAll ? 'DataTable.allItemsSelected:aria-live' : 'DataTable.allItemsDeselected:aria-live');
117
+ _this.setState({
118
+ selectAllMessage: message
119
+ });
120
+ _this.selectAllMessageTimer = window.setTimeout(function () {
121
+ _this.setState({
122
+ selectAllMessage: ''
123
+ });
124
+ }, 5000);
125
+ });
126
+ _defineProperty(_assertThisInitialized(_this), "getRow", function (index) {
127
+ var _this$tableRef$curren;
128
+ return (_this$tableRef$curren = _this.tableRef.current) === null || _this$tableRef$curren === void 0 ? void 0 : _this$tableRef$curren.querySelector("[aria-rowindex=\"".concat(index + 1, "\"]"));
129
+ });
130
+ _defineProperty(_assertThisInitialized(_this), "hasFocusableInHeader", function () {
131
+ return _this.headerRef.current && hasFocusableIn(_this.headerRef.current);
132
+ });
133
+ _defineProperty(_assertThisInitialized(_this), "onExpandRow", function (expandedRow) {
134
+ var expandedRows = _this.asProps.expandedRows;
135
+ if (expandedRows.has(expandedRow[UNIQ_ROW_KEY])) {
136
+ expandedRows["delete"](expandedRow[UNIQ_ROW_KEY]);
137
+ } else {
138
+ expandedRows.add(expandedRow[UNIQ_ROW_KEY]);
139
+ }
140
+ _this.handlers.expandedRows(new Set(_toConsumableArray(expandedRows)));
141
+ });
142
+ _defineProperty(_assertThisInitialized(_this), "changeFocusCell", function (rowIndex, colIndex, direction) {
143
+ var _this$tableRef$curren2, _this$tableRef$curren3;
144
+ var hasFocusable = _this.hasFocusableInHeader();
145
+ var maxCol = _this.columns.length - 1;
146
+ var maxRow = _this.totalRows || 1;
147
+ 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, "\"]"));
148
+ var headerCells = (_this$tableRef$curren3 = _this.tableRef.current) === null || _this$tableRef$curren3 === void 0 ? void 0 : _this$tableRef$curren3.querySelectorAll('[role=columnheader]');
149
+ var currentCell = currentRow === null || currentRow === void 0 ? void 0 : currentRow.querySelector("[role=gridcell][aria-colindex='".concat(_this.focusedCell[1] + 1, "']"));
150
+ var currentHeaderCell = headerCells === null || headerCells === void 0 ? void 0 : headerCells.item(_this.focusedCell[1]);
151
+ var changed = true;
152
+ var newRow = _this.focusedCell[0] + rowIndex;
153
+ var newCol = _this.focusedCell[1] + colIndex;
154
+ if ((hasFocusable && newRow < 0 || !hasFocusable && newRow < 1 || newRow > maxRow) && newRow !== _this.focusedCell[0]) {
155
+ changed = false;
156
+ }
157
+ if ((newCol < 0 || newCol > maxCol) && newCol !== _this.focusedCell[1]) {
158
+ changed = false;
159
+ }
160
+ if (!changed) return;
161
+ var row = _this.getRow(newRow);
162
+ var cell = row === null || row === void 0 ? void 0 : row.querySelector(":scope > [role=gridcell][aria-colindex=\"".concat(newCol + 1, "\"], :scope > [role=columnheader][aria-colindex=\"").concat(newCol + 1, "\"], :scope > div > [role=columnheader][aria-colindex=\"").concat(newCol + 1, "\"]"));
163
+ if (cell instanceof HTMLElement && currentCell !== cell) {
164
+ _this.focusedCell = [newRow, newCol];
165
+ currentCell === null || currentCell === void 0 ? void 0 : currentCell.setAttribute('inert', '');
166
+ if (currentCell !== currentHeaderCell) {
167
+ currentCell === null || currentCell === void 0 ? void 0 : currentCell.removeAttribute('aria-describedby');
168
+ }
169
+ var headerCell = headerCells === null || headerCells === void 0 ? void 0 : headerCells.item(newCol);
170
+ var describedBy = headerCell === null || headerCell === void 0 ? void 0 : headerCell.getAttribute('aria-describedby');
171
+ cell.removeAttribute('inert');
172
+ if (headerCell !== cell && describedBy) {
173
+ cell.setAttribute('aria-describedby', describedBy);
174
+ }
175
+ cell === null || cell === void 0 ? void 0 : cell.focus();
176
+ if (newRow !== 0) {
177
+ currentHeaderCell === null || currentHeaderCell === void 0 ? void 0 : currentHeaderCell.setAttribute('inert', '');
178
+ var _headerCell = headerCells === null || headerCells === void 0 ? void 0 : headerCells.item(newCol);
179
+ _headerCell === null || _headerCell === void 0 ? void 0 : _headerCell.removeAttribute('inert');
180
+ }
181
+ } else if (cell === null && currentCell instanceof HTMLElement) {
182
+ var rowI = rowIndex;
183
+ var colI = colIndex;
184
+ if (direction === 'left' || direction === 'right') {
185
+ var _currentCell$parentEl, _currentCell$parentEl2, _row$children;
186
+ // we need to skip Collapse Element with one big component from keyboard left/right pressing
187
+ if (((_currentCell$parentEl = currentCell.parentElement) === null || _currentCell$parentEl === void 0 ? void 0 : _currentCell$parentEl.dataset.uiName) === 'Collapse') {
188
+ return;
189
+ }
190
+
191
+ // left/right
192
+ if (currentCell.dataset.groupedBy === 'colgroup' || Number((_currentCell$parentEl2 = currentCell.parentElement) === null || _currentCell$parentEl2 === void 0 ? void 0 : _currentCell$parentEl2.getAttribute('aria-rowindex')) === 2 || Array.from((_row$children = row === null || row === void 0 ? void 0 : row.children) !== null && _row$children !== void 0 ? _row$children : []).indexOf(currentCell) > 0) {
193
+ colI = direction === 'left' ? colI - 1 : colI + 1;
194
+ } else {
195
+ rowI = rowI - 1;
196
+ }
197
+ } else if (direction === 'up' || direction === 'down') {
198
+ // top/bottom
199
+ if (currentCell.dataset.groupedBy === 'rowgroup' || Number(currentCell.getAttribute('aria-colindex')) === 1) {
200
+ rowI = direction === 'up' ? rowI - 1 : rowI + 1;
201
+ } else {
202
+ colI = colI - 1;
203
+ }
204
+ }
205
+ _this.changeFocusCell(rowI, colI, direction);
206
+ } else if (cell === null && currentHeaderCell instanceof HTMLElement && direction === 'down') {
207
+ var _colI = colIndex - 1;
208
+ _this.changeFocusCell(rowIndex, _colI, direction);
209
+ } else if (row === null && _this.focusedCell[0] === 0 && direction === 'down' && _this.asProps.virtualScroll) {
210
+ _this.changeFocusCell(rowIndex + 1, colIndex, direction);
211
+ }
212
+ });
213
+ _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (e) {
214
+ switch (e.key) {
215
+ case 'Tab':
216
+ {
217
+ _this.setInert(true);
218
+ break;
219
+ }
220
+ case 'ArrowLeft':
221
+ {
222
+ e.preventDefault();
223
+ _this.changeFocusCell(0, -1, 'left');
224
+ break;
225
+ }
226
+ case 'ArrowRight':
227
+ {
228
+ e.preventDefault();
229
+ _this.changeFocusCell(0, 1, 'right');
230
+ break;
231
+ }
232
+ case 'ArrowUp':
233
+ {
234
+ e.preventDefault();
235
+ _this.changeFocusCell(-1, 0, 'up');
236
+ break;
237
+ }
238
+ case 'ArrowDown':
239
+ {
240
+ e.preventDefault();
241
+ _this.changeFocusCell(1, 0, 'down');
242
+ break;
243
+ }
244
+ }
245
+ });
246
+ _defineProperty(_assertThisInitialized(_this), "initFocusableCell", function () {
247
+ var hasFocusable = _this.hasFocusableInHeader();
248
+ if (hasFocusable) {
249
+ _this.focusedCell = [0, 0];
250
+ } else {
251
+ _this.focusedCell = [1, 0];
252
+ }
253
+ });
254
+ _defineProperty(_assertThisInitialized(_this), "handleScroll", trottle(function (e) {
255
+ var scrollTop = e.target.scrollTop;
256
+ var scrollDirection = scrollTop > _this.state.scrollTop ? 'down' : 'up';
257
+ _this.setState({
258
+ scrollTop: scrollTop,
259
+ scrollDirection: scrollDirection
260
+ });
261
+ }));
262
+ _defineProperty(_assertThisInitialized(_this), "handleFocus", function (e) {
263
+ if (_this.asProps.loading) {
264
+ var _this$spinnerRef$curr;
265
+ (_this$spinnerRef$curr = _this.spinnerRef.current) === null || _this$spinnerRef$curr === void 0 ? void 0 : _this$spinnerRef$curr.focus();
266
+ e.currentTarget.setAttribute('tabIndex', '-1');
267
+ } else if ((!e.relatedTarget || !isFocusInside(e.currentTarget, e.relatedTarget)) && lastInteraction.isKeyboard()) {
268
+ var _row;
269
+ if (_this.focusedCell[0] === -1 && _this.focusedCell[1] === -1) {
270
+ _this.initFocusableCell();
271
+ }
272
+ _this.setInert(true);
273
+ var row = _this.getRow(_this.focusedCell[0]);
274
+ if (!row) {
275
+ _this.initFocusableCell();
276
+ row = _this.getRow(_this.focusedCell[0]);
277
+ }
278
+ if (!row && _this.asProps.virtualScroll) {
279
+ var _this$tableRef$curren4;
280
+ var firstAvailableCell = (_this$tableRef$curren4 = _this.tableRef.current) === null || _this$tableRef$curren4 === void 0 ? void 0 : _this$tableRef$curren4.querySelector("[role=\"gridcell\"]");
281
+ var firstAvailableRow = firstAvailableCell === null || firstAvailableCell === void 0 ? void 0 : firstAvailableCell.parentElement;
282
+ if (firstAvailableCell && firstAvailableRow) {
283
+ var _Number, _Number2;
284
+ var colIndex = ((_Number = Number(firstAvailableCell.getAttribute('aria-colindex'))) !== null && _Number !== void 0 ? _Number : 1) - 1;
285
+ var rowIndex = ((_Number2 = Number(firstAvailableRow.getAttribute('aria-rowindex'))) !== null && _Number2 !== void 0 ? _Number2 : 1) - 1;
286
+ _this.focusedCell[0] = rowIndex;
287
+ _this.focusedCell[1] = colIndex;
288
+ row = firstAvailableRow;
289
+ }
290
+ }
291
+ var cell = (_row = row) === null || _row === void 0 ? void 0 : _row.querySelectorAll('[role=gridcell], [role=columnheader]').item(_this.focusedCell[1]);
292
+ cell === null || cell === void 0 ? void 0 : cell.removeAttribute('inert');
293
+ if (cell instanceof HTMLElement) {
294
+ if (hasParent(e.target, cell)) {
295
+ e.target.focus();
296
+ } else {
297
+ cell.focus();
298
+ }
299
+ }
300
+ e.currentTarget.setAttribute('tabIndex', '-1');
301
+ }
302
+ });
303
+ _defineProperty(_assertThisInitialized(_this), "handleBlur", function (e) {
304
+ var relatedTarget = e.relatedTarget;
305
+ var tableElement = _this.tableRef.current;
306
+ if (tableElement && (!relatedTarget || !isFocusInside(tableElement, relatedTarget) || !lastInteraction.isKeyboard())) {
307
+ _this.setInert(false);
308
+ tableElement.setAttribute('tabIndex', '0');
309
+ }
310
+ });
311
+ _defineProperty(_assertThisInitialized(_this), "handleMouseMove", function () {
312
+ _this.setInert(false);
313
+ });
314
+ _defineProperty(_assertThisInitialized(_this), "handleBackFromAccordion", function (cellIndex) {
315
+ _this.changeFocusCell(-1, cellIndex === -1 ? 0 : cellIndex, 'up');
316
+ });
317
+ _defineProperty(_assertThisInitialized(_this), "getScrollOffsetValue", function () {
318
+ if (!_this.headerRef.current) {
319
+ return [0, 0];
320
+ }
321
+ var setToMap = function setToMap(element) {
322
+ if (element.getAttribute('name') && element.dataset.uiName === 'Head.Column') {
323
+ var name = element.getAttribute('name');
324
+ if (name) {
325
+ _this.headerNodesMap.set(name, element);
326
+ }
327
+ }
328
+ };
329
+ _this.headerRef.current.childNodes.forEach(function (node) {
330
+ if (node instanceof HTMLElement) {
331
+ if (node.classList.value.includes('SGroupContainer')) {
332
+ node.childNodes.forEach(function (columnNode) {
333
+ if (columnNode instanceof HTMLElement) {
334
+ setToMap(columnNode);
335
+ }
336
+ });
337
+ } else {
338
+ setToMap(node);
339
+ }
340
+ }
341
+ });
342
+ return _this.columns.reduce(function (acc, column) {
343
+ if (column.fixed === 'left') {
344
+ var _this$headerNodesMap$, _this$headerNodesMap$2;
345
+ 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;
346
+ }
347
+ if (column.fixed === 'right') {
348
+ var _this$headerNodesMap$3, _this$headerNodesMap$4;
349
+ 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;
350
+ }
351
+ return acc;
352
+ }, [0, 0]);
353
+ });
354
+ _defineProperty(_assertThisInitialized(_this), "getFixedStyle", function (cell) {
355
+ var side = cell.fixed;
356
+ if (!side) return [undefined, undefined];
357
+ var names = cell.name.split('/');
358
+ var nameSideMap = {
359
+ left: names[0],
360
+ right: names[names.length - 1]
361
+ };
362
+ var name = nameSideMap[side];
363
+ var index = _this.columns.findIndex(function (column) {
364
+ return column.name === name;
365
+ });
366
+ if (index === -1) return [undefined, undefined];
367
+ var startIndexSideMap = {
368
+ left: 0,
369
+ right: index + 1
370
+ };
371
+ var endIndexSideMap = {
372
+ left: index,
373
+ right: _this.columns.length
374
+ };
375
+ var columnsFixed = _this.columns.slice(startIndexSideMap[side], endIndexSideMap[side]);
376
+ if (columnsFixed.length < 1) return [side, 0];
377
+ var sum = columnsFixed.reduce(function (acc, column) {
378
+ var _this$headerNodesMap$5;
379
+ return acc + ((_this$headerNodesMap$5 = _this.headerNodesMap.get(column.name)) === null || _this$headerNodesMap$5 === void 0 ? void 0 : _this$headerNodesMap$5.getBoundingClientRect().width);
380
+ }, 0);
381
+ return [side, "".concat(sum, "px")];
382
+ });
383
+ if (props.children) {
384
+ _this.columns = _this.calculateColumns();
385
+ } else {
386
+ var cols = _this.calculateColumnsFromConfig();
387
+ _this.columns = cols[0];
388
+ _this.treeColumns = cols[1];
389
+ }
390
+ _this.rows = _this.calculateRows();
391
+ _this.flatRows = _this.rows.flat();
392
+ return _this;
393
+ }
394
+ _createClass(DataTableRoot, [{
395
+ key: "uncontrolledProps",
396
+ value: function uncontrolledProps() {
397
+ return {
398
+ expandedRows: new Set()
399
+ };
400
+ }
401
+ }, {
402
+ key: "componentDidMount",
403
+ value: function componentDidMount() {
404
+ var _this2 = this;
405
+ var _this$asProps2 = this.asProps,
406
+ headerProps = _this$asProps2.headerProps,
407
+ loading = _this$asProps2.loading;
408
+ if (headerProps !== null && headerProps !== void 0 && headerProps.sticky && !headerProps.h || loading || this.columns.some(function (c) {
409
+ return c.fixed;
410
+ })) {
411
+ requestAnimationFrame(function () {
412
+ _this2.forceUpdate();
413
+ });
414
+ }
415
+ }
416
+ }, {
417
+ key: "componentDidUpdate",
418
+ value: function componentDidUpdate(prevProps) {
419
+ var _this$asProps3 = this.asProps,
420
+ data = _this$asProps3.data,
421
+ selectedRows = _this$asProps3.selectedRows,
422
+ columns = _this$asProps3.columns;
423
+ if (prevProps.columns !== columns) {
424
+ var cols = this.calculateColumnsFromConfig();
425
+ this.columns = cols[0];
426
+ this.treeColumns = cols[1];
427
+ }
428
+ if (prevProps.data !== data || prevProps.columns !== columns) {
429
+ this.rows = this.calculateRows();
430
+ this.flatRows = this.rows.flat();
431
+ this.forceUpdate();
432
+ }
433
+ if (prevProps.selectedRows !== selectedRows && selectedRows !== undefined) {
434
+ if (prevProps.selectedRows.length < data.length && selectedRows.length === data.length) {
435
+ this.setSelectAllMessage(true);
436
+ } else if (prevProps.selectedRows.length > 0 && selectedRows.length === 0) {
437
+ this.setSelectAllMessage(false);
438
+ }
439
+ }
440
+ }
441
+ }, {
442
+ key: "totalRows",
443
+ get: function get() {
444
+ var _this$asProps4 = this.asProps,
445
+ totalRows = _this$asProps4.totalRows,
446
+ expandedRows = _this$asProps4.expandedRows;
447
+ var flatRows = this.rows.flat();
448
+ var expandedRowsCount = Array.from(expandedRows !== null && expandedRows !== void 0 ? expandedRows : []).reduce(function (acc, rowKey) {
449
+ var dtRow = flatRows.find(function (el) {
450
+ return el[UNIQ_ROW_KEY] === rowKey;
451
+ });
452
+ if (dtRow) {
453
+ var _expandedRows = dtRow[ACCORDION];
454
+ if (Array.isArray(_expandedRows)) {
455
+ acc = acc + _expandedRows.length;
456
+ } else {
457
+ acc = acc + 1;
458
+ }
459
+ }
460
+ return acc;
461
+ }, 0);
462
+ if (totalRows !== undefined) {
463
+ return totalRows + expandedRowsCount;
464
+ }
465
+ var rows = this.rows.reduce(function (acc, item) {
466
+ acc = acc + 1;
467
+ if (Array.isArray(item)) {
468
+ acc = acc + item.length;
469
+ }
470
+ return acc;
471
+ }, 0);
472
+ return rows + expandedRowsCount;
473
+ }
474
+ }, {
475
+ key: "gridSettings",
476
+ get: function get() {
477
+ var columns = this.columns;
478
+ var gridTemplateColumns = columns.map(function (c) {
479
+ return c.gtcWidth;
480
+ });
481
+ var gridTemplateAreas = columns.map(function (c) {
482
+ return c.name;
483
+ });
484
+ return {
485
+ gridTemplateColumns: gridTemplateColumns,
486
+ gridTemplateAreas: gridTemplateAreas
487
+ };
488
+ }
489
+ }, {
490
+ key: "getHeadProps",
491
+ value: function getHeadProps() {
492
+ var _this3 = this;
493
+ var _this$asProps5 = this.asProps,
494
+ use = _this$asProps5.use,
495
+ compact = _this$asProps5.compact,
496
+ sort = _this$asProps5.sort,
497
+ onSortChange = _this$asProps5.onSortChange,
498
+ getI18nText = _this$asProps5.getI18nText,
499
+ uid = _this$asProps5.uid,
500
+ headerProps = _this$asProps5.headerProps,
501
+ onSelectedRowsChange = _this$asProps5.onSelectedRowsChange,
502
+ selectedRows = _this$asProps5.selectedRows,
503
+ sideIndents = _this$asProps5.sideIndents;
504
+ var _this$gridSettings = this.gridSettings,
505
+ gridTemplateColumns = _this$gridSettings.gridTemplateColumns,
506
+ gridTemplateAreas = _this$gridSettings.gridTemplateAreas;
507
+ return _objectSpread({
508
+ columns: this.columns,
509
+ treeColumns: this.treeColumns,
510
+ use: use,
511
+ tableRef: this.tableRef,
512
+ compact: Boolean(compact),
513
+ sort: sort,
514
+ onSortChange: onSortChange,
515
+ getI18nText: getI18nText,
516
+ uid: uid,
517
+ ref: this.headerRef,
518
+ gridAreaGroupMap: this.gridAreaGroupMap,
519
+ gridTemplateColumns: gridTemplateColumns,
520
+ gridTemplateAreas: gridTemplateAreas,
521
+ sideIndents: sideIndents,
522
+ totalRows: this.totalRows,
523
+ selectedRows: selectedRows,
524
+ onChangeSelectAll: function onChangeSelectAll(value, e) {
525
+ var selectedRowsIndexes = value ? new Array(_this3.totalRows).fill(undefined).map(function (_, i) {
526
+ return i;
527
+ }) : [];
528
+ onSelectedRowsChange === null || onSelectedRowsChange === void 0 ? void 0 : onSelectedRowsChange(selectedRowsIndexes, e);
529
+ },
530
+ getFixedStyle: this.getFixedStyle
531
+ }, headerProps);
532
+ }
533
+ }, {
534
+ key: "getBodyProps",
535
+ value: function getBodyProps() {
536
+ var _this$asProps6 = this.asProps,
537
+ use = _this$asProps6.use,
538
+ compact = _this$asProps6.compact,
539
+ loading = _this$asProps6.loading,
540
+ getI18nText = _this$asProps6.getI18nText,
541
+ expandedRows = _this$asProps6.expandedRows,
542
+ virtualScroll = _this$asProps6.virtualScroll,
543
+ uid = _this$asProps6.uid,
544
+ rowProps = _this$asProps6.rowProps,
545
+ renderCell = _this$asProps6.renderCell,
546
+ headerProps = _this$asProps6.headerProps,
547
+ renderEmptyData = _this$asProps6.renderEmptyData,
548
+ sideIndents = _this$asProps6.sideIndents,
549
+ selectedRows = _this$asProps6.selectedRows;
550
+ var _this$gridSettings2 = this.gridSettings,
551
+ gridTemplateColumns = _this$gridSettings2.gridTemplateColumns,
552
+ gridTemplateAreas = _this$gridSettings2.gridTemplateAreas;
553
+ return {
554
+ columns: this.columns,
555
+ rows: this.rows,
556
+ flatRows: this.flatRows,
557
+ use: use,
558
+ compact: Boolean(compact),
559
+ gridTemplateColumns: gridTemplateColumns,
560
+ gridTemplateAreas: gridTemplateAreas,
561
+ loading: loading,
562
+ headerHeight: this.getHeaderHeight(),
563
+ stickyHeader: headerProps === null || headerProps === void 0 ? void 0 : headerProps.sticky,
564
+ getI18nText: getI18nText,
565
+ expandedRows: expandedRows,
566
+ onExpandRow: this.onExpandRow,
567
+ spinnerRef: this.spinnerRef,
568
+ scrollTop: this.state.scrollTop,
569
+ scrollDirection: this.state.scrollDirection,
570
+ tableContainerRef: this.tableContainerRef,
571
+ tableRef: this.tableRef,
572
+ scrollAreaRef: this.scrollAreaRef,
573
+ onBackFromAccordion: this.handleBackFromAccordion,
574
+ virtualScroll: virtualScroll,
575
+ hasGroups: this.hasGroups,
576
+ uid: uid,
577
+ rowProps: rowProps,
578
+ renderCell: renderCell,
579
+ renderEmptyData: renderEmptyData,
580
+ sideIndents: sideIndents,
581
+ selectedRows: selectedRows,
582
+ onSelectRow: this.handleSelectRow,
583
+ getFixedStyle: this.getFixedStyle
584
+ };
585
+ }
586
+ }, {
587
+ key: "setInert",
588
+ value: function setInert(value) {
589
+ var _this$tableRef$curren5;
590
+ var cells = (_this$tableRef$curren5 = this.tableRef.current) === null || _this$tableRef$curren5 === void 0 ? void 0 : _this$tableRef$curren5.querySelectorAll('[role=gridcell], [role=columnheader]');
591
+ cells === null || cells === void 0 ? void 0 : cells.forEach(function (cell) {
592
+ if (value === true) {
593
+ cell.setAttribute('inert', '');
594
+ } else {
595
+ cell.removeAttribute('inert');
596
+ }
597
+ });
598
+ }
599
+ }, {
600
+ key: "render",
601
+ value: function render() {
602
+ var _ref = this.asProps,
603
+ _ref2;
604
+ var SDataTable = Box;
605
+ var _this$asProps7 = this.asProps,
606
+ Children = _this$asProps7.Children,
607
+ styles = _this$asProps7.styles,
608
+ w = _this$asProps7.w,
609
+ wMax = _this$asProps7.wMax,
610
+ wMin = _this$asProps7.wMin,
611
+ h = _this$asProps7.h,
612
+ hMax = _this$asProps7.hMax,
613
+ hMin = _this$asProps7.hMin,
614
+ virtualScroll = _this$asProps7.virtualScroll,
615
+ children = _this$asProps7.children,
616
+ headerProps = _this$asProps7.headerProps,
617
+ loading = _this$asProps7.loading,
618
+ selectedRows = _this$asProps7.selectedRows;
619
+ var _this$getScrollOffset = this.getScrollOffsetValue(),
620
+ _this$getScrollOffset2 = _slicedToArray(_this$getScrollOffset, 2),
621
+ offsetLeftSum = _this$getScrollOffset2[0],
622
+ offsetRightSum = _this$getScrollOffset2[1];
623
+ var _this$gridSettings3 = this.gridSettings,
624
+ gridTemplateColumns = _this$gridSettings3.gridTemplateColumns,
625
+ gridTemplateAreas = _this$gridSettings3.gridTemplateAreas;
626
+ var Head = findComponent(Children, ['DataTable.Head']);
627
+ var headerPropsToCheck = headerProps !== null && headerProps !== void 0 ? headerProps : Head === null || Head === void 0 ? void 0 : Head.props;
628
+ var headerHeight = (headerProps === null || headerProps === void 0 ? void 0 : headerProps.h) || this.getHeaderHeight();
629
+ var topOffset = headerPropsToCheck !== null && headerPropsToCheck !== void 0 && headerPropsToCheck.sticky || headerPropsToCheck !== null && headerPropsToCheck !== void 0 && headerPropsToCheck.withScrollBar ? headerHeight : undefined;
630
+ var width = w !== null && w !== void 0 ? w : this.columns.some(function (c) {
631
+ return c.gtcWidth === 'auto' || c.gtcWidth === '1fr';
632
+ }) ? '100%' : undefined;
633
+ var gridTemplateRows = undefined;
634
+ if (virtualScroll && typeof virtualScroll !== 'boolean' && 'rowHeight' in virtualScroll) {
635
+ gridTemplateRows = "auto auto repeat(".concat(this.totalRows, ", minmax(").concat(virtualScroll.rowHeight, "px, auto)");
636
+ }
637
+ var scrollDirection = undefined;
638
+ var hasWidthSettings = Boolean(w) && w !== '100%' || Boolean(wMax);
639
+ var hasHeightSettings = Boolean(h) && h !== 'fit-content' || Boolean(hMax);
640
+ if (hasWidthSettings && !hasHeightSettings) {
641
+ scrollDirection = 'horizontal';
642
+ } else if (hasHeightSettings && !hasWidthSettings) {
643
+ scrollDirection = 'vertical';
644
+ } else if (hasWidthSettings && hasHeightSettings) {
645
+ scrollDirection = 'both';
646
+ }
647
+ return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(ScrollArea, _ref2.cn("ScrollArea", {
648
+ "leftOffset": offsetLeftSum,
649
+ "rightOffset": offsetRightSum,
650
+ "topOffset": topOffset,
651
+ "w": width,
652
+ "wMax": wMax,
653
+ "wMin": wMin,
654
+ "h": h,
655
+ "hMax": hMax,
656
+ "hMin": hMin,
657
+ "shadow": true,
658
+ "ref": this.scrollAreaRef,
659
+ "container": this.tableContainerRef,
660
+ "styles": scrollStyles,
661
+ "onScroll": virtualScroll ? this.handleScroll : undefined,
662
+ "disableAutofocusToContent": true
663
+ }), /*#__PURE__*/React.createElement(ScrollArea.Container, {
664
+ tabIndex: -1
665
+ // @ts-ignore
666
+ ,
667
+ scrollDirection: scrollDirection
668
+ // @ts-ignore
669
+ ,
670
+ loading: loading,
671
+ headerHeight: "".concat(headerHeight, "px"),
672
+ leftScrollPadding: "".concat(offsetLeftSum, "px"),
673
+ rightScrollPadding: "".concat(offsetRightSum, "px")
674
+ }, /*#__PURE__*/React.createElement(SDataTable, _ref2.cn("SDataTable", _objectSpread({}, _assignProps({
675
+ "ref": forkRef(this.tableRef, this.tableContainerRef),
676
+ "role": 'grid',
677
+ "onKeyDown": this.handleKeyDown,
678
+ "onMouseMove": this.handleMouseMove,
679
+ "tabIndex": 0,
680
+ "onFocus": this.handleFocus,
681
+ "onBlur": this.handleBlur,
682
+ "aria-rowcount": this.totalRows,
683
+ "aria-colcount": this.columns.length,
684
+ "gridTemplateColumns": gridTemplateColumns.join(' '),
685
+ "gridTemplateAreas": gridTemplateAreas.join(' '),
686
+ "gridTemplateRows": gridTemplateRows,
687
+ "w": '100%',
688
+ "use:data": undefined,
689
+ "use:w": undefined,
690
+ "use:wMax": undefined,
691
+ "use:wMin": undefined,
692
+ "use:h": undefined,
693
+ "use:hMax": undefined,
694
+ "use:hMin": undefined
695
+ }, _ref))), children ? /*#__PURE__*/React.createElement(Children, _ref2.cn("Children", {})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataTableInternal.Head, null), /*#__PURE__*/React.createElement(DataTableInternal.Body, null)))), (headerPropsToCheck === null || headerPropsToCheck === void 0 ? void 0 : headerPropsToCheck.withScrollBar) && topOffset && !loading && /*#__PURE__*/React.createElement(ScrollArea.Bar, {
696
+ orientation: "horizontal",
697
+ top: topOffset - SCROLL_BAR_HEIGHT,
698
+ zIndex: 10
699
+ }), !loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ScrollArea.Bar, {
700
+ orientation: "horizontal",
701
+ zIndex: 10
702
+ }), /*#__PURE__*/React.createElement(ScrollArea.Bar, {
703
+ orientation: "vertical",
704
+ zIndex: 10
705
+ })), selectedRows !== undefined && /*#__PURE__*/React.createElement(ScreenReaderOnly, _ref2.cn("ScreenReaderOnly", {
706
+ "aria-live": 'polite',
707
+ "role": 'status'
708
+ }), this.state.selectAllMessage));
709
+ }
710
+ }, {
711
+ key: "calculateColumns",
712
+ value: function calculateColumns() {
713
+ var _this4 = this;
714
+ var _this$props = this.props,
715
+ children = _this$props.children,
716
+ data = _this$props.data,
717
+ selectedRows = _this$props.selectedRows;
718
+ var HeadComponent = findComponent(children, ['Head']);
719
+ this.hasGroups = findComponent(HeadComponent.props.children, ['Head.Group']) !== undefined;
720
+ var columnIndex = 0;
721
+ var groupIndex = 0;
722
+ var gridColumnIndex = selectedRows ? 2 : 1;
723
+ var calculateGridTemplateColumn = this.calculateGridTemplateColumn.bind(this);
724
+ var columns = [];
725
+ if (selectedRows) {
726
+ var column = {
727
+ name: SELECT_ALL.toString(),
728
+ gtcWidth: '40px',
729
+ alignItems: 'flex-start',
730
+ children: ''
731
+ };
732
+ columns.push(column);
733
+ }
734
+ var makeColumn = function makeColumn(columnElement, parent, isFirst, isLast) {
735
+ var _columnElement$props$, _ref3, _columnElement$props$2;
736
+ var leftBordersFromParent = isFirst && ((parent === null || parent === void 0 ? void 0 : parent.props.borders) === 'both' || (parent === null || parent === void 0 ? void 0 : parent.props.borders) === 'left') ? 'left' : undefined;
737
+ var rightBordersFromParent = isLast && ((parent === null || parent === void 0 ? void 0 : parent.props.borders) === 'both' || (parent === null || parent === void 0 ? void 0 : parent.props.borders) === 'right') ? 'right' : undefined;
738
+ var column = {
739
+ name: columnElement.props.name,
740
+ gtcWidth: calculateGridTemplateColumn(columnElement),
741
+ fixed: (_columnElement$props$ = columnElement.props.fixed) !== null && _columnElement$props$ !== void 0 ? _columnElement$props$ : parent === null || parent === void 0 ? void 0 : parent.props.fixed,
742
+ borders: (_ref3 = (_columnElement$props$2 = columnElement.props.borders) !== null && _columnElement$props$2 !== void 0 ? _columnElement$props$2 : leftBordersFromParent) !== null && _ref3 !== void 0 ? _ref3 : rightBordersFromParent,
743
+ parent: parent,
744
+ flexWrap: columnElement.props.flexWrap,
745
+ alignItems: columnElement.props.alignItems,
746
+ alignContent: columnElement.props.alignContent,
747
+ justifyContent: columnElement.props.justifyContent,
748
+ children: ''
749
+ };
750
+ return column;
751
+ };
752
+ var childIsColumn = function childIsColumn(child) {
753
+ return child.type === Head.Column;
754
+ };
755
+ var childIsGroup = function childIsGroup(child) {
756
+ return child.type === Head.Group;
757
+ };
758
+ React.Children.forEach(HeadComponent.props.children, function (child, i) {
759
+ if (! /*#__PURE__*/React.isValidElement(child)) return;
760
+ if (childIsColumn(child)) {
761
+ var col = makeColumn(child);
762
+ col.gridArea = "1 / ".concat(gridColumnIndex, " / ").concat(_this4.hasGroups ? '3' : '2', " / ").concat(gridColumnIndex + 1);
763
+ columnIndex++;
764
+ gridColumnIndex++;
765
+ columns.push(col);
766
+ } else if (childIsGroup(child)) {
767
+ var Group = child;
768
+ var childCount = React.Children.count(child.props.children);
769
+ var initGridColumn = gridColumnIndex;
770
+ React.Children.forEach(child.props.children, function (child, j) {
771
+ if ((child === null || child === void 0 ? void 0 : child.type) === Head.Column) {
772
+ var isFirst = j === 0;
773
+ var isLast = j === childCount - 1;
774
+ var _col = makeColumn(child, Group, isFirst, isLast);
775
+ if (i === 0 && j === 0 && data.some(function (d) {
776
+ return d[ACCORDION];
777
+ })) {
778
+ gridColumnIndex++;
779
+ _col.gridArea = "2 / ".concat(gridColumnIndex - 1, " / 3 / ").concat(gridColumnIndex + 1);
780
+ } else {
781
+ _col.gridArea = "2 / ".concat(gridColumnIndex, " / 3 / ").concat(gridColumnIndex + 1);
782
+ }
783
+ _col.gridArea = "2 / ".concat(gridColumnIndex, " / 3 / ").concat(gridColumnIndex + 1);
784
+ columnIndex++;
785
+ gridColumnIndex++;
786
+ columns.push(_col);
787
+ }
788
+ });
789
+ _this4.gridAreaGroupMap.set(groupIndex, "1 / ".concat(initGridColumn, " / 2 / ").concat(gridColumnIndex));
790
+ groupIndex++;
791
+ }
792
+ });
793
+ return columns.filter(Boolean);
794
+ }
795
+ }, {
796
+ key: "calculateColumnsFromConfig",
797
+ value: function calculateColumnsFromConfig() {
798
+ var _this5 = this;
799
+ var _this$props2 = this.props,
800
+ columns = _this$props2.columns,
801
+ data = _this$props2.data,
802
+ selectedRows = _this$props2.selectedRows;
803
+ this.hasGroups = columns.some(function (column) {
804
+ return 'columns' in column;
805
+ });
806
+ var columnIndex = 0;
807
+ var groupIndex = 0;
808
+ var gridColumnIndex = selectedRows ? 2 : 1;
809
+ var calculateGridTemplateColumn = this.calculateGridTemplateColumn.bind(this);
810
+ var calculatedColumns = [];
811
+ var treeColumns = [];
812
+ if (selectedRows) {
813
+ var column = {
814
+ name: SELECT_ALL.toString(),
815
+ gtcWidth: '40px',
816
+ alignItems: 'flex-start',
817
+ children: ''
818
+ };
819
+ calculatedColumns.push(column);
820
+ }
821
+ var makeColumn = function makeColumn(columnElement, parent, isFirst, isLast) {
822
+ var _columnElement$fixed, _ref4, _columnElement$border;
823
+ 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;
824
+ 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;
825
+ var column = _objectSpread(_objectSpread({}, columnElement), {}, {
826
+ name: childIsColumn(columnElement) ? columnElement.name : '',
827
+ gtcWidth: childIsColumn(columnElement) ? calculateGridTemplateColumn(columnElement) : '',
828
+ fixed: (_columnElement$fixed = columnElement.fixed) !== null && _columnElement$fixed !== void 0 ? _columnElement$fixed : parent === null || parent === void 0 ? void 0 : parent.fixed,
829
+ borders: (_ref4 = (_columnElement$border = columnElement.borders) !== null && _columnElement$border !== void 0 ? _columnElement$border : leftBordersFromParent) !== null && _ref4 !== void 0 ? _ref4 : rightBordersFromParent,
830
+ parent: parent
831
+ });
832
+ return column;
833
+ };
834
+ var childIsColumn = function childIsColumn(child) {
835
+ return !('columns' in child);
836
+ };
837
+ var childIsGroup = function childIsGroup(child) {
838
+ return 'columns' in child;
839
+ };
840
+ columns.forEach(function (child, i) {
841
+ if (childIsColumn(child)) {
842
+ var col = makeColumn(child);
843
+ col.gridArea = "1 / ".concat(gridColumnIndex, " / ").concat(_this5.hasGroups ? '3' : '2', " / ").concat(gridColumnIndex + 1);
844
+ columnIndex++;
845
+ gridColumnIndex++;
846
+ calculatedColumns.push(col);
847
+ treeColumns.push(col);
848
+ } else if (childIsGroup(child)) {
849
+ var Group = makeColumn(child);
850
+ var childCount = child.columns.length;
851
+ var initGridColumn = gridColumnIndex;
852
+ Group.columns = [];
853
+ Group.children = child.children;
854
+ child.columns.forEach(function (child, j) {
855
+ var _Group$columns;
856
+ var isFirst = j === 0;
857
+ var isLast = j === childCount - 1;
858
+ var col = makeColumn(child, Group, isFirst, isLast);
859
+ if (i === 0 && j === 0 && data.some(function (d) {
860
+ return d[ACCORDION];
861
+ })) {
862
+ gridColumnIndex++;
863
+ col.gridArea = "2 / ".concat(gridColumnIndex - 1, " / 3 / ").concat(gridColumnIndex + 1);
864
+ } else {
865
+ col.gridArea = "2 / ".concat(gridColumnIndex, " / 3 / ").concat(gridColumnIndex + 1);
866
+ }
867
+ col.gridArea = "2 / ".concat(gridColumnIndex, " / 3 / ").concat(gridColumnIndex + 1);
868
+ columnIndex++;
869
+ gridColumnIndex++;
870
+ calculatedColumns.push(col);
871
+ (_Group$columns = Group.columns) === null || _Group$columns === void 0 ? void 0 : _Group$columns.push(col);
872
+ });
873
+ treeColumns.push(Group);
874
+ _this5.gridAreaGroupMap.set(groupIndex, "1 / ".concat(initGridColumn, " / 2 / ").concat(gridColumnIndex));
875
+ groupIndex++;
876
+ }
877
+ });
878
+ return [calculatedColumns, treeColumns];
879
+ }
880
+ }, {
881
+ key: "calculateRows",
882
+ value: function calculateRows() {
883
+ var _this6 = this;
884
+ var columns = this.columns;
885
+ // @ts-ignore
886
+ var _this$props3 = this.props,
887
+ data = _this$props3.data,
888
+ uid = _this$props3.uid;
889
+ var rows = [];
890
+ var columnNames = columns.map(function (column) {
891
+ return column.name;
892
+ });
893
+ var rowIndex = 0;
894
+ var id = 100000000; // need this for gen keys by toString(36)
895
+
896
+ var makeDtRow = function makeDtRow(row, excludeColumns) {
897
+ var _Object$entries$reduc;
898
+ var columns = new Set(columnNames);
899
+ var dtRow = Object.entries(row).reduce(function (acc, _ref5) {
900
+ var _ref6 = _slicedToArray(_ref5, 2),
901
+ key = _ref6[0],
902
+ value = _ref6[1];
903
+ var columnsToRow = key.split(_this6.columnsSplitter);
904
+ if (columnsToRow.length === 1) {
905
+ acc[key] = value !== null && value !== void 0 ? value : '';
906
+ columns["delete"](key);
907
+ } else {
908
+ acc[columnsToRow[0]] = new MergedColumnsCell(value, {
909
+ dataKey: key,
910
+ size: columnsToRow.length
911
+ });
912
+ columnsToRow.forEach(function (value) {
913
+ columns["delete"](value);
914
+ });
915
+ }
916
+ if (row[ACCORDION]) {
917
+ acc[ACCORDION] = row[ACCORDION];
918
+ }
919
+ return acc;
920
+ }, (_Object$entries$reduc = {}, _defineProperty(_Object$entries$reduc, UNIQ_ROW_KEY, row[UNIQ_ROW_KEY] || "".concat(uid, "_").concat((rowIndex + id).toString(36))), _defineProperty(_Object$entries$reduc, ROW_INDEX, rowIndex), _Object$entries$reduc));
921
+ excludeColumns === null || excludeColumns === void 0 ? void 0 : excludeColumns.forEach(function (value) {
922
+ columns["delete"](value);
923
+ });
924
+ if (columns.size > 0) {
925
+ columns.forEach(function (value) {
926
+ dtRow[value] = '';
927
+ });
928
+ }
929
+ return dtRow;
930
+ };
931
+ data.forEach(function (row) {
932
+ var groupedRows = row[ROW_GROUP];
933
+ if (groupedRows) {
934
+ var _Object$entries$reduc2;
935
+ var innerRows = [];
936
+ var groupedKeys = [];
937
+ var groupedRowData = Object.entries(row).reduce(function (acc, _ref7) {
938
+ var _ref8 = _slicedToArray(_ref7, 2),
939
+ key = _ref8[0],
940
+ value = _ref8[1];
941
+ acc[key] = new MergedRowsCell(value, groupedRows.length);
942
+ groupedKeys.push(key);
943
+ return acc;
944
+ }, (_Object$entries$reduc2 = {}, _defineProperty(_Object$entries$reduc2, UNIQ_ROW_KEY, ''), _defineProperty(_Object$entries$reduc2, ROW_INDEX, -1), _Object$entries$reduc2));
945
+ groupedRows.forEach(function (childRow, index) {
946
+ var dtRow;
947
+ if (index === 0) {
948
+ var rowData = _objectSpread(_objectSpread({}, childRow), groupedRowData);
949
+ dtRow = makeDtRow(rowData);
950
+ } else {
951
+ dtRow = makeDtRow(childRow, groupedKeys);
952
+ }
953
+ innerRows.push(dtRow);
954
+ rowIndex++;
955
+ });
956
+ rows.push(innerRows);
957
+ } else {
958
+ var dtRow = makeDtRow(row);
959
+ rows.push(dtRow);
960
+ rowIndex++;
961
+ }
962
+ });
963
+ return rows;
964
+ }
965
+ }, {
966
+ key: "calculateGridTemplateColumn",
967
+ value: function calculateGridTemplateColumn(c) {
968
+ var _ref9;
969
+ return (_ref9 = /*#__PURE__*/React.isValidElement(c) ? c.props.gtcWidth : c.gtcWidth) !== null && _ref9 !== void 0 ? _ref9 : this.props.defaultGridTemplateColumnWidth;
970
+ }
971
+ }, {
972
+ key: "getHeaderHeight",
973
+ value: function getHeaderHeight() {
974
+ var _this$headerRef$curre;
975
+ var header = (_this$headerRef$curre = this.headerRef.current) === null || _this$headerRef$curre === void 0 ? void 0 : _this$headerRef$curre.children;
976
+ var height = 0;
977
+ 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++) {
978
+ var _header$length, _header$item;
979
+ var columnHeight = header === null || header === void 0 ? void 0 : (_header$item = header.item(i)) === null || _header$item === void 0 ? void 0 : _header$item.getBoundingClientRect().height;
980
+ if (columnHeight) {
981
+ height = columnHeight;
982
+ break;
983
+ }
984
+ }
985
+ return height;
986
+ }
987
+ }]);
988
+ return DataTableRoot;
989
+ }(Component);
990
+ _defineProperty(DataTableRoot, "displayName", 'DataTable');
991
+ _defineProperty(DataTableRoot, "style", style);
992
+ _defineProperty(DataTableRoot, "enhance", [uniqueIDEnhancement(), i18nEnhance(localizedMessages)]);
993
+ _defineProperty(DataTableRoot, "defaultProps", {
994
+ use: 'primary',
995
+ defaultGridTemplateColumnWidth: 'auto',
996
+ defaultExpandedRows: new Set(),
997
+ defaultSelectedRows: undefined,
998
+ h: 'fit-content',
999
+ renderEmptyData: function renderEmptyData() {
1000
+ return /*#__PURE__*/React.createElement(NoData, {
1001
+ py: 10,
1002
+ type: 'nothing-found',
1003
+ description: '',
1004
+ w: '100%'
1005
+ });
1006
+ }
1007
+ });
1008
+ export var DataTable = createComponent(DataTableRoot, {
1009
+ Head: Head,
1010
+ Body: Body
1011
+ });
1012
+ export var DataTableInternal = DataTable;
1013
+ //# sourceMappingURL=DataTable.js.map