@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 +342 -235
- package/lib/esm/DataTable.mjs +473 -330
- package/lib/esm/Head.mjs +318 -207
- package/lib/esm/index.mjs +6 -6
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
- package/lib/esm/translations/de.json.mjs +5 -4
- package/lib/esm/translations/en.json.mjs +5 -4
- package/lib/esm/translations/es.json.mjs +5 -4
- package/lib/esm/translations/fr.json.mjs +5 -4
- package/lib/esm/translations/it.json.mjs +5 -4
- package/lib/esm/translations/ja.json.mjs +5 -4
- package/lib/esm/translations/ko.json.mjs +5 -4
- package/lib/esm/translations/nl.json.mjs +5 -4
- package/lib/esm/translations/pl.json.mjs +5 -4
- package/lib/esm/translations/pt.json.mjs +5 -4
- package/lib/esm/translations/sv.json.mjs +5 -4
- package/lib/esm/translations/tr.json.mjs +5 -4
- package/lib/esm/translations/vi.json.mjs +5 -4
- package/lib/esm/translations/zh.json.mjs +5 -4
- package/lib/esm/utils.mjs +44 -29
- package/package.json +5 -5
package/lib/esm/Body.mjs
CHANGED
|
@@ -1,320 +1,427 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { sstyled
|
|
14
|
-
import
|
|
15
|
-
import { Flex
|
|
16
|
-
import
|
|
17
|
-
import { getFixedStyle
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { forkRef
|
|
21
|
-
import
|
|
22
|
-
import { SORT_ICON_WIDTH
|
|
23
|
-
import { getFocusableIn
|
|
24
|
-
var
|
|
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
|
-
(
|
|
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
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
}
|
|
42
|
+
};
|
|
43
|
+
var displayContents = {
|
|
40
44
|
display: "contents"
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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 (
|
|
75
|
+
if (_this.lockedCell[1]) {
|
|
62
76
|
if (e.key === "Escape") {
|
|
63
|
-
var
|
|
64
|
-
(
|
|
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
|
|
67
|
-
if (e.target ===
|
|
68
|
-
var
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
78
|
-
e.preventDefault()
|
|
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
|
-
})
|
|
105
|
+
});
|
|
106
|
+
_defineProperty(_assertThisInitialized(_this), "onFocusCell", function(e) {
|
|
82
107
|
if (e.target === e.currentTarget && e.target.matches(":focus-visible")) {
|
|
83
|
-
var
|
|
84
|
-
return
|
|
108
|
+
var focusableChildren = Array.from(e.currentTarget.children).flatMap(function(node) {
|
|
109
|
+
return getFocusableIn(node);
|
|
85
110
|
});
|
|
86
|
-
|
|
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
|
-
})
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
}))
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
})
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}))
|
|
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
|
-
|
|
165
|
+
_createClass(Body2, [{
|
|
119
166
|
key: "renderCells",
|
|
120
|
-
value: function(
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
}),
|
|
178
|
+
}), _this2.renderRows(cell, true));
|
|
129
179
|
} else {
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
name
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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:
|
|
149
|
-
minWidth:
|
|
150
|
-
maxWidth:
|
|
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
|
-
|
|
154
|
-
|
|
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 (
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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 (
|
|
163
|
-
|
|
228
|
+
} catch (err) {
|
|
229
|
+
_iterator.e(err);
|
|
164
230
|
} finally {
|
|
165
|
-
|
|
231
|
+
_iterator.f();
|
|
166
232
|
}
|
|
167
|
-
var
|
|
168
|
-
return "igc-table-".concat(
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"
|
|
185
|
-
"aria-
|
|
186
|
-
|
|
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(
|
|
194
|
-
var
|
|
195
|
-
|
|
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:
|
|
199
|
-
top:
|
|
200
|
-
ref:
|
|
201
|
-
key
|
|
202
|
-
"aria-rowindex":
|
|
203
|
-
}
|
|
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 (
|
|
206
|
-
var
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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 (
|
|
212
|
-
|
|
289
|
+
} catch (err) {
|
|
290
|
+
_iterator2.e(err);
|
|
213
291
|
} finally {
|
|
214
|
-
|
|
292
|
+
_iterator2.f();
|
|
215
293
|
}
|
|
216
|
-
return
|
|
217
|
-
"data-nested":
|
|
218
|
-
role:
|
|
219
|
-
__excludeProps: ["data"]
|
|
220
|
-
},
|
|
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(
|
|
225
|
-
var
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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(
|
|
236
|
-
var
|
|
237
|
-
if (
|
|
238
|
-
var
|
|
239
|
-
|
|
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
|
-
}
|
|
329
|
+
};
|
|
330
|
+
var visibleRows = rowHeight !== void 0 ? rows.slice(startIndex, lastIndex) : [];
|
|
331
|
+
var processedVisibleRows = visibleRows.map(function(cells, index) {
|
|
243
332
|
return {
|
|
244
|
-
cells
|
|
245
|
-
dataIndex:
|
|
246
|
-
topOffset:
|
|
333
|
+
cells,
|
|
334
|
+
dataIndex: startIndex + index,
|
|
335
|
+
topOffset: rowHeight * (startIndex + index)
|
|
247
336
|
};
|
|
248
337
|
});
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
|
262
|
-
(
|
|
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
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
|
|
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__ */
|
|
280
|
-
hMin:
|
|
281
|
-
"aria-hidden":
|
|
282
|
-
})) : null,
|
|
283
|
-
if (
|
|
284
|
-
return /* @__PURE__ */
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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
|
-
},
|
|
301
|
-
style:
|
|
302
|
-
}), /* @__PURE__ */
|
|
303
|
-
style:
|
|
304
|
-
}), /* @__PURE__ */
|
|
305
|
-
style:
|
|
306
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
416
|
+
}), /* @__PURE__ */ React.createElement(ScrollArea.Bar, {
|
|
311
417
|
orientation: "vertical",
|
|
312
418
|
w: "12px",
|
|
313
419
|
zIndex: 2
|
|
314
|
-
}))))),
|
|
420
|
+
}))))), Children.origin));
|
|
315
421
|
}
|
|
316
|
-
}])
|
|
317
|
-
|
|
422
|
+
}]);
|
|
423
|
+
return Body2;
|
|
424
|
+
}(Component);
|
|
318
425
|
export {
|
|
319
|
-
|
|
426
|
+
Body as default
|
|
320
427
|
};
|