@deque/cauldron-react 4.2.1-canary.f766f9dd → 4.3.0-canary.ee347cd5
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>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import SkipLink from '../SkipLink';
|
|
2
3
|
interface TwoColumnPanelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
initialCollapsed?: boolean;
|
|
4
5
|
showCollapsedPanelLabel?: string;
|
|
5
6
|
hideCollapsedPanelLabel?: string;
|
|
7
|
+
skipLink?: SkipLink;
|
|
6
8
|
}
|
|
7
9
|
declare const TwoColumnPanel: React.ForwardRefExoticComponent<TwoColumnPanelProps & React.RefAttributes<HTMLDivElement>>;
|
|
8
10
|
export default TwoColumnPanel;
|
package/lib/index.js
CHANGED
|
@@ -8000,9 +8000,31 @@ function AxeLoader() {
|
|
|
8000
8000
|
React__default.createElement("path", { fill: "currentColor", d: "M379 549.9h-27.6v-16.7c-7.4 13.5-22.8 20.2-39 20.2-37.1 0-58.9-28.9-58.9-61.6 0-36.5 26.4-61.4 58.9-61.4 21.1 0 34 11.2 39 20.5V434H379v115.9zm-97.8-57.4c0 14.3 10.3 35.2 35.2 35.2 15.4 0 25.5-8 30.8-18.6 2.7-5.1 4-10.5 4.4-16.2.2-5.5-.8-11.2-3.2-16.2-4.9-11-15.6-20.5-32.3-20.5-22.4 0-35 18.1-35 36.1v.2zM436.2 488.9l-39-54.8h33.3l22.6 35.6 22.6-35.6h32.9l-38.8 54.8 43.2 61h-34L453.1 510l-26.2 39.9h-33.5l42.8-61z" })));
|
|
8001
8001
|
}
|
|
8002
8002
|
|
|
8003
|
-
|
|
8003
|
+
/**
|
|
8004
|
+
* When a component needs to track an internal ref on a component that has a
|
|
8005
|
+
* forwarded ref, useSharedRef will return a MutableRefObject<T> that will
|
|
8006
|
+
* correctly invoke the parent ref as well providing an internal ref.
|
|
8007
|
+
*
|
|
8008
|
+
* @example
|
|
8009
|
+
* React.forwardRef(function Component({ children }, ref) {
|
|
8010
|
+
* const internalRef = useSharedRef<HTMLElement>(ref)
|
|
8011
|
+
* if (internalRef.current) {
|
|
8012
|
+
* // do something with the internal ref...
|
|
8013
|
+
* }
|
|
8014
|
+
* return (<div ref={internalRef}>...</div>)
|
|
8015
|
+
* })
|
|
8016
|
+
*/
|
|
8017
|
+
function useSharedRef(ref) {
|
|
8018
|
+
var internalRef = React.useRef();
|
|
8019
|
+
React.useEffect(function () {
|
|
8020
|
+
setRef(ref, internalRef.current);
|
|
8021
|
+
}, [ref]);
|
|
8022
|
+
return internalRef;
|
|
8023
|
+
}
|
|
8024
|
+
|
|
8025
|
+
var LoaderOverlay = React.forwardRef(function (_a, ref) {
|
|
8004
8026
|
var className = _a.className, variant = _a.variant, label = _a.label, children = _a.children, focusOnInitialRender = _a.focusOnInitialRender, other = tslib.__rest(_a, ["className", "variant", "label", "children", "focusOnInitialRender"]);
|
|
8005
|
-
var overlayRef =
|
|
8027
|
+
var overlayRef = useSharedRef(ref);
|
|
8006
8028
|
React.useEffect(function () {
|
|
8007
8029
|
if (!!focusOnInitialRender && overlayRef.current) {
|
|
8008
8030
|
setTimeout(function () {
|
|
@@ -8012,11 +8034,6 @@ var LoaderOverlay = React__default.forwardRef(function (_a, ref) {
|
|
|
8012
8034
|
}
|
|
8013
8035
|
return;
|
|
8014
8036
|
}, [overlayRef.current]);
|
|
8015
|
-
React.useEffect(function () {
|
|
8016
|
-
if (typeof ref === 'function') {
|
|
8017
|
-
ref(overlayRef.current);
|
|
8018
|
-
}
|
|
8019
|
-
}, [ref]);
|
|
8020
8037
|
return (React__default.createElement("div", tslib.__assign({ className: classNames('Loader__overlay', className, variant === 'large'
|
|
8021
8038
|
? 'Loader__overlay--large'
|
|
8022
8039
|
: variant === 'small'
|
|
@@ -8106,13 +8123,26 @@ TableHead.propTypes = {
|
|
|
8106
8123
|
};
|
|
8107
8124
|
|
|
8108
8125
|
var TableHeader = function (_a) {
|
|
8109
|
-
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]);
|
|
8110
8138
|
return (React__default.createElement("th", tslib.__assign({ "aria-sort": sortDirection, className: classNames('TableHeader', className, {
|
|
8111
8139
|
'TableHeader--sort-ascending': sortDirection === 'ascending',
|
|
8112
8140
|
'TableHeader--sort-descending': sortDirection === 'descending'
|
|
8113
8141
|
}) }, other), !!onSort && !!sortDirection ? (React__default.createElement("button", { onClick: onSort, className: "TableHeader__sort-button", type: "button" },
|
|
8114
8142
|
children,
|
|
8115
|
-
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)));
|
|
8116
8146
|
};
|
|
8117
8147
|
TableHeader.displayName = 'TableHeader';
|
|
8118
8148
|
TableHeader.propTypes = {
|
|
@@ -8526,11 +8556,23 @@ var BreadcrumbLink = React.forwardRef(function (_a, ref) {
|
|
|
8526
8556
|
return (React__default.createElement(ElementType, tslib.__assign({ className: classNames('Link', 'Breadcrumb__Link', className), ref: ref }, props), children));
|
|
8527
8557
|
});
|
|
8528
8558
|
|
|
8559
|
+
var ColumnLeft = React.forwardRef(function (_a, ref) {
|
|
8560
|
+
var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
|
|
8561
|
+
return (React__default.createElement("section", tslib.__assign({ className: classNames('TwoColumnPanel__Left', className) }, props, { ref: ref }), children));
|
|
8562
|
+
});
|
|
8563
|
+
ColumnLeft.displayName = 'ColumnLeft';
|
|
8564
|
+
|
|
8565
|
+
var ColumnRight = React.forwardRef(function (_a, ref) {
|
|
8566
|
+
var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
|
|
8567
|
+
return (React__default.createElement("section", tslib.__assign({ className: classNames('TwoColumnPanel__Right', className) }, props, { ref: ref }), children));
|
|
8568
|
+
});
|
|
8569
|
+
ColumnRight.displayName = 'ColumnRight';
|
|
8570
|
+
|
|
8529
8571
|
var TwoColumnPanel = React.forwardRef(function (_a, ref) {
|
|
8530
|
-
var className = _a.className, children = _a.children, _b = _a.initialCollapsed, initialCollapsed = _b === void 0 ? false : _b, _c = _a.showCollapsedPanelLabel, showCollapsedPanelLabel = _c === void 0 ? 'Show Panel' : _c, _d = _a.hideCollapsedPanelLabel, hideCollapsedPanelLabel = _d === void 0 ? 'Hide Panel' : _d, props = tslib.__rest(_a, ["className", "children", "initialCollapsed", "showCollapsedPanelLabel", "hideCollapsedPanelLabel"]);
|
|
8531
|
-
var
|
|
8532
|
-
var
|
|
8533
|
-
var
|
|
8572
|
+
var className = _a.className, children = _a.children, _b = _a.initialCollapsed, initialCollapsed = _b === void 0 ? false : _b, _c = _a.showCollapsedPanelLabel, showCollapsedPanelLabel = _c === void 0 ? 'Show Panel' : _c, _d = _a.hideCollapsedPanelLabel, hideCollapsedPanelLabel = _d === void 0 ? 'Hide Panel' : _d, _e = _a.skipLink, skipLink = _e === void 0 ? null : _e, props = tslib.__rest(_a, ["className", "children", "initialCollapsed", "showCollapsedPanelLabel", "hideCollapsedPanelLabel", "skipLink"]);
|
|
8573
|
+
var _f = tslib.__read(React.useState(initialCollapsed), 2), isCollapsed = _f[0], setCollapsed = _f[1];
|
|
8574
|
+
var _g = tslib.__read(React.useState(false), 2), isFocusTrap = _g[0], setIsFocusTrap = _g[1];
|
|
8575
|
+
var _h = tslib.__read(React.useState(!initialCollapsed), 2), showPanel = _h[0], setShowPanel = _h[1];
|
|
8534
8576
|
var togglePanel = function () {
|
|
8535
8577
|
if (isCollapsed) {
|
|
8536
8578
|
setShowPanel(true);
|
|
@@ -8657,6 +8699,7 @@ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
|
|
|
8657
8699
|
fallbackFocus: columnLeftRef.current
|
|
8658
8700
|
}, containerElements: [columnLeftRef.current] }),
|
|
8659
8701
|
React__default.createElement(ClickOutsideListener, { onClickOutside: handleClickOutside, target: columnLeftRef.current }),
|
|
8702
|
+
isCollapsed ? null : skipLink,
|
|
8660
8703
|
showPanel ? ColumnLeftComponent : null,
|
|
8661
8704
|
ColumnRightComponent));
|
|
8662
8705
|
});
|
|
@@ -8674,18 +8717,6 @@ var ColumnGroupHeader = React.forwardRef(function (_a, ref) {
|
|
|
8674
8717
|
});
|
|
8675
8718
|
ColumnGroupHeader.displayName = 'ColumnGroupHeader';
|
|
8676
8719
|
|
|
8677
|
-
var ColumnLeft = React.forwardRef(function (_a, ref) {
|
|
8678
|
-
var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
|
|
8679
|
-
return (React__default.createElement("section", tslib.__assign({ className: classNames('TwoColumnPanel__Left', className) }, props, { ref: ref }), children));
|
|
8680
|
-
});
|
|
8681
|
-
ColumnLeft.displayName = 'ColumnLeft';
|
|
8682
|
-
|
|
8683
|
-
var ColumnRight = React.forwardRef(function (_a, ref) {
|
|
8684
|
-
var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
|
|
8685
|
-
return (React__default.createElement("section", tslib.__assign({ className: classNames('TwoColumnPanel__Right', className) }, props, { ref: ref }), children));
|
|
8686
|
-
});
|
|
8687
|
-
ColumnRight.displayName = 'ColumnRight';
|
|
8688
|
-
|
|
8689
8720
|
var ColumnList = React.forwardRef(function (_a, ref) {
|
|
8690
8721
|
var className = _a.className, children = _a.children, props = tslib.__rest(_a, ["className", "children"]);
|
|
8691
8722
|
return (React__default.createElement("div", tslib.__assign({ className: classNames('TwoColumnPanel__List', className) }, props, { ref: ref }), children));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MutableRefObject, Ref } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* When a component needs to track an internal ref on a component that has a
|
|
4
|
+
* forwarded ref, useSharedRef will return a MutableRefObject<T> that will
|
|
5
|
+
* correctly invoke the parent ref as well providing an internal ref.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* React.forwardRef(function Component({ children }, ref) {
|
|
9
|
+
* const internalRef = useSharedRef<HTMLElement>(ref)
|
|
10
|
+
* if (internalRef.current) {
|
|
11
|
+
* // do something with the internal ref...
|
|
12
|
+
* }
|
|
13
|
+
* return (<div ref={internalRef}>...</div>)
|
|
14
|
+
* })
|
|
15
|
+
*/
|
|
16
|
+
export default function useSharedRef<T>(ref: Ref<T>): MutableRefObject<T>;
|