@sproutsocial/racine 11.3.0-beta.0 → 11.3.1-beta-deps.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 +24 -0
- package/__flow__/Badge/constants.js +48 -0
- package/__flow__/Badge/index.js +60 -33
- package/__flow__/Badge/index.stories.js +35 -42
- package/__flow__/Badge/index.test.js +34 -32
- package/__flow__/Badge/styles.js +22 -42
- package/__flow__/Button/index.js +1 -0
- package/__flow__/Button/index.stories.js +51 -67
- package/__flow__/EmptyState/index.test.js +1 -1
- package/__flow__/Input/index.js +66 -124
- package/__flow__/Input/index.stories.js +0 -33
- package/__flow__/Input/index.test.js +1 -224
- package/__flow__/Input/styles.js +1 -1
- package/__flow__/Menu/__snapshots__/index.test.js.snap +3 -3
- package/__flow__/setupTests.js +1 -1
- package/__flow__/systemProps/tests/__snapshots__/layout.test.js.snap +0 -14
- package/__flow__/systemProps/tests/layout.test.js +0 -9
- package/__flow__/themes/extendedThemes/README.md +6 -0
- package/commonjs/Badge/constants.js +43 -0
- package/commonjs/Badge/index.js +41 -39
- package/commonjs/Badge/styles.js +15 -31
- package/commonjs/Button/index.js +1 -0
- package/commonjs/DatePicker/styles.js +5 -1
- package/commonjs/Input/index.js +29 -68
- package/commonjs/Input/styles.js +1 -1
- package/commonjs/Menu/index.js +10 -10
- package/commonjs/Modal/styles.js +5 -1
- package/commonjs/Toast/index.js +14 -14
- package/commonjs/Toast/styles.js +5 -2
- package/lib/Badge/constants.js +38 -0
- package/lib/Badge/index.js +38 -39
- package/lib/Badge/styles.js +12 -27
- package/lib/Button/index.js +1 -0
- package/lib/DatePicker/styles.js +5 -1
- package/lib/Input/index.js +28 -61
- package/lib/Input/styles.js +1 -1
- package/lib/Menu/index.js +11 -10
- package/lib/Modal/styles.js +5 -1
- package/lib/Toast/index.js +14 -14
- package/lib/Toast/styles.js +5 -1
- package/package.json +25 -21
- package/__flow__/Button/__snapshots__/index.test.js.snap +0 -511
- package/__flow__/Button/index.test.js +0 -113
package/__flow__/Input/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import Container, { Accessory } from "./styles";
|
|
4
|
-
import Button from "../Button";
|
|
5
|
-
import Icon from "../Icon";
|
|
6
4
|
|
|
7
5
|
type TypeProps = {
|
|
8
6
|
/** ID of the form element, should match the "for" value of the associated label */
|
|
@@ -12,8 +10,6 @@ type TypeProps = {
|
|
|
12
10
|
ariaLabel?: string,
|
|
13
11
|
/** Attribute used to associate other elements that describe the Input, like an error */
|
|
14
12
|
ariaDescribedby?: string,
|
|
15
|
-
/** Label for Input.ClearButton. Required when using <Input type="search"/> or <Input.ClearButton/>. */
|
|
16
|
-
clearButtonLabel?: string,
|
|
17
13
|
/** Placeholder text for when value is undefined or empty */
|
|
18
14
|
placeholder?: string,
|
|
19
15
|
/** Current value of the input */
|
|
@@ -45,14 +41,7 @@ type TypeProps = {
|
|
|
45
41
|
/** Used to get a reference to the underlying element */
|
|
46
42
|
innerRef?: React.Ref<"input">,
|
|
47
43
|
onBlur?: (e: SyntheticFocusEvent<HTMLInputElement>) => void,
|
|
48
|
-
onChange?: (
|
|
49
|
-
e:
|
|
50
|
-
| SyntheticInputEvent<HTMLInputElement>
|
|
51
|
-
| SyntheticEvent<HTMLButtonElement>,
|
|
52
|
-
value: string
|
|
53
|
-
) => void,
|
|
54
|
-
/** Called on Input.ClearButton trigger */
|
|
55
|
-
onClear?: (e: SyntheticEvent<HTMLButtonElement>) => void,
|
|
44
|
+
onChange?: (e: SyntheticInputEvent<HTMLInputElement>, value: string) => void,
|
|
56
45
|
onFocus?: (e: SyntheticFocusEvent<HTMLInputElement>) => void,
|
|
57
46
|
onKeyDown?: (
|
|
58
47
|
e: SyntheticKeyboardEvent<HTMLInputElement>,
|
|
@@ -65,34 +54,14 @@ type TypeProps = {
|
|
|
65
54
|
onPaste?: (e: SyntheticInputEvent<HTMLInputElement>, value: string) => void,
|
|
66
55
|
size?: "large" | "small" | "default",
|
|
67
56
|
qa?: Object,
|
|
68
|
-
/**
|
|
69
|
-
Controls the styles of the input. Primary is our standard input styles and secondary is a borderless input.
|
|
57
|
+
/**
|
|
58
|
+
Controls the styles of the input. Primary is our standard input styles and secondary is a borderless input.
|
|
70
59
|
Note that this prop should only be used to alter styles and not functionality.
|
|
71
60
|
*/
|
|
72
61
|
appearance?: "primary" | "secondary",
|
|
73
62
|
};
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
// regardless of whether it is manually included as elemAfter or automatically included for type="search" Inputs.
|
|
77
|
-
type TypeInputContext = $Shape<{
|
|
78
|
-
handleClear: (e: SyntheticEvent<HTMLButtonElement>) => void,
|
|
79
|
-
clearButtonLabel: string,
|
|
80
|
-
}>;
|
|
81
|
-
|
|
82
|
-
const InputContext = React.createContext<TypeInputContext>({});
|
|
83
|
-
|
|
84
|
-
const ClearButton = () => {
|
|
85
|
-
const { handleClear, clearButtonLabel } = React.useContext(InputContext);
|
|
86
|
-
return (
|
|
87
|
-
<Button onClick={handleClear}>
|
|
88
|
-
{/*Unlocalized fallback should not be used. Always include a localized
|
|
89
|
-
clearButtonLabel when using <Input.ClearButton/> or <Input type="search"/>.*/}
|
|
90
|
-
<Icon name="circlex" title={clearButtonLabel || "Clear"} />
|
|
91
|
-
</Button>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
class Input extends React.Component<TypeProps> {
|
|
64
|
+
export default class Input extends React.Component<TypeProps> {
|
|
96
65
|
static defaultProps = {
|
|
97
66
|
autoFocus: false,
|
|
98
67
|
disabled: false,
|
|
@@ -101,33 +70,41 @@ class Input extends React.Component<TypeProps> {
|
|
|
101
70
|
appearance: "primary",
|
|
102
71
|
};
|
|
103
72
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.props.onBlur?.(e);
|
|
108
|
-
|
|
109
|
-
handleClear = (e: SyntheticEvent<HTMLButtonElement>) => {
|
|
110
|
-
if (this.props.onClear) {
|
|
111
|
-
this.props.onClear(e);
|
|
112
|
-
} else if (this.props.onChange) {
|
|
113
|
-
this.props.onChange(e, "");
|
|
73
|
+
handleBlur = (e: SyntheticFocusEvent<HTMLInputElement>) => {
|
|
74
|
+
if (this.props.onBlur) {
|
|
75
|
+
this.props.onBlur(e);
|
|
114
76
|
}
|
|
115
77
|
};
|
|
116
78
|
|
|
117
|
-
handleChange = (e: SyntheticInputEvent<HTMLInputElement>) =>
|
|
118
|
-
this.props.onChange
|
|
79
|
+
handleChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
|
|
80
|
+
if (this.props.onChange) {
|
|
81
|
+
this.props.onChange(e, e.currentTarget.value);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
119
84
|
|
|
120
|
-
handleFocus = (e: SyntheticFocusEvent<HTMLInputElement>) =>
|
|
121
|
-
this.props.onFocus
|
|
85
|
+
handleFocus = (e: SyntheticFocusEvent<HTMLInputElement>) => {
|
|
86
|
+
if (this.props.onFocus) {
|
|
87
|
+
this.props.onFocus(e);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
122
90
|
|
|
123
|
-
handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) =>
|
|
124
|
-
this.props.onKeyDown
|
|
91
|
+
handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
|
92
|
+
if (this.props.onKeyDown) {
|
|
93
|
+
this.props.onKeyDown(e, e.currentTarget.value);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
125
96
|
|
|
126
|
-
handleKeyUp = (e: SyntheticKeyboardEvent<HTMLInputElement>) =>
|
|
127
|
-
this.props.onKeyUp
|
|
97
|
+
handleKeyUp = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
|
98
|
+
if (this.props.onKeyUp) {
|
|
99
|
+
this.props.onKeyUp(e, e.currentTarget.value);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
128
102
|
|
|
129
|
-
handlePaste = (e: SyntheticInputEvent<HTMLInputElement>) =>
|
|
130
|
-
this.props.onPaste
|
|
103
|
+
handlePaste = (e: SyntheticInputEvent<HTMLInputElement>) => {
|
|
104
|
+
if (this.props.onPaste) {
|
|
105
|
+
this.props.onPaste(e, e.currentTarget.value);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
131
108
|
|
|
132
109
|
render() {
|
|
133
110
|
const {
|
|
@@ -148,11 +125,9 @@ class Input extends React.Component<TypeProps> {
|
|
|
148
125
|
maxLength,
|
|
149
126
|
ariaLabel,
|
|
150
127
|
ariaDescribedby,
|
|
151
|
-
clearButtonLabel,
|
|
152
128
|
innerRef,
|
|
153
129
|
onBlur,
|
|
154
130
|
onChange,
|
|
155
|
-
onClear,
|
|
156
131
|
onFocus,
|
|
157
132
|
onKeyDown,
|
|
158
133
|
onKeyUp,
|
|
@@ -163,26 +138,15 @@ class Input extends React.Component<TypeProps> {
|
|
|
163
138
|
...rest
|
|
164
139
|
} = this.props;
|
|
165
140
|
|
|
166
|
-
// Convert autoComplete from a boolean prop to a string value.
|
|
167
141
|
let autoCompleteValue = undefined;
|
|
168
142
|
if (autoComplete !== undefined) {
|
|
169
143
|
autoCompleteValue = autoComplete ? "on" : "off";
|
|
170
144
|
}
|
|
171
145
|
|
|
172
|
-
// Add default elemBefore and elemAfter elements if type is search.
|
|
173
|
-
const elementBefore =
|
|
174
|
-
type === "search" && !elemBefore ? (
|
|
175
|
-
<Icon name="search" ariaHidden />
|
|
176
|
-
) : (
|
|
177
|
-
elemBefore
|
|
178
|
-
);
|
|
179
|
-
const elementAfter =
|
|
180
|
-
type === "search" && !elemAfter ? <ClearButton /> : elemAfter;
|
|
181
|
-
|
|
182
146
|
return (
|
|
183
147
|
<Container
|
|
184
|
-
hasBeforeElement={!!
|
|
185
|
-
hasAfterElement={!!
|
|
148
|
+
hasBeforeElement={!!elemBefore}
|
|
149
|
+
hasAfterElement={!!elemAfter}
|
|
186
150
|
disabled={disabled}
|
|
187
151
|
invalid={!!isInvalid}
|
|
188
152
|
warning={hasWarning}
|
|
@@ -190,61 +154,39 @@ class Input extends React.Component<TypeProps> {
|
|
|
190
154
|
// $FlowIssue - upgrade v0.112.0
|
|
191
155
|
{...rest}
|
|
192
156
|
>
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
data-qa-input-isrequired={required === true}
|
|
226
|
-
{...qa}
|
|
227
|
-
{...inputProps}
|
|
228
|
-
/>
|
|
229
|
-
|
|
230
|
-
{elementAfter && (
|
|
231
|
-
<Accessory
|
|
232
|
-
after
|
|
233
|
-
// Used for positioning. This logic will detect if the element is a ClearButton,
|
|
234
|
-
// regardless of whether it was manually passed as elemAfter or automatically added to a search Input.
|
|
235
|
-
isClearButton={
|
|
236
|
-
elementAfter?.type?.prototype === Input.ClearButton.prototype
|
|
237
|
-
}
|
|
238
|
-
>
|
|
239
|
-
{elementAfter}
|
|
240
|
-
</Accessory>
|
|
241
|
-
)}
|
|
242
|
-
</InputContext.Provider>
|
|
157
|
+
{elemBefore && <Accessory before>{elemBefore}</Accessory>}
|
|
158
|
+
|
|
159
|
+
<input
|
|
160
|
+
aria-invalid={!!isInvalid}
|
|
161
|
+
aria-label={ariaLabel}
|
|
162
|
+
aria-describedby={ariaDescribedby}
|
|
163
|
+
autoComplete={autoCompleteValue}
|
|
164
|
+
autoFocus={autoFocus}
|
|
165
|
+
disabled={disabled}
|
|
166
|
+
readOnly={readOnly}
|
|
167
|
+
id={id}
|
|
168
|
+
name={name}
|
|
169
|
+
placeholder={placeholder}
|
|
170
|
+
type={type}
|
|
171
|
+
required={required}
|
|
172
|
+
value={value}
|
|
173
|
+
maxLength={maxLength}
|
|
174
|
+
onBlur={this.handleBlur}
|
|
175
|
+
onChange={this.handleChange}
|
|
176
|
+
onFocus={this.handleFocus}
|
|
177
|
+
onKeyDown={this.handleKeyDown}
|
|
178
|
+
onKeyUp={this.handleKeyUp}
|
|
179
|
+
onPaste={this.handlePaste}
|
|
180
|
+
ref={innerRef}
|
|
181
|
+
data-qa-input={name || ""}
|
|
182
|
+
data-qa-input-isdisabled={disabled === true}
|
|
183
|
+
data-qa-input-isrequired={required === true}
|
|
184
|
+
{...qa}
|
|
185
|
+
{...inputProps}
|
|
186
|
+
/>
|
|
187
|
+
|
|
188
|
+
{elemAfter && <Accessory after>{elemAfter}</Accessory>}
|
|
243
189
|
</Container>
|
|
244
190
|
);
|
|
245
191
|
}
|
|
246
192
|
}
|
|
247
|
-
|
|
248
|
-
Input.ClearButton.displayName = "Input.ClearButton";
|
|
249
|
-
|
|
250
|
-
export default Input;
|
|
@@ -141,39 +141,6 @@ leftAndRightIcons.story = {
|
|
|
141
141
|
name: "Left and right icons",
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
export const searchInput = () => (
|
|
145
|
-
<Input
|
|
146
|
-
type="search"
|
|
147
|
-
placeholder={text("placeholder", "Please enter a value...")}
|
|
148
|
-
value={text("value", "val")}
|
|
149
|
-
onClear={() => window.alert("Cleared!")}
|
|
150
|
-
clearButtonLabel={text("clearButtonLabel", "Clear search")}
|
|
151
|
-
ariaLabel={text("ariaLabel", "Descriptive label goes here")}
|
|
152
|
-
/>
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
searchInput.story = {
|
|
156
|
-
name: "Search Input",
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export const nonSearchClearButtonInput = () => {
|
|
160
|
-
return (
|
|
161
|
-
<Input
|
|
162
|
-
type="text"
|
|
163
|
-
placeholder={text("placeholder", "Please enter a value...")}
|
|
164
|
-
value={text("value", "val")}
|
|
165
|
-
onClear={() => window.alert("Cleared!")}
|
|
166
|
-
ariaLabel={text("ariaLabel", "Descriptive label goes here")}
|
|
167
|
-
clearButtonLabel={text("clearButtonLabel", "Clear text")}
|
|
168
|
-
elemAfter={<Input.ClearButton />}
|
|
169
|
-
/>
|
|
170
|
-
);
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
nonSearchClearButtonInput.story = {
|
|
174
|
-
name: "Input.ClearButton usage",
|
|
175
|
-
};
|
|
176
|
-
|
|
177
144
|
export const autofocus = () => (
|
|
178
145
|
<Input
|
|
179
146
|
autoFocus
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "jest-styled-components";
|
|
3
|
-
import { render, fireEvent
|
|
3
|
+
import { render, fireEvent } from "../utils/react-testing-library";
|
|
4
4
|
import Input from "./";
|
|
5
5
|
import Text from "../Text";
|
|
6
6
|
|
|
@@ -69,229 +69,6 @@ describe("Input", () => {
|
|
|
69
69
|
expect(getByText("After")).toBeTruthy();
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
describe("Input.ClearButton", () => {
|
|
73
|
-
describe("Input type=search", () => {
|
|
74
|
-
it("should render a clear button for search Inputs", () => {
|
|
75
|
-
const { getByTitle } = render(
|
|
76
|
-
<Input
|
|
77
|
-
id="name"
|
|
78
|
-
name="name"
|
|
79
|
-
value="mic"
|
|
80
|
-
type="search"
|
|
81
|
-
clearButtonLabel="Clear search"
|
|
82
|
-
/>
|
|
83
|
-
);
|
|
84
|
-
expect(getByTitle("Clear search")).toBeTruthy();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("should not override an elemAfter prop if passed", () => {
|
|
88
|
-
const { getByText, queryByTitle } = render(
|
|
89
|
-
<Input
|
|
90
|
-
id="name"
|
|
91
|
-
name="name"
|
|
92
|
-
value="mic"
|
|
93
|
-
type="search"
|
|
94
|
-
elemAfter={<Text>After</Text>}
|
|
95
|
-
/>
|
|
96
|
-
);
|
|
97
|
-
expect(getByText("After")).toBeTruthy();
|
|
98
|
-
expect(queryByTitle("Clear")).not.toBeInTheDocument();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("should use the fallback title if clearButtonLabel is not provided", () => {
|
|
102
|
-
const { getByTitle } = render(
|
|
103
|
-
<Input id="name" name="name" value="mic" type="search" />
|
|
104
|
-
);
|
|
105
|
-
expect(getByTitle("Clear")).toBeTruthy();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("should call onClear when clicked", () => {
|
|
109
|
-
const mockOnClear = jest.fn();
|
|
110
|
-
const { getByTitle } = render(
|
|
111
|
-
<Input
|
|
112
|
-
id="name"
|
|
113
|
-
name="name"
|
|
114
|
-
value="mic"
|
|
115
|
-
type="search"
|
|
116
|
-
onClear={mockOnClear}
|
|
117
|
-
clearButtonLabel="Clear search"
|
|
118
|
-
/>
|
|
119
|
-
);
|
|
120
|
-
fireEvent.click(getByTitle("Clear search"));
|
|
121
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("should call onChange when clicked if there is no onClear prop", () => {
|
|
125
|
-
const mockOnChange = jest.fn();
|
|
126
|
-
const { getByTitle } = render(
|
|
127
|
-
<Input
|
|
128
|
-
id="name"
|
|
129
|
-
name="name"
|
|
130
|
-
value="mic"
|
|
131
|
-
type="search"
|
|
132
|
-
onChange={mockOnChange}
|
|
133
|
-
clearButtonLabel="Clear search"
|
|
134
|
-
/>
|
|
135
|
-
);
|
|
136
|
-
fireEvent.click(getByTitle("Clear search"));
|
|
137
|
-
expect(mockOnChange).toHaveBeenLastCalledWith(expect.anything(), "");
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("should allow keyboard access to and Space key triggering of the clear button", () => {
|
|
141
|
-
const mockOnClear = jest.fn();
|
|
142
|
-
const { getByRole } = render(
|
|
143
|
-
<Input
|
|
144
|
-
id="name"
|
|
145
|
-
name="name"
|
|
146
|
-
value="mic"
|
|
147
|
-
type="search"
|
|
148
|
-
onClear={mockOnClear}
|
|
149
|
-
clearButtonLabel="Clear search"
|
|
150
|
-
/>
|
|
151
|
-
);
|
|
152
|
-
const input = getByRole("searchbox");
|
|
153
|
-
const button = getByRole("button");
|
|
154
|
-
userEvent.tab();
|
|
155
|
-
expect(input).toHaveFocus();
|
|
156
|
-
userEvent.tab();
|
|
157
|
-
expect(button).toHaveFocus();
|
|
158
|
-
userEvent.keyboard("{space}");
|
|
159
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("should allow keyboard access to and Enter key triggering of the clear button", () => {
|
|
163
|
-
const mockOnClear = jest.fn();
|
|
164
|
-
const { getByRole } = render(
|
|
165
|
-
<Input
|
|
166
|
-
id="name"
|
|
167
|
-
name="name"
|
|
168
|
-
value="mic"
|
|
169
|
-
type="search"
|
|
170
|
-
onClear={mockOnClear}
|
|
171
|
-
clearButtonLabel="Clear search"
|
|
172
|
-
/>
|
|
173
|
-
);
|
|
174
|
-
const input = getByRole("searchbox");
|
|
175
|
-
const button = getByRole("button");
|
|
176
|
-
userEvent.tab();
|
|
177
|
-
expect(input).toHaveFocus();
|
|
178
|
-
userEvent.tab();
|
|
179
|
-
expect(button).toHaveFocus();
|
|
180
|
-
userEvent.keyboard("{enter}");
|
|
181
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
describe("Manual Input.ClearButton usage", () => {
|
|
186
|
-
it("should render a clear button when passed with elemAfter", () => {
|
|
187
|
-
const { getByTitle } = render(
|
|
188
|
-
<Input
|
|
189
|
-
id="name"
|
|
190
|
-
name="name"
|
|
191
|
-
value="mic"
|
|
192
|
-
type="text"
|
|
193
|
-
elemAfter={<Input.ClearButton />}
|
|
194
|
-
clearButtonLabel="Clear search"
|
|
195
|
-
/>
|
|
196
|
-
);
|
|
197
|
-
expect(getByTitle("Clear search")).toBeTruthy();
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it("should use the fallback title if clearButtonLabel is not provided", () => {
|
|
201
|
-
const { getByTitle } = render(
|
|
202
|
-
<Input
|
|
203
|
-
id="name"
|
|
204
|
-
name="name"
|
|
205
|
-
value="mic"
|
|
206
|
-
type="text"
|
|
207
|
-
elemAfter={<Input.ClearButton />}
|
|
208
|
-
/>
|
|
209
|
-
);
|
|
210
|
-
expect(getByTitle("Clear")).toBeTruthy();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it("should call onClear when Input.ClearButton is clicked", () => {
|
|
214
|
-
const mockOnClear = jest.fn();
|
|
215
|
-
const { getByTitle } = render(
|
|
216
|
-
<Input
|
|
217
|
-
id="name"
|
|
218
|
-
name="name"
|
|
219
|
-
value="mic"
|
|
220
|
-
type="text"
|
|
221
|
-
elemAfter={<Input.ClearButton />}
|
|
222
|
-
onClear={mockOnClear}
|
|
223
|
-
clearButtonLabel="Clear search"
|
|
224
|
-
/>
|
|
225
|
-
);
|
|
226
|
-
fireEvent.click(getByTitle("Clear search"));
|
|
227
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("should call onChange when clicked if there is no onClear prop", () => {
|
|
231
|
-
const mockOnChange = jest.fn();
|
|
232
|
-
const { getByTitle } = render(
|
|
233
|
-
<Input
|
|
234
|
-
id="name"
|
|
235
|
-
name="name"
|
|
236
|
-
value="mic"
|
|
237
|
-
type="text"
|
|
238
|
-
elemAfter={<Input.ClearButton />}
|
|
239
|
-
onChange={mockOnChange}
|
|
240
|
-
clearButtonLabel="Clear search"
|
|
241
|
-
/>
|
|
242
|
-
);
|
|
243
|
-
fireEvent.click(getByTitle("Clear search"));
|
|
244
|
-
expect(mockOnChange).toHaveBeenLastCalledWith(expect.anything(), "");
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it("should allow keyboard access to and Space key triggering of the clear button", () => {
|
|
248
|
-
const mockOnClear = jest.fn();
|
|
249
|
-
const { getByRole } = render(
|
|
250
|
-
<Input
|
|
251
|
-
id="name"
|
|
252
|
-
name="name"
|
|
253
|
-
value="mic"
|
|
254
|
-
type="text"
|
|
255
|
-
elemAfter={<Input.ClearButton />}
|
|
256
|
-
onClear={mockOnClear}
|
|
257
|
-
clearButtonLabel="Clear search"
|
|
258
|
-
/>
|
|
259
|
-
);
|
|
260
|
-
const input = getByRole("textbox");
|
|
261
|
-
const button = getByRole("button");
|
|
262
|
-
userEvent.tab();
|
|
263
|
-
expect(input).toHaveFocus();
|
|
264
|
-
userEvent.tab();
|
|
265
|
-
expect(button).toHaveFocus();
|
|
266
|
-
userEvent.keyboard("{space}");
|
|
267
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it("should allow keyboard access to and Enter key triggering of the clear button", () => {
|
|
271
|
-
const mockOnClear = jest.fn();
|
|
272
|
-
const { getByRole } = render(
|
|
273
|
-
<Input
|
|
274
|
-
id="name"
|
|
275
|
-
name="name"
|
|
276
|
-
value="mic"
|
|
277
|
-
type="text"
|
|
278
|
-
elemAfter={<Input.ClearButton />}
|
|
279
|
-
onClear={mockOnClear}
|
|
280
|
-
clearButtonLabel="Clear search"
|
|
281
|
-
/>
|
|
282
|
-
);
|
|
283
|
-
const input = getByRole("textbox");
|
|
284
|
-
const button = getByRole("button");
|
|
285
|
-
userEvent.tab();
|
|
286
|
-
expect(input).toHaveFocus();
|
|
287
|
-
userEvent.tab();
|
|
288
|
-
expect(button).toHaveFocus();
|
|
289
|
-
userEvent.keyboard("{enter}");
|
|
290
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
|
|
295
72
|
describe("autoComplete prop", () => {
|
|
296
73
|
it("should not have autoComplete attribute when passed prop is not passed", () => {
|
|
297
74
|
const { getByDataQaLabel } = render(<Input id="name" name="name" />);
|
package/__flow__/Input/styles.js
CHANGED
|
@@ -14,12 +14,12 @@ exports[`Menu AsMenuButton should match snapshot 1`] = `
|
|
|
14
14
|
fill: currentColor;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
_:-ms-fullscreen .
|
|
17
|
+
_:-ms-fullscreen .c2,
|
|
18
18
|
html .c3 {
|
|
19
19
|
width: 16px;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
.pdf-page .
|
|
22
|
+
.pdf-page .c2 {
|
|
23
23
|
width: 16px;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -96,7 +96,7 @@ html .c3 {
|
|
|
96
96
|
aria-expanded="false"
|
|
97
97
|
aria-haspopup="true"
|
|
98
98
|
aria-label="Open Menu"
|
|
99
|
-
class="c1"
|
|
99
|
+
class="c1 container"
|
|
100
100
|
data-qa-button=""
|
|
101
101
|
data-qa-button-isdisabled="false"
|
|
102
102
|
id="MenuButton-7"
|
package/__flow__/setupTests.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`layout system props display 1`] = `
|
|
4
|
-
.c0 {
|
|
5
|
-
display: -webkit-string;
|
|
6
|
-
display: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
<div>
|
|
10
|
-
<div
|
|
11
|
-
class="c0"
|
|
12
|
-
display="string"
|
|
13
|
-
/>
|
|
14
|
-
</div>
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
3
|
exports[`layout system props height 1`] = `
|
|
18
4
|
.c0 {
|
|
19
5
|
height: string;
|
|
@@ -10,15 +10,6 @@ describe("layout system props", () => {
|
|
|
10
10
|
${layoutSystemProps}
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
|
-
test("display", () => {
|
|
14
|
-
const { container } = render(
|
|
15
|
-
<>
|
|
16
|
-
<Component display="string" />
|
|
17
|
-
</>
|
|
18
|
-
);
|
|
19
|
-
expect(container).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
13
|
test("height", () => {
|
|
23
14
|
const { container } = render(
|
|
24
15
|
<>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
## Extended Theme Directory
|
|
2
|
+
|
|
3
|
+
This directory serves as a shared environment for all extended themes. Each unique theme should have its own folder and theme.js file.
|
|
4
|
+
`src/themes/extendedThemes/customTheme/theme.js`
|
|
5
|
+
|
|
6
|
+
Check out our documentation for [How to extend the theme](https://seeds.sproutsocial.com/components/theme#extending-the-theme) on Seeds.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.legacyBadgeColors = void 0;
|
|
5
|
+
var defaultPurple = {
|
|
6
|
+
color: "colors.text.body",
|
|
7
|
+
background: "colors.container.background.decorative.purple"
|
|
8
|
+
};
|
|
9
|
+
var suggestion = {
|
|
10
|
+
color: "colors.text.body",
|
|
11
|
+
background: "colors.container.background.decorative.blue"
|
|
12
|
+
};
|
|
13
|
+
var passive = {
|
|
14
|
+
color: "colors.text.body",
|
|
15
|
+
background: "colors.container.background.decorative.neutral"
|
|
16
|
+
};
|
|
17
|
+
var primary = {
|
|
18
|
+
color: "colors.text.body",
|
|
19
|
+
background: "colors.container.background.decorative.blue"
|
|
20
|
+
};
|
|
21
|
+
var secondary = {
|
|
22
|
+
color: "colors.text.body",
|
|
23
|
+
background: "colors.container.background.decorative.yellow"
|
|
24
|
+
};
|
|
25
|
+
var common = {
|
|
26
|
+
color: "colors.text.inverse",
|
|
27
|
+
background: "colors.aqua.600"
|
|
28
|
+
};
|
|
29
|
+
var approval = {
|
|
30
|
+
color: "colors.text.body",
|
|
31
|
+
background: "colors.container.background.decorative.orange"
|
|
32
|
+
}; //Deprecated former "types"
|
|
33
|
+
|
|
34
|
+
var legacyBadgeColors = {
|
|
35
|
+
primary: primary,
|
|
36
|
+
secondary: secondary,
|
|
37
|
+
passive: passive,
|
|
38
|
+
common: common,
|
|
39
|
+
approval: approval,
|
|
40
|
+
default: defaultPurple,
|
|
41
|
+
suggestion: suggestion
|
|
42
|
+
};
|
|
43
|
+
exports.legacyBadgeColors = legacyBadgeColors;
|