@deque/cauldron-react 4.2.1-canary.d1539456 → 4.3.0-canary.acd760d8
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.
|
@@ -6,9 +6,11 @@ interface TableHeaderProps extends ThHTMLAttributes<HTMLTableCellElement> {
|
|
|
6
6
|
sortDirection?: SortDirection;
|
|
7
7
|
onSort?: () => void;
|
|
8
8
|
className?: string;
|
|
9
|
+
sortAscendingAnnouncement?: string;
|
|
10
|
+
sortDescendingAnnouncemen?: string;
|
|
9
11
|
}
|
|
10
12
|
declare const TableHeader: {
|
|
11
|
-
({ children, sortDirection, onSort, className, ...other }: TableHeaderProps): JSX.Element;
|
|
13
|
+
({ children, sortDirection, onSort, className, sortAscendingAnnouncement, sortDescendingAnnouncemen, ...other }: TableHeaderProps): JSX.Element;
|
|
12
14
|
displayName: string;
|
|
13
15
|
propTypes: {
|
|
14
16
|
children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
package/lib/index.js
CHANGED
|
@@ -8123,13 +8123,26 @@ TableHead.propTypes = {
|
|
|
8123
8123
|
};
|
|
8124
8124
|
|
|
8125
8125
|
var TableHeader = function (_a) {
|
|
8126
|
-
var children = _a.children, sortDirection = _a.sortDirection, onSort = _a.onSort, className = _a.className, other = tslib.__rest(_a, ["children", "sortDirection", "onSort", "className"]);
|
|
8126
|
+
var children = _a.children, sortDirection = _a.sortDirection, onSort = _a.onSort, className = _a.className, _b = _a.sortAscendingAnnouncement, sortAscendingAnnouncement = _b === void 0 ? 'sorted ascending' : _b, _c = _a.sortDescendingAnnouncemen, sortDescendingAnnouncemen = _c === void 0 ? 'sorted descending' : _c, other = tslib.__rest(_a, ["children", "sortDirection", "onSort", "className", "sortAscendingAnnouncement", "sortDescendingAnnouncemen"]);
|
|
8127
|
+
// When the sort direction changes, we want to announce the change in a live region
|
|
8128
|
+
// because changes to the sort value is not widely supported yet
|
|
8129
|
+
// see: https://a11ysupport.io/tech/aria/aria-sort_attribute
|
|
8130
|
+
var _d = tslib.__read(React.useState(''), 2), announcement = _d[0], setAnnouncement = _d[1];
|
|
8131
|
+
React.useEffect(function () {
|
|
8132
|
+
if (sortDirection !== 'none') {
|
|
8133
|
+
setAnnouncement(sortDirection === 'ascending'
|
|
8134
|
+
? sortAscendingAnnouncement
|
|
8135
|
+
: sortDescendingAnnouncemen);
|
|
8136
|
+
}
|
|
8137
|
+
}, [sortDirection]);
|
|
8127
8138
|
return (React__default.createElement("th", tslib.__assign({ "aria-sort": sortDirection, className: classNames('TableHeader', className, {
|
|
8128
8139
|
'TableHeader--sort-ascending': sortDirection === 'ascending',
|
|
8129
8140
|
'TableHeader--sort-descending': sortDirection === 'descending'
|
|
8130
8141
|
}) }, other), !!onSort && !!sortDirection ? (React__default.createElement("button", { onClick: onSort, className: "TableHeader__sort-button", type: "button" },
|
|
8131
8142
|
children,
|
|
8132
|
-
React__default.createElement("span", { "aria-hidden": "true" }, sortDirection === 'none' ? (React__default.createElement(Icon, { type: "sort-triangle" })) : sortDirection === 'ascending' ? (React__default.createElement(Icon, { type: "triangle-up" })) : (React__default.createElement(Icon, { type: "triangle-down" })))
|
|
8143
|
+
React__default.createElement("span", { "aria-hidden": "true" }, sortDirection === 'none' ? (React__default.createElement(Icon, { type: "sort-triangle" })) : sortDirection === 'ascending' ? (React__default.createElement(Icon, { type: "triangle-up" })) : (React__default.createElement(Icon, { type: "triangle-down" }))),
|
|
8144
|
+
React__default.createElement(Offscreen, null,
|
|
8145
|
+
React__default.createElement("span", { role: "status", "aria-live": "polite" }, announcement)))) : (children)));
|
|
8133
8146
|
};
|
|
8134
8147
|
TableHeader.displayName = 'TableHeader';
|
|
8135
8148
|
TableHeader.propTypes = {
|