@sproutsocial/racine 11.7.0 → 11.9.0-typescript.0
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 +25 -0
- package/__flow__/Button/{index.js → index.tsx} +20 -21
- package/__flow__/Button/{styles.js → styles.ts} +1 -1
- package/__flow__/Checkbox/index.stories.js +73 -56
- package/__flow__/Checkbox/styles.js +75 -75
- package/__flow__/Collapsible/index.js +3 -2
- package/__flow__/EnumIconNames.js +1 -1
- package/__flow__/Icon/index.stories.js +41 -36
- package/__flow__/IconViewBoxes.js +1 -1
- package/__flow__/Image/index.js +10 -2
- package/__flow__/Input/index.js +47 -23
- package/__flow__/Input/index.stories.js +59 -33
- package/__flow__/Input/index.test.js +20 -0
- package/__flow__/Input/styles.js +2 -2
- package/__flow__/Loader/index.stories.js +18 -14
- package/__flow__/Numeral/index.stories.js +109 -50
- package/__flow__/Radio/index.stories.js +41 -26
- package/__flow__/SegmentedControl/index.js +3 -2
- package/__flow__/Switch/index.stories.js +26 -18
- package/__flow__/TableCell/index.js +9 -2
- package/__flow__/ToggleHint/index.js +9 -2
- package/__flow__/systemProps/color.js +1 -2
- package/__flow__/utils/responsiveProps/index.test.js +10 -2
- package/commonjs/IconViewBoxes.js +2 -0
- package/commonjs/Input/index.js +42 -22
- package/commonjs/Input/styles.js +2 -2
- package/commonjs/include-icons.js +1 -1
- package/dist/iconList.js +1 -1
- package/dist/icons.svg +1 -1
- package/icons/help-alt.svg +3 -0
- package/icons/plug.svg +3 -0
- package/includeIcons.js +1 -1
- package/lib/IconViewBoxes.js +2 -0
- package/lib/Input/index.js +42 -22
- package/lib/Input/styles.js +2 -2
- package/lib/include-icons.js +1 -1
- package/package.json +6 -1
- package/commonjs/Button/index.js +0 -70
- package/commonjs/Button/styles.js +0 -66
- package/lib/Button/index.js +0 -57
- package/lib/Button/styles.js +0 -48
package/lib/IconViewBoxes.js
CHANGED
|
@@ -171,6 +171,7 @@ module.exports = {
|
|
|
171
171
|
"heart-outline": "0 0 16 16",
|
|
172
172
|
"heart": "0 0 16 16",
|
|
173
173
|
"heartbeat": "0 0 18 16",
|
|
174
|
+
"help-alt": "0 0 12 16",
|
|
174
175
|
"help": "0 0 16 16",
|
|
175
176
|
"hiking": "0 0 16 16",
|
|
176
177
|
"history": "0 0 16 16",
|
|
@@ -253,6 +254,7 @@ module.exports = {
|
|
|
253
254
|
"pinterest": "0 0 16 16",
|
|
254
255
|
"play-circle": "0 0 16 16",
|
|
255
256
|
"play": "0 0 14 16",
|
|
257
|
+
"plug": "0 0 12 16",
|
|
256
258
|
"plus": "0 0 16 18",
|
|
257
259
|
"positive-sentiment": "0 0 16 16",
|
|
258
260
|
"power-up-outline": "0 0 12 16",
|
package/lib/Input/index.js
CHANGED
|
@@ -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
|
-
|
|
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,31 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
93
81
|
};
|
|
94
82
|
|
|
95
83
|
_this.handleClear = function (e) {
|
|
96
|
-
var
|
|
84
|
+
var input = _this.inputRef.current;
|
|
85
|
+
|
|
86
|
+
if (input) {
|
|
87
|
+
var _Object$getOwnPropert;
|
|
88
|
+
|
|
89
|
+
// Clear the value via the input prototype, then dispatch an input event in order to trigger handleChange
|
|
90
|
+
var nativeInputValueSetter = (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")) == null ? void 0 : _Object$getOwnPropert.set;
|
|
91
|
+
nativeInputValueSetter == null ? void 0 : nativeInputValueSetter.call(input, "");
|
|
92
|
+
var inputEvent = new Event("input", {
|
|
93
|
+
bubbles: true
|
|
94
|
+
});
|
|
95
|
+
input.dispatchEvent(inputEvent); // Focus the input, update hasValue, and call any onClear callback
|
|
96
|
+
|
|
97
|
+
input.focus();
|
|
98
|
+
|
|
99
|
+
_this.updateState("");
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
_this.props.onClear == null ? void 0 : _this.props.onClear(e);
|
|
102
|
+
}
|
|
100
103
|
};
|
|
101
104
|
|
|
102
105
|
_this.handleChange = function (e) {
|
|
103
|
-
|
|
106
|
+
_this.props.onChange == null ? void 0 : _this.props.onChange(e, e.currentTarget.value);
|
|
107
|
+
|
|
108
|
+
_this.updateState(e.currentTarget.value);
|
|
104
109
|
};
|
|
105
110
|
|
|
106
111
|
_this.handleFocus = function (e) {
|
|
@@ -119,6 +124,22 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
119
124
|
return _this.props.onPaste == null ? void 0 : _this.props.onPaste(e, e.currentTarget.value);
|
|
120
125
|
};
|
|
121
126
|
|
|
127
|
+
_this.updateState = function (inputValue) {
|
|
128
|
+
var hasValue = inputValue !== "";
|
|
129
|
+
var previousHasValue = _this.state.hasValue; // Only update state if the value of `hasValue` has changed to avoid unnecessary renders.
|
|
130
|
+
|
|
131
|
+
if (hasValue !== previousHasValue) {
|
|
132
|
+
_this.setState({
|
|
133
|
+
hasValue: hasValue
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
_this.state = {
|
|
139
|
+
// Tracking hasValue in state allows us to hide ClearButton when there is no value to clear
|
|
140
|
+
// for both controlled and uncontrolled inputs.
|
|
141
|
+
hasValue: !!props.value
|
|
142
|
+
};
|
|
122
143
|
return _this;
|
|
123
144
|
}
|
|
124
145
|
|
|
@@ -172,9 +193,9 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
172
193
|
name: "search",
|
|
173
194
|
ariaHidden: true,
|
|
174
195
|
color: "icon.base"
|
|
175
|
-
}) : elemBefore; // Do not add a ClearButton if
|
|
196
|
+
}) : elemBefore; // Do not add a ClearButton if an elemAfter prop was passed.
|
|
176
197
|
|
|
177
|
-
var elementAfter = type === "search" &&
|
|
198
|
+
var elementAfter = type === "search" && !elemAfter ? /*#__PURE__*/React.createElement(ClearButton, null) : elemAfter;
|
|
178
199
|
return /*#__PURE__*/React.createElement(Container, _extends({
|
|
179
200
|
hasBeforeElement: !!elementBefore,
|
|
180
201
|
hasAfterElement: !!elementAfter,
|
|
@@ -187,9 +208,8 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
187
208
|
}, rest), /*#__PURE__*/React.createElement(InputContext.Provider, {
|
|
188
209
|
value: {
|
|
189
210
|
handleClear: this.handleClear,
|
|
190
|
-
hasValue:
|
|
211
|
+
hasValue: this.state.hasValue,
|
|
191
212
|
clearButtonLabel: clearButtonLabel,
|
|
192
|
-
onClear: onClear,
|
|
193
213
|
size: size
|
|
194
214
|
}
|
|
195
215
|
}, elementBefore && /*#__PURE__*/React.createElement(Accessory, {
|
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";
|