@semcore/data-table 16.0.0-prerelease.9 → 16.0.0

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