@semcore/data-table 16.0.0-prerelease.4 → 16.0.0-prerelease.7

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.
package/lib/esm/Body.mjs CHANGED
@@ -1,320 +1,427 @@
1
- import oe from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import j from "@babel/runtime/helpers/esm/objectSpread2";
3
- import ue from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import ie from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
5
- import ae from "@babel/runtime/helpers/esm/slicedToArray";
6
- import q from "@babel/runtime/helpers/esm/typeof";
7
- import he from "@babel/runtime/helpers/esm/classCallCheck";
8
- import ge from "@babel/runtime/helpers/esm/createClass";
9
- import p from "@babel/runtime/helpers/esm/assertThisInitialized";
10
- import me from "@babel/runtime/helpers/esm/inherits";
11
- import pe from "@babel/runtime/helpers/esm/createSuper";
12
- import R from "@babel/runtime/helpers/esm/defineProperty";
13
- import { sstyled as V, assignProps as Re, Component as we } from "@semcore/core";
14
- import s from "react";
15
- import { Flex as Se, Box as M } from "@semcore/flex-box";
16
- import K, { hideScrollBarsFromScreenReadersContext as ye } from "@semcore/scroll-area";
17
- import { getFixedStyle as _e, getScrollOffsetValue as He } from "./utils.mjs";
18
- import W, { callAllEventHandlers as ne } from "@semcore/core/lib/utils/assignProps";
19
- import N from "@semcore/core/lib/utils/rafTrottle";
20
- import { forkRef as Oe } from "@semcore/core/lib/utils/ref";
21
- import be from "@semcore/core/lib/utils/canUseDOM";
22
- import { SORT_ICON_WIDTH as Pe } from "./Head.mjs";
23
- import { getFocusableIn as le } from "@semcore/core/lib/utils/focus-lock/getFocusableIn";
24
- var ze = ["childrenPropsGetter"], Ee = ["childrenPropsGetter"], xe = (
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 = (
25
26
  /*__reshadow_css_start__*/
26
- (V.insert(
27
+ (sstyled.insert(
27
28
  /*__inner_css_start__*/
28
29
  ".___SShadowHorizontal_11aq4_gg_:after,.___SShadowHorizontal_11aq4_gg_:before,.___SShadowVertical_11aq4_gg_:after,.___SShadowVertical_11aq4_gg_:before{z-index:1}",
29
30
  "11aq4_gg_"
30
31
  ), {
31
- __SShadowHorizontal: "___SShadowHorizontal_11aq4_gg_",
32
- __SShadowVertical: "___SShadowVertical_11aq4_gg_"
32
+ "__SShadowHorizontal": "___SShadowHorizontal_11aq4_gg_",
33
+ "__SShadowVertical": "___SShadowVertical_11aq4_gg_"
33
34
  })
34
- ), Ae = process.env.NODE_ENV === "test", ke = function(F) {
35
- var x = F.flat(20);
36
- return Object.fromEntries(x.map(function(r) {
37
- return [r.name, r.data];
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];
38
41
  }));
39
- }, J = {
42
+ };
43
+ var displayContents = {
40
44
  display: "contents"
41
- }, rr = /* @__PURE__ */ function(Q) {
42
- me(x, Q);
43
- var F = pe(x);
44
- function x() {
45
- var r;
46
- he(this, x);
47
- for (var l = arguments.length, i = new Array(l), c = 0; c < l; c++)
48
- i[c] = arguments[c];
49
- return r = F.call.apply(F, [this].concat(i)), R(p(r), "state", {
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", {
50
57
  rowHeight: void 0,
51
58
  scrollAreaHeight: void 0,
52
59
  scrollOffset: 0
53
- }), R(p(r), "scrollContainerRef", /* @__PURE__ */ s.createRef()), R(p(r), "firstRowRef", /* @__PURE__ */ s.createRef()), R(p(r), "firstRowResizeObserver", null), R(p(r), "lockedCell", [null, !1]), R(p(r), "getRowHeight", function() {
54
- var e = r.asProps.virtualScroll, o = q(e) === "object" && (e == null ? void 0 : e.rowHeight);
55
- return o || r.state.rowHeight;
56
- }), R(p(r), "handleKeyDown", function(e) {
57
- if (e.currentTarget === r.lockedCell[0]) {
58
- var o = Array.from(r.lockedCell[0].children).flatMap(function(g) {
59
- return le(g);
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);
60
74
  });
61
- if (r.lockedCell[1]) {
75
+ if (_this.lockedCell[1]) {
62
76
  if (e.key === "Escape") {
63
- var t;
64
- (t = r.lockedCell[0]) === null || t === void 0 || t.focus(), r.lockedCell[1] = !1;
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();
65
84
  }
66
- if (e.key.startsWith("Arrow") && (e.stopPropagation(), e.preventDefault()), e.key === "Tab") {
67
- if (e.target === o[0] && e.shiftKey) {
68
- var n;
69
- (n = o[o.length - 1]) === null || n === void 0 || n.focus(), e.preventDefault();
70
- } else if (e.target === o[o.length - 1] && !e.shiftKey) {
71
- var a;
72
- (a = o[0]) === null || a === void 0 || a.focus(), e.preventDefault();
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();
73
94
  }
74
95
  e.stopPropagation();
75
96
  }
76
97
  } else if (e.key === "Enter") {
77
- var f;
78
- e.preventDefault(), e.stopPropagation(), r.lockedCell[1] = !0, (f = o[0]) === null || f === void 0 || f.focus();
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();
79
103
  }
80
104
  }
81
- }), R(p(r), "onFocusCell", function(e) {
105
+ });
106
+ _defineProperty(_assertThisInitialized(_this), "onFocusCell", function(e) {
82
107
  if (e.target === e.currentTarget && e.target.matches(":focus-visible")) {
83
- var o = Array.from(e.currentTarget.children).flatMap(function(t) {
84
- return le(t);
108
+ var focusableChildren = Array.from(e.currentTarget.children).flatMap(function(node) {
109
+ return getFocusableIn(node);
85
110
  });
86
- o.length === 1 ? o[0].focus() : o.length > 1 && (r.lockedCell = [e.currentTarget, !1]);
111
+ if (focusableChildren.length === 1) {
112
+ focusableChildren[0].focus();
113
+ } else if (focusableChildren.length > 1) {
114
+ _this.lockedCell = [e.currentTarget, false];
115
+ }
87
116
  }
88
- }), R(p(r), "handleFirstRowResize", N(function(e) {
89
- var o = e[0].contentRect, t = o.height;
90
- r.setState(function(n) {
91
- return n.rowHeight === t ? n : {
92
- rowHeight: t
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
93
137
  };
94
138
  });
95
- })), R(p(r), "handleScrollAreaResize", N(function(e) {
96
- var o = r.asProps.virtualScroll;
97
- if (o) {
98
- var t = e[0].contentRect, n = t.height;
99
- r.setState(function(a) {
100
- return a.scrollAreaHeight === n ? a : {
101
- scrollAreaHeight: n
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
102
148
  };
103
149
  });
104
150
  }
105
- })), R(p(r), "handleScrollAreaScroll", function(e) {
106
- var o = e.target, t = o.scrollTop, n = r.asProps.virtualScroll;
107
- n && r.setState(function(a) {
108
- return a.scrollOffset === t ? a : {
109
- scrollOffset: t
110
- };
111
- });
112
- }), R(p(r), "setupRowSizeObserver", function() {
113
- r.firstRowRef.current && r.asProps.virtualScroll && be() && (r.firstRowResizeObserver = new ResizeObserver(r.handleFirstRowResize), r.firstRowResizeObserver.observe(r.firstRowRef.current));
114
- }), R(p(r), "handleBodyTransitionEnd", N(function() {
115
- r.forceUpdate();
116
- })), r;
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;
117
164
  }
118
- return ge(x, [{
165
+ _createClass(Body2, [{
119
166
  key: "renderCells",
120
- value: function(l, i, c) {
121
- var e = this, o = Se, t = this.asProps, n = t.styles, a = t.columns, f = t.use, g = t.uid;
122
- return l.map(function(d, S) {
123
- if (Array.isArray(d)) {
124
- var y, A = "div";
125
- return y = V(n), /* @__PURE__ */ s.createElement(A, y.cn("SGroupCell", {
126
- key: "".concat(S),
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),
127
177
  "data-ui-name": "group-cell"
128
- }), e.renderRows(d, !0));
178
+ }), _this2.renderRows(cell, true));
129
179
  } else {
130
- var _, H, m, u, w, O, P, z, E = d.name.split("/"), k = E[0], I = E[E.length - 1], b = a.find(function(h) {
131
- return h.name === k;
132
- }), T = a.find(function(h) {
133
- return h.name === I;
134
- }), v = a.find(function(h) {
135
- return h.name === d.name;
136
- }), G = _e(d, a), B = ae(G, 2), X = B[0], Y = B[1], se = (H = v == null ? void 0 : v.parentColumns.map(function(h) {
137
- return h.name;
138
- })) !== null && H !== void 0 ? H : [], L = (Array.isArray(d.cssVar) ? d.cssVar : [d.cssVar]).map(function(h) {
139
- return "var(".concat(h, ")");
140
- }), de = v == null || (m = v.props) === null || m === void 0 || (u = m.ref.current) === null || u === void 0 ? void 0 : u.style.getPropertyValue("min-width"), U = v == null || (w = v.props) === null || w === void 0 || (O = w.ref.current) === null || O === void 0 ? void 0 : O.style.getPropertyValue("max-width"), C = {
141
- name: d.name,
142
- children: /* @__PURE__ */ s.createElement(s.Fragment, null, d.data),
143
- justifyContent: v == null || (P = v.props) === null || P === void 0 ? void 0 : P.justifyContent,
144
- alignItems: v == null || (z = v.props) === null || z === void 0 ? void 0 : z.alignItems,
145
- borderLeft: b == null ? void 0 : b.borderLeft,
146
- borderRight: T == null ? void 0 : T.borderRight,
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,
147
209
  style: {
148
- width: L.length === 1 ? L[0] : "calc(".concat(L.join(" + "), ")"),
149
- minWidth: de,
150
- maxWidth: U && v !== null && v !== void 0 && v.sortable ? "calc(".concat(Pe, "px + ").concat(U, ")") : U
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
151
213
  }
152
214
  };
153
- X !== void 0 && Y !== void 0 && (C.style[X] = Y);
154
- var D = ie(d.cellPropsLayers || []), Z;
215
+ if (name !== void 0 && value !== void 0) {
216
+ _props.style[name] = value;
217
+ }
218
+ var _iterator = _createForOfIteratorHelper(cell.cellPropsLayers || []), _step;
155
219
  try {
156
- for (D.s(); !(Z = D.n()).done; ) {
157
- var $ = Z.value, ee = $.childrenPropsGetter, ve = ee === void 0 ? function(h) {
158
- return h;
159
- } : ee, fe = oe($, ze), re = W(fe, C);
160
- C = W(ve(re, i, c), re);
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);
161
227
  }
162
- } catch (h) {
163
- D.e(h);
228
+ } catch (err) {
229
+ _iterator.e(err);
164
230
  } finally {
165
- D.f();
231
+ _iterator.f();
166
232
  }
167
- var ce = [d.name].concat(ue(se)).filter(Boolean).map(function(h) {
168
- return "igc-table-".concat(g, "-").concat(h);
169
- }), te = E.length;
170
- return _ = V(n), /* @__PURE__ */ s.createElement(o, _.cn("SCell", j(j({
171
- key: d.name,
172
- role: "gridcell",
173
- headers: ce.join(" "),
174
- __excludeProps: ["data"]
175
- }, C), {}, {
176
- fixed: d.fixed,
177
- theme: C.theme,
178
- use: f,
179
- borderLeft: C.borderLeft,
180
- borderRight: C.borderRight,
181
- tabIndex: -1,
182
- onKeyDown: e.handleKeyDown,
183
- onFocus: e.onFocusCell,
184
- "aria-colindex": S + 1,
185
- "aria-colspan": te === 1 ? void 0 : te,
186
- innerOutline: !0
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
187
254
  })));
188
255
  }
189
256
  }, []);
190
257
  }
191
258
  }, {
192
259
  key: "renderRow",
193
- value: function(l, i) {
194
- var c, e = i.dataIndex, o = i.topOffset, t = i.nested, n = t === void 0 ? !1 : t, a = M, f = this.asProps, g = f.styles, d = f.rowPropsLayers, S = f.uniqueKey, y = f.virtualScroll, A = q(y) === "object" && (y == null ? void 0 : y.rowHeight), _ = l.flatRowData || ke(l), H = _[S] ? String(_[S]) : "row_".concat(e), m = e === 0 && !A, u = {
195
- children: this.renderCells(l, _, e),
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),
196
271
  theme: void 0,
197
272
  active: void 0,
198
- positioned: o !== void 0,
199
- top: o,
200
- ref: m ? this.firstRowRef : void 0,
201
- key: H,
202
- "aria-rowindex": n ? void 0 : e + 2
203
- }, w = ie(d), O;
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;
204
280
  try {
205
- for (w.s(); !(O = w.n()).done; ) {
206
- var P = O.value, z = P.childrenPropsGetter, E = z === void 0 ? function(b) {
207
- return b;
208
- } : z, k = oe(P, Ee), I = W(k, u);
209
- u = W(E(I, _, e), I);
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);
210
288
  }
211
- } catch (b) {
212
- w.e(b);
289
+ } catch (err) {
290
+ _iterator2.e(err);
213
291
  } finally {
214
- w.f();
292
+ _iterator2.f();
215
293
  }
216
- return c = V(g), /* @__PURE__ */ s.createElement(a, c.cn("SRow", j({
217
- "data-nested": n.toString(),
218
- role: n ? void 0 : "row",
219
- __excludeProps: ["data"]
220
- }, u)));
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)));
221
299
  }
222
300
  }, {
223
301
  key: "renderRows",
224
- value: function(l) {
225
- var i = this, c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
226
- return l.map(function(e, o) {
227
- return i.renderRow(e, {
228
- dataIndex: o,
229
- nested: c
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
230
309
  });
231
310
  });
232
311
  }
233
312
  }, {
234
313
  key: "renderVirtualizedRows",
235
- value: function(l) {
236
- var i, c = this;
237
- if (l.length === 0) return [];
238
- var e = this.asProps.virtualScroll, o = this.state, t = o.scrollOffset, n = o.scrollAreaHeight, a = this.getRowHeight(), f = (i = q(e) === "object" ? e == null ? void 0 : e.tollerance : 2) !== null && i !== void 0 ? i : 2, g = Math.max(Math.floor(t / a) - f, 0), d = Math.min(Math.ceil((t + n) / a) + f, l.length), S = q(e) === "object" && (e == null ? void 0 : e.rowHeight), y = !S, A = {
239
- cells: l[0],
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],
240
327
  dataIndex: 0,
241
328
  topOffset: 0
242
- }, _ = a !== void 0 ? l.slice(g, d) : [], H = _.map(function(m, u) {
329
+ };
330
+ var visibleRows = rowHeight !== void 0 ? rows.slice(startIndex, lastIndex) : [];
331
+ var processedVisibleRows = visibleRows.map(function(cells, index) {
243
332
  return {
244
- cells: m,
245
- dataIndex: g + u,
246
- topOffset: a * (g + u)
333
+ cells,
334
+ dataIndex: startIndex + index,
335
+ topOffset: rowHeight * (startIndex + index)
247
336
  };
248
337
  });
249
- return y && g !== 0 && H.unshift(A), H.map(function(m) {
250
- var u = m.cells, w = m.dataIndex, O = m.topOffset;
251
- return c.renderRow(u, {
252
- dataIndex: w,
253
- topOffset: O,
254
- nested: !1
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
255
347
  });
256
348
  });
257
349
  }
258
350
  }, {
259
351
  key: "componentWillUnmount",
260
- value: function() {
261
- var l;
262
- (l = this.firstRowResizeObserver) === null || l === void 0 || l.disconnect();
352
+ value: function componentWillUnmount() {
353
+ var _this$firstRowResizeO;
354
+ (_this$firstRowResizeO = this.firstRowResizeObserver) === null || _this$firstRowResizeO === void 0 ? void 0 : _this$firstRowResizeO.disconnect();
263
355
  }
264
356
  }, {
265
357
  key: "render",
266
- value: function() {
267
- var l = this.asProps, i, c = M, e = M, o = M, t = this.asProps, n = t.Children, a = t.styles, f = t.rows, g = t.columns, d = t.$scrollRef, S = t.virtualScroll, y = t.onResize, A = t.onScroll, _ = t.disabledScroll, H = t.renderRows, m = t.animationsDisabled, u = t.scrollContainerRef, w = g.reduce(function(v, G) {
268
- var B = G.width;
269
- return v + B;
270
- }, 0) > 0 || Ae, O = He(g), P = ae(O, 2), z = P[0], E = P[1], k = this.getRowHeight(), I = k !== void 0 && S ? k * f.length : void 0;
271
- S && w && !k && requestAnimationFrame(this.setupRowSizeObserver);
272
- var b = (i = V(a), /* @__PURE__ */ s.createElement(c, i.cn("SBody", j({}, Re({
273
- animationsDisabled: m,
274
- onTransitionEnd: this.handleBodyTransitionEnd
275
- }, l))), H ? H({
276
- rows: f,
277
- columns: g,
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,
278
380
  renderRow: this.renderRow.bind(this)
279
- }) || null : /* @__PURE__ */ s.createElement(s.Fragment, null, I ? /* @__PURE__ */ s.createElement(o, i.cn("SHeightHold", {
280
- hMin: I,
281
- "aria-hidden": !0
282
- })) : null, S ? this.renderVirtualizedRows(f) : this.renderRows(f))));
283
- if (_)
284
- return /* @__PURE__ */ s.createElement(e, null, b);
285
- var T = [d, this.scrollContainerRef];
286
- return u && T.push(u), /* @__PURE__ */ s.createElement(ye.Provider, {
287
- value: !0
288
- }, /* @__PURE__ */ s.createElement(e, i.cn("SBodyWrapper", {}), /* @__PURE__ */ s.createElement(K, i.cn("ScrollArea", {
289
- shadow: !0,
290
- leftOffset: z,
291
- rightOffset: E,
292
- onResize: ne(y, this.handleScrollAreaResize),
293
- onScroll: ne(A, this.handleScrollAreaScroll),
294
- styles: xe
295
- }), /* @__PURE__ */ s.createElement(K.Container, {
296
- ref: Oe.apply(void 0, T),
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),
297
403
  role: "rowgroup",
298
404
  focusRingTopOffset: "3px",
299
405
  tabIndex: -1
300
- }, b), /* @__PURE__ */ s.createElement("div", i.cn("div", {
301
- style: J
302
- }), /* @__PURE__ */ s.createElement("div", i.cn("div", {
303
- style: J
304
- }), /* @__PURE__ */ s.createElement("div", i.cn("div", {
305
- style: J
306
- }), /* @__PURE__ */ s.createElement(K.Bar, {
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, {
307
413
  orientation: "horizontal",
308
414
  bottom: 0,
309
415
  container: this.scrollContainerRef
310
- }), /* @__PURE__ */ s.createElement(K.Bar, {
416
+ }), /* @__PURE__ */ React.createElement(ScrollArea.Bar, {
311
417
  orientation: "vertical",
312
418
  w: "12px",
313
419
  zIndex: 2
314
- }))))), n.origin));
420
+ }))))), Children.origin));
315
421
  }
316
- }]), x;
317
- }(we);
422
+ }]);
423
+ return Body2;
424
+ }(Component);
318
425
  export {
319
- rr as default
426
+ Body as default
320
427
  };