@semcore/data-table 16.5.3-prerelease.4 → 17.0.0-prerelease.17
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/AccordionRows/AccordionRows.js +144 -157
- package/lib/cjs/components/AccordionRows/AccordionRows.js.map +1 -1
- package/lib/cjs/components/Body/Body.js +373 -395
- package/lib/cjs/components/Body/Body.js.map +1 -1
- package/lib/cjs/components/Body/Cell.js +135 -151
- package/lib/cjs/components/Body/Cell.js.map +1 -1
- package/lib/cjs/components/Body/LimitOverlay.js +142 -158
- package/lib/cjs/components/Body/LimitOverlay.js.map +1 -1
- package/lib/cjs/components/Body/MergedCells.js +25 -23
- package/lib/cjs/components/Body/MergedCells.js.map +1 -1
- package/lib/cjs/components/Body/Row.js +498 -539
- package/lib/cjs/components/Body/Row.js.map +1 -1
- package/lib/cjs/components/DataTable/DataTable.js +867 -938
- package/lib/cjs/components/DataTable/DataTable.js.map +1 -1
- package/lib/cjs/components/Head/Column.js +208 -234
- package/lib/cjs/components/Head/Column.js.map +1 -1
- package/lib/cjs/components/Head/Group.js +79 -92
- package/lib/cjs/components/Head/Group.js.map +1 -1
- package/lib/cjs/components/Head/Head.js +229 -263
- package/lib/cjs/components/Head/Head.js.map +1 -1
- package/lib/cjs/enhancers/focusableCell.js +6 -14
- package/lib/cjs/enhancers/focusableCell.js.map +1 -1
- package/lib/cjs/index.js +7 -14
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/components/AccordionRows/AccordionRows.js +142 -156
- package/lib/es6/components/AccordionRows/AccordionRows.js.map +1 -1
- package/lib/es6/components/Body/Body.js +370 -392
- package/lib/es6/components/Body/Body.js.map +1 -1
- package/lib/es6/components/Body/Cell.js +131 -147
- package/lib/es6/components/Body/Cell.js.map +1 -1
- package/lib/es6/components/Body/LimitOverlay.js +138 -154
- package/lib/es6/components/Body/LimitOverlay.js.map +1 -1
- package/lib/es6/components/Body/MergedCells.js +22 -22
- package/lib/es6/components/Body/MergedCells.js.map +1 -1
- package/lib/es6/components/Body/Row.js +493 -535
- package/lib/es6/components/Body/Row.js.map +1 -1
- package/lib/es6/components/DataTable/DataTable.js +861 -932
- package/lib/es6/components/DataTable/DataTable.js.map +1 -1
- package/lib/es6/components/Head/Column.js +201 -228
- package/lib/es6/components/Head/Column.js.map +1 -1
- package/lib/es6/components/Head/Group.js +74 -88
- package/lib/es6/components/Head/Group.js.map +1 -1
- package/lib/es6/components/Head/Head.js +228 -262
- package/lib/es6/components/Head/Head.js.map +1 -1
- package/lib/es6/enhancers/focusableCell.js +6 -14
- package/lib/es6/enhancers/focusableCell.js.map +1 -1
- package/lib/es6/index.js +3 -9
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/components/AccordionRows/AccordionRows.mjs +143 -134
- package/lib/esm/components/Body/Body.mjs +377 -343
- package/lib/esm/components/Body/Cell.mjs +136 -135
- package/lib/esm/components/Body/LimitOverlay.mjs +141 -144
- package/lib/esm/components/Body/MergedCells.mjs +22 -22
- package/lib/esm/components/Body/Row.mjs +498 -458
- package/lib/esm/components/DataTable/DataTable.mjs +866 -842
- package/lib/esm/components/Head/Column.mjs +208 -201
- package/lib/esm/components/Head/Group.mjs +76 -84
- package/lib/esm/components/Head/Head.mjs +231 -216
- package/lib/esm/enhancers/focusableCell.mjs +7 -14
- package/lib/esm/index.mjs +2 -5
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/types/components/Body/Cell.d.ts +1 -3
- package/lib/types/components/Body/Row.d.ts +1 -1
- package/lib/types/components/Head/Column.d.ts +2 -2
- package/lib/types/components/Head/Group.d.ts +1 -1
- package/lib/types/index.d.ts +2 -6
- package/package.json +20 -22
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.UNIQ_ROW_KEY = exports.SELECT_ALL = exports.ROW_INDEX = exports.ROW_GROUP = exports.IS_EMPTY_DATA_ROW = exports.GRID_ROW_INDEX = exports.DataTable = exports.ACCORDION = void 0;
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
|
-
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
13
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
10
|
var _core = require("@semcore/core");
|
|
19
11
|
var _baseComponents = require("@semcore/base-components");
|
|
@@ -22,7 +14,7 @@ var _i18nEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhan
|
|
|
22
14
|
var _findComponent = _interopRequireDefault(require("@semcore/core/lib/utils/findComponent"));
|
|
23
15
|
var _hasParent = require("@semcore/core/lib/utils/hasParent");
|
|
24
16
|
var _rafTrottle = _interopRequireDefault(require("@semcore/core/lib/utils/rafTrottle"));
|
|
25
|
-
var
|
|
17
|
+
var _ref3 = require("@semcore/core/lib/utils/ref");
|
|
26
18
|
var _uniqueID = _interopRequireDefault(require("@semcore/core/lib/utils/uniqueID"));
|
|
27
19
|
var _useFocusLock = require("@semcore/core/lib/utils/use/useFocusLock");
|
|
28
20
|
var _widgetEmpty = require("@semcore/widget-empty");
|
|
@@ -32,96 +24,103 @@ var _Body = require("../Body/Body");
|
|
|
32
24
|
var _MergedCells = require("../Body/MergedCells");
|
|
33
25
|
var _Head = require("../Head/Head");
|
|
34
26
|
/*!__reshadow-styles__:"./dataTable.shadow.css"*/
|
|
35
|
-
|
|
27
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SDataTable_wo0cb_gg_{display:grid;align-items:start;min-width:-moz-fit-content;min-width:fit-content;grid-auto-rows:min-content}.___SDataTable_wo0cb_gg_.__isDataEmpty_wo0cb_gg_{display:block;align-items:initial;min-width:initial}.___SDataTable_wo0cb_gg_.__gridTemplateColumns_wo0cb_gg_{grid-template-columns:var(--gridTemplateColumns_wo0cb)}.___SDataTable_wo0cb_gg_.__gridTemplateAreas_wo0cb_gg_{grid-template-areas:var(--gridTemplateAreas_wo0cb)}.___SDataTable_wo0cb_gg_.__gridTemplateRows_wo0cb_gg_{grid-template-rows:var(--gridTemplateRows_wo0cb)}", /*__inner_css_end__*/"wo0cb_gg_"),
|
|
36
28
|
/*__reshadow_css_end__*/
|
|
37
29
|
{
|
|
38
|
-
"__SDataTable": "
|
|
39
|
-
"_isDataEmpty": "
|
|
40
|
-
"_gridTemplateColumns": "
|
|
41
|
-
"--gridTemplateColumns": "--
|
|
42
|
-
"_gridTemplateAreas": "
|
|
43
|
-
"--gridTemplateAreas": "--
|
|
44
|
-
"_gridTemplateRows": "
|
|
45
|
-
"--gridTemplateRows": "--
|
|
30
|
+
"__SDataTable": "___SDataTable_wo0cb_gg_",
|
|
31
|
+
"_isDataEmpty": "__isDataEmpty_wo0cb_gg_",
|
|
32
|
+
"_gridTemplateColumns": "__gridTemplateColumns_wo0cb_gg_",
|
|
33
|
+
"--gridTemplateColumns": "--gridTemplateColumns_wo0cb",
|
|
34
|
+
"_gridTemplateAreas": "__gridTemplateAreas_wo0cb_gg_",
|
|
35
|
+
"--gridTemplateAreas": "--gridTemplateAreas_wo0cb",
|
|
36
|
+
"_gridTemplateRows": "__gridTemplateRows_wo0cb_gg_",
|
|
37
|
+
"--gridTemplateRows": "--gridTemplateRows_wo0cb"
|
|
46
38
|
});
|
|
47
39
|
/*!__reshadow-styles__:"../../style/scroll-shadows.shadow.css"*/
|
|
48
|
-
|
|
40
|
+
const scrollStyles = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SScrollArea_j4820_gg_{width:-moz-fit-content;width:fit-content}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_{overflow:visible;overflow:initial}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_both_j4820_gg_{overflow:auto}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_both_j4820_gg_.__loading_j4820_gg_,.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_horizontal_j4820_gg_.__loading_j4820_gg_,.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_vertical_j4820_gg_.__loading_j4820_gg_{overflow:hidden}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_horizontal_j4820_gg_{overflow-x:auto;overflow-y:initial}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_._scrollDirection_vertical_j4820_gg_{overflow-x:initial;overflow-y:auto}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_.__headerHeight_j4820_gg_{scroll-padding-top:var(--headerHeight_j4820)}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_.__leftScrollPadding_j4820_gg_{scroll-padding-left:var(--leftScrollPadding_j4820)}.___SScrollArea_j4820_gg_ .___SContainer_j4820_gg_.__rightScrollPadding_j4820_gg_{scroll-padding-right:var(--rightScrollPadding_j4820)}.___SScrollArea_j4820_gg_ .___SShadowHorizontal_j4820_gg_::before,.___SScrollArea_j4820_gg_ .___SShadowHorizontal_j4820_gg_:after,.___SScrollArea_j4820_gg_ .___SShadowVertical_j4820_gg_::after{z-index:20}.___SScrollArea_j4820_gg_ .___SShadowHorizontal_j4820_gg_.__leftOffset_j4820_gg_::before,.___SScrollArea_j4820_gg_ .___SShadowHorizontal_j4820_gg_.__rightOffset_j4820_gg_::after,.___SScrollArea_j4820_gg_ .___SShadowVertical_j4820_gg_::before{display:none}", /*__inner_css_end__*/"j4820_gg_"),
|
|
49
41
|
/*__reshadow_css_end__*/
|
|
50
42
|
{
|
|
51
|
-
"__SScrollArea": "
|
|
52
|
-
"__SContainer": "
|
|
53
|
-
"_scrollDirection_both": "
|
|
54
|
-
"_loading": "
|
|
55
|
-
"_scrollDirection_horizontal": "
|
|
56
|
-
"_scrollDirection_vertical": "
|
|
57
|
-
"_headerHeight": "
|
|
58
|
-
"--headerHeight": "--
|
|
59
|
-
"_leftScrollPadding": "
|
|
60
|
-
"--leftScrollPadding": "--
|
|
61
|
-
"_rightScrollPadding": "
|
|
62
|
-
"--rightScrollPadding": "--
|
|
63
|
-
"__SShadowVertical": "
|
|
64
|
-
"__SShadowHorizontal": "
|
|
65
|
-
"_leftOffset": "
|
|
66
|
-
"_rightOffset": "
|
|
43
|
+
"__SScrollArea": "___SScrollArea_j4820_gg_",
|
|
44
|
+
"__SContainer": "___SContainer_j4820_gg_",
|
|
45
|
+
"_scrollDirection_both": "_scrollDirection_both_j4820_gg_",
|
|
46
|
+
"_loading": "__loading_j4820_gg_",
|
|
47
|
+
"_scrollDirection_horizontal": "_scrollDirection_horizontal_j4820_gg_",
|
|
48
|
+
"_scrollDirection_vertical": "_scrollDirection_vertical_j4820_gg_",
|
|
49
|
+
"_headerHeight": "__headerHeight_j4820_gg_",
|
|
50
|
+
"--headerHeight": "--headerHeight_j4820",
|
|
51
|
+
"_leftScrollPadding": "__leftScrollPadding_j4820_gg_",
|
|
52
|
+
"--leftScrollPadding": "--leftScrollPadding_j4820",
|
|
53
|
+
"_rightScrollPadding": "__rightScrollPadding_j4820_gg_",
|
|
54
|
+
"--rightScrollPadding": "--rightScrollPadding_j4820",
|
|
55
|
+
"__SShadowVertical": "___SShadowVertical_j4820_gg_",
|
|
56
|
+
"__SShadowHorizontal": "___SShadowHorizontal_j4820_gg_",
|
|
57
|
+
"_leftOffset": "__leftOffset_j4820_gg_",
|
|
58
|
+
"_rightOffset": "__rightOffset_j4820_gg_"
|
|
67
59
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(
|
|
87
|
-
(0, _defineProperty2
|
|
88
|
-
(0, _defineProperty2
|
|
89
|
-
(0, _defineProperty2
|
|
90
|
-
(0, _defineProperty2
|
|
91
|
-
(0, _defineProperty2
|
|
92
|
-
(0, _defineProperty2
|
|
93
|
-
(0, _defineProperty2
|
|
94
|
-
(0, _defineProperty2
|
|
95
|
-
(0, _defineProperty2
|
|
96
|
-
(0, _defineProperty2
|
|
97
|
-
(0, _defineProperty2
|
|
60
|
+
const ACCORDION = exports.ACCORDION = Symbol('accordion');
|
|
61
|
+
const ROW_GROUP = exports.ROW_GROUP = Symbol('ROW_GROUP');
|
|
62
|
+
const UNIQ_ROW_KEY = exports.UNIQ_ROW_KEY = Symbol('UNIQ_ROW_KEY');
|
|
63
|
+
const IS_EMPTY_DATA_ROW = exports.IS_EMPTY_DATA_ROW = Symbol('IS_EMPTY_DATA_ROW');
|
|
64
|
+
const SELECT_ALL = exports.SELECT_ALL = Symbol('SELECT_ALL');
|
|
65
|
+
const ROW_INDEX = exports.ROW_INDEX = Symbol('ROW_INDEX');
|
|
66
|
+
const GRID_ROW_INDEX = exports.GRID_ROW_INDEX = Symbol('GRID_ROW_INDEX');
|
|
67
|
+
const SCROLL_BAR_HEIGHT = 12;
|
|
68
|
+
class DataTableRoot extends _core.Component {
|
|
69
|
+
static getDerivedStateFromProps(props, state) {
|
|
70
|
+
if (props.expandedRows === state.expandedRows || props.expandedRows === undefined) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
expandedRows: props.expandedRows
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
constructor(props) {
|
|
78
|
+
super(props);
|
|
79
|
+
(0, _defineProperty2.default)(this, "columns", []);
|
|
80
|
+
(0, _defineProperty2.default)(this, "treeColumns", []);
|
|
81
|
+
(0, _defineProperty2.default)(this, "hasGroups", false);
|
|
82
|
+
(0, _defineProperty2.default)(this, "hasFixedColumn", false);
|
|
83
|
+
(0, _defineProperty2.default)(this, "focusedCell", [-1, -1]);
|
|
84
|
+
(0, _defineProperty2.default)(this, "scrollAreaRef", /*#__PURE__*/React.createRef());
|
|
85
|
+
(0, _defineProperty2.default)(this, "tableContainerRef", /*#__PURE__*/React.createRef());
|
|
86
|
+
(0, _defineProperty2.default)(this, "tableRef", /*#__PURE__*/React.createRef());
|
|
87
|
+
(0, _defineProperty2.default)(this, "headerRef", /*#__PURE__*/React.createRef());
|
|
88
|
+
(0, _defineProperty2.default)(this, "spinnerRef", /*#__PURE__*/React.createRef());
|
|
89
|
+
(0, _defineProperty2.default)(this, "containerResizeEndTimeoutId", null);
|
|
90
|
+
(0, _defineProperty2.default)(this, "gridAreaGroupMap", new Map());
|
|
91
|
+
(0, _defineProperty2.default)(this, "columnsSplitter", '/');
|
|
92
|
+
(0, _defineProperty2.default)(this, "tmpData", void 0);
|
|
93
|
+
(0, _defineProperty2.default)(this, "calculatedRows", void 0);
|
|
94
|
+
(0, _defineProperty2.default)(this, "flatRows", void 0);
|
|
95
|
+
(0, _defineProperty2.default)(this, "gridSettings", {
|
|
98
96
|
gridTemplateColumns: [],
|
|
99
97
|
gridTemplateAreas: []
|
|
100
98
|
});
|
|
101
|
-
(0, _defineProperty2
|
|
102
|
-
(0, _defineProperty2
|
|
103
|
-
(0, _defineProperty2
|
|
104
|
-
(0, _defineProperty2
|
|
105
|
-
(0, _defineProperty2
|
|
99
|
+
(0, _defineProperty2.default)(this, "selectAllMessageTimer", 0);
|
|
100
|
+
(0, _defineProperty2.default)(this, "headerNodesMap", new Map());
|
|
101
|
+
(0, _defineProperty2.default)(this, "isPressedShift", false);
|
|
102
|
+
(0, _defineProperty2.default)(this, "lastSelectedRowKey", void 0);
|
|
103
|
+
(0, _defineProperty2.default)(this, "state", {
|
|
106
104
|
scrollTop: 0,
|
|
107
105
|
scrollDirection: 'down',
|
|
108
106
|
selectAllMessage: '',
|
|
109
107
|
shadowVertical: '',
|
|
110
108
|
expandedRows: new Set()
|
|
111
109
|
});
|
|
112
|
-
(0, _defineProperty2
|
|
113
|
-
|
|
114
|
-
var tableContainer = _this.tableContainerRef.current;
|
|
110
|
+
(0, _defineProperty2.default)(this, "handleDocumentScroll", (0, _rafTrottle.default)(() => {
|
|
111
|
+
const tableContainer = this.tableContainerRef.current;
|
|
115
112
|
if (!tableContainer) return;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
const tableContainerTop = tableContainer.getBoundingClientRect().top;
|
|
114
|
+
const {
|
|
115
|
+
headerProps
|
|
116
|
+
} = this.asProps;
|
|
117
|
+
const headerContainer = this.headerRef.current;
|
|
118
|
+
const elements = headerContainer?.querySelectorAll('[role="columnheader"], [data-ui-name="Head.Group"]');
|
|
119
|
+
const top = tableContainerTop - (headerProps?.top ?? 0);
|
|
120
|
+
const headerScrollBar = headerProps?.withScrollBar ? this.scrollAreaRef.current?.querySelector(`[role=scrollbar][aria-orientation=horizontal]`) : undefined;
|
|
122
121
|
if (top && top < 0) {
|
|
123
|
-
|
|
124
|
-
elements
|
|
122
|
+
const translate = `translateY(${Math.abs(top)}px)`;
|
|
123
|
+
elements?.forEach(column => {
|
|
125
124
|
if (column instanceof HTMLElement) {
|
|
126
125
|
column.style.setProperty('transform', translate);
|
|
127
126
|
}
|
|
@@ -130,7 +129,7 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
130
129
|
headerScrollBar.style.setProperty('transform', translate);
|
|
131
130
|
}
|
|
132
131
|
} else {
|
|
133
|
-
elements
|
|
132
|
+
elements?.forEach(column => {
|
|
134
133
|
if (column instanceof HTMLElement) {
|
|
135
134
|
column.style.removeProperty('transform');
|
|
136
135
|
}
|
|
@@ -140,175 +139,165 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
141
|
}));
|
|
143
|
-
(0, _defineProperty2
|
|
142
|
+
(0, _defineProperty2.default)(this, "handleCellClick", (e, opt) => {
|
|
144
143
|
if (_core.lastInteraction.isMouse()) {
|
|
145
|
-
|
|
144
|
+
this.initFocusableCell([this.hasFocusableInHeader() ? opt.rowIndex + 1 : opt.rowIndex, opt.colIndex]);
|
|
146
145
|
}
|
|
147
146
|
});
|
|
148
|
-
(0, _defineProperty2
|
|
149
|
-
|
|
150
|
-
selectedRows
|
|
151
|
-
onSelectedRowsChange
|
|
147
|
+
(0, _defineProperty2.default)(this, "handleSelectRow", (isSelected, selectedRowIndex, row, event) => {
|
|
148
|
+
const {
|
|
149
|
+
selectedRows,
|
|
150
|
+
onSelectedRowsChange
|
|
151
|
+
} = this.asProps;
|
|
152
152
|
if (!selectedRows || !onSelectedRowsChange) return;
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (!select && (item[UNIQ_ROW_KEY] === row[UNIQ_ROW_KEY] || item[UNIQ_ROW_KEY] === _this.lastSelectedRowKey)) {
|
|
167
|
-
select = true;
|
|
168
|
-
if (isSelected) {
|
|
169
|
-
selectedRowsSet.add(item[UNIQ_ROW_KEY]);
|
|
170
|
-
} else {
|
|
171
|
-
selectedRowsSet["delete"](item[UNIQ_ROW_KEY]);
|
|
172
|
-
}
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (select) {
|
|
176
|
-
if (isSelected) {
|
|
177
|
-
selectedRowsSet.add(item[UNIQ_ROW_KEY]);
|
|
178
|
-
} else {
|
|
179
|
-
selectedRowsSet["delete"](item[UNIQ_ROW_KEY]);
|
|
180
|
-
}
|
|
153
|
+
const selectedRowsSet = new Set(selectedRows);
|
|
154
|
+
if (this.isPressedShift && selectedRowsSet.size > 0 && this.lastSelectedRowKey && (isSelected ? selectedRowsSet.has(this.lastSelectedRowKey) : true)) {
|
|
155
|
+
let select = false;
|
|
156
|
+
const firstColumnKey = this.columns[0].name;
|
|
157
|
+
const isMerged = this.flatRows.some(item => item[firstColumnKey] instanceof _MergedCells.MergedRowsCell);
|
|
158
|
+
for (const item of this.flatRows) {
|
|
159
|
+
if (isMerged && !item[firstColumnKey]) continue;
|
|
160
|
+
if (!select && (item[UNIQ_ROW_KEY] === row[UNIQ_ROW_KEY] || item[UNIQ_ROW_KEY] === this.lastSelectedRowKey)) {
|
|
161
|
+
select = true;
|
|
162
|
+
if (isSelected) {
|
|
163
|
+
selectedRowsSet.add(item[UNIQ_ROW_KEY]);
|
|
164
|
+
} else {
|
|
165
|
+
selectedRowsSet.delete(item[UNIQ_ROW_KEY]);
|
|
181
166
|
}
|
|
182
|
-
|
|
183
|
-
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (select) {
|
|
170
|
+
if (isSelected) {
|
|
171
|
+
selectedRowsSet.add(item[UNIQ_ROW_KEY]);
|
|
172
|
+
} else {
|
|
173
|
+
selectedRowsSet.delete(item[UNIQ_ROW_KEY]);
|
|
184
174
|
}
|
|
185
175
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
_iterator.f();
|
|
176
|
+
if (select && (item[UNIQ_ROW_KEY] === row[UNIQ_ROW_KEY] || item[UNIQ_ROW_KEY] === this.lastSelectedRowKey)) {
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
190
179
|
}
|
|
191
180
|
} else {
|
|
192
181
|
if (selectedRowsSet.has(row[UNIQ_ROW_KEY])) {
|
|
193
|
-
selectedRowsSet
|
|
182
|
+
selectedRowsSet.delete(row[UNIQ_ROW_KEY]);
|
|
194
183
|
} else {
|
|
195
184
|
selectedRowsSet.add(row[UNIQ_ROW_KEY]);
|
|
196
185
|
}
|
|
197
186
|
}
|
|
198
|
-
|
|
187
|
+
this.lastSelectedRowKey = row[UNIQ_ROW_KEY];
|
|
199
188
|
onSelectedRowsChange(Array.from(selectedRowsSet), event, {
|
|
200
|
-
selectedRowIndex
|
|
201
|
-
isSelected
|
|
202
|
-
row
|
|
189
|
+
selectedRowIndex,
|
|
190
|
+
isSelected,
|
|
191
|
+
row
|
|
203
192
|
});
|
|
204
193
|
});
|
|
205
|
-
(0, _defineProperty2
|
|
206
|
-
if (
|
|
207
|
-
clearTimeout(
|
|
194
|
+
(0, _defineProperty2.default)(this, "setSelectAllMessage", selectedAll => {
|
|
195
|
+
if (this.selectAllMessageTimer) {
|
|
196
|
+
clearTimeout(this.selectAllMessageTimer);
|
|
208
197
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
198
|
+
const {
|
|
199
|
+
getI18nText
|
|
200
|
+
} = this.asProps;
|
|
201
|
+
const message = getI18nText(selectedAll ? 'DataTable.allItemsSelected:aria-live' : 'DataTable.allItemsDeselected:aria-live');
|
|
202
|
+
this.setState({
|
|
212
203
|
selectAllMessage: message
|
|
213
204
|
});
|
|
214
|
-
|
|
215
|
-
|
|
205
|
+
this.selectAllMessageTimer = window.setTimeout(() => {
|
|
206
|
+
this.setState({
|
|
216
207
|
selectAllMessage: ''
|
|
217
208
|
});
|
|
218
209
|
}, 5000);
|
|
219
210
|
});
|
|
220
|
-
(0, _defineProperty2
|
|
221
|
-
|
|
222
|
-
return (_this$tableRef$curren = _this.tableRef.current) === null || _this$tableRef$curren === void 0 ? void 0 : _this$tableRef$curren.querySelector(":scope [aria-rowindex=\"".concat(index + 1, "\"]:not([aria-hidden=\"true\"]):not(:scope [data-ui-name=\"DataTable\"] [aria-rowindex=\"").concat(index + 1, "\"]:not([aria-hidden=\"true\"])"));
|
|
211
|
+
(0, _defineProperty2.default)(this, "getRow", index => {
|
|
212
|
+
return this.tableRef.current?.querySelector(`:scope [aria-rowindex="${index + 1}"]:not([aria-hidden="true"]):not(:scope [data-ui-name="DataTable"] [aria-rowindex="${index + 1}"]:not([aria-hidden="true"])`);
|
|
223
213
|
});
|
|
224
|
-
(0, _defineProperty2
|
|
225
|
-
return
|
|
226
|
-
return column.sortable;
|
|
227
|
-
});
|
|
214
|
+
(0, _defineProperty2.default)(this, "hasFocusableInHeader", () => {
|
|
215
|
+
return this.headerRef.current && (0, _useFocusLock.hasFocusableIn)(this.headerRef.current) || this.columns.some(column => column.sortable);
|
|
228
216
|
});
|
|
229
|
-
(0, _defineProperty2
|
|
230
|
-
|
|
231
|
-
onAccordionToggle
|
|
232
|
-
accordionMode
|
|
233
|
-
|
|
217
|
+
(0, _defineProperty2.default)(this, "onExpandRow", expandedRow => {
|
|
218
|
+
const {
|
|
219
|
+
onAccordionToggle,
|
|
220
|
+
accordionMode
|
|
221
|
+
} = this.asProps;
|
|
222
|
+
const expandedRows = this.state.expandedRows;
|
|
234
223
|
if (expandedRows.has(expandedRow[UNIQ_ROW_KEY])) {
|
|
235
|
-
expandedRows
|
|
236
|
-
onAccordionToggle
|
|
224
|
+
expandedRows.delete(expandedRow[UNIQ_ROW_KEY]);
|
|
225
|
+
onAccordionToggle?.('close', expandedRow[UNIQ_ROW_KEY], expandedRow[ROW_INDEX]);
|
|
237
226
|
} else {
|
|
238
227
|
expandedRows.add(expandedRow[UNIQ_ROW_KEY]);
|
|
239
|
-
onAccordionToggle
|
|
228
|
+
onAccordionToggle?.('open', expandedRow[UNIQ_ROW_KEY], expandedRow[ROW_INDEX]);
|
|
240
229
|
if (accordionMode === 'toggle') {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
230
|
+
const rowIndex = expandedRow[ROW_INDEX];
|
|
231
|
+
const colIndex = this.focusedCell[1];
|
|
232
|
+
this.initFocusableCell([this.hasFocusableInHeader() ? rowIndex + 1 : rowIndex, colIndex]);
|
|
244
233
|
}
|
|
245
234
|
}
|
|
246
235
|
});
|
|
247
|
-
(0, _defineProperty2
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
236
|
+
(0, _defineProperty2.default)(this, "changeFocusCell", (rowIndex, colIndex, direction) => {
|
|
237
|
+
const {
|
|
238
|
+
limit
|
|
239
|
+
} = this.asProps;
|
|
240
|
+
const hasFocusable = this.hasFocusableInHeader();
|
|
241
|
+
const maxCol = this.columns.length - 1;
|
|
242
|
+
const maxRow = this.totalRows || 1;
|
|
243
|
+
const currentRow = this.tableRef.current?.querySelector(`[aria-rowindex="${this.focusedCell[0] + 1}"]`);
|
|
244
|
+
const headerCells = this.tableRef.current?.querySelectorAll('[role=columnheader]');
|
|
245
|
+
const currentCell = currentRow?.querySelector(`[role=gridcell][aria-colindex='${this.focusedCell[1] + 1}']`);
|
|
246
|
+
const currentHeaderCell = headerCells?.item(this.focusedCell[1]);
|
|
247
|
+
let changed = true;
|
|
248
|
+
const newRow = this.focusedCell[0] + rowIndex;
|
|
249
|
+
const newCol = this.focusedCell[1] + colIndex;
|
|
250
|
+
if ((hasFocusable && newRow < 0 || !hasFocusable && newRow < 1 || newRow > maxRow) && newRow !== this.focusedCell[0]) {
|
|
261
251
|
changed = false;
|
|
262
252
|
}
|
|
263
|
-
if ((newCol < 0 || newCol > maxCol) && newCol !==
|
|
253
|
+
if ((newCol < 0 || newCol > maxCol) && newCol !== this.focusedCell[1]) {
|
|
264
254
|
changed = false;
|
|
265
255
|
}
|
|
266
256
|
if (!changed) return;
|
|
267
|
-
|
|
268
|
-
|
|
257
|
+
const row = this.getRow(newRow);
|
|
258
|
+
const cell = row?.querySelector(`:scope > div > [role=gridcell][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"]), :scope > [role=columnheader][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"]), :scope > div > [role=columnheader][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"])`);
|
|
269
259
|
if (cell instanceof HTMLElement && currentCell !== cell) {
|
|
270
|
-
|
|
271
|
-
currentCell
|
|
260
|
+
this.focusedCell = [newRow, newCol];
|
|
261
|
+
currentCell?.setAttribute('inert', '');
|
|
272
262
|
if (currentCell !== currentHeaderCell) {
|
|
273
|
-
currentCell
|
|
263
|
+
currentCell?.removeAttribute('aria-describedby');
|
|
274
264
|
}
|
|
275
|
-
|
|
276
|
-
|
|
265
|
+
const headerCell = headerCells?.item(newCol);
|
|
266
|
+
const describedBy = headerCell?.getAttribute('aria-describedby');
|
|
277
267
|
cell.removeAttribute('inert');
|
|
278
268
|
if (headerCell !== cell && describedBy) {
|
|
279
269
|
cell.setAttribute('aria-describedby', describedBy);
|
|
280
270
|
}
|
|
281
|
-
cell
|
|
271
|
+
cell?.focus({
|
|
282
272
|
focusVisible: true
|
|
283
273
|
});
|
|
284
274
|
if (newRow !== 0) {
|
|
285
|
-
currentHeaderCell
|
|
286
|
-
|
|
287
|
-
|
|
275
|
+
currentHeaderCell?.setAttribute('inert', '');
|
|
276
|
+
const headerCell = headerCells?.item(newCol);
|
|
277
|
+
headerCell?.removeAttribute('inert');
|
|
288
278
|
}
|
|
289
279
|
} else if (cell === null && currentCell instanceof HTMLElement) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
280
|
+
let rowI = rowIndex;
|
|
281
|
+
let colI = colIndex;
|
|
282
|
+
const colspan = Number(currentCell.getAttribute('aria-colspan'));
|
|
283
|
+
const rowspan = Number(currentCell.getAttribute('aria-rowspan'));
|
|
294
284
|
if (direction === 'left' || direction === 'right') {
|
|
295
|
-
var _currentCell$parentEl;
|
|
296
285
|
// we need to skip Collapse Element with one big component from keyboard left/right pressing
|
|
297
|
-
if (
|
|
286
|
+
if (currentCell.parentElement?.parentElement?.dataset.uiName === 'Collapse') {
|
|
298
287
|
return;
|
|
299
288
|
}
|
|
300
289
|
// skipping x-axis movement of the focus within limit overlay and there is only limit by rows
|
|
301
|
-
if (
|
|
290
|
+
if (limit?.fromRow !== undefined && limit.fromColumn === undefined && newCol === limit.fromRow) {
|
|
302
291
|
return;
|
|
303
292
|
}
|
|
304
|
-
|
|
293
|
+
const hasRowSpanUpper = row instanceof HTMLElement && Number(row.dataset.filledColumns) < this.columns.length;
|
|
305
294
|
if (colspan > 0) {
|
|
306
|
-
if (direction === 'right' &&
|
|
295
|
+
if (direction === 'right' && limit?.fromColumn !== undefined && newCol === limit.fromColumn) {
|
|
307
296
|
rowI = rowI - 1;
|
|
308
297
|
} else {
|
|
309
298
|
colI = direction === 'left' ? colI - colspan + 1 : colI + colspan - 1;
|
|
310
299
|
}
|
|
311
|
-
} else if (hasRowSpanUpper || direction === 'right' && (
|
|
300
|
+
} else if (hasRowSpanUpper || direction === 'right' && (limit?.fromColumn !== undefined || limit?.fromRow !== undefined)) {
|
|
312
301
|
rowI = rowI - 1;
|
|
313
302
|
} else {
|
|
314
303
|
colI = direction === 'left' ? colI - 1 : colI + 1;
|
|
@@ -320,92 +309,92 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
320
309
|
} else if (Number(currentCell.getAttribute('aria-colindex')) === 1) {
|
|
321
310
|
rowI = direction === 'up' ? rowI - 1 : rowI + 1;
|
|
322
311
|
} else {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (areLimitsDefined && newRow > ((_limit$fromRow = limit === null || limit === void 0 ? void 0 : limit.fromRow) !== null && _limit$fromRow !== void 0 ? _limit$fromRow : 0) + 1) {
|
|
312
|
+
const areLimitsDefined = limit?.fromRow !== undefined || limit?.fromColumn !== undefined;
|
|
313
|
+
if (areLimitsDefined && newRow > (limit?.fromRow ?? 0) + 1) {
|
|
326
314
|
return;
|
|
327
315
|
}
|
|
328
|
-
|
|
329
|
-
if (direction === 'up' &&
|
|
316
|
+
const hasRowSpanUpper = row instanceof HTMLElement && currentRow instanceof HTMLElement && row.dataset.filledColumns !== currentRow.dataset.filledColumns;
|
|
317
|
+
if (direction === 'up' && hasRowSpanUpper) {
|
|
330
318
|
rowI = rowI - 1;
|
|
331
319
|
} else {
|
|
332
320
|
colI = colI - 1;
|
|
333
321
|
}
|
|
334
322
|
}
|
|
335
323
|
}
|
|
336
|
-
|
|
324
|
+
this.changeFocusCell(rowI, colI, direction);
|
|
337
325
|
} else if (cell === null && currentHeaderCell instanceof HTMLElement && direction === 'down') {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
} else if (row === null &&
|
|
341
|
-
|
|
326
|
+
const colI = colIndex - 1;
|
|
327
|
+
this.changeFocusCell(rowIndex, colI, direction);
|
|
328
|
+
} else if (row === null && this.focusedCell[0] === 0 && direction === 'down' && this.asProps.virtualScroll) {
|
|
329
|
+
this.changeFocusCell(rowIndex + 1, colIndex, direction);
|
|
342
330
|
}
|
|
343
331
|
});
|
|
344
|
-
(0, _defineProperty2
|
|
332
|
+
(0, _defineProperty2.default)(this, "handleKeyDown", e => {
|
|
345
333
|
switch (e.key) {
|
|
346
334
|
case 'Tab':
|
|
347
335
|
{
|
|
348
|
-
|
|
336
|
+
this.setInert(true);
|
|
349
337
|
break;
|
|
350
338
|
}
|
|
351
339
|
case 'ArrowLeft':
|
|
352
340
|
{
|
|
353
341
|
e.preventDefault();
|
|
354
|
-
|
|
342
|
+
this.changeFocusCell(0, -1, 'left');
|
|
355
343
|
break;
|
|
356
344
|
}
|
|
357
345
|
case 'ArrowRight':
|
|
358
346
|
{
|
|
359
347
|
e.preventDefault();
|
|
360
|
-
|
|
348
|
+
this.changeFocusCell(0, 1, 'right');
|
|
361
349
|
break;
|
|
362
350
|
}
|
|
363
351
|
case 'ArrowUp':
|
|
364
352
|
{
|
|
365
353
|
e.preventDefault();
|
|
366
|
-
|
|
354
|
+
this.changeFocusCell(-1, 0, 'up');
|
|
367
355
|
break;
|
|
368
356
|
}
|
|
369
357
|
case 'ArrowDown':
|
|
370
358
|
{
|
|
371
359
|
e.preventDefault();
|
|
372
|
-
|
|
360
|
+
this.changeFocusCell(1, 0, 'down');
|
|
373
361
|
break;
|
|
374
362
|
}
|
|
375
363
|
case 'Shift':
|
|
376
364
|
{
|
|
377
|
-
|
|
365
|
+
this.isPressedShift = true;
|
|
378
366
|
}
|
|
379
367
|
}
|
|
380
368
|
});
|
|
381
|
-
(0, _defineProperty2
|
|
369
|
+
(0, _defineProperty2.default)(this, "handleKeyUp", e => {
|
|
382
370
|
if (e.key === 'Shift') {
|
|
383
|
-
|
|
371
|
+
this.isPressedShift = false;
|
|
384
372
|
}
|
|
385
373
|
});
|
|
386
|
-
(0, _defineProperty2
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
scrollTop
|
|
392
|
-
scrollDirection
|
|
374
|
+
(0, _defineProperty2.default)(this, "handleScroll", (0, _rafTrottle.default)(e => {
|
|
375
|
+
if (this.asProps.virtualScroll) {
|
|
376
|
+
const scrollTop = e.target.scrollTop;
|
|
377
|
+
const scrollDirection = scrollTop > this.state.scrollTop ? 'down' : 'up';
|
|
378
|
+
this.setState({
|
|
379
|
+
scrollTop,
|
|
380
|
+
scrollDirection
|
|
393
381
|
});
|
|
394
382
|
}
|
|
395
|
-
if (
|
|
396
|
-
|
|
383
|
+
if (this.hasFixedColumn) {
|
|
384
|
+
this.calculateVerticalShadow();
|
|
397
385
|
}
|
|
398
386
|
}));
|
|
399
|
-
(0, _defineProperty2
|
|
400
|
-
if (!
|
|
401
|
-
|
|
402
|
-
scrollWidth
|
|
403
|
-
clientWidth
|
|
404
|
-
scrollLeft
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
387
|
+
(0, _defineProperty2.default)(this, "calculateVerticalShadow", () => {
|
|
388
|
+
if (!this.tableContainerRef.current) return;
|
|
389
|
+
const {
|
|
390
|
+
scrollWidth,
|
|
391
|
+
clientWidth,
|
|
392
|
+
scrollLeft
|
|
393
|
+
} = this.tableContainerRef.current;
|
|
394
|
+
const maxScrollRight = scrollWidth - clientWidth;
|
|
395
|
+
const roundedScroll = Math.round(scrollLeft);
|
|
396
|
+
const roundedMaxScroll = Math.round(maxScrollRight);
|
|
397
|
+
let shadow = '';
|
|
409
398
|
// not scroll
|
|
410
399
|
if (roundedMaxScroll <= 0) {
|
|
411
400
|
// start scroll
|
|
@@ -418,46 +407,41 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
418
407
|
} else if (roundedScroll > 0) {
|
|
419
408
|
shadow = 'median';
|
|
420
409
|
}
|
|
421
|
-
|
|
410
|
+
this.setState({
|
|
422
411
|
shadowVertical: shadow
|
|
423
412
|
});
|
|
424
413
|
});
|
|
425
|
-
(0, _defineProperty2
|
|
426
|
-
if (
|
|
427
|
-
|
|
428
|
-
(_this$spinnerRef$curr = _this.spinnerRef.current) === null || _this$spinnerRef$curr === void 0 || _this$spinnerRef$curr.focus();
|
|
414
|
+
(0, _defineProperty2.default)(this, "handleFocus", e => {
|
|
415
|
+
if (this.asProps.loading) {
|
|
416
|
+
this.spinnerRef.current?.focus();
|
|
429
417
|
e.currentTarget.setAttribute('tabIndex', '-1');
|
|
430
|
-
if (
|
|
431
|
-
|
|
432
|
-
(_this$headerRef$curre = _this.headerRef.current) === null || _this$headerRef$curre === void 0 || _this$headerRef$curre.setAttribute('tabIndex', '-1');
|
|
418
|
+
if (this.isDataEmpty) {
|
|
419
|
+
this.headerRef.current?.setAttribute('tabIndex', '-1');
|
|
433
420
|
}
|
|
434
421
|
} else if ((!e.relatedTarget || !(0, _useFocusLock.isFocusInside)(e.currentTarget, e.relatedTarget)) && _core.lastInteraction.isKeyboard()) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
_this.initFocusableCell();
|
|
422
|
+
if (this.focusedCell[0] === -1 && this.focusedCell[1] === -1) {
|
|
423
|
+
this.initFocusableCell();
|
|
438
424
|
}
|
|
439
|
-
|
|
440
|
-
|
|
425
|
+
this.setInert(true);
|
|
426
|
+
let row = this.getRow(this.focusedCell[0]);
|
|
441
427
|
if (!row) {
|
|
442
|
-
|
|
443
|
-
row =
|
|
428
|
+
this.initFocusableCell();
|
|
429
|
+
row = this.getRow(this.focusedCell[0]);
|
|
444
430
|
}
|
|
445
|
-
if (!row &&
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
var firstAvailableRow = firstAvailableCell === null || firstAvailableCell === void 0 || (_firstAvailableCell$p = firstAvailableCell.parentElement) === null || _firstAvailableCell$p === void 0 ? void 0 : _firstAvailableCell$p.parentElement;
|
|
431
|
+
if (!row && this.asProps.virtualScroll) {
|
|
432
|
+
const firstAvailableCell = this.tableRef.current?.querySelector(`[role="gridcell"]`);
|
|
433
|
+
const firstAvailableRow = firstAvailableCell?.parentElement?.parentElement;
|
|
449
434
|
if (firstAvailableCell && firstAvailableRow) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
_this.focusedCell[1] = colIndex;
|
|
435
|
+
const colIndex = Number(firstAvailableCell.getAttribute('aria-colindex') ?? 1) - 1;
|
|
436
|
+
const rowIndex = Number(firstAvailableRow.getAttribute('aria-rowindex') ?? 1) - 1;
|
|
437
|
+
this.focusedCell[0] = rowIndex;
|
|
438
|
+
this.focusedCell[1] = colIndex;
|
|
455
439
|
row = firstAvailableRow;
|
|
456
440
|
}
|
|
457
441
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
cell
|
|
442
|
+
const colindex = this.focusedCell[1];
|
|
443
|
+
const cell = colindex > -1 ? row?.querySelector(`[role=gridcell][aria-colindex="${colindex + 1}"]:not([aria-hidden="true"]), [role=columnheader][aria-colindex="${colindex + 1}"]:not([aria-hidden="true"])`) : undefined;
|
|
444
|
+
cell?.removeAttribute('inert');
|
|
461
445
|
if (cell instanceof HTMLElement) {
|
|
462
446
|
if ((0, _hasParent.hasParent)(e.target, cell) && !e.target.dataset.skipTargetFocus) {
|
|
463
447
|
e.target.focus({
|
|
@@ -469,58 +453,53 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
469
453
|
});
|
|
470
454
|
}
|
|
471
455
|
}
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
(_this$headerRef$curre2 = _this.headerRef.current) === null || _this$headerRef$curre2 === void 0 || _this$headerRef$curre2.setAttribute('tabIndex', '-1');
|
|
456
|
+
if (this.isDataEmpty) {
|
|
457
|
+
this.headerRef.current?.setAttribute('tabIndex', '-1');
|
|
475
458
|
}
|
|
476
459
|
e.currentTarget.setAttribute('tabIndex', '-1');
|
|
477
460
|
}
|
|
478
461
|
});
|
|
479
|
-
(0, _defineProperty2
|
|
480
|
-
|
|
481
|
-
|
|
462
|
+
(0, _defineProperty2.default)(this, "handleBlur", e => {
|
|
463
|
+
const relatedTarget = e.relatedTarget;
|
|
464
|
+
const tableElement = this.tableRef.current;
|
|
482
465
|
if (tableElement && (!relatedTarget || !(0, _useFocusLock.isFocusInside)(tableElement, relatedTarget) || !_core.lastInteraction.isKeyboard())) {
|
|
483
|
-
|
|
466
|
+
this.setInert(false);
|
|
484
467
|
tableElement.setAttribute('tabIndex', '0');
|
|
485
|
-
if (
|
|
486
|
-
|
|
487
|
-
(_this$headerRef$curre3 = _this.headerRef.current) === null || _this$headerRef$curre3 === void 0 || _this$headerRef$curre3.setAttribute('tabIndex', '0');
|
|
468
|
+
if (this.isDataEmpty) {
|
|
469
|
+
this.headerRef.current?.setAttribute('tabIndex', '0');
|
|
488
470
|
}
|
|
489
471
|
}
|
|
490
472
|
});
|
|
491
|
-
(0, _defineProperty2
|
|
492
|
-
|
|
473
|
+
(0, _defineProperty2.default)(this, "handleMouseMove", () => {
|
|
474
|
+
this.setInert(false);
|
|
493
475
|
});
|
|
494
|
-
(0, _defineProperty2
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
});
|
|
498
|
-
_this.changeFocusCell(-1, cellIndex === -1 ? 0 : cellIndex, 'up');
|
|
476
|
+
(0, _defineProperty2.default)(this, "handleBackFromAccordion", key => {
|
|
477
|
+
const cellIndex = this.columns.findIndex(c => c.name === key);
|
|
478
|
+
this.changeFocusCell(-1, cellIndex === -1 ? 0 : cellIndex, 'up');
|
|
499
479
|
});
|
|
500
|
-
(0, _defineProperty2
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
clearTimeout(_this.containerResizeEndTimeoutId);
|
|
480
|
+
(0, _defineProperty2.default)(this, "handleContainerResizeEnd", (entries, observer) => {
|
|
481
|
+
if (this.containerResizeEndTimeoutId) {
|
|
482
|
+
clearTimeout(this.containerResizeEndTimeoutId);
|
|
504
483
|
}
|
|
505
|
-
|
|
506
|
-
|
|
484
|
+
this.containerResizeEndTimeoutId = setTimeout(this.calculateVerticalShadow, 0);
|
|
485
|
+
this.asProps.onResize?.(entries, observer);
|
|
507
486
|
});
|
|
508
|
-
(0, _defineProperty2
|
|
509
|
-
if (!
|
|
487
|
+
(0, _defineProperty2.default)(this, "getScrollOffsetValue", () => {
|
|
488
|
+
if (!this.headerRef.current) {
|
|
510
489
|
return [0, 0];
|
|
511
490
|
}
|
|
512
|
-
|
|
491
|
+
const setToMap = element => {
|
|
513
492
|
if (element.getAttribute('name') && element.dataset.uiName === 'Head.Column') {
|
|
514
|
-
|
|
493
|
+
const name = element.getAttribute('name');
|
|
515
494
|
if (name) {
|
|
516
|
-
|
|
495
|
+
this.headerNodesMap.set(name, element);
|
|
517
496
|
}
|
|
518
497
|
}
|
|
519
498
|
};
|
|
520
|
-
|
|
499
|
+
this.headerRef.current.childNodes.forEach(node => {
|
|
521
500
|
if (node instanceof HTMLElement) {
|
|
522
501
|
if (node.classList.value.includes('SGroupContainer')) {
|
|
523
|
-
node.childNodes.forEach(
|
|
502
|
+
node.childNodes.forEach(columnNode => {
|
|
524
503
|
if (columnNode instanceof HTMLElement) {
|
|
525
504
|
setToMap(columnNode);
|
|
526
505
|
}
|
|
@@ -530,387 +509,362 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
530
509
|
}
|
|
531
510
|
}
|
|
532
511
|
});
|
|
533
|
-
return
|
|
512
|
+
return this.columns.reduce((acc, column) => {
|
|
534
513
|
if (column.fixed === 'left') {
|
|
535
|
-
|
|
536
|
-
acc[0] += (_this$headerNodesMap$ = (_this$headerNodesMap$2 = _this.headerNodesMap.get(column.name)) === null || _this$headerNodesMap$2 === void 0 ? void 0 : _this$headerNodesMap$2.getBoundingClientRect().width) !== null && _this$headerNodesMap$ !== void 0 ? _this$headerNodesMap$ : 0;
|
|
514
|
+
acc[0] += this.headerNodesMap.get(column.name)?.getBoundingClientRect().width ?? 0;
|
|
537
515
|
}
|
|
538
516
|
if (column.fixed === 'right') {
|
|
539
|
-
|
|
540
|
-
acc[1] += (_this$headerNodesMap$3 = (_this$headerNodesMap$4 = _this.headerNodesMap.get(column.name)) === null || _this$headerNodesMap$4 === void 0 ? void 0 : _this$headerNodesMap$4.getBoundingClientRect().width) !== null && _this$headerNodesMap$3 !== void 0 ? _this$headerNodesMap$3 : 0;
|
|
517
|
+
acc[1] += this.headerNodesMap.get(column.name)?.getBoundingClientRect().width ?? 0;
|
|
541
518
|
}
|
|
542
519
|
return acc;
|
|
543
520
|
}, [0, 0]);
|
|
544
521
|
});
|
|
545
|
-
(0, _defineProperty2
|
|
546
|
-
|
|
522
|
+
(0, _defineProperty2.default)(this, "getFixedStyle", cell => {
|
|
523
|
+
const side = cell.fixed;
|
|
547
524
|
if (!side) return [undefined, undefined];
|
|
548
|
-
|
|
549
|
-
|
|
525
|
+
const names = cell.name.split('/');
|
|
526
|
+
const nameSideMap = {
|
|
550
527
|
left: names[0],
|
|
551
528
|
right: names[names.length - 1]
|
|
552
529
|
};
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
return column.name === name;
|
|
556
|
-
});
|
|
530
|
+
const name = nameSideMap[side];
|
|
531
|
+
const index = this.columns.findIndex(column => column.name === name);
|
|
557
532
|
if (index === -1) return [undefined, undefined];
|
|
558
|
-
|
|
533
|
+
const startIndexSideMap = {
|
|
559
534
|
left: 0,
|
|
560
535
|
right: index + 1
|
|
561
536
|
};
|
|
562
|
-
|
|
537
|
+
const endIndexSideMap = {
|
|
563
538
|
left: index,
|
|
564
|
-
right:
|
|
539
|
+
right: this.columns.length
|
|
565
540
|
};
|
|
566
|
-
|
|
541
|
+
const columnsFixed = this.columns.slice(startIndexSideMap[side], endIndexSideMap[side]);
|
|
567
542
|
if (columnsFixed.length < 1) return [side, 0];
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
return acc + ((_this$headerNodesMap$5 = _this.headerNodesMap.get(column.name)) === null || _this$headerNodesMap$5 === void 0 ? void 0 : _this$headerNodesMap$5.getBoundingClientRect().width);
|
|
571
|
-
}, 0);
|
|
572
|
-
return [side, "".concat(sum, "px")];
|
|
543
|
+
const sum = columnsFixed.reduce((acc, column) => acc + this.headerNodesMap.get(column.name)?.getBoundingClientRect().width, 0);
|
|
544
|
+
return [side, `${sum}px`];
|
|
573
545
|
});
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
return _this;
|
|
546
|
+
const cols = this.calculateColumnsFromConfig();
|
|
547
|
+
this.columns = cols[0];
|
|
548
|
+
this.treeColumns = cols[1];
|
|
549
|
+
this.calculatedRows = this.getRows();
|
|
550
|
+
this.flatRows = this.calculatedRows.flat();
|
|
551
|
+
this.tmpData = props.data;
|
|
581
552
|
}
|
|
582
|
-
(
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
loading = _this$asProps4.loading;
|
|
590
|
-
if (headerProps !== null && headerProps !== void 0 && headerProps.sticky && !headerProps.h || loading || this.hasFixedColumn) {
|
|
591
|
-
requestAnimationFrame(function () {
|
|
592
|
-
_this2.forceUpdate();
|
|
593
|
-
_this2.calculateVerticalShadow();
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
if (headerProps !== null && headerProps !== void 0 && headerProps.sticky && (0, _canUseDOM["default"])() && this.scrollDirection === 'horizontal') {
|
|
597
|
-
document.addEventListener('scroll', this.handleDocumentScroll);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}, {
|
|
601
|
-
key: "componentDidUpdate",
|
|
602
|
-
value: function componentDidUpdate(prevProps) {
|
|
603
|
-
var _this$asProps5 = this.asProps,
|
|
604
|
-
data = _this$asProps5.data,
|
|
605
|
-
selectedRows = _this$asProps5.selectedRows,
|
|
606
|
-
columns = _this$asProps5.columns;
|
|
607
|
-
if (prevProps.columns !== columns) {
|
|
608
|
-
var cols = this.calculateColumnsFromConfig();
|
|
609
|
-
this.columns = cols[0];
|
|
610
|
-
this.treeColumns = cols[1];
|
|
553
|
+
componentDidMount() {
|
|
554
|
+
const {
|
|
555
|
+
headerProps,
|
|
556
|
+
loading
|
|
557
|
+
} = this.asProps;
|
|
558
|
+
if (headerProps?.sticky && !headerProps.h || loading || this.hasFixedColumn) {
|
|
559
|
+
requestAnimationFrame(() => {
|
|
611
560
|
this.forceUpdate();
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
if (this.hasFixedColumn) {
|
|
615
|
-
this.calculateVerticalShadow();
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
if (prevProps.selectedRows !== selectedRows && selectedRows !== undefined) {
|
|
619
|
-
var selectedRowsSet = new Set(selectedRows);
|
|
620
|
-
var allChecked = [];
|
|
621
|
-
var allUnchecked = [];
|
|
622
|
-
this.flatRows.forEach(function (row) {
|
|
623
|
-
if (selectedRowsSet.has(row[UNIQ_ROW_KEY])) {
|
|
624
|
-
allChecked.push(row[UNIQ_ROW_KEY]);
|
|
625
|
-
} else {
|
|
626
|
-
allUnchecked.push(row[UNIQ_ROW_KEY]);
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
if (allChecked.length === data.length) {
|
|
630
|
-
this.setSelectAllMessage(true);
|
|
631
|
-
} else if (allUnchecked.length === data.length) {
|
|
632
|
-
this.setSelectAllMessage(false);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
561
|
+
this.calculateVerticalShadow();
|
|
562
|
+
});
|
|
635
563
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
value: function componentWillUnmount() {
|
|
639
|
-
var _this$state$expandedR;
|
|
640
|
-
if ((0, _canUseDOM["default"])()) {
|
|
641
|
-
document.removeEventListener('scroll', this.handleDocumentScroll);
|
|
642
|
-
}
|
|
643
|
-
(_this$state$expandedR = this.state.expandedRows) === null || _this$state$expandedR === void 0 || _this$state$expandedR.clear();
|
|
564
|
+
if (headerProps?.sticky && (0, _canUseDOM.default)() && this.scrollDirection === 'horizontal') {
|
|
565
|
+
document.addEventListener('scroll', this.handleDocumentScroll);
|
|
644
566
|
}
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
if (Array.isArray(_expandedRows)) {
|
|
658
|
-
acc = acc + _expandedRows.length;
|
|
659
|
-
} else {
|
|
660
|
-
acc = acc + 1;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
return acc;
|
|
664
|
-
}, 0);
|
|
665
|
-
if (totalRows !== undefined) {
|
|
666
|
-
return totalRows + expandedRowsCount;
|
|
667
|
-
}
|
|
668
|
-
var rows = this.getRows().reduce(function (acc, item) {
|
|
669
|
-
if (Array.isArray(item)) {
|
|
670
|
-
acc = acc + item.length;
|
|
671
|
-
} else {
|
|
672
|
-
acc = acc + 1;
|
|
673
|
-
}
|
|
674
|
-
return acc;
|
|
675
|
-
}, 0);
|
|
676
|
-
return rows + expandedRowsCount;
|
|
567
|
+
}
|
|
568
|
+
componentDidUpdate(prevProps) {
|
|
569
|
+
const {
|
|
570
|
+
data,
|
|
571
|
+
selectedRows,
|
|
572
|
+
columns
|
|
573
|
+
} = this.asProps;
|
|
574
|
+
if (prevProps.columns !== columns) {
|
|
575
|
+
const cols = this.calculateColumnsFromConfig();
|
|
576
|
+
this.columns = cols[0];
|
|
577
|
+
this.treeColumns = cols[1];
|
|
578
|
+
this.forceUpdate();
|
|
677
579
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
var _this$asProps6 = this.asProps,
|
|
682
|
-
w = _this$asProps6.w,
|
|
683
|
-
wMax = _this$asProps6.wMax,
|
|
684
|
-
h = _this$asProps6.h,
|
|
685
|
-
hMax = _this$asProps6.hMax;
|
|
686
|
-
var scrollDirection = undefined;
|
|
687
|
-
var hasWidthSettings = Boolean(w) || Boolean(wMax);
|
|
688
|
-
var hasHeightSettings = Boolean(h) && h !== 'fit-content' || Boolean(hMax);
|
|
689
|
-
if (hasWidthSettings && !hasHeightSettings) {
|
|
690
|
-
scrollDirection = 'horizontal';
|
|
691
|
-
} else if (hasHeightSettings && !hasWidthSettings) {
|
|
692
|
-
scrollDirection = 'vertical';
|
|
693
|
-
} else if (hasWidthSettings && hasHeightSettings) {
|
|
694
|
-
scrollDirection = 'both';
|
|
580
|
+
if (prevProps.data !== data || prevProps.columns !== columns) {
|
|
581
|
+
if (this.hasFixedColumn) {
|
|
582
|
+
this.calculateVerticalShadow();
|
|
695
583
|
}
|
|
696
|
-
return scrollDirection;
|
|
697
|
-
}
|
|
698
|
-
}, {
|
|
699
|
-
key: "isDataEmpty",
|
|
700
|
-
get: function get() {
|
|
701
|
-
return this.asProps.data.length === 0;
|
|
702
584
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
headerProps = _this$asProps7.headerProps,
|
|
714
|
-
onSelectedRowsChange = _this$asProps7.onSelectedRowsChange,
|
|
715
|
-
selectedRows = _this$asProps7.selectedRows,
|
|
716
|
-
sideIndents = _this$asProps7.sideIndents,
|
|
717
|
-
variant = _this$asProps7.variant;
|
|
718
|
-
var _this$gridSettings = this.gridSettings,
|
|
719
|
-
gridTemplateColumns = _this$gridSettings.gridTemplateColumns,
|
|
720
|
-
gridTemplateAreas = _this$gridSettings.gridTemplateAreas;
|
|
721
|
-
var shadowVertical = this.state.shadowVertical;
|
|
722
|
-
var sideIndentsValue = variant === 'card' ? 'wide' : sideIndents;
|
|
723
|
-
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, headerProps), {}, {
|
|
724
|
-
columns: this.columns,
|
|
725
|
-
treeColumns: this.treeColumns,
|
|
726
|
-
use: use,
|
|
727
|
-
tableRef: this.tableRef,
|
|
728
|
-
compact: Boolean(compact),
|
|
729
|
-
sort: sort,
|
|
730
|
-
onSortChange: onSortChange,
|
|
731
|
-
getI18nText: getI18nText,
|
|
732
|
-
uid: uid,
|
|
733
|
-
ref: headerProps !== null && headerProps !== void 0 && headerProps.ref ? (0, _ref9.forkRef)(this.headerRef, headerProps.ref) : this.headerRef,
|
|
734
|
-
gridAreaGroupMap: this.gridAreaGroupMap,
|
|
735
|
-
gridTemplateColumns: gridTemplateColumns,
|
|
736
|
-
gridTemplateAreas: gridTemplateAreas,
|
|
737
|
-
sideIndents: sideIndentsValue,
|
|
738
|
-
totalRows: this.totalRows,
|
|
739
|
-
selectedRows: selectedRows,
|
|
740
|
-
flatRows: this.getFlatRows(),
|
|
741
|
-
onChangeSelectAll: onSelectedRowsChange,
|
|
742
|
-
getFixedStyle: this.getFixedStyle,
|
|
743
|
-
onCellClick: this.handleCellClick,
|
|
744
|
-
shadowVertical: shadowVertical,
|
|
745
|
-
scrollDirection: this.scrollDirection,
|
|
746
|
-
isDataEmpty: this.isDataEmpty
|
|
585
|
+
if (prevProps.selectedRows !== selectedRows && selectedRows !== undefined) {
|
|
586
|
+
const selectedRowsSet = new Set(selectedRows);
|
|
587
|
+
const allChecked = [];
|
|
588
|
+
const allUnchecked = [];
|
|
589
|
+
this.flatRows.forEach(row => {
|
|
590
|
+
if (selectedRowsSet.has(row[UNIQ_ROW_KEY])) {
|
|
591
|
+
allChecked.push(row[UNIQ_ROW_KEY]);
|
|
592
|
+
} else {
|
|
593
|
+
allUnchecked.push(row[UNIQ_ROW_KEY]);
|
|
594
|
+
}
|
|
747
595
|
});
|
|
596
|
+
if (allChecked.length === data.length) {
|
|
597
|
+
this.setSelectAllMessage(true);
|
|
598
|
+
} else if (allUnchecked.length === data.length) {
|
|
599
|
+
this.setSelectAllMessage(false);
|
|
600
|
+
}
|
|
748
601
|
}
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
use = _this$asProps8.use,
|
|
754
|
-
compact = _this$asProps8.compact,
|
|
755
|
-
loading = _this$asProps8.loading,
|
|
756
|
-
getI18nText = _this$asProps8.getI18nText,
|
|
757
|
-
virtualScroll = _this$asProps8.virtualScroll,
|
|
758
|
-
uid = _this$asProps8.uid,
|
|
759
|
-
rowProps = _this$asProps8.rowProps,
|
|
760
|
-
renderCell = _this$asProps8.renderCell,
|
|
761
|
-
headerProps = _this$asProps8.headerProps,
|
|
762
|
-
renderEmptyData = _this$asProps8.renderEmptyData,
|
|
763
|
-
sideIndents = _this$asProps8.sideIndents,
|
|
764
|
-
selectedRows = _this$asProps8.selectedRows,
|
|
765
|
-
accordionDuration = _this$asProps8.accordionDuration,
|
|
766
|
-
accordionMode = _this$asProps8.accordionMode,
|
|
767
|
-
rawData = _this$asProps8.data,
|
|
768
|
-
renderCellOverlay = _this$asProps8.renderCellOverlay,
|
|
769
|
-
limit = _this$asProps8.limit,
|
|
770
|
-
variant = _this$asProps8.variant,
|
|
771
|
-
totalRows = _this$asProps8.totalRows,
|
|
772
|
-
accordionAnimationRows = _this$asProps8.accordionAnimationRows;
|
|
773
|
-
var _this$gridSettings2 = this.gridSettings,
|
|
774
|
-
gridTemplateColumns = _this$gridSettings2.gridTemplateColumns,
|
|
775
|
-
gridTemplateAreas = _this$gridSettings2.gridTemplateAreas;
|
|
776
|
-
var shadowVertical = this.state.shadowVertical;
|
|
777
|
-
return {
|
|
778
|
-
accordionDuration: accordionDuration,
|
|
779
|
-
accordionAnimationRows: accordionAnimationRows,
|
|
780
|
-
accordionMode: accordionMode,
|
|
781
|
-
columns: this.columns,
|
|
782
|
-
rows: this.getRows(),
|
|
783
|
-
flatRows: this.getFlatRows(),
|
|
784
|
-
use: use,
|
|
785
|
-
compact: Boolean(compact),
|
|
786
|
-
gridTemplateColumns: gridTemplateColumns,
|
|
787
|
-
gridTemplateAreas: gridTemplateAreas,
|
|
788
|
-
loading: loading,
|
|
789
|
-
headerHeight: this.getHeaderHeight(),
|
|
790
|
-
stickyHeader: headerProps === null || headerProps === void 0 ? void 0 : headerProps.sticky,
|
|
791
|
-
getI18nText: getI18nText,
|
|
792
|
-
expandedRows: this.state.expandedRows,
|
|
793
|
-
onExpandRow: this.onExpandRow,
|
|
794
|
-
spinnerRef: this.spinnerRef,
|
|
795
|
-
scrollTop: this.state.scrollTop,
|
|
796
|
-
scrollDirection: this.state.scrollDirection,
|
|
797
|
-
tableContainerRef: this.tableContainerRef,
|
|
798
|
-
tableRef: this.tableRef,
|
|
799
|
-
scrollAreaRef: this.scrollAreaRef,
|
|
800
|
-
onBackFromAccordion: this.handleBackFromAccordion,
|
|
801
|
-
virtualScroll: virtualScroll,
|
|
802
|
-
hasGroups: this.hasGroups,
|
|
803
|
-
uid: uid,
|
|
804
|
-
rowProps: this.getRows().length > 0 ? rowProps : undefined,
|
|
805
|
-
renderCell: this.getRows().length > 0 ? renderCell : undefined,
|
|
806
|
-
renderEmptyData: renderEmptyData,
|
|
807
|
-
sideIndents: sideIndents,
|
|
808
|
-
selectedRows: selectedRows,
|
|
809
|
-
onSelectRow: this.handleSelectRow,
|
|
810
|
-
getFixedStyle: this.getFixedStyle,
|
|
811
|
-
onCellClick: this.handleCellClick,
|
|
812
|
-
rawData: rawData,
|
|
813
|
-
shadowVertical: shadowVertical,
|
|
814
|
-
renderCellOverlay: renderCellOverlay,
|
|
815
|
-
limit: limit,
|
|
816
|
-
variant: variant,
|
|
817
|
-
totalRows: totalRows
|
|
818
|
-
};
|
|
602
|
+
}
|
|
603
|
+
componentWillUnmount() {
|
|
604
|
+
if ((0, _canUseDOM.default)()) {
|
|
605
|
+
document.removeEventListener('scroll', this.handleDocumentScroll);
|
|
819
606
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
607
|
+
this.state.expandedRows?.clear();
|
|
608
|
+
}
|
|
609
|
+
get totalRows() {
|
|
610
|
+
const {
|
|
611
|
+
totalRows
|
|
612
|
+
} = this.asProps;
|
|
613
|
+
const flatRows = this.getFlatRows();
|
|
614
|
+
const expandedRows = this.state.expandedRows;
|
|
615
|
+
const expandedRowsCount = Array.from(expandedRows).reduce((acc, rowKey) => {
|
|
616
|
+
const dtRow = flatRows.find(el => el[UNIQ_ROW_KEY] === rowKey);
|
|
617
|
+
if (dtRow) {
|
|
618
|
+
const expandedRows = dtRow[ACCORDION];
|
|
619
|
+
if (Array.isArray(expandedRows)) {
|
|
620
|
+
acc = acc + expandedRows.length;
|
|
828
621
|
} else {
|
|
829
|
-
|
|
622
|
+
acc = acc + 1;
|
|
830
623
|
}
|
|
831
|
-
}
|
|
624
|
+
}
|
|
625
|
+
return acc;
|
|
626
|
+
}, 0);
|
|
627
|
+
if (totalRows !== undefined) {
|
|
628
|
+
return totalRows + expandedRowsCount;
|
|
832
629
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
var _initCell$, _initCell$2;
|
|
837
|
-
var hasFocusable = this.hasFocusableInHeader();
|
|
838
|
-
var initRow = (_initCell$ = initCell === null || initCell === void 0 ? void 0 : initCell[0]) !== null && _initCell$ !== void 0 ? _initCell$ : 0;
|
|
839
|
-
var initCol = (_initCell$2 = initCell === null || initCell === void 0 ? void 0 : initCell[1]) !== null && _initCell$2 !== void 0 ? _initCell$2 : 0;
|
|
840
|
-
if (hasFocusable) {
|
|
841
|
-
this.focusedCell = [initRow, initCol];
|
|
630
|
+
const rows = this.getRows().reduce((acc, item) => {
|
|
631
|
+
if (Array.isArray(item)) {
|
|
632
|
+
acc = acc + item.length;
|
|
842
633
|
} else {
|
|
843
|
-
|
|
634
|
+
acc = acc + 1;
|
|
844
635
|
}
|
|
636
|
+
return acc;
|
|
637
|
+
}, 0);
|
|
638
|
+
return rows + expandedRowsCount;
|
|
639
|
+
}
|
|
640
|
+
get scrollDirection() {
|
|
641
|
+
const {
|
|
642
|
+
w,
|
|
643
|
+
wMax,
|
|
644
|
+
h,
|
|
645
|
+
hMax
|
|
646
|
+
} = this.asProps;
|
|
647
|
+
let scrollDirection = undefined;
|
|
648
|
+
const hasWidthSettings = Boolean(w) || Boolean(wMax);
|
|
649
|
+
const hasHeightSettings = Boolean(h) && h !== 'fit-content' || Boolean(hMax);
|
|
650
|
+
if (hasWidthSettings && !hasHeightSettings) {
|
|
651
|
+
scrollDirection = 'horizontal';
|
|
652
|
+
} else if (hasHeightSettings && !hasWidthSettings) {
|
|
653
|
+
scrollDirection = 'vertical';
|
|
654
|
+
} else if (hasWidthSettings && hasHeightSettings) {
|
|
655
|
+
scrollDirection = 'both';
|
|
845
656
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
657
|
+
return scrollDirection;
|
|
658
|
+
}
|
|
659
|
+
get isDataEmpty() {
|
|
660
|
+
return this.asProps.data.length === 0;
|
|
661
|
+
}
|
|
662
|
+
getHeadProps() {
|
|
663
|
+
const {
|
|
664
|
+
use,
|
|
665
|
+
compact,
|
|
666
|
+
sort,
|
|
667
|
+
onSortChange,
|
|
668
|
+
getI18nText,
|
|
669
|
+
uid,
|
|
670
|
+
headerProps,
|
|
671
|
+
onSelectedRowsChange,
|
|
672
|
+
selectedRows,
|
|
673
|
+
sideIndents,
|
|
674
|
+
variant
|
|
675
|
+
} = this.asProps;
|
|
676
|
+
const {
|
|
677
|
+
gridTemplateColumns,
|
|
678
|
+
gridTemplateAreas
|
|
679
|
+
} = this.gridSettings;
|
|
680
|
+
const {
|
|
681
|
+
shadowVertical
|
|
682
|
+
} = this.state;
|
|
683
|
+
const sideIndentsValue = variant === 'card' ? 'wide' : sideIndents;
|
|
684
|
+
return {
|
|
685
|
+
...headerProps,
|
|
686
|
+
columns: this.columns,
|
|
687
|
+
treeColumns: this.treeColumns,
|
|
688
|
+
use,
|
|
689
|
+
tableRef: this.tableRef,
|
|
690
|
+
compact: Boolean(compact),
|
|
691
|
+
sort,
|
|
692
|
+
onSortChange,
|
|
693
|
+
getI18nText,
|
|
694
|
+
uid,
|
|
695
|
+
ref: headerProps?.ref ? (0, _ref3.forkRef)(this.headerRef, headerProps.ref) : this.headerRef,
|
|
696
|
+
gridAreaGroupMap: this.gridAreaGroupMap,
|
|
697
|
+
gridTemplateColumns,
|
|
698
|
+
gridTemplateAreas,
|
|
699
|
+
sideIndents: sideIndentsValue,
|
|
700
|
+
totalRows: this.totalRows,
|
|
701
|
+
selectedRows,
|
|
702
|
+
flatRows: this.getFlatRows(),
|
|
703
|
+
onChangeSelectAll: onSelectedRowsChange,
|
|
704
|
+
getFixedStyle: this.getFixedStyle,
|
|
705
|
+
onCellClick: this.handleCellClick,
|
|
706
|
+
shadowVertical,
|
|
707
|
+
scrollDirection: this.scrollDirection,
|
|
708
|
+
isDataEmpty: this.isDataEmpty
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
getBodyProps() {
|
|
712
|
+
const {
|
|
713
|
+
use,
|
|
714
|
+
compact,
|
|
715
|
+
loading,
|
|
716
|
+
getI18nText,
|
|
717
|
+
virtualScroll,
|
|
718
|
+
uid,
|
|
719
|
+
rowProps,
|
|
720
|
+
renderCell,
|
|
721
|
+
headerProps,
|
|
722
|
+
renderEmptyData,
|
|
723
|
+
sideIndents,
|
|
724
|
+
selectedRows,
|
|
725
|
+
accordionDuration,
|
|
726
|
+
accordionMode,
|
|
727
|
+
data: rawData,
|
|
728
|
+
renderCellOverlay,
|
|
729
|
+
limit,
|
|
730
|
+
variant,
|
|
731
|
+
totalRows,
|
|
732
|
+
accordionAnimationRows
|
|
733
|
+
} = this.asProps;
|
|
734
|
+
const {
|
|
735
|
+
gridTemplateColumns,
|
|
736
|
+
gridTemplateAreas
|
|
737
|
+
} = this.gridSettings;
|
|
738
|
+
const {
|
|
739
|
+
shadowVertical
|
|
740
|
+
} = this.state;
|
|
741
|
+
return {
|
|
742
|
+
accordionDuration,
|
|
743
|
+
accordionAnimationRows,
|
|
744
|
+
accordionMode,
|
|
745
|
+
columns: this.columns,
|
|
746
|
+
rows: this.getRows(),
|
|
747
|
+
flatRows: this.getFlatRows(),
|
|
748
|
+
use,
|
|
749
|
+
compact: Boolean(compact),
|
|
750
|
+
gridTemplateColumns,
|
|
751
|
+
gridTemplateAreas,
|
|
752
|
+
loading,
|
|
753
|
+
headerHeight: this.getHeaderHeight(),
|
|
754
|
+
stickyHeader: headerProps?.sticky,
|
|
755
|
+
getI18nText,
|
|
756
|
+
expandedRows: this.state.expandedRows,
|
|
757
|
+
onExpandRow: this.onExpandRow,
|
|
758
|
+
spinnerRef: this.spinnerRef,
|
|
759
|
+
scrollTop: this.state.scrollTop,
|
|
760
|
+
scrollDirection: this.state.scrollDirection,
|
|
761
|
+
tableContainerRef: this.tableContainerRef,
|
|
762
|
+
tableRef: this.tableRef,
|
|
763
|
+
scrollAreaRef: this.scrollAreaRef,
|
|
764
|
+
onBackFromAccordion: this.handleBackFromAccordion,
|
|
765
|
+
virtualScroll,
|
|
766
|
+
hasGroups: this.hasGroups,
|
|
767
|
+
uid,
|
|
768
|
+
rowProps: this.getRows().length > 0 ? rowProps : undefined,
|
|
769
|
+
renderCell: this.getRows().length > 0 ? renderCell : undefined,
|
|
770
|
+
renderEmptyData,
|
|
771
|
+
sideIndents,
|
|
772
|
+
selectedRows,
|
|
773
|
+
onSelectRow: this.handleSelectRow,
|
|
774
|
+
getFixedStyle: this.getFixedStyle,
|
|
775
|
+
onCellClick: this.handleCellClick,
|
|
776
|
+
rawData,
|
|
777
|
+
shadowVertical,
|
|
778
|
+
renderCellOverlay,
|
|
779
|
+
limit,
|
|
780
|
+
variant,
|
|
781
|
+
totalRows
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
setInert(value) {
|
|
785
|
+
const cells = this.tableRef.current?.querySelectorAll('[role=gridcell], [role=columnheader]');
|
|
786
|
+
cells?.forEach(cell => {
|
|
787
|
+
if (value === true) {
|
|
788
|
+
cell.setAttribute('inert', '');
|
|
789
|
+
} else {
|
|
790
|
+
cell.removeAttribute('inert');
|
|
883
791
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
initFocusableCell(initCell) {
|
|
795
|
+
const hasFocusable = this.hasFocusableInHeader();
|
|
796
|
+
const initRow = initCell?.[0] ?? 0;
|
|
797
|
+
const initCol = initCell?.[1] ?? 0;
|
|
798
|
+
if (hasFocusable) {
|
|
799
|
+
this.focusedCell = [initRow, initCol];
|
|
800
|
+
} else {
|
|
801
|
+
this.focusedCell = [initRow + 1, initCol];
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
render() {
|
|
805
|
+
var _ref = this.asProps,
|
|
806
|
+
_ref2;
|
|
807
|
+
const SDataTable = _baseComponents.Box;
|
|
808
|
+
const {
|
|
809
|
+
Children,
|
|
810
|
+
styles,
|
|
811
|
+
w,
|
|
812
|
+
wMax,
|
|
813
|
+
wMin,
|
|
814
|
+
h,
|
|
815
|
+
hMax,
|
|
816
|
+
hMin,
|
|
817
|
+
virtualScroll,
|
|
818
|
+
children,
|
|
819
|
+
headerProps,
|
|
820
|
+
loading,
|
|
821
|
+
selectedRows
|
|
822
|
+
} = this.asProps;
|
|
823
|
+
const [offsetLeftSum, offsetRightSum] = this.getScrollOffsetValue();
|
|
824
|
+
const {
|
|
825
|
+
gridTemplateColumns,
|
|
826
|
+
gridTemplateAreas
|
|
827
|
+
} = this.gridSettings;
|
|
828
|
+
const Head = (0, _findComponent.default)(Children, ['DataTable.Head']);
|
|
829
|
+
const headerPropsToCheck = headerProps ?? Head?.props;
|
|
830
|
+
const headerHeight = headerProps?.h || this.getHeaderHeight();
|
|
831
|
+
const topOffset = headerPropsToCheck?.sticky || headerPropsToCheck?.withScrollBar ? headerHeight : undefined;
|
|
832
|
+
const width = w ?? (this.columns.some(c => c.gtcWidth === 'auto' || c.gtcWidth === '1fr') ? '100%' : undefined);
|
|
833
|
+
let gridTemplateRows = undefined;
|
|
834
|
+
if (virtualScroll && typeof virtualScroll !== 'boolean' && 'rowHeight' in virtualScroll) {
|
|
835
|
+
gridTemplateRows = `auto auto repeat(${this.totalRows}, minmax(${virtualScroll.rowHeight}px, auto)`;
|
|
836
|
+
}
|
|
837
|
+
return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea, _ref2.cn("ScrollArea", {
|
|
838
|
+
"leftOffset": offsetLeftSum,
|
|
839
|
+
"rightOffset": offsetRightSum,
|
|
840
|
+
"topOffset": topOffset,
|
|
841
|
+
"w": width,
|
|
842
|
+
"wMax": wMax,
|
|
843
|
+
"wMin": wMin,
|
|
844
|
+
"h": h,
|
|
845
|
+
"hMax": hMax,
|
|
846
|
+
"hMin": hMin,
|
|
847
|
+
"shadow": true,
|
|
848
|
+
"ref": this.scrollAreaRef,
|
|
849
|
+
"container": this.tableContainerRef,
|
|
850
|
+
"styles": scrollStyles,
|
|
851
|
+
"onScroll": this.handleScroll,
|
|
852
|
+
"disableAutofocusToContent": true,
|
|
853
|
+
"onResize": this.handleContainerResizeEnd
|
|
854
|
+
}), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Container, {
|
|
855
|
+
tabIndex: -1
|
|
856
|
+
// @ts-ignore
|
|
857
|
+
,
|
|
858
|
+
scrollDirection: this.scrollDirection
|
|
859
|
+
// @ts-ignore
|
|
860
|
+
,
|
|
861
|
+
loading: loading,
|
|
862
|
+
headerHeight: `${headerHeight}px`,
|
|
863
|
+
leftScrollPadding: `${offsetLeftSum}px`,
|
|
864
|
+
rightScrollPadding: `${offsetRightSum}px`
|
|
865
|
+
}, /*#__PURE__*/React.createElement(SDataTable, _ref2.cn("SDataTable", {
|
|
866
|
+
...(0, _core.assignProps)({
|
|
867
|
+
"ref": (0, _ref3.forkRef)(this.tableRef, this.tableContainerRef),
|
|
914
868
|
"role": 'grid',
|
|
915
869
|
"onKeyDown": this.handleKeyDown,
|
|
916
870
|
"onKeyUp": this.handleKeyUp,
|
|
@@ -932,345 +886,320 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
932
886
|
"use:h": undefined,
|
|
933
887
|
"use:hMax": undefined,
|
|
934
888
|
"use:hMin": undefined
|
|
935
|
-
}, _ref)
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
return
|
|
960
|
-
return col.children !== null;
|
|
961
|
-
});
|
|
889
|
+
}, _ref)
|
|
890
|
+
}), children ? /*#__PURE__*/React.createElement(Children, _ref2.cn("Children", {})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataTable.Head, null), /*#__PURE__*/React.createElement(DataTable.Body, null)))), headerPropsToCheck?.withScrollBar && topOffset && !loading && /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
|
|
891
|
+
orientation: "horizontal",
|
|
892
|
+
top: topOffset - SCROLL_BAR_HEIGHT,
|
|
893
|
+
zIndex: 20
|
|
894
|
+
}), !loading && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
|
|
895
|
+
orientation: "horizontal",
|
|
896
|
+
zIndex: 20
|
|
897
|
+
}), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea.Bar, {
|
|
898
|
+
orientation: "vertical",
|
|
899
|
+
zIndex: 20
|
|
900
|
+
})), selectedRows !== undefined && /*#__PURE__*/React.createElement(_baseComponents.ScreenReaderOnly, _ref2.cn("ScreenReaderOnly", {
|
|
901
|
+
"aria-live": 'polite',
|
|
902
|
+
"role": 'status'
|
|
903
|
+
}), this.state.selectAllMessage));
|
|
904
|
+
}
|
|
905
|
+
calculateColumnsFromConfig() {
|
|
906
|
+
const {
|
|
907
|
+
columns,
|
|
908
|
+
data,
|
|
909
|
+
selectedRows
|
|
910
|
+
} = this.props;
|
|
911
|
+
this.hasGroups = columns.some(column => {
|
|
912
|
+
return 'columns' in column && column.columns.some(col => {
|
|
913
|
+
return col.children !== null;
|
|
962
914
|
});
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
calculatedColumns.push(column);
|
|
976
|
-
}
|
|
977
|
-
var makeColumn = function makeColumn(columnElement, parent, isFirst, isLast, hasGroups) {
|
|
978
|
-
var _columnElement$fixed, _ref3, _columnElement$border;
|
|
979
|
-
var leftBordersFromParent = isFirst && ((parent === null || parent === void 0 ? void 0 : parent.borders) === 'both' || (parent === null || parent === void 0 ? void 0 : parent.borders) === 'left') ? 'left' : undefined;
|
|
980
|
-
var rightBordersFromParent = isLast && ((parent === null || parent === void 0 ? void 0 : parent.borders) === 'both' || (parent === null || parent === void 0 ? void 0 : parent.borders) === 'right') ? 'right' : undefined;
|
|
981
|
-
var column = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, columnElement), {}, {
|
|
982
|
-
name: childIsColumn(columnElement) ? columnElement.name : '',
|
|
983
|
-
gtcWidth: childIsColumn(columnElement) ? calculateGridTemplateColumn(columnElement) : '',
|
|
984
|
-
fixed: (_columnElement$fixed = columnElement.fixed) !== null && _columnElement$fixed !== void 0 ? _columnElement$fixed : hasGroups ? parent === null || parent === void 0 ? void 0 : parent.fixed : undefined,
|
|
985
|
-
borders: (_ref3 = (_columnElement$border = columnElement.borders) !== null && _columnElement$border !== void 0 ? _columnElement$border : leftBordersFromParent) !== null && _ref3 !== void 0 ? _ref3 : rightBordersFromParent,
|
|
986
|
-
parent: parent
|
|
987
|
-
});
|
|
988
|
-
if (column.fixed) {
|
|
989
|
-
_this3.hasFixedColumn = true;
|
|
990
|
-
}
|
|
991
|
-
return column;
|
|
992
|
-
};
|
|
993
|
-
var childIsColumn = function childIsColumn(child) {
|
|
994
|
-
return !('columns' in child);
|
|
915
|
+
});
|
|
916
|
+
let groupIndex = 0;
|
|
917
|
+
let gridColumnIndex = selectedRows ? 2 : 1;
|
|
918
|
+
const calculateGridTemplateColumn = this.calculateGridTemplateColumn.bind(this);
|
|
919
|
+
const calculatedColumns = [];
|
|
920
|
+
const treeColumns = [];
|
|
921
|
+
if (selectedRows) {
|
|
922
|
+
const column = {
|
|
923
|
+
name: SELECT_ALL.toString(),
|
|
924
|
+
gtcWidth: 'min-content',
|
|
925
|
+
alignItems: 'flex-start',
|
|
926
|
+
children: ''
|
|
995
927
|
};
|
|
996
|
-
|
|
997
|
-
|
|
928
|
+
calculatedColumns.push(column);
|
|
929
|
+
}
|
|
930
|
+
const makeColumn = (columnElement, parent, isFirst, isLast, hasGroups) => {
|
|
931
|
+
const leftBordersFromParent = isFirst && (parent?.borders === 'both' || parent?.borders === 'left') ? 'left' : undefined;
|
|
932
|
+
const rightBordersFromParent = isLast && (parent?.borders === 'both' || parent?.borders === 'right') ? 'right' : undefined;
|
|
933
|
+
const column = {
|
|
934
|
+
...columnElement,
|
|
935
|
+
name: childIsColumn(columnElement) ? columnElement.name : '',
|
|
936
|
+
gtcWidth: childIsColumn(columnElement) ? calculateGridTemplateColumn(columnElement) : '',
|
|
937
|
+
fixed: columnElement.fixed ?? (hasGroups ? parent?.fixed : undefined),
|
|
938
|
+
borders: columnElement.borders ?? leftBordersFromParent ?? rightBordersFromParent,
|
|
939
|
+
parent
|
|
998
940
|
};
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
941
|
+
if (column.fixed) {
|
|
942
|
+
this.hasFixedColumn = true;
|
|
943
|
+
}
|
|
944
|
+
return column;
|
|
945
|
+
};
|
|
946
|
+
const childIsColumn = child => {
|
|
947
|
+
return !('columns' in child);
|
|
948
|
+
};
|
|
949
|
+
const childIsGroup = child => {
|
|
950
|
+
return 'columns' in child;
|
|
951
|
+
};
|
|
952
|
+
const setShowShadows = (col, i) => {
|
|
953
|
+
let prevCol = treeColumns[i - 1];
|
|
954
|
+
if ('columns' in prevCol && prevCol.columns) {
|
|
955
|
+
prevCol = prevCol.columns[prevCol.columns.length - 1];
|
|
956
|
+
}
|
|
957
|
+
if (prevCol.fixed && !col.fixed) {
|
|
958
|
+
prevCol.showShadowVertical = true;
|
|
959
|
+
} else if (!prevCol.fixed && col.fixed) {
|
|
960
|
+
col.showShadowVertical = true;
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
columns.forEach((child, i) => {
|
|
964
|
+
if (childIsColumn(child)) {
|
|
965
|
+
const col = makeColumn(child);
|
|
966
|
+
col.gridArea = `1 / ${gridColumnIndex} / ${this.hasGroups ? '3' : '2'} / ${gridColumnIndex + 1}`;
|
|
967
|
+
gridColumnIndex++;
|
|
968
|
+
calculatedColumns.push(col);
|
|
969
|
+
treeColumns.push(col);
|
|
970
|
+
if (i > 0) {
|
|
971
|
+
setShowShadows(col, i);
|
|
1008
972
|
}
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
973
|
+
} else if (childIsGroup(child)) {
|
|
974
|
+
const Group = makeColumn(child);
|
|
975
|
+
const childCount = child.columns.length;
|
|
976
|
+
const initGridColumn = gridColumnIndex;
|
|
977
|
+
const groupedRow = this.hasGroups ? 2 : 1;
|
|
978
|
+
Group.columns = [];
|
|
979
|
+
Group.children = child.children;
|
|
980
|
+
child.columns.forEach((child, j) => {
|
|
981
|
+
const isFirst = j === 0;
|
|
982
|
+
const isLast = j === childCount - 1;
|
|
983
|
+
const col = makeColumn(child, Group, isFirst, isLast, this.hasGroups);
|
|
984
|
+
if (i === 0 && j === 0 && data.some(d => d[ACCORDION])) {
|
|
985
|
+
gridColumnIndex++;
|
|
986
|
+
col.gridArea = `${groupedRow} / ${gridColumnIndex - 1} / ${groupedRow + 1} / ${gridColumnIndex + 1}`;
|
|
987
|
+
} else {
|
|
988
|
+
col.gridArea = `${groupedRow} / ${gridColumnIndex} / ${groupedRow + 1} / ${gridColumnIndex + 1}`;
|
|
989
|
+
}
|
|
990
|
+
col.gridArea = `${groupedRow} / ${gridColumnIndex} / ${groupedRow + 1} / ${gridColumnIndex + 1}`;
|
|
1014
991
|
gridColumnIndex++;
|
|
1015
992
|
calculatedColumns.push(col);
|
|
1016
|
-
|
|
1017
|
-
if (i > 0) {
|
|
993
|
+
if (isFirst && i > 0) {
|
|
1018
994
|
setShowShadows(col, i);
|
|
1019
995
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
Group.columns = [];
|
|
1026
|
-
Group.children = child.children;
|
|
1027
|
-
child.columns.forEach(function (child, j) {
|
|
1028
|
-
var _Group$columns;
|
|
1029
|
-
var isFirst = j === 0;
|
|
1030
|
-
var isLast = j === childCount - 1;
|
|
1031
|
-
var col = makeColumn(child, Group, isFirst, isLast, _this3.hasGroups);
|
|
1032
|
-
if (i === 0 && j === 0 && data.some(function (d) {
|
|
1033
|
-
return d[ACCORDION];
|
|
1034
|
-
})) {
|
|
1035
|
-
gridColumnIndex++;
|
|
1036
|
-
col.gridArea = "".concat(groupedRow, " / ").concat(gridColumnIndex - 1, " / ").concat(groupedRow + 1, " / ").concat(gridColumnIndex + 1);
|
|
1037
|
-
} else {
|
|
1038
|
-
col.gridArea = "".concat(groupedRow, " / ").concat(gridColumnIndex, " / ").concat(groupedRow + 1, " / ").concat(gridColumnIndex + 1);
|
|
1039
|
-
}
|
|
1040
|
-
col.gridArea = "".concat(groupedRow, " / ").concat(gridColumnIndex, " / ").concat(groupedRow + 1, " / ").concat(gridColumnIndex + 1);
|
|
1041
|
-
gridColumnIndex++;
|
|
1042
|
-
calculatedColumns.push(col);
|
|
1043
|
-
if (isFirst && i > 0) {
|
|
1044
|
-
setShowShadows(col, i);
|
|
1045
|
-
}
|
|
1046
|
-
(_Group$columns = Group.columns) === null || _Group$columns === void 0 || _Group$columns.push(col);
|
|
1047
|
-
});
|
|
1048
|
-
treeColumns.push(Group);
|
|
1049
|
-
_this3.gridAreaGroupMap.set(groupIndex, "1 / ".concat(initGridColumn, " / 2 / ").concat(gridColumnIndex));
|
|
1050
|
-
groupIndex++;
|
|
1051
|
-
}
|
|
1052
|
-
});
|
|
1053
|
-
var gridTemplateColumns = calculatedColumns.map(function (c) {
|
|
1054
|
-
return c.gtcWidth;
|
|
1055
|
-
});
|
|
1056
|
-
var gridTemplateAreas = calculatedColumns.map(function (c) {
|
|
1057
|
-
return c.name;
|
|
1058
|
-
});
|
|
1059
|
-
this.gridSettings = {
|
|
1060
|
-
gridTemplateColumns: gridTemplateColumns,
|
|
1061
|
-
gridTemplateAreas: gridTemplateAreas
|
|
1062
|
-
};
|
|
1063
|
-
return [calculatedColumns, treeColumns];
|
|
1064
|
-
}
|
|
1065
|
-
}, {
|
|
1066
|
-
key: "getFlatRows",
|
|
1067
|
-
value: function getFlatRows() {
|
|
1068
|
-
var data = this.props.data;
|
|
1069
|
-
if (this.tmpData === data && this.flatRows) {
|
|
1070
|
-
return this.flatRows;
|
|
996
|
+
Group.columns?.push(col);
|
|
997
|
+
});
|
|
998
|
+
treeColumns.push(Group);
|
|
999
|
+
this.gridAreaGroupMap.set(groupIndex, `1 / ${initGridColumn} / 2 / ${gridColumnIndex}`);
|
|
1000
|
+
groupIndex++;
|
|
1071
1001
|
}
|
|
1072
|
-
|
|
1002
|
+
});
|
|
1003
|
+
const gridTemplateColumns = calculatedColumns.map(c => c.gtcWidth);
|
|
1004
|
+
const gridTemplateAreas = calculatedColumns.map(c => c.name);
|
|
1005
|
+
this.gridSettings = {
|
|
1006
|
+
gridTemplateColumns,
|
|
1007
|
+
gridTemplateAreas
|
|
1008
|
+
};
|
|
1009
|
+
return [calculatedColumns, treeColumns];
|
|
1010
|
+
}
|
|
1011
|
+
getFlatRows() {
|
|
1012
|
+
const {
|
|
1013
|
+
data
|
|
1014
|
+
} = this.props;
|
|
1015
|
+
if (this.tmpData === data && this.flatRows) {
|
|
1073
1016
|
return this.flatRows;
|
|
1074
1017
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
var id = 100000000; // need this for gen keys by toString(36)
|
|
1018
|
+
this.flatRows = this.getRows().flat();
|
|
1019
|
+
return this.flatRows;
|
|
1020
|
+
}
|
|
1021
|
+
getRows() {
|
|
1022
|
+
const columns = this.columns;
|
|
1023
|
+
// @ts-ignore
|
|
1024
|
+
const {
|
|
1025
|
+
data,
|
|
1026
|
+
uid,
|
|
1027
|
+
uniqueRowKey
|
|
1028
|
+
} = this.props;
|
|
1029
|
+
if (this.tmpData === data) {
|
|
1030
|
+
return this.calculatedRows;
|
|
1031
|
+
}
|
|
1032
|
+
this.tmpData = data;
|
|
1033
|
+
const rows = [];
|
|
1034
|
+
const columnNames = columns.map(column => column.name);
|
|
1035
|
+
let rowIndex = 0;
|
|
1036
|
+
let gridRowIndex = 0;
|
|
1037
|
+
const id = 100000000; // need this for gen keys by toString(36)
|
|
1096
1038
|
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
} else {
|
|
1108
|
-
rowKey = keyValue;
|
|
1109
|
-
}
|
|
1039
|
+
const makeDtRow = (row, excludeColumns) => {
|
|
1040
|
+
const columns = new Set(columnNames);
|
|
1041
|
+
let accordionInCell = null;
|
|
1042
|
+
let rowKey = row[UNIQ_ROW_KEY];
|
|
1043
|
+
if (!rowKey) {
|
|
1044
|
+
if (uniqueRowKey) {
|
|
1045
|
+
// @ts-ignore
|
|
1046
|
+
const keyValue = row[uniqueRowKey];
|
|
1047
|
+
if (keyValue instanceof _MergedCells.MergedRowsCell) {
|
|
1048
|
+
rowKey = keyValue.value;
|
|
1110
1049
|
} else {
|
|
1111
|
-
rowKey =
|
|
1050
|
+
rowKey = keyValue;
|
|
1112
1051
|
}
|
|
1052
|
+
} else {
|
|
1053
|
+
rowKey = `${uid}_${(rowIndex + id).toString(36)}`;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
const initData = {
|
|
1057
|
+
/*
|
|
1058
|
+
row -> DataRowItem
|
|
1059
|
+
uniqueRowKey is a `keyof Data[number]` -> `keyof DataRowItem`
|
|
1060
|
+
*/
|
|
1061
|
+
// @ts-ignore
|
|
1062
|
+
[UNIQ_ROW_KEY]: rowKey,
|
|
1063
|
+
[ROW_INDEX]: rowIndex,
|
|
1064
|
+
[GRID_ROW_INDEX]: gridRowIndex
|
|
1065
|
+
};
|
|
1066
|
+
const dtRow = Object.entries(row).reduce((acc, [key, value]) => {
|
|
1067
|
+
const columnsToRow = key.split(this.columnsSplitter);
|
|
1068
|
+
if (columnsToRow.length === 1) {
|
|
1069
|
+
acc[key] = value ?? '';
|
|
1070
|
+
columns.delete(key);
|
|
1071
|
+
} else {
|
|
1072
|
+
acc[columnsToRow[0]] = new _MergedCells.MergedColumnsCell(value, {
|
|
1073
|
+
dataKey: key,
|
|
1074
|
+
size: columnsToRow.length
|
|
1075
|
+
});
|
|
1076
|
+
columnsToRow.forEach(value => {
|
|
1077
|
+
columns.delete(value);
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
if (value?.[ACCORDION]) {
|
|
1081
|
+
accordionInCell = value[ACCORDION];
|
|
1082
|
+
}
|
|
1083
|
+
return acc;
|
|
1084
|
+
}, initData);
|
|
1085
|
+
gridRowIndex++;
|
|
1086
|
+
if (row[ACCORDION]) {
|
|
1087
|
+
if (Array.isArray(row[ACCORDION])) {
|
|
1088
|
+
dtRow[ACCORDION] = row[ACCORDION].map(item => makeDtRow(item));
|
|
1089
|
+
} else if (/*#__PURE__*/React.isValidElement(row[ACCORDION])) {
|
|
1090
|
+
dtRow[ACCORDION] = row[ACCORDION];
|
|
1091
|
+
gridRowIndex++;
|
|
1113
1092
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1093
|
+
} else if (accordionInCell) {
|
|
1094
|
+
gridRowIndex++;
|
|
1095
|
+
}
|
|
1096
|
+
excludeColumns?.forEach(value => {
|
|
1097
|
+
columns.delete(value);
|
|
1098
|
+
});
|
|
1099
|
+
if (columns.size > 0) {
|
|
1100
|
+
columns.forEach(value => {
|
|
1101
|
+
dtRow[value] = '';
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
return dtRow;
|
|
1105
|
+
};
|
|
1106
|
+
data.forEach(row => {
|
|
1107
|
+
const groupedRows = row[ROW_GROUP];
|
|
1108
|
+
if (groupedRows && groupedRows.length > 1) {
|
|
1109
|
+
const innerRows = [];
|
|
1110
|
+
const groupedKeys = [];
|
|
1111
|
+
const groupedRowData = Object.entries(row).reduce((acc, [key, value]) => {
|
|
1112
|
+
const accordion = Array.isArray(row[ACCORDION]) ? row[ACCORDION].map(item => makeDtRow(item)) : row[ACCORDION];
|
|
1113
|
+
acc[key] = new _MergedCells.MergedRowsCell(value, groupedRows.length, accordion);
|
|
1114
|
+
const columnsToRow = key.split(this.columnsSplitter);
|
|
1120
1115
|
if (columnsToRow.length === 1) {
|
|
1121
|
-
|
|
1122
|
-
columns["delete"](key);
|
|
1116
|
+
groupedKeys.push(key);
|
|
1123
1117
|
} else {
|
|
1124
|
-
|
|
1125
|
-
dataKey: key,
|
|
1126
|
-
size: columnsToRow.length
|
|
1127
|
-
});
|
|
1128
|
-
columnsToRow.forEach(function (value) {
|
|
1129
|
-
columns["delete"](value);
|
|
1130
|
-
});
|
|
1131
|
-
}
|
|
1132
|
-
if (value !== null && value !== void 0 && value[ACCORDION]) {
|
|
1133
|
-
accordionInCell = value[ACCORDION];
|
|
1118
|
+
groupedKeys.push(...columnsToRow);
|
|
1134
1119
|
}
|
|
1135
1120
|
return acc;
|
|
1136
|
-
},
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
dtRow[ACCORDION] = row[ACCORDION].map(function (item) {
|
|
1141
|
-
return _makeDtRow(item);
|
|
1142
|
-
});
|
|
1143
|
-
} else if (/*#__PURE__*/React.isValidElement(row[ACCORDION])) {
|
|
1144
|
-
dtRow[ACCORDION] = row[ACCORDION];
|
|
1145
|
-
gridRowIndex++;
|
|
1146
|
-
}
|
|
1147
|
-
} else if (accordionInCell) {
|
|
1148
|
-
gridRowIndex++;
|
|
1149
|
-
}
|
|
1150
|
-
excludeColumns === null || excludeColumns === void 0 || excludeColumns.forEach(function (value) {
|
|
1151
|
-
columns["delete"](value);
|
|
1121
|
+
}, {
|
|
1122
|
+
[UNIQ_ROW_KEY]: '',
|
|
1123
|
+
// will fill in makeDtRow
|
|
1124
|
+
[ROW_INDEX]: -1
|
|
1152
1125
|
});
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
return _makeDtRow(item);
|
|
1171
|
-
}) : row[ACCORDION];
|
|
1172
|
-
acc[key] = new _MergedCells.MergedRowsCell(value, groupedRows.length, accordion);
|
|
1173
|
-
var columnsToRow = key.split(_this4.columnsSplitter);
|
|
1174
|
-
if (columnsToRow.length === 1) {
|
|
1175
|
-
groupedKeys.push(key);
|
|
1176
|
-
} else {
|
|
1177
|
-
groupedKeys.push.apply(groupedKeys, (0, _toConsumableArray2["default"])(columnsToRow));
|
|
1178
|
-
}
|
|
1179
|
-
return acc;
|
|
1180
|
-
}, (0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, UNIQ_ROW_KEY, ''), ROW_INDEX, -1));
|
|
1181
|
-
groupedRows.forEach(function (childRow, index) {
|
|
1182
|
-
var dtRow;
|
|
1183
|
-
if (index === 0) {
|
|
1184
|
-
var rowData = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, childRow), groupedRowData);
|
|
1185
|
-
dtRow = _makeDtRow(rowData);
|
|
1186
|
-
dtRow[ROW_GROUP] = new Set();
|
|
1187
|
-
} else {
|
|
1188
|
-
var _innerRows$;
|
|
1189
|
-
dtRow = _makeDtRow(childRow, groupedKeys);
|
|
1190
|
-
(_innerRows$ = innerRows[0]) === null || _innerRows$ === void 0 || (_innerRows$ = _innerRows$[ROW_GROUP]) === null || _innerRows$ === void 0 || _innerRows$.add(dtRow[UNIQ_ROW_KEY]);
|
|
1191
|
-
}
|
|
1192
|
-
innerRows.push(dtRow);
|
|
1193
|
-
if (index === groupedRows.length - 1 && row[ACCORDION]) {
|
|
1194
|
-
gridRowIndex = Array.isArray(row[ACCORDION]) ? gridRowIndex + row[ACCORDION].length : gridRowIndex + 1;
|
|
1195
|
-
}
|
|
1196
|
-
rowIndex++;
|
|
1197
|
-
});
|
|
1198
|
-
rows.push(innerRows);
|
|
1199
|
-
} else if ((groupedRows === null || groupedRows === void 0 ? void 0 : groupedRows.length) === 1) {
|
|
1200
|
-
var dtRow = _makeDtRow((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, groupedRows[0]), row));
|
|
1201
|
-
rows.push(dtRow);
|
|
1202
|
-
rowIndex++;
|
|
1203
|
-
} else {
|
|
1204
|
-
var _dtRow = _makeDtRow(row);
|
|
1205
|
-
rows.push(_dtRow);
|
|
1126
|
+
groupedRows.forEach((childRow, index) => {
|
|
1127
|
+
let dtRow;
|
|
1128
|
+
if (index === 0) {
|
|
1129
|
+
const rowData = {
|
|
1130
|
+
...childRow,
|
|
1131
|
+
...groupedRowData
|
|
1132
|
+
};
|
|
1133
|
+
dtRow = makeDtRow(rowData);
|
|
1134
|
+
dtRow[ROW_GROUP] = new Set();
|
|
1135
|
+
} else {
|
|
1136
|
+
dtRow = makeDtRow(childRow, groupedKeys);
|
|
1137
|
+
innerRows[0]?.[ROW_GROUP]?.add(dtRow[UNIQ_ROW_KEY]);
|
|
1138
|
+
}
|
|
1139
|
+
innerRows.push(dtRow);
|
|
1140
|
+
if (index === groupedRows.length - 1 && row[ACCORDION]) {
|
|
1141
|
+
gridRowIndex = Array.isArray(row[ACCORDION]) ? gridRowIndex + row[ACCORDION].length : gridRowIndex + 1;
|
|
1142
|
+
}
|
|
1206
1143
|
rowIndex++;
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
value: function getHeaderHeight() {
|
|
1221
|
-
var _this$headerRef$curre4;
|
|
1222
|
-
var header = (_this$headerRef$curre4 = this.headerRef.current) === null || _this$headerRef$curre4 === void 0 ? void 0 : _this$headerRef$curre4.children;
|
|
1223
|
-
var height = 0;
|
|
1224
|
-
for (var i = 0; i < ((_header$length = header === null || header === void 0 ? void 0 : header.length) !== null && _header$length !== void 0 ? _header$length : 0); i++) {
|
|
1225
|
-
var _header$length;
|
|
1226
|
-
var item = header === null || header === void 0 ? void 0 : header.item(i);
|
|
1227
|
-
var columnHeight = item === null || item === void 0 ? void 0 : item.getBoundingClientRect().height;
|
|
1228
|
-
if (item instanceof HTMLElement && item.dataset.groupContainer) {
|
|
1229
|
-
var _item$children$item$g, _item$children$item, _item$children$item$g2, _item$children$item2;
|
|
1230
|
-
var groupHeight = (_item$children$item$g = (_item$children$item = item.children.item(0)) === null || _item$children$item === void 0 ? void 0 : _item$children$item.getBoundingClientRect().height) !== null && _item$children$item$g !== void 0 ? _item$children$item$g : 0;
|
|
1231
|
-
var cellHeight = (_item$children$item$g2 = (_item$children$item2 = item.children.item(1)) === null || _item$children$item2 === void 0 ? void 0 : _item$children$item2.getBoundingClientRect().height) !== null && _item$children$item$g2 !== void 0 ? _item$children$item$g2 : 0;
|
|
1232
|
-
columnHeight = groupHeight + cellHeight;
|
|
1233
|
-
}
|
|
1234
|
-
if (columnHeight) {
|
|
1235
|
-
height = columnHeight;
|
|
1236
|
-
break;
|
|
1237
|
-
}
|
|
1144
|
+
});
|
|
1145
|
+
rows.push(innerRows);
|
|
1146
|
+
} else if (groupedRows?.length === 1) {
|
|
1147
|
+
const dtRow = makeDtRow({
|
|
1148
|
+
...groupedRows[0],
|
|
1149
|
+
...row
|
|
1150
|
+
});
|
|
1151
|
+
rows.push(dtRow);
|
|
1152
|
+
rowIndex++;
|
|
1153
|
+
} else {
|
|
1154
|
+
const dtRow = makeDtRow(row);
|
|
1155
|
+
rows.push(dtRow);
|
|
1156
|
+
rowIndex++;
|
|
1238
1157
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1158
|
+
});
|
|
1159
|
+
this.calculatedRows = rows;
|
|
1160
|
+
return rows;
|
|
1161
|
+
}
|
|
1162
|
+
calculateGridTemplateColumn(c) {
|
|
1163
|
+
return (/*#__PURE__*/React.isValidElement(c) ? c.props.gtcWidth : c.gtcWidth) ?? this.props.defaultGridTemplateColumnWidth;
|
|
1164
|
+
}
|
|
1165
|
+
getHeaderHeight() {
|
|
1166
|
+
const header = this.headerRef.current?.children;
|
|
1167
|
+
let height = 0;
|
|
1168
|
+
for (let i = 0; i < (header?.length ?? 0); i++) {
|
|
1169
|
+
const item = header?.item(i);
|
|
1170
|
+
let columnHeight = item?.getBoundingClientRect().height;
|
|
1171
|
+
if (item instanceof HTMLElement && item.dataset.groupContainer) {
|
|
1172
|
+
const groupHeight = item.children.item(0)?.getBoundingClientRect().height ?? 0;
|
|
1173
|
+
const cellHeight = item.children.item(1)?.getBoundingClientRect().height ?? 0;
|
|
1174
|
+
columnHeight = groupHeight + cellHeight;
|
|
1175
|
+
}
|
|
1176
|
+
if (columnHeight) {
|
|
1177
|
+
height = columnHeight;
|
|
1178
|
+
break;
|
|
1246
1179
|
}
|
|
1247
|
-
return {
|
|
1248
|
-
expandedRows: props.expandedRows
|
|
1249
|
-
};
|
|
1250
1180
|
}
|
|
1251
|
-
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
(0, _defineProperty2
|
|
1255
|
-
(0, _defineProperty2
|
|
1256
|
-
(0, _defineProperty2
|
|
1181
|
+
return height;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
(0, _defineProperty2.default)(DataTableRoot, "displayName", 'DataTable');
|
|
1185
|
+
(0, _defineProperty2.default)(DataTableRoot, "style", style);
|
|
1186
|
+
(0, _defineProperty2.default)(DataTableRoot, "enhance", [(0, _uniqueID.default)(), (0, _i18nEnhance.default)(_intergalacticDynamicLocales.localizedMessages)]);
|
|
1187
|
+
(0, _defineProperty2.default)(DataTableRoot, "defaultProps", {
|
|
1257
1188
|
use: 'primary',
|
|
1258
1189
|
defaultGridTemplateColumnWidth: 'auto',
|
|
1259
1190
|
defaultSelectedRows: undefined,
|
|
1260
1191
|
h: 'fit-content',
|
|
1261
|
-
renderEmptyData:
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
});
|
|
1268
|
-
},
|
|
1192
|
+
renderEmptyData: () => /*#__PURE__*/React.createElement(_widgetEmpty.NoData, {
|
|
1193
|
+
py: 10,
|
|
1194
|
+
type: "nothing-found",
|
|
1195
|
+
description: "",
|
|
1196
|
+
w: "100%"
|
|
1197
|
+
}),
|
|
1269
1198
|
variant: 'default',
|
|
1270
1199
|
accordionAnimationRows: 40,
|
|
1271
1200
|
accordionDuration: 200
|
|
1272
1201
|
});
|
|
1273
|
-
|
|
1202
|
+
const DataTable = exports.DataTable = (0, _core.createComponent)(DataTableRoot, {
|
|
1274
1203
|
Head: _Head.Head,
|
|
1275
1204
|
Body: _Body.Body
|
|
1276
1205
|
});
|