@semcore/data-table 4.50.0 → 4.50.1

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