carbon-react 109.1.3 → 109.2.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 (37) hide show
  1. package/esm/components/badge/badge.style.d.ts +1 -4
  2. package/esm/components/button/button.component.d.ts +1 -4
  3. package/esm/components/button/button.component.js +26 -12
  4. package/esm/components/duelling-picklist/picklist-group/picklist-group.style.js +2 -2
  5. package/esm/components/duelling-picklist/picklist-item/picklist-item.style.js +2 -2
  6. package/esm/components/multi-action-button/multi-action-button.component.js +1 -6
  7. package/esm/components/pill/index.d.ts +2 -1
  8. package/esm/components/pill/pill.component.d.ts +22 -0
  9. package/esm/components/pill/pill.component.js +219 -42
  10. package/esm/components/pill/pill.style.config.d.ts +18 -0
  11. package/esm/components/pill/pill.style.d.ts +22 -0
  12. package/esm/components/pill/pill.style.js +23 -22
  13. package/esm/components/search/search.style.js +22 -8
  14. package/esm/components/select/multi-select/multi-select.component.js +7 -2
  15. package/esm/components/select/multi-select/multi-select.d.ts +2 -0
  16. package/esm/components/select/multi-select/multi-select.style.js +1 -0
  17. package/esm/components/split-button/split-button.component.js +1 -6
  18. package/lib/components/badge/badge.style.d.ts +1 -4
  19. package/lib/components/button/button.component.d.ts +1 -4
  20. package/lib/components/button/button.component.js +29 -10
  21. package/lib/components/duelling-picklist/picklist-group/picklist-group.style.js +4 -2
  22. package/lib/components/duelling-picklist/picklist-item/picklist-item.style.js +2 -2
  23. package/lib/components/multi-action-button/multi-action-button.component.js +1 -6
  24. package/lib/components/pill/index.d.ts +2 -1
  25. package/lib/components/pill/pill.component.d.ts +22 -0
  26. package/lib/components/pill/pill.component.js +220 -46
  27. package/lib/components/pill/pill.style.config.d.ts +18 -0
  28. package/lib/components/pill/pill.style.d.ts +22 -0
  29. package/lib/components/pill/pill.style.js +23 -23
  30. package/lib/components/search/search.style.js +22 -8
  31. package/lib/components/select/multi-select/multi-select.component.js +7 -2
  32. package/lib/components/select/multi-select/multi-select.d.ts +2 -0
  33. package/lib/components/select/multi-select/multi-select.style.js +1 -0
  34. package/lib/components/split-button/split-button.component.js +1 -6
  35. package/package.json +4 -4
  36. package/esm/components/pill/pill.d.ts +0 -24
  37. package/lib/components/pill/pill.d.ts +0 -24
@@ -1,9 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  declare const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
3
  declare const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- declare const StyledButton: import("styled-components").StyledComponent<{
5
- ({ size, subtext, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: import("../button").ButtonProps): JSX.Element;
6
- displayName: string;
7
- }, any, {}, never>;
4
+ declare const StyledButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, {}, never>;
8
5
  declare const StyledCrossIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
9
6
  export { StyledBadgeWrapper, StyledButton, StyledCrossIcon, StyledCounter };
@@ -58,10 +58,7 @@ export interface ButtonProps extends SpaceProps {
58
58
  /** HTML rel attribute */
59
59
  rel?: string;
60
60
  }
61
- declare const Button: {
62
- ({ size, subtext, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: ButtonProps): JSX.Element;
63
- displayName: string;
64
- };
61
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
65
62
  declare const ButtonWithForwardRef: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
66
63
  export { ButtonWithForwardRef };
67
64
  export default Button;
@@ -7,6 +7,7 @@ import Icon from "../icon";
7
7
  import StyledButton, { StyledButtonSubtext } from "./button.style";
8
8
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
9
9
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
10
+ import Logger from "../../__internal__/utils/logger";
10
11
 
11
12
  function renderChildren({
12
13
  /* eslint-disable react/prop-types */
@@ -73,8 +74,8 @@ renderChildren.propTypes = {
73
74
  }
74
75
  }
75
76
  };
76
-
77
- const Button = ({
77
+ let deprecatedForwardRefWarnTriggered = false;
78
+ const Button = /*#__PURE__*/React.forwardRef(({
78
79
  size = "medium",
79
80
  subtext = "",
80
81
  children,
@@ -95,13 +96,18 @@ const Button = ({
95
96
  iconTooltipPosition,
96
97
  fullWidth = false,
97
98
  ...rest
98
- }) => {
99
+ }, ref) => {
99
100
  invariant(!!(children || iconType), "Either prop `iconType` must be defined or this node must have children.");
100
101
 
101
102
  if (subtext) {
102
103
  invariant(size === "large", "subtext prop has no effect unless the button is large.");
103
104
  }
104
105
 
106
+ if (!deprecatedForwardRefWarnTriggered && forwardRef) {
107
+ deprecatedForwardRefWarnTriggered = true;
108
+ Logger.deprecate("The `forwardRef` prop in `Button` component is deprecated and will soon be removed. Please use `ref` instead.");
109
+ }
110
+
105
111
  const [internalRef, setInternalRef] = useState();
106
112
  const buttonType = buttonTypeProp;
107
113
  let paddingX;
@@ -129,10 +135,11 @@ const Button = ({
129
135
 
130
136
  const setRefs = useCallback(reference => {
131
137
  setInternalRef(reference);
132
- if (!forwardRef) return;
133
- if (typeof forwardRef === "object") forwardRef.current = reference;
134
- if (typeof forwardRef === "function") forwardRef(reference);
135
- }, [forwardRef]);
138
+ const activeRef = ref || forwardRef;
139
+ if (!activeRef) return;
140
+ if (typeof activeRef === "object") activeRef.current = reference;
141
+ if (typeof activeRef === "function") activeRef(reference);
142
+ }, [ref, forwardRef]);
136
143
  return /*#__PURE__*/React.createElement(StyledButton, _extends({
137
144
  "aria-label": !children && iconType ? ariaLabel || iconType : undefined,
138
145
  as: !disabled && href ? "a" : "button",
@@ -169,8 +176,7 @@ const Button = ({
169
176
  iconTooltipPosition,
170
177
  tooltipTarget: internalRef
171
178
  }));
172
- };
173
-
179
+ });
174
180
  Button.propTypes = {
175
181
  "aria-label": PropTypes.string,
176
182
  "buttonType": PropTypes.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
@@ -507,9 +513,17 @@ Button.propTypes = {
507
513
  "target": PropTypes.string,
508
514
  "type": PropTypes.string
509
515
  };
510
- const ButtonWithForwardRef = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(Button, _extends({
511
- forwardRef: ref
512
- }, props)));
516
+ let deprecatedButtonForwardRefWarnTriggered = false;
517
+ const ButtonWithForwardRef = /*#__PURE__*/React.forwardRef((props, ref) => {
518
+ if (!deprecatedButtonForwardRefWarnTriggered) {
519
+ deprecatedButtonForwardRefWarnTriggered = true;
520
+ Logger.deprecate("The `ButtonWithForwardRef` component is deprecated and will soon be removed. Please use a basic `Button` component with `ref` instead.");
521
+ }
522
+
523
+ return /*#__PURE__*/React.createElement(Button, _extends({
524
+ ref: ref
525
+ }, props));
526
+ });
513
527
  ButtonWithForwardRef.propTypes = {
514
528
  "aria-label": PropTypes.string,
515
529
  "buttonType": PropTypes.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
@@ -1,5 +1,5 @@
1
1
  import styled, { css } from "styled-components";
2
- import { ButtonWithForwardRef } from "../../button";
2
+ import Button from "../../button";
3
3
  import { StyledButton } from "../picklist-item/picklist-item.style";
4
4
  const StyledGroupWrapper = styled.li`
5
5
  ${({
@@ -25,7 +25,7 @@ const StyledPicklistGroup = styled.li`
25
25
  width: 100%;
26
26
  margin-bottom: 4px;
27
27
  `;
28
- const StyledGroupButton = styled(ButtonWithForwardRef)`
28
+ const StyledGroupButton = styled(Button)`
29
29
  ${({
30
30
  iconType
31
31
  }) => css`
@@ -1,5 +1,5 @@
1
1
  import styled, { css } from "styled-components";
2
- import { ButtonWithForwardRef } from "../../button";
2
+ import Button from "../../button";
3
3
  import Icon from "../../icon";
4
4
  import StyledIcon from "../../icon/icon.style";
5
5
  const StyledPicklistItem = styled.li`
@@ -30,7 +30,7 @@ const StyledPicklistItem = styled.li`
30
30
  }
31
31
  `}
32
32
  `;
33
- const StyledButton = styled(ButtonWithForwardRef)`
33
+ const StyledButton = styled(Button)`
34
34
  ${({
35
35
  iconType
36
36
  }) => css`
@@ -4,7 +4,7 @@ import React, { useCallback, useEffect, useState, useRef, useMemo } from "react"
4
4
  import PropTypes from "prop-types";
5
5
  import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
6
6
  import { StyledMultiActionButton, StyledButtonChildrenContainer } from "./multi-action-button.style";
7
- import Button, { ButtonWithForwardRef } from "../button";
7
+ import Button from "../button";
8
8
  import Events from "../../__internal__/utils/helpers/events";
9
9
  import Popover from "../../__internal__/popover";
10
10
  import { filterStyledSystemMarginProps, filterOutStyledSystemSpacingProps } from "../../style/utils";
@@ -67,11 +67,6 @@ const MultiActionButton = ({
67
67
  (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
68
68
  }
69
69
  };
70
-
71
- if (child.type === Button) {
72
- return /*#__PURE__*/React.createElement(ButtonWithForwardRef, _extends({}, child.props, props));
73
- }
74
-
75
70
  return /*#__PURE__*/React.cloneElement(child, props);
76
71
  });
77
72
  };
@@ -1 +1,2 @@
1
- export { default } from "./pill";
1
+ export { default } from "./pill.component";
2
+ export type { PillProps } from "./pill.component";
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import { StyledPillProps } from "./pill.style";
3
+ export interface PillProps extends StyledPillProps {
4
+ /** The content to display inside of the pill. */
5
+ children: string;
6
+ /** Change the color of a status pill. */
7
+ colorVariant?: "neutral" | "negative" | "positive" | "warning";
8
+ /** Identifier used for testing purposes, applied to the root element of the component. */
9
+ "data-element"?: string;
10
+ /** Identifier used for testing purposes, applied to the root element of the component. */
11
+ "data-role"?: string;
12
+ /** Fills the pill background with colour. When fill is false only the border is coloured. */
13
+ fill?: boolean;
14
+ /** Callback function for when the pill is clicked. */
15
+ onClick?: React.MouseEventHandler<HTMLSpanElement>;
16
+ /** Callback function for when the remove icon is clicked. */
17
+ onDelete?: React.MouseEventHandler<HTMLButtonElement>;
18
+ /** Sets the type of pill in use. */
19
+ pillRole?: "tag" | "status";
20
+ }
21
+ export declare const Pill: ({ wrapText, borderColor, colorVariant, children, fill, maxWidth, onClick, onDelete, pillRole, size, ...rest }: PillProps) => JSX.Element;
22
+ export default Pill;
@@ -2,13 +2,10 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React from "react";
4
4
  import PropTypes from "prop-types";
5
- import styledSystemPropTypes from "@styled-system/prop-types";
6
5
  import StyledPill from "./pill.style";
7
6
  import Icon from "../icon";
8
7
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
9
8
  import IconButton from "../icon-button";
10
- import { filterStyledSystemMarginProps } from "../../style/utils";
11
- const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
12
9
 
13
10
  const renderCloseIcon = onDelete => /*#__PURE__*/React.createElement(IconButton, {
14
11
  onAction: onDelete,
@@ -19,57 +16,237 @@ const renderCloseIcon = onDelete => /*#__PURE__*/React.createElement(IconButton,
19
16
  }));
20
17
 
21
18
  const Pill = ({
22
- fill,
23
- onDelete,
24
- colorVariant,
19
+ wrapText,
25
20
  borderColor,
26
- pillRole,
21
+ colorVariant = "neutral",
27
22
  children,
28
- size,
23
+ fill = false,
24
+ maxWidth,
29
25
  onClick,
26
+ onDelete,
27
+ pillRole = "tag",
28
+ size = "M",
30
29
  ...rest
31
30
  }) => /*#__PURE__*/React.createElement(StyledPill, _extends({
32
31
  inFill: fill,
33
32
  colorVariant: colorVariant,
34
- isDeletable: onDelete,
33
+ isDeletable: !!onDelete,
35
34
  pillRole: pillRole,
36
35
  size: size,
37
36
  borderColor: borderColor,
38
37
  onClick: onClick
39
- }, tagComponent("pill", rest), rest), children, onDelete && renderCloseIcon(onDelete));
38
+ }, tagComponent("pill", rest), {
39
+ maxWidth: maxWidth,
40
+ wrapText: wrapText
41
+ }, rest), children, onDelete && renderCloseIcon(onDelete));
40
42
 
41
43
  Pill.propTypes = {
42
- /** Filtered styled system margin props */
43
- ...marginPropTypes,
44
-
45
- /** Change the color of a status pill. */
46
- colorVariant: PropTypes.oneOf(["neutral", "negative", "positive", "warning"]),
47
-
48
- /** Override color variant, provide design token, any color from palette or any valid css color value. */
49
- borderColor: PropTypes.string,
50
-
51
- /** The content to display inside of the pill. */
52
- children: PropTypes.string.isRequired,
53
-
54
- /** Fills the pill background with colour. When fill is false only the border is coloured. */
55
- fill: PropTypes.bool,
56
-
57
- /** Sets the type of pill in use. */
58
- pillRole: PropTypes.oneOf(["tag", "status"]),
59
-
60
- /** Callback function for when the pill is clicked. */
61
- onClick: PropTypes.func,
62
-
63
- /** Callback function for when the remove icon is clicked. */
64
- onDelete: PropTypes.func,
65
- size: PropTypes.oneOf(["S", "M", "L", "XL"])
66
- };
67
- Pill.defaultProps = {
68
- colorVariant: "neutral",
69
- fill: false,
70
- onClick: null,
71
- onDelete: null,
72
- pillRole: "tag",
73
- size: "M"
44
+ "borderColor": PropTypes.string,
45
+ "children": PropTypes.string.isRequired,
46
+ "colorVariant": PropTypes.oneOf(["negative", "neutral", "positive", "warning"]),
47
+ "data-element": PropTypes.string,
48
+ "data-role": PropTypes.string,
49
+ "fill": PropTypes.bool,
50
+ "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
51
+ "__@toStringTag": PropTypes.string.isRequired,
52
+ "description": PropTypes.string,
53
+ "toString": PropTypes.func.isRequired,
54
+ "valueOf": PropTypes.func.isRequired
55
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
56
+ "__@toStringTag": PropTypes.string.isRequired,
57
+ "description": PropTypes.string,
58
+ "toString": PropTypes.func.isRequired,
59
+ "valueOf": PropTypes.func.isRequired
60
+ }), PropTypes.string]),
61
+ "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
62
+ "__@toStringTag": PropTypes.string.isRequired,
63
+ "description": PropTypes.string,
64
+ "toString": PropTypes.func.isRequired,
65
+ "valueOf": PropTypes.func.isRequired
66
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
67
+ "__@toStringTag": PropTypes.string.isRequired,
68
+ "description": PropTypes.string,
69
+ "toString": PropTypes.func.isRequired,
70
+ "valueOf": PropTypes.func.isRequired
71
+ }), PropTypes.string]),
72
+ "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
73
+ "__@toStringTag": PropTypes.string.isRequired,
74
+ "description": PropTypes.string,
75
+ "toString": PropTypes.func.isRequired,
76
+ "valueOf": PropTypes.func.isRequired
77
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
78
+ "__@toStringTag": PropTypes.string.isRequired,
79
+ "description": PropTypes.string,
80
+ "toString": PropTypes.func.isRequired,
81
+ "valueOf": PropTypes.func.isRequired
82
+ }), PropTypes.string]),
83
+ "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
84
+ "__@toStringTag": PropTypes.string.isRequired,
85
+ "description": PropTypes.string,
86
+ "toString": PropTypes.func.isRequired,
87
+ "valueOf": PropTypes.func.isRequired
88
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
89
+ "__@toStringTag": PropTypes.string.isRequired,
90
+ "description": PropTypes.string,
91
+ "toString": PropTypes.func.isRequired,
92
+ "valueOf": PropTypes.func.isRequired
93
+ }), PropTypes.string]),
94
+ "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
95
+ "__@toStringTag": PropTypes.string.isRequired,
96
+ "description": PropTypes.string,
97
+ "toString": PropTypes.func.isRequired,
98
+ "valueOf": PropTypes.func.isRequired
99
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
100
+ "__@toStringTag": PropTypes.string.isRequired,
101
+ "description": PropTypes.string,
102
+ "toString": PropTypes.func.isRequired,
103
+ "valueOf": PropTypes.func.isRequired
104
+ }), PropTypes.string]),
105
+ "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
106
+ "__@toStringTag": PropTypes.string.isRequired,
107
+ "description": PropTypes.string,
108
+ "toString": PropTypes.func.isRequired,
109
+ "valueOf": PropTypes.func.isRequired
110
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
111
+ "__@toStringTag": PropTypes.string.isRequired,
112
+ "description": PropTypes.string,
113
+ "toString": PropTypes.func.isRequired,
114
+ "valueOf": PropTypes.func.isRequired
115
+ }), PropTypes.string]),
116
+ "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
117
+ "__@toStringTag": PropTypes.string.isRequired,
118
+ "description": PropTypes.string,
119
+ "toString": PropTypes.func.isRequired,
120
+ "valueOf": PropTypes.func.isRequired
121
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
122
+ "__@toStringTag": PropTypes.string.isRequired,
123
+ "description": PropTypes.string,
124
+ "toString": PropTypes.func.isRequired,
125
+ "valueOf": PropTypes.func.isRequired
126
+ }), PropTypes.string]),
127
+ "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
128
+ "__@toStringTag": PropTypes.string.isRequired,
129
+ "description": PropTypes.string,
130
+ "toString": PropTypes.func.isRequired,
131
+ "valueOf": PropTypes.func.isRequired
132
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
133
+ "__@toStringTag": PropTypes.string.isRequired,
134
+ "description": PropTypes.string,
135
+ "toString": PropTypes.func.isRequired,
136
+ "valueOf": PropTypes.func.isRequired
137
+ }), PropTypes.string]),
138
+ "maxWidth": PropTypes.string,
139
+ "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
140
+ "__@toStringTag": PropTypes.string.isRequired,
141
+ "description": PropTypes.string,
142
+ "toString": PropTypes.func.isRequired,
143
+ "valueOf": PropTypes.func.isRequired
144
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
145
+ "__@toStringTag": PropTypes.string.isRequired,
146
+ "description": PropTypes.string,
147
+ "toString": PropTypes.func.isRequired,
148
+ "valueOf": PropTypes.func.isRequired
149
+ }), PropTypes.string]),
150
+ "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
151
+ "__@toStringTag": PropTypes.string.isRequired,
152
+ "description": PropTypes.string,
153
+ "toString": PropTypes.func.isRequired,
154
+ "valueOf": PropTypes.func.isRequired
155
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
156
+ "__@toStringTag": PropTypes.string.isRequired,
157
+ "description": PropTypes.string,
158
+ "toString": PropTypes.func.isRequired,
159
+ "valueOf": PropTypes.func.isRequired
160
+ }), PropTypes.string]),
161
+ "mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
162
+ "__@toStringTag": PropTypes.string.isRequired,
163
+ "description": PropTypes.string,
164
+ "toString": PropTypes.func.isRequired,
165
+ "valueOf": PropTypes.func.isRequired
166
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
167
+ "__@toStringTag": PropTypes.string.isRequired,
168
+ "description": PropTypes.string,
169
+ "toString": PropTypes.func.isRequired,
170
+ "valueOf": PropTypes.func.isRequired
171
+ }), PropTypes.string]),
172
+ "mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
173
+ "__@toStringTag": PropTypes.string.isRequired,
174
+ "description": PropTypes.string,
175
+ "toString": PropTypes.func.isRequired,
176
+ "valueOf": PropTypes.func.isRequired
177
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
178
+ "__@toStringTag": PropTypes.string.isRequired,
179
+ "description": PropTypes.string,
180
+ "toString": PropTypes.func.isRequired,
181
+ "valueOf": PropTypes.func.isRequired
182
+ }), PropTypes.string]),
183
+ "mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
184
+ "__@toStringTag": PropTypes.string.isRequired,
185
+ "description": PropTypes.string,
186
+ "toString": PropTypes.func.isRequired,
187
+ "valueOf": PropTypes.func.isRequired
188
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
189
+ "__@toStringTag": PropTypes.string.isRequired,
190
+ "description": PropTypes.string,
191
+ "toString": PropTypes.func.isRequired,
192
+ "valueOf": PropTypes.func.isRequired
193
+ }), PropTypes.string]),
194
+ "my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
195
+ "__@toStringTag": PropTypes.string.isRequired,
196
+ "description": PropTypes.string,
197
+ "toString": PropTypes.func.isRequired,
198
+ "valueOf": PropTypes.func.isRequired
199
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
200
+ "__@toStringTag": PropTypes.string.isRequired,
201
+ "description": PropTypes.string,
202
+ "toString": PropTypes.func.isRequired,
203
+ "valueOf": PropTypes.func.isRequired
204
+ }), PropTypes.string]),
205
+ "onClick": PropTypes.func,
206
+ "onDelete": PropTypes.func,
207
+ "pillRole": PropTypes.oneOf(["status", "tag"]),
208
+ "size": PropTypes.oneOf(["L", "M", "S", "XL"]),
209
+ "theme": PropTypes.shape({
210
+ "colors": PropTypes.shape({
211
+ "destructive": PropTypes.shape({
212
+ "hover": PropTypes.string.isRequired
213
+ }),
214
+ "error": PropTypes.string,
215
+ "focus": PropTypes.string,
216
+ "info": PropTypes.string,
217
+ "loadingBarBackground": PropTypes.string,
218
+ "placeholder": PropTypes.string,
219
+ "primary": PropTypes.string,
220
+ "secondary": PropTypes.string,
221
+ "tertiary": PropTypes.string,
222
+ "warning": PropTypes.string,
223
+ "warningText": PropTypes.string,
224
+ "white": PropTypes.oneOf(["#FFFFFF"])
225
+ }),
226
+ "compatibility": PropTypes.object,
227
+ "disabled": PropTypes.shape({
228
+ "background": PropTypes.string.isRequired
229
+ }),
230
+ "name": PropTypes.string,
231
+ "palette": PropTypes.shape({
232
+ "blackOpacity": PropTypes.func.isRequired,
233
+ "whiteOpacity": PropTypes.func.isRequired
234
+ }),
235
+ "space": PropTypes.arrayOf(PropTypes.string),
236
+ "spacing": PropTypes.number,
237
+ "zIndex": PropTypes.shape({
238
+ "aboveAll": PropTypes.number.isRequired,
239
+ "fullScreenModal": PropTypes.number.isRequired,
240
+ "header": PropTypes.number.isRequired,
241
+ "modal": PropTypes.number.isRequired,
242
+ "nav": PropTypes.number.isRequired,
243
+ "notification": PropTypes.number.isRequired,
244
+ "overlay": PropTypes.number.isRequired,
245
+ "popover": PropTypes.number.isRequired,
246
+ "smallOverlay": PropTypes.number.isRequired
247
+ })
248
+ }),
249
+ "wrapText": PropTypes.bool
74
250
  };
251
+ export { Pill };
75
252
  export default Pill;
@@ -0,0 +1,18 @@
1
+ interface StyledPillInnerConfigProps {
2
+ varietyColor: string;
3
+ buttonFocus: string;
4
+ content: string;
5
+ }
6
+ interface StyledPillConfig {
7
+ status: {
8
+ neutral: StyledPillInnerConfigProps;
9
+ negative: StyledPillInnerConfigProps;
10
+ warning: StyledPillInnerConfigProps;
11
+ positive: StyledPillInnerConfigProps;
12
+ };
13
+ tag: {
14
+ primary: StyledPillInnerConfigProps;
15
+ };
16
+ }
17
+ declare const _default: () => StyledPillConfig;
18
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import { MarginProps } from "styled-system";
2
+ import { ThemeObject } from "../../style/themes/base/base-theme.config";
3
+ export interface StyledPillProps extends MarginProps {
4
+ /** Override color variant, provide any color from palette or any valid css color value. */
5
+ borderColor?: string;
6
+ /** Sets the max-width of the pill. */
7
+ maxWidth?: string;
8
+ /** Sets the size of the pill. */
9
+ size?: "S" | "M" | "L" | "XL";
10
+ /** @private @ignore */
11
+ theme?: Partial<ThemeObject>;
12
+ /** Allow the text within pill to wrap. */
13
+ wrapText?: boolean;
14
+ }
15
+ interface AllStyledPillProps extends StyledPillProps {
16
+ inFill?: boolean;
17
+ isDeletable: boolean;
18
+ colorVariant: "neutral" | "negative" | "positive" | "warning";
19
+ pillRole: "tag" | "status";
20
+ }
21
+ declare const StyledPill: import("styled-components").StyledComponent<"span", any, AllStyledPillProps, never>;
22
+ export default StyledPill;
@@ -1,5 +1,4 @@
1
1
  import styled, { css } from "styled-components";
2
- import PropTypes from "prop-types";
3
2
  import { shade, meetsContrastGuidelines } from "polished";
4
3
  import { margin } from "styled-system";
5
4
  import styleConfig from "./pill.style.config";
@@ -18,19 +17,20 @@ function addStyleToPillIcon(fontSize) {
18
17
  `;
19
18
  }
20
19
 
21
- const PillStyle = styled.span`
22
- ${margin};
20
+ const StyledPill = styled.span`
21
+ ${margin}
23
22
  ${({
24
- colorVariant,
23
+ wrapText,
25
24
  borderColor,
26
- theme,
27
- inFill,
25
+ colorVariant,
28
26
  isDeletable,
27
+ inFill,
28
+ maxWidth,
29
29
  pillRole,
30
- size
30
+ size,
31
+ theme
31
32
  }) => {
32
33
  const isStatus = pillRole === "status";
33
- const variety = isStatus ? colorVariant : "primary";
34
34
  let pillColor;
35
35
  let buttonFocusColor;
36
36
  let contentColor;
@@ -41,11 +41,15 @@ const PillStyle = styled.span`
41
41
  buttonFocusColor = shade(0.2, getColorValue(pillColor));
42
42
  contentColor = meetsContrastGuidelines(getColorValue(pillColor), theme.compatibility.colorsUtilityYin090).AAA ? "var(--colorsUtilityYin090)" : "var(--colorsUtilityYang100)";
43
43
  } else {
44
+ const {
45
+ status,
46
+ tag
47
+ } = styleConfig();
44
48
  const {
45
49
  varietyColor,
46
50
  buttonFocus,
47
51
  content
48
- } = styleConfig(theme)[pillRole][variety];
52
+ } = isStatus ? status[colorVariant] : tag.primary;
49
53
  pillColor = varietyColor;
50
54
  buttonFocusColor = buttonFocus;
51
55
  contentColor = content;
@@ -67,7 +71,13 @@ const PillStyle = styled.span`
67
71
  justify-content: center;
68
72
  border: 2px solid ${pillColor};
69
73
  height: auto;
70
- white-space: nowrap;
74
+ ${!wrapText && css`
75
+ white-space: nowrap;
76
+ `}
77
+ ${wrapText && css`
78
+ white-space: break-spaces;
79
+ hyphens: auto;
80
+ `}
71
81
  color: ${contentColor};
72
82
 
73
83
  ${inFill && css`
@@ -257,22 +267,13 @@ const PillStyle = styled.span`
257
267
  }
258
268
  `}
259
269
  `}
270
+ ${maxWidth && `max-width: ${maxWidth}`}
260
271
  `;
261
272
  }}
262
273
  `;
263
- PillStyle.defaultProps = {
274
+ StyledPill.defaultProps = {
264
275
  inFill: false,
265
- colorVariant: "default",
266
276
  isDeletable: false,
267
277
  theme: baseTheme
268
278
  };
269
- PillStyle.propTypes = {
270
- inFill: PropTypes.bool,
271
- colorVariant: PropTypes.oneOf(["neutral", "negative", "positive", "warning"]),
272
- isDeletable: PropTypes.func,
273
- size: PropTypes.oneOf(["S", "M", "L", "XL"]),
274
- pillRole: PropTypes.oneOf(["tag", "status"]),
275
- borderColor: PropTypes.string,
276
- theme: PropTypes.object
277
- };
278
- export default PillStyle;
279
+ export default StyledPill;
@@ -97,20 +97,34 @@ const StyledSearch = styled.div`
97
97
  z-index: ${theme.zIndex.smallOverlay};
98
98
  }
99
99
  ${StyledIcon} {
100
- color: ${iconColor ? "var(--colorsUtilityMajor400)" : "var(--colorsUtilityMajor200)"};
100
+ ${darkVariant && css`
101
+ ${iconColor && css`
102
+ color: var(--colorsUtilityMajor400);
103
+
104
+ :hover {
105
+ color: var(--colorsUtilityMajor500);
106
+ }
107
+ `}
108
+ ${!iconColor && css`
109
+ color: var(--colorsUtilityMajor200);
110
+
111
+ :hover {
112
+ color: var(--colorsUtilityMajor100);
113
+ }
114
+ `}
115
+ `}
116
+
101
117
  ${!darkVariant && css`
102
- color: var(--colorsUtilityMajor400);
118
+ color: var(--colorsActionMinor500);
119
+
120
+ :hover {
121
+ color: var(--colorsActionMinor600);
122
+ }
103
123
  `}
104
124
 
105
125
  width: 20px;
106
126
  height: 20px;
107
127
  cursor: pointer;
108
- :hover {
109
- color: ${iconColor ? "var(--colorsUtilityMajor500)" : "var(--colorsUtilityMajor100)"};
110
- ${!darkVariant && css`
111
- color: var(--colorsUtilityMajor500);
112
- `}
113
- }
114
128
  }
115
129
 
116
130
  ${StyledInputIconToggle} {