carbon-react 104.1.1 → 104.5.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.
- package/lib/__internal__/tooltip-provider/index.d.ts +1 -0
- package/lib/__internal__/tooltip-provider/index.js +6 -3
- package/lib/components/accordion/accordion.style.js +20 -45
- package/lib/components/button/button.component.d.ts +21 -1
- package/lib/components/button/button.component.js +63 -52
- package/lib/components/confirm/confirm.component.d.ts +4 -1
- package/lib/components/confirm/confirm.component.js +32 -4
- package/lib/components/dialog/dialog.component.js +12 -9
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +20 -9
- package/lib/components/icon/icon.component.js +4 -2
- package/lib/components/icon-button/icon-button.component.js +11 -19
- package/lib/components/tile-select/tile-select.style.js +18 -49
- package/lib/components/tooltip/tooltip.component.js +4 -0
- package/lib/components/tooltip/tooltip.d.ts +1 -0
- package/package.json +1 -1
|
@@ -21,14 +21,16 @@ const TooltipProvider = ({
|
|
|
21
21
|
helpAriaLabel,
|
|
22
22
|
focusable = true,
|
|
23
23
|
tooltipVisible,
|
|
24
|
-
disabled = false
|
|
24
|
+
disabled = false,
|
|
25
|
+
target
|
|
25
26
|
}) => /*#__PURE__*/_react.default.createElement(TooltipContext.Provider, {
|
|
26
27
|
value: {
|
|
27
28
|
tooltipPosition,
|
|
28
29
|
helpAriaLabel,
|
|
29
30
|
focusable,
|
|
30
31
|
tooltipVisible,
|
|
31
|
-
disabled
|
|
32
|
+
disabled,
|
|
33
|
+
target
|
|
32
34
|
}
|
|
33
35
|
}, children);
|
|
34
36
|
|
|
@@ -39,5 +41,6 @@ TooltipProvider.propTypes = {
|
|
|
39
41
|
helpAriaLabel: _propTypes.default.string,
|
|
40
42
|
focusable: _propTypes.default.bool,
|
|
41
43
|
tooltipVisible: _propTypes.default.bool,
|
|
42
|
-
disabled: _propTypes.default.bool
|
|
44
|
+
disabled: _propTypes.default.bool,
|
|
45
|
+
target: _propTypes.default.instanceOf(Element)
|
|
43
46
|
};
|
|
@@ -37,18 +37,11 @@ const StyledAccordionContainer = _styledComponents.default.div`
|
|
|
37
37
|
width: ${({
|
|
38
38
|
width
|
|
39
39
|
}) => width || "100%"};
|
|
40
|
-
color:
|
|
41
|
-
theme
|
|
42
|
-
}) => theme.text.color};
|
|
40
|
+
color: var(--colorsUtilityYin090);
|
|
43
41
|
background-color: ${({
|
|
44
|
-
scheme
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
${({
|
|
48
|
-
theme
|
|
49
|
-
}) => (0, _styledComponents.css)`
|
|
50
|
-
border: 1px solid ${theme.accordion.border};
|
|
51
|
-
`}
|
|
42
|
+
scheme
|
|
43
|
+
}) => scheme === "white" ? "var(--colorsUtilityYang100)" : "var(--colorsUtilityMajorTransparent)"};
|
|
44
|
+
border: 1px solid var(--colorsUtilityMajor100);
|
|
52
45
|
${({
|
|
53
46
|
borders
|
|
54
47
|
}) => borders === "default" && (0, _styledComponents.css)`
|
|
@@ -63,12 +56,8 @@ const StyledAccordionContainer = _styledComponents.default.div`
|
|
|
63
56
|
|
|
64
57
|
& + & {
|
|
65
58
|
margin-top: -1px;
|
|
66
|
-
border-top: 1px solid
|
|
67
|
-
|
|
68
|
-
}) => theme.accordion.border};
|
|
69
|
-
border-bottom: 1px solid ${({
|
|
70
|
-
theme
|
|
71
|
-
}) => theme.accordion.border};
|
|
59
|
+
border-top: 1px solid var(--colorsUtilityMajor100);
|
|
60
|
+
border-bottom: 1px solid var(--colorsUtilityMajor100);
|
|
72
61
|
}
|
|
73
62
|
`;
|
|
74
63
|
exports.StyledAccordionContainer = StyledAccordionContainer;
|
|
@@ -91,15 +80,15 @@ exports.StyledAccordionSubTitle = StyledAccordionSubTitle;
|
|
|
91
80
|
const StyledAccordionIcon = (0, _styledComponents.default)(_icon.default)`
|
|
92
81
|
transition: transform 0.3s;
|
|
93
82
|
margin-right: ${({
|
|
94
|
-
iconAlign
|
|
95
|
-
|
|
96
|
-
}) => iconAlign === "left" ? theme.spacing * 2 : 0}px;
|
|
83
|
+
iconAlign
|
|
84
|
+
}) => iconAlign === "left" ? "var(--spacing200)" : "var(--spacing000)"};
|
|
97
85
|
${({
|
|
98
86
|
isExpanded,
|
|
99
87
|
iconAlign
|
|
100
88
|
}) => {
|
|
101
89
|
return !isExpanded && (iconAlign === "right" ? "transform: rotate(90deg)" : "transform: rotate(-90deg)");
|
|
102
90
|
}};
|
|
91
|
+
color: var(--colorsActionMinor500);
|
|
103
92
|
`;
|
|
104
93
|
exports.StyledAccordionIcon = StyledAccordionIcon;
|
|
105
94
|
const StyledAccordionHeadingsContainer = _styledComponents.default.div`
|
|
@@ -134,10 +123,9 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
134
123
|
buttonWidth,
|
|
135
124
|
iconAlign,
|
|
136
125
|
size,
|
|
137
|
-
theme,
|
|
138
126
|
hasButtonProps
|
|
139
127
|
}) => (0, _styledComponents.css)`
|
|
140
|
-
padding: ${size === "small" ?
|
|
128
|
+
padding: ${size === "small" ? "var(--spacing200)" : "var(--spacing300)"};
|
|
141
129
|
${_styledSystem.space}
|
|
142
130
|
display: flex;
|
|
143
131
|
align-items: center;
|
|
@@ -152,12 +140,12 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
152
140
|
z-index: 1;
|
|
153
141
|
|
|
154
142
|
&:focus {
|
|
155
|
-
outline:
|
|
143
|
+
outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
|
|
156
144
|
}
|
|
157
145
|
|
|
158
146
|
${!buttonHeading && (0, _styledComponents.css)`
|
|
159
147
|
&:hover {
|
|
160
|
-
background-color:
|
|
148
|
+
background-color: var(--colorsUtilityMajor050);
|
|
161
149
|
}
|
|
162
150
|
`}
|
|
163
151
|
|
|
@@ -165,10 +153,10 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
165
153
|
box-sizing: border-box;
|
|
166
154
|
font-weight: 600;
|
|
167
155
|
text-decoration: none;
|
|
168
|
-
font-size:
|
|
169
|
-
min-height:
|
|
156
|
+
font-size: var(--fontSizes100);
|
|
157
|
+
min-height: var(--spacing500);
|
|
170
158
|
|
|
171
|
-
color:
|
|
159
|
+
color: var(--colorsActionMajor500);
|
|
172
160
|
|
|
173
161
|
${!hasButtonProps && (0, _styledComponents.css)`
|
|
174
162
|
${StyledAccordionHeadingsContainer} {
|
|
@@ -177,7 +165,7 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
177
165
|
`}
|
|
178
166
|
|
|
179
167
|
${StyledAccordionIcon} {
|
|
180
|
-
color:
|
|
168
|
+
color: var(--colorsActionMajor500);
|
|
181
169
|
${!hasButtonProps && (0, _styledComponents.css)`
|
|
182
170
|
position: relative;
|
|
183
171
|
${iconAlign}: 16px;
|
|
@@ -185,9 +173,9 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
185
173
|
}
|
|
186
174
|
|
|
187
175
|
&:hover {
|
|
188
|
-
color:
|
|
176
|
+
color: var(--colorsActionMajor600);
|
|
189
177
|
${StyledAccordionIcon} {
|
|
190
|
-
color:
|
|
178
|
+
color: var(--colorsActionMajor600);
|
|
191
179
|
}
|
|
192
180
|
}
|
|
193
181
|
|
|
@@ -217,9 +205,8 @@ const StyledAccordionContentContainer = _styledComponents.default.div`
|
|
|
217
205
|
`;
|
|
218
206
|
exports.StyledAccordionContentContainer = StyledAccordionContentContainer;
|
|
219
207
|
const StyledAccordionContent = _styledComponents.default.div`
|
|
220
|
-
padding:
|
|
221
|
-
|
|
222
|
-
}) => theme.spacing * 3}px;
|
|
208
|
+
padding: var(--spacing300);
|
|
209
|
+
padding-top: 0;
|
|
223
210
|
overflow: hidden;
|
|
224
211
|
|
|
225
212
|
${({
|
|
@@ -237,16 +224,4 @@ StyledAccordionContainer.defaultProps = {
|
|
|
237
224
|
};
|
|
238
225
|
StyledAccordionTitleContainer.defaultProps = {
|
|
239
226
|
theme: _themes.baseTheme
|
|
240
|
-
};
|
|
241
|
-
StyledAccordionTitle.defaultProps = {
|
|
242
|
-
theme: _themes.baseTheme
|
|
243
|
-
};
|
|
244
|
-
StyledAccordionIcon.defaultProps = {
|
|
245
|
-
theme: _themes.baseTheme
|
|
246
|
-
};
|
|
247
|
-
StyledAccordionContent.defaultProps = {
|
|
248
|
-
theme: _themes.baseTheme
|
|
249
|
-
};
|
|
250
|
-
StyledAccordionContentContainer.defaultProps = {
|
|
251
|
-
theme: _themes.baseTheme
|
|
252
227
|
};
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
export default Button;
|
|
2
2
|
export const ButtonWithForwardRef: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
3
|
-
declare function Button(
|
|
3
|
+
declare function Button({ size, subtext, as, children, forwardRef, "aria-label": ariaLabel, disabled, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, ...rest }: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
size: any;
|
|
6
|
+
subtext: any;
|
|
7
|
+
as: any;
|
|
8
|
+
children: any;
|
|
9
|
+
forwardRef: any;
|
|
10
|
+
"aria-label": any;
|
|
11
|
+
disabled: any;
|
|
12
|
+
buttonType: any;
|
|
13
|
+
iconType: any;
|
|
14
|
+
iconPosition: any;
|
|
15
|
+
href: any;
|
|
16
|
+
m?: number | undefined;
|
|
17
|
+
px: any;
|
|
18
|
+
noWrap: any;
|
|
19
|
+
target: any;
|
|
20
|
+
rel: any;
|
|
21
|
+
iconTooltipMessage: any;
|
|
22
|
+
iconTooltipPosition: any;
|
|
23
|
+
}): JSX.Element;
|
|
4
24
|
declare namespace Button {
|
|
5
25
|
const propTypes: any;
|
|
6
26
|
namespace defaultProps {
|
|
@@ -17,6 +17,8 @@ var _button = _interopRequireWildcard(require("./button.style"));
|
|
|
17
17
|
|
|
18
18
|
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
|
|
19
19
|
|
|
20
|
+
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
21
|
+
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
23
|
|
|
22
24
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -35,7 +37,8 @@ function renderChildren({
|
|
|
35
37
|
disabled,
|
|
36
38
|
buttonType,
|
|
37
39
|
iconTooltipMessage,
|
|
38
|
-
iconTooltipPosition
|
|
40
|
+
iconTooltipPosition,
|
|
41
|
+
tooltipTarget
|
|
39
42
|
/* eslint-enable */
|
|
40
43
|
|
|
41
44
|
}) {
|
|
@@ -57,43 +60,54 @@ function renderChildren({
|
|
|
57
60
|
"data-element": "main-text"
|
|
58
61
|
}, children), size === "large" && /*#__PURE__*/_react.default.createElement(_button.StyledButtonSubtext, {
|
|
59
62
|
"data-element": "subtext"
|
|
60
|
-
}, subtext)), iconType && !children && /*#__PURE__*/_react.default.createElement(
|
|
63
|
+
}, subtext)), iconType && !children && /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
64
|
+
disabled: disabled,
|
|
65
|
+
focusable: false,
|
|
66
|
+
target: tooltipTarget
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement(_icon.default, _extends({}, iconProps, {
|
|
61
68
|
tooltipMessage: iconTooltipMessage,
|
|
62
69
|
tooltipPosition: iconTooltipPosition
|
|
63
|
-
})), iconType && iconPosition === "after" && children && /*#__PURE__*/_react.default.createElement(_icon.default, iconProps));
|
|
70
|
+
}))), iconType && iconPosition === "after" && children && /*#__PURE__*/_react.default.createElement(_icon.default, iconProps));
|
|
64
71
|
}
|
|
65
72
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
const Button = ({
|
|
74
|
+
size,
|
|
75
|
+
subtext,
|
|
76
|
+
as,
|
|
77
|
+
children,
|
|
78
|
+
forwardRef,
|
|
79
|
+
"aria-label": ariaLabel,
|
|
80
|
+
disabled,
|
|
81
|
+
buttonType: buttonTypeProp,
|
|
82
|
+
iconType,
|
|
83
|
+
iconPosition,
|
|
84
|
+
href,
|
|
85
|
+
m = 0,
|
|
86
|
+
px,
|
|
87
|
+
noWrap,
|
|
88
|
+
target,
|
|
89
|
+
rel,
|
|
90
|
+
iconTooltipMessage,
|
|
91
|
+
iconTooltipPosition,
|
|
92
|
+
...rest
|
|
93
|
+
}) => {
|
|
94
|
+
const [internalRef, setInternalRef] = (0, _react.useState)(null);
|
|
95
|
+
const buttonType = buttonTypeProp || as;
|
|
96
|
+
|
|
97
|
+
if (subtext.length > 0 && size !== "large") {
|
|
98
|
+
throw new Error("subtext prop has no effect unless the button is large");
|
|
99
|
+
}
|
|
100
|
+
|
|
83
101
|
let paddingX;
|
|
84
102
|
|
|
85
103
|
const handleLinkKeyDown = event => {
|
|
86
104
|
// If space key click link
|
|
87
105
|
if (event.key === " ") {
|
|
88
106
|
event.preventDefault();
|
|
89
|
-
|
|
107
|
+
internalRef.click();
|
|
90
108
|
}
|
|
91
109
|
};
|
|
92
110
|
|
|
93
|
-
if (href) {
|
|
94
|
-
rest.href = href;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
111
|
switch (size) {
|
|
98
112
|
case "small":
|
|
99
113
|
paddingX = 2;
|
|
@@ -108,7 +122,7 @@ const renderStyledButton = buttonProps => {
|
|
|
108
122
|
}
|
|
109
123
|
|
|
110
124
|
return /*#__PURE__*/_react.default.createElement(_button.default, _extends({
|
|
111
|
-
"aria-label": !
|
|
125
|
+
"aria-label": !children && iconType ? ariaLabel || iconType : undefined,
|
|
112
126
|
as: !disabled && href ? "a" : "button",
|
|
113
127
|
onKeyDown: href && handleLinkKeyDown,
|
|
114
128
|
draggable: false,
|
|
@@ -121,36 +135,33 @@ const renderStyledButton = buttonProps => {
|
|
|
121
135
|
px: px ?? paddingX,
|
|
122
136
|
m: m,
|
|
123
137
|
noWrap: noWrap,
|
|
124
|
-
iconOnly: !
|
|
138
|
+
iconOnly: !children && iconType,
|
|
139
|
+
iconPosition: iconPosition,
|
|
125
140
|
target: target,
|
|
126
141
|
rel: rel
|
|
127
|
-
}, (0, _tags.default)("button",
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
142
|
+
}, (0, _tags.default)("button", rest), rest, href && {
|
|
143
|
+
href
|
|
144
|
+
}, {
|
|
145
|
+
ref: reference => {
|
|
146
|
+
if (reference) {
|
|
147
|
+
setInternalRef(reference);
|
|
148
|
+
if (!forwardRef) return;
|
|
149
|
+
if (typeof forwardRef === "object") forwardRef.current = reference;
|
|
150
|
+
if (typeof forwardRef === "function") forwardRef(reference);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}), renderChildren({
|
|
154
|
+
iconType,
|
|
155
|
+
iconPosition,
|
|
134
156
|
size,
|
|
135
|
-
subtext
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const {
|
|
139
|
-
as,
|
|
157
|
+
subtext,
|
|
158
|
+
children,
|
|
159
|
+
disabled,
|
|
140
160
|
buttonType,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
buttonType: buttonType || as,
|
|
146
|
-
ref: forwardRef || linkRef
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
if (subtext.length > 0 && size !== "large") {
|
|
150
|
-
throw new Error("subtext prop has no effect unless the button is large");
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return renderStyledButton(propsWithoutAs);
|
|
161
|
+
iconTooltipMessage,
|
|
162
|
+
iconTooltipPosition,
|
|
163
|
+
tooltipTarget: internalRef
|
|
164
|
+
}));
|
|
154
165
|
};
|
|
155
166
|
|
|
156
167
|
Button.propTypes = {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export default Confirm;
|
|
2
|
-
declare function Confirm({ open, children, destructive, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, ...rest }: {
|
|
2
|
+
declare function Confirm({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, destructive, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, ...rest }: {
|
|
3
3
|
[x: string]: any;
|
|
4
|
+
"aria-labelledby": any;
|
|
5
|
+
"aria-describedby": any;
|
|
6
|
+
"aria-label": any;
|
|
4
7
|
open: any;
|
|
5
8
|
children: any;
|
|
6
9
|
destructive: any;
|
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid/guid.js"));
|
|
13
|
+
|
|
12
14
|
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
13
15
|
|
|
14
16
|
var _heading = _interopRequireDefault(require("../heading"));
|
|
@@ -27,11 +29,18 @@ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLoc
|
|
|
27
29
|
|
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
31
|
|
|
32
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
33
|
+
|
|
34
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
+
|
|
30
36
|
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); }
|
|
31
37
|
|
|
32
38
|
let deprecatedWarnTriggered = false;
|
|
33
39
|
|
|
34
40
|
const Confirm = ({
|
|
41
|
+
"aria-labelledby": ariaLabelledBy,
|
|
42
|
+
"aria-describedby": ariaDescribedBy,
|
|
43
|
+
"aria-label": ariaLabel,
|
|
35
44
|
open,
|
|
36
45
|
children,
|
|
37
46
|
destructive,
|
|
@@ -62,6 +71,25 @@ const Confirm = ({
|
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
const l = (0, _useLocale.default)();
|
|
74
|
+
const {
|
|
75
|
+
current: titleId
|
|
76
|
+
} = (0, _react.useRef)((0, _guid.default)());
|
|
77
|
+
const {
|
|
78
|
+
current: subtitleId
|
|
79
|
+
} = (0, _react.useRef)((0, _guid.default)());
|
|
80
|
+
const ariaProps = {
|
|
81
|
+
"aria-labelledby": ariaLabelledBy,
|
|
82
|
+
"aria-describedby": ariaDescribedBy,
|
|
83
|
+
"aria-label": ariaLabel
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
if (title && iconType) {
|
|
87
|
+
ariaProps["aria-labelledby"] = titleId;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (subtitle && iconType) {
|
|
91
|
+
ariaProps["aria-describedby"] = subtitleId;
|
|
92
|
+
}
|
|
65
93
|
|
|
66
94
|
const renderCancelButton = () => {
|
|
67
95
|
if (!onCancel) return null;
|
|
@@ -100,9 +128,9 @@ const Confirm = ({
|
|
|
100
128
|
fontSize: "medium"
|
|
101
129
|
}), /*#__PURE__*/_react.default.createElement(_heading.default, {
|
|
102
130
|
title: title,
|
|
103
|
-
titleId:
|
|
131
|
+
titleId: titleId,
|
|
104
132
|
subheader: subtitle,
|
|
105
|
-
subtitleId:
|
|
133
|
+
subtitleId: subtitleId,
|
|
106
134
|
divider: false
|
|
107
135
|
}));
|
|
108
136
|
}
|
|
@@ -118,7 +146,7 @@ const Confirm = ({
|
|
|
118
146
|
title: getTitle(),
|
|
119
147
|
"data-component": "confirm",
|
|
120
148
|
role: "alertdialog"
|
|
121
|
-
}, rest), children, /*#__PURE__*/_react.default.createElement(_confirm.StyledConfirmButtons, null, renderCancelButton(), renderConfirmButton()));
|
|
149
|
+
}, ariaProps, rest), children, /*#__PURE__*/_react.default.createElement(_confirm.StyledConfirmButtons, null, renderCancelButton(), renderConfirmButton()));
|
|
122
150
|
};
|
|
123
151
|
|
|
124
152
|
Confirm.defaultProps = {
|
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid/guid.js"));
|
|
13
|
+
|
|
12
14
|
var _modal = _interopRequireDefault(require("../modal"));
|
|
13
15
|
|
|
14
16
|
var _heading = _interopRequireDefault(require("../heading"));
|
|
@@ -58,6 +60,12 @@ const Dialog = ({
|
|
|
58
60
|
const innerContentRef = (0, _react.useRef)();
|
|
59
61
|
const titleRef = (0, _react.useRef)();
|
|
60
62
|
const listenersAdded = (0, _react.useRef)(false);
|
|
63
|
+
const {
|
|
64
|
+
current: titleId
|
|
65
|
+
} = (0, _react.useRef)((0, _guid.default)());
|
|
66
|
+
const {
|
|
67
|
+
current: subtitleId
|
|
68
|
+
} = (0, _react.useRef)((0, _guid.default)());
|
|
61
69
|
const centerDialog = (0, _react.useCallback)(() => {
|
|
62
70
|
const {
|
|
63
71
|
width: dialogWidth,
|
|
@@ -133,9 +141,9 @@ const Dialog = ({
|
|
|
133
141
|
}, typeof title === "string" ? /*#__PURE__*/_react.default.createElement(_heading.default, {
|
|
134
142
|
"data-element": "dialog-title",
|
|
135
143
|
title: title,
|
|
136
|
-
titleId:
|
|
144
|
+
titleId: titleId,
|
|
137
145
|
subheader: subtitle,
|
|
138
|
-
subtitleId:
|
|
146
|
+
subtitleId: subtitleId,
|
|
139
147
|
divider: false,
|
|
140
148
|
help: help
|
|
141
149
|
}) : title);
|
|
@@ -150,15 +158,10 @@ const Dialog = ({
|
|
|
150
158
|
const dialogProps = {
|
|
151
159
|
size,
|
|
152
160
|
dialogHeight,
|
|
153
|
-
"aria-labelledby": rest["aria-labelledby"],
|
|
154
|
-
"aria-describedby": subtitle ?
|
|
161
|
+
"aria-labelledby": title && typeof title === "string" ? titleId : rest["aria-labelledby"],
|
|
162
|
+
"aria-describedby": subtitle ? subtitleId : rest["aria-describedby"],
|
|
155
163
|
"aria-label": rest["aria-label"]
|
|
156
164
|
};
|
|
157
|
-
|
|
158
|
-
if (title && typeof title === "string") {
|
|
159
|
-
dialogProps["aria-labelledby"] = "carbon-dialog-title";
|
|
160
|
-
}
|
|
161
|
-
|
|
162
165
|
const componentTags = {
|
|
163
166
|
"data-component": rest["data-component"] || "dialog",
|
|
164
167
|
"data-element": rest["data-element"],
|
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid/guid.js"));
|
|
13
|
+
|
|
12
14
|
var _modal = _interopRequireDefault(require("../modal"));
|
|
13
15
|
|
|
14
16
|
var _heading = _interopRequireDefault(require("../heading"));
|
|
@@ -51,11 +53,17 @@ const DialogFullScreen = ({
|
|
|
51
53
|
onCancel,
|
|
52
54
|
contentRef,
|
|
53
55
|
help,
|
|
54
|
-
role = "
|
|
56
|
+
role = "dialog",
|
|
55
57
|
...rest
|
|
56
58
|
}) => {
|
|
57
59
|
const dialogRef = (0, _react.useRef)();
|
|
58
60
|
const headingRef = (0, _react.useRef)();
|
|
61
|
+
const {
|
|
62
|
+
current: titleId
|
|
63
|
+
} = (0, _react.useRef)((0, _guid.default)());
|
|
64
|
+
const {
|
|
65
|
+
current: subtitleId
|
|
66
|
+
} = (0, _react.useRef)((0, _guid.default)());
|
|
59
67
|
|
|
60
68
|
const closeIcon = () => {
|
|
61
69
|
if (!showCloseIcon || !onCancel) return null;
|
|
@@ -74,13 +82,18 @@ const DialogFullScreen = ({
|
|
|
74
82
|
}, typeof title === "string" ? /*#__PURE__*/_react.default.createElement(_heading.default, {
|
|
75
83
|
"data-element": "dialog-title",
|
|
76
84
|
title: title,
|
|
77
|
-
titleId:
|
|
85
|
+
titleId: titleId,
|
|
78
86
|
subheader: subtitle,
|
|
79
|
-
subtitleId:
|
|
87
|
+
subtitleId: subtitleId,
|
|
80
88
|
divider: false,
|
|
81
89
|
help: help
|
|
82
90
|
}) : title, headerChildren);
|
|
83
91
|
|
|
92
|
+
const ariaProps = {
|
|
93
|
+
"aria-labelledby": title && typeof title === "string" ? titleId : ariaLabelledBy,
|
|
94
|
+
"aria-describedby": subtitle ? subtitleId : ariaDescribedBy,
|
|
95
|
+
"aria-label": ariaLabel
|
|
96
|
+
};
|
|
84
97
|
const componentTags = {
|
|
85
98
|
"data-component": "dialog-full-screen",
|
|
86
99
|
"data-element": rest["data-element"],
|
|
@@ -94,16 +107,14 @@ const DialogFullScreen = ({
|
|
|
94
107
|
autoFocus: !disableAutoFocus,
|
|
95
108
|
focusFirstElement: focusFirstElement,
|
|
96
109
|
wrapperRef: dialogRef
|
|
97
|
-
}, /*#__PURE__*/_react.default.createElement(_dialogFullScreen.default, {
|
|
98
|
-
"aria-modal": true
|
|
99
|
-
|
|
100
|
-
"aria-label": ariaLabel,
|
|
101
|
-
"aria-labelledby": ariaLabelledBy || "carbon-dialog-title",
|
|
110
|
+
}, /*#__PURE__*/_react.default.createElement(_dialogFullScreen.default, _extends({
|
|
111
|
+
"aria-modal": true
|
|
112
|
+
}, ariaProps, {
|
|
102
113
|
ref: dialogRef,
|
|
103
114
|
"data-element": "dialog-full-screen",
|
|
104
115
|
pagesStyling: pagesStyling,
|
|
105
116
|
role: role
|
|
106
|
-
}, dialogTitle(), /*#__PURE__*/_react.default.createElement(_content.default, {
|
|
117
|
+
}), dialogTitle(), /*#__PURE__*/_react.default.createElement(_content.default, {
|
|
107
118
|
hasHeader: title !== undefined,
|
|
108
119
|
"data-element": "content",
|
|
109
120
|
ref: contentRef,
|
|
@@ -63,7 +63,8 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
63
63
|
tooltipPosition: tooltipPositionFromContext,
|
|
64
64
|
focusable: focusableFromContext,
|
|
65
65
|
tooltipVisible: tooltipVisibleFromContext,
|
|
66
|
-
disabled: disabledFromContext
|
|
66
|
+
disabled: disabledFromContext,
|
|
67
|
+
target
|
|
67
68
|
} = (0, _react.useContext)(_tooltipProvider.TooltipContext);
|
|
68
69
|
/** Return Icon type with overrides */
|
|
69
70
|
|
|
@@ -131,7 +132,8 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
131
132
|
inputSize: inputSize,
|
|
132
133
|
bgColor: tooltipBgColor,
|
|
133
134
|
fontColor: tooltipFontColor,
|
|
134
|
-
flipOverrides: tooltipFlipOverrides
|
|
135
|
+
flipOverrides: tooltipFlipOverrides,
|
|
136
|
+
target: target
|
|
135
137
|
}, icon);
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -38,13 +38,8 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
38
38
|
disabled,
|
|
39
39
|
...rest
|
|
40
40
|
}, ref) => {
|
|
41
|
+
const [internalRef, setInternalRef] = (0, _react.useState)(null);
|
|
41
42
|
const marginProps = (0, _utils.filterStyledSystemMarginProps)(rest);
|
|
42
|
-
const hasIconWithTooltip = !!_react.default.Children.toArray(children).find(child => {
|
|
43
|
-
var _child$props;
|
|
44
|
-
|
|
45
|
-
return child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.tooltipMessage;
|
|
46
|
-
});
|
|
47
|
-
const [tooltipVisible, setTooltipVisible] = (0, _react.useState)(undefined);
|
|
48
43
|
|
|
49
44
|
const onKeyDown = e => {
|
|
50
45
|
if (_events.default.isEnterKey(e) || _events.default.isSpaceKey(e)) {
|
|
@@ -59,26 +54,23 @@ const IconButton = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
59
54
|
onAction(e);
|
|
60
55
|
};
|
|
61
56
|
|
|
62
|
-
const handleTooltipVisibility = (ev, callbackName) => {
|
|
63
|
-
setTooltipVisible(["onFocus", "onMouseEnter"].includes(callbackName));
|
|
64
|
-
if (rest[callbackName]) rest[callbackName](ev);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
57
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, _extends({}, rest, {
|
|
68
58
|
"aria-label": ariaLabel,
|
|
69
59
|
onKeyDown: onKeyDown,
|
|
70
60
|
onClick: handleOnAction,
|
|
71
|
-
ref:
|
|
61
|
+
ref: reference => {
|
|
62
|
+
if (reference) {
|
|
63
|
+
setInternalRef(reference);
|
|
64
|
+
if (!ref) return;
|
|
65
|
+
if (typeof ref === "object") ref.current = reference;
|
|
66
|
+
if (typeof ref === "function") ref(reference);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
72
69
|
disabled: disabled
|
|
73
|
-
}, !disabled && hasIconWithTooltip && {
|
|
74
|
-
onFocus: ev => handleTooltipVisibility(ev, "onFocus"),
|
|
75
|
-
onBlur: ev => handleTooltipVisibility(ev, "onBlur"),
|
|
76
|
-
onMouseEnter: ev => handleTooltipVisibility(ev, "onMouseEnter"),
|
|
77
|
-
onMouseLeave: ev => handleTooltipVisibility(ev, "onMouseLeave")
|
|
78
70
|
}, marginProps), /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
79
71
|
disabled: disabled,
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
focusable: false,
|
|
73
|
+
target: internalRef
|
|
82
74
|
}, children));
|
|
83
75
|
});
|
|
84
76
|
|
|
@@ -13,8 +13,6 @@ var _fieldset = _interopRequireDefault(require("../fieldset"));
|
|
|
13
13
|
|
|
14
14
|
var _input = require("../../__internal__/input");
|
|
15
15
|
|
|
16
|
-
var _tint = _interopRequireDefault(require("../../style/utils/tint"));
|
|
17
|
-
|
|
18
16
|
var _fieldset2 = require("../fieldset/fieldset.style");
|
|
19
17
|
|
|
20
18
|
var _icon = _interopRequireDefault(require("../icon/icon.style"));
|
|
@@ -33,6 +31,7 @@ const StyledTitle = _styledComponents.default.h3`
|
|
|
33
31
|
margin: 0;
|
|
34
32
|
margin-right: 16px;
|
|
35
33
|
margin-bottom: 8px;
|
|
34
|
+
color: var(--colorsActionMinorYin090);
|
|
36
35
|
`;
|
|
37
36
|
exports.StyledTitle = StyledTitle;
|
|
38
37
|
const StyledSubtitle = _styledComponents.default.h4`
|
|
@@ -41,6 +40,7 @@ const StyledSubtitle = _styledComponents.default.h4`
|
|
|
41
40
|
margin: 0;
|
|
42
41
|
margin-right: 16px;
|
|
43
42
|
margin-bottom: 8px;
|
|
43
|
+
color: var(--colorsActionMinorYin090);
|
|
44
44
|
`;
|
|
45
45
|
exports.StyledSubtitle = StyledSubtitle;
|
|
46
46
|
const StyledAdornment = _styledComponents.default.div`
|
|
@@ -51,36 +51,28 @@ const StyledAdornment = _styledComponents.default.div`
|
|
|
51
51
|
`;
|
|
52
52
|
exports.StyledAdornment = StyledAdornment;
|
|
53
53
|
const StyledDescription = _styledComponents.default.p`
|
|
54
|
-
color:
|
|
55
|
-
theme
|
|
56
|
-
}) => theme.tileSelect.descriptionColor};
|
|
54
|
+
color: var(--colorsActionMinorYin055);
|
|
57
55
|
font-size: 14px;
|
|
58
56
|
margin: 0;
|
|
59
57
|
`;
|
|
60
58
|
exports.StyledDescription = StyledDescription;
|
|
61
59
|
const StyledTileSelect = _styledComponents.default.div`
|
|
62
|
-
background
|
|
63
|
-
theme
|
|
64
|
-
}) => theme.colors.white};
|
|
60
|
+
background: var(--colorsActionMinorYang100);
|
|
65
61
|
padding: 24px;
|
|
66
62
|
${({
|
|
67
|
-
checked
|
|
68
|
-
theme
|
|
63
|
+
checked
|
|
69
64
|
}) => checked && (0, _styledComponents.css)`
|
|
70
|
-
background:
|
|
65
|
+
background: var(--colorsActionMajor025);
|
|
71
66
|
`}
|
|
72
67
|
|
|
73
68
|
${({
|
|
74
|
-
disabled
|
|
75
|
-
theme
|
|
69
|
+
disabled
|
|
76
70
|
}) => disabled && (0, _styledComponents.css)`
|
|
77
|
-
background:
|
|
71
|
+
background: var(--colorsActionMinorYang100);
|
|
78
72
|
${StyledTitle}, ${StyledSubtitle}, ${StyledDescription} {
|
|
79
|
-
color:
|
|
73
|
+
color: var(--colorsActionMinorYin030);
|
|
80
74
|
}
|
|
81
75
|
${StyledAdornment} * {
|
|
82
|
-
color: ${theme.colors.black};
|
|
83
|
-
fill: ${theme.colors.black};
|
|
84
76
|
opacity: 0.3;
|
|
85
77
|
}
|
|
86
78
|
`}
|
|
@@ -89,18 +81,17 @@ exports.StyledTileSelect = StyledTileSelect;
|
|
|
89
81
|
const StyledFocusWrapper = _styledComponents.default.div`
|
|
90
82
|
${({
|
|
91
83
|
checked,
|
|
92
|
-
theme,
|
|
93
84
|
hasFocus
|
|
94
85
|
}) => (0, _styledComponents.css)`
|
|
95
86
|
position: relative;
|
|
96
|
-
border: 1px solid
|
|
87
|
+
border: 1px solid var(--colorsActionMinor250);
|
|
97
88
|
${checked && (0, _styledComponents.css)`
|
|
98
|
-
border-color:
|
|
89
|
+
border-color: var(--colorsActionMajor500);
|
|
99
90
|
z-index: 10;
|
|
100
91
|
`}
|
|
101
92
|
|
|
102
93
|
${hasFocus && (0, _styledComponents.css)`
|
|
103
|
-
outline: 3px solid
|
|
94
|
+
outline: 3px solid var(--colorsSemanticFocus500);
|
|
104
95
|
z-index: 15;
|
|
105
96
|
`}
|
|
106
97
|
`}
|
|
@@ -116,11 +107,10 @@ const StyledTileSelectContainer = _styledComponents.default.div`
|
|
|
116
107
|
}
|
|
117
108
|
${({
|
|
118
109
|
checked,
|
|
119
|
-
disabled
|
|
120
|
-
theme
|
|
110
|
+
disabled
|
|
121
111
|
}) => !checked && !disabled && (0, _styledComponents.css)`
|
|
122
112
|
&:hover ${StyledTileSelect} {
|
|
123
|
-
background:
|
|
113
|
+
background: var(--colorsActionMinor050);
|
|
124
114
|
}
|
|
125
115
|
`}
|
|
126
116
|
`;
|
|
@@ -171,8 +161,7 @@ const StyledTitleContainer = _styledComponents.default.div`
|
|
|
171
161
|
exports.StyledTitleContainer = StyledTitleContainer;
|
|
172
162
|
const StyledDeselectWrapper = _styledComponents.default.div`
|
|
173
163
|
${({
|
|
174
|
-
hasActionAdornment
|
|
175
|
-
theme
|
|
164
|
+
hasActionAdornment
|
|
176
165
|
}) => (0, _styledComponents.css)`
|
|
177
166
|
z-index: 200;
|
|
178
167
|
position: relative;
|
|
@@ -181,10 +170,10 @@ const StyledDeselectWrapper = _styledComponents.default.div`
|
|
|
181
170
|
height: fit-content;
|
|
182
171
|
|
|
183
172
|
${hasActionAdornment && `
|
|
184
|
-
margin-right:
|
|
173
|
+
margin-right: var(--sizing200);
|
|
185
174
|
display: flex;
|
|
186
175
|
align-items: baseline;
|
|
187
|
-
min-height:
|
|
176
|
+
min-height: var(--sizing400);
|
|
188
177
|
|
|
189
178
|
${_icon.default} {
|
|
190
179
|
top: 2px;
|
|
@@ -214,9 +203,7 @@ const StyledTileSelectFieldset = (0, _styledComponents.default)(_fieldset.defaul
|
|
|
214
203
|
`;
|
|
215
204
|
exports.StyledTileSelectFieldset = StyledTileSelectFieldset;
|
|
216
205
|
const StyledGroupDescription = _styledComponents.default.p`
|
|
217
|
-
color:
|
|
218
|
-
theme
|
|
219
|
-
}) => theme.tileSelect.descriptionColor};
|
|
206
|
+
color: var(--colorsActionMinorYin055);
|
|
220
207
|
margin: 0;
|
|
221
208
|
margin-bottom: 16px;
|
|
222
209
|
`;
|
|
@@ -224,24 +211,6 @@ exports.StyledGroupDescription = StyledGroupDescription;
|
|
|
224
211
|
StyledTileSelectFieldset.defaultProps = {
|
|
225
212
|
theme: _themes.baseTheme
|
|
226
213
|
};
|
|
227
|
-
StyledTileSelect.defaultProps = {
|
|
228
|
-
theme: _themes.baseTheme
|
|
229
|
-
};
|
|
230
214
|
StyledTileSelectContainer.defaultProps = {
|
|
231
215
|
theme: _themes.baseTheme
|
|
232
|
-
};
|
|
233
|
-
StyledGroupDescription.defaultProps = {
|
|
234
|
-
theme: _themes.baseTheme
|
|
235
|
-
};
|
|
236
|
-
StyledTileSelectInput.defaultProps = {
|
|
237
|
-
theme: _themes.baseTheme
|
|
238
|
-
};
|
|
239
|
-
StyledDescription.defaultProps = {
|
|
240
|
-
theme: _themes.baseTheme
|
|
241
|
-
};
|
|
242
|
-
StyledDeselectWrapper.defaultProps = {
|
|
243
|
-
theme: _themes.baseTheme
|
|
244
|
-
};
|
|
245
|
-
StyledFocusWrapper.defaultProps = {
|
|
246
|
-
theme: _themes.baseTheme
|
|
247
216
|
};
|
|
@@ -42,6 +42,7 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
42
42
|
bgColor,
|
|
43
43
|
fontColor,
|
|
44
44
|
flipOverrides,
|
|
45
|
+
target,
|
|
45
46
|
...rest
|
|
46
47
|
}, ref) => {
|
|
47
48
|
const tooltipRef = (0, _react.useRef)(ref || null);
|
|
@@ -81,6 +82,7 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
81
82
|
visible: isVisible
|
|
82
83
|
}, {
|
|
83
84
|
render: attrs => tooltip(attrs, message),
|
|
85
|
+
reference: target,
|
|
84
86
|
popperOptions: {
|
|
85
87
|
modifiers: [...(flipOverrides ? [{
|
|
86
88
|
name: "flip",
|
|
@@ -119,6 +121,8 @@ Tooltip.propTypes = {
|
|
|
119
121
|
|
|
120
122
|
/** Defines the size of the tooltip content */
|
|
121
123
|
size: _propTypes.default.oneOf(["medium", "large"]),
|
|
124
|
+
// Reference element, tooltip will be positioned in relation to this element
|
|
125
|
+
target: _propTypes.default.instanceOf(Element),
|
|
122
126
|
|
|
123
127
|
/** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
|
|
124
128
|
bgColor: _propTypes.default.string,
|
|
@@ -25,6 +25,7 @@ export interface TooltipProps {
|
|
|
25
25
|
* (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
|
|
26
26
|
*/
|
|
27
27
|
flipOverrides?: ["top" | "bottom" | "left" | "right"];
|
|
28
|
+
target?: Element;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export interface TooltipInternalProps extends TooltipProps {
|