@sproutsocial/racine 11.3.0-beta.1 → 11.3.1-beta-deps.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 +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 +67 -116
- package/__flow__/Input/index.stories.js +0 -33
- package/__flow__/Input/index.test.js +1 -199
- 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 +30 -66
- 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 +29 -59
- 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 */
|
|
@@ -46,8 +42,6 @@ type TypeProps = {
|
|
|
46
42
|
innerRef?: React.Ref<"input">,
|
|
47
43
|
onBlur?: (e: SyntheticFocusEvent<HTMLInputElement>) => void,
|
|
48
44
|
onChange?: (e: SyntheticInputEvent<HTMLInputElement>, value: string) => void,
|
|
49
|
-
/** Called on Input.ClearButton trigger. */
|
|
50
|
-
onClear?: (e: SyntheticEvent<HTMLButtonElement>) => void,
|
|
51
45
|
onFocus?: (e: SyntheticFocusEvent<HTMLInputElement>) => void,
|
|
52
46
|
onKeyDown?: (
|
|
53
47
|
e: SyntheticKeyboardEvent<HTMLInputElement>,
|
|
@@ -60,34 +54,14 @@ type TypeProps = {
|
|
|
60
54
|
onPaste?: (e: SyntheticInputEvent<HTMLInputElement>, value: string) => void,
|
|
61
55
|
size?: "large" | "small" | "default",
|
|
62
56
|
qa?: Object,
|
|
63
|
-
/**
|
|
64
|
-
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.
|
|
65
59
|
Note that this prop should only be used to alter styles and not functionality.
|
|
66
60
|
*/
|
|
67
61
|
appearance?: "primary" | "secondary",
|
|
68
62
|
};
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
// regardless of whether it is manually included as elemAfter or automatically included for type="search" Inputs.
|
|
72
|
-
type TypeInputContext = $Shape<{
|
|
73
|
-
handleClear: (e: SyntheticEvent<HTMLButtonElement>) => void,
|
|
74
|
-
clearButtonLabel: string,
|
|
75
|
-
}>;
|
|
76
|
-
|
|
77
|
-
const InputContext = React.createContext<TypeInputContext>({});
|
|
78
|
-
|
|
79
|
-
const ClearButton = () => {
|
|
80
|
-
const { handleClear, clearButtonLabel } = React.useContext(InputContext);
|
|
81
|
-
return (
|
|
82
|
-
<Button onClick={handleClear}>
|
|
83
|
-
{/*Unlocalized fallback should not be used. Always include a localized
|
|
84
|
-
clearButtonLabel when using <Input.ClearButton/> or <Input type="search"/>.*/}
|
|
85
|
-
<Icon name="circlex" title={clearButtonLabel || "Clear"} />
|
|
86
|
-
</Button>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
class Input extends React.Component<TypeProps> {
|
|
64
|
+
export default class Input extends React.Component<TypeProps> {
|
|
91
65
|
static defaultProps = {
|
|
92
66
|
autoFocus: false,
|
|
93
67
|
disabled: false,
|
|
@@ -96,28 +70,41 @@ class Input extends React.Component<TypeProps> {
|
|
|
96
70
|
appearance: "primary",
|
|
97
71
|
};
|
|
98
72
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
handleClear = (e: SyntheticEvent<HTMLButtonElement>) =>
|
|
105
|
-
this.props.onClear?.(e);
|
|
73
|
+
handleBlur = (e: SyntheticFocusEvent<HTMLInputElement>) => {
|
|
74
|
+
if (this.props.onBlur) {
|
|
75
|
+
this.props.onBlur(e);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
106
78
|
|
|
107
|
-
handleChange = (e: SyntheticInputEvent<HTMLInputElement>) =>
|
|
108
|
-
this.props.onChange
|
|
79
|
+
handleChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
|
|
80
|
+
if (this.props.onChange) {
|
|
81
|
+
this.props.onChange(e, e.currentTarget.value);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
109
84
|
|
|
110
|
-
handleFocus = (e: SyntheticFocusEvent<HTMLInputElement>) =>
|
|
111
|
-
this.props.onFocus
|
|
85
|
+
handleFocus = (e: SyntheticFocusEvent<HTMLInputElement>) => {
|
|
86
|
+
if (this.props.onFocus) {
|
|
87
|
+
this.props.onFocus(e);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
112
90
|
|
|
113
|
-
handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) =>
|
|
114
|
-
this.props.onKeyDown
|
|
91
|
+
handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
|
92
|
+
if (this.props.onKeyDown) {
|
|
93
|
+
this.props.onKeyDown(e, e.currentTarget.value);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
115
96
|
|
|
116
|
-
handleKeyUp = (e: SyntheticKeyboardEvent<HTMLInputElement>) =>
|
|
117
|
-
this.props.onKeyUp
|
|
97
|
+
handleKeyUp = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
|
98
|
+
if (this.props.onKeyUp) {
|
|
99
|
+
this.props.onKeyUp(e, e.currentTarget.value);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
118
102
|
|
|
119
|
-
handlePaste = (e: SyntheticInputEvent<HTMLInputElement>) =>
|
|
120
|
-
this.props.onPaste
|
|
103
|
+
handlePaste = (e: SyntheticInputEvent<HTMLInputElement>) => {
|
|
104
|
+
if (this.props.onPaste) {
|
|
105
|
+
this.props.onPaste(e, e.currentTarget.value);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
121
108
|
|
|
122
109
|
render() {
|
|
123
110
|
const {
|
|
@@ -138,11 +125,9 @@ class Input extends React.Component<TypeProps> {
|
|
|
138
125
|
maxLength,
|
|
139
126
|
ariaLabel,
|
|
140
127
|
ariaDescribedby,
|
|
141
|
-
clearButtonLabel,
|
|
142
128
|
innerRef,
|
|
143
129
|
onBlur,
|
|
144
130
|
onChange,
|
|
145
|
-
onClear,
|
|
146
131
|
onFocus,
|
|
147
132
|
onKeyDown,
|
|
148
133
|
onKeyUp,
|
|
@@ -153,27 +138,15 @@ class Input extends React.Component<TypeProps> {
|
|
|
153
138
|
...rest
|
|
154
139
|
} = this.props;
|
|
155
140
|
|
|
156
|
-
// Convert autoComplete from a boolean prop to a string value.
|
|
157
141
|
let autoCompleteValue = undefined;
|
|
158
142
|
if (autoComplete !== undefined) {
|
|
159
143
|
autoCompleteValue = autoComplete ? "on" : "off";
|
|
160
144
|
}
|
|
161
145
|
|
|
162
|
-
// Add default elemBefore and elemAfter elements if type is search.
|
|
163
|
-
const elementBefore =
|
|
164
|
-
type === "search" && !elemBefore ? (
|
|
165
|
-
<Icon name="search" ariaHidden />
|
|
166
|
-
) : (
|
|
167
|
-
elemBefore
|
|
168
|
-
);
|
|
169
|
-
// Do not add a ClearButton if no onClear callback is provided or if an elemAfter prop was passed.
|
|
170
|
-
const elementAfter =
|
|
171
|
-
type === "search" && onClear && !elemAfter ? <ClearButton /> : elemAfter;
|
|
172
|
-
|
|
173
146
|
return (
|
|
174
147
|
<Container
|
|
175
|
-
hasBeforeElement={!!
|
|
176
|
-
hasAfterElement={!!
|
|
148
|
+
hasBeforeElement={!!elemBefore}
|
|
149
|
+
hasAfterElement={!!elemAfter}
|
|
177
150
|
disabled={disabled}
|
|
178
151
|
invalid={!!isInvalid}
|
|
179
152
|
warning={hasWarning}
|
|
@@ -181,61 +154,39 @@ class Input extends React.Component<TypeProps> {
|
|
|
181
154
|
// $FlowIssue - upgrade v0.112.0
|
|
182
155
|
{...rest}
|
|
183
156
|
>
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
data-qa-input-isrequired={required === true}
|
|
217
|
-
{...qa}
|
|
218
|
-
{...inputProps}
|
|
219
|
-
/>
|
|
220
|
-
|
|
221
|
-
{elementAfter && (
|
|
222
|
-
<Accessory
|
|
223
|
-
after
|
|
224
|
-
// Used for positioning. This logic will detect if the element is a ClearButton,
|
|
225
|
-
// regardless of whether it was manually passed as elemAfter or automatically added to a search Input.
|
|
226
|
-
isClearButton={
|
|
227
|
-
elementAfter?.type?.prototype === Input.ClearButton.prototype
|
|
228
|
-
}
|
|
229
|
-
>
|
|
230
|
-
{elementAfter}
|
|
231
|
-
</Accessory>
|
|
232
|
-
)}
|
|
233
|
-
</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>}
|
|
234
189
|
</Container>
|
|
235
190
|
);
|
|
236
191
|
}
|
|
237
192
|
}
|
|
238
|
-
|
|
239
|
-
Input.ClearButton.displayName = "Input.ClearButton";
|
|
240
|
-
|
|
241
|
-
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,204 +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 { getByRole } = render(
|
|
76
|
-
<Input
|
|
77
|
-
id="name"
|
|
78
|
-
name="name"
|
|
79
|
-
value="mic"
|
|
80
|
-
type="search"
|
|
81
|
-
onClear={jest.fn()}
|
|
82
|
-
clearButtonLabel="Clear search"
|
|
83
|
-
/>
|
|
84
|
-
);
|
|
85
|
-
expect(getByRole("button")).toBeTruthy();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("should not override an elemAfter prop if passed", () => {
|
|
89
|
-
const { getByText, queryByTitle } = render(
|
|
90
|
-
<Input
|
|
91
|
-
id="name"
|
|
92
|
-
name="name"
|
|
93
|
-
value="mic"
|
|
94
|
-
type="search"
|
|
95
|
-
onClear={jest.fn()}
|
|
96
|
-
elemAfter={<Text>After</Text>}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
expect(getByText("After")).toBeTruthy();
|
|
100
|
-
expect(queryByTitle("Clear")).not.toBeInTheDocument();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("should use the fallback title if clearButtonLabel is not provided", () => {
|
|
104
|
-
const { getByTitle } = render(
|
|
105
|
-
<Input
|
|
106
|
-
id="name"
|
|
107
|
-
name="name"
|
|
108
|
-
value="mic"
|
|
109
|
-
type="search"
|
|
110
|
-
onClear={jest.fn()}
|
|
111
|
-
/>
|
|
112
|
-
);
|
|
113
|
-
expect(getByTitle("Clear")).toBeTruthy();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("should call onClear when clicked", () => {
|
|
117
|
-
const mockOnClear = jest.fn();
|
|
118
|
-
const { getByRole } = render(
|
|
119
|
-
<Input
|
|
120
|
-
id="name"
|
|
121
|
-
name="name"
|
|
122
|
-
value="mic"
|
|
123
|
-
type="search"
|
|
124
|
-
onClear={mockOnClear}
|
|
125
|
-
clearButtonLabel="Clear search"
|
|
126
|
-
/>
|
|
127
|
-
);
|
|
128
|
-
fireEvent.click(getByRole("button"));
|
|
129
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("should allow keyboard access to and Space key triggering of the clear button", () => {
|
|
133
|
-
const mockOnClear = jest.fn();
|
|
134
|
-
const { getByRole } = render(
|
|
135
|
-
<Input
|
|
136
|
-
id="name"
|
|
137
|
-
name="name"
|
|
138
|
-
value="mic"
|
|
139
|
-
type="search"
|
|
140
|
-
onClear={mockOnClear}
|
|
141
|
-
clearButtonLabel="Clear search"
|
|
142
|
-
/>
|
|
143
|
-
);
|
|
144
|
-
const input = getByRole("searchbox");
|
|
145
|
-
const button = getByRole("button");
|
|
146
|
-
userEvent.tab();
|
|
147
|
-
expect(input).toHaveFocus();
|
|
148
|
-
userEvent.tab();
|
|
149
|
-
expect(button).toHaveFocus();
|
|
150
|
-
userEvent.keyboard("{space}");
|
|
151
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("should allow keyboard access to and Enter key triggering of the clear button", () => {
|
|
155
|
-
const mockOnClear = jest.fn();
|
|
156
|
-
const { getByRole } = render(
|
|
157
|
-
<Input
|
|
158
|
-
id="name"
|
|
159
|
-
name="name"
|
|
160
|
-
value="mic"
|
|
161
|
-
type="search"
|
|
162
|
-
onClear={mockOnClear}
|
|
163
|
-
clearButtonLabel="Clear search"
|
|
164
|
-
/>
|
|
165
|
-
);
|
|
166
|
-
const input = getByRole("searchbox");
|
|
167
|
-
const button = getByRole("button");
|
|
168
|
-
userEvent.tab();
|
|
169
|
-
expect(input).toHaveFocus();
|
|
170
|
-
userEvent.tab();
|
|
171
|
-
expect(button).toHaveFocus();
|
|
172
|
-
userEvent.keyboard("{enter}");
|
|
173
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
describe("Manual Input.ClearButton usage", () => {
|
|
178
|
-
it("should render a clear button when passed with elemAfter", () => {
|
|
179
|
-
const { getByRole } = render(
|
|
180
|
-
<Input
|
|
181
|
-
id="name"
|
|
182
|
-
name="name"
|
|
183
|
-
value="mic"
|
|
184
|
-
type="text"
|
|
185
|
-
elemAfter={<Input.ClearButton />}
|
|
186
|
-
clearButtonLabel="Clear search"
|
|
187
|
-
/>
|
|
188
|
-
);
|
|
189
|
-
expect(getByRole("button")).toBeTruthy();
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("should use the fallback title if clearButtonLabel is not provided", () => {
|
|
193
|
-
const { getByTitle } = render(
|
|
194
|
-
<Input
|
|
195
|
-
id="name"
|
|
196
|
-
name="name"
|
|
197
|
-
value="mic"
|
|
198
|
-
type="text"
|
|
199
|
-
elemAfter={<Input.ClearButton />}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
expect(getByTitle("Clear")).toBeTruthy();
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it("should call onClear when Input.ClearButton is clicked", () => {
|
|
206
|
-
const mockOnClear = jest.fn();
|
|
207
|
-
const { getByRole } = render(
|
|
208
|
-
<Input
|
|
209
|
-
id="name"
|
|
210
|
-
name="name"
|
|
211
|
-
value="mic"
|
|
212
|
-
type="text"
|
|
213
|
-
elemAfter={<Input.ClearButton />}
|
|
214
|
-
onClear={mockOnClear}
|
|
215
|
-
clearButtonLabel="Clear search"
|
|
216
|
-
/>
|
|
217
|
-
);
|
|
218
|
-
fireEvent.click(getByRole("button"));
|
|
219
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("should allow keyboard access to and Space key triggering of the clear button", () => {
|
|
223
|
-
const mockOnClear = jest.fn();
|
|
224
|
-
const { getByRole } = render(
|
|
225
|
-
<Input
|
|
226
|
-
id="name"
|
|
227
|
-
name="name"
|
|
228
|
-
value="mic"
|
|
229
|
-
type="text"
|
|
230
|
-
elemAfter={<Input.ClearButton />}
|
|
231
|
-
onClear={mockOnClear}
|
|
232
|
-
clearButtonLabel="Clear search"
|
|
233
|
-
/>
|
|
234
|
-
);
|
|
235
|
-
const input = getByRole("textbox");
|
|
236
|
-
const button = getByRole("button");
|
|
237
|
-
userEvent.tab();
|
|
238
|
-
expect(input).toHaveFocus();
|
|
239
|
-
userEvent.tab();
|
|
240
|
-
expect(button).toHaveFocus();
|
|
241
|
-
userEvent.keyboard("{space}");
|
|
242
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("should allow keyboard access to and Enter key triggering of the clear button", () => {
|
|
246
|
-
const mockOnClear = jest.fn();
|
|
247
|
-
const { getByRole } = render(
|
|
248
|
-
<Input
|
|
249
|
-
id="name"
|
|
250
|
-
name="name"
|
|
251
|
-
value="mic"
|
|
252
|
-
type="text"
|
|
253
|
-
elemAfter={<Input.ClearButton />}
|
|
254
|
-
onClear={mockOnClear}
|
|
255
|
-
clearButtonLabel="Clear search"
|
|
256
|
-
/>
|
|
257
|
-
);
|
|
258
|
-
const input = getByRole("textbox");
|
|
259
|
-
const button = getByRole("button");
|
|
260
|
-
userEvent.tab();
|
|
261
|
-
expect(input).toHaveFocus();
|
|
262
|
-
userEvent.tab();
|
|
263
|
-
expect(button).toHaveFocus();
|
|
264
|
-
userEvent.keyboard("{enter}");
|
|
265
|
-
expect(mockOnClear).toHaveBeenCalled();
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
|
|
270
72
|
describe("autoComplete prop", () => {
|
|
271
73
|
it("should not have autoComplete attribute when passed prop is not passed", () => {
|
|
272
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;
|