carbon-react 114.11.0 → 114.12.1
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/esm/components/dialog/dialog.component.js +1 -1
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +1 -1
- package/esm/components/dismissible-box/dismissible-box.component.js +1 -1
- package/esm/components/icon-button/icon-button.component.d.ts +4 -2
- package/esm/components/icon-button/icon-button.component.js +16 -5
- package/esm/components/image/image.component.d.ts +1 -1
- package/esm/components/image/image.component.js +4 -1
- package/esm/components/image/image.style.d.ts +2 -0
- package/esm/components/link-preview/link-preview.component.js +1 -1
- package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +1 -1
- package/esm/components/message/message.component.js +1 -1
- package/esm/components/pill/pill.component.js +1 -1
- package/esm/components/pod/pod.component.js +2 -2
- package/esm/components/popover-container/popover-container.component.js +2 -2
- package/esm/components/sidebar/sidebar.component.js +1 -1
- package/esm/components/toast/toast.component.js +1 -1
- package/esm/components/vertical-menu/vertical-menu-full-screen.component.js +1 -1
- package/lib/components/dialog/dialog.component.js +1 -1
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +1 -1
- package/lib/components/dismissible-box/dismissible-box.component.js +1 -1
- package/lib/components/icon-button/icon-button.component.d.ts +4 -2
- package/lib/components/icon-button/icon-button.component.js +20 -5
- package/lib/components/image/image.component.d.ts +1 -1
- package/lib/components/image/image.component.js +4 -1
- package/lib/components/image/image.style.d.ts +2 -0
- package/lib/components/link-preview/link-preview.component.js +1 -1
- package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +1 -1
- package/lib/components/message/message.component.js +1 -1
- package/lib/components/pill/pill.component.js +1 -1
- package/lib/components/pod/pod.component.js +2 -2
- package/lib/components/popover-container/popover-container.component.js +2 -2
- package/lib/components/sidebar/sidebar.component.js +1 -1
- package/lib/components/toast/toast.component.js +1 -1
- package/lib/components/vertical-menu/vertical-menu-full-screen.component.js +1 -1
- package/package.json +1 -1
|
@@ -117,7 +117,7 @@ const Dialog = ({
|
|
|
117
117
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
118
118
|
"data-element": "close",
|
|
119
119
|
"aria-label": locale.dialog.ariaLabels.close(),
|
|
120
|
-
|
|
120
|
+
onClick: onCancel,
|
|
121
121
|
disabled: disableClose
|
|
122
122
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
123
123
|
type: "close"
|
|
@@ -58,7 +58,7 @@ const DialogFullScreen = ({
|
|
|
58
58
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
59
59
|
"data-element": "close",
|
|
60
60
|
"aria-label": locale.dialogFullScreen.ariaLabels.close(),
|
|
61
|
-
|
|
61
|
+
onClick: onCancel
|
|
62
62
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
63
63
|
type: "close"
|
|
64
64
|
}));
|
|
@@ -16,7 +16,7 @@ const DismissibleBox = ({
|
|
|
16
16
|
}, rest), children, /*#__PURE__*/React.createElement("span", {
|
|
17
17
|
"data-element": "close-button-wrapper"
|
|
18
18
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
19
|
-
|
|
19
|
+
onClick: onClose,
|
|
20
20
|
"aria-label": "close-button",
|
|
21
21
|
ml: 3
|
|
22
22
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -14,10 +14,12 @@ export interface IconButtonProps extends SpaceProps {
|
|
|
14
14
|
onMouseEnter?: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
15
15
|
/** Callback triggered on mouse leave */
|
|
16
16
|
onMouseLeave?: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
17
|
-
/** Action callback */
|
|
18
|
-
onAction
|
|
17
|
+
/** [DEPRECATED - use `onClick` instead] Action callback */
|
|
18
|
+
onAction?: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
19
19
|
/** Set the button to disabled */
|
|
20
20
|
disabled?: boolean;
|
|
21
|
+
/** Callback triggered on click */
|
|
22
|
+
onClick?: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
21
23
|
}
|
|
22
24
|
declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
23
25
|
export default IconButton;
|
|
@@ -2,19 +2,29 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import React, { useState, useCallback, useContext } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
+
import invariant from "invariant";
|
|
5
6
|
import Events from "../../__internal__/utils/helpers/events";
|
|
6
7
|
import StyledIconButton from "./icon-button.style";
|
|
7
8
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
8
9
|
import { ButtonBarContext } from "../button-bar/button-bar.component";
|
|
10
|
+
import Logger from "../../__internal__/utils/logger";
|
|
11
|
+
let onActionButtonWarnTriggered = false;
|
|
9
12
|
const IconButton = /*#__PURE__*/React.forwardRef(({
|
|
10
13
|
"aria-label": ariaLabel,
|
|
11
14
|
onAction,
|
|
15
|
+
onClick,
|
|
12
16
|
children,
|
|
13
17
|
disabled,
|
|
14
18
|
...rest
|
|
15
19
|
}, ref) => {
|
|
16
20
|
var _internalRef$querySel;
|
|
17
21
|
|
|
22
|
+
if (!onActionButtonWarnTriggered && onAction) {
|
|
23
|
+
onActionButtonWarnTriggered = true;
|
|
24
|
+
Logger.deprecate("The `onAction` callback for the `IconButton` component is deprecated and will soon be removed. Please use `onClick` instead");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
!!(onClick && onAction) ? process.env.NODE_ENV !== "production" ? invariant(false, "onClick and onAction have both been set, please use onClick as onAction will soon be deprecated") : invariant(false) : void 0;
|
|
18
28
|
const [internalRef, setInternalRef] = useState();
|
|
19
29
|
const context = useContext(ButtonBarContext);
|
|
20
30
|
const ariaLabelValue = Object.keys(context).length ? ariaLabel || (internalRef === null || internalRef === void 0 ? void 0 : (_internalRef$querySel = internalRef.querySelector("[data-component='icon']")) === null || _internalRef$querySel === void 0 ? void 0 : _internalRef$querySel.getAttribute("type")) || undefined : ariaLabel;
|
|
@@ -22,14 +32,14 @@ const IconButton = /*#__PURE__*/React.forwardRef(({
|
|
|
22
32
|
const handleKeyDown = e => {
|
|
23
33
|
if (Events.isEnterKey(e) || Events.isSpaceKey(e)) {
|
|
24
34
|
e.preventDefault();
|
|
25
|
-
onAction(e);
|
|
26
|
-
|
|
27
|
-
e.stopPropagation();
|
|
35
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(e);
|
|
36
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
28
37
|
}
|
|
29
38
|
};
|
|
30
39
|
|
|
31
40
|
const handleOnClick = e => {
|
|
32
|
-
onAction(e);
|
|
41
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(e);
|
|
42
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
33
43
|
};
|
|
34
44
|
|
|
35
45
|
const setRefs = useCallback(reference => {
|
|
@@ -210,8 +220,9 @@ IconButton.propTypes = {
|
|
|
210
220
|
"toString": PropTypes.func.isRequired,
|
|
211
221
|
"valueOf": PropTypes.func.isRequired
|
|
212
222
|
}), PropTypes.string]),
|
|
213
|
-
"onAction": PropTypes.func
|
|
223
|
+
"onAction": PropTypes.func,
|
|
214
224
|
"onBlur": PropTypes.func,
|
|
225
|
+
"onClick": PropTypes.func,
|
|
215
226
|
"onFocus": PropTypes.func,
|
|
216
227
|
"onMouseEnter": PropTypes.func,
|
|
217
228
|
"onMouseLeave": PropTypes.func,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { StyledImageProps } from "./image.style";
|
|
3
3
|
export declare const Image: {
|
|
4
|
-
({ alt, src, children, ...rest }: StyledImageProps): JSX.Element;
|
|
4
|
+
({ alt, decorative, src, children, ...rest }: StyledImageProps): JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
export default Image;
|
|
@@ -7,14 +7,16 @@ import { StyledImage } from "./image.style";
|
|
|
7
7
|
|
|
8
8
|
const Image = ({
|
|
9
9
|
alt,
|
|
10
|
+
decorative = false,
|
|
10
11
|
src,
|
|
11
12
|
children,
|
|
12
13
|
...rest
|
|
13
14
|
}) => {
|
|
14
15
|
!(!src || !children) ? process.env.NODE_ENV !== "production" ? invariant(false, "The 'Image' component renders as an 'img' element when the 'src' prop is used and therefore does not accept children.") : invariant(false) : void 0;
|
|
15
|
-
!(!src || alt && typeof alt === "string") ? process.env.NODE_ENV !== "production" ? invariant(false, "Please provide an 'alt' string when rendering the 'Image' component as an 'img' element.") : invariant(false) : void 0;
|
|
16
|
+
!(!src || alt && typeof alt === "string" || decorative) ? process.env.NODE_ENV !== "production" ? invariant(false, "Please use the 'decorative' prop if the 'alt' text should be an empty value or provide an 'alt' string when rendering the 'Image' component as an 'img' element.") : invariant(false) : void 0;
|
|
16
17
|
return /*#__PURE__*/React.createElement(StyledImage, _extends({
|
|
17
18
|
alt: alt,
|
|
19
|
+
decorative: decorative,
|
|
18
20
|
src: src
|
|
19
21
|
}, rest), children);
|
|
20
22
|
};
|
|
@@ -527,6 +529,7 @@ Image.propTypes = {
|
|
|
527
529
|
"valueOf": PropTypes.func.isRequired
|
|
528
530
|
}), PropTypes.string]),
|
|
529
531
|
"children": PropTypes.node,
|
|
532
|
+
"decorative": PropTypes.bool,
|
|
530
533
|
"display": PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "-ms-flexbox", "-ms-grid", "-ms-inline-flexbox", "-ms-inline-grid", "-webkit-flex", "-webkit-inline-flex", "block", "contents", "flex", "flow-root", "flow", "grid", "inherit", "initial", "inline-block", "inline-flex", "inline-grid", "inline-list-item", "inline-table", "inline", "list-item", "none", "revert", "ruby-base-container", "ruby-base", "ruby-text-container", "ruby-text", "ruby", "run-in", "table-caption", "table-cell", "table-column-group", "table-column", "table-footer-group", "table-header-group", "table-row-group", "table-row", "table", "unset"]), PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "-ms-flexbox", "-ms-grid", "-ms-inline-flexbox", "-ms-inline-grid", "-webkit-flex", "-webkit-inline-flex", "block", "contents", "flex", "flow-root", "flow", "grid", "inherit", "initial", "inline-block", "inline-flex", "inline-grid", "inline-list-item", "inline-table", "inline", "list-item", "none", "revert", "ruby-base-container", "ruby-base", "ruby-text-container", "ruby-text", "ruby", "run-in", "table-caption", "table-cell", "table-column-group", "table-column", "table-footer-group", "table-header-group", "table-row-group", "table-row", "table", "unset", null]), PropTypes.shape({
|
|
531
534
|
"__@iterator": PropTypes.func.isRequired,
|
|
532
535
|
"anchor": PropTypes.func.isRequired,
|
|
@@ -3,6 +3,8 @@ import { MarginProps, BackgroundProps, LayoutProps } from "styled-system";
|
|
|
3
3
|
export interface StyledImageProps extends MarginProps, BackgroundProps, LayoutProps {
|
|
4
4
|
/** HTML alt property to display when an img fails to load */
|
|
5
5
|
alt?: string;
|
|
6
|
+
/** Prop to specify if the image is decorative */
|
|
7
|
+
decorative?: boolean;
|
|
6
8
|
/** Any valid file path, passing this will render the component as an img element */
|
|
7
9
|
src?: string;
|
|
8
10
|
/** HTML hidden property to indicate whether to remain hidden visually and from screen readers */
|
|
@@ -55,7 +55,7 @@ const LinkPreview = ({
|
|
|
55
55
|
lines: 4
|
|
56
56
|
}, /*#__PURE__*/React.createElement(StyledTitle, null, title), /*#__PURE__*/React.createElement(StyledDescription, null, /*#__PURE__*/React.createElement("div", null, description)), /*#__PURE__*/React.createElement(StyledUrl, null, displayUrl()))), onClose && as === "div" && /*#__PURE__*/React.createElement(StyledCloseIconWrapper, null, /*#__PURE__*/React.createElement(IconButton, {
|
|
57
57
|
"aria-label": "link preview close button",
|
|
58
|
-
|
|
58
|
+
onClick: () => onClose(url)
|
|
59
59
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
60
60
|
type: "close"
|
|
61
61
|
}))));
|
|
@@ -63,7 +63,7 @@ const MenuFullscreen = ({
|
|
|
63
63
|
startPosition: startPosition
|
|
64
64
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
65
65
|
"aria-label": "menu fullscreen close button",
|
|
66
|
-
|
|
66
|
+
onClick: onClose,
|
|
67
67
|
"data-element": "close"
|
|
68
68
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
69
69
|
type: "close",
|
|
@@ -32,7 +32,7 @@ const Message = ({
|
|
|
32
32
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
33
33
|
"data-element": "close",
|
|
34
34
|
"aria-label": closeButtonAriaLabel || l.message.closeButtonAriaLabel(),
|
|
35
|
-
|
|
35
|
+
onClick: onDismiss
|
|
36
36
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
37
37
|
type: "close"
|
|
38
38
|
}));
|
|
@@ -32,7 +32,7 @@ const Pill = ({
|
|
|
32
32
|
maxWidth: maxWidth,
|
|
33
33
|
wrapText: wrapText
|
|
34
34
|
}, rest), children, onDelete && /*#__PURE__*/React.createElement(IconButton, {
|
|
35
|
-
|
|
35
|
+
onClick: onDelete,
|
|
36
36
|
"data-element": "close",
|
|
37
37
|
"aria-label": ariaLabelOfRemoveButton
|
|
38
38
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -122,7 +122,7 @@ const Pod = /*#__PURE__*/React.forwardRef(({
|
|
|
122
122
|
noBorder: !border,
|
|
123
123
|
size: size,
|
|
124
124
|
variant: variant,
|
|
125
|
-
|
|
125
|
+
onClick: processPodAction(onUndo)
|
|
126
126
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
127
127
|
type: "undo"
|
|
128
128
|
})), !softDelete && onEdit && /*#__PURE__*/React.createElement(StyledEditAction, _extends({}, editEvents, {
|
|
@@ -152,7 +152,7 @@ const Pod = /*#__PURE__*/React.forwardRef(({
|
|
|
152
152
|
noBorder: !border,
|
|
153
153
|
size: size,
|
|
154
154
|
variant: variant,
|
|
155
|
-
|
|
155
|
+
onClick: processPodAction(onDelete)
|
|
156
156
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
157
157
|
type: "delete"
|
|
158
158
|
}))));
|
|
@@ -22,7 +22,7 @@ const renderOpen = ({
|
|
|
22
22
|
"aria-haspopup": ariaHasPopup
|
|
23
23
|
}) => /*#__PURE__*/React.createElement(PopoverContainerOpenIcon, {
|
|
24
24
|
tabIndex: tabIndex,
|
|
25
|
-
|
|
25
|
+
onClick: onClick,
|
|
26
26
|
"data-element": dataElement,
|
|
27
27
|
ref: ref,
|
|
28
28
|
"aria-label": ariaLabel,
|
|
@@ -54,7 +54,7 @@ const renderClose = ({
|
|
|
54
54
|
}) => /*#__PURE__*/React.createElement(PopoverContainerCloseIcon, {
|
|
55
55
|
"data-element": dataElement,
|
|
56
56
|
tabIndex: tabIndex,
|
|
57
|
-
|
|
57
|
+
onClick: onClick,
|
|
58
58
|
ref: ref,
|
|
59
59
|
"aria-label": ariaLabel
|
|
60
60
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -58,7 +58,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
58
58
|
if (!onCancel) return null;
|
|
59
59
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
60
60
|
"aria-label": locale.sidebar.ariaLabels.close(),
|
|
61
|
-
|
|
61
|
+
onClick: onCancel,
|
|
62
62
|
"data-element": "close"
|
|
63
63
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
64
64
|
type: "close"
|
|
@@ -82,7 +82,7 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
82
82
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
83
83
|
"aria-label": locale.toast.ariaLabels.close(),
|
|
84
84
|
"data-element": "close",
|
|
85
|
-
|
|
85
|
+
onClick: onDismiss,
|
|
86
86
|
ref: closeIconRef
|
|
87
87
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
88
88
|
type: "close"
|
|
@@ -51,7 +51,7 @@ const VerticalMenuFullScreen = ({
|
|
|
51
51
|
boxSizing: "border-box"
|
|
52
52
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
53
53
|
"aria-label": l.verticalMenuFullScreen.ariaLabels.close(),
|
|
54
|
-
|
|
54
|
+
onClick: onClose,
|
|
55
55
|
"data-element": "close"
|
|
56
56
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
57
57
|
type: "close",
|
|
@@ -144,7 +144,7 @@ const Dialog = ({
|
|
|
144
144
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
145
145
|
"data-element": "close",
|
|
146
146
|
"aria-label": locale.dialog.ariaLabels.close(),
|
|
147
|
-
|
|
147
|
+
onClick: onCancel,
|
|
148
148
|
disabled: disableClose
|
|
149
149
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
150
150
|
type: "close"
|
|
@@ -84,7 +84,7 @@ const DialogFullScreen = ({
|
|
|
84
84
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
85
85
|
"data-element": "close",
|
|
86
86
|
"aria-label": locale.dialogFullScreen.ariaLabels.close(),
|
|
87
|
-
|
|
87
|
+
onClick: onCancel
|
|
88
88
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
89
89
|
type: "close"
|
|
90
90
|
}));
|
|
@@ -29,7 +29,7 @@ const DismissibleBox = ({
|
|
|
29
29
|
}, rest), children, /*#__PURE__*/_react.default.createElement("span", {
|
|
30
30
|
"data-element": "close-button-wrapper"
|
|
31
31
|
}, /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
32
|
-
|
|
32
|
+
onClick: onClose,
|
|
33
33
|
"aria-label": "close-button",
|
|
34
34
|
ml: 3
|
|
35
35
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
@@ -14,10 +14,12 @@ export interface IconButtonProps extends SpaceProps {
|
|
|
14
14
|
onMouseEnter?: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
15
15
|
/** Callback triggered on mouse leave */
|
|
16
16
|
onMouseLeave?: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
17
|
-
/** Action callback */
|
|
18
|
-
onAction
|
|
17
|
+
/** [DEPRECATED - use `onClick` instead] Action callback */
|
|
18
|
+
onAction?: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
19
19
|
/** Set the button to disabled */
|
|
20
20
|
disabled?: boolean;
|
|
21
|
+
/** Callback triggered on click */
|
|
22
|
+
onClick?: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
21
23
|
}
|
|
22
24
|
declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
23
25
|
export default IconButton;
|
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
13
|
+
|
|
12
14
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
13
15
|
|
|
14
16
|
var _iconButton = _interopRequireDefault(require("./icon-button.style"));
|
|
@@ -17,6 +19,8 @@ var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
|
17
19
|
|
|
18
20
|
var _buttonBar = require("../button-bar/button-bar.component");
|
|
19
21
|
|
|
22
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
23
|
+
|
|
20
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
25
|
|
|
22
26
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -25,15 +29,25 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
25
29
|
|
|
26
30
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
27
31
|
|
|
32
|
+
let onActionButtonWarnTriggered = false;
|
|
33
|
+
|
|
28
34
|
const IconButton = /*#__PURE__*/_react.default.forwardRef(({
|
|
29
35
|
"aria-label": ariaLabel,
|
|
30
36
|
onAction,
|
|
37
|
+
onClick,
|
|
31
38
|
children,
|
|
32
39
|
disabled,
|
|
33
40
|
...rest
|
|
34
41
|
}, ref) => {
|
|
35
42
|
var _internalRef$querySel;
|
|
36
43
|
|
|
44
|
+
if (!onActionButtonWarnTriggered && onAction) {
|
|
45
|
+
onActionButtonWarnTriggered = true;
|
|
46
|
+
|
|
47
|
+
_logger.default.deprecate("The `onAction` callback for the `IconButton` component is deprecated and will soon be removed. Please use `onClick` instead");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
!!(onClick && onAction) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "onClick and onAction have both been set, please use onClick as onAction will soon be deprecated") : (0, _invariant.default)(false) : void 0;
|
|
37
51
|
const [internalRef, setInternalRef] = (0, _react.useState)();
|
|
38
52
|
const context = (0, _react.useContext)(_buttonBar.ButtonBarContext);
|
|
39
53
|
const ariaLabelValue = Object.keys(context).length ? ariaLabel || (internalRef === null || internalRef === void 0 ? void 0 : (_internalRef$querySel = internalRef.querySelector("[data-component='icon']")) === null || _internalRef$querySel === void 0 ? void 0 : _internalRef$querySel.getAttribute("type")) || undefined : ariaLabel;
|
|
@@ -41,14 +55,14 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
41
55
|
const handleKeyDown = e => {
|
|
42
56
|
if (_events.default.isEnterKey(e) || _events.default.isSpaceKey(e)) {
|
|
43
57
|
e.preventDefault();
|
|
44
|
-
onAction(e);
|
|
45
|
-
|
|
46
|
-
e.stopPropagation();
|
|
58
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(e);
|
|
59
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
47
60
|
}
|
|
48
61
|
};
|
|
49
62
|
|
|
50
63
|
const handleOnClick = e => {
|
|
51
|
-
onAction(e);
|
|
64
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(e);
|
|
65
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
52
66
|
};
|
|
53
67
|
|
|
54
68
|
const setRefs = (0, _react.useCallback)(reference => {
|
|
@@ -230,8 +244,9 @@ IconButton.propTypes = {
|
|
|
230
244
|
"toString": _propTypes.default.func.isRequired,
|
|
231
245
|
"valueOf": _propTypes.default.func.isRequired
|
|
232
246
|
}), _propTypes.default.string]),
|
|
233
|
-
"onAction": _propTypes.default.func
|
|
247
|
+
"onAction": _propTypes.default.func,
|
|
234
248
|
"onBlur": _propTypes.default.func,
|
|
249
|
+
"onClick": _propTypes.default.func,
|
|
235
250
|
"onFocus": _propTypes.default.func,
|
|
236
251
|
"onMouseEnter": _propTypes.default.func,
|
|
237
252
|
"onMouseLeave": _propTypes.default.func,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { StyledImageProps } from "./image.style";
|
|
3
3
|
export declare const Image: {
|
|
4
|
-
({ alt, src, children, ...rest }: StyledImageProps): JSX.Element;
|
|
4
|
+
({ alt, decorative, src, children, ...rest }: StyledImageProps): JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
export default Image;
|
|
@@ -19,14 +19,16 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
19
19
|
|
|
20
20
|
const Image = ({
|
|
21
21
|
alt,
|
|
22
|
+
decorative = false,
|
|
22
23
|
src,
|
|
23
24
|
children,
|
|
24
25
|
...rest
|
|
25
26
|
}) => {
|
|
26
27
|
!(!src || !children) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "The 'Image' component renders as an 'img' element when the 'src' prop is used and therefore does not accept children.") : (0, _invariant.default)(false) : void 0;
|
|
27
|
-
!(!src || alt && typeof alt === "string") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Please provide an 'alt' string when rendering the 'Image' component as an 'img' element.") : (0, _invariant.default)(false) : void 0;
|
|
28
|
+
!(!src || alt && typeof alt === "string" || decorative) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Please use the 'decorative' prop if the 'alt' text should be an empty value or provide an 'alt' string when rendering the 'Image' component as an 'img' element.") : (0, _invariant.default)(false) : void 0;
|
|
28
29
|
return /*#__PURE__*/_react.default.createElement(_image.StyledImage, _extends({
|
|
29
30
|
alt: alt,
|
|
31
|
+
decorative: decorative,
|
|
30
32
|
src: src
|
|
31
33
|
}, rest), children);
|
|
32
34
|
};
|
|
@@ -540,6 +542,7 @@ Image.propTypes = {
|
|
|
540
542
|
"valueOf": _propTypes.default.func.isRequired
|
|
541
543
|
}), _propTypes.default.string]),
|
|
542
544
|
"children": _propTypes.default.node,
|
|
545
|
+
"decorative": _propTypes.default.bool,
|
|
543
546
|
"display": _propTypes.default.oneOfType([_propTypes.default.oneOf(["-moz-initial", "-ms-flexbox", "-ms-grid", "-ms-inline-flexbox", "-ms-inline-grid", "-webkit-flex", "-webkit-inline-flex", "block", "contents", "flex", "flow-root", "flow", "grid", "inherit", "initial", "inline-block", "inline-flex", "inline-grid", "inline-list-item", "inline-table", "inline", "list-item", "none", "revert", "ruby-base-container", "ruby-base", "ruby-text-container", "ruby-text", "ruby", "run-in", "table-caption", "table-cell", "table-column-group", "table-column", "table-footer-group", "table-header-group", "table-row-group", "table-row", "table", "unset"]), _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf(["-moz-initial", "-ms-flexbox", "-ms-grid", "-ms-inline-flexbox", "-ms-inline-grid", "-webkit-flex", "-webkit-inline-flex", "block", "contents", "flex", "flow-root", "flow", "grid", "inherit", "initial", "inline-block", "inline-flex", "inline-grid", "inline-list-item", "inline-table", "inline", "list-item", "none", "revert", "ruby-base-container", "ruby-base", "ruby-text-container", "ruby-text", "ruby", "run-in", "table-caption", "table-cell", "table-column-group", "table-column", "table-footer-group", "table-header-group", "table-row-group", "table-row", "table", "unset", null]), _propTypes.default.shape({
|
|
544
547
|
"__@iterator": _propTypes.default.func.isRequired,
|
|
545
548
|
"anchor": _propTypes.default.func.isRequired,
|
|
@@ -3,6 +3,8 @@ import { MarginProps, BackgroundProps, LayoutProps } from "styled-system";
|
|
|
3
3
|
export interface StyledImageProps extends MarginProps, BackgroundProps, LayoutProps {
|
|
4
4
|
/** HTML alt property to display when an img fails to load */
|
|
5
5
|
alt?: string;
|
|
6
|
+
/** Prop to specify if the image is decorative */
|
|
7
|
+
decorative?: boolean;
|
|
6
8
|
/** Any valid file path, passing this will render the component as an img element */
|
|
7
9
|
src?: string;
|
|
8
10
|
/** HTML hidden property to indicate whether to remain hidden visually and from screen readers */
|
|
@@ -72,7 +72,7 @@ const LinkPreview = ({
|
|
|
72
72
|
lines: 4
|
|
73
73
|
}, /*#__PURE__*/_react.default.createElement(_linkPreview.StyledTitle, null, title), /*#__PURE__*/_react.default.createElement(_linkPreview.StyledDescription, null, /*#__PURE__*/_react.default.createElement("div", null, description)), /*#__PURE__*/_react.default.createElement(_linkPreview.StyledUrl, null, displayUrl()))), onClose && as === "div" && /*#__PURE__*/_react.default.createElement(_linkPreview.StyledCloseIconWrapper, null, /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
74
74
|
"aria-label": "link preview close button",
|
|
75
|
-
|
|
75
|
+
onClick: () => onClose(url)
|
|
76
76
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
77
77
|
type: "close"
|
|
78
78
|
}))));
|
|
@@ -87,7 +87,7 @@ const MenuFullscreen = ({
|
|
|
87
87
|
startPosition: startPosition
|
|
88
88
|
}, /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
89
89
|
"aria-label": "menu fullscreen close button",
|
|
90
|
-
|
|
90
|
+
onClick: onClose,
|
|
91
91
|
"data-element": "close"
|
|
92
92
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
93
93
|
type: "close",
|
|
@@ -50,7 +50,7 @@ const Message = ({
|
|
|
50
50
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
51
51
|
"data-element": "close",
|
|
52
52
|
"aria-label": closeButtonAriaLabel || l.message.closeButtonAriaLabel(),
|
|
53
|
-
|
|
53
|
+
onClick: onDismiss
|
|
54
54
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
55
55
|
type: "close"
|
|
56
56
|
}));
|
|
@@ -46,7 +46,7 @@ const Pill = ({
|
|
|
46
46
|
maxWidth: maxWidth,
|
|
47
47
|
wrapText: wrapText
|
|
48
48
|
}, rest), children, onDelete && /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
49
|
-
|
|
49
|
+
onClick: onDelete,
|
|
50
50
|
"data-element": "close",
|
|
51
51
|
"aria-label": ariaLabelOfRemoveButton
|
|
52
52
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
@@ -145,7 +145,7 @@ const Pod = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
145
145
|
noBorder: !border,
|
|
146
146
|
size: size,
|
|
147
147
|
variant: variant,
|
|
148
|
-
|
|
148
|
+
onClick: processPodAction(onUndo)
|
|
149
149
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
150
150
|
type: "undo"
|
|
151
151
|
})), !softDelete && onEdit && /*#__PURE__*/_react.default.createElement(_pod.StyledEditAction, _extends({}, editEvents, {
|
|
@@ -175,7 +175,7 @@ const Pod = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
175
175
|
noBorder: !border,
|
|
176
176
|
size: size,
|
|
177
177
|
variant: variant,
|
|
178
|
-
|
|
178
|
+
onClick: processPodAction(onDelete)
|
|
179
179
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
180
180
|
type: "delete"
|
|
181
181
|
}))));
|
|
@@ -44,7 +44,7 @@ const renderOpen = ({
|
|
|
44
44
|
"aria-haspopup": ariaHasPopup
|
|
45
45
|
}) => /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerOpenIcon, {
|
|
46
46
|
tabIndex: tabIndex,
|
|
47
|
-
|
|
47
|
+
onClick: onClick,
|
|
48
48
|
"data-element": dataElement,
|
|
49
49
|
ref: ref,
|
|
50
50
|
"aria-label": ariaLabel,
|
|
@@ -76,7 +76,7 @@ const renderClose = ({
|
|
|
76
76
|
}) => /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerCloseIcon, {
|
|
77
77
|
"data-element": dataElement,
|
|
78
78
|
tabIndex: tabIndex,
|
|
79
|
-
|
|
79
|
+
onClick: onClick,
|
|
80
80
|
ref: ref,
|
|
81
81
|
"aria-label": ariaLabel
|
|
82
82
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
@@ -87,7 +87,7 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
87
87
|
if (!onCancel) return null;
|
|
88
88
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
89
89
|
"aria-label": locale.sidebar.ariaLabels.close(),
|
|
90
|
-
|
|
90
|
+
onClick: onCancel,
|
|
91
91
|
"data-element": "close"
|
|
92
92
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
93
93
|
type: "close"
|
|
@@ -105,7 +105,7 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
105
105
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
106
106
|
"aria-label": locale.toast.ariaLabels.close(),
|
|
107
107
|
"data-element": "close",
|
|
108
|
-
|
|
108
|
+
onClick: onDismiss,
|
|
109
109
|
ref: closeIconRef
|
|
110
110
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
111
111
|
type: "close"
|
|
@@ -75,7 +75,7 @@ const VerticalMenuFullScreen = ({
|
|
|
75
75
|
boxSizing: "border-box"
|
|
76
76
|
}, /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
77
77
|
"aria-label": l.verticalMenuFullScreen.ariaLabels.close(),
|
|
78
|
-
|
|
78
|
+
onClick: onClose,
|
|
79
79
|
"data-element": "close"
|
|
80
80
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
81
81
|
type: "close",
|