@semcore/data-table 4.49.1 → 16.0.0-prerelease.10

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 (37) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/cjs/Body.js +10 -10
  3. package/lib/cjs/Body.js.map +1 -1
  4. package/lib/cjs/DataTable.js +47 -52
  5. package/lib/cjs/DataTable.js.map +1 -1
  6. package/lib/cjs/Head.js +6 -5
  7. package/lib/cjs/Head.js.map +1 -1
  8. package/lib/cjs/style/data-table.shadow.css +0 -19
  9. package/lib/es6/Body.js +11 -10
  10. package/lib/es6/Body.js.map +1 -1
  11. package/lib/es6/DataTable.js +48 -51
  12. package/lib/es6/DataTable.js.map +1 -1
  13. package/lib/es6/Head.js +6 -5
  14. package/lib/es6/Head.js.map +1 -1
  15. package/lib/es6/style/data-table.shadow.css +0 -19
  16. package/lib/esm/Body.mjs +344 -237
  17. package/lib/esm/DataTable.mjs +476 -336
  18. package/lib/esm/Head.mjs +318 -206
  19. package/lib/esm/index.mjs +6 -6
  20. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
  21. package/lib/esm/translations/de.json.mjs +5 -4
  22. package/lib/esm/translations/en.json.mjs +5 -4
  23. package/lib/esm/translations/es.json.mjs +5 -4
  24. package/lib/esm/translations/fr.json.mjs +5 -4
  25. package/lib/esm/translations/it.json.mjs +5 -4
  26. package/lib/esm/translations/ja.json.mjs +5 -4
  27. package/lib/esm/translations/ko.json.mjs +5 -4
  28. package/lib/esm/translations/nl.json.mjs +5 -4
  29. package/lib/esm/translations/pl.json.mjs +5 -4
  30. package/lib/esm/translations/pt.json.mjs +5 -4
  31. package/lib/esm/translations/sv.json.mjs +5 -4
  32. package/lib/esm/translations/tr.json.mjs +5 -4
  33. package/lib/esm/translations/vi.json.mjs +5 -4
  34. package/lib/esm/translations/zh.json.mjs +5 -4
  35. package/lib/esm/utils.mjs +44 -29
  36. package/lib/types/Body.d.ts +1 -1
  37. package/package.json +5 -8
package/lib/esm/Body.mjs CHANGED
@@ -1,320 +1,427 @@
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"], ke = (
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
26
  /*__reshadow_css_start__*/
27
- (Re.insert(
27
+ (sstyled.insert(
28
28
  /*__inner_css_start__*/
29
- ".___SShadowHorizontal_uv7k9_gg_:after,.___SShadowHorizontal_uv7k9_gg_:before,.___SShadowVertical_uv7k9_gg_:after,.___SShadowVertical_uv7k9_gg_:before{z-index:1}",
30
- "uv7k9_gg_"
29
+ ".___SShadowHorizontal_11aq4_gg_:after,.___SShadowHorizontal_11aq4_gg_:before,.___SShadowVertical_11aq4_gg_:after,.___SShadowVertical_11aq4_gg_:before{z-index:1}",
30
+ "11aq4_gg_"
31
31
  ), {
32
- __SShadowHorizontal: "___SShadowHorizontal_uv7k9_gg_",
33
- __SShadowVertical: "___SShadowVertical_uv7k9_gg_"
32
+ "__SShadowHorizontal": "___SShadowHorizontal_11aq4_gg_",
33
+ "__SShadowVertical": "___SShadowVertical_11aq4_gg_"
34
34
  })
35
- ), Ae = 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];
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];
39
41
  }));
40
- }, J = {
42
+ };
43
+ var displayContents = {
41
44
  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", {
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", {
51
57
  rowHeight: void 0,
52
58
  scrollAreaHeight: void 0,
53
59
  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);
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);
61
74
  });
62
- if (r.lockedCell[1]) {
75
+ if (_this.lockedCell[1]) {
63
76
  if (e.key === "Escape") {
64
- var t;
65
- (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();
66
84
  }
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();
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();
74
94
  }
75
95
  e.stopPropagation();
76
96
  }
77
97
  } 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();
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();
80
103
  }
81
104
  }
82
- }), R(p(r), "onFocusCell", function(e) {
105
+ });
106
+ _defineProperty(_assertThisInitialized(_this), "onFocusCell", function(e) {
83
107
  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);
108
+ var focusableChildren = Array.from(e.currentTarget.children).flatMap(function(node) {
109
+ return getFocusableIn(node);
86
110
  });
87
- 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
+ }
88
116
  }
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
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
94
137
  };
95
138
  });
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
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
103
148
  };
104
149
  });
105
150
  }
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;
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;
118
164
  }
119
- return ge(x, [{
165
+ _createClass(Body2, [{
120
166
  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, k = "div";
126
- return S = M(n), /* @__PURE__ */ s.createElement(k, S.cn("SGroupCell", {
127
- key: "".concat(y),
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),
128
177
  "data-ui-name": "group-cell"
129
- }), e.renderRows(d, !0));
178
+ }), _this2.renderRows(cell, true));
130
179
  } else {
131
- var _, H, m, u, w, O, P, z, E = d.name.split("/"), A = E[0], I = E[E.length - 1], b = a.find(function(h) {
132
- return h.name === A;
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,
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,
148
209
  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
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
152
213
  }
153
214
  };
154
- X !== void 0 && Y !== void 0 && (C.style[X] = Y);
155
- var B = 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;
156
219
  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);
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);
162
227
  }
163
- } catch (h) {
164
- B.e(h);
228
+ } catch (err) {
229
+ _iterator.e(err);
165
230
  } finally {
166
- B.f();
231
+ _iterator.f();
167
232
  }
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
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 = K, f = this.asProps, g = f.styles, d = f.rowPropsLayers, y = f.uniqueKey, S = f.virtualScroll, k = j(S) === "object" && (S == null ? void 0 : S.rowHeight), _ = l.flatRowData || Ie(l), H = _[y] ? String(_[y]) : "row_".concat(e), m = e === 0 && !k, 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, A = oe(P, xe), I = G(A, u);
209
- u = G(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 = 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)));
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 = 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, k = {
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 S && g !== 0 && H.unshift(k), 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 = 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, k = 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 || Ae, O = Oe(g), P = ae(O, 2), z = P[0], E = P[1], A = this.getRowHeight(), I = A !== void 0 && y ? A * f.length : void 0;
271
- y && w && !A && 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,
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, 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(k, this.handleScrollAreaScroll),
294
- styles: ke
295
- }), /* @__PURE__ */ s.createElement(W.Container, {
296
- ref: be.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(W.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(W.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
- }(ye);
422
+ }]);
423
+ return Body2;
424
+ }(Component);
318
425
  export {
319
- or as default
426
+ Body as default
320
427
  };