@sproutsocial/racine 11.3.0-beta.3 → 11.3.0-text-highlight.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.
Files changed (184) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/__flow__/Input/index.js +66 -141
  3. package/__flow__/Input/index.stories.js +0 -65
  4. package/__flow__/Input/index.test.js +1 -227
  5. package/__flow__/Input/styles.js +1 -1
  6. package/__flow__/themes/dark/theme.js +3 -0
  7. package/__flow__/themes/light/theme.js +3 -0
  8. package/__flow__/types/theme.colors.flow.js +3 -0
  9. package/commonjs/Avatar/index.js +4 -7
  10. package/commonjs/Badge/index.js +1 -3
  11. package/commonjs/Badge/styles.js +1 -1
  12. package/commonjs/Banner/index.js +1 -3
  13. package/commonjs/Banner/styles.js +1 -1
  14. package/commonjs/Box/styles.js +1 -1
  15. package/commonjs/Breadcrumb/index.js +2 -5
  16. package/commonjs/Button/index.js +1 -3
  17. package/commonjs/Card/index.js +1 -3
  18. package/commonjs/Card/styles.js +3 -3
  19. package/commonjs/CharacterCounter/index.js +1 -3
  20. package/commonjs/CharacterCounter/styles.js +1 -1
  21. package/commonjs/ChartLegend/index.js +1 -3
  22. package/commonjs/ChartLegend/styles.js +3 -3
  23. package/commonjs/Checkbox/index.js +1 -3
  24. package/commonjs/Checkbox/styles.js +1 -1
  25. package/commonjs/Collapsible/index.js +2 -5
  26. package/commonjs/DatePicker/DateRangePicker.js +1 -3
  27. package/commonjs/DatePicker/SingleDatePicker.js +1 -3
  28. package/commonjs/DatePicker/StatefulDateRangePicker.js +1 -3
  29. package/commonjs/DatePicker/StatefulSingleDatePicker.js +1 -3
  30. package/commonjs/DatePicker/common.js +1 -1
  31. package/commonjs/DatePicker/styles.js +6 -2
  32. package/commonjs/Drawer/SlideTransition.js +1 -3
  33. package/commonjs/Drawer/index.js +4 -9
  34. package/commonjs/Drawer/styles.js +2 -2
  35. package/commonjs/EmptyState/index.js +1 -3
  36. package/commonjs/Fieldset/index.js +3 -7
  37. package/commonjs/FormField/index.js +1 -3
  38. package/commonjs/Icon/index.js +2 -5
  39. package/commonjs/Icon/styles.js +1 -1
  40. package/commonjs/Image/index.js +1 -3
  41. package/commonjs/Image/styles.js +1 -1
  42. package/commonjs/Indicator/index.js +1 -3
  43. package/commonjs/Input/index.js +31 -103
  44. package/commonjs/Input/styles.js +3 -3
  45. package/commonjs/KeyboardKey/index.js +1 -3
  46. package/commonjs/Label/index.js +2 -4
  47. package/commonjs/Link/index.js +1 -3
  48. package/commonjs/Link/styles.js +1 -1
  49. package/commonjs/Listbox/index.js +4 -7
  50. package/commonjs/Loader/index.js +1 -3
  51. package/commonjs/Loader/styles.js +2 -2
  52. package/commonjs/LoaderButton/index.js +1 -3
  53. package/commonjs/Menu/constants.js +1 -1
  54. package/commonjs/Menu/descendants.js +7 -10
  55. package/commonjs/Menu/hooks.js +1 -1
  56. package/commonjs/Menu/index.js +16 -22
  57. package/commonjs/Menu/styles.js +2 -2
  58. package/commonjs/Message/index.js +1 -3
  59. package/commonjs/Message/styles.js +1 -1
  60. package/commonjs/Modal/index.js +3 -7
  61. package/commonjs/Modal/styles.js +6 -4
  62. package/commonjs/Numeral/constants.js +1 -1
  63. package/commonjs/Numeral/index.js +1 -3
  64. package/commonjs/Numeral/styles.js +3 -3
  65. package/commonjs/OverflowList/styles.js +1 -1
  66. package/commonjs/Popout/index.js +3 -7
  67. package/commonjs/Popout/styles.js +1 -1
  68. package/commonjs/Radio/index.js +1 -3
  69. package/commonjs/Radio/styles.js +4 -4
  70. package/commonjs/SegmentedControl/index.js +2 -5
  71. package/commonjs/Select/index.js +1 -3
  72. package/commonjs/Stack/index.js +1 -3
  73. package/commonjs/Switch/index.js +1 -3
  74. package/commonjs/Switch/styles.js +1 -1
  75. package/commonjs/Table/index.js +5 -10
  76. package/commonjs/TableCell/index.js +1 -3
  77. package/commonjs/TableHeaderCell/index.js +1 -3
  78. package/commonjs/TableRowAccordion/index.js +1 -3
  79. package/commonjs/Tabs/index.js +2 -5
  80. package/commonjs/Tabs/styles.js +4 -4
  81. package/commonjs/Text/index.js +1 -3
  82. package/commonjs/Text/styles.js +1 -1
  83. package/commonjs/Textarea/index.js +1 -3
  84. package/commonjs/Toast/index.js +15 -15
  85. package/commonjs/Toast/styles.js +7 -4
  86. package/commonjs/ToggleHint/index.js +1 -3
  87. package/commonjs/Token/index.js +1 -3
  88. package/commonjs/Token/styles.js +1 -1
  89. package/commonjs/TokenInput/index.js +1 -3
  90. package/commonjs/Tooltip/index.js +2 -5
  91. package/commonjs/Tooltip/styles.js +1 -1
  92. package/commonjs/VisuallyHidden/index.js +1 -1
  93. package/commonjs/index.js +1 -1
  94. package/commonjs/themes/dark/decorative-palettes.js +1 -1
  95. package/commonjs/themes/dark/theme.js +5 -2
  96. package/commonjs/themes/light/decorative-palettes.js +1 -1
  97. package/commonjs/themes/light/theme.js +5 -2
  98. package/commonjs/utils/hooks.js +2 -3
  99. package/commonjs/utils/mixins.js +1 -1
  100. package/commonjs/utils/system-props.js +1 -1
  101. package/dist/themes/dark/dark.scss +9 -6
  102. package/dist/themes/light/light.scss +99 -96
  103. package/lib/Avatar/index.js +4 -7
  104. package/lib/Badge/index.js +1 -3
  105. package/lib/Badge/styles.js +1 -1
  106. package/lib/Banner/index.js +1 -3
  107. package/lib/Banner/styles.js +1 -1
  108. package/lib/Box/styles.js +1 -1
  109. package/lib/Breadcrumb/index.js +2 -5
  110. package/lib/Button/index.js +1 -3
  111. package/lib/Card/index.js +1 -3
  112. package/lib/Card/styles.js +2 -2
  113. package/lib/CharacterCounter/index.js +1 -3
  114. package/lib/CharacterCounter/styles.js +1 -1
  115. package/lib/ChartLegend/index.js +1 -3
  116. package/lib/ChartLegend/styles.js +3 -3
  117. package/lib/Checkbox/index.js +1 -3
  118. package/lib/Collapsible/index.js +2 -5
  119. package/lib/DatePicker/DateRangePicker.js +1 -3
  120. package/lib/DatePicker/SingleDatePicker.js +1 -3
  121. package/lib/DatePicker/StatefulDateRangePicker.js +1 -3
  122. package/lib/DatePicker/StatefulSingleDatePicker.js +1 -3
  123. package/lib/DatePicker/styles.js +6 -2
  124. package/lib/Drawer/SlideTransition.js +1 -3
  125. package/lib/Drawer/index.js +4 -9
  126. package/lib/Drawer/styles.js +2 -2
  127. package/lib/EmptyState/index.js +1 -3
  128. package/lib/Fieldset/index.js +3 -7
  129. package/lib/FormField/index.js +1 -3
  130. package/lib/Icon/index.js +2 -5
  131. package/lib/Icon/styles.js +1 -1
  132. package/lib/Image/index.js +1 -3
  133. package/lib/Image/styles.js +1 -1
  134. package/lib/Indicator/index.js +1 -3
  135. package/lib/Input/index.js +30 -96
  136. package/lib/Input/styles.js +3 -3
  137. package/lib/KeyboardKey/index.js +1 -3
  138. package/lib/Label/index.js +2 -4
  139. package/lib/Link/index.js +1 -3
  140. package/lib/Link/styles.js +1 -1
  141. package/lib/Listbox/index.js +3 -6
  142. package/lib/Loader/index.js +1 -3
  143. package/lib/Loader/styles.js +2 -2
  144. package/lib/LoaderButton/index.js +1 -3
  145. package/lib/Menu/descendants.js +2 -5
  146. package/lib/Menu/index.js +16 -20
  147. package/lib/Menu/styles.js +2 -2
  148. package/lib/Message/index.js +1 -3
  149. package/lib/Modal/index.js +3 -7
  150. package/lib/Modal/styles.js +5 -3
  151. package/lib/Numeral/index.js +1 -3
  152. package/lib/Numeral/styles.js +2 -2
  153. package/lib/OverflowList/styles.js +1 -1
  154. package/lib/Popout/index.js +3 -7
  155. package/lib/Popout/styles.js +1 -1
  156. package/lib/Radio/index.js +1 -3
  157. package/lib/Radio/styles.js +4 -4
  158. package/lib/SegmentedControl/index.js +2 -5
  159. package/lib/Select/index.js +1 -3
  160. package/lib/Stack/index.js +1 -3
  161. package/lib/Switch/index.js +1 -3
  162. package/lib/Switch/styles.js +1 -1
  163. package/lib/Table/index.js +4 -9
  164. package/lib/TableCell/index.js +1 -3
  165. package/lib/TableHeaderCell/index.js +1 -3
  166. package/lib/TableRowAccordion/index.js +1 -3
  167. package/lib/Tabs/index.js +2 -5
  168. package/lib/Tabs/styles.js +3 -3
  169. package/lib/Text/index.js +1 -3
  170. package/lib/Text/styles.js +1 -1
  171. package/lib/Textarea/index.js +1 -3
  172. package/lib/Toast/index.js +14 -14
  173. package/lib/Toast/styles.js +7 -3
  174. package/lib/ToggleHint/index.js +1 -3
  175. package/lib/Token/index.js +1 -3
  176. package/lib/Token/styles.js +1 -1
  177. package/lib/TokenInput/index.js +1 -3
  178. package/lib/Tooltip/index.js +2 -5
  179. package/lib/Tooltip/styles.js +1 -1
  180. package/lib/VisuallyHidden/index.js +1 -1
  181. package/lib/themes/dark/theme.js +4 -1
  182. package/lib/themes/light/theme.js +4 -1
  183. package/package.json +1 -1
  184. package/bin/buildNpm.js +0 -58
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 11.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - a73cdfb: remove weird characters from props descriptions
8
+
3
9
  ## 11.2.4
4
10
 
5
11
  ### Patch Changes
@@ -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,61 +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
- // Using Context so that Input's Input.ClearButton-specific props can be passed to Input.ClearButton,
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, size } =
82
- React.useContext(InputContext);
83
-
84
- // Hide the button when there is no text to clear.
85
- if (!hasValue) {
86
- return null;
87
- }
88
-
89
- // Cut down the padding for size small Inputs so that the focus ring won't go outside the bounds of the Input.
90
- // This adjustment is handled automatically for default and large Inputs via Button's size. There is no "small" Button.
91
- const py = size === "small" ? 100 : undefined;
92
- const px = size === "small" ? 200 : undefined;
93
- const buttonSize = size === "small" ? "default" : size;
94
-
95
- // Warn if clearButtonLabel is not included, so that the unlocalized fallback will not be mistaken for a proper label.
96
- if (!clearButtonLabel) {
97
- console.warn(
98
- "Warning: clearButtonLabel prop is required when using Input.ClearButton. Please pass a localized label to Input."
99
- );
100
- }
101
- return (
102
- <Button onClick={handleClear} size={buttonSize} py={py} px={px}>
103
- <Icon name="circlex" title={clearButtonLabel || "Clear"} />
104
- </Button>
105
- );
106
- };
107
-
108
- // Used for positioning elementAfter. This logic will detect if the element is a ClearButton,
109
- // regardless of whether it was manually passed as elemAfter or automatically added to a search Input.
110
- const isClearButton = (elem: any) => {
111
- if (elem?.type) {
112
- return elem.type.displayName === "Input.ClearButton";
113
- }
114
- return false;
115
- };
116
-
117
- class Input extends React.Component<TypeProps> {
64
+ export default class Input extends React.Component<TypeProps> {
118
65
  static defaultProps = {
119
66
  autoFocus: false,
120
67
  disabled: false,
@@ -123,30 +70,41 @@ class Input extends React.Component<TypeProps> {
123
70
  appearance: "primary",
124
71
  };
125
72
 
126
- static ClearButton = ClearButton;
127
-
128
- handleBlur = (e: SyntheticFocusEvent<HTMLInputElement>) =>
129
- this.props.onBlur?.(e);
130
-
131
- handleClear = (e: SyntheticEvent<HTMLButtonElement>) => {
132
- this.props.onClear?.(e);
133
- this.props.innerRef?.current?.focus();
73
+ handleBlur = (e: SyntheticFocusEvent<HTMLInputElement>) => {
74
+ if (this.props.onBlur) {
75
+ this.props.onBlur(e);
76
+ }
134
77
  };
135
78
 
136
- handleChange = (e: SyntheticInputEvent<HTMLInputElement>) =>
137
- this.props.onChange?.(e, e.currentTarget.value);
79
+ handleChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
80
+ if (this.props.onChange) {
81
+ this.props.onChange(e, e.currentTarget.value);
82
+ }
83
+ };
138
84
 
139
- handleFocus = (e: SyntheticFocusEvent<HTMLInputElement>) =>
140
- this.props.onFocus?.(e);
85
+ handleFocus = (e: SyntheticFocusEvent<HTMLInputElement>) => {
86
+ if (this.props.onFocus) {
87
+ this.props.onFocus(e);
88
+ }
89
+ };
141
90
 
142
- handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) =>
143
- this.props.onKeyDown?.(e, e.currentTarget.value);
91
+ handleKeyDown = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
92
+ if (this.props.onKeyDown) {
93
+ this.props.onKeyDown(e, e.currentTarget.value);
94
+ }
95
+ };
144
96
 
145
- handleKeyUp = (e: SyntheticKeyboardEvent<HTMLInputElement>) =>
146
- this.props.onKeyUp?.(e, e.currentTarget.value);
97
+ handleKeyUp = (e: SyntheticKeyboardEvent<HTMLInputElement>) => {
98
+ if (this.props.onKeyUp) {
99
+ this.props.onKeyUp(e, e.currentTarget.value);
100
+ }
101
+ };
147
102
 
148
- handlePaste = (e: SyntheticInputEvent<HTMLInputElement>) =>
149
- this.props.onPaste?.(e, e.currentTarget.value);
103
+ handlePaste = (e: SyntheticInputEvent<HTMLInputElement>) => {
104
+ if (this.props.onPaste) {
105
+ this.props.onPaste(e, e.currentTarget.value);
106
+ }
107
+ };
150
108
 
151
109
  render() {
152
110
  const {
@@ -167,11 +125,9 @@ class Input extends React.Component<TypeProps> {
167
125
  maxLength,
168
126
  ariaLabel,
169
127
  ariaDescribedby,
170
- clearButtonLabel,
171
128
  innerRef,
172
129
  onBlur,
173
130
  onChange,
174
- onClear,
175
131
  onFocus,
176
132
  onKeyDown,
177
133
  onKeyUp,
@@ -179,89 +135,58 @@ class Input extends React.Component<TypeProps> {
179
135
  inputProps = {},
180
136
  qa = {},
181
137
  appearance,
182
- size,
183
138
  ...rest
184
139
  } = this.props;
185
140
 
186
- // Convert autoComplete from a boolean prop to a string value.
187
141
  let autoCompleteValue = undefined;
188
142
  if (autoComplete !== undefined) {
189
143
  autoCompleteValue = autoComplete ? "on" : "off";
190
144
  }
191
145
 
192
- // Add default elemBefore and elemAfter elements if type is search.
193
- const elementBefore =
194
- type === "search" && !elemBefore ? (
195
- <Icon name="search" ariaHidden color="icon.base" />
196
- ) : (
197
- elemBefore
198
- );
199
- // Do not add a ClearButton if no onClear callback is provided or if an elemAfter prop was passed.
200
- const elementAfter =
201
- type === "search" && onClear && !elemAfter ? <ClearButton /> : elemAfter;
202
-
203
146
  return (
204
147
  <Container
205
- hasBeforeElement={!!elementBefore}
206
- hasAfterElement={!!elementAfter}
148
+ hasBeforeElement={!!elemBefore}
149
+ hasAfterElement={!!elemAfter}
207
150
  disabled={disabled}
208
151
  invalid={!!isInvalid}
209
152
  warning={hasWarning}
210
153
  appearance={appearance}
211
- size={size}
212
154
  // $FlowIssue - upgrade v0.112.0
213
155
  {...rest}
214
156
  >
215
- <InputContext.Provider
216
- value={{
217
- handleClear: this.handleClear,
218
- hasValue: !!value,
219
- clearButtonLabel,
220
- size,
221
- }}
222
- >
223
- {elementBefore && <Accessory before>{elementBefore}</Accessory>}
224
-
225
- <input
226
- aria-invalid={!!isInvalid}
227
- aria-label={ariaLabel}
228
- aria-describedby={ariaDescribedby}
229
- autoComplete={autoCompleteValue}
230
- autoFocus={autoFocus}
231
- disabled={disabled}
232
- readOnly={readOnly}
233
- id={id}
234
- name={name}
235
- placeholder={placeholder}
236
- type={type}
237
- required={required}
238
- value={value}
239
- maxLength={maxLength}
240
- onBlur={this.handleBlur}
241
- onChange={this.handleChange}
242
- onFocus={this.handleFocus}
243
- onKeyDown={this.handleKeyDown}
244
- onKeyUp={this.handleKeyUp}
245
- onPaste={this.handlePaste}
246
- ref={innerRef}
247
- data-qa-input={name || ""}
248
- data-qa-input-isdisabled={disabled === true}
249
- data-qa-input-isrequired={required === true}
250
- {...qa}
251
- {...inputProps}
252
- />
253
-
254
- {elementAfter && (
255
- <Accessory after isClearButton={isClearButton(elementAfter)}>
256
- {elementAfter}
257
- </Accessory>
258
- )}
259
- </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>}
260
189
  </Container>
261
190
  );
262
191
  }
263
192
  }
264
-
265
- Input.ClearButton.displayName = "Input.ClearButton";
266
-
267
- export default Input;
@@ -141,71 +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 smallSearchInput = () => (
160
- <Input
161
- type="search"
162
- size="small"
163
- placeholder={text("placeholder", "Please enter a value...")}
164
- value={text("value", "val")}
165
- onClear={() => window.alert("Cleared!")}
166
- clearButtonLabel={text("clearButtonLabel", "Clear search")}
167
- ariaLabel={text("ariaLabel", "Descriptive label goes here")}
168
- />
169
- );
170
-
171
- smallSearchInput.story = {
172
- name: "Small Search Input",
173
- };
174
-
175
- export const largeSearchInput = () => (
176
- <Input
177
- type="search"
178
- size="large"
179
- placeholder={text("placeholder", "Please enter a value...")}
180
- value={text("value", "val")}
181
- onClear={() => window.alert("Cleared!")}
182
- clearButtonLabel={text("clearButtonLabel", "Clear search")}
183
- ariaLabel={text("ariaLabel", "Descriptive label goes here")}
184
- />
185
- );
186
-
187
- largeSearchInput.story = {
188
- name: "Large Search Input",
189
- };
190
-
191
- export const nonSearchClearButtonInput = () => {
192
- return (
193
- <Input
194
- type="text"
195
- placeholder={text("placeholder", "Please enter a value...")}
196
- value={text("value", "val")}
197
- onClear={() => window.alert("Cleared!")}
198
- ariaLabel={text("ariaLabel", "Descriptive label goes here")}
199
- clearButtonLabel={text("clearButtonLabel", "Clear text")}
200
- elemAfter={<Input.ClearButton />}
201
- />
202
- );
203
- };
204
-
205
- nonSearchClearButtonInput.story = {
206
- name: "Manual Input.ClearButton usage",
207
- };
208
-
209
144
  export const autofocus = () => (
210
145
  <Input
211
146
  autoFocus
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import "jest-styled-components";
3
- import { render, fireEvent, userEvent } from "../utils/react-testing-library";
3
+ import { render, fireEvent } from "../utils/react-testing-library";
4
4
  import Input from "./";
5
5
  import Text from "../Text";
6
6
 
@@ -69,232 +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 render a clear button for search Inputs if there is no text", () => {
89
- const { queryByRole } = render(
90
- <Input
91
- id="name"
92
- name="name"
93
- value=""
94
- type="search"
95
- onClear={jest.fn()}
96
- clearButtonLabel="Clear search"
97
- />
98
- );
99
- expect(queryByRole("button")).toBeFalsy();
100
- });
101
-
102
- it("should not override an elemAfter prop if passed", () => {
103
- const { getByText, queryByTitle } = render(
104
- <Input
105
- id="name"
106
- name="name"
107
- value="mic"
108
- type="search"
109
- onClear={jest.fn()}
110
- elemAfter={<Text>After</Text>}
111
- />
112
- );
113
- expect(getByText("After")).toBeTruthy();
114
- expect(queryByTitle("Clear")).not.toBeInTheDocument();
115
- });
116
-
117
- it("should use the fallback title if clearButtonLabel is not provided", () => {
118
- const { getByTitle } = render(
119
- <Input
120
- id="name"
121
- name="name"
122
- value="mic"
123
- type="search"
124
- onClear={jest.fn()}
125
- />
126
- );
127
- expect(getByTitle("Clear")).toBeTruthy();
128
- });
129
-
130
- it("should call onClear when clicked", () => {
131
- const mockOnClear = jest.fn();
132
- const { getByRole } = render(
133
- <Input
134
- id="name"
135
- name="name"
136
- value="mic"
137
- type="search"
138
- onClear={mockOnClear}
139
- clearButtonLabel="Clear search"
140
- />
141
- );
142
- fireEvent.click(getByRole("button"));
143
- expect(mockOnClear).toHaveBeenCalled();
144
- });
145
-
146
- it("should allow keyboard access to and Space key triggering of the clear button", () => {
147
- const mockOnClear = jest.fn();
148
- const { getByRole } = render(
149
- <Input
150
- id="name"
151
- name="name"
152
- value="mic"
153
- type="search"
154
- onClear={mockOnClear}
155
- clearButtonLabel="Clear search"
156
- />
157
- );
158
- const input = getByRole("searchbox");
159
- const button = getByRole("button");
160
- userEvent.tab();
161
- expect(input).toHaveFocus();
162
- userEvent.tab();
163
- expect(button).toHaveFocus();
164
- userEvent.keyboard("{space}");
165
- expect(mockOnClear).toHaveBeenCalled();
166
- });
167
-
168
- it("should allow keyboard access to and Enter key triggering of the clear button", () => {
169
- const mockOnClear = jest.fn();
170
- const { getByRole } = render(
171
- <Input
172
- id="name"
173
- name="name"
174
- value="mic"
175
- type="search"
176
- onClear={mockOnClear}
177
- clearButtonLabel="Clear search"
178
- />
179
- );
180
- const input = getByRole("searchbox");
181
- const button = getByRole("button");
182
- userEvent.tab();
183
- expect(input).toHaveFocus();
184
- userEvent.tab();
185
- expect(button).toHaveFocus();
186
- userEvent.keyboard("{enter}");
187
- expect(mockOnClear).toHaveBeenCalled();
188
- });
189
- });
190
-
191
- describe("Manual Input.ClearButton usage", () => {
192
- it("should render a clear button when passed with elemAfter", () => {
193
- const { getByRole } = render(
194
- <Input
195
- id="name"
196
- name="name"
197
- value="mic"
198
- type="text"
199
- elemAfter={<Input.ClearButton />}
200
- clearButtonLabel="Clear search"
201
- />
202
- );
203
- expect(getByRole("button")).toBeTruthy();
204
- });
205
-
206
- it("should not render a clear button if there is no text", () => {
207
- const { queryByRole } = render(
208
- <Input
209
- id="name"
210
- name="name"
211
- value=""
212
- type="text"
213
- elemAfter={<Input.ClearButton />}
214
- clearButtonLabel="Clear search"
215
- />
216
- );
217
- expect(queryByRole("button")).toBeFalsy();
218
- });
219
-
220
- it("should use the fallback title if clearButtonLabel is not provided", () => {
221
- const { getByTitle } = render(
222
- <Input
223
- id="name"
224
- name="name"
225
- value="mic"
226
- type="text"
227
- elemAfter={<Input.ClearButton />}
228
- />
229
- );
230
- expect(getByTitle("Clear")).toBeTruthy();
231
- });
232
-
233
- it("should call onClear when Input.ClearButton is clicked", () => {
234
- const mockOnClear = jest.fn();
235
- const { getByRole } = render(
236
- <Input
237
- id="name"
238
- name="name"
239
- value="mic"
240
- type="text"
241
- elemAfter={<Input.ClearButton />}
242
- onClear={mockOnClear}
243
- clearButtonLabel="Clear search"
244
- />
245
- );
246
- fireEvent.click(getByRole("button"));
247
- expect(mockOnClear).toHaveBeenCalled();
248
- });
249
-
250
- it("should allow keyboard access to and Space key triggering of the clear button", () => {
251
- const mockOnClear = jest.fn();
252
- const { getByRole } = render(
253
- <Input
254
- id="name"
255
- name="name"
256
- value="mic"
257
- type="text"
258
- elemAfter={<Input.ClearButton />}
259
- onClear={mockOnClear}
260
- clearButtonLabel="Clear search"
261
- />
262
- );
263
- const input = getByRole("textbox");
264
- const button = getByRole("button");
265
- userEvent.tab();
266
- expect(input).toHaveFocus();
267
- userEvent.tab();
268
- expect(button).toHaveFocus();
269
- userEvent.keyboard("{space}");
270
- expect(mockOnClear).toHaveBeenCalled();
271
- });
272
-
273
- it("should allow keyboard access to and Enter key triggering of the clear button", () => {
274
- const mockOnClear = jest.fn();
275
- const { getByRole } = render(
276
- <Input
277
- id="name"
278
- name="name"
279
- value="mic"
280
- type="text"
281
- elemAfter={<Input.ClearButton />}
282
- onClear={mockOnClear}
283
- clearButtonLabel="Clear search"
284
- />
285
- );
286
- const input = getByRole("textbox");
287
- const button = getByRole("button");
288
- userEvent.tab();
289
- expect(input).toHaveFocus();
290
- userEvent.tab();
291
- expect(button).toHaveFocus();
292
- userEvent.keyboard("{enter}");
293
- expect(mockOnClear).toHaveBeenCalled();
294
- });
295
- });
296
- });
297
-
298
72
  describe("autoComplete prop", () => {
299
73
  it("should not have autoComplete attribute when passed prop is not passed", () => {
300
74
  const { getByDataQaLabel } = render(<Input id="name" name="name" />);
@@ -140,7 +140,7 @@ export const Accessory: StyledComponent<any, TypeTheme, *> = styled.div`
140
140
  ${(props) =>
141
141
  props.after &&
142
142
  css`
143
- right: ${props.isClearButton ? 0 : props.theme.space[350]};
143
+ right: ${props.theme.space[350]};
144
144
  `};
145
145
  `;
146
146
 
@@ -174,6 +174,9 @@ const colors = {
174
174
  body: COLORS.COLOR_NEUTRAL_100,
175
175
  inverse: COLORS.COLOR_NEUTRAL_900,
176
176
  error: COLORS.COLOR_RED_400,
177
+ background: {
178
+ highlight: COLORS.COLOR_YELLOW_900,
179
+ },
177
180
  },
178
181
  icon: {
179
182
  base: COLORS.COLOR_NEUTRAL_100,
@@ -171,6 +171,9 @@ const colors = {
171
171
  body: COLORS.COLOR_NEUTRAL_800,
172
172
  inverse: COLORS.COLOR_NEUTRAL_0,
173
173
  error: COLORS.COLOR_RED_800,
174
+ background: {
175
+ highlight: COLORS.COLOR_YELLOW_200,
176
+ },
174
177
  },
175
178
  icon: {
176
179
  base: COLORS.COLOR_NEUTRAL_800,
@@ -158,6 +158,9 @@ type TypeTextColors = {|
158
158
  body: string,
159
159
  inverse: string,
160
160
  error: string,
161
+ background: {
162
+ highlight: string,
163
+ },
161
164
  },
162
165
  |};
163
166