carbon-react 108.0.0 → 109.0.2

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.
Files changed (75) hide show
  1. package/esm/__internal__/input/input-presentation.style.d.ts +1 -1
  2. package/esm/__internal__/input/input.component.js +52 -2
  3. package/esm/__internal__/input-icon-toggle/index.d.ts +2 -1
  4. package/esm/__internal__/input-icon-toggle/input-icon-toggle.component.d.ts +20 -0
  5. package/esm/__internal__/input-icon-toggle/input-icon-toggle.component.js +16 -17
  6. package/esm/__internal__/input-icon-toggle/input-icon-toggle.style.d.ts +12 -0
  7. package/esm/__internal__/input-icon-toggle/input-icon-toggle.style.js +7 -17
  8. package/esm/__internal__/label/label.component.js +1 -1
  9. package/esm/__spec_helper__/index.js +1 -1
  10. package/esm/components/accordion/accordion.style.d.ts +2 -2
  11. package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +1 -1
  12. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +1 -1
  13. package/esm/components/action-popover/action-popover.style.d.ts +4 -4
  14. package/esm/components/badge/badge.style.d.ts +1 -2
  15. package/esm/components/button/button.component.d.ts +2 -1
  16. package/esm/components/button/button.component.js +3 -3
  17. package/esm/components/confirm/confirm.d.ts +1 -1
  18. package/esm/components/flat-table/flat-table.style.js +1 -1
  19. package/esm/components/form/form.style.js +1 -1
  20. package/esm/components/help/help.d.ts +1 -1
  21. package/esm/components/icon/icon-config.d.ts +14 -11
  22. package/esm/components/icon/icon-config.js +1 -1
  23. package/esm/components/icon/icon-type.d.ts +1 -0
  24. package/esm/components/icon/icon-type.js +1 -0
  25. package/esm/components/icon/icon.component.d.ts +46 -0
  26. package/esm/components/icon/icon.component.js +212 -125
  27. package/esm/components/icon/icon.style.d.ts +37 -1
  28. package/esm/components/icon/icon.style.js +10 -35
  29. package/esm/components/icon/index.d.ts +3 -2
  30. package/esm/components/icon-button/icon-button.d.ts +1 -1
  31. package/esm/components/link/link.component.d.ts +2 -2
  32. package/esm/components/link/link.component.js +1 -1
  33. package/esm/components/menu/menu-item/menu-item.d.ts +1 -1
  34. package/esm/components/multi-action-button/multi-action-button.component.js +50 -1
  35. package/esm/hooks/__internal__/useModalManager/useModalManager.js +14 -11
  36. package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
  37. package/lib/__internal__/input/input.component.js +52 -2
  38. package/lib/__internal__/input-icon-toggle/index.d.ts +2 -1
  39. package/lib/__internal__/input-icon-toggle/input-icon-toggle.component.d.ts +20 -0
  40. package/lib/__internal__/input-icon-toggle/input-icon-toggle.component.js +16 -17
  41. package/lib/__internal__/input-icon-toggle/input-icon-toggle.style.d.ts +12 -0
  42. package/lib/__internal__/input-icon-toggle/input-icon-toggle.style.js +7 -18
  43. package/lib/__internal__/label/label.component.js +1 -1
  44. package/lib/__spec_helper__/index.js +1 -1
  45. package/lib/components/accordion/accordion.style.d.ts +2 -2
  46. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +1 -1
  47. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +1 -1
  48. package/lib/components/action-popover/action-popover.style.d.ts +4 -4
  49. package/lib/components/badge/badge.style.d.ts +1 -2
  50. package/lib/components/button/button.component.d.ts +2 -1
  51. package/lib/components/button/button.component.js +3 -3
  52. package/lib/components/confirm/confirm.d.ts +1 -1
  53. package/lib/components/flat-table/flat-table.style.js +1 -1
  54. package/lib/components/form/form.style.js +1 -1
  55. package/lib/components/help/help.d.ts +1 -1
  56. package/lib/components/icon/icon-config.d.ts +14 -11
  57. package/lib/components/icon/icon-config.js +1 -1
  58. package/lib/components/icon/icon-type.d.ts +1 -0
  59. package/lib/components/icon/icon-type.js +5 -0
  60. package/lib/components/icon/icon.component.d.ts +46 -0
  61. package/lib/components/icon/icon.component.js +215 -130
  62. package/lib/components/icon/icon.style.d.ts +37 -1
  63. package/lib/components/icon/icon.style.js +10 -36
  64. package/lib/components/icon/index.d.ts +3 -2
  65. package/lib/components/icon-button/icon-button.d.ts +1 -1
  66. package/lib/components/link/link.component.d.ts +2 -2
  67. package/lib/components/link/link.component.js +1 -1
  68. package/lib/components/menu/menu-item/menu-item.d.ts +1 -1
  69. package/lib/components/multi-action-button/multi-action-button.component.js +50 -1
  70. package/lib/hooks/__internal__/useModalManager/useModalManager.js +14 -11
  71. package/package.json +10 -10
  72. package/esm/__internal__/input-icon-toggle/input-icon-toggle.d.ts +0 -24
  73. package/esm/components/icon/icon.d.ts +0 -252
  74. package/lib/__internal__/input-icon-toggle/input-icon-toggle.d.ts +0 -24
  75. package/lib/components/icon/icon.d.ts +0 -252
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ import { StyledIconProps } from "./icon.style";
4
+ import { IconType } from "./icon-type";
5
+ import { TooltipPositions } from "../tooltip/tooltip.config";
6
+ export declare type LegacyIconTypes = "help" | "maintenance" | "new" | "success" | "messages";
7
+ export interface IconProps extends Omit<StyledIconProps, "type">, MarginProps {
8
+ /** Set whether icon should be recognised by assistive technologies */
9
+ "aria-hidden"?: boolean;
10
+ /** Aria label for accessibility purposes */
11
+ ariaLabel?: string;
12
+ /** Id passed to the icon. */
13
+ id?: string;
14
+ /** The ARIA role to be applied to the Icon */
15
+ role?: string;
16
+ /** The message to be displayed within the tooltip */
17
+ tooltipMessage?: React.ReactNode;
18
+ /** The position to display the tooltip */
19
+ tooltipPosition?: TooltipPositions;
20
+ /** Control whether the tooltip is visible */
21
+ tooltipVisible?: boolean;
22
+ /** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
23
+ tooltipBgColor?: string;
24
+ /** Override font color of the Tooltip, provide any color from palette or any valid css color value. */
25
+ tooltipFontColor?: string;
26
+ /** Overrides the default flip behaviour of the Tooltip */
27
+ tooltipFlipOverrides?: TooltipPositions[];
28
+ /** Id passed to the tooltip container, used for accessibility purposes */
29
+ tooltipId?: string;
30
+ /**
31
+ * Icon type
32
+ *
33
+ * The full list of types can be seen [here](https://carbon.sage.com/?path=/docs/icon--list-of-icons#list-of-icons).
34
+ */
35
+ type: IconType | LegacyIconTypes;
36
+ /** @ignore @private */
37
+ focusable?: boolean;
38
+ /** @ignore @private */
39
+ isPartOfInput?: boolean;
40
+ /** @ignore @private */
41
+ inputSize?: "small" | "medium" | "large";
42
+ /** @ignore @private */
43
+ tabIndex?: number;
44
+ }
45
+ declare const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<HTMLSpanElement>>;
46
+ export default Icon;
@@ -1,25 +1,27 @@
1
- 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); }
2
-
3
1
  import React, { useContext } from "react";
4
2
  import PropTypes from "prop-types";
5
- import styledSystemPropTypes from "@styled-system/prop-types";
6
- import tagComponent from "../../__internal__/utils/helpers/tags/tags";
7
- import StyledIcon from "./icon.style";
3
+ import invariant from "invariant";
8
4
  import Tooltip from "../tooltip";
9
5
  import { filterStyledSystemMarginProps } from "../../style/utils";
10
- import { ICON_TOOLTIP_POSITIONS } from "./icon-config";
11
6
  import { TooltipContext } from "../../__internal__/tooltip-provider";
12
- const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
7
+ import tagComponent from "../../__internal__/utils/helpers/tags/tags";
8
+ import StyledIcon from "./icon.style";
9
+ import { ICON_TOOLTIP_POSITIONS } from "./icon-config";
13
10
  const Icon = /*#__PURE__*/React.forwardRef(({
14
11
  "aria-hidden": ariaHidden,
12
+ ariaLabel,
15
13
  bg,
16
14
  bgShape,
17
- bgSize,
15
+ bgSize = "small",
18
16
  className,
19
17
  color,
20
18
  disabled,
21
- fontSize,
22
- type,
19
+ focusable = true,
20
+ fontSize = "small",
21
+ id,
22
+ inputSize,
23
+ isPartOfInput,
24
+ tabIndex,
23
25
  tooltipMessage,
24
26
  tooltipPosition,
25
27
  tooltipVisible,
@@ -27,15 +29,16 @@ const Icon = /*#__PURE__*/React.forwardRef(({
27
29
  tooltipFontColor,
28
30
  tooltipFlipOverrides,
29
31
  tooltipId,
30
- tabIndex,
31
- id,
32
- isPartOfInput,
33
- inputSize,
32
+ type,
34
33
  role,
35
- ariaLabel,
36
- focusable = true,
37
34
  ...rest
38
35
  }, ref) => {
36
+ const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => ICON_TOOLTIP_POSITIONS.includes(override));
37
+
38
+ if (tooltipFlipOverrides) {
39
+ invariant(flipBehaviourCheck, `The tooltipFlipOverrides prop supplied to \`Icon\` must be an array containing some or all of ["top", "bottom", "left", "right"].`);
40
+ }
41
+
39
42
  const isInteractive = !!tooltipMessage && !disabled;
40
43
  const {
41
44
  tooltipPosition: tooltipPositionFromContext,
@@ -71,31 +74,29 @@ const Icon = /*#__PURE__*/React.forwardRef(({
71
74
  };
72
75
 
73
76
  const isFocusable = focusableFromContext !== undefined ? focusableFromContext : focusable;
74
- const hasTooltip = !disabled && !disabledFromContext && tooltipMessage && isFocusable;
75
- const styleProps = {
77
+ const hasTooltip = !disabled && !disabledFromContext && !!tooltipMessage && isFocusable;
78
+ const styledIconProps = {
79
+ "aria-hidden": ariaHidden,
80
+ "aria-label": ariaLabel,
76
81
  bg,
77
82
  bgSize,
78
83
  bgShape,
84
+ className: className || undefined,
79
85
  color,
86
+ "data-element": iconType(),
80
87
  disabled: disabledFromContext || disabled,
81
88
  fontSize,
89
+ hasTooltip,
90
+ id,
82
91
  isInteractive,
83
- type: iconType(),
92
+ key: "icon",
93
+ ref,
94
+ role,
84
95
  tabIndex: hasTooltip && tabIndex === undefined ? 0 : tabIndex,
96
+ type: iconType(),
97
+ ...tagComponent("icon", rest),
85
98
  ...filterStyledSystemMarginProps(rest)
86
99
  };
87
- const icon = /*#__PURE__*/React.createElement(StyledIcon, _extends({
88
- "aria-hidden": ariaHidden,
89
- ref: ref,
90
- key: "icon",
91
- id: id,
92
- className: className || null,
93
- "data-element": iconType()
94
- }, tagComponent("icon", rest), styleProps, {
95
- hasTooltip: hasTooltip,
96
- "aria-label": ariaLabel,
97
- role: role
98
- }));
99
100
 
100
101
  if (tooltipMessage) {
101
102
  const showTooltip = tooltipVisibleFromContext !== undefined ? tooltipVisibleFromContext : tooltipVisible;
@@ -112,103 +113,189 @@ const Icon = /*#__PURE__*/React.forwardRef(({
112
113
  fontColor: tooltipFontColor,
113
114
  flipOverrides: tooltipFlipOverrides,
114
115
  target: target
115
- }, icon);
116
+ }, /*#__PURE__*/React.createElement(StyledIcon, styledIconProps));
116
117
  }
117
118
 
118
- return icon;
119
+ return /*#__PURE__*/React.createElement(StyledIcon, styledIconProps);
119
120
  });
120
- Icon.propTypes = { ...marginPropTypes,
121
-
122
- /**
123
- * @private
124
- * @ignore
125
- * Add classes to this component
126
- * */
127
- className: PropTypes.string,
128
-
129
- /**
130
- * Icon type.
131
- *
132
- * The full list of types can be seen [here](https://github.com/Sage/carbon/blob/master/src/components/icon/icon-config.js).
133
- * */
134
- type: PropTypes.string.isRequired,
135
-
136
- /** Background size */
137
- bgSize: PropTypes.oneOf(["extra-small", "small", "medium", "large", "extra-large"]),
138
-
139
- /** Background shape */
140
- bgShape: PropTypes.oneOf(["circle", "rounded-rect", "square"]),
141
-
142
- /** Icon font size */
143
- fontSize: PropTypes.oneOf(["small", "medium", "large", "extra-large"]),
144
-
145
- /** Icon colour, provide design token, any color from palette or any valid css color value. */
146
- color: PropTypes.string,
147
-
148
- /** Background colour, provide design token, any color from palette, or any valid css color value. */
149
- bg: PropTypes.string,
150
-
151
- /** Sets the icon in the disabled state */
152
- disabled: PropTypes.bool,
153
-
154
- /** Aria label for accessibility purposes */
155
- ariaLabel: PropTypes.string,
156
-
157
- /** Set whether icon should be recognised by assistive technologies */
121
+ Icon.propTypes = {
158
122
  "aria-hidden": PropTypes.bool,
159
-
160
- /** The message to be displayed within the tooltip */
161
- tooltipMessage: PropTypes.node,
162
-
163
- /** The position to display the tooltip */
164
- tooltipPosition: PropTypes.oneOf(["top", "bottom", "left", "right"]),
165
-
166
- /** Control whether the tooltip is visible */
167
- tooltipVisible: PropTypes.bool,
168
-
169
- /** Override background color of the Tooltip, provide design token, any color from palette or any valid css color value. */
170
- tooltipBgColor: PropTypes.string,
171
-
172
- /** Override font color of the Tooltip, provide design token, any color from palette or any valid css color value. */
173
- tooltipFontColor: PropTypes.string,
174
-
175
- /** Id passed to the tooltip container, used for accessibility purposes. */
176
- tooltipId: PropTypes.string,
177
-
178
- /** Overrides the default flip behaviour of the Tooltip, must be an array containing some or all of ["top", "bottom", "left", "right"].
179
- *
180
- * See the Popper [documentation](https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements) for more information
181
- * */
182
- tooltipFlipOverrides: (props, propName) => {
183
- const prop = props[propName];
184
- const isValid = prop && Array.isArray(prop) && prop.every(placement => ICON_TOOLTIP_POSITIONS.includes(placement));
185
-
186
- if (!prop || isValid) {
187
- return null;
188
- }
189
-
190
- return new Error( // eslint-disable-next-line max-len
191
- `The \`${propName}\` prop supplied to \`Icon\` must be an array containing some or all of ["top", "bottom", "left", "right"].`);
192
- },
193
-
194
- /** @ignore @private */
195
- isPartOfInput: PropTypes.bool,
196
-
197
- /** @ignore @private */
198
- inputSize: PropTypes.oneOf(["small", "medium", "large"]),
199
-
200
- /** @ignore @private */
201
- tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
202
-
203
- /** @ignore @private */
204
- focusable: PropTypes.bool,
205
-
206
- /** Id passed to the icon. */
207
- id: PropTypes.string
208
- };
209
- Icon.defaultProps = {
210
- bgSize: "small",
211
- fontSize: "small",
212
- disabled: false
123
+ "ariaLabel": PropTypes.string,
124
+ "bg": PropTypes.string,
125
+ "bgShape": PropTypes.oneOf(["circle", "rounded-rect", "square"]),
126
+ "bgSize": PropTypes.oneOf(["extra-large", "extra-small", "large", "medium", "small"]),
127
+ "className": PropTypes.string,
128
+ "color": PropTypes.string,
129
+ "disabled": PropTypes.bool,
130
+ "focusable": PropTypes.bool,
131
+ "fontSize": PropTypes.oneOf(["extra-large", "large", "medium", "small"]),
132
+ "id": PropTypes.string,
133
+ "inputSize": PropTypes.oneOf(["large", "medium", "small"]),
134
+ "isPartOfInput": PropTypes.bool,
135
+ "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
136
+ "__@toStringTag": PropTypes.string.isRequired,
137
+ "description": PropTypes.string,
138
+ "toString": PropTypes.func.isRequired,
139
+ "valueOf": PropTypes.func.isRequired
140
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
141
+ "__@toStringTag": PropTypes.string.isRequired,
142
+ "description": PropTypes.string,
143
+ "toString": PropTypes.func.isRequired,
144
+ "valueOf": PropTypes.func.isRequired
145
+ }), PropTypes.string]),
146
+ "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
147
+ "__@toStringTag": PropTypes.string.isRequired,
148
+ "description": PropTypes.string,
149
+ "toString": PropTypes.func.isRequired,
150
+ "valueOf": PropTypes.func.isRequired
151
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
152
+ "__@toStringTag": PropTypes.string.isRequired,
153
+ "description": PropTypes.string,
154
+ "toString": PropTypes.func.isRequired,
155
+ "valueOf": PropTypes.func.isRequired
156
+ }), PropTypes.string]),
157
+ "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
158
+ "__@toStringTag": PropTypes.string.isRequired,
159
+ "description": PropTypes.string,
160
+ "toString": PropTypes.func.isRequired,
161
+ "valueOf": PropTypes.func.isRequired
162
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
163
+ "__@toStringTag": PropTypes.string.isRequired,
164
+ "description": PropTypes.string,
165
+ "toString": PropTypes.func.isRequired,
166
+ "valueOf": PropTypes.func.isRequired
167
+ }), PropTypes.string]),
168
+ "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
169
+ "__@toStringTag": PropTypes.string.isRequired,
170
+ "description": PropTypes.string,
171
+ "toString": PropTypes.func.isRequired,
172
+ "valueOf": PropTypes.func.isRequired
173
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
174
+ "__@toStringTag": PropTypes.string.isRequired,
175
+ "description": PropTypes.string,
176
+ "toString": PropTypes.func.isRequired,
177
+ "valueOf": PropTypes.func.isRequired
178
+ }), PropTypes.string]),
179
+ "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
180
+ "__@toStringTag": PropTypes.string.isRequired,
181
+ "description": PropTypes.string,
182
+ "toString": PropTypes.func.isRequired,
183
+ "valueOf": PropTypes.func.isRequired
184
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
185
+ "__@toStringTag": PropTypes.string.isRequired,
186
+ "description": PropTypes.string,
187
+ "toString": PropTypes.func.isRequired,
188
+ "valueOf": PropTypes.func.isRequired
189
+ }), PropTypes.string]),
190
+ "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
191
+ "__@toStringTag": PropTypes.string.isRequired,
192
+ "description": PropTypes.string,
193
+ "toString": PropTypes.func.isRequired,
194
+ "valueOf": PropTypes.func.isRequired
195
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
196
+ "__@toStringTag": PropTypes.string.isRequired,
197
+ "description": PropTypes.string,
198
+ "toString": PropTypes.func.isRequired,
199
+ "valueOf": PropTypes.func.isRequired
200
+ }), PropTypes.string]),
201
+ "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
202
+ "__@toStringTag": PropTypes.string.isRequired,
203
+ "description": PropTypes.string,
204
+ "toString": PropTypes.func.isRequired,
205
+ "valueOf": PropTypes.func.isRequired
206
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
207
+ "__@toStringTag": PropTypes.string.isRequired,
208
+ "description": PropTypes.string,
209
+ "toString": PropTypes.func.isRequired,
210
+ "valueOf": PropTypes.func.isRequired
211
+ }), PropTypes.string]),
212
+ "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
213
+ "__@toStringTag": PropTypes.string.isRequired,
214
+ "description": PropTypes.string,
215
+ "toString": PropTypes.func.isRequired,
216
+ "valueOf": PropTypes.func.isRequired
217
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
218
+ "__@toStringTag": PropTypes.string.isRequired,
219
+ "description": PropTypes.string,
220
+ "toString": PropTypes.func.isRequired,
221
+ "valueOf": PropTypes.func.isRequired
222
+ }), PropTypes.string]),
223
+ "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
224
+ "__@toStringTag": PropTypes.string.isRequired,
225
+ "description": PropTypes.string,
226
+ "toString": PropTypes.func.isRequired,
227
+ "valueOf": PropTypes.func.isRequired
228
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
229
+ "__@toStringTag": PropTypes.string.isRequired,
230
+ "description": PropTypes.string,
231
+ "toString": PropTypes.func.isRequired,
232
+ "valueOf": PropTypes.func.isRequired
233
+ }), PropTypes.string]),
234
+ "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
235
+ "__@toStringTag": PropTypes.string.isRequired,
236
+ "description": PropTypes.string,
237
+ "toString": PropTypes.func.isRequired,
238
+ "valueOf": PropTypes.func.isRequired
239
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
240
+ "__@toStringTag": PropTypes.string.isRequired,
241
+ "description": PropTypes.string,
242
+ "toString": PropTypes.func.isRequired,
243
+ "valueOf": PropTypes.func.isRequired
244
+ }), PropTypes.string]),
245
+ "mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
246
+ "__@toStringTag": PropTypes.string.isRequired,
247
+ "description": PropTypes.string,
248
+ "toString": PropTypes.func.isRequired,
249
+ "valueOf": PropTypes.func.isRequired
250
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
251
+ "__@toStringTag": PropTypes.string.isRequired,
252
+ "description": PropTypes.string,
253
+ "toString": PropTypes.func.isRequired,
254
+ "valueOf": PropTypes.func.isRequired
255
+ }), PropTypes.string]),
256
+ "mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
257
+ "__@toStringTag": PropTypes.string.isRequired,
258
+ "description": PropTypes.string,
259
+ "toString": PropTypes.func.isRequired,
260
+ "valueOf": PropTypes.func.isRequired
261
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
262
+ "__@toStringTag": PropTypes.string.isRequired,
263
+ "description": PropTypes.string,
264
+ "toString": PropTypes.func.isRequired,
265
+ "valueOf": PropTypes.func.isRequired
266
+ }), PropTypes.string]),
267
+ "mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
268
+ "__@toStringTag": PropTypes.string.isRequired,
269
+ "description": PropTypes.string,
270
+ "toString": PropTypes.func.isRequired,
271
+ "valueOf": PropTypes.func.isRequired
272
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
273
+ "__@toStringTag": PropTypes.string.isRequired,
274
+ "description": PropTypes.string,
275
+ "toString": PropTypes.func.isRequired,
276
+ "valueOf": PropTypes.func.isRequired
277
+ }), PropTypes.string]),
278
+ "my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
279
+ "__@toStringTag": PropTypes.string.isRequired,
280
+ "description": PropTypes.string,
281
+ "toString": PropTypes.func.isRequired,
282
+ "valueOf": PropTypes.func.isRequired
283
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
284
+ "__@toStringTag": PropTypes.string.isRequired,
285
+ "description": PropTypes.string,
286
+ "toString": PropTypes.func.isRequired,
287
+ "valueOf": PropTypes.func.isRequired
288
+ }), PropTypes.string]),
289
+ "role": PropTypes.string,
290
+ "tabIndex": PropTypes.number,
291
+ "tooltipBgColor": PropTypes.string,
292
+ "tooltipFlipOverrides": PropTypes.arrayOf(PropTypes.oneOf(["bottom", "left", "right", "top"])),
293
+ "tooltipFontColor": PropTypes.string,
294
+ "tooltipId": PropTypes.string,
295
+ "tooltipMessage": PropTypes.node,
296
+ "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
297
+ "tooltipVisible": PropTypes.bool,
298
+ "type": PropTypes.oneOf(["add", "admin", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "arrow", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "go", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "maintenance", "marker", "message", "messages", "minus_large", "minus", "mobile", "money_bag", "new", "none", "old_warning", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "piggy_bank", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "success", "sync", "tag", "talk", "three_boxes", "tick_circle", "tick", "true_tick", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]).isRequired
213
299
  };
300
+ Icon.displayName = "Icon";
214
301
  export default Icon;
@@ -1,2 +1,38 @@
1
+ import { ThemeObject } from "../../style/themes/base";
2
+ import { IconType } from "./icon-type";
3
+ export declare type BackgroundShape = "circle" | "rounded-rect" | "square";
4
+ export declare type BgSize = "extra-small" | "small" | "medium" | "large" | "extra-large";
5
+ export declare type FontSize = "small" | "medium" | "large" | "extra-large";
6
+ export interface StyledIconProps {
7
+ /** Background colour, provide any color from palette or any valid css color value. */
8
+ bg?: string;
9
+ /** Background shape */
10
+ bgShape?: BackgroundShape;
11
+ /** Background size */
12
+ bgSize?: BgSize;
13
+ /**
14
+ * @private
15
+ * @ignore
16
+ * Add classes to this component
17
+ */
18
+ className?: string;
19
+ /** Icon colour, provide any color from palette or any valid css color value. */
20
+ color?: string;
21
+ /** Sets the icon in the disabled state */
22
+ disabled?: boolean;
23
+ /** Icon font size */
24
+ fontSize?: FontSize;
25
+ /**
26
+ * Icon type
27
+ *
28
+ * The full list of types can be seen [here](https://github.com/Sage/carbon/blob/master/src/components/icon/icon-config.js).
29
+ */
30
+ type: IconType;
31
+ }
32
+ export interface StyledIconInternalProps {
33
+ isInteractive?: boolean;
34
+ hasTooltip?: boolean;
35
+ theme?: ThemeObject;
36
+ }
37
+ declare const StyledIcon: import("styled-components").StyledComponent<"span", any, StyledIconProps & StyledIconInternalProps, never>;
1
38
  export default StyledIcon;
2
- declare const StyledIcon: import("styled-components").StyledComponent<"span", any, {}, never>;
@@ -1,38 +1,19 @@
1
1
  import styled, { css } from "styled-components";
2
- import PropTypes from "prop-types";
3
2
  import { shade } from "polished";
4
3
  import { margin } from "styled-system";
5
4
  import iconUnicodes from "./icon-unicodes";
6
5
  import baseTheme from "../../style/themes/base";
7
- import iconSizeConfig, { ICON_SHAPES } from "./icon-config";
6
+ import iconConfig from "./icon-config";
8
7
  import browserTypeCheck, { isSafari } from "../../__internal__/utils/helpers/browser-type-check";
9
8
  import styledColor from "../../style/utils/color";
10
9
  import getColorValue from "../../style/utils/get-color-value";
11
10
 
12
11
  function adjustIconBgSize(fontSize, bgSize) {
13
- var _replacements$fontSiz;
14
-
15
- const replacements = {
16
- medium: {
17
- small: "medium"
18
- },
19
- large: {
20
- small: "large",
21
- medium: "large"
22
- },
23
- "extra-large": {
24
- small: "extra-large",
25
- medium: "extra-large",
26
- large: "extra-large"
27
- }
28
- };
29
- const replacement = replacements === null || replacements === void 0 ? void 0 : (_replacements$fontSiz = replacements[fontSize]) === null || _replacements$fontSiz === void 0 ? void 0 : _replacements$fontSiz[bgSize];
30
-
31
- if (replacement) {
32
- return iconSizeConfig.backgroundSize[replacement];
12
+ if (fontSize && fontSize !== "small") {
13
+ return iconConfig.backgroundSize[fontSize];
33
14
  }
34
15
 
35
- return iconSizeConfig.backgroundSize[bgSize];
16
+ return bgSize ? iconConfig.backgroundSize[bgSize] : undefined;
36
17
  }
37
18
 
38
19
  const StyledIcon = styled.span`
@@ -99,7 +80,7 @@ const StyledIcon = styled.span`
99
80
  justify-content: center;
100
81
  height: ${adjustIconBgSize(fontSize, bgSize)};
101
82
  width: ${adjustIconBgSize(fontSize, bgSize)};
102
- border-radius: ${iconSizeConfig.backgroundShape[bgShape]};
83
+ ${bgShape ? `border-radius: ${iconConfig.backgroundShape[bgShape]}` : ""};
103
84
 
104
85
  ${isInteractive && css`
105
86
  &:hover {
@@ -114,12 +95,15 @@ const StyledIcon = styled.span`
114
95
 
115
96
  font-family: CarbonIcons;
116
97
  content: "${iconUnicodes[type]}";
117
- font-size: ${iconSizeConfig.iconSize[fontSize]};
118
98
  font-style: normal;
119
99
  font-weight: normal;
120
- line-height: ${iconSizeConfig.iconSize[fontSize]};
121
100
  vertical-align: middle;
122
101
 
102
+ ${fontSize && css`
103
+ font-size: ${iconConfig.iconSize[fontSize]};
104
+ line-height: ${iconConfig.iconSize[fontSize]};
105
+ `}
106
+
123
107
  ${type === "services" && browserTypeCheck(window) && css`
124
108
  margin-top: ${fontSize === "small" ? "-7px" : "-8px"};
125
109
  `}
@@ -141,15 +125,6 @@ const StyledIcon = styled.span`
141
125
  `;
142
126
  }}
143
127
  `;
144
- StyledIcon.propTypes = {
145
- theme: PropTypes.object,
146
- type: PropTypes.string,
147
- isInteractive: PropTypes.bool,
148
- disabled: PropTypes.bool,
149
- bgSize: PropTypes.oneOf(["extra-small", "small", "medium", "large", "extra-large"]),
150
- bgShape: PropTypes.oneOf(ICON_SHAPES),
151
- fontSize: PropTypes.oneOf(["small", "medium", "large", "extra-large"])
152
- };
153
128
  StyledIcon.defaultProps = {
154
129
  theme: baseTheme
155
130
  };
@@ -1,2 +1,3 @@
1
- export { default } from "./icon";
2
- export * from "./icon";
1
+ export { default } from "./icon.component";
2
+ export type { IconProps } from "./icon.component";
3
+ export type { IconType } from "./icon-type";
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { MarginProps } from "styled-system";
3
- import { IconProps } from "../icon/icon";
3
+ import { IconProps } from "../icon/icon-type";
4
4
 
5
5
  export interface IconButtonProps extends MarginProps {
6
6
  /** Optional: alternative rendered content, displayed within <SelectList> of <Select> (eg: an icon, an image, etc) */
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { IconType } from "components/icon/icon";
2
+ import { IconType } from "components/icon/icon-type";
3
3
  export interface LinkProps extends React.AriaAttributes {
4
4
  /** The disabled state of the link. */
5
5
  disabled?: boolean;
@@ -34,5 +34,5 @@ export interface LinkProps extends React.AriaAttributes {
34
34
  /** allows to set rel property in <a> tag */
35
35
  rel?: string;
36
36
  }
37
- export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLLinkElement | HTMLButtonElement>>;
37
+ export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLButtonElement | HTMLLinkElement>>;
38
38
  export default Link;
@@ -153,7 +153,7 @@ Link.propTypes = {
153
153
  "className": PropTypes.string,
154
154
  "disabled": PropTypes.bool,
155
155
  "href": PropTypes.string,
156
- "icon": PropTypes.oneOf(["add", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "copy", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "messages", "minus_large", "minus", "mobile", "money_bag", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "three_boxes", "tick_circle", "tick", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
156
+ "icon": PropTypes.oneOf(["add", "admin", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "arrow", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "go", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "piggy_bank", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "three_boxes", "tick_circle", "tick", "true_tick", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
157
157
  "iconAlign": PropTypes.oneOf(["left", "right"]),
158
158
  "isSkipLink": PropTypes.bool,
159
159
  "onClick": PropTypes.func,
@@ -1,4 +1,4 @@
1
- import { IconType } from "components/icon/icon";
1
+ import { IconType } from "components/icon/icon-type";
2
2
  import * as React from "react";
3
3
  import { FlexboxProps, LayoutProps } from "styled-system";
4
4