@semcore/data-table 16.0.2 → 16.0.3-prerelease.0
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/README.md +1 -31
- package/lib/cjs/components/Body/Body.js +71 -73
- package/lib/cjs/components/Body/Body.js.map +1 -1
- package/lib/cjs/components/Body/Body.types.js.map +1 -1
- package/lib/cjs/components/Body/Cell.js +57 -58
- package/lib/cjs/components/Body/Cell.js.map +1 -1
- package/lib/cjs/components/Body/Cell.types.js.map +1 -1
- package/lib/cjs/components/Body/MergedCells.js +3 -5
- package/lib/cjs/components/Body/MergedCells.js.map +1 -1
- package/lib/cjs/components/Body/Row.js +57 -58
- package/lib/cjs/components/Body/Row.js.map +1 -1
- package/lib/cjs/components/Body/Row.types.js +0 -2
- package/lib/cjs/components/Body/Row.types.js.map +1 -1
- package/lib/cjs/components/DataTable/DataTable.js +107 -123
- package/lib/cjs/components/DataTable/DataTable.js.map +1 -1
- package/lib/cjs/components/DataTable/DataTable.types.js +0 -2
- package/lib/cjs/components/DataTable/DataTable.types.js.map +1 -1
- package/lib/cjs/components/Head/Column.js +56 -57
- package/lib/cjs/components/Head/Column.js.map +1 -1
- package/lib/cjs/components/Head/Column.types.js.map +1 -1
- package/lib/cjs/components/Head/Group.js +37 -38
- package/lib/cjs/components/Head/Group.js.map +1 -1
- package/lib/cjs/components/Head/Group.type.js.map +1 -1
- package/lib/cjs/components/Head/Head.js +55 -57
- package/lib/cjs/components/Head/Head.js.map +1 -1
- package/lib/cjs/components/Head/Head.types.js.map +1 -1
- package/lib/cjs/index.js +1 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +4 -5
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/components/Body/Body.js +70 -71
- package/lib/es6/components/Body/Body.js.map +1 -1
- package/lib/es6/components/Body/Body.types.js.map +1 -1
- package/lib/es6/components/Body/Cell.js +57 -57
- package/lib/es6/components/Body/Cell.js.map +1 -1
- package/lib/es6/components/Body/Cell.types.js.map +1 -1
- package/lib/es6/components/Body/MergedCells.js.map +1 -1
- package/lib/es6/components/Body/Row.js +56 -56
- package/lib/es6/components/Body/Row.js.map +1 -1
- package/lib/es6/components/Body/Row.types.js +1 -1
- package/lib/es6/components/Body/Row.types.js.map +1 -1
- package/lib/es6/components/DataTable/DataTable.js +101 -110
- package/lib/es6/components/DataTable/DataTable.js.map +1 -1
- package/lib/es6/components/DataTable/DataTable.types.js +1 -1
- package/lib/es6/components/DataTable/DataTable.types.js.map +1 -1
- package/lib/es6/components/Head/Column.js +54 -54
- package/lib/es6/components/Head/Column.js.map +1 -1
- package/lib/es6/components/Head/Column.types.js.map +1 -1
- package/lib/es6/components/Head/Group.js +34 -33
- package/lib/es6/components/Head/Group.js.map +1 -1
- package/lib/es6/components/Head/Group.type.js.map +1 -1
- package/lib/es6/components/Head/Head.js +50 -51
- package/lib/es6/components/Head/Head.js.map +1 -1
- package/lib/es6/components/Head/Head.types.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/components/Body/Body.mjs +73 -72
- package/lib/esm/components/Body/Cell.mjs +59 -57
- package/lib/esm/components/Body/Row.mjs +58 -56
- package/lib/esm/components/DataTable/DataTable.mjs +99 -100
- package/lib/esm/components/Head/Column.mjs +55 -53
- package/lib/esm/components/Head/Group.mjs +38 -35
- package/lib/esm/components/Head/Head.mjs +57 -55
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
- package/lib/types/components/Body/Body.d.ts +7 -7
- package/lib/types/components/Body/Body.types.d.ts +4 -5
- package/lib/types/components/Body/Cell.types.d.ts +3 -4
- package/lib/types/components/Body/MergedCells.d.ts +1 -2
- package/lib/types/components/Body/Row.types.d.ts +5 -6
- package/lib/types/components/DataTable/DataTable.d.ts +3 -3
- package/lib/types/components/DataTable/DataTable.types.d.ts +8 -9
- package/lib/types/components/Head/Column.d.ts +2 -2
- package/lib/types/components/Head/Column.types.d.ts +1 -2
- package/lib/types/components/Head/Group.d.ts +3 -3
- package/lib/types/components/Head/Group.type.d.ts +3 -3
- package/lib/types/components/Head/Head.d.ts +7 -96
- package/lib/types/components/Head/Head.types.d.ts +2 -3
- package/lib/types/index.d.ts +3 -6
- package/package.json +16 -16
|
@@ -3,42 +3,46 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
5
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
-
import
|
|
6
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
7
|
+
import _isNativeReflectConstruct from "@babel/runtime/helpers/esm/isNativeReflectConstruct";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
9
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
10
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import { ScrollArea, ScreenReaderOnly, Box } from "@semcore/base-components";
|
|
13
|
-
import { Head } from "../Head/Head.mjs";
|
|
14
|
-
import { Body } from "../Body/Body.mjs";
|
|
15
|
-
import { hasFocusableIn, isFocusInside } from "@semcore/core/lib/utils/use/useFocusLock";
|
|
16
|
-
import findComponent from "@semcore/core/lib/utils/findComponent";
|
|
17
|
-
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
11
|
+
import { createComponent, sstyled, assignProps, Component, lastInteraction } from "@semcore/core";
|
|
12
|
+
import { ScrollArea, Box, ScreenReaderOnly } from "@semcore/base-components";
|
|
18
13
|
import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
|
|
19
|
-
import
|
|
20
|
-
import { forkRef } from "@semcore/core/lib/utils/ref";
|
|
14
|
+
import findComponent from "@semcore/core/lib/utils/findComponent";
|
|
21
15
|
import { hasParent } from "@semcore/core/lib/utils/hasParent";
|
|
22
16
|
import trottle from "@semcore/core/lib/utils/rafTrottle";
|
|
23
|
-
import {
|
|
17
|
+
import { forkRef } from "@semcore/core/lib/utils/ref";
|
|
18
|
+
import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
|
|
19
|
+
import { hasFocusableIn, isFocusInside } from "@semcore/core/lib/utils/use/useFocusLock";
|
|
24
20
|
import { NoData } from "@semcore/widget-empty";
|
|
21
|
+
import * as React from "react";
|
|
22
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
23
|
+
import { Body } from "../Body/Body.mjs";
|
|
24
|
+
import { MergedRowsCell, MergedColumnsCell } from "../Body/MergedCells.mjs";
|
|
25
|
+
import { Head } from "../Head/Head.mjs";
|
|
26
|
+
function _callSuper(t, o, e) {
|
|
27
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
28
|
+
}
|
|
25
29
|
/*!__reshadow-styles__:"./dataTable.shadow.css"*/
|
|
26
30
|
var style = (
|
|
27
31
|
/*__reshadow_css_start__*/
|
|
28
32
|
(sstyled.insert(
|
|
29
33
|
/*__inner_css_start__*/
|
|
30
|
-
".
|
|
34
|
+
".___SDataTable_1k5kz_gg_{display:grid;align-items:start;min-width:-moz-fit-content;min-width:fit-content}.___SDataTable_1k5kz_gg_.__gridTemplateColumns_1k5kz_gg_{grid-template-columns:var(--gridTemplateColumns_1k5kz)}.___SDataTable_1k5kz_gg_.__gridTemplateAreas_1k5kz_gg_{grid-template-areas:var(--gridTemplateAreas_1k5kz)}.___SDataTable_1k5kz_gg_.__gridTemplateRows_1k5kz_gg_{grid-template-rows:var(--gridTemplateRows_1k5kz)}",
|
|
31
35
|
/*__inner_css_end__*/
|
|
32
|
-
"
|
|
36
|
+
"1k5kz_gg_"
|
|
33
37
|
), /*__reshadow_css_end__*/
|
|
34
38
|
{
|
|
35
|
-
"__SDataTable": "
|
|
36
|
-
"_gridTemplateColumns": "
|
|
37
|
-
"--gridTemplateColumns": "--
|
|
38
|
-
"_gridTemplateAreas": "
|
|
39
|
-
"--gridTemplateAreas": "--
|
|
40
|
-
"_gridTemplateRows": "
|
|
41
|
-
"--gridTemplateRows": "--
|
|
39
|
+
"__SDataTable": "___SDataTable_1k5kz_gg_",
|
|
40
|
+
"_gridTemplateColumns": "__gridTemplateColumns_1k5kz_gg_",
|
|
41
|
+
"--gridTemplateColumns": "--gridTemplateColumns_1k5kz",
|
|
42
|
+
"_gridTemplateAreas": "__gridTemplateAreas_1k5kz_gg_",
|
|
43
|
+
"--gridTemplateAreas": "--gridTemplateAreas_1k5kz",
|
|
44
|
+
"_gridTemplateRows": "__gridTemplateRows_1k5kz_gg_",
|
|
45
|
+
"--gridTemplateRows": "--gridTemplateRows_1k5kz"
|
|
42
46
|
})
|
|
43
47
|
);
|
|
44
48
|
/*!__reshadow-styles__:"../../style/scroll-shadows.shadow.css"*/
|
|
@@ -46,25 +50,25 @@ var scrollStyles = (
|
|
|
46
50
|
/*__reshadow_css_start__*/
|
|
47
51
|
(sstyled.insert(
|
|
48
52
|
/*__inner_css_start__*/
|
|
49
|
-
".
|
|
53
|
+
".___SScrollArea_qh4me_gg_{width:-moz-fit-content;width:fit-content}.___SScrollArea_qh4me_gg_ .___SContainer_qh4me_gg_{overflow:visible;overflow:initial}.___SScrollArea_qh4me_gg_ .___SContainer_qh4me_gg_._scrollDirection_both_qh4me_gg_{overflow:auto}.___SScrollArea_qh4me_gg_ .___SContainer_qh4me_gg_._scrollDirection_horizontal_qh4me_gg_{overflow-x:auto;overflow-y:initial}.___SScrollArea_qh4me_gg_ .___SContainer_qh4me_gg_._scrollDirection_vertical_qh4me_gg_{overflow-x:initial;overflow-y:auto}.___SScrollArea_qh4me_gg_ .___SContainer_qh4me_gg_.__loading_qh4me_gg_{overflow:hidden}.___SScrollArea_qh4me_gg_ .___SContainer_qh4me_gg_.__headerHeight_qh4me_gg_{scroll-padding-top:var(--headerHeight_qh4me)}.___SScrollArea_qh4me_gg_ .___SContainer_qh4me_gg_.__leftScrollPadding_qh4me_gg_{scroll-padding-left:var(--leftScrollPadding_qh4me)}.___SScrollArea_qh4me_gg_ .___SContainer_qh4me_gg_.__rightScrollPadding_qh4me_gg_{scroll-padding-right:var(--rightScrollPadding_qh4me)}.___SScrollArea_qh4me_gg_ .___SShadowVertical_qh4me_gg_:before{display:none}.___SScrollArea_qh4me_gg_ .___SShadowHorizontal_qh4me_gg_:after,.___SScrollArea_qh4me_gg_ .___SShadowHorizontal_qh4me_gg_:before,.___SScrollArea_qh4me_gg_ .___SShadowVertical_qh4me_gg_:after{z-index:2}",
|
|
50
54
|
/*__inner_css_end__*/
|
|
51
|
-
"
|
|
55
|
+
"qh4me_gg_"
|
|
52
56
|
), /*__reshadow_css_end__*/
|
|
53
57
|
{
|
|
54
|
-
"__SScrollArea": "
|
|
55
|
-
"__SContainer": "
|
|
56
|
-
"_scrollDirection_both": "
|
|
57
|
-
"_scrollDirection_horizontal": "
|
|
58
|
-
"_scrollDirection_vertical": "
|
|
59
|
-
"_loading": "
|
|
60
|
-
"_headerHeight": "
|
|
61
|
-
"--headerHeight": "--
|
|
62
|
-
"_leftScrollPadding": "
|
|
63
|
-
"--leftScrollPadding": "--
|
|
64
|
-
"_rightScrollPadding": "
|
|
65
|
-
"--rightScrollPadding": "--
|
|
66
|
-
"__SShadowVertical": "
|
|
67
|
-
"__SShadowHorizontal": "
|
|
58
|
+
"__SScrollArea": "___SScrollArea_qh4me_gg_",
|
|
59
|
+
"__SContainer": "___SContainer_qh4me_gg_",
|
|
60
|
+
"_scrollDirection_both": "_scrollDirection_both_qh4me_gg_",
|
|
61
|
+
"_scrollDirection_horizontal": "_scrollDirection_horizontal_qh4me_gg_",
|
|
62
|
+
"_scrollDirection_vertical": "_scrollDirection_vertical_qh4me_gg_",
|
|
63
|
+
"_loading": "__loading_qh4me_gg_",
|
|
64
|
+
"_headerHeight": "__headerHeight_qh4me_gg_",
|
|
65
|
+
"--headerHeight": "--headerHeight_qh4me",
|
|
66
|
+
"_leftScrollPadding": "__leftScrollPadding_qh4me_gg_",
|
|
67
|
+
"--leftScrollPadding": "--leftScrollPadding_qh4me",
|
|
68
|
+
"_rightScrollPadding": "__rightScrollPadding_qh4me_gg_",
|
|
69
|
+
"--rightScrollPadding": "--rightScrollPadding_qh4me",
|
|
70
|
+
"__SShadowVertical": "___SShadowVertical_qh4me_gg_",
|
|
71
|
+
"__SShadowHorizontal": "___SShadowHorizontal_qh4me_gg_"
|
|
68
72
|
})
|
|
69
73
|
);
|
|
70
74
|
var ACCORDION = Symbol("accordion");
|
|
@@ -74,35 +78,32 @@ var SELECT_ALL = Symbol("SELECT_ALL");
|
|
|
74
78
|
var ROW_INDEX = Symbol("ROW_INDEX");
|
|
75
79
|
var SCROLL_BAR_HEIGHT = 12;
|
|
76
80
|
var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
77
|
-
_inherits(DataTableRoot2, _Component);
|
|
78
|
-
var _super = _createSuper(DataTableRoot2);
|
|
79
81
|
function DataTableRoot2(props) {
|
|
80
82
|
var _this;
|
|
81
83
|
_classCallCheck(this, DataTableRoot2);
|
|
82
|
-
_this =
|
|
83
|
-
_defineProperty(
|
|
84
|
-
_defineProperty(
|
|
85
|
-
_defineProperty(
|
|
86
|
-
_defineProperty(
|
|
87
|
-
_defineProperty(
|
|
88
|
-
_defineProperty(
|
|
89
|
-
_defineProperty(
|
|
90
|
-
_defineProperty(
|
|
91
|
-
_defineProperty(
|
|
92
|
-
_defineProperty(
|
|
93
|
-
_defineProperty(
|
|
94
|
-
_defineProperty(
|
|
95
|
-
_defineProperty(
|
|
96
|
-
_defineProperty(
|
|
97
|
-
_defineProperty(
|
|
98
|
-
_defineProperty(
|
|
84
|
+
_this = _callSuper(this, DataTableRoot2, [props]);
|
|
85
|
+
_defineProperty(_this, "columns", []);
|
|
86
|
+
_defineProperty(_this, "treeColumns", []);
|
|
87
|
+
_defineProperty(_this, "hasGroups", false);
|
|
88
|
+
_defineProperty(_this, "focusedCell", [-1, -1]);
|
|
89
|
+
_defineProperty(_this, "scrollAreaRef", /* @__PURE__ */ React.createRef());
|
|
90
|
+
_defineProperty(_this, "tableContainerRef", /* @__PURE__ */ React.createRef());
|
|
91
|
+
_defineProperty(_this, "tableRef", /* @__PURE__ */ React.createRef());
|
|
92
|
+
_defineProperty(_this, "headerRef", /* @__PURE__ */ React.createRef());
|
|
93
|
+
_defineProperty(_this, "spinnerRef", /* @__PURE__ */ React.createRef());
|
|
94
|
+
_defineProperty(_this, "gridAreaGroupMap", /* @__PURE__ */ new Map());
|
|
95
|
+
_defineProperty(_this, "columnsSplitter", "/");
|
|
96
|
+
_defineProperty(_this, "rows", []);
|
|
97
|
+
_defineProperty(_this, "flatRows", []);
|
|
98
|
+
_defineProperty(_this, "selectAllMessageTimer", 0);
|
|
99
|
+
_defineProperty(_this, "headerNodesMap", /* @__PURE__ */ new Map());
|
|
100
|
+
_defineProperty(_this, "state", {
|
|
99
101
|
scrollTop: 0,
|
|
100
102
|
scrollDirection: "down",
|
|
101
103
|
selectAllMessage: ""
|
|
102
104
|
});
|
|
103
|
-
_defineProperty(
|
|
105
|
+
_defineProperty(_this, "handleSelectRow", function(isSelected, selectedRowIndex, row, event) {
|
|
104
106
|
var _this$asProps = _this.asProps, selectedRows = _this$asProps.selectedRows, onSelectedRowsChange = _this$asProps.onSelectedRowsChange;
|
|
105
|
-
_this$asProps.data;
|
|
106
107
|
if (selectedRows && onSelectedRowsChange) {
|
|
107
108
|
var newSelectedRows = new Set(selectedRows);
|
|
108
109
|
if (isSelected && !newSelectedRows.has(selectedRowIndex)) {
|
|
@@ -117,7 +118,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
120
|
});
|
|
120
|
-
_defineProperty(
|
|
121
|
+
_defineProperty(_this, "setSelectAllMessage", function(selectedAll) {
|
|
121
122
|
if (_this.selectAllMessageTimer) {
|
|
122
123
|
clearTimeout(_this.selectAllMessageTimer);
|
|
123
124
|
}
|
|
@@ -132,14 +133,14 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
132
133
|
});
|
|
133
134
|
}, 5e3);
|
|
134
135
|
});
|
|
135
|
-
_defineProperty(
|
|
136
|
+
_defineProperty(_this, "getRow", function(index) {
|
|
136
137
|
var _this$tableRef$curren;
|
|
137
138
|
return (_this$tableRef$curren = _this.tableRef.current) === null || _this$tableRef$curren === void 0 ? void 0 : _this$tableRef$curren.querySelector('[aria-rowindex="'.concat(index + 1, '"]:not([aria-hidden="true"])'));
|
|
138
139
|
});
|
|
139
|
-
_defineProperty(
|
|
140
|
+
_defineProperty(_this, "hasFocusableInHeader", function() {
|
|
140
141
|
return _this.headerRef.current && hasFocusableIn(_this.headerRef.current);
|
|
141
142
|
});
|
|
142
|
-
_defineProperty(
|
|
143
|
+
_defineProperty(_this, "onExpandRow", function(expandedRow) {
|
|
143
144
|
var expandedRows = _this.asProps.expandedRows;
|
|
144
145
|
if (expandedRows.has(expandedRow[UNIQ_ROW_KEY])) {
|
|
145
146
|
expandedRows["delete"](expandedRow[UNIQ_ROW_KEY]);
|
|
@@ -151,7 +152,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
151
152
|
_this.handlers.expandedRows(new Set(_toConsumableArray(expandedRows)));
|
|
152
153
|
}
|
|
153
154
|
});
|
|
154
|
-
_defineProperty(
|
|
155
|
+
_defineProperty(_this, "changeFocusCell", function(rowIndex, colIndex, direction) {
|
|
155
156
|
var _this$tableRef$curren2, _this$tableRef$curren3;
|
|
156
157
|
var hasFocusable = _this.hasFocusableInHeader();
|
|
157
158
|
var maxCol = _this.columns.length - 1;
|
|
@@ -174,9 +175,9 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
174
175
|
var cell = row === null || row === void 0 ? void 0 : row.querySelector(':scope > div > [role=gridcell][aria-colindex="'.concat(newCol + 1, '"], :scope > [role=columnheader][aria-colindex="').concat(newCol + 1, '"], :scope > div > [role=columnheader][aria-colindex="').concat(newCol + 1, '"]'));
|
|
175
176
|
if (cell instanceof HTMLElement && currentCell !== cell) {
|
|
176
177
|
_this.focusedCell = [newRow, newCol];
|
|
177
|
-
currentCell === null || currentCell === void 0
|
|
178
|
+
currentCell === null || currentCell === void 0 || currentCell.setAttribute("inert", "");
|
|
178
179
|
if (currentCell !== currentHeaderCell) {
|
|
179
|
-
currentCell === null || currentCell === void 0
|
|
180
|
+
currentCell === null || currentCell === void 0 || currentCell.removeAttribute("aria-describedby");
|
|
180
181
|
}
|
|
181
182
|
var headerCell = headerCells === null || headerCells === void 0 ? void 0 : headerCells.item(newCol);
|
|
182
183
|
var describedBy = headerCell === null || headerCell === void 0 ? void 0 : headerCell.getAttribute("aria-describedby");
|
|
@@ -184,21 +185,21 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
184
185
|
if (headerCell !== cell && describedBy) {
|
|
185
186
|
cell.setAttribute("aria-describedby", describedBy);
|
|
186
187
|
}
|
|
187
|
-
cell === null || cell === void 0
|
|
188
|
+
cell === null || cell === void 0 || cell.focus();
|
|
188
189
|
if (newRow !== 0) {
|
|
189
|
-
currentHeaderCell === null || currentHeaderCell === void 0
|
|
190
|
+
currentHeaderCell === null || currentHeaderCell === void 0 || currentHeaderCell.setAttribute("inert", "");
|
|
190
191
|
var _headerCell = headerCells === null || headerCells === void 0 ? void 0 : headerCells.item(newCol);
|
|
191
|
-
_headerCell === null || _headerCell === void 0
|
|
192
|
+
_headerCell === null || _headerCell === void 0 || _headerCell.removeAttribute("inert");
|
|
192
193
|
}
|
|
193
194
|
} else if (cell === null && currentCell instanceof HTMLElement) {
|
|
194
195
|
var rowI = rowIndex;
|
|
195
196
|
var colI = colIndex;
|
|
196
197
|
if (direction === "left" || direction === "right") {
|
|
197
|
-
var _currentCell$parentEl, _currentCell$parentEl2,
|
|
198
|
-
if (((_currentCell$parentEl = currentCell.parentElement) === null || _currentCell$parentEl === void 0
|
|
198
|
+
var _currentCell$parentEl, _currentCell$parentEl2, _row$children;
|
|
199
|
+
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") {
|
|
199
200
|
return;
|
|
200
201
|
}
|
|
201
|
-
if (currentCell.dataset.groupedBy === "colgroup" || Number((_currentCell$
|
|
202
|
+
if (currentCell.dataset.groupedBy === "colgroup" || Number((_currentCell$parentEl2 = currentCell.parentElement) === null || _currentCell$parentEl2 === void 0 || (_currentCell$parentEl2 = _currentCell$parentEl2.parentElement) === null || _currentCell$parentEl2 === void 0 ? void 0 : _currentCell$parentEl2.getAttribute("aria-rowindex")) === 2 || currentCell.parentElement && Array.from((_row$children = row === null || row === void 0 ? void 0 : row.children) !== null && _row$children !== void 0 ? _row$children : []).indexOf(currentCell.parentElement) > 0) {
|
|
202
203
|
colI = direction === "left" ? colI - 1 : colI + 1;
|
|
203
204
|
} else {
|
|
204
205
|
rowI = rowI - 1;
|
|
@@ -218,7 +219,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
218
219
|
_this.changeFocusCell(rowIndex + 1, colIndex, direction);
|
|
219
220
|
}
|
|
220
221
|
});
|
|
221
|
-
_defineProperty(
|
|
222
|
+
_defineProperty(_this, "handleKeyDown", function(e) {
|
|
222
223
|
switch (e.key) {
|
|
223
224
|
case "Tab": {
|
|
224
225
|
_this.setInert(true);
|
|
@@ -246,7 +247,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
249
|
});
|
|
249
|
-
_defineProperty(
|
|
250
|
+
_defineProperty(_this, "initFocusableCell", function() {
|
|
250
251
|
var hasFocusable = _this.hasFocusableInHeader();
|
|
251
252
|
if (hasFocusable) {
|
|
252
253
|
_this.focusedCell = [0, 0];
|
|
@@ -254,7 +255,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
254
255
|
_this.focusedCell = [1, 0];
|
|
255
256
|
}
|
|
256
257
|
});
|
|
257
|
-
_defineProperty(
|
|
258
|
+
_defineProperty(_this, "handleScroll", trottle(function(e) {
|
|
258
259
|
var scrollTop = e.target.scrollTop;
|
|
259
260
|
var scrollDirection = scrollTop > _this.state.scrollTop ? "down" : "up";
|
|
260
261
|
_this.setState({
|
|
@@ -262,10 +263,10 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
262
263
|
scrollDirection
|
|
263
264
|
});
|
|
264
265
|
}));
|
|
265
|
-
_defineProperty(
|
|
266
|
+
_defineProperty(_this, "handleFocus", function(e) {
|
|
266
267
|
if (_this.asProps.loading) {
|
|
267
268
|
var _this$spinnerRef$curr;
|
|
268
|
-
(_this$spinnerRef$curr = _this.spinnerRef.current) === null || _this$spinnerRef$curr === void 0
|
|
269
|
+
(_this$spinnerRef$curr = _this.spinnerRef.current) === null || _this$spinnerRef$curr === void 0 || _this$spinnerRef$curr.focus();
|
|
269
270
|
e.currentTarget.setAttribute("tabIndex", "-1");
|
|
270
271
|
} else if ((!e.relatedTarget || !isFocusInside(e.currentTarget, e.relatedTarget)) && lastInteraction.isKeyboard()) {
|
|
271
272
|
var _row;
|
|
@@ -281,18 +282,18 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
281
282
|
if (!row && _this.asProps.virtualScroll) {
|
|
282
283
|
var _this$tableRef$curren4, _firstAvailableCell$p;
|
|
283
284
|
var firstAvailableCell = (_this$tableRef$curren4 = _this.tableRef.current) === null || _this$tableRef$curren4 === void 0 ? void 0 : _this$tableRef$curren4.querySelector('[role="gridcell"]');
|
|
284
|
-
var firstAvailableRow = firstAvailableCell === null || firstAvailableCell === void 0
|
|
285
|
+
var firstAvailableRow = firstAvailableCell === null || firstAvailableCell === void 0 || (_firstAvailableCell$p = firstAvailableCell.parentElement) === null || _firstAvailableCell$p === void 0 ? void 0 : _firstAvailableCell$p.parentElement;
|
|
285
286
|
if (firstAvailableCell && firstAvailableRow) {
|
|
286
|
-
var
|
|
287
|
-
var colIndex = ((
|
|
288
|
-
var rowIndex = ((
|
|
287
|
+
var _firstAvailableCell$g, _firstAvailableRow$ge;
|
|
288
|
+
var colIndex = Number((_firstAvailableCell$g = firstAvailableCell.getAttribute("aria-colindex")) !== null && _firstAvailableCell$g !== void 0 ? _firstAvailableCell$g : 1) - 1;
|
|
289
|
+
var rowIndex = Number((_firstAvailableRow$ge = firstAvailableRow.getAttribute("aria-rowindex")) !== null && _firstAvailableRow$ge !== void 0 ? _firstAvailableRow$ge : 1) - 1;
|
|
289
290
|
_this.focusedCell[0] = rowIndex;
|
|
290
291
|
_this.focusedCell[1] = colIndex;
|
|
291
292
|
row = firstAvailableRow;
|
|
292
293
|
}
|
|
293
294
|
}
|
|
294
295
|
var cell = (_row = row) === null || _row === void 0 ? void 0 : _row.querySelectorAll("[role=gridcell], [role=columnheader]").item(_this.focusedCell[1]);
|
|
295
|
-
cell === null || cell === void 0
|
|
296
|
+
cell === null || cell === void 0 || cell.removeAttribute("inert");
|
|
296
297
|
if (cell instanceof HTMLElement) {
|
|
297
298
|
if (hasParent(e.target, cell)) {
|
|
298
299
|
e.target.focus();
|
|
@@ -303,7 +304,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
303
304
|
e.currentTarget.setAttribute("tabIndex", "-1");
|
|
304
305
|
}
|
|
305
306
|
});
|
|
306
|
-
_defineProperty(
|
|
307
|
+
_defineProperty(_this, "handleBlur", function(e) {
|
|
307
308
|
var relatedTarget = e.relatedTarget;
|
|
308
309
|
var tableElement = _this.tableRef.current;
|
|
309
310
|
if (tableElement && (!relatedTarget || !isFocusInside(tableElement, relatedTarget) || !lastInteraction.isKeyboard())) {
|
|
@@ -311,13 +312,13 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
311
312
|
tableElement.setAttribute("tabIndex", "0");
|
|
312
313
|
}
|
|
313
314
|
});
|
|
314
|
-
_defineProperty(
|
|
315
|
+
_defineProperty(_this, "handleMouseMove", function() {
|
|
315
316
|
_this.setInert(false);
|
|
316
317
|
});
|
|
317
|
-
_defineProperty(
|
|
318
|
+
_defineProperty(_this, "handleBackFromAccordion", function(cellIndex) {
|
|
318
319
|
_this.changeFocusCell(-1, cellIndex === -1 ? 0 : cellIndex, "up");
|
|
319
320
|
});
|
|
320
|
-
_defineProperty(
|
|
321
|
+
_defineProperty(_this, "getScrollOffsetValue", function() {
|
|
321
322
|
if (!_this.headerRef.current) {
|
|
322
323
|
return [0, 0];
|
|
323
324
|
}
|
|
@@ -354,7 +355,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
354
355
|
return acc;
|
|
355
356
|
}, [0, 0]);
|
|
356
357
|
});
|
|
357
|
-
_defineProperty(
|
|
358
|
+
_defineProperty(_this, "getFixedStyle", function(cell) {
|
|
358
359
|
var side = cell.fixed;
|
|
359
360
|
if (!side) return [void 0, void 0];
|
|
360
361
|
var names = cell.name.split("/");
|
|
@@ -394,7 +395,8 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
394
395
|
_this.flatRows = _this.rows.flat();
|
|
395
396
|
return _this;
|
|
396
397
|
}
|
|
397
|
-
|
|
398
|
+
_inherits(DataTableRoot2, _Component);
|
|
399
|
+
return _createClass(DataTableRoot2, [{
|
|
398
400
|
key: "uncontrolledProps",
|
|
399
401
|
value: function uncontrolledProps() {
|
|
400
402
|
return {
|
|
@@ -509,7 +511,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
509
511
|
var selectedRowsIndexes = value ? new Array(_this3.totalRows).fill(void 0).map(function(_, i) {
|
|
510
512
|
return i;
|
|
511
513
|
}) : [];
|
|
512
|
-
onSelectedRowsChange === null || onSelectedRowsChange === void 0
|
|
514
|
+
onSelectedRowsChange === null || onSelectedRowsChange === void 0 || onSelectedRowsChange(selectedRowsIndexes, e);
|
|
513
515
|
},
|
|
514
516
|
getFixedStyle: this.getFixedStyle
|
|
515
517
|
}, headerProps);
|
|
@@ -558,7 +560,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
558
560
|
value: function setInert(value) {
|
|
559
561
|
var _this$tableRef$curren5;
|
|
560
562
|
var cells = (_this$tableRef$curren5 = this.tableRef.current) === null || _this$tableRef$curren5 === void 0 ? void 0 : _this$tableRef$curren5.querySelectorAll("[role=gridcell], [role=columnheader]");
|
|
561
|
-
cells === null || cells === void 0
|
|
563
|
+
cells === null || cells === void 0 || cells.forEach(function(cell) {
|
|
562
564
|
if (value === true) {
|
|
563
565
|
cell.setAttribute("inert", "");
|
|
564
566
|
} else {
|
|
@@ -803,7 +805,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
803
805
|
col2.gridArea = "2 / ".concat(gridColumnIndex, " / 3 / ").concat(gridColumnIndex + 1);
|
|
804
806
|
gridColumnIndex++;
|
|
805
807
|
calculatedColumns.push(col2);
|
|
806
|
-
(_Group$columns = Group.columns) === null || _Group$columns === void 0
|
|
808
|
+
(_Group$columns = Group.columns) === null || _Group$columns === void 0 || _Group$columns.push(col2);
|
|
807
809
|
});
|
|
808
810
|
treeColumns.push(Group);
|
|
809
811
|
_this5.gridAreaGroupMap.set(groupIndex, "1 / ".concat(initGridColumn, " / 2 / ").concat(gridColumnIndex));
|
|
@@ -825,7 +827,6 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
825
827
|
var rowIndex = 0;
|
|
826
828
|
var id = 1e8;
|
|
827
829
|
var makeDtRow = function makeDtRow2(row, excludeColumns) {
|
|
828
|
-
var _Object$entries$reduc;
|
|
829
830
|
var columns2 = new Set(columnNames);
|
|
830
831
|
var dtRow = Object.entries(row).reduce(function(acc, _ref5) {
|
|
831
832
|
var _ref6 = _slicedToArray(_ref5, 2), key = _ref6[0], value = _ref6[1];
|
|
@@ -846,8 +847,8 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
846
847
|
acc[ACCORDION] = row[ACCORDION];
|
|
847
848
|
}
|
|
848
849
|
return acc;
|
|
849
|
-
}, (
|
|
850
|
-
excludeColumns === null || excludeColumns === void 0
|
|
850
|
+
}, _defineProperty(_defineProperty({}, UNIQ_ROW_KEY, row[UNIQ_ROW_KEY] || "".concat(uid, "_").concat((rowIndex + id).toString(36))), ROW_INDEX, rowIndex));
|
|
851
|
+
excludeColumns === null || excludeColumns === void 0 || excludeColumns.forEach(function(value) {
|
|
851
852
|
columns2["delete"](value);
|
|
852
853
|
});
|
|
853
854
|
if (columns2.size > 0) {
|
|
@@ -860,7 +861,6 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
860
861
|
data.forEach(function(row) {
|
|
861
862
|
var groupedRows = row[ROW_GROUP];
|
|
862
863
|
if (groupedRows) {
|
|
863
|
-
var _Object$entries$reduc2;
|
|
864
864
|
var innerRows = [];
|
|
865
865
|
var groupedKeys = [];
|
|
866
866
|
var groupedRowData = Object.entries(row).reduce(function(acc, _ref7) {
|
|
@@ -868,7 +868,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
868
868
|
acc[key] = new MergedRowsCell(value, groupedRows.length, row[ACCORDION]);
|
|
869
869
|
groupedKeys.push(key);
|
|
870
870
|
return acc;
|
|
871
|
-
}, (
|
|
871
|
+
}, _defineProperty(_defineProperty({}, UNIQ_ROW_KEY, ""), ROW_INDEX, -1));
|
|
872
872
|
groupedRows.forEach(function(childRow, index) {
|
|
873
873
|
var dtRow2;
|
|
874
874
|
if (index === 0) {
|
|
@@ -876,12 +876,12 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
876
876
|
dtRow2 = makeDtRow(rowData);
|
|
877
877
|
dtRow2[ROW_GROUP] = /* @__PURE__ */ new Set();
|
|
878
878
|
} else {
|
|
879
|
-
var _innerRows
|
|
879
|
+
var _innerRows$;
|
|
880
880
|
if (index === groupedRows.length - 1 && row[ACCORDION]) {
|
|
881
881
|
childRow[ACCORDION] = row[ACCORDION];
|
|
882
882
|
}
|
|
883
883
|
dtRow2 = makeDtRow(childRow, groupedKeys);
|
|
884
|
-
(_innerRows$ = innerRows[0]) === null || _innerRows$ === void 0
|
|
884
|
+
(_innerRows$ = innerRows[0]) === null || _innerRows$ === void 0 || (_innerRows$ = _innerRows$[ROW_GROUP]) === null || _innerRows$ === void 0 || _innerRows$.add(dtRow2[UNIQ_ROW_KEY]);
|
|
885
885
|
}
|
|
886
886
|
innerRows.push(dtRow2);
|
|
887
887
|
rowIndex++;
|
|
@@ -909,7 +909,7 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
909
909
|
var height = 0;
|
|
910
910
|
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++) {
|
|
911
911
|
var _header$length, _header$item;
|
|
912
|
-
var columnHeight = header === null || header === void 0
|
|
912
|
+
var columnHeight = header === null || header === void 0 || (_header$item = header.item(i)) === null || _header$item === void 0 ? void 0 : _header$item.getBoundingClientRect().height;
|
|
913
913
|
if (columnHeight) {
|
|
914
914
|
height = columnHeight;
|
|
915
915
|
break;
|
|
@@ -918,7 +918,6 @@ var DataTableRoot = /* @__PURE__ */ function(_Component) {
|
|
|
918
918
|
return height;
|
|
919
919
|
}
|
|
920
920
|
}]);
|
|
921
|
-
return DataTableRoot2;
|
|
922
921
|
}(Component);
|
|
923
922
|
_defineProperty(DataTableRoot, "displayName", "DataTable");
|
|
924
923
|
_defineProperty(DataTableRoot, "style", style);
|