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