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