@sproutsocial/racine 11.3.0-beta.2 → 11.3.0-text-highlight.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 +6 -0
- package/__flow__/Input/index.js +67 -126
- 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__/themes/dark/theme.js +1 -0
- package/__flow__/themes/light/theme.js +1 -0
- package/__flow__/types/theme.colors.flow.js +1 -0
- package/commonjs/Avatar/index.js +4 -7
- package/commonjs/Badge/index.js +1 -3
- package/commonjs/Badge/styles.js +1 -1
- package/commonjs/Banner/index.js +1 -3
- package/commonjs/Banner/styles.js +1 -1
- package/commonjs/Box/styles.js +1 -1
- package/commonjs/Breadcrumb/index.js +2 -5
- package/commonjs/Button/index.js +1 -3
- package/commonjs/Card/index.js +1 -3
- package/commonjs/Card/styles.js +3 -3
- package/commonjs/CharacterCounter/index.js +1 -3
- package/commonjs/CharacterCounter/styles.js +1 -1
- package/commonjs/ChartLegend/index.js +1 -3
- package/commonjs/ChartLegend/styles.js +3 -3
- package/commonjs/Checkbox/index.js +1 -3
- package/commonjs/Checkbox/styles.js +1 -1
- package/commonjs/Collapsible/index.js +2 -5
- package/commonjs/DatePicker/DateRangePicker.js +1 -3
- package/commonjs/DatePicker/SingleDatePicker.js +1 -3
- package/commonjs/DatePicker/StatefulDateRangePicker.js +1 -3
- package/commonjs/DatePicker/StatefulSingleDatePicker.js +1 -3
- package/commonjs/DatePicker/common.js +1 -1
- package/commonjs/DatePicker/styles.js +6 -2
- package/commonjs/Drawer/SlideTransition.js +1 -3
- package/commonjs/Drawer/index.js +4 -9
- package/commonjs/Drawer/styles.js +2 -2
- package/commonjs/EmptyState/index.js +1 -3
- package/commonjs/Fieldset/index.js +3 -7
- package/commonjs/FormField/index.js +1 -3
- package/commonjs/Icon/index.js +2 -5
- package/commonjs/Icon/styles.js +1 -1
- package/commonjs/Image/index.js +1 -3
- package/commonjs/Image/styles.js +1 -1
- package/commonjs/Indicator/index.js +1 -3
- package/commonjs/Input/index.js +29 -80
- package/commonjs/Input/styles.js +3 -3
- package/commonjs/KeyboardKey/index.js +1 -3
- package/commonjs/Label/index.js +2 -4
- package/commonjs/Link/index.js +1 -3
- package/commonjs/Link/styles.js +1 -1
- package/commonjs/Listbox/index.js +4 -7
- package/commonjs/Loader/index.js +1 -3
- package/commonjs/Loader/styles.js +2 -2
- package/commonjs/LoaderButton/index.js +1 -3
- package/commonjs/Menu/constants.js +1 -1
- package/commonjs/Menu/descendants.js +7 -10
- package/commonjs/Menu/hooks.js +1 -1
- package/commonjs/Menu/index.js +16 -22
- package/commonjs/Menu/styles.js +2 -2
- package/commonjs/Message/index.js +1 -3
- package/commonjs/Message/styles.js +1 -1
- package/commonjs/Modal/index.js +3 -7
- package/commonjs/Modal/styles.js +6 -4
- package/commonjs/Numeral/constants.js +1 -1
- package/commonjs/Numeral/index.js +1 -3
- package/commonjs/Numeral/styles.js +3 -3
- package/commonjs/OverflowList/styles.js +1 -1
- package/commonjs/Popout/index.js +3 -7
- package/commonjs/Popout/styles.js +1 -1
- package/commonjs/Radio/index.js +1 -3
- package/commonjs/Radio/styles.js +4 -4
- package/commonjs/SegmentedControl/index.js +2 -5
- package/commonjs/Select/index.js +1 -3
- package/commonjs/Stack/index.js +1 -3
- package/commonjs/Switch/index.js +1 -3
- package/commonjs/Switch/styles.js +1 -1
- package/commonjs/Table/index.js +5 -10
- package/commonjs/TableCell/index.js +1 -3
- package/commonjs/TableHeaderCell/index.js +1 -3
- package/commonjs/TableRowAccordion/index.js +1 -3
- package/commonjs/Tabs/index.js +2 -5
- package/commonjs/Tabs/styles.js +4 -4
- package/commonjs/Text/index.js +1 -3
- package/commonjs/Text/styles.js +1 -1
- package/commonjs/Textarea/index.js +1 -3
- package/commonjs/Toast/index.js +15 -15
- package/commonjs/Toast/styles.js +7 -4
- package/commonjs/ToggleHint/index.js +1 -3
- package/commonjs/Token/index.js +1 -3
- package/commonjs/Token/styles.js +1 -1
- package/commonjs/TokenInput/index.js +1 -3
- package/commonjs/Tooltip/index.js +2 -5
- package/commonjs/Tooltip/styles.js +1 -1
- package/commonjs/VisuallyHidden/index.js +1 -1
- package/commonjs/index.js +1 -1
- package/commonjs/themes/dark/decorative-palettes.js +1 -1
- package/commonjs/themes/dark/theme.js +3 -2
- package/commonjs/themes/light/decorative-palettes.js +1 -1
- package/commonjs/themes/light/theme.js +3 -2
- package/commonjs/utils/hooks.js +2 -3
- package/commonjs/utils/mixins.js +1 -1
- package/commonjs/utils/system-props.js +1 -1
- package/dist/themes/dark/dark.scss +7 -6
- package/dist/themes/light/light.scss +97 -96
- package/lib/Avatar/index.js +4 -7
- package/lib/Badge/index.js +1 -3
- package/lib/Badge/styles.js +1 -1
- package/lib/Banner/index.js +1 -3
- package/lib/Banner/styles.js +1 -1
- package/lib/Box/styles.js +1 -1
- package/lib/Breadcrumb/index.js +2 -5
- package/lib/Button/index.js +1 -3
- package/lib/Card/index.js +1 -3
- package/lib/Card/styles.js +2 -2
- package/lib/CharacterCounter/index.js +1 -3
- package/lib/CharacterCounter/styles.js +1 -1
- package/lib/ChartLegend/index.js +1 -3
- package/lib/ChartLegend/styles.js +3 -3
- package/lib/Checkbox/index.js +1 -3
- package/lib/Collapsible/index.js +2 -5
- package/lib/DatePicker/DateRangePicker.js +1 -3
- package/lib/DatePicker/SingleDatePicker.js +1 -3
- package/lib/DatePicker/StatefulDateRangePicker.js +1 -3
- package/lib/DatePicker/StatefulSingleDatePicker.js +1 -3
- package/lib/DatePicker/styles.js +6 -2
- package/lib/Drawer/SlideTransition.js +1 -3
- package/lib/Drawer/index.js +4 -9
- package/lib/Drawer/styles.js +2 -2
- package/lib/EmptyState/index.js +1 -3
- package/lib/Fieldset/index.js +3 -7
- package/lib/FormField/index.js +1 -3
- package/lib/Icon/index.js +2 -5
- package/lib/Icon/styles.js +1 -1
- package/lib/Image/index.js +1 -3
- package/lib/Image/styles.js +1 -1
- package/lib/Indicator/index.js +1 -3
- package/lib/Input/index.js +28 -73
- package/lib/Input/styles.js +3 -3
- package/lib/KeyboardKey/index.js +1 -3
- package/lib/Label/index.js +2 -4
- package/lib/Link/index.js +1 -3
- package/lib/Link/styles.js +1 -1
- package/lib/Listbox/index.js +3 -6
- package/lib/Loader/index.js +1 -3
- package/lib/Loader/styles.js +2 -2
- package/lib/LoaderButton/index.js +1 -3
- package/lib/Menu/descendants.js +2 -5
- package/lib/Menu/index.js +16 -20
- package/lib/Menu/styles.js +2 -2
- package/lib/Message/index.js +1 -3
- package/lib/Modal/index.js +3 -7
- package/lib/Modal/styles.js +5 -3
- package/lib/Numeral/index.js +1 -3
- package/lib/Numeral/styles.js +2 -2
- package/lib/OverflowList/styles.js +1 -1
- package/lib/Popout/index.js +3 -7
- package/lib/Popout/styles.js +1 -1
- package/lib/Radio/index.js +1 -3
- package/lib/Radio/styles.js +4 -4
- package/lib/SegmentedControl/index.js +2 -5
- package/lib/Select/index.js +1 -3
- package/lib/Stack/index.js +1 -3
- package/lib/Switch/index.js +1 -3
- package/lib/Switch/styles.js +1 -1
- package/lib/Table/index.js +4 -9
- package/lib/TableCell/index.js +1 -3
- package/lib/TableHeaderCell/index.js +1 -3
- package/lib/TableRowAccordion/index.js +1 -3
- package/lib/Tabs/index.js +2 -5
- package/lib/Tabs/styles.js +3 -3
- package/lib/Text/index.js +1 -3
- package/lib/Text/styles.js +1 -1
- package/lib/Textarea/index.js +1 -3
- package/lib/Toast/index.js +14 -14
- package/lib/Toast/styles.js +7 -3
- package/lib/ToggleHint/index.js +1 -3
- package/lib/Token/index.js +1 -3
- package/lib/Token/styles.js +1 -1
- package/lib/TokenInput/index.js +1 -3
- package/lib/Tooltip/index.js +2 -5
- package/lib/Tooltip/styles.js +1 -1
- package/lib/VisuallyHidden/index.js +1 -1
- package/lib/themes/dark/theme.js +2 -1
- package/lib/themes/light/theme.js +2 -1
- package/package.json +1 -1
- package/bin/buildNpm.js +0 -58
package/CHANGELOG.md
CHANGED
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,50 +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
|
-
hasValue: boolean,
|
|
76
|
-
}>;
|
|
77
|
-
|
|
78
|
-
const InputContext = React.createContext<TypeInputContext>({});
|
|
79
|
-
|
|
80
|
-
const ClearButton = () => {
|
|
81
|
-
const { handleClear, clearButtonLabel, hasValue } =
|
|
82
|
-
React.useContext(InputContext);
|
|
83
|
-
|
|
84
|
-
// Hide the button when there is no text to clear.
|
|
85
|
-
if (!hasValue) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
return (
|
|
89
|
-
<Button onClick={handleClear}>
|
|
90
|
-
{/*Unlocalized fallback should not be used. Always include a localized
|
|
91
|
-
clearButtonLabel when using <Input.ClearButton/> or <Input type="search"/>.*/}
|
|
92
|
-
<Icon name="circlex" title={clearButtonLabel || "Clear"} />
|
|
93
|
-
</Button>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// Used for positioning elementAfter. This logic will detect if the element is a ClearButton,
|
|
98
|
-
// regardless of whether it was manually passed as elemAfter or automatically added to a search Input.
|
|
99
|
-
const isClearButton = (elem: any) => {
|
|
100
|
-
if (elem?.type) {
|
|
101
|
-
return elem.type.displayName === "Input.ClearButton";
|
|
102
|
-
}
|
|
103
|
-
return false;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
class Input extends React.Component<TypeProps> {
|
|
64
|
+
export default class Input extends React.Component<TypeProps> {
|
|
107
65
|
static defaultProps = {
|
|
108
66
|
autoFocus: false,
|
|
109
67
|
disabled: false,
|
|
@@ -112,28 +70,41 @@ class Input extends React.Component<TypeProps> {
|
|
|
112
70
|
appearance: "primary",
|
|
113
71
|
};
|
|
114
72
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
handleClear = (e: SyntheticEvent<HTMLButtonElement>) =>
|
|
121
|
-
this.props.onClear?.(e);
|
|
73
|
+
handleBlur = (e: SyntheticFocusEvent<HTMLInputElement>) => {
|
|
74
|
+
if (this.props.onBlur) {
|
|
75
|
+
this.props.onBlur(e);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
122
78
|
|
|
123
|
-
handleChange = (e: SyntheticInputEvent<HTMLInputElement>) =>
|
|
124
|
-
this.props.onChange
|
|
79
|
+
handleChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
|
|
80
|
+
if (this.props.onChange) {
|
|
81
|
+
this.props.onChange(e, e.currentTarget.value);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
125
84
|
|
|
126
|
-
handleFocus = (e: SyntheticFocusEvent<HTMLInputElement>) =>
|
|
127
|
-
this.props.onFocus
|
|
85
|
+
handleFocus = (e: SyntheticFocusEvent<HTMLInputElement>) => {
|
|
86
|
+
if (this.props.onFocus) {
|
|
87
|
+
this.props.onFocus(e);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
128
90
|
|
|
129
|
-
handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) =>
|
|
130
|
-
this.props.onKeyDown
|
|
91
|
+
handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
|
92
|
+
if (this.props.onKeyDown) {
|
|
93
|
+
this.props.onKeyDown(e, e.currentTarget.value);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
131
96
|
|
|
132
|
-
handleKeyUp = (e: SyntheticKeyboardEvent<HTMLInputElement>) =>
|
|
133
|
-
this.props.onKeyUp
|
|
97
|
+
handleKeyUp = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
|
|
98
|
+
if (this.props.onKeyUp) {
|
|
99
|
+
this.props.onKeyUp(e, e.currentTarget.value);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
134
102
|
|
|
135
|
-
handlePaste = (e: SyntheticInputEvent<HTMLInputElement>) =>
|
|
136
|
-
this.props.onPaste
|
|
103
|
+
handlePaste = (e: SyntheticInputEvent<HTMLInputElement>) => {
|
|
104
|
+
if (this.props.onPaste) {
|
|
105
|
+
this.props.onPaste(e, e.currentTarget.value);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
137
108
|
|
|
138
109
|
render() {
|
|
139
110
|
const {
|
|
@@ -154,11 +125,9 @@ class Input extends React.Component<TypeProps> {
|
|
|
154
125
|
maxLength,
|
|
155
126
|
ariaLabel,
|
|
156
127
|
ariaDescribedby,
|
|
157
|
-
clearButtonLabel,
|
|
158
128
|
innerRef,
|
|
159
129
|
onBlur,
|
|
160
130
|
onChange,
|
|
161
|
-
onClear,
|
|
162
131
|
onFocus,
|
|
163
132
|
onKeyDown,
|
|
164
133
|
onKeyUp,
|
|
@@ -169,27 +138,15 @@ class Input extends React.Component<TypeProps> {
|
|
|
169
138
|
...rest
|
|
170
139
|
} = this.props;
|
|
171
140
|
|
|
172
|
-
// Convert autoComplete from a boolean prop to a string value.
|
|
173
141
|
let autoCompleteValue = undefined;
|
|
174
142
|
if (autoComplete !== undefined) {
|
|
175
143
|
autoCompleteValue = autoComplete ? "on" : "off";
|
|
176
144
|
}
|
|
177
145
|
|
|
178
|
-
// Add default elemBefore and elemAfter elements if type is search.
|
|
179
|
-
const elementBefore =
|
|
180
|
-
type === "search" && !elemBefore ? (
|
|
181
|
-
<Icon name="search" ariaHidden />
|
|
182
|
-
) : (
|
|
183
|
-
elemBefore
|
|
184
|
-
);
|
|
185
|
-
// Do not add a ClearButton if no onClear callback is provided or if an elemAfter prop was passed.
|
|
186
|
-
const elementAfter =
|
|
187
|
-
type === "search" && onClear && !elemAfter ? <ClearButton /> : elemAfter;
|
|
188
|
-
|
|
189
146
|
return (
|
|
190
147
|
<Container
|
|
191
|
-
hasBeforeElement={!!
|
|
192
|
-
hasAfterElement={!!
|
|
148
|
+
hasBeforeElement={!!elemBefore}
|
|
149
|
+
hasAfterElement={!!elemAfter}
|
|
193
150
|
disabled={disabled}
|
|
194
151
|
invalid={!!isInvalid}
|
|
195
152
|
warning={hasWarning}
|
|
@@ -197,55 +154,39 @@ class Input extends React.Component<TypeProps> {
|
|
|
197
154
|
// $FlowIssue - upgrade v0.112.0
|
|
198
155
|
{...rest}
|
|
199
156
|
>
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
data-qa-input-isdisabled={disabled === true}
|
|
233
|
-
data-qa-input-isrequired={required === true}
|
|
234
|
-
{...qa}
|
|
235
|
-
{...inputProps}
|
|
236
|
-
/>
|
|
237
|
-
|
|
238
|
-
{elementAfter && (
|
|
239
|
-
<Accessory after isClearButton={isClearButton(elementAfter)}>
|
|
240
|
-
{elementAfter}
|
|
241
|
-
</Accessory>
|
|
242
|
-
)}
|
|
243
|
-
</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>}
|
|
244
189
|
</Container>
|
|
245
190
|
);
|
|
246
191
|
}
|
|
247
192
|
}
|
|
248
|
-
|
|
249
|
-
Input.ClearButton.displayName = "Input.ClearButton";
|
|
250
|
-
|
|
251
|
-
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
package/commonjs/Avatar/index.js
CHANGED
|
@@ -15,9 +15,6 @@ var _Image = _interopRequireDefault(require("../Image"));
|
|
|
15
15
|
|
|
16
16
|
var _Text = _interopRequireDefault(require("../Text"));
|
|
17
17
|
|
|
18
|
-
var _excluded = ["fontSize"],
|
|
19
|
-
_excluded2 = ["appearance", "name", "src", "variant", "type", "size", "bg", "color"];
|
|
20
|
-
|
|
21
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
19
|
|
|
23
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -30,12 +27,12 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
30
27
|
|
|
31
28
|
var AvatarText = (0, _styledComponents.default)(function (_ref) {
|
|
32
29
|
var fontSize = _ref.fontSize,
|
|
33
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
30
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["fontSize"]);
|
|
34
31
|
|
|
35
32
|
return /*#__PURE__*/React.createElement(_Text.default, rest);
|
|
36
33
|
}).withConfig({
|
|
37
34
|
displayName: "Avatar__AvatarText",
|
|
38
|
-
componentId: "
|
|
35
|
+
componentId: "yx873f-0"
|
|
39
36
|
})(["font-size:", "px;color:", "px;"], function (props) {
|
|
40
37
|
return props.fontSize;
|
|
41
38
|
}, function (props) {
|
|
@@ -43,7 +40,7 @@ var AvatarText = (0, _styledComponents.default)(function (_ref) {
|
|
|
43
40
|
});
|
|
44
41
|
var Container = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
45
42
|
displayName: "Avatar__Container",
|
|
46
|
-
componentId: "
|
|
43
|
+
componentId: "yx873f-1"
|
|
47
44
|
})(["", ""], function (_ref2) {
|
|
48
45
|
var theme = _ref2.theme,
|
|
49
46
|
type = _ref2.type,
|
|
@@ -78,7 +75,7 @@ var Avatar = function Avatar(_ref3) {
|
|
|
78
75
|
size = _ref3$size === void 0 ? "40px" : _ref3$size,
|
|
79
76
|
bg = _ref3.bg,
|
|
80
77
|
color = _ref3.color,
|
|
81
|
-
rest = _objectWithoutPropertiesLoose(_ref3,
|
|
78
|
+
rest = _objectWithoutPropertiesLoose(_ref3, ["appearance", "name", "src", "variant", "type", "size", "bg", "color"]);
|
|
82
79
|
|
|
83
80
|
var _useState = (0, React.useState)(false),
|
|
84
81
|
imageFailedLoading = _useState[0],
|
package/commonjs/Badge/index.js
CHANGED
|
@@ -11,8 +11,6 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
11
11
|
|
|
12
12
|
var _Box = _interopRequireDefault(require("../Box"));
|
|
13
13
|
|
|
14
|
-
var _excluded = ["children", "text", "iconName", "type", "tip", "size", "badgeColor"];
|
|
15
|
-
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
18
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -33,7 +31,7 @@ var Badge = function Badge(_ref) {
|
|
|
33
31
|
size = _ref$size === void 0 ? "small" : _ref$size,
|
|
34
32
|
_ref$badgeColor = _ref.badgeColor,
|
|
35
33
|
badgeColor = _ref$badgeColor === void 0 ? "blue" : _ref$badgeColor,
|
|
36
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
34
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["children", "text", "iconName", "type", "tip", "size", "badgeColor"]);
|
|
37
35
|
|
|
38
36
|
if (children && text) {
|
|
39
37
|
throw new Error("can't use both `children` and `text` props. Text is deprecated, consider using children.");
|
package/commonjs/Badge/styles.js
CHANGED
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
// eslint-disable-next-line prettier/prettier
|
|
17
17
|
var Container = _styledComponents.default.span.withConfig({
|
|
18
18
|
displayName: "styles__Container",
|
|
19
|
-
componentId: "
|
|
19
|
+
componentId: "g1g76b-0"
|
|
20
20
|
})(["font-family:", ";", ";border-radius:9999px;line-height:16px;display:inline-block;color:", ";background:", ";padding:", ";", ";"], function (p) {
|
|
21
21
|
return p.theme.fontFamily;
|
|
22
22
|
}, function (p) {
|
package/commonjs/Banner/index.js
CHANGED
|
@@ -11,8 +11,6 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
11
11
|
|
|
12
12
|
var _Box = _interopRequireDefault(require("../Box"));
|
|
13
13
|
|
|
14
|
-
var _excluded = ["type", "text"];
|
|
15
|
-
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
18
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -83,7 +81,7 @@ var Banner = /*#__PURE__*/function (_React$Component) {
|
|
|
83
81
|
var _this$props = this.props,
|
|
84
82
|
type = _this$props.type,
|
|
85
83
|
text = _this$props.text,
|
|
86
|
-
rest = _objectWithoutPropertiesLoose(_this$props,
|
|
84
|
+
rest = _objectWithoutPropertiesLoose(_this$props, ["type", "text"]);
|
|
87
85
|
|
|
88
86
|
return /*#__PURE__*/React.createElement(_styles.default // danger needs to be properly deprecated and removed DS-1094
|
|
89
87
|
, _extends({
|
|
@@ -13,7 +13,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
13
13
|
|
|
14
14
|
var Container = _styledComponents.default.div.withConfig({
|
|
15
15
|
displayName: "styles__Container",
|
|
16
|
-
componentId: "
|
|
16
|
+
componentId: "q43dr4-0"
|
|
17
17
|
})(function (props) {
|
|
18
18
|
return (0, _styledComponents.css)(["display:flex;overflow:hidden;align-items:center;justify-content:space-between;color:", ";border-radius:", ";font-family:", ";", " padding:", ";border:1px solid ", ";background-color:", ";.Icon{align-self:flex-start;margin-top:3px;margin-right:", ";min-width:16px;color:", ";}a,button{font-weight:", ";color:", ";font-size:inherit;&:hover{color:", ";text-decoration:underline;}}> span:not(.Icon){display:block;}", " ", ""], props.theme.colors.text.body, props.theme.radii.outer, props.theme.fontFamily, props.theme.typography[200], props.theme.space[300], props.theme.colors.container.border[props.type], props.theme.colors.container.background[props.type], props.theme.space[400], props.theme.colors.icon[props.type], props.theme.fontWeights.semibold, props.theme.colors.text.body, props.theme.colors.text.body, _systemProps.COMMON, _systemProps.LAYOUT);
|
|
19
19
|
});
|