@sproutsocial/racine 11.5.0 → 11.6.1-input-beta.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 (39) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/__flow__/Checkbox/styles.js +75 -75
  3. package/__flow__/Collapsible/index.js +3 -2
  4. package/__flow__/Image/index.js +10 -2
  5. package/__flow__/Input/index.js +43 -23
  6. package/__flow__/Input/index.stories.js +14 -0
  7. package/__flow__/Input/index.test.js +20 -0
  8. package/__flow__/Input/styles.js +2 -2
  9. package/__flow__/SegmentedControl/index.js +3 -2
  10. package/__flow__/TableCell/index.js +9 -2
  11. package/__flow__/ThemeProvider/index.js +5 -2
  12. package/__flow__/ToggleHint/index.js +9 -2
  13. package/__flow__/index.js +5 -1
  14. package/__flow__/systemProps/color.js +1 -2
  15. package/__flow__/themes/dark/theme.js +3 -3
  16. package/__flow__/themes/extendedThemes/sproutTheme/dark/theme.js +42 -0
  17. package/__flow__/themes/extendedThemes/sproutTheme/index.js +3 -0
  18. package/__flow__/themes/extendedThemes/sproutTheme/light/theme.js +42 -0
  19. package/__flow__/types/theme.colors.flow.js +8 -1
  20. package/__flow__/types/theme.flow.js +14 -0
  21. package/__flow__/utils/responsiveProps/index.test.js +10 -2
  22. package/commonjs/Input/index.js +39 -22
  23. package/commonjs/Input/styles.js +2 -2
  24. package/commonjs/index.js +8 -1
  25. package/commonjs/themes/dark/theme.js +3 -3
  26. package/commonjs/themes/extendedThemes/sproutTheme/dark/theme.js +49 -0
  27. package/commonjs/themes/extendedThemes/sproutTheme/index.js +14 -0
  28. package/commonjs/themes/extendedThemes/sproutTheme/light/theme.js +49 -0
  29. package/commonjs/types/theme.flow.js +3 -1
  30. package/dist/themes/dark/dark.scss +0 -3
  31. package/lib/Input/index.js +39 -22
  32. package/lib/Input/styles.js +2 -2
  33. package/lib/index.js +1 -0
  34. package/lib/themes/dark/theme.js +3 -3
  35. package/lib/themes/extendedThemes/sproutTheme/dark/theme.js +39 -0
  36. package/lib/themes/extendedThemes/sproutTheme/index.js +2 -0
  37. package/lib/themes/extendedThemes/sproutTheme/light/theme.js +39 -0
  38. package/lib/types/theme.flow.js +2 -1
  39. package/package.json +2 -2
@@ -13,7 +13,10 @@ import {
13
13
  } from "../themes/light/theme";
14
14
  import type { TypeColors } from "./theme.colors.flow.js";
15
15
  import type { TypeFontFamilyString } from "../themes/light/theme";
16
+ import { navigation } from "../themes/extendedThemes/sproutTheme/light/theme";
16
17
 
18
+ export type TypeThemeUtils = {| interact: (color: string) => string |};
19
+ export type TypeThemeMode = "light" | "dark";
17
20
  export type TypeBreakpoint = typeof breakpoints;
18
21
  export type TypeTypography = typeof typography;
19
22
  export type TypeFontWeight = typeof fontWeights;
@@ -28,6 +31,8 @@ export type TypeEasing = typeof easing;
28
31
  export type TypeDuration = typeof duration;
29
32
 
30
33
  export type TypeTheme = {
34
+ mode: TypeThemeMode,
35
+ utils: TypeThemeUtils,
31
36
  breakpoints: TypeBreakpoint,
32
37
  colors: TypeColor,
33
38
  typography: TypeTypography,
@@ -41,3 +46,12 @@ export type TypeTheme = {
41
46
  easing: TypeEasing,
42
47
  duration: TypeDuration,
43
48
  };
49
+
50
+ // Extended themes
51
+ export type TypeSproutTheme = {
52
+ ...$Exact<TypeTheme>,
53
+ colors: {|
54
+ ...$Exact<TypeColor>,
55
+ navigation: typeof navigation,
56
+ |},
57
+ };
@@ -19,13 +19,21 @@ describe("normalizeResponsiveProp", () => {
19
19
 
20
20
  it("should handle arrays with 4 values", () => {
21
21
  expect(normalizeResponsiveProp([0, 1, 2, 3])).toMatchObject([
22
- 0, 1, 2, 3, 3,
22
+ 0,
23
+ 1,
24
+ 2,
25
+ 3,
26
+ 3,
23
27
  ]);
24
28
  });
25
29
 
26
30
  it("should handle arrays with 5 values", () => {
27
31
  expect(normalizeResponsiveProp([0, 1, 2, 3, 4])).toMatchObject([
28
- 0, 1, 2, 3, 4,
32
+ 0,
33
+ 1,
34
+ 2,
35
+ 3,
36
+ 4,
29
37
  ]);
30
38
  });
31
39
  });
@@ -41,7 +41,6 @@ var StyledButton = (0, _styledComponents.default)(_Button.default).withConfig({
41
41
 
42
42
  var ClearButton = function ClearButton() {
43
43
  var _React$useContext = React.useContext(InputContext),
44
- onClear = _React$useContext.onClear,
45
44
  handleClear = _React$useContext.handleClear,
46
45
  clearButtonLabel = _React$useContext.clearButtonLabel,
47
46
  hasValue = _React$useContext.hasValue,
@@ -50,13 +49,6 @@ var ClearButton = function ClearButton() {
50
49
 
51
50
  if (!hasValue) {
52
51
  return null;
53
- } // Log a warning and hide the button when no onClear callback is provided.
54
- // If we called handleClear with no onClear prop, all the button would do is focus the Input.
55
-
56
-
57
- if (!onClear) {
58
- console.warn("Warning: No onClear prop provided to Input when using Input.ClearButton. Omitting Input.ClearButton.");
59
- return null;
60
52
  } // Warn if clearButtonLabel is not included, so that the unlocalized fallback will not be mistaken for a proper label.
61
53
 
62
54
 
@@ -95,14 +87,10 @@ var isClearButton = function isClearButton(elem) {
95
87
  var Input = /*#__PURE__*/function (_React$Component) {
96
88
  _inheritsLoose(Input, _React$Component);
97
89
 
98
- function Input() {
90
+ function Input(props) {
99
91
  var _this;
100
92
 
101
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
102
- args[_key] = arguments[_key];
103
- }
104
-
105
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
93
+ _this = _React$Component.call(this, props) || this;
106
94
  _this.inputRef = /*#__PURE__*/React.createRef();
107
95
 
108
96
  _this.handleBlur = function (e) {
@@ -110,14 +98,28 @@ var Input = /*#__PURE__*/function (_React$Component) {
110
98
  };
111
99
 
112
100
  _this.handleClear = function (e) {
113
- var _this$inputRef, _this$inputRef$curren;
101
+ var input = _this.inputRef.current;
102
+
103
+ if (input) {
104
+ // Clear the value via ref, then dispatch an input event in order to trigger handleChange
105
+ input.value = "";
106
+ var inputEvent = new Event("input", {
107
+ bubbles: true
108
+ });
109
+ input.dispatchEvent(inputEvent); // Focus the input, update hasValue, and call any onClear callback
110
+
111
+ input.focus();
112
+
113
+ _this.updateState("");
114
114
 
115
- (_this$inputRef = _this.inputRef) == null ? void 0 : (_this$inputRef$curren = _this$inputRef.current) == null ? void 0 : _this$inputRef$curren.focus();
116
- _this.props.onClear == null ? void 0 : _this.props.onClear(e);
115
+ _this.props.onClear == null ? void 0 : _this.props.onClear(e);
116
+ }
117
117
  };
118
118
 
119
119
  _this.handleChange = function (e) {
120
- return _this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
120
+ _this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
121
+
122
+ _this.updateState(e.currentTarget.value);
121
123
  };
122
124
 
123
125
  _this.handleFocus = function (e) {
@@ -136,6 +138,22 @@ var Input = /*#__PURE__*/function (_React$Component) {
136
138
  return _this.props.onPaste == null ? void 0 : _this.props.onPaste(e, e.currentTarget.value);
137
139
  };
138
140
 
141
+ _this.updateState = function (inputValue) {
142
+ var hasValue = inputValue !== "";
143
+ var previousHasValue = _this.state.hasValue; // Only update state if the value of `hasValue` has changed to avoid unnecessary renders.
144
+
145
+ if (hasValue !== previousHasValue) {
146
+ _this.setState({
147
+ hasValue: hasValue
148
+ });
149
+ }
150
+ };
151
+
152
+ _this.state = {
153
+ // Tracking hasValue in state allows us to hide ClearButton when there is no value to clear
154
+ // for both controlled and uncontrolled inputs.
155
+ hasValue: !!props.value
156
+ };
139
157
  return _this;
140
158
  }
141
159
 
@@ -189,9 +207,9 @@ var Input = /*#__PURE__*/function (_React$Component) {
189
207
  name: "search",
190
208
  ariaHidden: true,
191
209
  color: "icon.base"
192
- }) : elemBefore; // Do not add a ClearButton if no onClear callback is provided or if an elemAfter prop was passed.
210
+ }) : elemBefore; // Do not add a ClearButton if an elemAfter prop was passed.
193
211
 
194
- var elementAfter = type === "search" && onClear && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
212
+ var elementAfter = type === "search" && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
195
213
  return /*#__PURE__*/React.createElement(_styles.default, _extends({
196
214
  hasBeforeElement: !!elementBefore,
197
215
  hasAfterElement: !!elementAfter,
@@ -204,9 +222,8 @@ var Input = /*#__PURE__*/function (_React$Component) {
204
222
  }, rest), /*#__PURE__*/React.createElement(InputContext.Provider, {
205
223
  value: {
206
224
  handleClear: this.handleClear,
207
- hasValue: !!value,
225
+ hasValue: this.state.hasValue,
208
226
  clearButtonLabel: clearButtonLabel,
209
- onClear: onClear,
210
227
  size: size
211
228
  }
212
229
  }, elementBefore && /*#__PURE__*/React.createElement(_styles.Accessory, {
@@ -84,9 +84,9 @@ var Accessory = _styledComponents.default.div.withConfig({
84
84
  })(["position:absolute;top:50%;transform:translateY(-50%);color:", ";display:flex;align-items:center;", ";", ";"], function (props) {
85
85
  return props.theme.colors.icon.base;
86
86
  }, function (props) {
87
- return props.before && (0, _styledComponents.css)(["left:", ";"], props.theme.space[350]);
87
+ return props.before && (0, _styledComponents.css)(["left:", ";"], props.theme.space[300]);
88
88
  }, function (props) {
89
- return props.after && (0, _styledComponents.css)(["right:", ";"], props.isClearButton ? 0 : props.theme.space[350]);
89
+ return props.after && (0, _styledComponents.css)(["right:", ";"], props.isClearButton ? 0 : props.theme.space[300]);
90
90
  });
91
91
 
92
92
  exports.Accessory = Accessory;
package/commonjs/index.js CHANGED
@@ -61,6 +61,8 @@ var _exportNames = {
61
61
  Menu: true,
62
62
  Listbox: true,
63
63
  OverflowList: true,
64
+ sproutLightTheme: true,
65
+ sproutDarkTheme: true,
64
66
  toast: true,
65
67
  MenuButton: true,
66
68
  MenuButtonContext: true,
@@ -70,7 +72,7 @@ var _exportNames = {
70
72
  DateRangePicker: true,
71
73
  VisuallyHidden: true
72
74
  };
73
- exports.visuallyHidden = exports.useTextContent = exports.useSelect = exports.useMultiselect = exports.toast = exports.theme = exports.focusRing = exports.disabled = exports.darkTheme = exports.VisuallyHidden = exports.Tooltip = exports.TokenInput = exports.Token = exports.ToggleHint = exports.ToastContainer = exports.ThemeProvider = exports.Textarea = exports.Text = exports.Tabs = exports.TableRowAccordion = exports.TableHeaderCell = exports.TableCell = exports.Table = exports.Switch = exports.Stack = exports.Skeleton = exports.SingleDatePicker = exports.Select = exports.SegmentedControl = exports.Radio = exports.Popout = exports.OverflowList = exports.Numeral = exports.Modal = exports.Message = exports.MenuItemContainer = exports.MenuButtonContext = exports.MenuButton = exports.Menu = exports.LoaderButton = exports.Loader = exports.ListboxButton = exports.Listbox = exports.Link = exports.Label = exports.KeyboardKey = exports.Input = exports.Indicator = exports.Image = exports.Icon = exports.FormField = exports.Fieldset = exports.EmptyState = exports.Drawer = exports.DateRangePicker = exports.Collapsible = exports.Checkbox = exports.ChartLegend = exports.CharacterCounter = exports.Card = exports.Button = exports.Breadcrumb = exports.Box = exports.Banner = exports.Badge = exports.Avatar = exports.Alert = void 0;
75
+ exports.visuallyHidden = exports.useTextContent = exports.useSelect = exports.useMultiselect = exports.toast = exports.theme = exports.sproutLightTheme = exports.sproutDarkTheme = exports.focusRing = exports.disabled = exports.darkTheme = exports.VisuallyHidden = exports.Tooltip = exports.TokenInput = exports.Token = exports.ToggleHint = exports.ToastContainer = exports.ThemeProvider = exports.Textarea = exports.Text = exports.Tabs = exports.TableRowAccordion = exports.TableHeaderCell = exports.TableCell = exports.Table = exports.Switch = exports.Stack = exports.Skeleton = exports.SingleDatePicker = exports.Select = exports.SegmentedControl = exports.Radio = exports.Popout = exports.OverflowList = exports.Numeral = exports.Modal = exports.Message = exports.MenuItemContainer = exports.MenuButtonContext = exports.MenuButton = exports.Menu = exports.LoaderButton = exports.Loader = exports.ListboxButton = exports.Listbox = exports.Link = exports.Label = exports.KeyboardKey = exports.Input = exports.Indicator = exports.Image = exports.Icon = exports.FormField = exports.Fieldset = exports.EmptyState = exports.Drawer = exports.DateRangePicker = exports.Collapsible = exports.Checkbox = exports.ChartLegend = exports.CharacterCounter = exports.Card = exports.Button = exports.Breadcrumb = exports.Box = exports.Banner = exports.Badge = exports.Avatar = exports.Alert = void 0;
74
76
 
75
77
  var _systemProps = require("./systemProps");
76
78
 
@@ -101,6 +103,11 @@ var _theme2 = _interopRequireDefault(require("./themes/dark/theme"));
101
103
 
102
104
  exports.darkTheme = _theme2.default;
103
105
 
106
+ var _sproutTheme = require("./themes/extendedThemes/sproutTheme");
107
+
108
+ exports.sproutLightTheme = _sproutTheme.sproutLightTheme;
109
+ exports.sproutDarkTheme = _sproutTheme.sproutDarkTheme;
110
+
104
111
  var _Icon = _interopRequireDefault(require("./Icon"));
105
112
 
106
113
  exports.Icon = _Icon.default;
@@ -31,9 +31,6 @@ var shadows = {
31
31
  exports.shadows = shadows;
32
32
 
33
33
  var colors = _extends({}, _theme.default.colors, {
34
- utils: {
35
- interact: (0, _interact.default)(MODE)
36
- },
37
34
  app: {
38
35
  background: {
39
36
  base: _seedsColor.default.COLOR_NEUTRAL_1000
@@ -237,6 +234,9 @@ var colors = _extends({}, _theme.default.colors, {
237
234
  }, _datavizPalette.datavizPalette);
238
235
 
239
236
  var darkTheme = _extends({}, _theme.default, {
237
+ utils: {
238
+ interact: (0, _interact.default)(MODE)
239
+ },
240
240
  colors: colors,
241
241
  shadows: shadows,
242
242
  mode: MODE
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.navigation = exports.default = void 0;
5
+
6
+ var _theme = _interopRequireDefault(require("../../../dark/theme"));
7
+
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+
10
+ 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); }
11
+
12
+ var navigation = {
13
+ main: {
14
+ background: {
15
+ base: _theme.default.colors.neutral[1000],
16
+ overflowGradient: _theme.default.colors.neutral[1100]
17
+ }
18
+ },
19
+ secondary: {
20
+ background: {
21
+ base: _theme.default.colors.neutral[900]
22
+ }
23
+ },
24
+ text: {
25
+ base: _theme.default.colors.neutral[0],
26
+ hover: _theme.default.colors.neutral[0]
27
+ },
28
+ icon: {
29
+ base: _theme.default.colors.neutral[0],
30
+ hover: _theme.default.colors.neutral[0]
31
+ },
32
+ listItem: {
33
+ background: {
34
+ base: _theme.default.colors.neutral[1000],
35
+ hover: _theme.default.colors.neutral[1100],
36
+ selected: _theme.default.colors.neutral[700]
37
+ }
38
+ }
39
+ };
40
+ exports.navigation = navigation;
41
+
42
+ var darkTheme = _extends({}, _theme.default, {
43
+ colors: _extends({}, _theme.default.colors, {
44
+ navigation: navigation
45
+ })
46
+ });
47
+
48
+ var _default = darkTheme;
49
+ exports.default = _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.sproutLightTheme = exports.sproutDarkTheme = void 0;
5
+
6
+ var _theme = _interopRequireDefault(require("./light/theme"));
7
+
8
+ exports.sproutLightTheme = _theme.default;
9
+
10
+ var _theme2 = _interopRequireDefault(require("./dark/theme"));
11
+
12
+ exports.sproutDarkTheme = _theme2.default;
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.navigation = exports.default = void 0;
5
+
6
+ var _theme = _interopRequireDefault(require("../../../light/theme"));
7
+
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+
10
+ 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); }
11
+
12
+ var navigation = {
13
+ main: {
14
+ background: {
15
+ base: _theme.default.colors.neutral[900],
16
+ overflowGradient: _theme.default.colors.neutral[1000]
17
+ }
18
+ },
19
+ secondary: {
20
+ background: {
21
+ base: _theme.default.colors.neutral[800]
22
+ }
23
+ },
24
+ text: {
25
+ base: _theme.default.colors.neutral[0],
26
+ hover: _theme.default.colors.neutral[0]
27
+ },
28
+ icon: {
29
+ base: _theme.default.colors.neutral[0],
30
+ hover: _theme.default.colors.neutral[0]
31
+ },
32
+ listItem: {
33
+ background: {
34
+ base: _theme.default.colors.neutral[800],
35
+ hover: _theme.default.colors.neutral[1000],
36
+ selected: _theme.default.colors.neutral[700]
37
+ }
38
+ }
39
+ };
40
+ exports.navigation = navigation;
41
+
42
+ var lightTheme = _extends({}, _theme.default, {
43
+ colors: _extends({}, _theme.default.colors, {
44
+ navigation: navigation
45
+ })
46
+ });
47
+
48
+ var _default = lightTheme;
49
+ exports.default = _default;
@@ -1,3 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _theme = require("../themes/light/theme");
3
+ var _theme = require("../themes/light/theme");
4
+
5
+ var _theme2 = require("../themes/extendedThemes/sproutTheme/light/theme");
@@ -430,9 +430,6 @@ $dark: (
430
430
  18: #ff7f6e,
431
431
  19: #c2f2bd,
432
432
  20: #ffe99a
433
- ),
434
- utils: (
435
-
436
433
  )
437
434
  ),
438
435
  typography: (
@@ -24,7 +24,6 @@ var StyledButton = styled(Button).withConfig({
24
24
 
25
25
  var ClearButton = function ClearButton() {
26
26
  var _React$useContext = React.useContext(InputContext),
27
- onClear = _React$useContext.onClear,
28
27
  handleClear = _React$useContext.handleClear,
29
28
  clearButtonLabel = _React$useContext.clearButtonLabel,
30
29
  hasValue = _React$useContext.hasValue,
@@ -33,13 +32,6 @@ var ClearButton = function ClearButton() {
33
32
 
34
33
  if (!hasValue) {
35
34
  return null;
36
- } // Log a warning and hide the button when no onClear callback is provided.
37
- // If we called handleClear with no onClear prop, all the button would do is focus the Input.
38
-
39
-
40
- if (!onClear) {
41
- console.warn("Warning: No onClear prop provided to Input when using Input.ClearButton. Omitting Input.ClearButton.");
42
- return null;
43
35
  } // Warn if clearButtonLabel is not included, so that the unlocalized fallback will not be mistaken for a proper label.
44
36
 
45
37
 
@@ -78,14 +70,10 @@ var isClearButton = function isClearButton(elem) {
78
70
  var Input = /*#__PURE__*/function (_React$Component) {
79
71
  _inheritsLoose(Input, _React$Component);
80
72
 
81
- function Input() {
73
+ function Input(props) {
82
74
  var _this;
83
75
 
84
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
85
- args[_key] = arguments[_key];
86
- }
87
-
88
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
76
+ _this = _React$Component.call(this, props) || this;
89
77
  _this.inputRef = /*#__PURE__*/React.createRef();
90
78
 
91
79
  _this.handleBlur = function (e) {
@@ -93,14 +81,28 @@ var Input = /*#__PURE__*/function (_React$Component) {
93
81
  };
94
82
 
95
83
  _this.handleClear = function (e) {
96
- var _this$inputRef, _this$inputRef$curren;
84
+ var input = _this.inputRef.current;
85
+
86
+ if (input) {
87
+ // Clear the value via ref, then dispatch an input event in order to trigger handleChange
88
+ input.value = "";
89
+ var inputEvent = new Event("input", {
90
+ bubbles: true
91
+ });
92
+ input.dispatchEvent(inputEvent); // Focus the input, update hasValue, and call any onClear callback
93
+
94
+ input.focus();
95
+
96
+ _this.updateState("");
97
97
 
98
- (_this$inputRef = _this.inputRef) == null ? void 0 : (_this$inputRef$curren = _this$inputRef.current) == null ? void 0 : _this$inputRef$curren.focus();
99
- _this.props.onClear == null ? void 0 : _this.props.onClear(e);
98
+ _this.props.onClear == null ? void 0 : _this.props.onClear(e);
99
+ }
100
100
  };
101
101
 
102
102
  _this.handleChange = function (e) {
103
- return _this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
103
+ _this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
104
+
105
+ _this.updateState(e.currentTarget.value);
104
106
  };
105
107
 
106
108
  _this.handleFocus = function (e) {
@@ -119,6 +121,22 @@ var Input = /*#__PURE__*/function (_React$Component) {
119
121
  return _this.props.onPaste == null ? void 0 : _this.props.onPaste(e, e.currentTarget.value);
120
122
  };
121
123
 
124
+ _this.updateState = function (inputValue) {
125
+ var hasValue = inputValue !== "";
126
+ var previousHasValue = _this.state.hasValue; // Only update state if the value of `hasValue` has changed to avoid unnecessary renders.
127
+
128
+ if (hasValue !== previousHasValue) {
129
+ _this.setState({
130
+ hasValue: hasValue
131
+ });
132
+ }
133
+ };
134
+
135
+ _this.state = {
136
+ // Tracking hasValue in state allows us to hide ClearButton when there is no value to clear
137
+ // for both controlled and uncontrolled inputs.
138
+ hasValue: !!props.value
139
+ };
122
140
  return _this;
123
141
  }
124
142
 
@@ -172,9 +190,9 @@ var Input = /*#__PURE__*/function (_React$Component) {
172
190
  name: "search",
173
191
  ariaHidden: true,
174
192
  color: "icon.base"
175
- }) : elemBefore; // Do not add a ClearButton if no onClear callback is provided or if an elemAfter prop was passed.
193
+ }) : elemBefore; // Do not add a ClearButton if an elemAfter prop was passed.
176
194
 
177
- var elementAfter = type === "search" && onClear && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
195
+ var elementAfter = type === "search" && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
178
196
  return /*#__PURE__*/React.createElement(Container, _extends({
179
197
  hasBeforeElement: !!elementBefore,
180
198
  hasAfterElement: !!elementAfter,
@@ -187,9 +205,8 @@ var Input = /*#__PURE__*/function (_React$Component) {
187
205
  }, rest), /*#__PURE__*/React.createElement(InputContext.Provider, {
188
206
  value: {
189
207
  handleClear: this.handleClear,
190
- hasValue: !!value,
208
+ hasValue: this.state.hasValue,
191
209
  clearButtonLabel: clearButtonLabel,
192
- onClear: onClear,
193
210
  size: size
194
211
  }
195
212
  }, elementBefore && /*#__PURE__*/React.createElement(Accessory, {
@@ -71,9 +71,9 @@ export var Accessory = styled.div.withConfig({
71
71
  })(["position:absolute;top:50%;transform:translateY(-50%);color:", ";display:flex;align-items:center;", ";", ";"], function (props) {
72
72
  return props.theme.colors.icon.base;
73
73
  }, function (props) {
74
- return props.before && css(["left:", ";"], props.theme.space[350]);
74
+ return props.before && css(["left:", ";"], props.theme.space[300]);
75
75
  }, function (props) {
76
- return props.after && css(["right:", ";"], props.isClearButton ? 0 : props.theme.space[350]);
76
+ return props.after && css(["right:", ";"], props.isClearButton ? 0 : props.theme.space[300]);
77
77
  });
78
78
  Container.displayName = "InputContainer";
79
79
  Accessory.displayName = "InputAccessory";
package/lib/index.js CHANGED
@@ -3,6 +3,7 @@ export { visuallyHidden, focusRing, disabled } from "./utils/mixins";
3
3
  export { useSelect, useMultiselect, useTextContent } from "./utils/hooks";
4
4
  export { default as theme } from "./themes/light/theme";
5
5
  export { default as darkTheme } from "./themes/dark/theme";
6
+ export { sproutLightTheme, sproutDarkTheme } from "./themes/extendedThemes/sproutTheme";
6
7
  export { default as Icon } from "./Icon"; // DEPRECATED: Alert has been renamed to Banner
7
8
 
8
9
  export { default as Alert } from "./Banner";
@@ -15,9 +15,6 @@ export var shadows = {
15
15
  }; // If you are making changes to the colors in the theme file tag the Design Systems team on your PR! Thank you!!
16
16
 
17
17
  var colors = _extends({}, lightTheme.colors, {
18
- utils: {
19
- interact: interact(MODE)
20
- },
21
18
  app: {
22
19
  background: {
23
20
  base: COLORS.COLOR_NEUTRAL_1000
@@ -221,6 +218,9 @@ var colors = _extends({}, lightTheme.colors, {
221
218
  }, datavizPalette);
222
219
 
223
220
  var darkTheme = _extends({}, lightTheme, {
221
+ utils: {
222
+ interact: interact(MODE)
223
+ },
224
224
  colors: colors,
225
225
  shadows: shadows,
226
226
  mode: MODE
@@ -0,0 +1,39 @@
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
+ import baseDarkTheme from "../../../dark/theme";
4
+ export var navigation = {
5
+ main: {
6
+ background: {
7
+ base: baseDarkTheme.colors.neutral[1000],
8
+ overflowGradient: baseDarkTheme.colors.neutral[1100]
9
+ }
10
+ },
11
+ secondary: {
12
+ background: {
13
+ base: baseDarkTheme.colors.neutral[900]
14
+ }
15
+ },
16
+ text: {
17
+ base: baseDarkTheme.colors.neutral[0],
18
+ hover: baseDarkTheme.colors.neutral[0]
19
+ },
20
+ icon: {
21
+ base: baseDarkTheme.colors.neutral[0],
22
+ hover: baseDarkTheme.colors.neutral[0]
23
+ },
24
+ listItem: {
25
+ background: {
26
+ base: baseDarkTheme.colors.neutral[1000],
27
+ hover: baseDarkTheme.colors.neutral[1100],
28
+ selected: baseDarkTheme.colors.neutral[700]
29
+ }
30
+ }
31
+ };
32
+
33
+ var darkTheme = _extends({}, baseDarkTheme, {
34
+ colors: _extends({}, baseDarkTheme.colors, {
35
+ navigation: navigation
36
+ })
37
+ });
38
+
39
+ export default darkTheme;
@@ -0,0 +1,2 @@
1
+ export { default as sproutLightTheme } from "./light/theme";
2
+ export { default as sproutDarkTheme } from "./dark/theme";
@@ -0,0 +1,39 @@
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
+ import baseLightTheme from "../../../light/theme";
4
+ export var navigation = {
5
+ main: {
6
+ background: {
7
+ base: baseLightTheme.colors.neutral[900],
8
+ overflowGradient: baseLightTheme.colors.neutral[1000]
9
+ }
10
+ },
11
+ secondary: {
12
+ background: {
13
+ base: baseLightTheme.colors.neutral[800]
14
+ }
15
+ },
16
+ text: {
17
+ base: baseLightTheme.colors.neutral[0],
18
+ hover: baseLightTheme.colors.neutral[0]
19
+ },
20
+ icon: {
21
+ base: baseLightTheme.colors.neutral[0],
22
+ hover: baseLightTheme.colors.neutral[0]
23
+ },
24
+ listItem: {
25
+ background: {
26
+ base: baseLightTheme.colors.neutral[800],
27
+ hover: baseLightTheme.colors.neutral[1000],
28
+ selected: baseLightTheme.colors.neutral[700]
29
+ }
30
+ }
31
+ };
32
+
33
+ var lightTheme = _extends({}, baseLightTheme, {
34
+ colors: _extends({}, baseLightTheme.colors, {
35
+ navigation: navigation
36
+ })
37
+ });
38
+
39
+ export default lightTheme;
@@ -1 +1,2 @@
1
- import { breakpoints, typography, fontWeights, radii, borders, borderWidths, shadows, space, easing, duration } from "../themes/light/theme";
1
+ import { breakpoints, typography, fontWeights, radii, borders, borderWidths, shadows, space, easing, duration } from "../themes/light/theme";
2
+ import { navigation } from "../themes/extendedThemes/sproutTheme/light/theme";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/racine",
3
- "version": "11.5.0",
3
+ "version": "11.6.1-input-beta.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "__flow__",
@@ -166,7 +166,7 @@
166
166
  "svgo": "^1.3.0",
167
167
  "svgstore": "^2.0.3",
168
168
  "webpack": "^4.20.0",
169
- "webpack-dev-server": "^3.11.0"
169
+ "webpack-dev-server": "^4.9.0"
170
170
  },
171
171
  "peerDependencies": {
172
172
  "@sproutsocial/seeds-border": ">=0.3.0",