@semcore/data-table 16.0.0-prerelease.7 → 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
package/lib/esm/Body.mjs DELETED
@@ -1,427 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
5
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
- import _typeof from "@babel/runtime/helpers/esm/typeof";
7
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
8
- import _createClass from "@babel/runtime/helpers/esm/createClass";
9
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
10
- import _inherits from "@babel/runtime/helpers/esm/inherits";
11
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
12
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
13
- import { sstyled, assignProps as assignProps$1, Component } from "@semcore/core";
14
- import React from "react";
15
- import { Flex, Box } from "@semcore/flex-box";
16
- import ScrollArea, { hideScrollBarsFromScreenReadersContext } from "@semcore/scroll-area";
17
- import { getFixedStyle, getScrollOffsetValue } from "./utils.mjs";
18
- import assignProps, { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
19
- import trottle from "@semcore/core/lib/utils/rafTrottle";
20
- import { forkRef } from "@semcore/core/lib/utils/ref";
21
- import canUseDOM from "@semcore/core/lib/utils/canUseDOM";
22
- import { SORT_ICON_WIDTH } from "./Head.mjs";
23
- import { getFocusableIn } from "@semcore/core/lib/utils/focus-lock/getFocusableIn";
24
- var _excluded = ["childrenPropsGetter"], _excluded2 = ["childrenPropsGetter"];
25
- var scrollStyles = (
26
- /*__reshadow_css_start__*/
27
- (sstyled.insert(
28
- /*__inner_css_start__*/
29
- ".___SShadowHorizontal_11aq4_gg_:after,.___SShadowHorizontal_11aq4_gg_:before,.___SShadowVertical_11aq4_gg_:after,.___SShadowVertical_11aq4_gg_:before{z-index:1}",
30
- "11aq4_gg_"
31
- ), {
32
- "__SShadowHorizontal": "___SShadowHorizontal_11aq4_gg_",
33
- "__SShadowVertical": "___SShadowVertical_11aq4_gg_"
34
- })
35
- );
36
- var testEnv = process.env.NODE_ENV === "test";
37
- var getCellsByColumn = function getCellsByColumn2(cells) {
38
- var flattenCells = cells.flat(20);
39
- return Object.fromEntries(flattenCells.map(function(cell) {
40
- return [cell.name, cell.data];
41
- }));
42
- };
43
- var displayContents = {
44
- display: "contents"
45
- };
46
- var Body = /* @__PURE__ */ function(_Component) {
47
- _inherits(Body2, _Component);
48
- var _super = _createSuper(Body2);
49
- function Body2() {
50
- var _this;
51
- _classCallCheck(this, Body2);
52
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
53
- args[_key] = arguments[_key];
54
- }
55
- _this = _super.call.apply(_super, [this].concat(args));
56
- _defineProperty(_assertThisInitialized(_this), "state", {
57
- rowHeight: void 0,
58
- scrollAreaHeight: void 0,
59
- scrollOffset: 0
60
- });
61
- _defineProperty(_assertThisInitialized(_this), "scrollContainerRef", /* @__PURE__ */ React.createRef());
62
- _defineProperty(_assertThisInitialized(_this), "firstRowRef", /* @__PURE__ */ React.createRef());
63
- _defineProperty(_assertThisInitialized(_this), "firstRowResizeObserver", null);
64
- _defineProperty(_assertThisInitialized(_this), "lockedCell", [null, false]);
65
- _defineProperty(_assertThisInitialized(_this), "getRowHeight", function() {
66
- var virtualScroll = _this.asProps.virtualScroll;
67
- var rowHeightFromProps = _typeof(virtualScroll) === "object" && (virtualScroll === null || virtualScroll === void 0 ? void 0 : virtualScroll.rowHeight);
68
- return rowHeightFromProps || _this.state.rowHeight;
69
- });
70
- _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function(e) {
71
- if (e.currentTarget === _this.lockedCell[0]) {
72
- var focusableChildren = Array.from(_this.lockedCell[0].children).flatMap(function(node) {
73
- return getFocusableIn(node);
74
- });
75
- if (_this.lockedCell[1]) {
76
- if (e.key === "Escape") {
77
- var _this$lockedCell$;
78
- (_this$lockedCell$ = _this.lockedCell[0]) === null || _this$lockedCell$ === void 0 ? void 0 : _this$lockedCell$.focus();
79
- _this.lockedCell[1] = false;
80
- }
81
- if (e.key.startsWith("Arrow")) {
82
- e.stopPropagation();
83
- e.preventDefault();
84
- }
85
- if (e.key === "Tab") {
86
- if (e.target === focusableChildren[0] && e.shiftKey) {
87
- var _focusableChildren;
88
- (_focusableChildren = focusableChildren[focusableChildren.length - 1]) === null || _focusableChildren === void 0 ? void 0 : _focusableChildren.focus();
89
- e.preventDefault();
90
- } else if (e.target === focusableChildren[focusableChildren.length - 1] && !e.shiftKey) {
91
- var _focusableChildren$;
92
- (_focusableChildren$ = focusableChildren[0]) === null || _focusableChildren$ === void 0 ? void 0 : _focusableChildren$.focus();
93
- e.preventDefault();
94
- }
95
- e.stopPropagation();
96
- }
97
- } else if (e.key === "Enter") {
98
- var _focusableChildren$2;
99
- e.preventDefault();
100
- e.stopPropagation();
101
- _this.lockedCell[1] = true;
102
- (_focusableChildren$2 = focusableChildren[0]) === null || _focusableChildren$2 === void 0 ? void 0 : _focusableChildren$2.focus();
103
- }
104
- }
105
- });
106
- _defineProperty(_assertThisInitialized(_this), "onFocusCell", function(e) {
107
- if (e.target === e.currentTarget && e.target.matches(":focus-visible")) {
108
- var focusableChildren = Array.from(e.currentTarget.children).flatMap(function(node) {
109
- return getFocusableIn(node);
110
- });
111
- if (focusableChildren.length === 1) {
112
- focusableChildren[0].focus();
113
- } else if (focusableChildren.length > 1) {
114
- _this.lockedCell = [e.currentTarget, false];
115
- }
116
- }
117
- });
118
- _defineProperty(_assertThisInitialized(_this), "handleFirstRowResize", trottle(function(entries) {
119
- var contentRect = entries[0].contentRect;
120
- var height = contentRect.height;
121
- _this.setState(function(oldState) {
122
- if (oldState.rowHeight === height) return oldState;
123
- return {
124
- rowHeight: height
125
- };
126
- });
127
- }));
128
- _defineProperty(_assertThisInitialized(_this), "handleScrollAreaResize", trottle(function(entries) {
129
- var virtualScroll = _this.asProps.virtualScroll;
130
- if (!virtualScroll) return;
131
- var contentRect = entries[0].contentRect;
132
- var height = contentRect.height;
133
- _this.setState(function(oldState) {
134
- if (oldState.scrollAreaHeight === height) return oldState;
135
- return {
136
- scrollAreaHeight: height
137
- };
138
- });
139
- }));
140
- _defineProperty(_assertThisInitialized(_this), "handleScrollAreaScroll", function(event) {
141
- var _ref6 = event.target, scrollTop = _ref6.scrollTop;
142
- var virtualScroll = _this.asProps.virtualScroll;
143
- if (virtualScroll) {
144
- _this.setState(function(oldState) {
145
- if (oldState.scrollOffset === scrollTop) return oldState;
146
- return {
147
- scrollOffset: scrollTop
148
- };
149
- });
150
- }
151
- });
152
- _defineProperty(_assertThisInitialized(_this), "setupRowSizeObserver", function() {
153
- if (!_this.firstRowRef.current) return;
154
- if (!_this.asProps.virtualScroll) return;
155
- if (canUseDOM()) {
156
- _this.firstRowResizeObserver = new ResizeObserver(_this.handleFirstRowResize);
157
- _this.firstRowResizeObserver.observe(_this.firstRowRef.current);
158
- }
159
- });
160
- _defineProperty(_assertThisInitialized(_this), "handleBodyTransitionEnd", trottle(function() {
161
- _this.forceUpdate();
162
- }));
163
- return _this;
164
- }
165
- _createClass(Body2, [{
166
- key: "renderCells",
167
- value: function renderCells(cells, rowData, dataIndex) {
168
- var _this2 = this;
169
- var SCell = Flex;
170
- var _this$asProps = this.asProps, styles = _this$asProps.styles, columns = _this$asProps.columns, use = _this$asProps.use, uid = _this$asProps.uid;
171
- return cells.map(function(cell, cellIndex) {
172
- if (Array.isArray(cell)) {
173
- var _ref2;
174
- var SGroupCell = "div";
175
- return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(SGroupCell, _ref2.cn("SGroupCell", {
176
- "key": "".concat(cellIndex),
177
- "data-ui-name": "group-cell"
178
- }), _this2.renderRows(cell, true));
179
- } else {
180
- var _ref3, _column$parentColumns, _column$props, _column$props$ref$cur, _column$props2, _column$props2$ref$cu, _column$props3, _column$props4;
181
- var nameParts = cell.name.split("/");
182
- var firstName = nameParts[0];
183
- var lastName = nameParts[nameParts.length - 1];
184
- var firstColumn = columns.find(function(c) {
185
- return c.name === firstName;
186
- });
187
- var lastColumn = columns.find(function(c) {
188
- return c.name === lastName;
189
- });
190
- var column = columns.find(function(c) {
191
- return c.name === cell.name;
192
- });
193
- var _getFixedStyle = getFixedStyle(cell, columns), _getFixedStyle2 = _slicedToArray(_getFixedStyle, 2), name = _getFixedStyle2[0], value = _getFixedStyle2[1];
194
- var parentColumnNames = (_column$parentColumns = column === null || column === void 0 ? void 0 : column.parentColumns.map(function(column2) {
195
- return column2.name;
196
- })) !== null && _column$parentColumns !== void 0 ? _column$parentColumns : [];
197
- var vars = (Array.isArray(cell.cssVar) ? cell.cssVar : [cell.cssVar]).map(function(name2) {
198
- return "var(".concat(name2, ")");
199
- });
200
- var columnWMin = column === null || column === void 0 ? void 0 : (_column$props = column.props) === null || _column$props === void 0 ? void 0 : (_column$props$ref$cur = _column$props.ref.current) === null || _column$props$ref$cur === void 0 ? void 0 : _column$props$ref$cur.style.getPropertyValue("min-width");
201
- var columnWMax = column === null || column === void 0 ? void 0 : (_column$props2 = column.props) === null || _column$props2 === void 0 ? void 0 : (_column$props2$ref$cu = _column$props2.ref.current) === null || _column$props2$ref$cu === void 0 ? void 0 : _column$props2$ref$cu.style.getPropertyValue("max-width");
202
- var _props = {
203
- name: cell.name,
204
- children: /* @__PURE__ */ React.createElement(React.Fragment, null, cell.data),
205
- justifyContent: column === null || column === void 0 ? void 0 : (_column$props3 = column.props) === null || _column$props3 === void 0 ? void 0 : _column$props3.justifyContent,
206
- alignItems: column === null || column === void 0 ? void 0 : (_column$props4 = column.props) === null || _column$props4 === void 0 ? void 0 : _column$props4.alignItems,
207
- borderLeft: firstColumn === null || firstColumn === void 0 ? void 0 : firstColumn.borderLeft,
208
- borderRight: lastColumn === null || lastColumn === void 0 ? void 0 : lastColumn.borderRight,
209
- style: {
210
- width: vars.length === 1 ? vars[0] : "calc(".concat(vars.join(" + "), ")"),
211
- minWidth: columnWMin,
212
- maxWidth: columnWMax && column !== null && column !== void 0 && column.sortable ? "calc(".concat(SORT_ICON_WIDTH, "px + ").concat(columnWMax, ")") : columnWMax
213
- }
214
- };
215
- if (name !== void 0 && value !== void 0) {
216
- _props.style[name] = value;
217
- }
218
- var _iterator = _createForOfIteratorHelper(cell.cellPropsLayers || []), _step;
219
- try {
220
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
221
- var cellPropLayer = _step.value;
222
- var _cellPropLayer$childr = cellPropLayer.childrenPropsGetter, childrenPropsGetter = _cellPropLayer$childr === void 0 ? function(p) {
223
- return p;
224
- } : _cellPropLayer$childr, other = _objectWithoutProperties(cellPropLayer, _excluded);
225
- var propsCell = assignProps(other, _props);
226
- _props = assignProps(childrenPropsGetter(propsCell, rowData, dataIndex), propsCell);
227
- }
228
- } catch (err) {
229
- _iterator.e(err);
230
- } finally {
231
- _iterator.f();
232
- }
233
- var headerIds = [cell.name].concat(_toConsumableArray(parentColumnNames)).filter(Boolean).map(function(name2) {
234
- return "igc-table-".concat(uid, "-").concat(name2);
235
- });
236
- var ariaColspan = nameParts.length;
237
- return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SCell, _ref3.cn("SCell", _objectSpread(_objectSpread({
238
- "key": cell.name,
239
- "role": "gridcell",
240
- "headers": headerIds.join(" "),
241
- "__excludeProps": ["data"]
242
- }, _props), {}, {
243
- "fixed": cell.fixed,
244
- "theme": _props.theme,
245
- "use": use,
246
- "borderLeft": _props.borderLeft,
247
- "borderRight": _props.borderRight,
248
- "tabIndex": -1,
249
- "onKeyDown": _this2.handleKeyDown,
250
- "onFocus": _this2.onFocusCell,
251
- "aria-colindex": cellIndex + 1,
252
- "aria-colspan": ariaColspan === 1 ? void 0 : ariaColspan,
253
- "innerOutline": true
254
- })));
255
- }
256
- }, []);
257
- }
258
- }, {
259
- key: "renderRow",
260
- value: function renderRow(cells, _ref7) {
261
- var _ref4;
262
- var dataIndex = _ref7.dataIndex, topOffset = _ref7.topOffset, _ref7$nested = _ref7.nested, nested = _ref7$nested === void 0 ? false : _ref7$nested;
263
- var SRow = Box;
264
- var _this$asProps2 = this.asProps, styles = _this$asProps2.styles, rowPropsLayers = _this$asProps2.rowPropsLayers, uniqueKey = _this$asProps2.uniqueKey, virtualScroll = _this$asProps2.virtualScroll;
265
- var rowHeightFromProps = _typeof(virtualScroll) === "object" && (virtualScroll === null || virtualScroll === void 0 ? void 0 : virtualScroll.rowHeight);
266
- var rowData = cells.flatRowData || getCellsByColumn(cells);
267
- var key = rowData[uniqueKey] ? String(rowData[uniqueKey]) : "row_".concat(dataIndex);
268
- var needToMeasureHeight = dataIndex === 0 && !rowHeightFromProps;
269
- var props = {
270
- children: this.renderCells(cells, rowData, dataIndex),
271
- theme: void 0,
272
- active: void 0,
273
- positioned: topOffset !== void 0,
274
- top: topOffset,
275
- ref: needToMeasureHeight ? this.firstRowRef : void 0,
276
- key,
277
- "aria-rowindex": !nested ? dataIndex + 2 : void 0
278
- };
279
- var _iterator2 = _createForOfIteratorHelper(rowPropsLayers), _step2;
280
- try {
281
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
282
- var rowPropsLayer = _step2.value;
283
- var _rowPropsLayer$childr = rowPropsLayer.childrenPropsGetter, childrenPropsGetter = _rowPropsLayer$childr === void 0 ? function(p) {
284
- return p;
285
- } : _rowPropsLayer$childr, other = _objectWithoutProperties(rowPropsLayer, _excluded2);
286
- var propsRow = assignProps(other, props);
287
- props = assignProps(childrenPropsGetter(propsRow, rowData, dataIndex), propsRow);
288
- }
289
- } catch (err) {
290
- _iterator2.e(err);
291
- } finally {
292
- _iterator2.f();
293
- }
294
- return _ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(SRow, _ref4.cn("SRow", _objectSpread({
295
- "data-nested": nested.toString(),
296
- "role": !nested ? "row" : void 0,
297
- "__excludeProps": ["data"]
298
- }, props)));
299
- }
300
- }, {
301
- key: "renderRows",
302
- value: function renderRows(rows) {
303
- var _this3 = this;
304
- var nested = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
305
- return rows.map(function(cells, dataIndex) {
306
- return _this3.renderRow(cells, {
307
- dataIndex,
308
- nested
309
- });
310
- });
311
- }
312
- }, {
313
- key: "renderVirtualizedRows",
314
- value: function renderVirtualizedRows(rows) {
315
- var _ref8, _this4 = this;
316
- if (rows.length === 0) return [];
317
- var virtualScroll = this.asProps.virtualScroll;
318
- var _this$state = this.state, scrollOffset = _this$state.scrollOffset, scrollAreaHeight = _this$state.scrollAreaHeight;
319
- var rowHeight = this.getRowHeight();
320
- var tollerance = (_ref8 = _typeof(virtualScroll) === "object" ? virtualScroll === null || virtualScroll === void 0 ? void 0 : virtualScroll.tollerance : 2) !== null && _ref8 !== void 0 ? _ref8 : 2;
321
- var startIndex = Math.max(Math.floor(scrollOffset / rowHeight) - tollerance, 0);
322
- var lastIndex = Math.min(Math.ceil((scrollOffset + scrollAreaHeight) / rowHeight) + tollerance, rows.length);
323
- var rowHeightFromProps = _typeof(virtualScroll) === "object" && (virtualScroll === null || virtualScroll === void 0 ? void 0 : virtualScroll.rowHeight);
324
- var needToMeasureFirstRowHeight = !rowHeightFromProps;
325
- var firstRow = {
326
- cells: rows[0],
327
- dataIndex: 0,
328
- topOffset: 0
329
- };
330
- var visibleRows = rowHeight !== void 0 ? rows.slice(startIndex, lastIndex) : [];
331
- var processedVisibleRows = visibleRows.map(function(cells, index) {
332
- return {
333
- cells,
334
- dataIndex: startIndex + index,
335
- topOffset: rowHeight * (startIndex + index)
336
- };
337
- });
338
- if (needToMeasureFirstRowHeight && startIndex !== 0) {
339
- processedVisibleRows.unshift(firstRow);
340
- }
341
- return processedVisibleRows.map(function(_ref9) {
342
- var cells = _ref9.cells, dataIndex = _ref9.dataIndex, topOffset = _ref9.topOffset;
343
- return _this4.renderRow(cells, {
344
- dataIndex,
345
- topOffset,
346
- nested: false
347
- });
348
- });
349
- }
350
- }, {
351
- key: "componentWillUnmount",
352
- value: function componentWillUnmount() {
353
- var _this$firstRowResizeO;
354
- (_this$firstRowResizeO = this.firstRowResizeObserver) === null || _this$firstRowResizeO === void 0 ? void 0 : _this$firstRowResizeO.disconnect();
355
- }
356
- }, {
357
- key: "render",
358
- value: function render() {
359
- var _ref = this.asProps, _ref5;
360
- var SBody = Box;
361
- var SBodyWrapper = Box;
362
- var SHeightHold = Box;
363
- var _this$asProps3 = this.asProps, Children = _this$asProps3.Children, styles = _this$asProps3.styles, rows = _this$asProps3.rows, columns = _this$asProps3.columns, $scrollRef = _this$asProps3.$scrollRef, virtualScroll = _this$asProps3.virtualScroll, onResize = _this$asProps3.onResize, onScroll = _this$asProps3.onScroll, disabledScroll = _this$asProps3.disabledScroll, renderRows = _this$asProps3.renderRows, animationsDisabled = _this$asProps3.animationsDisabled, scrollContainerRef = _this$asProps3.scrollContainerRef;
364
- var columnsInitialized = columns.reduce(function(sum, _ref10) {
365
- var width = _ref10.width;
366
- return sum + width;
367
- }, 0) > 0 || testEnv;
368
- var _getScrollOffsetValue = getScrollOffsetValue(columns), _getScrollOffsetValue2 = _slicedToArray(_getScrollOffsetValue, 2), offsetLeftSum = _getScrollOffsetValue2[0], offsetRightSum = _getScrollOffsetValue2[1];
369
- var rowHeight = this.getRowHeight();
370
- var holdHeight = rowHeight !== void 0 && virtualScroll ? rowHeight * rows.length : void 0;
371
- if (virtualScroll && columnsInitialized && !rowHeight) {
372
- requestAnimationFrame(this.setupRowSizeObserver);
373
- }
374
- var body = (_ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SBody, _ref5.cn("SBody", _objectSpread({}, assignProps$1({
375
- "animationsDisabled": animationsDisabled,
376
- "onTransitionEnd": this.handleBodyTransitionEnd
377
- }, _ref))), renderRows ? renderRows({
378
- rows,
379
- columns,
380
- renderRow: this.renderRow.bind(this)
381
- }) || null : /* @__PURE__ */ React.createElement(React.Fragment, null, holdHeight ? /* @__PURE__ */ React.createElement(SHeightHold, _ref5.cn("SHeightHold", {
382
- "hMin": holdHeight,
383
- "aria-hidden": true
384
- })) : null, virtualScroll ? this.renderVirtualizedRows(rows) : this.renderRows(rows))));
385
- if (disabledScroll) {
386
- return /* @__PURE__ */ React.createElement(SBodyWrapper, null, body);
387
- }
388
- var scrollContainerRefs = [$scrollRef, this.scrollContainerRef];
389
- if (scrollContainerRef) {
390
- scrollContainerRefs.push(scrollContainerRef);
391
- }
392
- return /* @__PURE__ */ React.createElement(hideScrollBarsFromScreenReadersContext.Provider, {
393
- value: true
394
- }, /* @__PURE__ */ React.createElement(SBodyWrapper, _ref5.cn("SBodyWrapper", {}), /* @__PURE__ */ React.createElement(ScrollArea, _ref5.cn("ScrollArea", {
395
- "shadow": true,
396
- "leftOffset": offsetLeftSum,
397
- "rightOffset": offsetRightSum,
398
- "onResize": callAllEventHandlers(onResize, this.handleScrollAreaResize),
399
- "onScroll": callAllEventHandlers(onScroll, this.handleScrollAreaScroll),
400
- "styles": scrollStyles
401
- }), /* @__PURE__ */ React.createElement(ScrollArea.Container, {
402
- ref: forkRef.apply(void 0, scrollContainerRefs),
403
- role: "rowgroup",
404
- focusRingTopOffset: "3px",
405
- tabIndex: -1
406
- }, body), /* @__PURE__ */ React.createElement("div", _ref5.cn("div", {
407
- "style": displayContents
408
- }), /* @__PURE__ */ React.createElement("div", _ref5.cn("div", {
409
- "style": displayContents
410
- }), /* @__PURE__ */ React.createElement("div", _ref5.cn("div", {
411
- "style": displayContents
412
- }), /* @__PURE__ */ React.createElement(ScrollArea.Bar, {
413
- orientation: "horizontal",
414
- bottom: 0,
415
- container: this.scrollContainerRef
416
- }), /* @__PURE__ */ React.createElement(ScrollArea.Bar, {
417
- orientation: "vertical",
418
- w: "12px",
419
- zIndex: 2
420
- }))))), Children.origin));
421
- }
422
- }]);
423
- return Body2;
424
- }(Component);
425
- export {
426
- Body as default
427
- };