@sproutsocial/racine 11.3.0-beta.0 → 11.3.0-beta.3

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.
@@ -72,16 +72,31 @@ describe("Input", () => {
72
72
  describe("Input.ClearButton", () => {
73
73
  describe("Input type=search", () => {
74
74
  it("should render a clear button for search Inputs", () => {
75
- const { getByTitle } = render(
75
+ const { getByRole } = render(
76
76
  <Input
77
77
  id="name"
78
78
  name="name"
79
79
  value="mic"
80
80
  type="search"
81
+ onClear={jest.fn()}
82
+ clearButtonLabel="Clear search"
83
+ />
84
+ );
85
+ expect(getByRole("button")).toBeTruthy();
86
+ });
87
+
88
+ it("should not render a clear button for search Inputs if there is no text", () => {
89
+ const { queryByRole } = render(
90
+ <Input
91
+ id="name"
92
+ name="name"
93
+ value=""
94
+ type="search"
95
+ onClear={jest.fn()}
81
96
  clearButtonLabel="Clear search"
82
97
  />
83
98
  );
84
- expect(getByTitle("Clear search")).toBeTruthy();
99
+ expect(queryByRole("button")).toBeFalsy();
85
100
  });
86
101
 
87
102
  it("should not override an elemAfter prop if passed", () => {
@@ -91,6 +106,7 @@ describe("Input", () => {
91
106
  name="name"
92
107
  value="mic"
93
108
  type="search"
109
+ onClear={jest.fn()}
94
110
  elemAfter={<Text>After</Text>}
95
111
  />
96
112
  );
@@ -99,42 +115,32 @@ describe("Input", () => {
99
115
  });
100
116
 
101
117
  it("should use the fallback title if clearButtonLabel is not provided", () => {
102
- const { getByTitle } = render(
103
- <Input id="name" name="name" value="mic" type="search" />
104
- );
105
- expect(getByTitle("Clear")).toBeTruthy();
106
- });
107
-
108
- it("should call onClear when clicked", () => {
109
- const mockOnClear = jest.fn();
110
118
  const { getByTitle } = render(
111
119
  <Input
112
120
  id="name"
113
121
  name="name"
114
122
  value="mic"
115
123
  type="search"
116
- onClear={mockOnClear}
117
- clearButtonLabel="Clear search"
124
+ onClear={jest.fn()}
118
125
  />
119
126
  );
120
- fireEvent.click(getByTitle("Clear search"));
121
- expect(mockOnClear).toHaveBeenCalled();
127
+ expect(getByTitle("Clear")).toBeTruthy();
122
128
  });
123
129
 
124
- it("should call onChange when clicked if there is no onClear prop", () => {
125
- const mockOnChange = jest.fn();
126
- const { getByTitle } = render(
130
+ it("should call onClear when clicked", () => {
131
+ const mockOnClear = jest.fn();
132
+ const { getByRole } = render(
127
133
  <Input
128
134
  id="name"
129
135
  name="name"
130
136
  value="mic"
131
137
  type="search"
132
- onChange={mockOnChange}
138
+ onClear={mockOnClear}
133
139
  clearButtonLabel="Clear search"
134
140
  />
135
141
  );
136
- fireEvent.click(getByTitle("Clear search"));
137
- expect(mockOnChange).toHaveBeenLastCalledWith(expect.anything(), "");
142
+ fireEvent.click(getByRole("button"));
143
+ expect(mockOnClear).toHaveBeenCalled();
138
144
  });
139
145
 
140
146
  it("should allow keyboard access to and Space key triggering of the clear button", () => {
@@ -184,7 +190,7 @@ describe("Input", () => {
184
190
 
185
191
  describe("Manual Input.ClearButton usage", () => {
186
192
  it("should render a clear button when passed with elemAfter", () => {
187
- const { getByTitle } = render(
193
+ const { getByRole } = render(
188
194
  <Input
189
195
  id="name"
190
196
  name="name"
@@ -194,24 +200,24 @@ describe("Input", () => {
194
200
  clearButtonLabel="Clear search"
195
201
  />
196
202
  );
197
- expect(getByTitle("Clear search")).toBeTruthy();
203
+ expect(getByRole("button")).toBeTruthy();
198
204
  });
199
205
 
200
- it("should use the fallback title if clearButtonLabel is not provided", () => {
201
- const { getByTitle } = render(
206
+ it("should not render a clear button if there is no text", () => {
207
+ const { queryByRole } = render(
202
208
  <Input
203
209
  id="name"
204
210
  name="name"
205
- value="mic"
211
+ value=""
206
212
  type="text"
207
213
  elemAfter={<Input.ClearButton />}
214
+ clearButtonLabel="Clear search"
208
215
  />
209
216
  );
210
- expect(getByTitle("Clear")).toBeTruthy();
217
+ expect(queryByRole("button")).toBeFalsy();
211
218
  });
212
219
 
213
- it("should call onClear when Input.ClearButton is clicked", () => {
214
- const mockOnClear = jest.fn();
220
+ it("should use the fallback title if clearButtonLabel is not provided", () => {
215
221
  const { getByTitle } = render(
216
222
  <Input
217
223
  id="name"
@@ -219,29 +225,26 @@ describe("Input", () => {
219
225
  value="mic"
220
226
  type="text"
221
227
  elemAfter={<Input.ClearButton />}
222
- onClear={mockOnClear}
223
- clearButtonLabel="Clear search"
224
228
  />
225
229
  );
226
- fireEvent.click(getByTitle("Clear search"));
227
- expect(mockOnClear).toHaveBeenCalled();
230
+ expect(getByTitle("Clear")).toBeTruthy();
228
231
  });
229
232
 
230
- it("should call onChange when clicked if there is no onClear prop", () => {
231
- const mockOnChange = jest.fn();
232
- const { getByTitle } = render(
233
+ it("should call onClear when Input.ClearButton is clicked", () => {
234
+ const mockOnClear = jest.fn();
235
+ const { getByRole } = render(
233
236
  <Input
234
237
  id="name"
235
238
  name="name"
236
239
  value="mic"
237
240
  type="text"
238
241
  elemAfter={<Input.ClearButton />}
239
- onChange={mockOnChange}
242
+ onClear={mockOnClear}
240
243
  clearButtonLabel="Clear search"
241
244
  />
242
245
  );
243
- fireEvent.click(getByTitle("Clear search"));
244
- expect(mockOnChange).toHaveBeenLastCalledWith(expect.anything(), "");
246
+ fireEvent.click(getByRole("button"));
247
+ expect(mockOnClear).toHaveBeenCalled();
245
248
  });
246
249
 
247
250
  it("should allow keyboard access to and Space key triggering of the clear button", () => {
@@ -8,10 +8,11 @@ type TypeProps = {
8
8
  /** Optional prop to make the URL open in a new tab */
9
9
  external?: boolean,
10
10
  children: React.Node,
11
+ /** Setting this prop will cause the component to be rendered as a link */
11
12
  href?: string,
12
13
  /** Disables user action and applies a disabled style to the component */
13
14
  disabled?: boolean,
14
- /** Setting this prop will cause the component to be rendered as a button instead of an anchor) */
15
+ /** Can be used in addition to an href but still renders as a link. Omitting href will render as button */
15
16
  onClick?: (e: SyntheticEvent<HTMLButtonElement>) => void,
16
17
  as?: $PropertyType<TypeStyledComponentsCommonProps, "as">,
17
18
  underline?: boolean,
@@ -0,0 +1,6 @@
1
+ ## Extended Theme Directory
2
+
3
+ This directory serves as a shared environment for all extended themes. Each unique theme should have its own folder and theme.js file.
4
+ `src/themes/extendedThemes/customTheme/theme.js`
5
+
6
+ Check out our documentation for [How to extend the theme](https://seeds.sproutsocial.com/components/theme#extending-the-theme) on Seeds.
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.legacyBadgeColors = void 0;
5
+ var defaultPurple = {
6
+ color: "colors.text.body",
7
+ background: "colors.container.background.decorative.purple"
8
+ };
9
+ var suggestion = {
10
+ color: "colors.text.body",
11
+ background: "colors.container.background.decorative.blue"
12
+ };
13
+ var passive = {
14
+ color: "colors.text.body",
15
+ background: "colors.container.background.decorative.neutral"
16
+ };
17
+ var primary = {
18
+ color: "colors.text.body",
19
+ background: "colors.container.background.decorative.blue"
20
+ };
21
+ var secondary = {
22
+ color: "colors.text.body",
23
+ background: "colors.container.background.decorative.yellow"
24
+ };
25
+ var common = {
26
+ color: "colors.text.inverse",
27
+ background: "colors.aqua.600"
28
+ };
29
+ var approval = {
30
+ color: "colors.text.body",
31
+ background: "colors.container.background.decorative.orange"
32
+ }; //Deprecated former "types"
33
+
34
+ var legacyBadgeColors = {
35
+ primary: primary,
36
+ secondary: secondary,
37
+ passive: passive,
38
+ common: common,
39
+ approval: approval,
40
+ default: defaultPurple,
41
+ suggestion: suggestion
42
+ };
43
+ exports.legacyBadgeColors = legacyBadgeColors;
@@ -5,9 +5,13 @@ exports.default = void 0;
5
5
 
6
6
  var React = _interopRequireWildcard(require("react"));
7
7
 
8
+ var _Icon = _interopRequireDefault(require("../Icon"));
9
+
8
10
  var _styles = _interopRequireDefault(require("./styles"));
9
11
 
10
- var _excluded = ["size", "type", "tip", "text"];
12
+ var _Box = _interopRequireDefault(require("../Box"));
13
+
14
+ var _excluded = ["children", "text", "iconName", "type", "tip", "size", "badgeColor"];
11
15
 
12
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
17
 
@@ -19,43 +23,41 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
19
23
 
20
24
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
25
 
22
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
23
-
24
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25
-
26
- var Badge = /*#__PURE__*/function (_React$Component) {
27
- _inheritsLoose(Badge, _React$Component);
28
-
29
- function Badge() {
30
- return _React$Component.apply(this, arguments) || this;
26
+ var Badge = function Badge(_ref) {
27
+ var children = _ref.children,
28
+ text = _ref.text,
29
+ iconName = _ref.iconName,
30
+ type = _ref.type,
31
+ tip = _ref.tip,
32
+ _ref$size = _ref.size,
33
+ size = _ref$size === void 0 ? "small" : _ref$size,
34
+ _ref$badgeColor = _ref.badgeColor,
35
+ badgeColor = _ref$badgeColor === void 0 ? "blue" : _ref$badgeColor,
36
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
37
+
38
+ if (children && text) {
39
+ throw new Error("can't use both `children` and `text` props. Text is deprecated, consider using children.");
31
40
  }
32
41
 
33
- var _proto = Badge.prototype;
34
-
35
- _proto.render = function render() {
36
- var _this$props = this.props,
37
- size = _this$props.size,
38
- type = _this$props.type,
39
- tip = _this$props.tip,
40
- text = _this$props.text,
41
- rest = _objectWithoutPropertiesLoose(_this$props, _excluded);
42
-
43
- return /*#__PURE__*/React.createElement(_styles.default, _extends({
44
- type: type,
45
- small: size === "small",
46
- "data-tip": tip,
47
- "data-qa-badge": text || "",
48
- "data-qa-badge-type": type,
49
- "data-qa-badge-tip": tip || "" // $FlowIssue - upgrade v0.112.0
50
-
51
- }, rest), text);
52
- };
53
-
54
- return Badge;
55
- }(React.Component);
56
-
57
- exports.default = Badge;
58
- Badge.defaultProps = {
59
- type: "primary",
60
- size: "default"
61
- };
42
+ return /*#__PURE__*/React.createElement(_styles.default, _extends({}, rest, {
43
+ // size previously included default, which currently maps to small. Once consumers have updated this can be simplified.
44
+ size: size === "default" ? "large" : size,
45
+ badgeColor: badgeColor,
46
+ "data-tip": tip,
47
+ "data-qa-badge": text || "",
48
+ "data-qa-badge-type": type,
49
+ "data-qa-badge-tip": tip || "",
50
+ type: type && type
51
+ }), /*#__PURE__*/React.createElement(_Box.default, {
52
+ display: "flex",
53
+ alignItems: "center",
54
+ JustifyContent: "center"
55
+ }, iconName ? /*#__PURE__*/React.createElement(_Icon.default, {
56
+ mr: 200,
57
+ name: iconName,
58
+ size: size === "small" ? "mini" : "default"
59
+ }) : null, children || text));
60
+ };
61
+
62
+ var _default = Badge;
63
+ exports.default = _default;
@@ -3,46 +3,30 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
5
 
6
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
6
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
7
7
 
8
8
  var _systemProps = require("../utils/system-props");
9
9
 
10
10
  var _themeGet = require("@styled-system/theme-get");
11
11
 
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
-
16
- var colors = {
17
- primary: "colors.neutral.0",
18
- secondary: "colors.neutral.800",
19
- passive: "colors.neutral.800",
20
- common: "colors.neutral.0",
21
- approval: "colors.neutral.800",
22
- default: "colors.neutral.0",
23
- suggestion: "colors.neutral.900"
24
- };
25
- var backgroundColors = {
26
- primary: "colors.blue.700",
27
- secondary: "colors.yellow.500",
28
- passive: "colors.neutral.200",
29
- common: "colors.aqua.600",
30
- approval: "colors.orange.300",
31
- default: "colors.purple.700",
32
- suggestion: "colors.blue.300"
33
- }; // eslint-disable-next-line prettier/prettier
12
+ var _constants = require("./constants");
34
13
 
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ // eslint-disable-next-line prettier/prettier
35
17
  var Container = _styledComponents.default.span.withConfig({
36
18
  displayName: "styles__Container",
37
19
  componentId: "sc-g1g76b-0"
38
- })(["display:inline-block;text-align:center;border-radius:50px;font-family:", ";padding:", ";", " ", " ", ""], function (props) {
39
- return props.theme.fontFamily;
40
- }, function (props) {
41
- return props.small ? props.theme.space[200] + " " + props.theme.space[300] : props.theme.space[300] + " " + props.theme.space[350];
42
- }, function (props) {
43
- return props.small ? props.theme.typography[100] : props.theme.typography[200];
44
- }, function (props) {
45
- return (0, _styledComponents.css)(["color:", ";background:", ";"], (0, _themeGet.themeGet)(colors[props.type])(props), (0, _themeGet.themeGet)(backgroundColors[props.type])(props));
20
+ })(["font-family:", ";", ";border-radius:9999px;line-height:16px;display:inline-block;color:", ";background:", ";padding:", ";", ";"], function (p) {
21
+ return p.theme.fontFamily;
22
+ }, function (p) {
23
+ return p.size === "small" ? p.theme.typography[100] : p.theme.typography[200];
24
+ }, function (p) {
25
+ return p.type ? (0, _themeGet.themeGet)(_constants.legacyBadgeColors[p.type].color) : p.theme.colors.text.body;
26
+ }, function (p) {
27
+ return p.type ? (0, _themeGet.themeGet)(_constants.legacyBadgeColors[p.type].background) : p.theme.colors.container.background.decorative[p.badgeColor];
28
+ }, function (p) {
29
+ return p.size === "small" ? p.theme.space[0] + " " + p.theme.space[200] : "" + p.theme.space[300];
46
30
  }, _systemProps.COMMON);
47
31
 
48
32
  var _default = Container;
@@ -11,7 +11,7 @@ var _Button = _interopRequireDefault(require("../Button"));
11
11
 
12
12
  var _Icon = _interopRequireDefault(require("../Icon"));
13
13
 
14
- var _excluded = ["autoComplete", "autoFocus", "disabled", "readOnly", "isInvalid", "hasWarning", "id", "name", "placeholder", "type", "required", "value", "elemBefore", "elemAfter", "maxLength", "ariaLabel", "ariaDescribedby", "clearButtonLabel", "innerRef", "onBlur", "onChange", "onClear", "onFocus", "onKeyDown", "onKeyUp", "onPaste", "inputProps", "qa", "appearance"];
14
+ var _excluded = ["autoComplete", "autoFocus", "disabled", "readOnly", "isInvalid", "hasWarning", "id", "name", "placeholder", "type", "required", "value", "elemBefore", "elemAfter", "maxLength", "ariaLabel", "ariaDescribedby", "clearButtonLabel", "innerRef", "onBlur", "onChange", "onClear", "onFocus", "onKeyDown", "onKeyUp", "onPaste", "inputProps", "qa", "appearance", "size"];
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
@@ -32,14 +32,44 @@ var InputContext = /*#__PURE__*/React.createContext({});
32
32
  var ClearButton = function ClearButton() {
33
33
  var _React$useContext = React.useContext(InputContext),
34
34
  handleClear = _React$useContext.handleClear,
35
- clearButtonLabel = _React$useContext.clearButtonLabel;
35
+ clearButtonLabel = _React$useContext.clearButtonLabel,
36
+ hasValue = _React$useContext.hasValue,
37
+ size = _React$useContext.size; // Hide the button when there is no text to clear.
38
+
39
+
40
+ if (!hasValue) {
41
+ return null;
42
+ } // Cut down the padding for size small Inputs so that the focus ring won't go outside the bounds of the Input.
43
+ // This adjustment is handled automatically for default and large Inputs via Button's size. There is no "small" Button.
44
+
45
+
46
+ var py = size === "small" ? 100 : undefined;
47
+ var px = size === "small" ? 200 : undefined;
48
+ var buttonSize = size === "small" ? "default" : size; // Warn if clearButtonLabel is not included, so that the unlocalized fallback will not be mistaken for a proper label.
49
+
50
+ if (!clearButtonLabel) {
51
+ console.warn("Warning: clearButtonLabel prop is required when using Input.ClearButton. Please pass a localized label to Input.");
52
+ }
36
53
 
37
54
  return /*#__PURE__*/React.createElement(_Button.default, {
38
- onClick: handleClear
55
+ onClick: handleClear,
56
+ size: buttonSize,
57
+ py: py,
58
+ px: px
39
59
  }, /*#__PURE__*/React.createElement(_Icon.default, {
40
60
  name: "circlex",
41
61
  title: clearButtonLabel || "Clear"
42
62
  }));
63
+ }; // Used for positioning elementAfter. This logic will detect if the element is a ClearButton,
64
+ // regardless of whether it was manually passed as elemAfter or automatically added to a search Input.
65
+
66
+
67
+ var isClearButton = function isClearButton(elem) {
68
+ if (elem != null && elem.type) {
69
+ return elem.type.displayName === "Input.ClearButton";
70
+ }
71
+
72
+ return false;
43
73
  };
44
74
 
45
75
  var Input = /*#__PURE__*/function (_React$Component) {
@@ -59,11 +89,10 @@ var Input = /*#__PURE__*/function (_React$Component) {
59
89
  };
60
90
 
61
91
  _this.handleClear = function (e) {
62
- if (_this.props.onClear) {
63
- _this.props.onClear(e);
64
- } else if (_this.props.onChange) {
65
- _this.props.onChange(e, "");
66
- }
92
+ var _this$props$innerRef, _this$props$innerRef$;
93
+
94
+ _this.props.onClear == null ? void 0 : _this.props.onClear(e);
95
+ (_this$props$innerRef = _this.props.innerRef) == null ? void 0 : (_this$props$innerRef$ = _this$props$innerRef.current) == null ? void 0 : _this$props$innerRef$.focus();
67
96
  };
68
97
 
69
98
  _this.handleChange = function (e) {
@@ -92,8 +121,6 @@ var Input = /*#__PURE__*/function (_React$Component) {
92
121
  var _proto = Input.prototype;
93
122
 
94
123
  _proto.render = function render() {
95
- var _elementAfter$type;
96
-
97
124
  var _this$props = this.props,
98
125
  autoComplete = _this$props.autoComplete,
99
126
  autoFocus = _this$props.autoFocus,
@@ -126,6 +153,7 @@ var Input = /*#__PURE__*/function (_React$Component) {
126
153
  _this$props$qa = _this$props.qa,
127
154
  qa = _this$props$qa === void 0 ? {} : _this$props$qa,
128
155
  appearance = _this$props.appearance,
156
+ size = _this$props.size,
129
157
  rest = _objectWithoutPropertiesLoose(_this$props, _excluded); // Convert autoComplete from a boolean prop to a string value.
130
158
 
131
159
 
@@ -138,21 +166,26 @@ var Input = /*#__PURE__*/function (_React$Component) {
138
166
 
139
167
  var elementBefore = type === "search" && !elemBefore ? /*#__PURE__*/React.createElement(_Icon.default, {
140
168
  name: "search",
141
- ariaHidden: true
142
- }) : elemBefore;
143
- var elementAfter = type === "search" && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
169
+ ariaHidden: true,
170
+ color: "icon.base"
171
+ }) : elemBefore; // Do not add a ClearButton if no onClear callback is provided or if an elemAfter prop was passed.
172
+
173
+ var elementAfter = type === "search" && onClear && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
144
174
  return /*#__PURE__*/React.createElement(_styles.default, _extends({
145
175
  hasBeforeElement: !!elementBefore,
146
176
  hasAfterElement: !!elementAfter,
147
177
  disabled: disabled,
148
178
  invalid: !!isInvalid,
149
179
  warning: hasWarning,
150
- appearance: appearance // $FlowIssue - upgrade v0.112.0
180
+ appearance: appearance,
181
+ size: size // $FlowIssue - upgrade v0.112.0
151
182
 
152
183
  }, rest), /*#__PURE__*/React.createElement(InputContext.Provider, {
153
184
  value: {
154
185
  handleClear: this.handleClear,
155
- clearButtonLabel: clearButtonLabel
186
+ hasValue: !!value,
187
+ clearButtonLabel: clearButtonLabel,
188
+ size: size
156
189
  }
157
190
  }, elementBefore && /*#__PURE__*/React.createElement(_styles.Accessory, {
158
191
  before: true
@@ -182,10 +215,8 @@ var Input = /*#__PURE__*/function (_React$Component) {
182
215
  "data-qa-input-isdisabled": disabled === true,
183
216
  "data-qa-input-isrequired": required === true
184
217
  }, qa, inputProps)), elementAfter && /*#__PURE__*/React.createElement(_styles.Accessory, {
185
- after: true // Used for positioning. This logic will detect if the element is a ClearButton,
186
- // regardless of whether it was manually passed as elemAfter or automatically added to a search Input.
187
- ,
188
- isClearButton: (elementAfter == null ? void 0 : (_elementAfter$type = elementAfter.type) == null ? void 0 : _elementAfter$type.prototype) === Input.ClearButton.prototype
218
+ after: true,
219
+ isClearButton: isClearButton(elementAfter)
189
220
  }, elementAfter)));
190
221
  };
191
222
 
@@ -0,0 +1,38 @@
1
+ var defaultPurple = {
2
+ color: "colors.text.body",
3
+ background: "colors.container.background.decorative.purple"
4
+ };
5
+ var suggestion = {
6
+ color: "colors.text.body",
7
+ background: "colors.container.background.decorative.blue"
8
+ };
9
+ var passive = {
10
+ color: "colors.text.body",
11
+ background: "colors.container.background.decorative.neutral"
12
+ };
13
+ var primary = {
14
+ color: "colors.text.body",
15
+ background: "colors.container.background.decorative.blue"
16
+ };
17
+ var secondary = {
18
+ color: "colors.text.body",
19
+ background: "colors.container.background.decorative.yellow"
20
+ };
21
+ var common = {
22
+ color: "colors.text.inverse",
23
+ background: "colors.aqua.600"
24
+ };
25
+ var approval = {
26
+ color: "colors.text.body",
27
+ background: "colors.container.background.decorative.orange"
28
+ }; //Deprecated former "types"
29
+
30
+ export var legacyBadgeColors = {
31
+ primary: primary,
32
+ secondary: secondary,
33
+ passive: passive,
34
+ common: common,
35
+ approval: approval,
36
+ default: defaultPurple,
37
+ suggestion: suggestion
38
+ };
@@ -1,49 +1,48 @@
1
- var _excluded = ["size", "type", "tip", "text"];
1
+ var _excluded = ["children", "text", "iconName", "type", "tip", "size", "badgeColor"];
2
2
 
3
3
  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); }
4
4
 
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
6
 
7
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
8
-
9
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10
-
11
7
  import * as React from "react";
8
+ import Icon from "../Icon";
12
9
  import Container from "./styles";
13
-
14
- var Badge = /*#__PURE__*/function (_React$Component) {
15
- _inheritsLoose(Badge, _React$Component);
16
-
17
- function Badge() {
18
- return _React$Component.apply(this, arguments) || this;
10
+ import Box from "../Box";
11
+
12
+ var Badge = function Badge(_ref) {
13
+ var children = _ref.children,
14
+ text = _ref.text,
15
+ iconName = _ref.iconName,
16
+ type = _ref.type,
17
+ tip = _ref.tip,
18
+ _ref$size = _ref.size,
19
+ size = _ref$size === void 0 ? "small" : _ref$size,
20
+ _ref$badgeColor = _ref.badgeColor,
21
+ badgeColor = _ref$badgeColor === void 0 ? "blue" : _ref$badgeColor,
22
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
23
+
24
+ if (children && text) {
25
+ throw new Error("can't use both `children` and `text` props. Text is deprecated, consider using children.");
19
26
  }
20
27
 
21
- var _proto = Badge.prototype;
22
-
23
- _proto.render = function render() {
24
- var _this$props = this.props,
25
- size = _this$props.size,
26
- type = _this$props.type,
27
- tip = _this$props.tip,
28
- text = _this$props.text,
29
- rest = _objectWithoutPropertiesLoose(_this$props, _excluded);
30
-
31
- return /*#__PURE__*/React.createElement(Container, _extends({
32
- type: type,
33
- small: size === "small",
34
- "data-tip": tip,
35
- "data-qa-badge": text || "",
36
- "data-qa-badge-type": type,
37
- "data-qa-badge-tip": tip || "" // $FlowIssue - upgrade v0.112.0
38
-
39
- }, rest), text);
40
- };
41
-
42
- return Badge;
43
- }(React.Component);
44
-
45
- Badge.defaultProps = {
46
- type: "primary",
47
- size: "default"
28
+ return /*#__PURE__*/React.createElement(Container, _extends({}, rest, {
29
+ // size previously included default, which currently maps to small. Once consumers have updated this can be simplified.
30
+ size: size === "default" ? "large" : size,
31
+ badgeColor: badgeColor,
32
+ "data-tip": tip,
33
+ "data-qa-badge": text || "",
34
+ "data-qa-badge-type": type,
35
+ "data-qa-badge-tip": tip || "",
36
+ type: type && type
37
+ }), /*#__PURE__*/React.createElement(Box, {
38
+ display: "flex",
39
+ alignItems: "center",
40
+ JustifyContent: "center"
41
+ }, iconName ? /*#__PURE__*/React.createElement(Icon, {
42
+ mr: 200,
43
+ name: iconName,
44
+ size: size === "small" ? "mini" : "default"
45
+ }) : null, children || text));
48
46
  };
49
- export { Badge as default };
47
+
48
+ export default Badge;