@semcore/data-table 17.0.0-prerelease.36 → 17.0.0-prerelease.39
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 +1 -1
- package/lib/cjs/components/DataTable/DataTable.js +14 -40
- package/lib/cjs/components/DataTable/DataTable.js.map +1 -1
- package/lib/cjs/components/Head/Head.js +6 -1
- package/lib/cjs/components/Head/Head.js.map +1 -1
- package/lib/cjs/components/RowSelector/RowsSelector.js +1 -1
- package/lib/cjs/components/RowSelector/RowsSelector.js.map +1 -1
- package/lib/cjs/components/RowSelector/SRAnnouncer.js +49 -0
- package/lib/cjs/components/RowSelector/SRAnnouncer.js.map +1 -0
- package/lib/cjs/components/RowSelector/SRReactiveAnnouncer.js +31 -0
- package/lib/cjs/components/RowSelector/SRReactiveAnnouncer.js.map +1 -0
- package/lib/cjs/store/SelectableRows.js +6 -5
- package/lib/cjs/store/SelectableRows.js.map +1 -1
- package/lib/cjs/translations/de.json +6 -1
- package/lib/cjs/translations/es.json +6 -1
- package/lib/cjs/translations/fr.json +6 -1
- package/lib/cjs/translations/it.json +6 -1
- package/lib/cjs/translations/ja.json +6 -1
- package/lib/cjs/translations/ko.json +6 -1
- package/lib/cjs/translations/nl.json +6 -1
- package/lib/cjs/translations/pl.json +6 -1
- package/lib/cjs/translations/pt.json +6 -1
- package/lib/cjs/translations/sv.json +6 -1
- package/lib/cjs/translations/tr.json +6 -1
- package/lib/cjs/translations/vi.json +6 -1
- package/lib/cjs/translations/zh.json +6 -1
- package/lib/es6/components/DataTable/DataTable.js +15 -41
- package/lib/es6/components/DataTable/DataTable.js.map +1 -1
- package/lib/es6/components/Head/Head.js +6 -1
- package/lib/es6/components/Head/Head.js.map +1 -1
- package/lib/es6/components/RowSelector/RowsSelector.js +1 -1
- package/lib/es6/components/RowSelector/RowsSelector.js.map +1 -1
- package/lib/es6/components/RowSelector/SRAnnouncer.js +42 -0
- package/lib/es6/components/RowSelector/SRAnnouncer.js.map +1 -0
- package/lib/es6/components/RowSelector/SRReactiveAnnouncer.js +24 -0
- package/lib/es6/components/RowSelector/SRReactiveAnnouncer.js.map +1 -0
- package/lib/es6/store/SelectableRows.js +6 -5
- package/lib/es6/store/SelectableRows.js.map +1 -1
- package/lib/es6/translations/de.json +6 -1
- package/lib/es6/translations/es.json +6 -1
- package/lib/es6/translations/fr.json +6 -1
- package/lib/es6/translations/it.json +6 -1
- package/lib/es6/translations/ja.json +6 -1
- package/lib/es6/translations/ko.json +6 -1
- package/lib/es6/translations/nl.json +6 -1
- package/lib/es6/translations/pl.json +6 -1
- package/lib/es6/translations/pt.json +6 -1
- package/lib/es6/translations/sv.json +6 -1
- package/lib/es6/translations/tr.json +6 -1
- package/lib/es6/translations/vi.json +6 -1
- package/lib/es6/translations/zh.json +6 -1
- package/lib/esm/components/AccordionRows/AccordionRows.mjs +0 -1
- package/lib/esm/components/Body/Body.mjs +19 -26
- package/lib/esm/components/Body/Cell.mjs +6 -9
- package/lib/esm/components/Body/LimitOverlay.mjs +2 -3
- package/lib/esm/components/Body/Row.mjs +18 -23
- package/lib/esm/components/Body/RowGroup.mjs +3 -3
- package/lib/esm/components/DataTable/DataTable.mjs +91 -134
- package/lib/esm/components/Head/Column.mjs +13 -19
- package/lib/esm/components/Head/Group.mjs +1 -2
- package/lib/esm/components/Head/Head.mjs +15 -15
- package/lib/esm/components/RowSelector/RowsSelector.mjs +6 -7
- package/lib/esm/components/RowSelector/SRAnnouncer.mjs +44 -0
- package/lib/esm/components/RowSelector/SRReactiveAnnouncer.mjs +26 -0
- package/lib/esm/enhancers/focusableCell.mjs +4 -5
- package/lib/esm/store/SelectableRows.mjs +6 -5
- package/lib/esm/translations/de.json.mjs +6 -1
- package/lib/esm/translations/es.json.mjs +6 -1
- package/lib/esm/translations/fr.json.mjs +6 -1
- package/lib/esm/translations/it.json.mjs +6 -1
- package/lib/esm/translations/ja.json.mjs +6 -1
- package/lib/esm/translations/ko.json.mjs +6 -1
- package/lib/esm/translations/nl.json.mjs +6 -1
- package/lib/esm/translations/pl.json.mjs +6 -1
- package/lib/esm/translations/pt.json.mjs +6 -1
- package/lib/esm/translations/sv.json.mjs +6 -1
- package/lib/esm/translations/tr.json.mjs +6 -1
- package/lib/esm/translations/vi.json.mjs +6 -1
- package/lib/esm/translations/zh.json.mjs +6 -1
- package/lib/types/components/RowSelector/SRAnnouncer.d.ts +10 -0
- package/lib/types/components/RowSelector/SRReactiveAnnouncer.d.ts +8 -0
- package/lib/types/store/SelectableRows.d.ts +5 -1
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +65 -0
- package/package.json +20 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { sstyled, Component, lastInteraction, assignProps, createComponent } from "@semcore/core";
|
|
3
|
+
import { Box, ScrollArea } from "@semcore/base-components";
|
|
4
4
|
import canUseDOM from "@semcore/core/lib/utils/canUseDOM";
|
|
5
5
|
import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
|
|
6
6
|
import findComponent from "@semcore/core/lib/utils/findComponent";
|
|
@@ -16,7 +16,8 @@ import { localizedMessages } from "../../translations/__intergalactic-dynamic-lo
|
|
|
16
16
|
import { Body } from "../Body/Body.mjs";
|
|
17
17
|
import { MergedRowsCell, MergedColumnsCell } from "../Body/MergedCells.mjs";
|
|
18
18
|
import { Head } from "../Head/Head.mjs";
|
|
19
|
-
|
|
19
|
+
import { SRAnnouncer } from "../RowSelector/SRAnnouncer.mjs";
|
|
20
|
+
import { SRReactiveAnnouncer } from "../RowSelector/SRReactiveAnnouncer.mjs";
|
|
20
21
|
const style = (
|
|
21
22
|
/*__reshadow_css_start__*/
|
|
22
23
|
(sstyled.insert(
|
|
@@ -36,7 +37,6 @@ const style = (
|
|
|
36
37
|
"--gridTemplateRows": "--gridTemplateRows_wo0cb"
|
|
37
38
|
})
|
|
38
39
|
);
|
|
39
|
-
/*!__reshadow-styles__:"../../style/scroll-shadows.shadow.css"*/
|
|
40
40
|
const scrollStyles = (
|
|
41
41
|
/*__reshadow_css_start__*/
|
|
42
42
|
(sstyled.insert(
|
|
@@ -64,13 +64,13 @@ const scrollStyles = (
|
|
|
64
64
|
"_rightOffset": "__rightOffset_j4820_gg_"
|
|
65
65
|
})
|
|
66
66
|
);
|
|
67
|
-
const ACCORDION = Symbol("accordion");
|
|
68
|
-
const ROW_GROUP = Symbol("ROW_GROUP");
|
|
69
|
-
const UNIQ_ROW_KEY = Symbol("UNIQ_ROW_KEY");
|
|
70
|
-
const IS_EMPTY_DATA_ROW = Symbol("IS_EMPTY_DATA_ROW");
|
|
71
|
-
const SELECT_ALL = Symbol("SELECT_ALL");
|
|
72
|
-
const ROW_INDEX = Symbol("ROW_INDEX");
|
|
73
|
-
const GRID_ROW_INDEX = Symbol("GRID_ROW_INDEX");
|
|
67
|
+
const ACCORDION = /* @__PURE__ */ Symbol("accordion");
|
|
68
|
+
const ROW_GROUP = /* @__PURE__ */ Symbol("ROW_GROUP");
|
|
69
|
+
const UNIQ_ROW_KEY = /* @__PURE__ */ Symbol("UNIQ_ROW_KEY");
|
|
70
|
+
const IS_EMPTY_DATA_ROW = /* @__PURE__ */ Symbol("IS_EMPTY_DATA_ROW");
|
|
71
|
+
const SELECT_ALL = /* @__PURE__ */ Symbol("SELECT_ALL");
|
|
72
|
+
const ROW_INDEX = /* @__PURE__ */ Symbol("ROW_INDEX");
|
|
73
|
+
const GRID_ROW_INDEX = /* @__PURE__ */ Symbol("GRID_ROW_INDEX");
|
|
74
74
|
const SCROLL_BAR_HEIGHT = 12;
|
|
75
75
|
class DataTableRoot extends Component {
|
|
76
76
|
static getDerivedStateFromProps(props, state) {
|
|
@@ -103,7 +103,6 @@ class DataTableRoot extends Component {
|
|
|
103
103
|
gridTemplateColumns: [],
|
|
104
104
|
gridTemplateAreas: []
|
|
105
105
|
});
|
|
106
|
-
_defineProperty(this, "selectAllMessageTimer", 0);
|
|
107
106
|
_defineProperty(this, "headerNodesMap", /* @__PURE__ */ new Map());
|
|
108
107
|
_defineProperty(this, "selectedRowsContainer", void 0);
|
|
109
108
|
_defineProperty(this, "lastSelectedRowKey", void 0);
|
|
@@ -115,7 +114,6 @@ class DataTableRoot extends Component {
|
|
|
115
114
|
expandedRows: /* @__PURE__ */ new Set()
|
|
116
115
|
});
|
|
117
116
|
_defineProperty(this, "handleDocumentScroll", trottle(() => {
|
|
118
|
-
var _a;
|
|
119
117
|
const tableContainer = this.tableContainerRef.current;
|
|
120
118
|
if (!tableContainer) return;
|
|
121
119
|
const tableContainerTop = tableContainer.getBoundingClientRect().top;
|
|
@@ -123,12 +121,12 @@ class DataTableRoot extends Component {
|
|
|
123
121
|
headerProps
|
|
124
122
|
} = this.asProps;
|
|
125
123
|
const headerContainer = this.headerRef.current;
|
|
126
|
-
const elements = headerContainer
|
|
127
|
-
const top = tableContainerTop - (
|
|
128
|
-
const headerScrollBar =
|
|
124
|
+
const elements = headerContainer?.querySelectorAll('[role="columnheader"], [data-ui-name="Head.Group"]');
|
|
125
|
+
const top = tableContainerTop - (headerProps?.top ?? 0);
|
|
126
|
+
const headerScrollBar = headerProps?.withScrollBar ? this.scrollAreaRef.current?.querySelector(`[role=scrollbar][aria-orientation=horizontal]`) : void 0;
|
|
129
127
|
if (top && top < 0) {
|
|
130
128
|
const translate = `translateY(${Math.abs(top)}px)`;
|
|
131
|
-
elements
|
|
129
|
+
elements?.forEach((column) => {
|
|
132
130
|
if (column instanceof HTMLElement) {
|
|
133
131
|
column.style.setProperty("transform", translate);
|
|
134
132
|
}
|
|
@@ -137,7 +135,7 @@ class DataTableRoot extends Component {
|
|
|
137
135
|
headerScrollBar.style.setProperty("transform", translate);
|
|
138
136
|
}
|
|
139
137
|
} else {
|
|
140
|
-
elements
|
|
138
|
+
elements?.forEach((column) => {
|
|
141
139
|
if (column instanceof HTMLElement) {
|
|
142
140
|
column.style.removeProperty("transform");
|
|
143
141
|
}
|
|
@@ -205,26 +203,8 @@ class DataTableRoot extends Component {
|
|
|
205
203
|
row
|
|
206
204
|
});
|
|
207
205
|
});
|
|
208
|
-
_defineProperty(this, "setSelectAllMessage", (selectedAll) => {
|
|
209
|
-
if (this.selectAllMessageTimer) {
|
|
210
|
-
clearTimeout(this.selectAllMessageTimer);
|
|
211
|
-
}
|
|
212
|
-
const {
|
|
213
|
-
getI18nText
|
|
214
|
-
} = this.asProps;
|
|
215
|
-
const message = getI18nText(selectedAll ? "DataTable.allItemsSelected:aria-live" : "DataTable.allItemsDeselected:aria-live");
|
|
216
|
-
this.setState({
|
|
217
|
-
selectAllMessage: message
|
|
218
|
-
});
|
|
219
|
-
this.selectAllMessageTimer = window.setTimeout(() => {
|
|
220
|
-
this.setState({
|
|
221
|
-
selectAllMessage: ""
|
|
222
|
-
});
|
|
223
|
-
}, 5e3);
|
|
224
|
-
});
|
|
225
206
|
_defineProperty(this, "getRow", (index) => {
|
|
226
|
-
|
|
227
|
-
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"])`);
|
|
207
|
+
return this.tableRef.current?.querySelector(`:scope [aria-rowindex="${index + 1}"]:not([aria-hidden="true"]):not(:scope [data-ui-name="DataTable"] [aria-rowindex="${index + 1}"]:not([aria-hidden="true"])`);
|
|
228
208
|
});
|
|
229
209
|
_defineProperty(this, "hasFocusableInHeader", () => {
|
|
230
210
|
return this.headerRef.current && hasFocusableIn(this.headerRef.current) || this.columns.some((column) => column.sortable);
|
|
@@ -237,10 +217,10 @@ class DataTableRoot extends Component {
|
|
|
237
217
|
const expandedRows = this.state.expandedRows;
|
|
238
218
|
if (expandedRows.has(expandedRow[UNIQ_ROW_KEY])) {
|
|
239
219
|
expandedRows.delete(expandedRow[UNIQ_ROW_KEY]);
|
|
240
|
-
onAccordionToggle
|
|
220
|
+
onAccordionToggle?.("close", expandedRow[UNIQ_ROW_KEY], expandedRow[ROW_INDEX]);
|
|
241
221
|
} else {
|
|
242
222
|
expandedRows.add(expandedRow[UNIQ_ROW_KEY]);
|
|
243
|
-
onAccordionToggle
|
|
223
|
+
onAccordionToggle?.("open", expandedRow[UNIQ_ROW_KEY], expandedRow[ROW_INDEX]);
|
|
244
224
|
if (accordionMode === "toggle") {
|
|
245
225
|
const rowIndex = expandedRow[ROW_INDEX];
|
|
246
226
|
const colIndex = this.focusedCell[1];
|
|
@@ -249,17 +229,16 @@ class DataTableRoot extends Component {
|
|
|
249
229
|
}
|
|
250
230
|
});
|
|
251
231
|
_defineProperty(this, "changeFocusCell", (rowIndex, colIndex, direction) => {
|
|
252
|
-
var _a, _b, _c, _d;
|
|
253
232
|
const {
|
|
254
233
|
limit
|
|
255
234
|
} = this.asProps;
|
|
256
235
|
const hasFocusable = this.hasFocusableInHeader();
|
|
257
236
|
const maxCol = this.columns.length - 1;
|
|
258
237
|
const maxRow = this.totalRows || 1;
|
|
259
|
-
const currentRow =
|
|
260
|
-
const headerCells =
|
|
261
|
-
const currentCell = currentRow
|
|
262
|
-
const currentHeaderCell = headerCells
|
|
238
|
+
const currentRow = this.tableRef.current?.querySelector(`[aria-rowindex="${this.focusedCell[0] + 1}"]`);
|
|
239
|
+
const headerCells = this.tableRef.current?.querySelectorAll("[role=columnheader]");
|
|
240
|
+
const currentCell = currentRow?.querySelector(`[role=gridcell][aria-colindex='${this.focusedCell[1] + 1}']`);
|
|
241
|
+
const currentHeaderCell = headerCells?.item(this.focusedCell[1]);
|
|
263
242
|
let changed = true;
|
|
264
243
|
const newRow = this.focusedCell[0] + rowIndex;
|
|
265
244
|
const newCol = this.focusedCell[1] + colIndex;
|
|
@@ -271,26 +250,26 @@ class DataTableRoot extends Component {
|
|
|
271
250
|
}
|
|
272
251
|
if (!changed) return;
|
|
273
252
|
const row = this.getRow(newRow);
|
|
274
|
-
const cell = row
|
|
253
|
+
const cell = row?.querySelector(`:scope > div > [role=gridcell][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"]), :scope > [role=columnheader][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"]), :scope > div > [role=columnheader][aria-colindex="${newCol + 1}"]:not([aria-hidden="true"])`);
|
|
275
254
|
if (cell instanceof HTMLElement && currentCell !== cell) {
|
|
276
255
|
this.focusedCell = [newRow, newCol];
|
|
277
|
-
currentCell
|
|
256
|
+
currentCell?.setAttribute("inert", "");
|
|
278
257
|
if (currentCell !== currentHeaderCell) {
|
|
279
|
-
currentCell
|
|
258
|
+
currentCell?.removeAttribute("aria-describedby");
|
|
280
259
|
}
|
|
281
|
-
const headerCell = headerCells
|
|
282
|
-
const describedBy = headerCell
|
|
260
|
+
const headerCell = headerCells?.item(newCol);
|
|
261
|
+
const describedBy = headerCell?.getAttribute("aria-describedby");
|
|
283
262
|
cell.removeAttribute("inert");
|
|
284
263
|
if (headerCell !== cell && describedBy) {
|
|
285
264
|
cell.setAttribute("aria-describedby", describedBy);
|
|
286
265
|
}
|
|
287
|
-
cell
|
|
266
|
+
cell?.focus({
|
|
288
267
|
focusVisible: true
|
|
289
268
|
});
|
|
290
269
|
if (newRow !== 0) {
|
|
291
|
-
currentHeaderCell
|
|
292
|
-
const headerCell2 = headerCells
|
|
293
|
-
headerCell2
|
|
270
|
+
currentHeaderCell?.setAttribute("inert", "");
|
|
271
|
+
const headerCell2 = headerCells?.item(newCol);
|
|
272
|
+
headerCell2?.removeAttribute("inert");
|
|
294
273
|
}
|
|
295
274
|
} else if (cell === null && currentCell instanceof HTMLElement) {
|
|
296
275
|
let rowI = rowIndex;
|
|
@@ -298,20 +277,20 @@ class DataTableRoot extends Component {
|
|
|
298
277
|
const colspan = Number(currentCell.getAttribute("aria-colspan"));
|
|
299
278
|
const rowspan = Number(currentCell.getAttribute("aria-rowspan"));
|
|
300
279
|
if (direction === "left" || direction === "right") {
|
|
301
|
-
if (
|
|
280
|
+
if (currentCell.parentElement?.parentElement?.dataset.uiName === "Collapse") {
|
|
302
281
|
return;
|
|
303
282
|
}
|
|
304
|
-
if (
|
|
283
|
+
if (limit?.fromRow !== void 0 && limit.fromColumn === void 0 && newCol === limit.fromRow) {
|
|
305
284
|
return;
|
|
306
285
|
}
|
|
307
286
|
const hasRowSpanUpper = row instanceof HTMLElement && Number(row.dataset.filledColumns) < this.columns.length;
|
|
308
287
|
if (colspan > 0) {
|
|
309
|
-
if (direction === "right" &&
|
|
288
|
+
if (direction === "right" && limit?.fromColumn !== void 0 && newCol === limit.fromColumn) {
|
|
310
289
|
rowI = rowI - 1;
|
|
311
290
|
} else {
|
|
312
291
|
colI = direction === "left" ? colI - colspan + 1 : colI + colspan - 1;
|
|
313
292
|
}
|
|
314
|
-
} else if (hasRowSpanUpper || direction === "right" && (
|
|
293
|
+
} else if (hasRowSpanUpper || direction === "right" && (limit?.fromColumn !== void 0 || limit?.fromRow !== void 0)) {
|
|
315
294
|
rowI = rowI - 1;
|
|
316
295
|
} else {
|
|
317
296
|
colI = direction === "left" ? colI - 1 : colI + 1;
|
|
@@ -322,8 +301,8 @@ class DataTableRoot extends Component {
|
|
|
322
301
|
} else if (Number(currentCell.getAttribute("aria-colindex")) === 1) {
|
|
323
302
|
rowI = direction === "up" ? rowI - 1 : rowI + 1;
|
|
324
303
|
} else {
|
|
325
|
-
const areLimitsDefined =
|
|
326
|
-
if (areLimitsDefined && newRow > (
|
|
304
|
+
const areLimitsDefined = limit?.fromRow !== void 0 || limit?.fromColumn !== void 0;
|
|
305
|
+
if (areLimitsDefined && newRow > (limit?.fromRow ?? 0) + 1) {
|
|
327
306
|
return;
|
|
328
307
|
}
|
|
329
308
|
const hasRowSpanUpper = row instanceof HTMLElement && currentRow instanceof HTMLElement && row.dataset.filledColumns !== currentRow.dataset.filledColumns;
|
|
@@ -402,8 +381,8 @@ class DataTableRoot extends Component {
|
|
|
402
381
|
const roundedScroll = Math.round(scrollLeft);
|
|
403
382
|
const roundedMaxScroll = Math.round(maxScrollRight);
|
|
404
383
|
let shadow = "";
|
|
405
|
-
if (roundedMaxScroll <= 0)
|
|
406
|
-
else if (roundedScroll <= 0) {
|
|
384
|
+
if (roundedMaxScroll <= 0) {
|
|
385
|
+
} else if (roundedScroll <= 0) {
|
|
407
386
|
shadow = "end";
|
|
408
387
|
} else if (roundedScroll >= roundedMaxScroll) {
|
|
409
388
|
shadow = "start";
|
|
@@ -415,12 +394,11 @@ class DataTableRoot extends Component {
|
|
|
415
394
|
});
|
|
416
395
|
});
|
|
417
396
|
_defineProperty(this, "handleFocus", (e) => {
|
|
418
|
-
var _a, _b, _c, _d, _e;
|
|
419
397
|
if (this.asProps.loading) {
|
|
420
|
-
|
|
398
|
+
this.spinnerRef.current?.focus();
|
|
421
399
|
e.currentTarget.setAttribute("tabIndex", "-1");
|
|
422
400
|
if (this.isDataEmpty) {
|
|
423
|
-
|
|
401
|
+
this.headerRef.current?.setAttribute("tabIndex", "-1");
|
|
424
402
|
}
|
|
425
403
|
} else if ((!e.relatedTarget || !isFocusInside(e.currentTarget, e.relatedTarget)) && lastInteraction.isKeyboard()) {
|
|
426
404
|
if (this.focusedCell[0] === -1 && this.focusedCell[1] === -1) {
|
|
@@ -433,8 +411,8 @@ class DataTableRoot extends Component {
|
|
|
433
411
|
row = this.getRow(this.focusedCell[0]);
|
|
434
412
|
}
|
|
435
413
|
if (!row && this.asProps.virtualScroll) {
|
|
436
|
-
const firstAvailableCell =
|
|
437
|
-
const firstAvailableRow =
|
|
414
|
+
const firstAvailableCell = this.tableRef.current?.querySelector(`[role="gridcell"]`);
|
|
415
|
+
const firstAvailableRow = firstAvailableCell?.parentElement?.parentElement;
|
|
438
416
|
if (firstAvailableCell && firstAvailableRow) {
|
|
439
417
|
const colIndex = Number(firstAvailableCell.getAttribute("aria-colindex") ?? 1) - 1;
|
|
440
418
|
const rowIndex = Number(firstAvailableRow.getAttribute("aria-rowindex") ?? 1) - 1;
|
|
@@ -444,8 +422,8 @@ class DataTableRoot extends Component {
|
|
|
444
422
|
}
|
|
445
423
|
}
|
|
446
424
|
const colindex = this.focusedCell[1];
|
|
447
|
-
const cell = colindex > -1 ? row
|
|
448
|
-
cell
|
|
425
|
+
const cell = colindex > -1 ? row?.querySelector(`[role=gridcell][aria-colindex="${colindex + 1}"]:not([aria-hidden="true"]), [role=columnheader][aria-colindex="${colindex + 1}"]:not([aria-hidden="true"])`) : void 0;
|
|
426
|
+
cell?.removeAttribute("inert");
|
|
449
427
|
if (cell instanceof HTMLElement) {
|
|
450
428
|
if (hasParent(e.target, cell) && !e.target.dataset.skipTargetFocus) {
|
|
451
429
|
e.target.focus({
|
|
@@ -458,20 +436,19 @@ class DataTableRoot extends Component {
|
|
|
458
436
|
}
|
|
459
437
|
}
|
|
460
438
|
if (this.isDataEmpty) {
|
|
461
|
-
|
|
439
|
+
this.headerRef.current?.setAttribute("tabIndex", "-1");
|
|
462
440
|
}
|
|
463
441
|
e.currentTarget.setAttribute("tabIndex", "-1");
|
|
464
442
|
}
|
|
465
443
|
});
|
|
466
444
|
_defineProperty(this, "handleBlur", (e) => {
|
|
467
|
-
var _a;
|
|
468
445
|
const relatedTarget = e.relatedTarget;
|
|
469
446
|
const tableElement = this.tableRef.current;
|
|
470
447
|
if (tableElement && (!relatedTarget || !isFocusInside(tableElement, relatedTarget) || !lastInteraction.isKeyboard())) {
|
|
471
448
|
this.setInert(false);
|
|
472
449
|
tableElement.setAttribute("tabIndex", "0");
|
|
473
450
|
if (this.isDataEmpty) {
|
|
474
|
-
|
|
451
|
+
this.headerRef.current?.setAttribute("tabIndex", "0");
|
|
475
452
|
}
|
|
476
453
|
}
|
|
477
454
|
});
|
|
@@ -483,12 +460,11 @@ class DataTableRoot extends Component {
|
|
|
483
460
|
this.changeFocusCell(-1, cellIndex === -1 ? 0 : cellIndex, "up");
|
|
484
461
|
});
|
|
485
462
|
_defineProperty(this, "handleContainerResizeEnd", (entries, observer) => {
|
|
486
|
-
var _a, _b;
|
|
487
463
|
if (this.containerResizeEndTimeoutId) {
|
|
488
464
|
clearTimeout(this.containerResizeEndTimeoutId);
|
|
489
465
|
}
|
|
490
466
|
this.containerResizeEndTimeoutId = setTimeout(this.calculateVerticalShadow, 0);
|
|
491
|
-
|
|
467
|
+
this.asProps.onResize?.(entries, observer);
|
|
492
468
|
});
|
|
493
469
|
_defineProperty(this, "getScrollOffsetValue", () => {
|
|
494
470
|
if (!this.headerRef.current) {
|
|
@@ -516,12 +492,11 @@ class DataTableRoot extends Component {
|
|
|
516
492
|
}
|
|
517
493
|
});
|
|
518
494
|
return this.columns.reduce((acc, column) => {
|
|
519
|
-
var _a, _b;
|
|
520
495
|
if (column.fixed === "left") {
|
|
521
|
-
acc[0] +=
|
|
496
|
+
acc[0] += this.headerNodesMap.get(column.name)?.getBoundingClientRect().width ?? 0;
|
|
522
497
|
}
|
|
523
498
|
if (column.fixed === "right") {
|
|
524
|
-
acc[1] +=
|
|
499
|
+
acc[1] += this.headerNodesMap.get(column.name)?.getBoundingClientRect().width ?? 0;
|
|
525
500
|
}
|
|
526
501
|
return acc;
|
|
527
502
|
}, [0, 0]);
|
|
@@ -547,10 +522,7 @@ class DataTableRoot extends Component {
|
|
|
547
522
|
};
|
|
548
523
|
const columnsFixed = this.columns.slice(startIndexSideMap[side], endIndexSideMap[side]);
|
|
549
524
|
if (columnsFixed.length < 1) return [side, 0];
|
|
550
|
-
const sum = columnsFixed.reduce((acc, column) =>
|
|
551
|
-
var _a;
|
|
552
|
-
return acc + ((_a = this.headerNodesMap.get(column.name)) == null ? void 0 : _a.getBoundingClientRect().width);
|
|
553
|
-
}, 0);
|
|
525
|
+
const sum = columnsFixed.reduce((acc, column) => acc + this.headerNodesMap.get(column.name)?.getBoundingClientRect().width, 0);
|
|
554
526
|
return [side, `${sum}px`];
|
|
555
527
|
});
|
|
556
528
|
const cols = this.calculateColumnsFromConfig();
|
|
@@ -570,13 +542,13 @@ class DataTableRoot extends Component {
|
|
|
570
542
|
headerProps,
|
|
571
543
|
loading
|
|
572
544
|
} = this.asProps;
|
|
573
|
-
if (
|
|
545
|
+
if (headerProps?.sticky && !headerProps.h || loading || this.hasFixedColumn) {
|
|
574
546
|
requestAnimationFrame(() => {
|
|
575
547
|
this.forceUpdate();
|
|
576
548
|
this.calculateVerticalShadow();
|
|
577
549
|
});
|
|
578
550
|
}
|
|
579
|
-
if (
|
|
551
|
+
if (headerProps?.sticky && canUseDOM() && this.scrollDirection === "horizontal") {
|
|
580
552
|
document.addEventListener("scroll", this.handleDocumentScroll);
|
|
581
553
|
}
|
|
582
554
|
}
|
|
@@ -597,33 +569,15 @@ class DataTableRoot extends Component {
|
|
|
597
569
|
this.calculateVerticalShadow();
|
|
598
570
|
}
|
|
599
571
|
}
|
|
600
|
-
if (prevProps.selectedRows !== selectedRows && selectedRows !== void 0 && Array.isArray(selectedRows)) {
|
|
601
|
-
const selectedRowsSet = new Set(selectedRows);
|
|
602
|
-
const allChecked = [];
|
|
603
|
-
const allUnchecked = [];
|
|
604
|
-
this.flatRows.forEach((row) => {
|
|
605
|
-
if (selectedRowsSet.has(row[UNIQ_ROW_KEY])) {
|
|
606
|
-
allChecked.push(row[UNIQ_ROW_KEY]);
|
|
607
|
-
} else {
|
|
608
|
-
allUnchecked.push(row[UNIQ_ROW_KEY]);
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
if (allChecked.length === data.length) {
|
|
612
|
-
this.setSelectAllMessage(true);
|
|
613
|
-
} else if (allUnchecked.length === data.length) {
|
|
614
|
-
this.setSelectAllMessage(false);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
572
|
if (prevProps.selectedRows !== selectedRows && selectedRows !== void 0 && !Array.isArray(selectedRows)) {
|
|
618
573
|
this.selectedRowsContainer = selectedRows;
|
|
619
574
|
}
|
|
620
575
|
}
|
|
621
576
|
componentWillUnmount() {
|
|
622
|
-
var _a;
|
|
623
577
|
if (canUseDOM()) {
|
|
624
578
|
document.removeEventListener("scroll", this.handleDocumentScroll);
|
|
625
579
|
}
|
|
626
|
-
|
|
580
|
+
this.state.expandedRows?.clear();
|
|
627
581
|
}
|
|
628
582
|
get totalRows() {
|
|
629
583
|
const {
|
|
@@ -710,7 +664,7 @@ class DataTableRoot extends Component {
|
|
|
710
664
|
onSortChange,
|
|
711
665
|
getI18nText,
|
|
712
666
|
uid,
|
|
713
|
-
ref:
|
|
667
|
+
ref: headerProps?.ref ? forkRef(this.headerRef, headerProps.ref) : this.headerRef,
|
|
714
668
|
gridAreaGroupMap: this.gridAreaGroupMap,
|
|
715
669
|
gridTemplateColumns,
|
|
716
670
|
gridTemplateAreas,
|
|
@@ -769,7 +723,7 @@ class DataTableRoot extends Component {
|
|
|
769
723
|
gridTemplateAreas,
|
|
770
724
|
loading,
|
|
771
725
|
headerHeight: this.getHeaderHeight(),
|
|
772
|
-
stickyHeader: headerProps
|
|
726
|
+
stickyHeader: headerProps?.sticky,
|
|
773
727
|
getI18nText,
|
|
774
728
|
expandedRows: this.state.expandedRows,
|
|
775
729
|
onExpandRow: this.onExpandRow,
|
|
@@ -800,9 +754,8 @@ class DataTableRoot extends Component {
|
|
|
800
754
|
};
|
|
801
755
|
}
|
|
802
756
|
setInert(value) {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
cells == null ? void 0 : cells.forEach((cell) => {
|
|
757
|
+
const cells = this.tableRef.current?.querySelectorAll("[role=gridcell], [role=columnheader]");
|
|
758
|
+
cells?.forEach((cell) => {
|
|
806
759
|
if (value === true) {
|
|
807
760
|
cell.setAttribute("inert", "");
|
|
808
761
|
} else {
|
|
@@ -812,8 +765,8 @@ class DataTableRoot extends Component {
|
|
|
812
765
|
}
|
|
813
766
|
initFocusableCell(initCell) {
|
|
814
767
|
const hasFocusable = this.hasFocusableInHeader();
|
|
815
|
-
const initRow =
|
|
816
|
-
const initCol =
|
|
768
|
+
const initRow = initCell?.[0] ?? 0;
|
|
769
|
+
const initCol = initCell?.[1] ?? 0;
|
|
817
770
|
if (hasFocusable) {
|
|
818
771
|
this.focusedCell = [initRow, initCol];
|
|
819
772
|
} else {
|
|
@@ -836,7 +789,9 @@ class DataTableRoot extends Component {
|
|
|
836
789
|
children,
|
|
837
790
|
headerProps,
|
|
838
791
|
loading,
|
|
839
|
-
selectedRows
|
|
792
|
+
selectedRows,
|
|
793
|
+
getI18nText,
|
|
794
|
+
data
|
|
840
795
|
} = this.asProps;
|
|
841
796
|
const [offsetLeftSum, offsetRightSum] = this.getScrollOffsetValue();
|
|
842
797
|
const {
|
|
@@ -844,9 +799,9 @@ class DataTableRoot extends Component {
|
|
|
844
799
|
gridTemplateAreas
|
|
845
800
|
} = this.gridSettings;
|
|
846
801
|
const Head2 = findComponent(Children, ["DataTable.Head"]);
|
|
847
|
-
const headerPropsToCheck = headerProps ??
|
|
848
|
-
const headerHeight =
|
|
849
|
-
const topOffset =
|
|
802
|
+
const headerPropsToCheck = headerProps ?? Head2?.props;
|
|
803
|
+
const headerHeight = headerProps?.h || this.getHeaderHeight();
|
|
804
|
+
const topOffset = headerPropsToCheck?.sticky || headerPropsToCheck?.withScrollBar ? headerHeight : void 0;
|
|
850
805
|
const width = w ?? (this.columns.some((c) => c.gtcWidth === "auto" || c.gtcWidth === "1fr") ? "100%" : void 0);
|
|
851
806
|
let gridTemplateRows = void 0;
|
|
852
807
|
if (virtualScroll && typeof virtualScroll !== "boolean" && "rowHeight" in virtualScroll) {
|
|
@@ -901,7 +856,7 @@ class DataTableRoot extends Component {
|
|
|
901
856
|
"use:hMax": void 0,
|
|
902
857
|
"use:hMin": void 0
|
|
903
858
|
}, _ref)
|
|
904
|
-
}), 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)))),
|
|
859
|
+
}), children ? /* @__PURE__ */ React.createElement(Children, _ref2.cn("Children", {})) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DataTable.Head, null), /* @__PURE__ */ React.createElement(DataTable.Body, null)))), headerPropsToCheck?.withScrollBar && topOffset && !loading && /* @__PURE__ */ React.createElement(ScrollArea.Bar, {
|
|
905
860
|
orientation: "horizontal",
|
|
906
861
|
top: topOffset - SCROLL_BAR_HEIGHT,
|
|
907
862
|
zIndex: 20
|
|
@@ -911,10 +866,15 @@ class DataTableRoot extends Component {
|
|
|
911
866
|
}), /* @__PURE__ */ React.createElement(ScrollArea.Bar, {
|
|
912
867
|
orientation: "vertical",
|
|
913
868
|
zIndex: 20
|
|
914
|
-
})), selectedRows !== void 0 && /* @__PURE__ */ React.createElement(
|
|
915
|
-
"
|
|
916
|
-
"
|
|
917
|
-
}),
|
|
869
|
+
})), selectedRows !== void 0 && !Array.isArray(selectedRows) && /* @__PURE__ */ React.createElement(SRReactiveAnnouncer, _ref2.cn("SRReactiveAnnouncer", {
|
|
870
|
+
"selectedRows": selectedRows,
|
|
871
|
+
"getI18nText": getI18nText
|
|
872
|
+
})), selectedRows !== void 0 && Array.isArray(selectedRows) && /* @__PURE__ */ React.createElement(SRAnnouncer, _ref2.cn("SRAnnouncer", {
|
|
873
|
+
"selectedRows": selectedRows,
|
|
874
|
+
"getI18nText": getI18nText,
|
|
875
|
+
"data": data,
|
|
876
|
+
"flatRows": this.flatRows
|
|
877
|
+
})));
|
|
918
878
|
}
|
|
919
879
|
calculateColumnsFromConfig() {
|
|
920
880
|
const {
|
|
@@ -942,13 +902,13 @@ class DataTableRoot extends Component {
|
|
|
942
902
|
calculatedColumns.push(column);
|
|
943
903
|
}
|
|
944
904
|
const makeColumn = (columnElement, parent, isFirst, isLast, hasGroups) => {
|
|
945
|
-
const leftBordersFromParent = isFirst && (
|
|
946
|
-
const rightBordersFromParent = isLast && (
|
|
905
|
+
const leftBordersFromParent = isFirst && (parent?.borders === "both" || parent?.borders === "left") ? "left" : void 0;
|
|
906
|
+
const rightBordersFromParent = isLast && (parent?.borders === "both" || parent?.borders === "right") ? "right" : void 0;
|
|
947
907
|
const column = {
|
|
948
908
|
...columnElement,
|
|
949
909
|
name: childIsColumn(columnElement) ? columnElement.name : "",
|
|
950
910
|
gtcWidth: childIsColumn(columnElement) ? calculateGridTemplateColumn(columnElement) : "",
|
|
951
|
-
fixed: columnElement.fixed ?? (hasGroups ? parent
|
|
911
|
+
fixed: columnElement.fixed ?? (hasGroups ? parent?.fixed : void 0),
|
|
952
912
|
borders: columnElement.borders ?? leftBordersFromParent ?? rightBordersFromParent,
|
|
953
913
|
parent
|
|
954
914
|
};
|
|
@@ -992,7 +952,6 @@ class DataTableRoot extends Component {
|
|
|
992
952
|
Group.columns = [];
|
|
993
953
|
Group.children = child.children;
|
|
994
954
|
child.columns.forEach((child2, j) => {
|
|
995
|
-
var _a;
|
|
996
955
|
const isFirst = j === 0;
|
|
997
956
|
const isLast = j === childCount - 1;
|
|
998
957
|
const col = makeColumn(child2, Group, isFirst, isLast, this.hasGroups);
|
|
@@ -1008,7 +967,7 @@ class DataTableRoot extends Component {
|
|
|
1008
967
|
if (isFirst && i > 0) {
|
|
1009
968
|
setShowShadows(col, i);
|
|
1010
969
|
}
|
|
1011
|
-
|
|
970
|
+
Group.columns?.push(col);
|
|
1012
971
|
});
|
|
1013
972
|
treeColumns.push(Group);
|
|
1014
973
|
this.gridAreaGroupMap.set(groupIndex, `1 / ${initGridColumn} / 2 / ${gridColumnIndex}`);
|
|
@@ -1091,7 +1050,7 @@ class DataTableRoot extends Component {
|
|
|
1091
1050
|
columns2.delete(value2);
|
|
1092
1051
|
});
|
|
1093
1052
|
}
|
|
1094
|
-
if (value
|
|
1053
|
+
if (value?.[ACCORDION]) {
|
|
1095
1054
|
accordionInCell = value[ACCORDION];
|
|
1096
1055
|
}
|
|
1097
1056
|
return acc;
|
|
@@ -1107,7 +1066,7 @@ class DataTableRoot extends Component {
|
|
|
1107
1066
|
} else if (accordionInCell) {
|
|
1108
1067
|
gridRowIndex++;
|
|
1109
1068
|
}
|
|
1110
|
-
excludeColumns
|
|
1069
|
+
excludeColumns?.forEach((value) => {
|
|
1111
1070
|
columns2.delete(value);
|
|
1112
1071
|
});
|
|
1113
1072
|
if (columns2.size > 0) {
|
|
@@ -1141,7 +1100,6 @@ class DataTableRoot extends Component {
|
|
|
1141
1100
|
[ROW_INDEX]: -1
|
|
1142
1101
|
});
|
|
1143
1102
|
groupedRows.forEach((childRow, index) => {
|
|
1144
|
-
var _a, _b;
|
|
1145
1103
|
let dtRow;
|
|
1146
1104
|
if (index === 0) {
|
|
1147
1105
|
const rowData = {
|
|
@@ -1152,7 +1110,7 @@ class DataTableRoot extends Component {
|
|
|
1152
1110
|
dtRow[ROW_GROUP] = /* @__PURE__ */ new Set();
|
|
1153
1111
|
} else {
|
|
1154
1112
|
dtRow = makeDtRow(childRow, groupedKeys);
|
|
1155
|
-
|
|
1113
|
+
innerRows[0]?.[ROW_GROUP]?.add(dtRow[UNIQ_ROW_KEY]);
|
|
1156
1114
|
}
|
|
1157
1115
|
innerRows.push(dtRow);
|
|
1158
1116
|
if (index === groupedRows.length - 1 && row[ACCORDION]) {
|
|
@@ -1161,7 +1119,7 @@ class DataTableRoot extends Component {
|
|
|
1161
1119
|
rowIndex++;
|
|
1162
1120
|
});
|
|
1163
1121
|
rows.push(innerRows);
|
|
1164
|
-
} else if (
|
|
1122
|
+
} else if (groupedRows?.length === 1) {
|
|
1165
1123
|
const dtRow = makeDtRow({
|
|
1166
1124
|
...groupedRows[0],
|
|
1167
1125
|
...row
|
|
@@ -1184,15 +1142,14 @@ class DataTableRoot extends Component {
|
|
|
1184
1142
|
return (/* @__PURE__ */ React.isValidElement(c) ? c.props.gtcWidth : c.gtcWidth) ?? this.props.defaultGridTemplateColumnWidth;
|
|
1185
1143
|
}
|
|
1186
1144
|
getHeaderHeight() {
|
|
1187
|
-
|
|
1188
|
-
const header = (_a = this.headerRef.current) == null ? void 0 : _a.children;
|
|
1145
|
+
const header = this.headerRef.current?.children;
|
|
1189
1146
|
let height = 0;
|
|
1190
|
-
for (let i = 0; i < (
|
|
1191
|
-
const item = header
|
|
1192
|
-
let columnHeight = item
|
|
1147
|
+
for (let i = 0; i < (header?.length ?? 0); i++) {
|
|
1148
|
+
const item = header?.item(i);
|
|
1149
|
+
let columnHeight = item?.getBoundingClientRect().height;
|
|
1193
1150
|
if (item instanceof HTMLElement && item.dataset.groupContainer) {
|
|
1194
|
-
const groupHeight =
|
|
1195
|
-
const cellHeight =
|
|
1151
|
+
const groupHeight = item.children.item(0)?.getBoundingClientRect().height ?? 0;
|
|
1152
|
+
const cellHeight = item.children.item(1)?.getBoundingClientRect().height ?? 0;
|
|
1196
1153
|
columnHeight = groupHeight + cellHeight;
|
|
1197
1154
|
}
|
|
1198
1155
|
if (columnHeight) {
|