@deque/cauldron-react 6.3.2-canary.fd124360 → 6.4.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.
|
@@ -2,14 +2,25 @@ import React from 'react';
|
|
|
2
2
|
import { IconType } from '../Icon';
|
|
3
3
|
import { TooltipProps } from '../Tooltip';
|
|
4
4
|
import { PolymorphicProps, PolymorphicComponent } from '../../utils/polymorphicComponent';
|
|
5
|
-
export interface IconButtonProps extends PolymorphicProps<React.HTMLAttributes<HTMLButtonElement>, 'button'> {
|
|
5
|
+
export interface IconButtonProps extends PolymorphicProps<React.HTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, 'button' | 'a'> {
|
|
6
6
|
icon: IconType;
|
|
7
7
|
label: React.ReactNode;
|
|
8
|
+
tooltipProps?: Omit<TooltipProps, 'children' | 'target'>;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use `tooltipProps.placement` instead
|
|
12
|
+
*/
|
|
8
13
|
tooltipPlacement?: TooltipProps['placement'];
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated use `tooltipProps.variant` instead
|
|
16
|
+
*/
|
|
9
17
|
tooltipVariant?: TooltipProps['variant'];
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated use `tooltipProps.portal` instead
|
|
20
|
+
*/
|
|
10
21
|
tooltipPortal?: TooltipProps['portal'];
|
|
11
22
|
variant?: 'primary' | 'secondary' | 'error';
|
|
12
23
|
large?: boolean;
|
|
13
24
|
}
|
|
14
|
-
declare const IconButton: PolymorphicComponent<IconButtonProps, "button">;
|
|
25
|
+
declare const IconButton: PolymorphicComponent<IconButtonProps, "button" | "a">;
|
|
15
26
|
export default IconButton;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import AriaIsolate from '../../utils/aria-isolate';
|
|
3
|
-
export interface ToastProps {
|
|
3
|
+
export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
type: 'confirmation' | 'caution' | 'error' | 'action-needed' | 'info';
|
|
5
5
|
onDismiss: () => void;
|
|
6
6
|
dismissText?: string;
|
package/lib/index.js
CHANGED
|
@@ -1797,25 +1797,38 @@ var TooltipContent = function (_a) {
|
|
|
1797
1797
|
return (React__default["default"].createElement("div", tslib.__assign({ className: classNames__default["default"]('TooltipContent', className) }, other)));
|
|
1798
1798
|
};
|
|
1799
1799
|
|
|
1800
|
+
var isButton = function (component) { return component === 'button'; };
|
|
1801
|
+
var looksLikeLink = function (props) {
|
|
1802
|
+
return 'to' in props || 'href' in props;
|
|
1803
|
+
};
|
|
1800
1804
|
var IconButton = React.forwardRef(function (_a, ref) {
|
|
1801
|
-
var _b = _a.as, Component = _b === void 0 ? 'button' : _b, icon = _a.icon, label = _a.label,
|
|
1805
|
+
var _b = _a.as, Component = _b === void 0 ? 'button' : _b, icon = _a.icon, label = _a.label, tooltipPlacement = _a.tooltipPlacement, tooltipVariant = _a.tooltipVariant, tooltipPortal = _a.tooltipPortal, _c = _a.tooltipProps, tooltipPropsProp = _c === void 0 ? {} : _c, className = _a.className, _d = _a.variant, variant = _d === void 0 ? 'secondary' : _d, disabled = _a.disabled, _e = _a.tabIndex, tabIndex = _e === void 0 ? 0 : _e, large = _a.large, other = tslib.__rest(_a, ["as", "icon", "label", "tooltipPlacement", "tooltipVariant", "tooltipPortal", "tooltipProps", "className", "variant", "disabled", "tabIndex", "large"]);
|
|
1802
1806
|
var internalRef = React.useRef();
|
|
1803
1807
|
React.useImperativeHandle(ref, function () { return internalRef.current; });
|
|
1804
1808
|
// Configure additional properties based on the type of the Component
|
|
1805
1809
|
// for accessibility
|
|
1806
1810
|
var accessibilityProps = {};
|
|
1807
|
-
if (Component
|
|
1811
|
+
if (isButton(Component)) {
|
|
1808
1812
|
accessibilityProps.type = 'button';
|
|
1809
1813
|
}
|
|
1810
1814
|
else {
|
|
1811
1815
|
// We don't need to set an anchor's role, since it would be redundant
|
|
1812
1816
|
if (Component !== 'a') {
|
|
1813
|
-
accessibilityProps.role = other
|
|
1817
|
+
accessibilityProps.role = looksLikeLink(other) ? 'link' : 'button';
|
|
1814
1818
|
}
|
|
1815
1819
|
if (disabled) {
|
|
1816
1820
|
accessibilityProps['aria-disabled'] = disabled;
|
|
1817
1821
|
}
|
|
1818
1822
|
}
|
|
1823
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1824
|
+
if (!!tooltipPlacement || !!tooltipVariant || !!tooltipPortal) {
|
|
1825
|
+
React__default["default"].useEffect(function () {
|
|
1826
|
+
console.warn('[IconButton] The following props are deprecated: tooltipPlacement, tooltipVariant, tooltipPortal. ' +
|
|
1827
|
+
'See https://cauldron.dequelabs.com/components/IconButton for recommended replacement.');
|
|
1828
|
+
}, []);
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
var tooltipProps = tslib.__assign({ placement: tooltipPlacement || 'auto', variant: tooltipVariant, portal: tooltipPortal, association: 'aria-labelledby', hideElementOnHidden: true }, tooltipPropsProp);
|
|
1819
1832
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1820
1833
|
React__default["default"].createElement(Component, tslib.__assign({ className: classNames__default["default"](className, {
|
|
1821
1834
|
IconButton: true,
|
|
@@ -1823,10 +1836,12 @@ var IconButton = React.forwardRef(function (_a, ref) {
|
|
|
1823
1836
|
'IconButton--secondary': variant === 'secondary',
|
|
1824
1837
|
'IconButton--error': variant === 'error',
|
|
1825
1838
|
'IconButton--large': large
|
|
1826
|
-
}),
|
|
1839
|
+
}),
|
|
1840
|
+
// @ts-expect-error the concrete type is unknown, so HTMLElement is expected
|
|
1841
|
+
ref: internalRef, disabled: disabled, tabIndex: disabled ? -1 : tabIndex }, accessibilityProps, other),
|
|
1827
1842
|
React__default["default"].createElement(Icon, { type: icon }),
|
|
1828
1843
|
disabled && React__default["default"].createElement(Offscreen, null, label)),
|
|
1829
|
-
!disabled && (React__default["default"].createElement(Tooltip, { target: internalRef
|
|
1844
|
+
!disabled && (React__default["default"].createElement(Tooltip, tslib.__assign({ target: internalRef }, tooltipProps), label))));
|
|
1830
1845
|
});
|
|
1831
1846
|
IconButton.displayName = 'IconButton';
|
|
1832
1847
|
|
|
@@ -1932,11 +1947,11 @@ var Toast = /** @class */ (function (_super) {
|
|
|
1932
1947
|
var _a = this.props, type = _a.type, children = _a.children;
|
|
1933
1948
|
// prevent `onDismiss` from being passed-through to DOM
|
|
1934
1949
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1935
|
-
_a.onDismiss; var dismissText = _a.dismissText, toastRef = _a.toastRef, focus = _a.focus, show = _a.show, dismissible = _a.dismissible, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show", "dismissible"]);
|
|
1950
|
+
_a.onDismiss; var dismissText = _a.dismissText, toastRef = _a.toastRef, focus = _a.focus, show = _a.show, dismissible = _a.dismissible, className = _a.className, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show", "dismissible", "className"]);
|
|
1936
1951
|
var scrim = type === 'action-needed' && show ? (React__default["default"].createElement("div", { className: "Scrim--light Scrim--show Scrim--fade-in" })) : null;
|
|
1937
1952
|
var defaultProps = {
|
|
1938
1953
|
tabIndex: -1,
|
|
1939
|
-
className: classNames__default["default"]('Toast', "Toast--".concat(typeMap[type].className), animationClass, { 'Toast--non-dismissible': !dismissible })
|
|
1954
|
+
className: classNames__default["default"]('Toast', "Toast--".concat(typeMap[type].className), animationClass, { 'Toast--non-dismissible': !dismissible }, className)
|
|
1940
1955
|
};
|
|
1941
1956
|
if (!focus) {
|
|
1942
1957
|
defaultProps.role = 'alert';
|
|
@@ -2267,7 +2282,7 @@ var RadioCardGroup = function (_a) {
|
|
|
2267
2282
|
RadioCardGroup.displayName = 'RadioCardGroup';
|
|
2268
2283
|
|
|
2269
2284
|
var Checkbox = React.forwardRef(function (_a, ref) {
|
|
2270
|
-
var id = _a.id, label = _a.label, labelDescription = _a.labelDescription, error = _a.error, checkboxRef = _a.checkboxRef, className = _a.className, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, ariaDescribedby = _a["aria-describedby"], _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.checked, checked = _c === void 0 ? false : _c
|
|
2285
|
+
var id = _a.id, label = _a.label, labelDescription = _a.labelDescription, error = _a.error, checkboxRef = _a.checkboxRef, className = _a.className, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, ariaDescribedby = _a["aria-describedby"], _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.checked, checked = _c === void 0 ? false : _c; _a.children; var other = tslib.__rest(_a, ["id", "label", "labelDescription", "error", "checkboxRef", "className", "onChange", "onFocus", "onBlur", 'aria-describedby', "disabled", "checked", "children"]);
|
|
2271
2286
|
var _d = tslib.__read(React.useState(checked), 2), isChecked = _d[0], setIsChecked = _d[1];
|
|
2272
2287
|
var _e = tslib.__read(React.useState(false), 2), focused = _e[0], setFocused = _e[1];
|
|
2273
2288
|
var checkRef = React.useRef(null);
|
|
@@ -2368,7 +2383,7 @@ var TextField = /** @class */ (function (_super) {
|
|
|
2368
2383
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2369
2384
|
_a.onChange;
|
|
2370
2385
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2371
|
-
_a.defaultValue; var _b = _a.error, error = _b === void 0 ? null : _b, requiredText = _a.requiredText, multiline = _a.multiline, ariaDescribedby = _a["aria-describedby"]
|
|
2386
|
+
_a.defaultValue; var _b = _a.error, error = _b === void 0 ? null : _b, requiredText = _a.requiredText, multiline = _a.multiline, ariaDescribedby = _a["aria-describedby"]; _a.children; var className = _a.className, other = tslib.__rest(_a, ["label", "fieldRef", "value", "onChange", "defaultValue", "error", "requiredText", "multiline", 'aria-describedby', "children", "className"]);
|
|
2372
2387
|
// typescript can't infer the type so it's complaining about
|
|
2373
2388
|
// textarea and input props being incompatible
|
|
2374
2389
|
// we should probably fix this
|
|
@@ -2875,9 +2890,9 @@ var Pagination = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
2875
2890
|
}) }, other),
|
|
2876
2891
|
React__default["default"].createElement("ul", null,
|
|
2877
2892
|
React__default["default"].createElement("li", null,
|
|
2878
|
-
React__default["default"].createElement(IconButton, { icon: "chevron-double-left",
|
|
2893
|
+
React__default["default"].createElement(IconButton, { icon: "chevron-double-left", tooltipProps: { placement: tooltipPlacement }, label: firstPageLabel, "aria-disabled": isFirstPage, onClick: isFirstPage ? undefined : onFirstPageClick })),
|
|
2879
2894
|
React__default["default"].createElement("li", null,
|
|
2880
|
-
React__default["default"].createElement(IconButton, { icon: "chevron-left",
|
|
2895
|
+
React__default["default"].createElement(IconButton, { icon: "chevron-left", tooltipProps: { placement: tooltipPlacement }, label: previousPageLabel, "aria-disabled": isFirstPage, onClick: isFirstPage ? undefined : onPreviousPageClick })),
|
|
2881
2896
|
React__default["default"].createElement("li", null,
|
|
2882
2897
|
React__default["default"].createElement("span", { role: "log", "aria-atomic": "true", "aria-live": "polite" }, statusLabel || (React__default["default"].createElement("span", null,
|
|
2883
2898
|
"Showing ",
|
|
@@ -2888,9 +2903,9 @@ var Pagination = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
2888
2903
|
" of ",
|
|
2889
2904
|
React__default["default"].createElement("strong", null, totalItems))))),
|
|
2890
2905
|
React__default["default"].createElement("li", null,
|
|
2891
|
-
React__default["default"].createElement(IconButton, { icon: "chevron-right",
|
|
2906
|
+
React__default["default"].createElement(IconButton, { icon: "chevron-right", tooltipProps: { placement: tooltipPlacement }, label: nextPageLabel, "aria-disabled": isLastPage, onClick: isLastPage ? undefined : onNextPageClick })),
|
|
2892
2907
|
React__default["default"].createElement("li", null,
|
|
2893
|
-
React__default["default"].createElement(IconButton, { icon: "chevron-double-right",
|
|
2908
|
+
React__default["default"].createElement(IconButton, { icon: "chevron-double-right", tooltipProps: { placement: tooltipPlacement }, label: lastPageLabel, "aria-disabled": isLastPage, onClick: isLastPage ? undefined : onLastPageClick })))));
|
|
2894
2909
|
});
|
|
2895
2910
|
Pagination.displayName = 'Pagination';
|
|
2896
2911
|
|
package/package.json
CHANGED