@sproutsocial/racine 11.6.0 → 11.6.1-input-beta.1
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.
- package/CHANGELOG.md +13 -0
- package/__flow__/Checkbox/styles.js +75 -75
- package/__flow__/Collapsible/index.js +3 -2
- package/__flow__/Image/index.js +10 -2
- package/__flow__/Input/index.js +48 -16
- package/__flow__/Input/index.stories.js +14 -0
- package/__flow__/Input/index.test.js +18 -0
- package/__flow__/Input/styles.js +2 -2
- package/__flow__/SegmentedControl/index.js +3 -2
- package/__flow__/TableCell/index.js +9 -2
- package/__flow__/ThemeProvider/index.js +1 -2
- package/__flow__/ToggleHint/index.js +9 -2
- package/__flow__/index.js +1 -2
- package/__flow__/systemProps/color.js +1 -2
- package/__flow__/themes/dark/theme.js +3 -3
- package/__flow__/themes/extendedThemes/sproutTheme/dark/theme.js +34 -15
- package/__flow__/themes/extendedThemes/sproutTheme/index.js +0 -1
- package/__flow__/themes/extendedThemes/sproutTheme/light/theme.js +34 -15
- package/__flow__/types/theme.colors.flow.js +8 -1
- package/__flow__/types/theme.flow.js +10 -13
- package/__flow__/utils/responsiveProps/index.test.js +10 -2
- package/commonjs/Input/index.js +40 -16
- package/commonjs/Input/styles.js +2 -2
- package/commonjs/themes/dark/theme.js +3 -3
- package/commonjs/themes/extendedThemes/sproutTheme/dark/theme.js +36 -15
- package/commonjs/themes/extendedThemes/sproutTheme/light/theme.js +36 -15
- package/commonjs/types/theme.flow.js +3 -1
- package/dist/themes/dark/dark.scss +0 -3
- package/lib/Input/index.js +40 -16
- package/lib/Input/styles.js +2 -2
- package/lib/themes/dark/theme.js +3 -3
- package/lib/themes/extendedThemes/sproutTheme/dark/theme.js +33 -10
- package/lib/themes/extendedThemes/sproutTheme/light/theme.js +33 -10
- package/lib/types/theme.flow.js +2 -1
- package/package.json +2 -3
- package/__flow__/themes/extendedThemes/sproutTheme/NonColorThemeValues/index.js +0 -17
- package/__flow__/themes/extendedThemes/sproutTheme/dark/getDarkThemeColors.js +0 -36
- package/__flow__/themes/extendedThemes/sproutTheme/light/getLightThemeColors.js +0 -36
- package/__flow__/themes/extendedThemes/sproutTheme/sproutThemeType.flow.js +0 -36
- package/commonjs/themes/extendedThemes/sproutTheme/NonColorThemeValues/index.js +0 -16
- package/commonjs/themes/extendedThemes/sproutTheme/dark/getDarkThemeColors.js +0 -39
- package/commonjs/themes/extendedThemes/sproutTheme/light/getLightThemeColors.js +0 -39
- package/commonjs/themes/extendedThemes/sproutTheme/sproutThemeType.flow.js +0 -1
- package/lib/themes/extendedThemes/sproutTheme/NonColorThemeValues/index.js +0 -12
- package/lib/themes/extendedThemes/sproutTheme/dark/getDarkThemeColors.js +0 -34
- package/lib/themes/extendedThemes/sproutTheme/light/getLightThemeColors.js +0 -34
- package/lib/themes/extendedThemes/sproutTheme/sproutThemeType.flow.js +0 -0
|
@@ -229,7 +229,14 @@ type TypeElevationColors = {|
|
|
|
229
229
|
},
|
|
230
230
|
|};
|
|
231
231
|
|
|
232
|
-
type TypeDatavizColors =
|
|
232
|
+
type TypeDatavizColors = {|
|
|
233
|
+
DATAVIZ_COLORS_MAP: typeof datavizPalette.DATAVIZ_COLORS_MAP,
|
|
234
|
+
DATAVIZ_COLORS_LIST: typeof datavizPalette.DATAVIZ_COLORS_LIST,
|
|
235
|
+
dataviz: {
|
|
236
|
+
map: typeof datavizPalette.DATAVIZ_COLORS_MAP,
|
|
237
|
+
list: typeof datavizPalette.DATAVIZ_COLORS_LIST,
|
|
238
|
+
},
|
|
239
|
+
|};
|
|
233
240
|
|
|
234
241
|
type TypeNetworkColors = {|
|
|
235
242
|
network: {
|
|
@@ -13,7 +13,9 @@ 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 |};
|
|
17
19
|
export type TypeThemeMode = "light" | "dark";
|
|
18
20
|
export type TypeBreakpoint = typeof breakpoints;
|
|
19
21
|
export type TypeTypography = typeof typography;
|
|
@@ -30,6 +32,7 @@ export type TypeDuration = typeof duration;
|
|
|
30
32
|
|
|
31
33
|
export type TypeTheme = {
|
|
32
34
|
mode: TypeThemeMode,
|
|
35
|
+
utils: TypeThemeUtils,
|
|
33
36
|
breakpoints: TypeBreakpoint,
|
|
34
37
|
colors: TypeColor,
|
|
35
38
|
typography: TypeTypography,
|
|
@@ -44,17 +47,11 @@ export type TypeTheme = {
|
|
|
44
47
|
duration: TypeDuration,
|
|
45
48
|
};
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
radii: TypeRadii,
|
|
55
|
-
borders: TypeBorder,
|
|
56
|
-
borderWidths: TypeBorderWidth,
|
|
57
|
-
shadows: TypeShadow,
|
|
58
|
-
easing: TypeEasing,
|
|
59
|
-
duration: TypeDuration,
|
|
50
|
+
// Extended themes
|
|
51
|
+
export type TypeSproutTheme = {
|
|
52
|
+
...$Exact<TypeTheme>,
|
|
53
|
+
colors: {|
|
|
54
|
+
...$Exact<TypeColor>,
|
|
55
|
+
navigation: typeof navigation,
|
|
56
|
+
|},
|
|
60
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,
|
|
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,
|
|
32
|
+
0,
|
|
33
|
+
1,
|
|
34
|
+
2,
|
|
35
|
+
3,
|
|
36
|
+
4,
|
|
29
37
|
]);
|
|
30
38
|
});
|
|
31
39
|
});
|
package/commonjs/Input/index.js
CHANGED
|
@@ -44,18 +44,18 @@ var ClearButton = function ClearButton() {
|
|
|
44
44
|
onClear = _React$useContext.onClear,
|
|
45
45
|
handleClear = _React$useContext.handleClear,
|
|
46
46
|
clearButtonLabel = _React$useContext.clearButtonLabel,
|
|
47
|
+
isControlled = _React$useContext.isControlled,
|
|
47
48
|
hasValue = _React$useContext.hasValue,
|
|
48
49
|
inputSize = _React$useContext.size; // Hide the button when there is no text to clear.
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
if (!hasValue) {
|
|
52
53
|
return null;
|
|
53
|
-
} //
|
|
54
|
-
//
|
|
54
|
+
} // Hide the button when no onClear callback is provided to a controlled Input.
|
|
55
|
+
// For a controlled component, all the button would do without an onClear is focus the input.
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
if (!onClear) {
|
|
58
|
-
console.warn("Warning: No onClear prop provided to Input when using Input.ClearButton. Omitting Input.ClearButton.");
|
|
58
|
+
if (isControlled && !onClear) {
|
|
59
59
|
return null;
|
|
60
60
|
} // Warn if clearButtonLabel is not included, so that the unlocalized fallback will not be mistaken for a proper label.
|
|
61
61
|
|
|
@@ -95,14 +95,10 @@ var isClearButton = function isClearButton(elem) {
|
|
|
95
95
|
var Input = /*#__PURE__*/function (_React$Component) {
|
|
96
96
|
_inheritsLoose(Input, _React$Component);
|
|
97
97
|
|
|
98
|
-
function Input() {
|
|
98
|
+
function Input(props) {
|
|
99
99
|
var _this;
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
args[_key] = arguments[_key];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
101
|
+
_this = _React$Component.call(this, props) || this;
|
|
106
102
|
_this.inputRef = /*#__PURE__*/React.createRef();
|
|
107
103
|
|
|
108
104
|
_this.handleBlur = function (e) {
|
|
@@ -110,14 +106,25 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
110
106
|
};
|
|
111
107
|
|
|
112
108
|
_this.handleClear = function (e) {
|
|
113
|
-
var _this$inputRef
|
|
109
|
+
var _this$inputRef$curren;
|
|
110
|
+
|
|
111
|
+
// If the component is uncontrolled, clear its value via ref.
|
|
112
|
+
if (typeof _this.props.value !== "string") {
|
|
113
|
+
if (_this.inputRef.current) {
|
|
114
|
+
_this.inputRef.current.value = "";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
114
117
|
|
|
115
|
-
(_this$inputRef
|
|
118
|
+
(_this$inputRef$curren = _this.inputRef.current) == null ? void 0 : _this$inputRef$curren.focus();
|
|
116
119
|
_this.props.onClear == null ? void 0 : _this.props.onClear(e);
|
|
120
|
+
|
|
121
|
+
_this.updateState("");
|
|
117
122
|
};
|
|
118
123
|
|
|
119
124
|
_this.handleChange = function (e) {
|
|
120
|
-
|
|
125
|
+
_this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
|
|
126
|
+
|
|
127
|
+
_this.updateState(e.currentTarget.value);
|
|
121
128
|
};
|
|
122
129
|
|
|
123
130
|
_this.handleFocus = function (e) {
|
|
@@ -136,6 +143,22 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
136
143
|
return _this.props.onPaste == null ? void 0 : _this.props.onPaste(e, e.currentTarget.value);
|
|
137
144
|
};
|
|
138
145
|
|
|
146
|
+
_this.updateState = function (value) {
|
|
147
|
+
var hasValue = value !== "";
|
|
148
|
+
var hadValue = _this.state.hasValue; // Only update state if the value has changed to avoid unnecessary renders.
|
|
149
|
+
|
|
150
|
+
if (hasValue !== hadValue) {
|
|
151
|
+
_this.setState({
|
|
152
|
+
hasValue: hasValue
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
_this.state = {
|
|
158
|
+
// Tracking hasValue in state allows us to hide ClearButton when there is no value to clear
|
|
159
|
+
// for both controlled and uncontrolled inputs.
|
|
160
|
+
hasValue: !!props.value
|
|
161
|
+
};
|
|
139
162
|
return _this;
|
|
140
163
|
}
|
|
141
164
|
|
|
@@ -189,9 +212,9 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
189
212
|
name: "search",
|
|
190
213
|
ariaHidden: true,
|
|
191
214
|
color: "icon.base"
|
|
192
|
-
}) : elemBefore; // Do not add a ClearButton if
|
|
215
|
+
}) : elemBefore; // Do not add a ClearButton if an elemAfter prop was passed.
|
|
193
216
|
|
|
194
|
-
var elementAfter = type === "search" &&
|
|
217
|
+
var elementAfter = type === "search" && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
|
|
195
218
|
return /*#__PURE__*/React.createElement(_styles.default, _extends({
|
|
196
219
|
hasBeforeElement: !!elementBefore,
|
|
197
220
|
hasAfterElement: !!elementAfter,
|
|
@@ -204,7 +227,8 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
204
227
|
}, rest), /*#__PURE__*/React.createElement(InputContext.Provider, {
|
|
205
228
|
value: {
|
|
206
229
|
handleClear: this.handleClear,
|
|
207
|
-
hasValue:
|
|
230
|
+
hasValue: this.state.hasValue,
|
|
231
|
+
isControlled: typeof this.props.value === "string",
|
|
208
232
|
clearButtonLabel: clearButtonLabel,
|
|
209
233
|
onClear: onClear,
|
|
210
234
|
size: size
|
package/commonjs/Input/styles.js
CHANGED
|
@@ -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[
|
|
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[
|
|
89
|
+
return props.after && (0, _styledComponents.css)(["right:", ";"], props.isClearButton ? 0 : props.theme.space[300]);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
exports.Accessory = Accessory;
|
|
@@ -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
|
|
@@ -1,28 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
|
|
6
|
-
var _justClone = _interopRequireDefault(require("just-clone"));
|
|
4
|
+
exports.navigation = exports.default = void 0;
|
|
7
5
|
|
|
8
6
|
var _theme = _interopRequireDefault(require("../../../dark/theme"));
|
|
9
7
|
|
|
10
|
-
var _getDarkThemeColors = require("./getDarkThemeColors");
|
|
11
|
-
|
|
12
|
-
var _NonColorThemeValues = require("../NonColorThemeValues");
|
|
13
|
-
|
|
14
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
9
|
|
|
16
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); }
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
});
|
|
26
47
|
|
|
27
48
|
var _default = darkTheme;
|
|
28
49
|
exports.default = _default;
|
|
@@ -1,28 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
|
|
6
|
-
var _justClone = _interopRequireDefault(require("just-clone"));
|
|
4
|
+
exports.navigation = exports.default = void 0;
|
|
7
5
|
|
|
8
6
|
var _theme = _interopRequireDefault(require("../../../light/theme"));
|
|
9
7
|
|
|
10
|
-
var _getLightThemeColors = require("./getLightThemeColors");
|
|
11
|
-
|
|
12
|
-
var _NonColorThemeValues = require("../NonColorThemeValues");
|
|
13
|
-
|
|
14
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
9
|
|
|
16
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); }
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
});
|
|
26
47
|
|
|
27
48
|
var _default = lightTheme;
|
|
28
49
|
exports.default = _default;
|
package/lib/Input/index.js
CHANGED
|
@@ -27,18 +27,18 @@ var ClearButton = function ClearButton() {
|
|
|
27
27
|
onClear = _React$useContext.onClear,
|
|
28
28
|
handleClear = _React$useContext.handleClear,
|
|
29
29
|
clearButtonLabel = _React$useContext.clearButtonLabel,
|
|
30
|
+
isControlled = _React$useContext.isControlled,
|
|
30
31
|
hasValue = _React$useContext.hasValue,
|
|
31
32
|
inputSize = _React$useContext.size; // Hide the button when there is no text to clear.
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
if (!hasValue) {
|
|
35
36
|
return null;
|
|
36
|
-
} //
|
|
37
|
-
//
|
|
37
|
+
} // Hide the button when no onClear callback is provided to a controlled Input.
|
|
38
|
+
// For a controlled component, all the button would do without an onClear is focus the input.
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
if (!onClear) {
|
|
41
|
-
console.warn("Warning: No onClear prop provided to Input when using Input.ClearButton. Omitting Input.ClearButton.");
|
|
41
|
+
if (isControlled && !onClear) {
|
|
42
42
|
return null;
|
|
43
43
|
} // Warn if clearButtonLabel is not included, so that the unlocalized fallback will not be mistaken for a proper label.
|
|
44
44
|
|
|
@@ -78,14 +78,10 @@ var isClearButton = function isClearButton(elem) {
|
|
|
78
78
|
var Input = /*#__PURE__*/function (_React$Component) {
|
|
79
79
|
_inheritsLoose(Input, _React$Component);
|
|
80
80
|
|
|
81
|
-
function Input() {
|
|
81
|
+
function Input(props) {
|
|
82
82
|
var _this;
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
args[_key] = arguments[_key];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
84
|
+
_this = _React$Component.call(this, props) || this;
|
|
89
85
|
_this.inputRef = /*#__PURE__*/React.createRef();
|
|
90
86
|
|
|
91
87
|
_this.handleBlur = function (e) {
|
|
@@ -93,14 +89,25 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
93
89
|
};
|
|
94
90
|
|
|
95
91
|
_this.handleClear = function (e) {
|
|
96
|
-
var _this$inputRef
|
|
92
|
+
var _this$inputRef$curren;
|
|
93
|
+
|
|
94
|
+
// If the component is uncontrolled, clear its value via ref.
|
|
95
|
+
if (typeof _this.props.value !== "string") {
|
|
96
|
+
if (_this.inputRef.current) {
|
|
97
|
+
_this.inputRef.current.value = "";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
97
100
|
|
|
98
|
-
(_this$inputRef
|
|
101
|
+
(_this$inputRef$curren = _this.inputRef.current) == null ? void 0 : _this$inputRef$curren.focus();
|
|
99
102
|
_this.props.onClear == null ? void 0 : _this.props.onClear(e);
|
|
103
|
+
|
|
104
|
+
_this.updateState("");
|
|
100
105
|
};
|
|
101
106
|
|
|
102
107
|
_this.handleChange = function (e) {
|
|
103
|
-
|
|
108
|
+
_this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
|
|
109
|
+
|
|
110
|
+
_this.updateState(e.currentTarget.value);
|
|
104
111
|
};
|
|
105
112
|
|
|
106
113
|
_this.handleFocus = function (e) {
|
|
@@ -119,6 +126,22 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
119
126
|
return _this.props.onPaste == null ? void 0 : _this.props.onPaste(e, e.currentTarget.value);
|
|
120
127
|
};
|
|
121
128
|
|
|
129
|
+
_this.updateState = function (value) {
|
|
130
|
+
var hasValue = value !== "";
|
|
131
|
+
var hadValue = _this.state.hasValue; // Only update state if the value has changed to avoid unnecessary renders.
|
|
132
|
+
|
|
133
|
+
if (hasValue !== hadValue) {
|
|
134
|
+
_this.setState({
|
|
135
|
+
hasValue: hasValue
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
_this.state = {
|
|
141
|
+
// Tracking hasValue in state allows us to hide ClearButton when there is no value to clear
|
|
142
|
+
// for both controlled and uncontrolled inputs.
|
|
143
|
+
hasValue: !!props.value
|
|
144
|
+
};
|
|
122
145
|
return _this;
|
|
123
146
|
}
|
|
124
147
|
|
|
@@ -172,9 +195,9 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
172
195
|
name: "search",
|
|
173
196
|
ariaHidden: true,
|
|
174
197
|
color: "icon.base"
|
|
175
|
-
}) : elemBefore; // Do not add a ClearButton if
|
|
198
|
+
}) : elemBefore; // Do not add a ClearButton if an elemAfter prop was passed.
|
|
176
199
|
|
|
177
|
-
var elementAfter = type === "search" &&
|
|
200
|
+
var elementAfter = type === "search" && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
|
|
178
201
|
return /*#__PURE__*/React.createElement(Container, _extends({
|
|
179
202
|
hasBeforeElement: !!elementBefore,
|
|
180
203
|
hasAfterElement: !!elementAfter,
|
|
@@ -187,7 +210,8 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
187
210
|
}, rest), /*#__PURE__*/React.createElement(InputContext.Provider, {
|
|
188
211
|
value: {
|
|
189
212
|
handleClear: this.handleClear,
|
|
190
|
-
hasValue:
|
|
213
|
+
hasValue: this.state.hasValue,
|
|
214
|
+
isControlled: typeof this.props.value === "string",
|
|
191
215
|
clearButtonLabel: clearButtonLabel,
|
|
192
216
|
onClear: onClear,
|
|
193
217
|
size: size
|
package/lib/Input/styles.js
CHANGED
|
@@ -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[
|
|
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[
|
|
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/themes/dark/theme.js
CHANGED
|
@@ -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
|
|
@@ -1,16 +1,39 @@
|
|
|
1
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
2
|
|
|
3
|
-
import clone from "just-clone";
|
|
4
3
|
import baseDarkTheme from "../../../dark/theme";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
};
|
|
9
32
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
var darkTheme = _extends({}, baseDarkTheme, {
|
|
34
|
+
colors: _extends({}, baseDarkTheme.colors, {
|
|
35
|
+
navigation: navigation
|
|
36
|
+
})
|
|
37
|
+
});
|
|
15
38
|
|
|
16
39
|
export default darkTheme;
|
|
@@ -1,16 +1,39 @@
|
|
|
1
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
2
|
|
|
3
|
-
import clone from "just-clone";
|
|
4
3
|
import baseLightTheme from "../../../light/theme";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
};
|
|
9
32
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
var lightTheme = _extends({}, baseLightTheme, {
|
|
34
|
+
colors: _extends({}, baseLightTheme.colors, {
|
|
35
|
+
navigation: navigation
|
|
36
|
+
})
|
|
37
|
+
});
|
|
15
38
|
|
|
16
39
|
export default lightTheme;
|
package/lib/types/theme.flow.js
CHANGED
|
@@ -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.6.
|
|
3
|
+
"version": "11.6.1-input-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"__flow__",
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@styled-system/theme-get": "^5.1.2",
|
|
68
68
|
"classnames": "^2.2.6",
|
|
69
|
-
"just-clone": "^5.0.1",
|
|
70
69
|
"lodash.curry": "^4.1.1",
|
|
71
70
|
"lodash.uniqueid": "^4.0.1",
|
|
72
71
|
"lru-memoize": "^1.1.0",
|
|
@@ -167,7 +166,7 @@
|
|
|
167
166
|
"svgo": "^1.3.0",
|
|
168
167
|
"svgstore": "^2.0.3",
|
|
169
168
|
"webpack": "^4.20.0",
|
|
170
|
-
"webpack-dev-server": "^
|
|
169
|
+
"webpack-dev-server": "^4.9.0"
|
|
171
170
|
},
|
|
172
171
|
"peerDependencies": {
|
|
173
172
|
"@sproutsocial/seeds-border": ">=0.3.0",
|