@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,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Component, lastInteraction,
|
|
2
|
+
import { sstyled, Component, lastInteraction, assignProps } from "@semcore/core";
|
|
3
3
|
import { Flex } from "@semcore/base-components";
|
|
4
4
|
import { ButtonLink } from "@semcore/button";
|
|
5
5
|
import canUseDOM from "@semcore/core/lib/utils/canUseDOM";
|
|
@@ -11,7 +11,6 @@ import SortAsc from "@semcore/icon/SortAsc/m";
|
|
|
11
11
|
import SortDesc from "@semcore/icon/SortDesc/m";
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { handleKeydownFocusCell, handleFocusCell } from "../../enhancers/focusableCell.mjs";
|
|
14
|
-
/*!__reshadow-styles__:"./style.shadow.css"*/
|
|
15
14
|
const style = (
|
|
16
15
|
/*__reshadow_css_start__*/
|
|
17
16
|
(sstyled.insert(
|
|
@@ -82,7 +81,6 @@ class Column extends Component {
|
|
|
82
81
|
sortVisible: false
|
|
83
82
|
});
|
|
84
83
|
_defineProperty(this, "calculateActiveColumnMinWidth", () => {
|
|
85
|
-
var _a;
|
|
86
84
|
const node = this.columnRef.current;
|
|
87
85
|
if (node) {
|
|
88
86
|
const clonedColumn = document.createElement("div");
|
|
@@ -101,7 +99,7 @@ class Column extends Component {
|
|
|
101
99
|
document.body.appendChild(clonedColumn);
|
|
102
100
|
const computedWidth = Math.ceil(clonedColumn.getBoundingClientRect().width);
|
|
103
101
|
document.body.removeChild(clonedColumn);
|
|
104
|
-
const defaultNodeWidth =
|
|
102
|
+
const defaultNodeWidth = this.columnRef.current?.clientWidth ?? 0;
|
|
105
103
|
if (computedWidth >= defaultNodeWidth) {
|
|
106
104
|
return defaultNodeWidth + SORT_ICON_WIDTH;
|
|
107
105
|
} else {
|
|
@@ -139,7 +137,7 @@ class Column extends Component {
|
|
|
139
137
|
sortable
|
|
140
138
|
} = this.asProps;
|
|
141
139
|
if (sortable && onSortChange) {
|
|
142
|
-
const sortDirection =
|
|
140
|
+
const sortDirection = sort?.[0] === name ? reversedSortDirection[sort[1]] : this.defaultDirection;
|
|
143
141
|
onSortChange([name, sortDirection], e);
|
|
144
142
|
}
|
|
145
143
|
});
|
|
@@ -153,7 +151,6 @@ class Column extends Component {
|
|
|
153
151
|
handleKeydownFocusCell(this.lockedCell, e);
|
|
154
152
|
});
|
|
155
153
|
_defineProperty(this, "handleFocusableCellFocus", (e) => {
|
|
156
|
-
var _a;
|
|
157
154
|
const cellElement = e.currentTarget;
|
|
158
155
|
const target = e.target;
|
|
159
156
|
if (lastInteraction.isKeyboard()) {
|
|
@@ -163,7 +160,7 @@ class Column extends Component {
|
|
|
163
160
|
handleFocusCell(this.lockedCell, target, cellElement);
|
|
164
161
|
});
|
|
165
162
|
} else {
|
|
166
|
-
const focusableChildren = Array.from(
|
|
163
|
+
const focusableChildren = Array.from(this.columnRef.current?.children ?? []).flatMap((node) => getFocusableIn(node));
|
|
167
164
|
if (isInteractiveElement(e.target) && this.columnRef.current && focusableChildren.length > 1) {
|
|
168
165
|
this.lockedCell[0] = this.columnRef.current;
|
|
169
166
|
this.lockedCell[1] = true;
|
|
@@ -171,7 +168,6 @@ class Column extends Component {
|
|
|
171
168
|
}
|
|
172
169
|
});
|
|
173
170
|
_defineProperty(this, "handleClick", (e) => {
|
|
174
|
-
var _a;
|
|
175
171
|
const {
|
|
176
172
|
sortable,
|
|
177
173
|
onClick,
|
|
@@ -180,19 +176,18 @@ class Column extends Component {
|
|
|
180
176
|
if (sortable) {
|
|
181
177
|
this.handleSort(e);
|
|
182
178
|
}
|
|
183
|
-
const focusableChildren = Array.from(
|
|
179
|
+
const focusableChildren = Array.from(this.columnRef.current?.children ?? []).flatMap((node) => getFocusableIn(node));
|
|
184
180
|
if (isInteractiveElement(e.target) && this.columnRef.current && focusableChildren.length > 1) {
|
|
185
181
|
this.lockedCell[0] = this.columnRef.current;
|
|
186
182
|
this.lockedCell[1] = true;
|
|
187
183
|
}
|
|
188
|
-
onClick
|
|
184
|
+
onClick?.(e, {
|
|
189
185
|
rowIndex: -1,
|
|
190
186
|
colIndex: columnIndex
|
|
191
187
|
});
|
|
192
188
|
});
|
|
193
189
|
}
|
|
194
190
|
componentDidMount() {
|
|
195
|
-
var _a;
|
|
196
191
|
const {
|
|
197
192
|
parent,
|
|
198
193
|
sticky,
|
|
@@ -203,18 +198,17 @@ class Column extends Component {
|
|
|
203
198
|
} = this.asProps;
|
|
204
199
|
if (parent && sticky && scrollDirection !== "horizontal") {
|
|
205
200
|
const columnElement = this.columnRef.current;
|
|
206
|
-
const groupElement =
|
|
207
|
-
const groupRectHeight =
|
|
201
|
+
const groupElement = columnElement?.parentElement?.children.item(0);
|
|
202
|
+
const groupRectHeight = groupElement?.getBoundingClientRect().height ?? 0;
|
|
208
203
|
const topOffset = groupElement instanceof HTMLElement ? cssToIntDefault(groupElement.style.top) : 0;
|
|
209
|
-
columnElement
|
|
204
|
+
columnElement?.style.setProperty("top", `${groupRectHeight + topOffset}px`);
|
|
210
205
|
}
|
|
211
|
-
if (canUseDOM() && changeSortSize &&
|
|
206
|
+
if (canUseDOM() && changeSortSize && sort?.[0] === name) {
|
|
212
207
|
this.changeTemplateColumnBySort();
|
|
213
208
|
}
|
|
214
209
|
}
|
|
215
210
|
componentDidUpdate(prevProps) {
|
|
216
|
-
|
|
217
|
-
if (this.asProps.changeSortSize && canUseDOM() && ((_a = prevProps.sort) == null ? void 0 : _a[0]) !== ((_b = this.asProps.sort) == null ? void 0 : _b[0])) {
|
|
211
|
+
if (this.asProps.changeSortSize && canUseDOM() && prevProps.sort?.[0] !== this.asProps.sort?.[0]) {
|
|
218
212
|
this.changeTemplateColumnBySort();
|
|
219
213
|
}
|
|
220
214
|
}
|
|
@@ -226,7 +220,7 @@ class Column extends Component {
|
|
|
226
220
|
sort,
|
|
227
221
|
name
|
|
228
222
|
} = this.asProps;
|
|
229
|
-
if (
|
|
223
|
+
if (sort?.[0] === name) {
|
|
230
224
|
const newWidth = this.calculateActiveColumnMinWidth();
|
|
231
225
|
setTimeout(() => {
|
|
232
226
|
if (tableRef.current && newWidth !== null) {
|
|
@@ -238,7 +232,7 @@ class Column extends Component {
|
|
|
238
232
|
}).join(" "));
|
|
239
233
|
}
|
|
240
234
|
});
|
|
241
|
-
} else if (
|
|
235
|
+
} else if (sort?.[0] !== name) {
|
|
242
236
|
setTimeout(() => {
|
|
243
237
|
if (tableRef.current) {
|
|
244
238
|
const currentGridTemplateColumns = tableRef.current.style.getPropertyValue("grid-template-columns");
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
-
import {
|
|
3
|
+
import { sstyled, Component, assignProps } from "@semcore/core";
|
|
4
4
|
import { Box } from "@semcore/base-components";
|
|
5
5
|
import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
|
|
6
6
|
import React__default from "react";
|
|
7
7
|
import { DataTable } from "../DataTable/DataTable.mjs";
|
|
8
|
-
/*!__reshadow-styles__:"./style.shadow.css"*/
|
|
9
8
|
const style = (
|
|
10
9
|
/*__reshadow_css_start__*/
|
|
11
10
|
(sstyled.insert(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
-
import {
|
|
3
|
+
import { sstyled, Component, assignProps, createComponent } from "@semcore/core";
|
|
4
4
|
import { Box, ScreenReaderOnly } from "@semcore/base-components";
|
|
5
5
|
import Checkbox from "@semcore/checkbox";
|
|
6
6
|
import React__default from "react";
|
|
@@ -8,7 +8,6 @@ import { Column } from "./Column.mjs";
|
|
|
8
8
|
import { Group } from "./Group.mjs";
|
|
9
9
|
import { SelectableRows } from "../../store/SelectableRows.mjs";
|
|
10
10
|
import { UNIQ_ROW_KEY, SELECT_ALL, DataTable } from "../DataTable/DataTable.mjs";
|
|
11
|
-
/*!__reshadow-styles__:"./style.shadow.css"*/
|
|
12
11
|
const style = (
|
|
13
12
|
/*__reshadow_css_start__*/
|
|
14
13
|
(sstyled.insert(
|
|
@@ -59,8 +58,8 @@ class HeadRoot extends Component {
|
|
|
59
58
|
constructor(...args) {
|
|
60
59
|
super(...args);
|
|
61
60
|
_defineProperty(this, "unsubscribeSelectAll", void 0);
|
|
61
|
+
_defineProperty(this, "unsubscribeSetIndeterminate", void 0);
|
|
62
62
|
_defineProperty(this, "handleSelectAll", (value, event) => {
|
|
63
|
-
var _a, _b;
|
|
64
63
|
const {
|
|
65
64
|
selectedRows
|
|
66
65
|
} = this.asProps;
|
|
@@ -75,7 +74,7 @@ class HeadRoot extends Component {
|
|
|
75
74
|
idsSet.delete(row[UNIQ_ROW_KEY]);
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
|
-
|
|
77
|
+
this.asProps.onChangeSelectAll?.(Array.from(idsSet), event);
|
|
79
78
|
} else if (selectedRows) {
|
|
80
79
|
if (value) {
|
|
81
80
|
selectedRows.selectAll();
|
|
@@ -85,8 +84,8 @@ class HeadRoot extends Component {
|
|
|
85
84
|
}
|
|
86
85
|
});
|
|
87
86
|
_defineProperty(this, "handleClickSelectAll", (value) => (event) => {
|
|
88
|
-
event
|
|
89
|
-
event
|
|
87
|
+
event?.preventDefault();
|
|
88
|
+
event?.stopPropagation();
|
|
90
89
|
this.handleSelectAll(value, event);
|
|
91
90
|
});
|
|
92
91
|
}
|
|
@@ -95,14 +94,17 @@ class HeadRoot extends Component {
|
|
|
95
94
|
selectedRows
|
|
96
95
|
} = this.asProps;
|
|
97
96
|
if (selectedRows && !Array.isArray(selectedRows)) {
|
|
98
|
-
this.unsubscribeSelectAll = selectedRows.
|
|
97
|
+
this.unsubscribeSelectAll = selectedRows.on(SelectableRows.SELECT_ALL_EVENT, () => {
|
|
98
|
+
this.forceUpdate();
|
|
99
|
+
});
|
|
100
|
+
this.unsubscribeSetIndeterminate = selectedRows.on(SelectableRows.SET_INDETERMINATE_EVENT, () => {
|
|
99
101
|
this.forceUpdate();
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
componentWillUnmount() {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
this.unsubscribeSelectAll?.();
|
|
107
|
+
this.unsubscribeSetIndeterminate?.();
|
|
106
108
|
}
|
|
107
109
|
sortableColumnDescribeId() {
|
|
108
110
|
const {
|
|
@@ -216,7 +218,7 @@ class HeadRoot extends Component {
|
|
|
216
218
|
selectedRows
|
|
217
219
|
} = this.asProps;
|
|
218
220
|
if (Array.isArray(selectedRows)) {
|
|
219
|
-
return selectedRows.length > 0 && this.selectableRows.every((row) => selectedRows
|
|
221
|
+
return selectedRows.length > 0 && this.selectableRows.every((row) => selectedRows?.includes(row[UNIQ_ROW_KEY]));
|
|
220
222
|
} else if (selectedRows) {
|
|
221
223
|
return selectedRows.isAllSelected();
|
|
222
224
|
}
|
|
@@ -226,7 +228,7 @@ class HeadRoot extends Component {
|
|
|
226
228
|
selectedRows
|
|
227
229
|
} = this.asProps;
|
|
228
230
|
if (Array.isArray(selectedRows)) {
|
|
229
|
-
return this.selectableRows.some((row) => selectedRows
|
|
231
|
+
return this.selectableRows.some((row) => selectedRows?.includes(row[UNIQ_ROW_KEY]));
|
|
230
232
|
} else if (selectedRows) {
|
|
231
233
|
return selectedRows.isIndeterminate();
|
|
232
234
|
}
|
|
@@ -237,8 +239,7 @@ class HeadRoot extends Component {
|
|
|
237
239
|
flatRows
|
|
238
240
|
} = this.asProps;
|
|
239
241
|
const mappedFlatRows = flatRows.filter((r) => {
|
|
240
|
-
|
|
241
|
-
const nextColumnName = (_a = columns[1]) == null ? void 0 : _a.name;
|
|
242
|
+
const nextColumnName = columns[1]?.name;
|
|
242
243
|
return r[nextColumnName] !== void 0;
|
|
243
244
|
});
|
|
244
245
|
return mappedFlatRows;
|
|
@@ -282,9 +283,8 @@ class HeadRoot extends Component {
|
|
|
282
283
|
}), /* @__PURE__ */ React__default.createElement(Checkbox.Value, null, /* @__PURE__ */ React__default.createElement(Checkbox.Value.Control, null), /* @__PURE__ */ React__default.createElement(Checkbox.Value.CheckMark, {
|
|
283
284
|
mt: 0
|
|
284
285
|
})))), children ? /* @__PURE__ */ React__default.createElement(Children, _ref2.cn("Children", {})) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, treeColumns.map((column, _i) => {
|
|
285
|
-
var _a;
|
|
286
286
|
if ("columns" in column) {
|
|
287
|
-
const columnsName =
|
|
287
|
+
const columnsName = column.columns?.map((c) => c.name).join("/");
|
|
288
288
|
return /* @__PURE__ */ React__default.createElement(DataTable.Head.Group, _extends({
|
|
289
289
|
key: columnsName
|
|
290
290
|
}, column, {
|
|
@@ -18,21 +18,21 @@ class RowSelector extends React__default.PureComponent {
|
|
|
18
18
|
onSelectRow,
|
|
19
19
|
selectedRows
|
|
20
20
|
} = this.props;
|
|
21
|
-
onSelectRow
|
|
21
|
+
onSelectRow?.(value, rowIndex, row, event);
|
|
22
22
|
if (selectedRows && !Array.isArray(selectedRows)) {
|
|
23
23
|
selectedRows.toggle(value, row);
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
_defineProperty(this, "handleClickCheckbox", (value) => (event) => {
|
|
27
|
-
event
|
|
28
|
-
event
|
|
27
|
+
event?.preventDefault();
|
|
28
|
+
event?.stopPropagation();
|
|
29
29
|
const {
|
|
30
30
|
row,
|
|
31
31
|
rowIndex,
|
|
32
32
|
onSelectRow,
|
|
33
33
|
selectedRows
|
|
34
34
|
} = this.props;
|
|
35
|
-
onSelectRow
|
|
35
|
+
onSelectRow?.(value, rowIndex, row, event);
|
|
36
36
|
if (selectedRows && !Array.isArray(selectedRows)) {
|
|
37
37
|
selectedRows.toggle(value, row);
|
|
38
38
|
}
|
|
@@ -51,7 +51,7 @@ class RowSelector extends React__default.PureComponent {
|
|
|
51
51
|
selectedRows
|
|
52
52
|
} = this.props;
|
|
53
53
|
if (selectedRows && !Array.isArray(selectedRows)) {
|
|
54
|
-
this.unsubscribeToggle = selectedRows.
|
|
54
|
+
this.unsubscribeToggle = selectedRows.on(SelectableRows.TOGGLE_EVENT, (key) => {
|
|
55
55
|
if (row[UNIQ_ROW_KEY] === key) {
|
|
56
56
|
this.setState({
|
|
57
57
|
checked: selectedRows.has(row[UNIQ_ROW_KEY])
|
|
@@ -61,8 +61,7 @@ class RowSelector extends React__default.PureComponent {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
componentWillUnmount() {
|
|
64
|
-
|
|
65
|
-
(_a = this.unsubscribeToggle) == null ? void 0 : _a.call(this);
|
|
64
|
+
this.unsubscribeToggle?.();
|
|
66
65
|
}
|
|
67
66
|
render() {
|
|
68
67
|
const SCheckboxCell = Row.Cell;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ScreenReaderOnly } from "@semcore/base-components";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { UNIQ_ROW_KEY } from "../DataTable/DataTable.mjs";
|
|
4
|
+
function SRAnnouncer(props) {
|
|
5
|
+
const [ariaMessage, setAriaMessage] = React__default.useState("");
|
|
6
|
+
const [selectedAll, setSelectedAll] = React__default.useState(false);
|
|
7
|
+
React__default.useEffect(() => {
|
|
8
|
+
const selectedRowsSet = new Set(props.selectedRows);
|
|
9
|
+
const allChecked = [];
|
|
10
|
+
const allUnchecked = [];
|
|
11
|
+
props.flatRows.forEach((row) => {
|
|
12
|
+
if (selectedRowsSet.has(row[UNIQ_ROW_KEY])) {
|
|
13
|
+
allChecked.push(row[UNIQ_ROW_KEY]);
|
|
14
|
+
} else {
|
|
15
|
+
allUnchecked.push(row[UNIQ_ROW_KEY]);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
if (allChecked.length === props.data.length) {
|
|
19
|
+
setSelectedAll(true);
|
|
20
|
+
} else if (allUnchecked.length === props.data.length) {
|
|
21
|
+
setSelectedAll(false);
|
|
22
|
+
}
|
|
23
|
+
}, [props.selectedRows, props.data, props.flatRows]);
|
|
24
|
+
React__default.useEffect(() => {
|
|
25
|
+
const {
|
|
26
|
+
getI18nText
|
|
27
|
+
} = props;
|
|
28
|
+
const message = getI18nText(selectedAll ? "DataTable.allItemsSelected:aria-live" : "DataTable.allItemsDeselected:aria-live");
|
|
29
|
+
setAriaMessage(message);
|
|
30
|
+
const timeout = setTimeout(() => setAriaMessage(""), 5e3);
|
|
31
|
+
return () => clearTimeout(timeout);
|
|
32
|
+
}, [selectedAll, props.getI18nText]);
|
|
33
|
+
React__default.useEffect(() => {
|
|
34
|
+
const timer = setTimeout(() => setAriaMessage(""), 1e3);
|
|
35
|
+
return () => clearTimeout(timer);
|
|
36
|
+
}, [ariaMessage]);
|
|
37
|
+
return /* @__PURE__ */ React__default.createElement(ScreenReaderOnly, {
|
|
38
|
+
role: "status",
|
|
39
|
+
"aria-live": "polite"
|
|
40
|
+
}, ariaMessage);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
SRAnnouncer
|
|
44
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ScreenReaderOnly } from "@semcore/base-components";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
import { SelectableRows } from "../../store/SelectableRows.mjs";
|
|
4
|
+
function SRReactiveAnnouncer(props) {
|
|
5
|
+
const [ariaMessage, setAriaMessage] = React__default.useState("");
|
|
6
|
+
const setAriaCallback = React__default.useCallback(() => {
|
|
7
|
+
const isAllSelected = props.selectedRows.isAllSelected();
|
|
8
|
+
const message = props.getI18nText(isAllSelected ? "DataTable.allItemsSelected:aria-live" : "DataTable.allItemsDeselected:aria-live");
|
|
9
|
+
setAriaMessage(message);
|
|
10
|
+
}, [props.selectedRows]);
|
|
11
|
+
React__default.useEffect(() => {
|
|
12
|
+
const unsubscribe = props.selectedRows.on(SelectableRows.SELECT_ALL_EVENT, setAriaCallback);
|
|
13
|
+
return unsubscribe;
|
|
14
|
+
}, [props.selectedRows]);
|
|
15
|
+
React__default.useEffect(() => {
|
|
16
|
+
const timer = setTimeout(() => setAriaMessage(""), 1e3);
|
|
17
|
+
return () => clearTimeout(timer);
|
|
18
|
+
}, [ariaMessage]);
|
|
19
|
+
return /* @__PURE__ */ React__default.createElement(ScreenReaderOnly, {
|
|
20
|
+
role: "status",
|
|
21
|
+
"aria-live": "polite"
|
|
22
|
+
}, ariaMessage);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
SRReactiveAnnouncer
|
|
26
|
+
};
|
|
@@ -23,12 +23,11 @@ function handleFocusCell(lockedCell, target, currentTarget) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
function handleKeydownFocusCell(lockedCell, e) {
|
|
26
|
-
var _a, _b, _c, _d;
|
|
27
26
|
if (e.currentTarget === lockedCell[0]) {
|
|
28
27
|
const focusableChildren = Array.from(lockedCell[0].children).flatMap((node) => getFocusableIn(node));
|
|
29
28
|
if (lockedCell[1]) {
|
|
30
29
|
if (e.key === "Escape") {
|
|
31
|
-
|
|
30
|
+
lockedCell[0]?.focus({
|
|
32
31
|
focusVisible: true
|
|
33
32
|
});
|
|
34
33
|
lockedCell[1] = false;
|
|
@@ -39,12 +38,12 @@ function handleKeydownFocusCell(lockedCell, e) {
|
|
|
39
38
|
}
|
|
40
39
|
if (e.key === "Tab") {
|
|
41
40
|
if (e.target === focusableChildren[0] && e.shiftKey) {
|
|
42
|
-
|
|
41
|
+
focusableChildren[focusableChildren.length - 1]?.focus({
|
|
43
42
|
focusVisible: true
|
|
44
43
|
});
|
|
45
44
|
e.preventDefault();
|
|
46
45
|
} else if (e.target === focusableChildren[focusableChildren.length - 1] && !e.shiftKey) {
|
|
47
|
-
|
|
46
|
+
focusableChildren[0]?.focus({
|
|
48
47
|
focusVisible: true
|
|
49
48
|
});
|
|
50
49
|
e.preventDefault();
|
|
@@ -55,7 +54,7 @@ function handleKeydownFocusCell(lockedCell, e) {
|
|
|
55
54
|
e.preventDefault();
|
|
56
55
|
e.stopPropagation();
|
|
57
56
|
lockedCell[1] = true;
|
|
58
|
-
|
|
57
|
+
focusableChildren[0]?.focus({
|
|
59
58
|
focusVisible: true
|
|
60
59
|
});
|
|
61
60
|
}
|
|
@@ -97,16 +97,16 @@ class SelectableRows extends EventEmitter {
|
|
|
97
97
|
}
|
|
98
98
|
toggleOneRow(isSelected, key) {
|
|
99
99
|
if (isSelected) {
|
|
100
|
-
if (this.
|
|
101
|
-
this.emit(SelectableRows.
|
|
100
|
+
if (!this.isIndeterminate()) {
|
|
101
|
+
this.emit(SelectableRows.SET_INDETERMINATE_EVENT);
|
|
102
102
|
}
|
|
103
103
|
this.values.add(key);
|
|
104
|
-
if (this.
|
|
104
|
+
if (this.isAllSelected()) {
|
|
105
105
|
this.emit(SelectableRows.SELECT_ALL_EVENT);
|
|
106
106
|
}
|
|
107
107
|
} else {
|
|
108
|
-
if (this.
|
|
109
|
-
this.emit(SelectableRows.
|
|
108
|
+
if (this.isAllSelected()) {
|
|
109
|
+
this.emit(SelectableRows.SET_INDETERMINATE_EVENT);
|
|
110
110
|
}
|
|
111
111
|
this.values.delete(key);
|
|
112
112
|
if (this.values.size === 0) {
|
|
@@ -118,6 +118,7 @@ class SelectableRows extends EventEmitter {
|
|
|
118
118
|
}
|
|
119
119
|
_defineProperty(SelectableRows, "TOGGLE_EVENT", "toggle_selected_row");
|
|
120
120
|
_defineProperty(SelectableRows, "SELECT_ALL_EVENT", "select_all_selected_rows");
|
|
121
|
+
_defineProperty(SelectableRows, "SET_INDETERMINATE_EVENT", "set_indeterminate");
|
|
121
122
|
export {
|
|
122
123
|
SelectableRows
|
|
123
124
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Sortierbar";
|
|
2
2
|
const de = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Details einblenden",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Details ausblenden",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Alle Elemente",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Alle Elemente ausgewählt",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Alle Elemente nicht ausgewählt"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
de as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Ordenable";
|
|
2
2
|
const es = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Mostrar detalles",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Ocultar detalles",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Todos los elementos",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Todos los elementos seleccionados",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Todos los elementos deseleccionados"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
es as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Triable";
|
|
2
2
|
const fr = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Afficher les détails",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Masquer les détails",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Tous les éléments",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Tous les éléments sélectionnés",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Tous les éléments désélectionnés"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
fr as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Ordinabile";
|
|
2
2
|
const it = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Mostra dettagli",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Nascondi dettagli",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Tutti gli elementi",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Tutti gli elementi selezionati",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Tutti gli elementi deselezionati"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
it as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "分類可能";
|
|
2
2
|
const ja = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "詳細を表示する",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "詳細を非表示にする",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "すべての項目",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "すべての項目が選択されました",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "すべての項目が選択解除されました"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
ja as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "정렬 가능";
|
|
2
2
|
const ko = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "세부 정보 표시",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "세부 정보 숨기기",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "모든 항목",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "모든 항목이 선택됨",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "모든 항목이 선택 해제됨"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
ko as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Sorteerbaar";
|
|
2
2
|
const nl = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Details tonen",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Details verbergen",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Alle items",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Alle items geselecteerd",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Alle items niet geselecteerd"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
nl as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Umożliwia sortowanie";
|
|
2
2
|
const pl = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Pokaż szczegóły",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Ukryj szczegóły",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Wszystkie przedmioty",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Wszystkie przedmioty wybrane",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Wszystkie przedmioty odznaczone"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
pl as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Classificável";
|
|
2
2
|
const pt = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Exibir detalhes",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Ocultar detalhes",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Todos os itens",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Todos os itens selecionados",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Todos os itens desmarcados"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
pt as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Sorterbar";
|
|
2
2
|
const sv = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Visa detaljer",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Dölj detaljer",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Alla objekt",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Alla objekt valda",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Alla objekt avmarkerade"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
sv as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Sıralanabilir";
|
|
2
2
|
const tr = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Detayları göster",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Detayları gizle",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Tüm öğeler",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Tüm öğeler seçildi",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Tüm öğeler seçilmedi"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
tr as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "Có thể sắp xếp";
|
|
2
2
|
const vi = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "Hiển thị chi tiết",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "Ẩn bớt",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "Tất cả các mục",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "Tất cả các mục đã được chọn",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "Tất cả các mục đã được bỏ chọn"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
vi as default,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const sortableColumn = "可排序";
|
|
2
2
|
const zh = {
|
|
3
|
-
sortableColumn
|
|
3
|
+
sortableColumn,
|
|
4
|
+
"DataTable.Cell.AccordionToggle.expand:aria-label": "显示详细信息",
|
|
5
|
+
"DataTable.Cell.AccordionToggle.collapse:aria-label": "隐藏详细信息",
|
|
6
|
+
"DataTable.Header.selectAllCheckbox:aria-label": "所有项目",
|
|
7
|
+
"DataTable.allItemsSelected:aria-live": "所有项目已选择",
|
|
8
|
+
"DataTable.allItemsDeselected:aria-live": "所有项目已取消选择"
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
zh as default,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DTRow } from '../Body/Row.types';
|
|
3
|
+
type Props<UniqKey> = {
|
|
4
|
+
selectedRows: Array<UniqKey>;
|
|
5
|
+
getI18nText: (key: string) => string;
|
|
6
|
+
flatRows: DTRow<UniqKey>[];
|
|
7
|
+
data: unknown[];
|
|
8
|
+
};
|
|
9
|
+
export declare function SRAnnouncer<UniqKey>(props: Props<UniqKey>): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ISelectedRows } from '../../store/SelectableRows';
|
|
3
|
+
type Props<UniqKey> = {
|
|
4
|
+
selectedRows: ISelectedRows<UniqKey>;
|
|
5
|
+
getI18nText: (key: string) => string;
|
|
6
|
+
};
|
|
7
|
+
export declare function SRReactiveAnnouncer<UniqKey>(props: Props<UniqKey>): React.JSX.Element;
|
|
8
|
+
export {};
|