@sproutsocial/racine 11.2.5-sproutTheme-beta.0 → 11.2.5-sproutTheme-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.
Files changed (45) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/__flow__/Button/index.stories.js +1 -0
  3. package/__flow__/Input/index.js +185 -66
  4. package/__flow__/Input/index.stories.js +65 -0
  5. package/__flow__/Input/index.test.js +230 -1
  6. package/__flow__/Input/styles.js +1 -1
  7. package/__flow__/ThemeProvider/index.js +5 -1
  8. package/__flow__/TokenInput/index.js +1 -1
  9. package/__flow__/index.js +1 -0
  10. package/__flow__/themes/dark/theme.js +3 -0
  11. package/__flow__/themes/extendedThemes/sproutTheme/NonColorThemeValues/index.js +17 -0
  12. package/__flow__/themes/extendedThemes/sproutTheme/dark/getDarkThemeColors.js +57 -0
  13. package/__flow__/themes/extendedThemes/sproutTheme/dark/theme.js +17 -35
  14. package/__flow__/themes/extendedThemes/sproutTheme/index.js +2 -0
  15. package/__flow__/themes/extendedThemes/sproutTheme/light/getLightThemeColors.js +53 -0
  16. package/__flow__/themes/extendedThemes/sproutTheme/light/theme.js +16 -35
  17. package/__flow__/themes/extendedThemes/sproutTheme/sproutThemeType.flow.js +36 -0
  18. package/__flow__/themes/light/theme.js +3 -0
  19. package/__flow__/types/theme.colors.flow.js +3 -0
  20. package/__flow__/types/theme.flow.js +15 -0
  21. package/commonjs/Input/index.js +124 -30
  22. package/commonjs/Input/styles.js +1 -1
  23. package/commonjs/TokenInput/index.js +1 -1
  24. package/commonjs/themes/dark/theme.js +4 -1
  25. package/commonjs/themes/extendedThemes/sproutTheme/NonColorThemeValues/index.js +15 -0
  26. package/commonjs/themes/extendedThemes/sproutTheme/dark/getDarkThemeColors.js +57 -0
  27. package/commonjs/themes/extendedThemes/sproutTheme/dark/theme.js +16 -35
  28. package/commonjs/themes/extendedThemes/sproutTheme/light/getLightThemeColors.js +53 -0
  29. package/commonjs/themes/extendedThemes/sproutTheme/light/theme.js +16 -35
  30. package/commonjs/themes/extendedThemes/sproutTheme/sproutThemeType.flow.js +1 -0
  31. package/commonjs/themes/light/theme.js +4 -1
  32. package/dist/themes/dark/dark.scss +4 -1
  33. package/dist/themes/light/light.scss +4 -1
  34. package/lib/Input/index.js +117 -30
  35. package/lib/Input/styles.js +1 -1
  36. package/lib/TokenInput/index.js +1 -1
  37. package/lib/themes/dark/theme.js +4 -1
  38. package/lib/themes/extendedThemes/sproutTheme/NonColorThemeValues/index.js +10 -0
  39. package/lib/themes/extendedThemes/sproutTheme/dark/getDarkThemeColors.js +52 -0
  40. package/lib/themes/extendedThemes/sproutTheme/dark/theme.js +13 -35
  41. package/lib/themes/extendedThemes/sproutTheme/light/getLightThemeColors.js +48 -0
  42. package/lib/themes/extendedThemes/sproutTheme/light/theme.js +13 -35
  43. package/lib/themes/extendedThemes/sproutTheme/sproutThemeType.flow.js +0 -0
  44. package/lib/themes/light/theme.js +4 -1
  45. package/package.json +1 -1
@@ -140,7 +140,7 @@ export const Accessory: StyledComponent<any, TypeTheme, *> = styled.div`
140
140
  ${(props) =>
141
141
  props.after &&
142
142
  css`
143
- right: ${props.theme.space[350]};
143
+ right: ${props.isClearButton ? 0 : props.theme.space[350]};
144
144
  `};
145
145
  `;
146
146
 
@@ -4,9 +4,13 @@ import { ThemeProvider as BaseThemeProvider } from "styled-components";
4
4
  import theme from "../themes/light/theme";
5
5
 
6
6
  import type { TypeTheme } from "../types/theme.flow";
7
+ import type { TypeSproutTheme } from "../themes/extendedThemes/sproutTheme/sproutThemeType.flow";
8
+
9
+ // We can append additional themes types here
10
+ type TypeAllThemes = TypeTheme | TypeSproutTheme;
7
11
 
8
12
  type TypeProps = $ReadOnly<{|
9
- theme?: TypeTheme,
13
+ theme?: TypeAllThemes,
10
14
  children: React.Node,
11
15
  |}>;
12
16
 
@@ -341,7 +341,7 @@ export default class TokenInput extends React.Component<TypeProps, TypeState> {
341
341
  aria-invalid={!!isInvalid}
342
342
  aria-label={ariaLabel}
343
343
  autoFocus={autoFocus}
344
- autocomplete={autocomplete}
344
+ autoComplete={autocomplete}
345
345
  disabled={disabled}
346
346
  id={id}
347
347
  name={name}
package/__flow__/index.js CHANGED
@@ -10,6 +10,7 @@ export {
10
10
  sproutLightTheme,
11
11
  sproutDarkTheme,
12
12
  } from "./themes/extendedThemes/sproutTheme";
13
+ export type { TypeSproutTheme } from "./themes/extendedThemes/sproutTheme";
13
14
  export { default as Icon } from "./Icon";
14
15
  // DEPRECATED: Alert has been renamed to Banner
15
16
  export { default as Alert } from "./Banner";
@@ -174,6 +174,9 @@ const colors = {
174
174
  body: COLORS.COLOR_NEUTRAL_100,
175
175
  inverse: COLORS.COLOR_NEUTRAL_900,
176
176
  error: COLORS.COLOR_RED_400,
177
+ background: {
178
+ highlight: COLORS.COLOR_YELLOW_900,
179
+ },
177
180
  },
178
181
  icon: {
179
182
  base: COLORS.COLOR_NEUTRAL_100,
@@ -0,0 +1,17 @@
1
+ // @flow strict-local
2
+ import type {
3
+ TypeNonColorThemeValues,
4
+ TypeTheme,
5
+ } from "../../../../types/theme.flow.js";
6
+
7
+ export function getNonColorThemeValues(
8
+ theme: TypeTheme
9
+ ): TypeNonColorThemeValues {
10
+ const { colors, ...otherThemeValues } = theme;
11
+ return {
12
+ ...otherThemeValues,
13
+ /**
14
+ * You can add your own theme values or overrides here.
15
+ */
16
+ };
17
+ }
@@ -0,0 +1,57 @@
1
+ // @flow strict-local
2
+ import type { TypeColors } from "../../../../types/theme.colors.flow.js";
3
+
4
+ export function getDarkThemeColors(themeColors: TypeColors) {
5
+ return {
6
+ ...themeColors,
7
+ navigation: {
8
+ main: {
9
+ background: {
10
+ base: themeColors.neutral[1000],
11
+ gradient: themeColors.neutral[1100],
12
+ },
13
+ },
14
+ secondary: {
15
+ background: {
16
+ base: themeColors.neutral[900],
17
+ },
18
+ },
19
+ text: {
20
+ base: themeColors.neutral[0],
21
+ hover: themeColors.neutral[0],
22
+ },
23
+ icon: {
24
+ base: themeColors.neutral[0],
25
+ hover: themeColors.neutral[0],
26
+ },
27
+ listItem: {
28
+ background: {
29
+ base: themeColors.neutral[1000],
30
+ hover: themeColors.neutral[1100],
31
+ active: themeColors.neutral[700],
32
+ },
33
+ },
34
+ },
35
+ container: {
36
+ ...themeColors.container,
37
+ background: {
38
+ ...themeColors.container.background,
39
+ // FIX: These need to be changed to have dark mode colors
40
+ // For now we've copied the light mode values here as well.
41
+ positive_sentiment: themeColors.blue[500],
42
+ negative_sentiment: themeColors.red[500],
43
+ neutral_sentiment: themeColors.neutral[300],
44
+ },
45
+ },
46
+ icon: {
47
+ ...themeColors.icon,
48
+ // FIX: These need to be changed to have dark mode colors
49
+ // For now we've copied the light mode values here as well.
50
+ sentiment: {
51
+ positive_sentiment: themeColors.blue[500],
52
+ negative_sentiment: themeColors.red[500],
53
+ neutral_sentiment: themeColors.neutral[300],
54
+ },
55
+ },
56
+ };
57
+ }
@@ -1,44 +1,26 @@
1
1
  // @flow strict-local
2
2
  import clone from "just-clone";
3
+ import baseDarkTheme from "../../../dark/theme";
4
+ import { getDarkThemeColors } from "./getDarkThemeColors";
5
+ import { getNonColorThemeValues } from "../NonColorThemeValues";
3
6
  import type { TypeTheme } from "../../../../types/theme.flow.js";
7
+ import type { TypeSproutTheme } from "../sproutThemeType.flow";
4
8
 
5
- const darkTheme = (theme: TypeTheme) => {
6
- const sproutDarkTheme = clone(theme);
9
+ const darkTheme = (baseDarkTheme: TypeTheme): TypeSproutTheme => {
10
+ // clone base theme. (we don't want to mutate the base theme)
11
+ const themeClone = clone(baseDarkTheme);
7
12
 
8
- sproutDarkTheme.sprout = {
9
- colors: {
10
- navigation: {
11
- main: {
12
- background: {
13
- base: theme.colors.neutral[1000],
14
- gradient: theme.colors.neutral[1100],
15
- },
16
- },
17
- secondary: {
18
- background: {
19
- base: theme.colors.neutral[900],
20
- },
21
- },
22
- text: {
23
- base: theme.colors.neutral[0],
24
- hover: theme.colors.neutral[0],
25
- },
26
- icon: {
27
- base: theme.colors.neutral[0],
28
- hover: theme.colors.neutral[0],
29
- },
30
- item: {
31
- background: {
32
- base: theme.colors.neutral[1000],
33
- hover: theme.colors.neutral[1100],
34
- active: theme.colors.neutral[700],
35
- },
36
- },
37
- },
38
- },
39
- };
13
+ // get non color theme values
14
+ const nonColorThemeValues = getNonColorThemeValues(themeClone);
15
+
16
+ // get sprout specific dark theme colors
17
+ const darkThemeColors = getDarkThemeColors(themeClone.colors);
40
18
 
41
- return sproutDarkTheme;
19
+ return {
20
+ ...themeClone,
21
+ ...nonColorThemeValues,
22
+ ...darkThemeColors,
23
+ };
42
24
  };
43
25
 
44
26
  export default darkTheme;
@@ -1,2 +1,4 @@
1
+ // @flow
1
2
  export { default as sproutLightTheme } from "./light/theme";
2
3
  export { default as sproutDarkTheme } from "./dark/theme";
4
+ export type { TypeSproutTheme } from "./sproutThemeType.flow";
@@ -0,0 +1,53 @@
1
+ // @flow strict-local
2
+ import type { TypeColors } from "../../../../types/theme.colors.flow.js";
3
+
4
+ export function getLightThemeColors(themeColors: TypeColors) {
5
+ return {
6
+ ...themeColors,
7
+ navigation: {
8
+ main: {
9
+ background: {
10
+ base: themeColors.neutral[900],
11
+ overflowGradient: themeColors.neutral[1000],
12
+ },
13
+ },
14
+ secondary: {
15
+ background: {
16
+ base: themeColors.neutral[800],
17
+ },
18
+ },
19
+ text: {
20
+ base: themeColors.neutral[0],
21
+ hover: themeColors.neutral[0],
22
+ },
23
+ icon: {
24
+ base: themeColors.neutral[0],
25
+ hover: themeColors.neutral[0],
26
+ },
27
+ listItem: {
28
+ background: {
29
+ base: themeColors.neutral[800],
30
+ hover: themeColors.neutral[1000],
31
+ selected: themeColors.neutral[700],
32
+ },
33
+ },
34
+ },
35
+ container: {
36
+ ...themeColors.container,
37
+ background: {
38
+ ...themeColors.container.background,
39
+ positive_sentiment: themeColors.blue[500],
40
+ negative_sentiment: themeColors.red[500],
41
+ neutral_sentiment: themeColors.neutral[300],
42
+ },
43
+ },
44
+ icon: {
45
+ ...themeColors.icon,
46
+ sentiment: {
47
+ positive_sentiment: themeColors.blue[500],
48
+ negative_sentiment: themeColors.red[500],
49
+ neutral_sentiment: themeColors.neutral[300],
50
+ },
51
+ },
52
+ };
53
+ }
@@ -1,44 +1,25 @@
1
1
  // @flow strict-local
2
2
  import clone from "just-clone";
3
+ import baseLightTheme from "../../../light/theme";
4
+ import { getLightThemeColors } from "./getLightThemeColors";
5
+ import { getNonColorThemeValues } from "../NonColorThemeValues";
3
6
  import type { TypeTheme } from "../../../../types/theme.flow.js";
4
7
 
5
- const lightTheme = (theme: TypeTheme) => {
6
- const sproutLightTheme = clone(theme);
8
+ const lightTheme = (baseLightTheme: TypeTheme) => {
9
+ // clone base theme. (we don't want to mutate the base theme)
10
+ const themeClone = clone(baseLightTheme);
7
11
 
8
- sproutLightTheme.sprout = {
9
- colors: {
10
- navigation: {
11
- main: {
12
- background: {
13
- base: theme.colors.neutral[900],
14
- gradient: theme.colors.neutral[1000],
15
- },
16
- },
17
- secondary: {
18
- background: {
19
- base: theme.colors.neutral[800],
20
- },
21
- },
22
- text: {
23
- base: theme.colors.neutral[0],
24
- hover: theme.colors.neutral[0],
25
- },
26
- icon: {
27
- base: theme.colors.neutral[0],
28
- hover: theme.colors.neutral[0],
29
- },
30
- item: {
31
- background: {
32
- base: theme.colors.neutral[800],
33
- hover: theme.colors.neutral[1000],
34
- active: theme.colors.neutral[700],
35
- },
36
- },
37
- },
38
- },
39
- };
12
+ // get non color theme values
13
+ const nonColorThemeValues = getNonColorThemeValues(themeClone);
14
+
15
+ // get sprout specific light theme colors
16
+ const lightThemeColors = getLightThemeColors(themeClone.colors);
40
17
 
41
- return sproutLightTheme;
18
+ return {
19
+ ...themeClone,
20
+ ...nonColorThemeValues,
21
+ ...lightThemeColors,
22
+ };
42
23
  };
43
24
 
44
25
  export default lightTheme;
@@ -0,0 +1,36 @@
1
+ // @flow strict-local
2
+ import type { TypeTheme } from "../../../types/theme.flow";
3
+
4
+ export type TypeSproutTheme = {
5
+ ...$Exact<TypeTheme>,
6
+ colors: {|
7
+ navigation: {|
8
+ main: {|
9
+ background: {|
10
+ base: string,
11
+ gradient: string,
12
+ |},
13
+ |},
14
+ secondary: {|
15
+ background: {|
16
+ base: string,
17
+ |},
18
+ |},
19
+ text: {|
20
+ base: string,
21
+ hover: string,
22
+ |},
23
+ icon: {|
24
+ base: string,
25
+ hover: string,
26
+ |},
27
+ listItem: {|
28
+ background: {|
29
+ base: string,
30
+ hover: string,
31
+ active: string,
32
+ |},
33
+ |},
34
+ |},
35
+ |},
36
+ };
@@ -171,6 +171,9 @@ const colors = {
171
171
  body: COLORS.COLOR_NEUTRAL_800,
172
172
  inverse: COLORS.COLOR_NEUTRAL_0,
173
173
  error: COLORS.COLOR_RED_800,
174
+ background: {
175
+ highlight: COLORS.COLOR_YELLOW_200,
176
+ },
174
177
  },
175
178
  icon: {
176
179
  base: COLORS.COLOR_NEUTRAL_800,
@@ -158,6 +158,9 @@ type TypeTextColors = {|
158
158
  body: string,
159
159
  inverse: string,
160
160
  error: string,
161
+ background: {
162
+ highlight: string,
163
+ },
161
164
  },
162
165
  |};
163
166
 
@@ -43,3 +43,18 @@ export type TypeTheme = {
43
43
  easing: TypeEasing,
44
44
  duration: TypeDuration,
45
45
  };
46
+
47
+ export type TypeNonColorThemeValues = {
48
+ mode: TypeThemeMode,
49
+ breakpoints: TypeBreakpoint,
50
+ typography: TypeTypography,
51
+ fontWeights: TypeFontWeight,
52
+ fontFamily: TypeFontFamily,
53
+ space: TypeSpace,
54
+ radii: TypeRadii,
55
+ borders: TypeBorder,
56
+ borderWidths: TypeBorderWidth,
57
+ shadows: TypeShadow,
58
+ easing: TypeEasing,
59
+ duration: TypeDuration,
60
+ };
@@ -7,6 +7,14 @@ var React = _interopRequireWildcard(require("react"));
7
7
 
8
8
  var _styles = _interopRequireWildcard(require("./styles"));
9
9
 
10
+ var _Button = _interopRequireDefault(require("../Button"));
11
+
12
+ var _Icon = _interopRequireDefault(require("../Icon"));
13
+
14
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
10
18
  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); }
11
19
 
12
20
  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; }
@@ -19,6 +27,67 @@ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.crea
19
27
 
20
28
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
29
 
30
+ var InputContext = /*#__PURE__*/React.createContext({});
31
+ var StyledButton = (0, _styledComponents.default)(_Button.default).withConfig({
32
+ displayName: "Input__StyledButton",
33
+ componentId: "sc-1ck1dnm-0"
34
+ })(["&:hover,&:active{color:", ";}"], function (props) {
35
+ return props.theme.utils.interact(props.theme.colors.icon.base);
36
+ });
37
+
38
+ var ClearButton = function ClearButton() {
39
+ var _React$useContext = React.useContext(InputContext),
40
+ onClear = _React$useContext.onClear,
41
+ handleClear = _React$useContext.handleClear,
42
+ clearButtonLabel = _React$useContext.clearButtonLabel,
43
+ hasValue = _React$useContext.hasValue,
44
+ inputSize = _React$useContext.size; // Hide the button when there is no text to clear.
45
+
46
+
47
+ if (!hasValue) {
48
+ return null;
49
+ } // Log a warning and hide the button when no onClear callback is provided.
50
+ // If we called handleClear with no onClear prop, all the button would do is focus the Input.
51
+
52
+
53
+ if (!onClear) {
54
+ console.warn("Warning: No onClear prop provided to Input when using Input.ClearButton. Omitting Input.ClearButton.");
55
+ return null;
56
+ } // Warn if clearButtonLabel is not included, so that the unlocalized fallback will not be mistaken for a proper label.
57
+
58
+
59
+ if (!clearButtonLabel) {
60
+ console.warn("Warning: clearButtonLabel prop is required when using Input.ClearButton. Please pass a localized clearButtonLabel to Input.");
61
+ } // Reduce Button padding for size small Inputs so that the Button won't go outside the bounds of the Input.
62
+ // This adjustment is handled automatically for default and large Inputs via Button's size. There is no "small" Button.
63
+
64
+
65
+ var py = inputSize === "small" ? 100 : undefined;
66
+ var px = inputSize === "small" ? 200 : undefined;
67
+ var buttonSize = inputSize === "small" ? "default" : inputSize;
68
+ return /*#__PURE__*/React.createElement(StyledButton, {
69
+ onClick: handleClear,
70
+ size: buttonSize,
71
+ py: py,
72
+ px: px,
73
+ title: clearButtonLabel || "Clear",
74
+ ariaLabel: clearButtonLabel || "Clear",
75
+ color: "icon.base"
76
+ }, /*#__PURE__*/React.createElement(_Icon.default, {
77
+ name: "circlex"
78
+ }));
79
+ }; // Used for positioning elementAfter. This logic will detect if the element is a ClearButton,
80
+ // regardless of whether it was manually passed as elemAfter or automatically added to a search Input.
81
+
82
+
83
+ var isClearButton = function isClearButton(elem) {
84
+ if (elem != null && elem.type) {
85
+ return elem.type.displayName === "Input.ClearButton";
86
+ }
87
+
88
+ return false;
89
+ };
90
+
22
91
  var Input = /*#__PURE__*/function (_React$Component) {
23
92
  _inheritsLoose(Input, _React$Component);
24
93
 
@@ -32,39 +101,38 @@ var Input = /*#__PURE__*/function (_React$Component) {
32
101
  _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
33
102
 
34
103
  _this.handleBlur = function (e) {
35
- if (_this.props.onBlur) {
36
- _this.props.onBlur(e);
104
+ return _this.props.onBlur == null ? void 0 : _this.props.onBlur(e);
105
+ };
106
+
107
+ _this.handleClear = function (e) {
108
+ // Only attempt to focus the input if the ref is an object. It won't work for refs that are functions.
109
+ if (typeof _this.props.innerRef === "object") {
110
+ var _this$props$innerRef$;
111
+
112
+ (_this$props$innerRef$ = _this.props.innerRef.current) == null ? void 0 : _this$props$innerRef$.focus();
37
113
  }
114
+
115
+ _this.props.onClear == null ? void 0 : _this.props.onClear(e);
38
116
  };
39
117
 
40
118
  _this.handleChange = function (e) {
41
- if (_this.props.onChange) {
42
- _this.props.onChange(e, e.currentTarget.value);
43
- }
119
+ return _this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
44
120
  };
45
121
 
46
122
  _this.handleFocus = function (e) {
47
- if (_this.props.onFocus) {
48
- _this.props.onFocus(e);
49
- }
123
+ return _this.props.onFocus == null ? void 0 : _this.props.onFocus(e);
50
124
  };
51
125
 
52
126
  _this.handleKeyDown = function (e) {
53
- if (_this.props.onKeyDown) {
54
- _this.props.onKeyDown(e, e.currentTarget.value);
55
- }
127
+ return _this.props.onKeyDown == null ? void 0 : _this.props.onKeyDown(e, e.currentTarget.value);
56
128
  };
57
129
 
58
130
  _this.handleKeyUp = function (e) {
59
- if (_this.props.onKeyUp) {
60
- _this.props.onKeyUp(e, e.currentTarget.value);
61
- }
131
+ return _this.props.onKeyUp == null ? void 0 : _this.props.onKeyUp(e, e.currentTarget.value);
62
132
  };
63
133
 
64
134
  _this.handlePaste = function (e) {
65
- if (_this.props.onPaste) {
66
- _this.props.onPaste(e, e.currentTarget.value);
67
- }
135
+ return _this.props.onPaste == null ? void 0 : _this.props.onPaste(e, e.currentTarget.value);
68
136
  };
69
137
 
70
138
  return _this;
@@ -91,9 +159,11 @@ var Input = /*#__PURE__*/function (_React$Component) {
91
159
  maxLength = _this$props.maxLength,
92
160
  ariaLabel = _this$props.ariaLabel,
93
161
  ariaDescribedby = _this$props.ariaDescribedby,
162
+ clearButtonLabel = _this$props.clearButtonLabel,
94
163
  innerRef = _this$props.innerRef,
95
164
  onBlur = _this$props.onBlur,
96
165
  onChange = _this$props.onChange,
166
+ onClear = _this$props.onClear,
97
167
  onFocus = _this$props.onFocus,
98
168
  onKeyDown = _this$props.onKeyDown,
99
169
  onKeyUp = _this$props.onKeyUp,
@@ -103,25 +173,44 @@ var Input = /*#__PURE__*/function (_React$Component) {
103
173
  _this$props$qa = _this$props.qa,
104
174
  qa = _this$props$qa === void 0 ? {} : _this$props$qa,
105
175
  appearance = _this$props.appearance,
106
- rest = _objectWithoutPropertiesLoose(_this$props, ["autoComplete", "autoFocus", "disabled", "readOnly", "isInvalid", "hasWarning", "id", "name", "placeholder", "type", "required", "value", "elemBefore", "elemAfter", "maxLength", "ariaLabel", "ariaDescribedby", "innerRef", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "onPaste", "inputProps", "qa", "appearance"]);
176
+ size = _this$props.size,
177
+ rest = _objectWithoutPropertiesLoose(_this$props, ["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"]); // Convert autoComplete from a boolean prop to a string value.
178
+
107
179
 
108
180
  var autoCompleteValue = undefined;
109
181
 
110
182
  if (autoComplete !== undefined) {
111
183
  autoCompleteValue = autoComplete ? "on" : "off";
112
- }
184
+ } // Add default elemBefore and elemAfter elements if type is search.
185
+
113
186
 
187
+ var elementBefore = type === "search" && !elemBefore ? /*#__PURE__*/React.createElement(_Icon.default, {
188
+ name: "search",
189
+ ariaHidden: true,
190
+ color: "icon.base"
191
+ }) : elemBefore; // Do not add a ClearButton if no onClear callback is provided or if an elemAfter prop was passed.
192
+
193
+ var elementAfter = type === "search" && onClear && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
114
194
  return /*#__PURE__*/React.createElement(_styles.default, _extends({
115
- hasBeforeElement: !!elemBefore,
116
- hasAfterElement: !!elemAfter,
195
+ hasBeforeElement: !!elementBefore,
196
+ hasAfterElement: !!elementAfter,
117
197
  disabled: disabled,
118
198
  invalid: !!isInvalid,
119
199
  warning: hasWarning,
120
- appearance: appearance // $FlowIssue - upgrade v0.112.0
200
+ appearance: appearance,
201
+ size: size // $FlowIssue - upgrade v0.112.0
121
202
 
122
- }, rest), elemBefore && /*#__PURE__*/React.createElement(_styles.Accessory, {
203
+ }, rest), /*#__PURE__*/React.createElement(InputContext.Provider, {
204
+ value: {
205
+ handleClear: this.handleClear,
206
+ hasValue: !!value,
207
+ clearButtonLabel: clearButtonLabel,
208
+ onClear: onClear,
209
+ size: size
210
+ }
211
+ }, elementBefore && /*#__PURE__*/React.createElement(_styles.Accessory, {
123
212
  before: true
124
- }, elemBefore), /*#__PURE__*/React.createElement("input", _extends({
213
+ }, elementBefore), /*#__PURE__*/React.createElement("input", _extends({
125
214
  "aria-invalid": !!isInvalid,
126
215
  "aria-label": ariaLabel,
127
216
  "aria-describedby": ariaDescribedby,
@@ -146,19 +235,24 @@ var Input = /*#__PURE__*/function (_React$Component) {
146
235
  "data-qa-input": name || "",
147
236
  "data-qa-input-isdisabled": disabled === true,
148
237
  "data-qa-input-isrequired": required === true
149
- }, qa, inputProps)), elemAfter && /*#__PURE__*/React.createElement(_styles.Accessory, {
150
- after: true
151
- }, elemAfter));
238
+ }, qa, inputProps)), elementAfter && /*#__PURE__*/React.createElement(_styles.Accessory, {
239
+ after: true,
240
+ isClearButton: isClearButton(elementAfter)
241
+ }, elementAfter)));
152
242
  };
153
243
 
154
244
  return Input;
155
245
  }(React.Component);
156
246
 
157
- exports.default = Input;
158
247
  Input.defaultProps = {
159
248
  autoFocus: false,
160
249
  disabled: false,
161
250
  type: "text",
162
251
  size: "default",
163
- appearance: "primary"
164
- };
252
+ appearance: "primary",
253
+ innerRef: /*#__PURE__*/React.createRef()
254
+ };
255
+ Input.ClearButton = ClearButton;
256
+ Input.ClearButton.displayName = "Input.ClearButton";
257
+ var _default = Input;
258
+ exports.default = _default;
@@ -86,7 +86,7 @@ var Accessory = _styledComponents.default.div.withConfig({
86
86
  }, function (props) {
87
87
  return props.before && (0, _styledComponents.css)(["left:", ";"], props.theme.space[350]);
88
88
  }, function (props) {
89
- return props.after && (0, _styledComponents.css)(["right:", ";"], props.theme.space[350]);
89
+ return props.after && (0, _styledComponents.css)(["right:", ";"], props.isClearButton ? 0 : props.theme.space[350]);
90
90
  });
91
91
 
92
92
  exports.Accessory = Accessory;
@@ -300,7 +300,7 @@ var TokenInput = /*#__PURE__*/function (_React$Component) {
300
300
  "aria-invalid": !!isInvalid,
301
301
  "aria-label": ariaLabel,
302
302
  autoFocus: autoFocus,
303
- autocomplete: autocomplete,
303
+ autoComplete: autocomplete,
304
304
  disabled: disabled,
305
305
  id: id,
306
306
  name: name,
@@ -175,7 +175,10 @@ var colors = _extends({}, _theme.default.colors, {
175
175
  subtext: _seedsColor.default.COLOR_NEUTRAL_300,
176
176
  body: _seedsColor.default.COLOR_NEUTRAL_100,
177
177
  inverse: _seedsColor.default.COLOR_NEUTRAL_900,
178
- error: _seedsColor.default.COLOR_RED_400
178
+ error: _seedsColor.default.COLOR_RED_400,
179
+ background: {
180
+ highlight: _seedsColor.default.COLOR_YELLOW_900
181
+ }
179
182
  },
180
183
  icon: {
181
184
  base: _seedsColor.default.COLOR_NEUTRAL_100,