carbon-react 94.8.0 → 95.1.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__/focus-trap/focus-trap.component.js +3 -2
- package/lib/__internal__/tooltip-provider/index.d.ts +2 -0
- package/lib/__internal__/tooltip-provider/index.js +6 -3
- package/lib/__internal__/validations/validation-icon.component.js +3 -1
- package/lib/components/button/button.component.js +17 -8
- package/lib/components/button-toggle/button-toggle-icon.component.js +3 -4
- package/lib/components/button-toggle/button-toggle.style.js +2 -0
- package/lib/components/button-toggle-group/button-toggle-group.component.js +11 -3
- package/lib/components/button-toggle-group/button-toggle-group.d.ts +2 -0
- package/lib/components/checkbox/checkbox.component.js +6 -1
- package/lib/components/checkbox/checkbox.d.ts +2 -0
- package/lib/components/date/date.component.js +2 -1
- package/lib/components/decimal/decimal.component.js +4 -1
- package/lib/components/grouped-character/grouped-character.component.js +4 -1
- package/lib/components/heading/heading.component.js +8 -2
- package/lib/components/heading/heading.style.js +1 -0
- package/lib/components/help/help.component.js +24 -7
- package/lib/components/help/help.d.ts +2 -0
- package/lib/components/icon/icon-config.js +3 -5
- package/lib/components/icon/icon.component.js +16 -24
- package/lib/components/icon/icon.d.ts +3 -18
- package/lib/components/icon/icon.style.js +26 -77
- package/lib/components/link/link.component.js +8 -2
- package/lib/components/link/link.style.js +1 -0
- package/lib/components/message/type-icon/type-icon.component.js +1 -2
- package/lib/components/numeral-date/numeral-date.component.js +11 -3
- package/lib/components/numeral-date/numeral-date.d.ts +2 -0
- package/lib/components/pill/pill.component.js +1 -3
- package/lib/components/pill/pill.style.js +2 -0
- package/lib/components/radio-button/radio-button.component.js +5 -0
- package/lib/components/radio-button/radio-button.d.ts +2 -0
- package/lib/components/split-button/split-button.component.js +11 -4
- package/lib/components/switch/switch.component.js +6 -1
- package/lib/components/switch/switch.d.ts +2 -0
- package/lib/components/tabs/__internal__/tab-title/tab-title.style.js +10 -4
- package/lib/components/tabs/tabs.component.js +49 -31
- package/lib/components/textarea/textarea.component.js +6 -1
- package/lib/components/textarea/textarea.d.ts +2 -0
- package/lib/components/textbox/textbox.component.js +8 -3
- package/lib/components/textbox/textbox.d.ts +3 -1
- package/package.json +1 -1
|
@@ -42,8 +42,9 @@ const FocusTrap = ({
|
|
|
42
42
|
return Array.from(candidate).some((el, i) => el !== focusableElements[i]);
|
|
43
43
|
}, [focusableElements]);
|
|
44
44
|
const updateFocusableElements = (0, _react.useCallback)(() => {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const ref = wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current;
|
|
46
|
+
|
|
47
|
+
if (ref) {
|
|
47
48
|
const elements = Array.from(ref.querySelectorAll(_focusTrapUtils.defaultFocusableSelectors)).filter(el => Number(el.tabIndex) !== -1);
|
|
48
49
|
|
|
49
50
|
if (hasNewInputs(elements)) {
|
|
@@ -9,6 +9,8 @@ export interface TooltipProviderProps {
|
|
|
9
9
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
10
10
|
/** Control whether the tooltip is visible */
|
|
11
11
|
children: React.ReactNode;
|
|
12
|
+
/** Aria label for rendered help component */
|
|
13
|
+
helpAriaLabel?: string;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
declare const ToolbarContext: React.Context<ToolbarContextProps>;
|
|
@@ -17,15 +17,18 @@ exports.TooltipContext = TooltipContext;
|
|
|
17
17
|
|
|
18
18
|
const TooltipProvider = ({
|
|
19
19
|
children,
|
|
20
|
-
tooltipPosition
|
|
20
|
+
tooltipPosition,
|
|
21
|
+
helpAriaLabel
|
|
21
22
|
}) => /*#__PURE__*/_react.default.createElement(TooltipContext.Provider, {
|
|
22
23
|
value: {
|
|
23
|
-
tooltipPosition
|
|
24
|
+
tooltipPosition,
|
|
25
|
+
helpAriaLabel
|
|
24
26
|
}
|
|
25
27
|
}, children);
|
|
26
28
|
|
|
27
29
|
exports.TooltipProvider = TooltipProvider;
|
|
28
30
|
TooltipProvider.propTypes = {
|
|
29
31
|
children: _propTypes.default.node.isRequired,
|
|
30
|
-
tooltipPosition: _propTypes.default.oneOf(["top", "bottom", "left", "right"])
|
|
32
|
+
tooltipPosition: _propTypes.default.oneOf(["top", "bottom", "left", "right"]),
|
|
33
|
+
helpAriaLabel: _propTypes.default.string
|
|
31
34
|
};
|
|
@@ -100,7 +100,9 @@ const ValidationIcon = ({
|
|
|
100
100
|
tooltipVisible: hasFocus || hasMouseOver || groupHasFocus || groupHasMouseOver || triggeredByIcon,
|
|
101
101
|
tooltipFlipOverrides: isPartOfInput && !tooltipFlipOverrides ? ["top", "bottom"] : tooltipFlipOverrides,
|
|
102
102
|
isPartOfInput: isPartOfInput,
|
|
103
|
-
inputSize: size
|
|
103
|
+
inputSize: size,
|
|
104
|
+
"aria-hidden": "true",
|
|
105
|
+
focusable: false
|
|
104
106
|
}));
|
|
105
107
|
};
|
|
106
108
|
|
|
@@ -7,6 +7,8 @@ exports.default = exports.ButtonWithForwardRef = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
+
var _styledComponents = require("styled-components");
|
|
11
|
+
|
|
10
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
13
|
|
|
12
14
|
var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
|
|
@@ -17,6 +19,8 @@ var _button = _interopRequireWildcard(require("./button.style"));
|
|
|
17
19
|
|
|
18
20
|
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
|
|
19
21
|
|
|
22
|
+
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
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; }
|
|
@@ -35,21 +39,23 @@ function renderChildren({
|
|
|
35
39
|
disabled,
|
|
36
40
|
buttonType,
|
|
37
41
|
iconTooltipMessage,
|
|
38
|
-
iconTooltipPosition
|
|
42
|
+
iconTooltipPosition,
|
|
43
|
+
theme
|
|
39
44
|
/* eslint-enable */
|
|
40
45
|
|
|
41
46
|
}) {
|
|
42
47
|
const iconColorMap = {
|
|
43
|
-
primary:
|
|
44
|
-
secondary:
|
|
45
|
-
tertiary:
|
|
46
|
-
darkBackground:
|
|
48
|
+
primary: theme.colors.white,
|
|
49
|
+
secondary: theme.colors.primary,
|
|
50
|
+
tertiary: theme.colors.primary,
|
|
51
|
+
darkBackground: theme.colors.primary
|
|
47
52
|
};
|
|
48
53
|
const iconProps = {
|
|
49
54
|
type: iconType,
|
|
50
55
|
disabled,
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
bgSize: "extra-small",
|
|
57
|
+
color: iconColorMap[buttonType],
|
|
58
|
+
bg: "transparent"
|
|
53
59
|
};
|
|
54
60
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconType && iconPosition === "before" && children && /*#__PURE__*/_react.default.createElement(_icon.default, iconProps), /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("span", {
|
|
55
61
|
"data-element": "main-text"
|
|
@@ -129,6 +135,8 @@ const renderStyledButton = buttonProps => {
|
|
|
129
135
|
};
|
|
130
136
|
|
|
131
137
|
const Button = props => {
|
|
138
|
+
const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _base.default;
|
|
139
|
+
|
|
132
140
|
const {
|
|
133
141
|
size,
|
|
134
142
|
subtext
|
|
@@ -142,7 +150,8 @@ const Button = props => {
|
|
|
142
150
|
} = props;
|
|
143
151
|
const propsWithoutAs = { ...rest,
|
|
144
152
|
buttonType: buttonType || as,
|
|
145
|
-
ref: forwardRef || linkRef
|
|
153
|
+
ref: forwardRef || linkRef,
|
|
154
|
+
theme
|
|
146
155
|
};
|
|
147
156
|
|
|
148
157
|
if (subtext.length > 0 && size !== "large") {
|
|
@@ -19,10 +19,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
19
19
|
|
|
20
20
|
const ButtonToggleIcon = props => /*#__PURE__*/_react.default.createElement(_buttonToggle.StyledButtonToggleIcon, props, /*#__PURE__*/_react.default.createElement(_icon.default, _extends({
|
|
21
21
|
type: props.buttonIcon,
|
|
22
|
-
fontSize: props.buttonIconSize
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})));
|
|
22
|
+
fontSize: props.buttonIconSize,
|
|
23
|
+
bgSize: "extra-small"
|
|
24
|
+
}, props)));
|
|
26
25
|
|
|
27
26
|
ButtonToggleIcon.propTypes = {
|
|
28
27
|
/**
|
|
@@ -144,6 +144,8 @@ const StyledButtonToggleIcon = _styledComponents.default.div`
|
|
|
144
144
|
${_icon.default} {
|
|
145
145
|
margin-right: 0;
|
|
146
146
|
margin-bottom: 8px;
|
|
147
|
+
height: ${`${iconFontSizes.largeIcon}px`};
|
|
148
|
+
width: ${`${iconFontSizes.largeIcon}px`};
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
${_icon.default}::before {
|
|
@@ -25,6 +25,8 @@ var _inputBehaviour = require("../../__internal__/input-behaviour");
|
|
|
25
25
|
|
|
26
26
|
var _utils = require("../../style/utils");
|
|
27
27
|
|
|
28
|
+
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
29
|
+
|
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
31
|
|
|
30
32
|
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); }
|
|
@@ -53,6 +55,7 @@ const ButtonToggleGroup = ({
|
|
|
53
55
|
"data-component": dataComponent,
|
|
54
56
|
"data-element": dataElement,
|
|
55
57
|
"data-role": dataRole,
|
|
58
|
+
helpAriaLabel,
|
|
56
59
|
...props
|
|
57
60
|
}) => {
|
|
58
61
|
const validationProps = {
|
|
@@ -60,7 +63,9 @@ const ButtonToggleGroup = ({
|
|
|
60
63
|
warning,
|
|
61
64
|
info
|
|
62
65
|
};
|
|
63
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
67
|
+
helpAriaLabel: helpAriaLabel
|
|
68
|
+
}, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputGroupBehaviour, null, /*#__PURE__*/_react.default.createElement(_formField.default, _extends({
|
|
64
69
|
useValidationIcon: validationOnLabel,
|
|
65
70
|
label: label,
|
|
66
71
|
labelHelp: labelHelp,
|
|
@@ -84,7 +89,7 @@ const ButtonToggleGroup = ({
|
|
|
84
89
|
value: value
|
|
85
90
|
}, children), !validationOnLabel && /*#__PURE__*/_react.default.createElement(_validationIcon.default, _extends({}, validationProps, {
|
|
86
91
|
tooltipFlipOverrides: ["top", "bottom"]
|
|
87
|
-
})))));
|
|
92
|
+
}))))));
|
|
88
93
|
};
|
|
89
94
|
|
|
90
95
|
ButtonToggleGroup.propTypes = { ...marginPropTypes,
|
|
@@ -171,7 +176,10 @@ ButtonToggleGroup.propTypes = { ...marginPropTypes,
|
|
|
171
176
|
onBlur: _propTypes.default.func,
|
|
172
177
|
|
|
173
178
|
/** The value of the Button Toggle Group */
|
|
174
|
-
value: _propTypes.default.string
|
|
179
|
+
value: _propTypes.default.string,
|
|
180
|
+
|
|
181
|
+
/** Aria label for rendered help component */
|
|
182
|
+
helpAriaLabel: _propTypes.default.string
|
|
175
183
|
};
|
|
176
184
|
ButtonToggleGroup.defaultProps = {
|
|
177
185
|
validationOnLabel: false,
|
|
@@ -49,6 +49,8 @@ export interface ButtonToggleGroupProps
|
|
|
49
49
|
onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
50
50
|
/** The value of the Button Toggle Group */
|
|
51
51
|
value?: string;
|
|
52
|
+
/** Aria label for rendered help component */
|
|
53
|
+
helpAriaLabel?: string;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
declare function ButtonToggleGroup(props: ButtonToggleGroupProps): JSX.Element;
|
|
@@ -60,6 +60,7 @@ const Checkbox = ({
|
|
|
60
60
|
"data-component": dataComponent,
|
|
61
61
|
"data-element": dataElement,
|
|
62
62
|
"data-role": dataRole,
|
|
63
|
+
helpAriaLabel,
|
|
63
64
|
...props
|
|
64
65
|
}) => {
|
|
65
66
|
const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveSpacingBreakpoint);
|
|
@@ -93,6 +94,7 @@ const Checkbox = ({
|
|
|
93
94
|
...props
|
|
94
95
|
};
|
|
95
96
|
return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
97
|
+
helpAriaLabel: helpAriaLabel,
|
|
96
98
|
tooltipPosition: tooltipPosition
|
|
97
99
|
}, /*#__PURE__*/_react.default.createElement(_checkbox.default, _extends({
|
|
98
100
|
"data-component": dataComponent,
|
|
@@ -206,7 +208,10 @@ Checkbox.propTypes = {
|
|
|
206
208
|
required: _propTypes.default.bool,
|
|
207
209
|
|
|
208
210
|
/** Overrides the default tooltip position */
|
|
209
|
-
tooltipPosition: _propTypes.default.oneOf(["top", "bottom", "left", "right"])
|
|
211
|
+
tooltipPosition: _propTypes.default.oneOf(["top", "bottom", "left", "right"]),
|
|
212
|
+
|
|
213
|
+
/** Aria label for rendered help component */
|
|
214
|
+
helpAriaLabel: _propTypes.default.string
|
|
210
215
|
};
|
|
211
216
|
Checkbox.defaultProps = {
|
|
212
217
|
reverse: false,
|
|
@@ -15,6 +15,8 @@ export interface CheckboxProps extends CommonCheckableInputProps, MarginProps {
|
|
|
15
15
|
value?: string;
|
|
16
16
|
/** Overrides the default tooltip position */
|
|
17
17
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
18
|
+
/** Aria label for rendered help component */
|
|
19
|
+
helpAriaLabel?: string;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
declare function Checkbox(props: CheckboxProps): JSX.Element;
|
|
@@ -619,7 +619,8 @@ let BaseDateInput = /*#__PURE__*/function (_React$Component) {
|
|
|
619
619
|
}),
|
|
620
620
|
inputRef: this.assignInput,
|
|
621
621
|
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
|
|
622
|
-
tooltipPosition: tooltipPosition
|
|
622
|
+
tooltipPosition: tooltipPosition,
|
|
623
|
+
helpAriaLabel: this.props.helpAriaLabel
|
|
623
624
|
}, events)), this.renderHiddenInput(), this.renderDatePicker({
|
|
624
625
|
minDate,
|
|
625
626
|
maxDate
|
|
@@ -361,7 +361,10 @@ Decimal.propTypes = {
|
|
|
361
361
|
/**
|
|
362
362
|
* Override the locale string, default from I18nProvider
|
|
363
363
|
*/
|
|
364
|
-
locale: _propTypes.default.string
|
|
364
|
+
locale: _propTypes.default.string,
|
|
365
|
+
|
|
366
|
+
/** Aria label for rendered help component */
|
|
367
|
+
helpAriaLabel: _propTypes.default.string
|
|
365
368
|
};
|
|
366
369
|
Decimal.defaultProps = {
|
|
367
370
|
align: "right",
|
|
@@ -164,7 +164,10 @@ GroupedCharacter.propTypes = { ...marginPropTypes,
|
|
|
164
164
|
onBlur: _propTypes.default.func,
|
|
165
165
|
|
|
166
166
|
/** Flag to configure component as mandatory */
|
|
167
|
-
required: _propTypes.default.bool
|
|
167
|
+
required: _propTypes.default.bool,
|
|
168
|
+
|
|
169
|
+
/** Aria label for rendered help component */
|
|
170
|
+
helpAriaLabel: _propTypes.default.string
|
|
168
171
|
};
|
|
169
172
|
var _default = GroupedCharacter;
|
|
170
173
|
exports.default = _default;
|
|
@@ -71,7 +71,8 @@ let Heading = /*#__PURE__*/function (_React$Component) {
|
|
|
71
71
|
return /*#__PURE__*/_react.default.createElement(_heading.StyledHeaderHelp, {
|
|
72
72
|
"data-element": "help",
|
|
73
73
|
tooltipPosition: "right",
|
|
74
|
-
href: this.props.helpLink
|
|
74
|
+
href: this.props.helpLink,
|
|
75
|
+
ariaLabel: this.props.helpAriaLabel
|
|
75
76
|
}, this.props.help);
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
@@ -255,7 +256,12 @@ Heading.propTypes = { ...marginPropTypes,
|
|
|
255
256
|
/**
|
|
256
257
|
* Pills that will be added after the title.
|
|
257
258
|
*/
|
|
258
|
-
pills: _propTypes.default.node
|
|
259
|
+
pills: _propTypes.default.node,
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Aria label for rendered help component
|
|
263
|
+
*/
|
|
264
|
+
helpAriaLabel: _propTypes.default.string
|
|
259
265
|
};
|
|
260
266
|
Heading.defaultProps = {
|
|
261
267
|
divider: true,
|
|
@@ -19,6 +19,8 @@ var _help = _interopRequireDefault(require("./help.style"));
|
|
|
19
19
|
|
|
20
20
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
21
21
|
|
|
22
|
+
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
23
|
+
|
|
22
24
|
var _utils = require("../../style/utils");
|
|
23
25
|
|
|
24
26
|
var _help2 = require("./help.config");
|
|
@@ -46,10 +48,14 @@ const Help = ({
|
|
|
46
48
|
tooltipBgColor,
|
|
47
49
|
tooltipFontColor,
|
|
48
50
|
tooltipFlipOverrides,
|
|
51
|
+
ariaLabel,
|
|
49
52
|
...rest
|
|
50
53
|
}) => {
|
|
51
54
|
const helpElement = (0, _react.useRef)(null);
|
|
52
55
|
const [isTooltipVisible, updateTooltipVisible] = (0, _react.useState)(false);
|
|
56
|
+
const {
|
|
57
|
+
helpAriaLabel
|
|
58
|
+
} = (0, _react.useContext)(_tooltipProvider.TooltipContext);
|
|
53
59
|
(0, _react.useEffect)(() => {
|
|
54
60
|
document.addEventListener("keydown", handleKeyPress);
|
|
55
61
|
return function cleanup() {
|
|
@@ -72,13 +78,10 @@ const Help = ({
|
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
return /*#__PURE__*/_react.default.createElement(_help.default, _extends({
|
|
75
|
-
role: "tooltip",
|
|
76
81
|
className: className,
|
|
77
82
|
as: tagType,
|
|
78
83
|
href: href,
|
|
79
84
|
id: helpId,
|
|
80
|
-
target: "_blank",
|
|
81
|
-
rel: "noopener noreferrer",
|
|
82
85
|
ref: helpElement,
|
|
83
86
|
onClick: () => {
|
|
84
87
|
helpElement.current.focus();
|
|
@@ -89,15 +92,26 @@ const Help = ({
|
|
|
89
92
|
onMouseLeave: handleFocusBlur(false)
|
|
90
93
|
}, (0, _tags.default)("help", rest), {
|
|
91
94
|
tabIndex: tabIndex
|
|
92
|
-
},
|
|
95
|
+
}, href ? {
|
|
96
|
+
target: "_blank",
|
|
97
|
+
rel: "noopener noreferrer"
|
|
98
|
+
} : {
|
|
99
|
+
role: "tooltip",
|
|
100
|
+
"aria-label": ariaLabel || helpAriaLabel
|
|
101
|
+
}, (0, _utils.filterStyledSystemMarginProps)(rest), rest), /*#__PURE__*/_react.default.createElement(_icon.default, _extends({
|
|
93
102
|
type: type,
|
|
94
103
|
tooltipMessage: children,
|
|
95
104
|
tooltipPosition: tooltipPosition,
|
|
96
105
|
tooltipVisible: isFocused || isTooltipVisible,
|
|
97
106
|
tooltipBgColor: tooltipBgColor,
|
|
98
107
|
tooltipFontColor: tooltipFontColor,
|
|
99
|
-
tooltipFlipOverrides: tooltipFlipOverrides
|
|
100
|
-
|
|
108
|
+
tooltipFlipOverrides: tooltipFlipOverrides,
|
|
109
|
+
focusable: false,
|
|
110
|
+
"aria-hidden": "true"
|
|
111
|
+
}, href && {
|
|
112
|
+
role: "tooltip",
|
|
113
|
+
ariaLabel: ariaLabel || helpAriaLabel
|
|
114
|
+
})));
|
|
101
115
|
};
|
|
102
116
|
|
|
103
117
|
Help.propTypes = { ...marginPropTypes,
|
|
@@ -150,7 +164,10 @@ Help.propTypes = { ...marginPropTypes,
|
|
|
150
164
|
|
|
151
165
|
return new Error( // eslint-disable-next-line max-len
|
|
152
166
|
`The \`${propName}\` prop supplied to \`${componentName}\` must be an array containing some or all of ["top", "bottom", "left", "right"].`);
|
|
153
|
-
}
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
/** Aria label */
|
|
170
|
+
ariaLabel: _propTypes.default.string
|
|
154
171
|
};
|
|
155
172
|
Help.defaultProps = {
|
|
156
173
|
tooltipPosition: "top",
|
|
@@ -30,6 +30,8 @@ export interface HelpProps extends MarginProps {
|
|
|
30
30
|
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
31
31
|
/** Help Icon type */
|
|
32
32
|
type?: IconType;
|
|
33
|
+
/** Aria label */
|
|
34
|
+
ariaLabel?: string;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
declare function Help(props: HelpProps): JSX.Element;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.ICONS = exports.
|
|
6
|
+
exports.default = exports.ICONS = exports.ICON_FONT_SIZES = exports.ICON_SIZES = exports.ICON_SHAPES = exports.ICON_TOOLTIP_POSITIONS = void 0;
|
|
7
7
|
const dlsConfig = {
|
|
8
8
|
backgroundSize: {
|
|
9
9
|
"extra-small": "16px",
|
|
@@ -30,10 +30,8 @@ const ICON_SHAPES = ["circle", "rounded-rect", "square"];
|
|
|
30
30
|
exports.ICON_SHAPES = ICON_SHAPES;
|
|
31
31
|
const ICON_SIZES = ["extra-small", "small", "medium", "large", "extra-large"];
|
|
32
32
|
exports.ICON_SIZES = ICON_SIZES;
|
|
33
|
-
const
|
|
34
|
-
exports.
|
|
35
|
-
const ICON_COLORS = ["default", "on-light-background", "on-dark-background", "business-color"];
|
|
36
|
-
exports.ICON_COLORS = ICON_COLORS;
|
|
33
|
+
const ICON_FONT_SIZES = ["small", "medium", "large", "extra-large"];
|
|
34
|
+
exports.ICON_FONT_SIZES = ICON_FONT_SIZES;
|
|
37
35
|
const ICONS = ["add", "alert", "analysis", "arrow_down", "arrow_left", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_right", "arrow_right_small", "arrow_up", "attach", "bank", "basket", "basket_with_squares", "bin", "blocked", "blocked_square", "block_arrow_right", "bold", "boxed_shapes", "bulk_destroy", "bullet_list", "bullet_list_dotted", "bullet_list_numbers", "business", "calendar", "calendar_today", "call", "camera", "card_view", "caret_down", "caret_left", "caret_right", "caret_up", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "cart", "chat", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chevron_down", "chevron_left", "chevron_right", "chevron_up", "chevron_down_thick", "chevron_left_thick", "chevron_right_thick", "chevron_up_thick", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "copy", "credit_card", "credit_card_slash", "cross", "cross_circle", "csv", "delete", "delivery", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "drag", "drag_vertical", "draft", "dropdown", "duplicate", "edit", "edited", "email", "email_switch", "ellipsis_horizontal", "ellipsis_vertical", "envelope_dollar", "envelope_euro", "error", "error_square", "euro", "expand", "factory", "favourite", "favourite_lined", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter", "filter_new", "fit_height", "fit_width", "flag", "folder", "gift", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger", "ledger_arrow_left", "ledger_arrow_right", "link", "list_view", "locked", "location", "logout", "lookup", "marker", "message", "messages", "minus", "minus_large", "mobile", "money_bag", "pause", "pause_circle", "pdf", "people", "people_switch", "person", "person_info", "person_tick", "phone", "play", "play_circle", "plus", "plus_large", "pound", "print", "progress", "progressed", "question", "refresh", "refresh_clock", "remove", "sage_coin", "save", "scan", "search", "services", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split", "split_container", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "three_boxes", "tick", "tick_circle", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning", "admin", "arrow", "contacts", "create", "disconnect", "entry", "go", "lightbulb_off", "lightbulb_on", "none", "old_warning", "piggy_bank", "question_hollow", "question_mark", "settings_old", "talk", "true_tick"];
|
|
38
36
|
exports.ICONS = ICONS;
|
|
39
37
|
var _default = dlsConfig;
|
|
@@ -19,8 +19,6 @@ var _tooltip = _interopRequireDefault(require("../tooltip"));
|
|
|
19
19
|
|
|
20
20
|
var _utils = require("../../style/utils");
|
|
21
21
|
|
|
22
|
-
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
23
|
-
|
|
24
22
|
var _iconConfig = require("./icon-config");
|
|
25
23
|
|
|
26
24
|
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
@@ -33,19 +31,16 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
33
31
|
|
|
34
32
|
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); }
|
|
35
33
|
|
|
36
|
-
let deprecatedWarnTriggered = false;
|
|
37
34
|
const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
|
|
38
35
|
|
|
39
36
|
const Icon = /*#__PURE__*/_react.default.forwardRef(({
|
|
40
37
|
bg,
|
|
41
38
|
bgShape,
|
|
42
39
|
bgSize,
|
|
43
|
-
bgTheme,
|
|
44
40
|
className,
|
|
45
41
|
color,
|
|
46
42
|
disabled,
|
|
47
43
|
fontSize,
|
|
48
|
-
iconColor,
|
|
49
44
|
type,
|
|
50
45
|
tooltipMessage,
|
|
51
46
|
tooltipPosition,
|
|
@@ -56,14 +51,11 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
56
51
|
tabIndex,
|
|
57
52
|
isPartOfInput,
|
|
58
53
|
inputSize,
|
|
54
|
+
role,
|
|
55
|
+
ariaLabel,
|
|
56
|
+
focusable = true,
|
|
59
57
|
...rest
|
|
60
58
|
}, ref) => {
|
|
61
|
-
if (!deprecatedWarnTriggered && (iconColor || bgTheme)) {
|
|
62
|
-
deprecatedWarnTriggered = true;
|
|
63
|
-
|
|
64
|
-
_logger.default.deprecate("`iconColor` and `bgTheme` props are deprecated and will soon be removed");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
59
|
const isInteractive = !!tooltipMessage && !disabled;
|
|
68
60
|
/** Return Icon type with overrides */
|
|
69
61
|
|
|
@@ -91,18 +83,17 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
91
83
|
}
|
|
92
84
|
};
|
|
93
85
|
|
|
86
|
+
const hasTooltip = !disabled && tooltipMessage && focusable;
|
|
94
87
|
const styleProps = {
|
|
95
88
|
bg,
|
|
96
|
-
bgTheme,
|
|
97
89
|
bgSize,
|
|
98
90
|
bgShape,
|
|
99
91
|
color,
|
|
100
92
|
disabled,
|
|
101
93
|
fontSize,
|
|
102
94
|
isInteractive,
|
|
103
|
-
iconColor,
|
|
104
|
-
tabIndex,
|
|
105
95
|
type: iconType(),
|
|
96
|
+
tabIndex: hasTooltip && tabIndex === undefined ? 0 : tabIndex,
|
|
106
97
|
...(0, _utils.filterStyledSystemMarginProps)(rest)
|
|
107
98
|
};
|
|
108
99
|
|
|
@@ -111,7 +102,11 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
111
102
|
key: "icon",
|
|
112
103
|
className: className || null,
|
|
113
104
|
"data-element": iconType()
|
|
114
|
-
}, (0, _tags.default)("icon", rest), styleProps
|
|
105
|
+
}, (0, _tags.default)("icon", rest), styleProps, {
|
|
106
|
+
hasTooltip: hasTooltip,
|
|
107
|
+
"aria-label": ariaLabel,
|
|
108
|
+
role: hasTooltip && role === undefined ? "tooltip" : role
|
|
109
|
+
}));
|
|
115
110
|
|
|
116
111
|
const {
|
|
117
112
|
tooltipPosition: tooltipPositionFromContext
|
|
@@ -157,19 +152,13 @@ Icon.propTypes = { ...marginPropTypes,
|
|
|
157
152
|
/** Background shape */
|
|
158
153
|
bgShape: _propTypes.default.oneOf(["circle", "rounded-rect", "square"]),
|
|
159
154
|
|
|
160
|
-
/** Background color theme */
|
|
161
|
-
bgTheme: _propTypes.default.oneOf(["info", "error", "success", "warning", "business", "none"]),
|
|
162
|
-
|
|
163
155
|
/** Icon font size */
|
|
164
156
|
fontSize: _propTypes.default.oneOf(["small", "medium", "large", "extra-large"]),
|
|
165
157
|
|
|
166
|
-
/** Icon color */
|
|
167
|
-
iconColor: _propTypes.default.oneOf(["default", "on-light-background", "on-dark-background", "business-color"]),
|
|
168
|
-
|
|
169
|
-
/** Override iconColor, provide any color from palette or any valid css color value. */
|
|
158
|
+
/** Icon colour, provide any color from palette or any valid css color value. */
|
|
170
159
|
color: _propTypes.default.string,
|
|
171
160
|
|
|
172
|
-
/**
|
|
161
|
+
/** Background colour, provide any color from palette or any valid css color value. */
|
|
173
162
|
bg: _propTypes.default.string,
|
|
174
163
|
|
|
175
164
|
/** Sets the icon in the disabled state */
|
|
@@ -216,7 +205,10 @@ Icon.propTypes = { ...marginPropTypes,
|
|
|
216
205
|
inputSize: _propTypes.default.oneOf(["small", "medium", "large"]),
|
|
217
206
|
|
|
218
207
|
/** @ignore @private */
|
|
219
|
-
tabIndex: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.
|
|
208
|
+
tabIndex: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
209
|
+
|
|
210
|
+
/** @ignore @private */
|
|
211
|
+
focusable: _propTypes.default.bool
|
|
220
212
|
};
|
|
221
213
|
Icon.defaultProps = {
|
|
222
214
|
bgSize: "small",
|
|
@@ -15,13 +15,7 @@ export type FontSize =
|
|
|
15
15
|
| "large"
|
|
16
16
|
| "extra-large";
|
|
17
17
|
export type BackgroundShape = "circle" | "rounded-rect" | "square";
|
|
18
|
-
|
|
19
|
-
| "info"
|
|
20
|
-
| "error"
|
|
21
|
-
| "success"
|
|
22
|
-
| "warning"
|
|
23
|
-
| "business"
|
|
24
|
-
| "none";
|
|
18
|
+
|
|
25
19
|
export type IconType =
|
|
26
20
|
| "add"
|
|
27
21
|
| "alert"
|
|
@@ -209,11 +203,6 @@ export type IconType =
|
|
|
209
203
|
| "video"
|
|
210
204
|
| "view"
|
|
211
205
|
| "warning";
|
|
212
|
-
export type IconColor =
|
|
213
|
-
| "default"
|
|
214
|
-
| "on-light-background"
|
|
215
|
-
| "on-dark-background"
|
|
216
|
-
| "business-color";
|
|
217
206
|
|
|
218
207
|
export interface IconProps extends MarginProps {
|
|
219
208
|
/** Icon type */
|
|
@@ -222,15 +211,11 @@ export interface IconProps extends MarginProps {
|
|
|
222
211
|
bgSize?: BgSize;
|
|
223
212
|
/** Background shape */
|
|
224
213
|
bgShape?: BackgroundShape;
|
|
225
|
-
/** Background color theme */
|
|
226
|
-
bgTheme?: BackgroundTheme;
|
|
227
214
|
/** Icon font size */
|
|
228
215
|
fontSize?: FontSize;
|
|
229
|
-
/** Icon color */
|
|
230
|
-
iconColor?: IconColor;
|
|
231
|
-
/** Override iconColor, provide any color from palette or any valid css color value. */
|
|
216
|
+
/** Icon colour, provide any color from palette or any valid css color value. */
|
|
232
217
|
color?: string;
|
|
233
|
-
/**
|
|
218
|
+
/** Background colour, provide any color from palette or any valid css color value. */
|
|
234
219
|
bg?: string;
|
|
235
220
|
/** Sets the icon in the disabled state */
|
|
236
221
|
disabled?: boolean;
|