carbon-react 140.2.0 → 141.0.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/__internal__/input/input-presentation.component.js +2 -1
- package/esm/components/date/date.style.d.ts +2 -1
- package/esm/components/date/date.style.js +3 -3
- package/esm/components/date-range/date-range.component.d.ts +2 -2
- package/esm/components/icon-button/icon-button.component.d.ts +0 -2
- package/esm/components/icon-button/icon-button.component.js +1 -16
- package/esm/components/link/link.component.js +6 -1
- package/esm/components/menu/menu.component.d.ts +1 -2
- package/esm/components/menu/menu.component.js +0 -1
- package/esm/components/sidebar/sidebar.component.d.ts +1 -1
- package/esm/components/sidebar/sidebar.component.js +8 -9
- package/lib/__internal__/input/input-presentation.component.js +2 -1
- package/lib/components/date/date.style.d.ts +2 -1
- package/lib/components/date/date.style.js +3 -3
- package/lib/components/date-range/date-range.component.d.ts +2 -2
- package/lib/components/icon-button/icon-button.component.d.ts +0 -2
- package/lib/components/icon-button/icon-button.component.js +1 -16
- package/lib/components/link/link.component.js +5 -0
- package/lib/components/menu/menu.component.d.ts +1 -2
- package/lib/components/menu/menu.component.js +1 -8
- package/lib/components/sidebar/sidebar.component.d.ts +1 -1
- package/lib/components/sidebar/sidebar.component.js +8 -9
- package/package.json +1 -1
|
@@ -43,7 +43,8 @@ const InputPresentation = ({
|
|
|
43
43
|
};
|
|
44
44
|
return /*#__PURE__*/React.createElement(StyledInputPresentationContainer, {
|
|
45
45
|
inputWidth: inputWidth,
|
|
46
|
-
maxWidth: maxWidth
|
|
46
|
+
maxWidth: maxWidth,
|
|
47
|
+
"data-role": "input-presentation-container"
|
|
47
48
|
}, positionedChildren, /*#__PURE__*/React.createElement(InputPresentationStyle, {
|
|
48
49
|
hasFocus: hasFocus,
|
|
49
50
|
role: "presentation",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DateInputProps } from "./date.component";
|
|
2
|
-
interface StyledDateInputProps extends Pick<DateInputProps, "inputWidth" | "
|
|
2
|
+
interface StyledDateInputProps extends Pick<DateInputProps, "inputWidth" | "maxWidth" | "labelInline"> {
|
|
3
3
|
applyDateRangeStyling?: boolean;
|
|
4
|
+
size: Required<DateInputProps>["size"];
|
|
4
5
|
}
|
|
5
6
|
declare const StyledDateInput: import("styled-components").StyledComponent<"div", any, StyledDateInputProps, never>;
|
|
6
7
|
export default StyledDateInput;
|
|
@@ -19,7 +19,7 @@ const StyledDateInput = styled.div`
|
|
|
19
19
|
width: ${({
|
|
20
20
|
inputWidth,
|
|
21
21
|
maxWidth,
|
|
22
|
-
size
|
|
22
|
+
size
|
|
23
23
|
}) => maxWidth || inputWidth ? "" : datePickerWidth[size]};
|
|
24
24
|
|
|
25
25
|
${StyledInput} {
|
|
@@ -30,11 +30,11 @@ const StyledDateInput = styled.div`
|
|
|
30
30
|
${({
|
|
31
31
|
applyDateRangeStyling,
|
|
32
32
|
maxWidth,
|
|
33
|
-
size
|
|
33
|
+
size,
|
|
34
34
|
labelInline
|
|
35
35
|
}) => applyDateRangeStyling && !labelInline && css`
|
|
36
36
|
${FieldLineStyle} {
|
|
37
|
-
max-width: ${maxWidth || datePickerWidth[size]}
|
|
37
|
+
max-width: ${maxWidth || datePickerWidth[size]};
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
${StyledValidationMessage}, ${StyledLabel} {
|
|
@@ -16,7 +16,7 @@ export interface DateRangeChangeEvent {
|
|
|
16
16
|
}
|
|
17
17
|
export interface DateRangeProps extends StyledDateRangeProps, MarginProps, TagProps {
|
|
18
18
|
/** Props for the child end Date component */
|
|
19
|
-
endDateProps?: Partial<DateInputProps>;
|
|
19
|
+
endDateProps?: Omit<Partial<DateInputProps>, "required">;
|
|
20
20
|
/** Optional label for endDate field */
|
|
21
21
|
endLabel?: string;
|
|
22
22
|
/**
|
|
@@ -50,7 +50,7 @@ export interface DateRangeProps extends StyledDateRangeProps, MarginProps, TagPr
|
|
|
50
50
|
/** Specify a callback triggered on blur */
|
|
51
51
|
onBlur?: (ev: DateRangeChangeEvent) => void;
|
|
52
52
|
/** Props for the child start Date component */
|
|
53
|
-
startDateProps?: Partial<DateInputProps>;
|
|
53
|
+
startDateProps?: Omit<Partial<DateInputProps>, "required">;
|
|
54
54
|
/** Optional label for startDate field */
|
|
55
55
|
startLabel?: string;
|
|
56
56
|
/**
|
|
@@ -14,8 +14,6 @@ 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
|
-
/** [DEPRECATED - use `onClick` instead] Action callback */
|
|
18
|
-
onAction?: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
19
17
|
/** Set the button to disabled */
|
|
20
18
|
disabled?: boolean;
|
|
21
19
|
/** Callback triggered on click */
|
|
@@ -1,38 +1,24 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
2
2
|
import React, { useState, useCallback } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import invariant from "invariant";
|
|
5
4
|
import Events from "../../__internal__/utils/helpers/events";
|
|
6
5
|
import StyledIconButton from "./icon-button.style";
|
|
7
6
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
8
|
-
import Logger from "../../__internal__/utils/logger";
|
|
9
|
-
let onActionButtonWarnTriggered = false;
|
|
10
7
|
const IconButton = /*#__PURE__*/React.forwardRef(({
|
|
11
8
|
"aria-label": ariaLabel,
|
|
12
|
-
onAction,
|
|
13
9
|
onClick,
|
|
14
10
|
children,
|
|
15
11
|
disabled,
|
|
16
12
|
...rest
|
|
17
13
|
}, ref) => {
|
|
18
|
-
if (!onActionButtonWarnTriggered && onAction) {
|
|
19
|
-
onActionButtonWarnTriggered = true;
|
|
20
|
-
Logger.deprecate("The `onAction` callback for the `IconButton` component is deprecated and will soon be removed. Please use `onClick` instead");
|
|
21
|
-
}
|
|
22
|
-
!!(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;
|
|
23
14
|
const [internalRef, setInternalRef] = useState();
|
|
24
15
|
const ariaLabelValue = ariaLabel || internalRef?.querySelector("[data-component='icon']")?.getAttribute("type") || "";
|
|
25
16
|
const handleKeyDown = e => {
|
|
26
17
|
if (Events.isEnterKey(e) || Events.isSpaceKey(e)) {
|
|
27
18
|
e.preventDefault();
|
|
28
|
-
onAction?.(e);
|
|
29
19
|
onClick?.(e);
|
|
30
20
|
}
|
|
31
21
|
};
|
|
32
|
-
const handleOnClick = e => {
|
|
33
|
-
onAction?.(e);
|
|
34
|
-
onClick?.(e);
|
|
35
|
-
};
|
|
36
22
|
const setRefs = useCallback(reference => {
|
|
37
23
|
setInternalRef(reference);
|
|
38
24
|
if (!ref) return;
|
|
@@ -44,7 +30,7 @@ const IconButton = /*#__PURE__*/React.forwardRef(({
|
|
|
44
30
|
}, rest, {
|
|
45
31
|
"aria-label": ariaLabelValue,
|
|
46
32
|
onKeyDown: handleKeyDown,
|
|
47
|
-
onClick:
|
|
33
|
+
onClick: onClick,
|
|
48
34
|
ref: setRefs,
|
|
49
35
|
disabled: disabled
|
|
50
36
|
}), /*#__PURE__*/React.createElement(TooltipProvider, {
|
|
@@ -212,7 +198,6 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
212
198
|
"toString": PropTypes.func.isRequired,
|
|
213
199
|
"valueOf": PropTypes.func.isRequired
|
|
214
200
|
}), PropTypes.string]),
|
|
215
|
-
"onAction": PropTypes.func,
|
|
216
201
|
"onBlur": PropTypes.func,
|
|
217
202
|
"onClick": PropTypes.func,
|
|
218
203
|
"onFocus": PropTypes.func,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
2
|
-
import React, { useContext, useMemo, useState } from "react";
|
|
2
|
+
import React, { useContext, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import Icon from "../icon";
|
|
5
5
|
import MenuContext from "../menu/__internal__/menu.context";
|
|
@@ -83,6 +83,11 @@ const Link = /*#__PURE__*/React.forwardRef(({
|
|
|
83
83
|
"data-role": "link-anchor"
|
|
84
84
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, renderLinkIcon(), /*#__PURE__*/React.createElement(StyledContent, null, isSkipLink ? l.link.skipLinkLabel() : children), renderLinkIcon("right")));
|
|
85
85
|
};
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (disabled || !(href || onClick)) {
|
|
88
|
+
setHasFocus(false);
|
|
89
|
+
}
|
|
90
|
+
}, [disabled, href, onClick]);
|
|
86
91
|
return /*#__PURE__*/React.createElement(StyledLink, _extends({
|
|
87
92
|
isSkipLink: isSkipLink,
|
|
88
93
|
disabled: disabled,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { LayoutProps, FlexboxProps } from "styled-system";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
-
import
|
|
4
|
+
import { MenuType } from "./__internal__/menu.context";
|
|
5
5
|
export interface MenuProps extends TagProps, LayoutProps, FlexboxProps {
|
|
6
6
|
/** Children elements */
|
|
7
7
|
children: React.ReactNode;
|
|
@@ -9,5 +9,4 @@ export interface MenuProps extends TagProps, LayoutProps, FlexboxProps {
|
|
|
9
9
|
menuType?: MenuType;
|
|
10
10
|
}
|
|
11
11
|
export declare const Menu: ({ menuType, children, ...rest }: MenuProps) => React.JSX.Element;
|
|
12
|
-
export { MenuContext };
|
|
13
12
|
export default Menu;
|
|
@@ -5,7 +5,7 @@ import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
|
5
5
|
declare type CustomRefObject<T> = {
|
|
6
6
|
current?: T | null;
|
|
7
7
|
};
|
|
8
|
-
export interface SidebarProps extends PaddingProps, TagProps, WidthProps, Pick<ModalProps, "topModalOverride"> {
|
|
8
|
+
export interface SidebarProps extends PaddingProps, Omit<TagProps, "data-component">, WidthProps, Pick<ModalProps, "topModalOverride"> {
|
|
9
9
|
/** Prop to specify the aria-describedby property of the component */
|
|
10
10
|
"aria-describedby"?: string;
|
|
11
11
|
/**
|
|
@@ -20,6 +20,8 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
20
20
|
"aria-describedby": ariaDescribedBy,
|
|
21
21
|
"aria-label": ariaLabel,
|
|
22
22
|
"aria-labelledby": ariaLabelledBy,
|
|
23
|
+
"data-element": dataElement = "sidebar",
|
|
24
|
+
"data-role": dataRole,
|
|
23
25
|
open,
|
|
24
26
|
bespokeFocusTrap,
|
|
25
27
|
disableAutoFocus = false,
|
|
@@ -62,20 +64,17 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
62
64
|
type: "close"
|
|
63
65
|
}));
|
|
64
66
|
};
|
|
65
|
-
const componentTags = {
|
|
66
|
-
"data-component": "sidebar",
|
|
67
|
-
"data-element": rest["data-element"],
|
|
68
|
-
"data-role": rest["data-role"]
|
|
69
|
-
};
|
|
70
67
|
const sidebar = /*#__PURE__*/React.createElement(StyledSidebar, _extends({
|
|
71
68
|
"aria-modal": !enableBackgroundUI && isTopModal,
|
|
72
69
|
"aria-describedby": ariaDescribedBy,
|
|
73
70
|
"aria-label": ariaLabel,
|
|
74
71
|
"aria-labelledby": !ariaLabelledBy && !ariaLabel ? headerId : ariaLabelledBy,
|
|
72
|
+
"data-component": "sidebar",
|
|
73
|
+
"data-element": dataElement,
|
|
74
|
+
"data-role": dataRole,
|
|
75
75
|
ref: setRefs,
|
|
76
76
|
position: position,
|
|
77
77
|
size: size,
|
|
78
|
-
"data-element": "sidebar",
|
|
79
78
|
onCancel: onCancel,
|
|
80
79
|
role: role
|
|
81
80
|
}, filterStyledSystemPaddingProps(rest), {
|
|
@@ -86,6 +85,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
86
85
|
id: headerId
|
|
87
86
|
}), header), !header && closeIcon(), /*#__PURE__*/React.createElement(Box, _extends({
|
|
88
87
|
"data-element": "sidebar-content",
|
|
88
|
+
"data-role": "sidebar-content",
|
|
89
89
|
pt: "var(--spacing300)",
|
|
90
90
|
pb: "var(--spacing400)",
|
|
91
91
|
px: "var(--spacing400)"
|
|
@@ -98,13 +98,13 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
98
98
|
isInSidebar: true
|
|
99
99
|
}
|
|
100
100
|
}, children)));
|
|
101
|
-
return /*#__PURE__*/React.createElement(Modal,
|
|
101
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
102
102
|
open: open,
|
|
103
103
|
onCancel: onCancel,
|
|
104
104
|
disableEscKey: disableEscKey,
|
|
105
105
|
enableBackgroundUI: enableBackgroundUI,
|
|
106
106
|
topModalOverride: topModalOverride
|
|
107
|
-
},
|
|
107
|
+
}, enableBackgroundUI ? sidebar : /*#__PURE__*/React.createElement(FocusTrap, {
|
|
108
108
|
wrapperRef: sidebarRef,
|
|
109
109
|
isOpen: open,
|
|
110
110
|
additionalWrapperRefs: focusableContainers,
|
|
@@ -121,7 +121,6 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
121
121
|
"aria-labelledby": PropTypes.string,
|
|
122
122
|
"bespokeFocusTrap": PropTypes.func,
|
|
123
123
|
"children": PropTypes.node,
|
|
124
|
-
"data-component": PropTypes.string,
|
|
125
124
|
"data-element": PropTypes.string,
|
|
126
125
|
"data-role": PropTypes.string,
|
|
127
126
|
"disableAutoFocus": PropTypes.bool,
|
|
@@ -52,7 +52,8 @@ const InputPresentation = ({
|
|
|
52
52
|
};
|
|
53
53
|
return /*#__PURE__*/_react.default.createElement(_inputPresentation.StyledInputPresentationContainer, {
|
|
54
54
|
inputWidth: inputWidth,
|
|
55
|
-
maxWidth: maxWidth
|
|
55
|
+
maxWidth: maxWidth,
|
|
56
|
+
"data-role": "input-presentation-container"
|
|
56
57
|
}, positionedChildren, /*#__PURE__*/_react.default.createElement(_inputPresentation.default, {
|
|
57
58
|
hasFocus: hasFocus,
|
|
58
59
|
role: "presentation",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DateInputProps } from "./date.component";
|
|
2
|
-
interface StyledDateInputProps extends Pick<DateInputProps, "inputWidth" | "
|
|
2
|
+
interface StyledDateInputProps extends Pick<DateInputProps, "inputWidth" | "maxWidth" | "labelInline"> {
|
|
3
3
|
applyDateRangeStyling?: boolean;
|
|
4
|
+
size: Required<DateInputProps>["size"];
|
|
4
5
|
}
|
|
5
6
|
declare const StyledDateInput: import("styled-components").StyledComponent<"div", any, StyledDateInputProps, never>;
|
|
6
7
|
export default StyledDateInput;
|
|
@@ -28,7 +28,7 @@ const StyledDateInput = _styledComponents.default.div`
|
|
|
28
28
|
width: ${({
|
|
29
29
|
inputWidth,
|
|
30
30
|
maxWidth,
|
|
31
|
-
size
|
|
31
|
+
size
|
|
32
32
|
}) => maxWidth || inputWidth ? "" : datePickerWidth[size]};
|
|
33
33
|
|
|
34
34
|
${_input.default} {
|
|
@@ -39,11 +39,11 @@ const StyledDateInput = _styledComponents.default.div`
|
|
|
39
39
|
${({
|
|
40
40
|
applyDateRangeStyling,
|
|
41
41
|
maxWidth,
|
|
42
|
-
size
|
|
42
|
+
size,
|
|
43
43
|
labelInline
|
|
44
44
|
}) => applyDateRangeStyling && !labelInline && (0, _styledComponents.css)`
|
|
45
45
|
${_formField.FieldLineStyle} {
|
|
46
|
-
max-width: ${maxWidth || datePickerWidth[size]}
|
|
46
|
+
max-width: ${maxWidth || datePickerWidth[size]};
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
${_validationMessage.default}, ${_label.default} {
|
|
@@ -16,7 +16,7 @@ export interface DateRangeChangeEvent {
|
|
|
16
16
|
}
|
|
17
17
|
export interface DateRangeProps extends StyledDateRangeProps, MarginProps, TagProps {
|
|
18
18
|
/** Props for the child end Date component */
|
|
19
|
-
endDateProps?: Partial<DateInputProps>;
|
|
19
|
+
endDateProps?: Omit<Partial<DateInputProps>, "required">;
|
|
20
20
|
/** Optional label for endDate field */
|
|
21
21
|
endLabel?: string;
|
|
22
22
|
/**
|
|
@@ -50,7 +50,7 @@ export interface DateRangeProps extends StyledDateRangeProps, MarginProps, TagPr
|
|
|
50
50
|
/** Specify a callback triggered on blur */
|
|
51
51
|
onBlur?: (ev: DateRangeChangeEvent) => void;
|
|
52
52
|
/** Props for the child start Date component */
|
|
53
|
-
startDateProps?: Partial<DateInputProps>;
|
|
53
|
+
startDateProps?: Omit<Partial<DateInputProps>, "required">;
|
|
54
54
|
/** Optional label for startDate field */
|
|
55
55
|
startLabel?: string;
|
|
56
56
|
/**
|
|
@@ -14,8 +14,6 @@ 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
|
-
/** [DEPRECATED - use `onClick` instead] Action callback */
|
|
18
|
-
onAction?: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
19
17
|
/** Set the button to disabled */
|
|
20
18
|
disabled?: boolean;
|
|
21
19
|
/** Callback triggered on click */
|
|
@@ -6,42 +6,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _invariant = _interopRequireDefault(require("invariant"));
|
|
10
9
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
11
10
|
var _iconButton = _interopRequireDefault(require("./icon-button.style"));
|
|
12
11
|
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
13
|
-
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
15
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
18
|
-
let onActionButtonWarnTriggered = false;
|
|
19
16
|
const IconButton = /*#__PURE__*/_react.default.forwardRef(({
|
|
20
17
|
"aria-label": ariaLabel,
|
|
21
|
-
onAction,
|
|
22
18
|
onClick,
|
|
23
19
|
children,
|
|
24
20
|
disabled,
|
|
25
21
|
...rest
|
|
26
22
|
}, ref) => {
|
|
27
|
-
if (!onActionButtonWarnTriggered && onAction) {
|
|
28
|
-
onActionButtonWarnTriggered = true;
|
|
29
|
-
_logger.default.deprecate("The `onAction` callback for the `IconButton` component is deprecated and will soon be removed. Please use `onClick` instead");
|
|
30
|
-
}
|
|
31
|
-
!!(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;
|
|
32
23
|
const [internalRef, setInternalRef] = (0, _react.useState)();
|
|
33
24
|
const ariaLabelValue = ariaLabel || internalRef?.querySelector("[data-component='icon']")?.getAttribute("type") || "";
|
|
34
25
|
const handleKeyDown = e => {
|
|
35
26
|
if (_events.default.isEnterKey(e) || _events.default.isSpaceKey(e)) {
|
|
36
27
|
e.preventDefault();
|
|
37
|
-
onAction?.(e);
|
|
38
28
|
onClick?.(e);
|
|
39
29
|
}
|
|
40
30
|
};
|
|
41
|
-
const handleOnClick = e => {
|
|
42
|
-
onAction?.(e);
|
|
43
|
-
onClick?.(e);
|
|
44
|
-
};
|
|
45
31
|
const setRefs = (0, _react.useCallback)(reference => {
|
|
46
32
|
setInternalRef(reference);
|
|
47
33
|
if (!ref) return;
|
|
@@ -53,7 +39,7 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
53
39
|
}, rest, {
|
|
54
40
|
"aria-label": ariaLabelValue,
|
|
55
41
|
onKeyDown: handleKeyDown,
|
|
56
|
-
onClick:
|
|
42
|
+
onClick: onClick,
|
|
57
43
|
ref: setRefs,
|
|
58
44
|
disabled: disabled
|
|
59
45
|
}), /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
@@ -221,7 +207,6 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
221
207
|
"toString": _propTypes.default.func.isRequired,
|
|
222
208
|
"valueOf": _propTypes.default.func.isRequired
|
|
223
209
|
}), _propTypes.default.string]),
|
|
224
|
-
"onAction": _propTypes.default.func,
|
|
225
210
|
"onBlur": _propTypes.default.func,
|
|
226
211
|
"onClick": _propTypes.default.func,
|
|
227
212
|
"onFocus": _propTypes.default.func,
|
|
@@ -92,6 +92,11 @@ const Link = exports.Link = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
92
92
|
"data-role": "link-anchor"
|
|
93
93
|
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderLinkIcon(), /*#__PURE__*/_react.default.createElement(_link.StyledContent, null, isSkipLink ? l.link.skipLinkLabel() : children), renderLinkIcon("right")));
|
|
94
94
|
};
|
|
95
|
+
(0, _react.useEffect)(() => {
|
|
96
|
+
if (disabled || !(href || onClick)) {
|
|
97
|
+
setHasFocus(false);
|
|
98
|
+
}
|
|
99
|
+
}, [disabled, href, onClick]);
|
|
95
100
|
return /*#__PURE__*/_react.default.createElement(_link.StyledLink, _extends({
|
|
96
101
|
isSkipLink: isSkipLink,
|
|
97
102
|
disabled: disabled,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { LayoutProps, FlexboxProps } from "styled-system";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
-
import
|
|
4
|
+
import { MenuType } from "./__internal__/menu.context";
|
|
5
5
|
export interface MenuProps extends TagProps, LayoutProps, FlexboxProps {
|
|
6
6
|
/** Children elements */
|
|
7
7
|
children: React.ReactNode;
|
|
@@ -9,5 +9,4 @@ export interface MenuProps extends TagProps, LayoutProps, FlexboxProps {
|
|
|
9
9
|
menuType?: MenuType;
|
|
10
10
|
}
|
|
11
11
|
export declare const Menu: ({ menuType, children, ...rest }: MenuProps) => React.JSX.Element;
|
|
12
|
-
export { MenuContext };
|
|
13
12
|
export default Menu;
|
|
@@ -3,14 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Menu = void 0;
|
|
7
|
-
Object.defineProperty(exports, "MenuContext", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _menu2.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.Menu = void 0;
|
|
14
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
9
|
var _menu = require("./menu.style");
|
|
@@ -5,7 +5,7 @@ import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
|
5
5
|
declare type CustomRefObject<T> = {
|
|
6
6
|
current?: T | null;
|
|
7
7
|
};
|
|
8
|
-
export interface SidebarProps extends PaddingProps, TagProps, WidthProps, Pick<ModalProps, "topModalOverride"> {
|
|
8
|
+
export interface SidebarProps extends PaddingProps, Omit<TagProps, "data-component">, WidthProps, Pick<ModalProps, "topModalOverride"> {
|
|
9
9
|
/** Prop to specify the aria-describedby property of the component */
|
|
10
10
|
"aria-describedby"?: string;
|
|
11
11
|
/**
|
|
@@ -28,6 +28,8 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
28
28
|
"aria-describedby": ariaDescribedBy,
|
|
29
29
|
"aria-label": ariaLabel,
|
|
30
30
|
"aria-labelledby": ariaLabelledBy,
|
|
31
|
+
"data-element": dataElement = "sidebar",
|
|
32
|
+
"data-role": dataRole,
|
|
31
33
|
open,
|
|
32
34
|
bespokeFocusTrap,
|
|
33
35
|
disableAutoFocus = false,
|
|
@@ -70,20 +72,17 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
70
72
|
type: "close"
|
|
71
73
|
}));
|
|
72
74
|
};
|
|
73
|
-
const componentTags = {
|
|
74
|
-
"data-component": "sidebar",
|
|
75
|
-
"data-element": rest["data-element"],
|
|
76
|
-
"data-role": rest["data-role"]
|
|
77
|
-
};
|
|
78
75
|
const sidebar = /*#__PURE__*/_react.default.createElement(_sidebar.default, _extends({
|
|
79
76
|
"aria-modal": !enableBackgroundUI && isTopModal,
|
|
80
77
|
"aria-describedby": ariaDescribedBy,
|
|
81
78
|
"aria-label": ariaLabel,
|
|
82
79
|
"aria-labelledby": !ariaLabelledBy && !ariaLabel ? headerId : ariaLabelledBy,
|
|
80
|
+
"data-component": "sidebar",
|
|
81
|
+
"data-element": dataElement,
|
|
82
|
+
"data-role": dataRole,
|
|
83
83
|
ref: setRefs,
|
|
84
84
|
position: position,
|
|
85
85
|
size: size,
|
|
86
|
-
"data-element": "sidebar",
|
|
87
86
|
onCancel: onCancel,
|
|
88
87
|
role: role
|
|
89
88
|
}, (0, _utils.filterStyledSystemPaddingProps)(rest), {
|
|
@@ -94,6 +93,7 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
94
93
|
id: headerId
|
|
95
94
|
}), header), !header && closeIcon(), /*#__PURE__*/_react.default.createElement(_box.default, _extends({
|
|
96
95
|
"data-element": "sidebar-content",
|
|
96
|
+
"data-role": "sidebar-content",
|
|
97
97
|
pt: "var(--spacing300)",
|
|
98
98
|
pb: "var(--spacing400)",
|
|
99
99
|
px: "var(--spacing400)"
|
|
@@ -106,13 +106,13 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
106
106
|
isInSidebar: true
|
|
107
107
|
}
|
|
108
108
|
}, children)));
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(_modal.default,
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement(_modal.default, {
|
|
110
110
|
open: open,
|
|
111
111
|
onCancel: onCancel,
|
|
112
112
|
disableEscKey: disableEscKey,
|
|
113
113
|
enableBackgroundUI: enableBackgroundUI,
|
|
114
114
|
topModalOverride: topModalOverride
|
|
115
|
-
},
|
|
115
|
+
}, enableBackgroundUI ? sidebar : /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
|
|
116
116
|
wrapperRef: sidebarRef,
|
|
117
117
|
isOpen: open,
|
|
118
118
|
additionalWrapperRefs: focusableContainers,
|
|
@@ -129,7 +129,6 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
129
129
|
"aria-labelledby": _propTypes.default.string,
|
|
130
130
|
"bespokeFocusTrap": _propTypes.default.func,
|
|
131
131
|
"children": _propTypes.default.node,
|
|
132
|
-
"data-component": _propTypes.default.string,
|
|
133
132
|
"data-element": _propTypes.default.string,
|
|
134
133
|
"data-role": _propTypes.default.string,
|
|
135
134
|
"disableAutoFocus": _propTypes.default.bool,
|