@deque/cauldron-react 4.3.0-canary.9d2b7bb9 → 4.3.0-canary.cd53f1dd
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.
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unfortunately, eslint does not recognize the Polymorphic component has propTypes set
|
|
3
|
+
*
|
|
4
|
+
* We might be able to remove this if we upgrade eslint and associated plugins
|
|
5
|
+
* See: https://github.com/dequelabs/cauldron/issues/451
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
1
8
|
import * as Polymorphic from '../../utils/polymorphic-type';
|
|
2
9
|
import { IconType } from '../Icon';
|
|
3
10
|
import { TooltipProps } from '../Tooltip';
|
|
4
11
|
export interface IconButtonOwnProps {
|
|
5
12
|
icon: IconType;
|
|
6
|
-
label:
|
|
13
|
+
label: React.ReactNode;
|
|
7
14
|
tooltipPlacement?: TooltipProps['placement'];
|
|
8
15
|
tooltipVariant?: TooltipProps['variant'];
|
|
9
16
|
tooltipPortal?: TooltipProps['portal'];
|
package/lib/index.js
CHANGED
|
@@ -1665,13 +1665,6 @@ var IconButton = React.forwardRef(function (_a, ref) {
|
|
|
1665
1665
|
accessibilityProps['aria-disabled'] = disabled;
|
|
1666
1666
|
}
|
|
1667
1667
|
}
|
|
1668
|
-
React.useEffect(function () {
|
|
1669
|
-
var _a;
|
|
1670
|
-
if (!disabled) {
|
|
1671
|
-
return;
|
|
1672
|
-
}
|
|
1673
|
-
(_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-label', label);
|
|
1674
|
-
}, [disabled]);
|
|
1675
1668
|
return (React__default.createElement(React__default.Fragment, null,
|
|
1676
1669
|
React__default.createElement(Component, tslib.__assign({ className: classNames(className, {
|
|
1677
1670
|
IconButton: true,
|
|
@@ -1679,7 +1672,8 @@ var IconButton = React.forwardRef(function (_a, ref) {
|
|
|
1679
1672
|
'IconButton--secondary': variant === 'secondary',
|
|
1680
1673
|
'IconButton--error': variant === 'error'
|
|
1681
1674
|
}), ref: internalRef, disabled: disabled, tabIndex: disabled ? -1 : tabIndex }, accessibilityProps, other),
|
|
1682
|
-
React__default.createElement(Icon, { type: icon })
|
|
1675
|
+
React__default.createElement(Icon, { type: icon }),
|
|
1676
|
+
React__default.createElement(Offscreen, null, label)),
|
|
1683
1677
|
!disabled && (React__default.createElement(Tooltip, { target: internalRef, placement: tooltipPlacement, variant: tooltipVariant, portal: tooltipPortal, association: "aria-labelledby", hideElementOnHidden: true }, label))));
|
|
1684
1678
|
});
|
|
1685
1679
|
IconButton.propTypes = {
|
|
@@ -1687,7 +1681,7 @@ IconButton.propTypes = {
|
|
|
1687
1681
|
as: PropTypes.elementType,
|
|
1688
1682
|
// @ts-expect-error
|
|
1689
1683
|
icon: PropTypes.string.isRequired,
|
|
1690
|
-
label: PropTypes.
|
|
1684
|
+
label: PropTypes.node.isRequired,
|
|
1691
1685
|
// @ts-expect-error
|
|
1692
1686
|
tooltipPlacement: PropTypes.string,
|
|
1693
1687
|
// @ts-expect-error
|