@khanacademy/wonder-blocks-dropdown 2.6.10 → 2.7.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 +11 -0
- package/dist/es/index.js +26 -141
- package/dist/index.js +56 -198
- package/package.json +2 -1
- package/src/components/__tests__/search-text-input.test.js +124 -57
- package/src/components/search-text-input.js +15 -149
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-dropdown
|
|
2
2
|
|
|
3
|
+
## 2.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b3960766: Replaced core elements with Wonder Blocks SearchField (added dependency to SearchField)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [b3960766]
|
|
12
|
+
- @khanacademy/wonder-blocks-search-field@1.0.4
|
|
13
|
+
|
|
3
14
|
## 2.6.10
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/extends';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { StyleSheet
|
|
3
|
+
import { StyleSheet } from 'aphrodite';
|
|
4
4
|
import { Link } from 'react-router-dom';
|
|
5
5
|
import { __RouterContext } from 'react-router';
|
|
6
6
|
import Color, { mix, fade, SemanticColor } from '@khanacademy/wonder-blocks-color';
|
|
7
7
|
import Spacing from '@khanacademy/wonder-blocks-spacing';
|
|
8
|
-
import { LabelMedium,
|
|
8
|
+
import { LabelMedium, LabelLarge } from '@khanacademy/wonder-blocks-typography';
|
|
9
9
|
import { getClickableBehavior, isClientSideUrl, ClickableBehavior } from '@khanacademy/wonder-blocks-clickable';
|
|
10
10
|
import { addStyle, View } from '@khanacademy/wonder-blocks-core';
|
|
11
11
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
|
|
@@ -13,7 +13,7 @@ import Icon, { icons } from '@khanacademy/wonder-blocks-icon';
|
|
|
13
13
|
import ReactDOM from 'react-dom';
|
|
14
14
|
import { VariableSizeList } from 'react-window';
|
|
15
15
|
import { withActionScheduler } from '@khanacademy/wonder-blocks-timing';
|
|
16
|
-
import
|
|
16
|
+
import SearchField from '@khanacademy/wonder-blocks-search-field';
|
|
17
17
|
import { Popper } from 'react-popper';
|
|
18
18
|
import { maybeGetPortalMountedModalHostElement } from '@khanacademy/wonder-blocks-modal';
|
|
19
19
|
import { Strut } from '@khanacademy/wonder-blocks-layout';
|
|
@@ -93,7 +93,7 @@ class ActionItem extends React.Component {
|
|
|
93
93
|
hovered,
|
|
94
94
|
focused
|
|
95
95
|
} = state;
|
|
96
|
-
const defaultStyle = [styles$
|
|
96
|
+
const defaultStyle = [styles$8.shared, disabled && styles$8.disabled, !disabled && (pressed ? styles$8.active : (hovered || focused) && styles$8.focus), style];
|
|
97
97
|
|
|
98
98
|
const props = _extends({
|
|
99
99
|
"data-test-id": testId,
|
|
@@ -104,7 +104,7 @@ class ActionItem extends React.Component {
|
|
|
104
104
|
|
|
105
105
|
const children = React.createElement(React.Fragment, null, React.createElement(LabelMedium, {
|
|
106
106
|
lang: lang,
|
|
107
|
-
style: [indent && styles$
|
|
107
|
+
style: [indent && styles$8.indent, styles$8.label]
|
|
108
108
|
}, label));
|
|
109
109
|
|
|
110
110
|
if (href && !disabled) {
|
|
@@ -135,7 +135,7 @@ ActionItem.defaultProps = {
|
|
|
135
135
|
role: "menuitem"
|
|
136
136
|
};
|
|
137
137
|
ActionItem.__IS_ACTION_ITEM__ = true;
|
|
138
|
-
const styles$
|
|
138
|
+
const styles$8 = StyleSheet.create({
|
|
139
139
|
shared: {
|
|
140
140
|
background: white$4,
|
|
141
141
|
color: offBlack$3,
|
|
@@ -189,10 +189,10 @@ function Check(props) {
|
|
|
189
189
|
icon: icons.check,
|
|
190
190
|
size: "small",
|
|
191
191
|
color: disabled ? offBlack32$3 : pressed || hovered || focused ? white$3 : offBlack$2,
|
|
192
|
-
style: [styles$
|
|
192
|
+
style: [styles$7.bounds, !selected && styles$7.hide]
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
-
const styles$
|
|
195
|
+
const styles$7 = StyleSheet.create({
|
|
196
196
|
bounds: {
|
|
197
197
|
minHeight: 16,
|
|
198
198
|
minWidth: 16
|
|
@@ -226,17 +226,17 @@ function Checkbox(props) {
|
|
|
226
226
|
const bgColor = disabled ? offWhite : selected && !clickInteraction ? blue$2 : white$2;
|
|
227
227
|
const checkColor = disabled ? offBlack32$2 : clickInteraction ? pressed ? activeBlue : blue$2 : white$2;
|
|
228
228
|
return React.createElement(View, {
|
|
229
|
-
style: [styles$
|
|
229
|
+
style: [styles$6.checkbox, (clickInteraction || selected && !disabled) && styles$6.noBorder, disabled && styles$6.disabledCheckbox, {
|
|
230
230
|
backgroundColor: bgColor
|
|
231
231
|
}]
|
|
232
232
|
}, selected && React.createElement(Icon, {
|
|
233
233
|
icon: checkboxCheck,
|
|
234
234
|
size: "small",
|
|
235
235
|
color: checkColor,
|
|
236
|
-
style: [disabled && selected && styles$
|
|
236
|
+
style: [disabled && selected && styles$6.disabledCheckFormatting]
|
|
237
237
|
}));
|
|
238
238
|
}
|
|
239
|
-
const styles$
|
|
239
|
+
const styles$6 = StyleSheet.create({
|
|
240
240
|
checkbox: {
|
|
241
241
|
minHeight: 16,
|
|
242
242
|
minWidth: 16,
|
|
@@ -314,7 +314,7 @@ class OptionItem extends React.Component {
|
|
|
314
314
|
hovered,
|
|
315
315
|
focused
|
|
316
316
|
} = state;
|
|
317
|
-
const defaultStyle = [styles$
|
|
317
|
+
const defaultStyle = [styles$5.itemContainer, pressed ? styles$5.active : (hovered || focused) && styles$5.focus, disabled && styles$5.disabled, style];
|
|
318
318
|
return React.createElement(View, _extends({}, sharedProps, {
|
|
319
319
|
testId: testId,
|
|
320
320
|
style: defaultStyle,
|
|
@@ -327,7 +327,7 @@ class OptionItem extends React.Component {
|
|
|
327
327
|
hovered: hovered,
|
|
328
328
|
focused: focused
|
|
329
329
|
}), React.createElement(LabelMedium, {
|
|
330
|
-
style: styles$
|
|
330
|
+
style: styles$5.label
|
|
331
331
|
}, label));
|
|
332
332
|
});
|
|
333
333
|
}
|
|
@@ -346,7 +346,7 @@ const {
|
|
|
346
346
|
offBlack: offBlack$1,
|
|
347
347
|
offBlack32: offBlack32$1
|
|
348
348
|
} = Color;
|
|
349
|
-
const styles$
|
|
349
|
+
const styles$5 = StyleSheet.create({
|
|
350
350
|
itemContainer: {
|
|
351
351
|
flexDirection: "row",
|
|
352
352
|
background: white$1,
|
|
@@ -392,14 +392,14 @@ class SeparatorItem extends React.Component {
|
|
|
392
392
|
|
|
393
393
|
render() {
|
|
394
394
|
return React.createElement(View, {
|
|
395
|
-
style: [styles$
|
|
395
|
+
style: [styles$4.separator, this.props.style],
|
|
396
396
|
"aria-hidden": "true"
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
}
|
|
401
401
|
SeparatorItem.__IS_SEPARATOR_ITEM__ = true;
|
|
402
|
-
const styles$
|
|
402
|
+
const styles$4 = StyleSheet.create({
|
|
403
403
|
separator: {
|
|
404
404
|
boxShadow: `0 -1px ${Color.offBlack16}`,
|
|
405
405
|
height: 1,
|
|
@@ -487,110 +487,30 @@ class DropdownVirtualizedItem extends React.Component {
|
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
class SearchTextInput extends React.Component {
|
|
490
|
-
constructor(...args) {
|
|
491
|
-
super(...args);
|
|
492
|
-
this.state = {
|
|
493
|
-
focused: false,
|
|
494
|
-
labels: _extends({
|
|
495
|
-
clearSearch: defaultLabels.clearSearch,
|
|
496
|
-
filter: defaultLabels.filter
|
|
497
|
-
}, this.props.labels)
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
this.handleChange = e => {
|
|
501
|
-
e.preventDefault();
|
|
502
|
-
this.props.onChange(e.target.value);
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
this.handleDismiss = () => {
|
|
506
|
-
const {
|
|
507
|
-
onClick,
|
|
508
|
-
onChange
|
|
509
|
-
} = this.props;
|
|
510
|
-
onChange("");
|
|
511
|
-
|
|
512
|
-
if (onClick) {
|
|
513
|
-
onClick();
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
this.handleBlur = e => {
|
|
518
|
-
this.setState({
|
|
519
|
-
focused: false
|
|
520
|
-
});
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
this.handleFocus = e => {
|
|
524
|
-
this.setState({
|
|
525
|
-
focused: true
|
|
526
|
-
});
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
|
|
530
490
|
static isClassOf(instance) {
|
|
531
491
|
return instance && instance.type && instance.type.__IS_SEARCH_TEXT_INPUT__;
|
|
532
492
|
}
|
|
533
493
|
|
|
534
|
-
componentDidUpdate(prevProps) {
|
|
535
|
-
if (this.props.labels !== prevProps.labels) {
|
|
536
|
-
this.setState({
|
|
537
|
-
labels: _extends({}, this.state.labels, this.props.labels)
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
maybeRenderDismissIconButton() {
|
|
543
|
-
const {
|
|
544
|
-
searchText
|
|
545
|
-
} = this.props;
|
|
546
|
-
const {
|
|
547
|
-
clearSearch
|
|
548
|
-
} = this.state.labels;
|
|
549
|
-
|
|
550
|
-
if (searchText.length > 0) {
|
|
551
|
-
return React.createElement(IconButton, {
|
|
552
|
-
icon: icons.dismiss,
|
|
553
|
-
kind: "tertiary",
|
|
554
|
-
onClick: this.handleDismiss,
|
|
555
|
-
style: styles$4.dismissIcon,
|
|
556
|
-
"aria-label": clearSearch
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
return null;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
494
|
render() {
|
|
564
495
|
const {
|
|
496
|
+
labels,
|
|
497
|
+
onChange,
|
|
565
498
|
onClick,
|
|
566
499
|
itemRef,
|
|
567
500
|
searchText,
|
|
568
501
|
style,
|
|
569
502
|
testId
|
|
570
503
|
} = this.props;
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
return React.createElement(View, {
|
|
504
|
+
return React.createElement(SearchField, {
|
|
505
|
+
clearAriaLabel: labels.clearSearch,
|
|
506
|
+
onChange: onChange,
|
|
575
507
|
onClick: onClick,
|
|
576
|
-
|
|
577
|
-
}, React.createElement(Icon, {
|
|
578
|
-
icon: icons.search,
|
|
579
|
-
size: "medium",
|
|
580
|
-
color: Color.offBlack64,
|
|
581
|
-
style: styles$4.searchIcon,
|
|
582
|
-
"aria-hidden": "true"
|
|
583
|
-
}), React.createElement("input", {
|
|
584
|
-
type: "text",
|
|
585
|
-
onChange: this.handleChange,
|
|
586
|
-
onFocus: this.handleFocus,
|
|
587
|
-
onBlur: this.handleBlur,
|
|
508
|
+
placeholder: labels.filter,
|
|
588
509
|
ref: itemRef,
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
}), this.maybeRenderDismissIconButton());
|
|
510
|
+
style: style,
|
|
511
|
+
testId: testId,
|
|
512
|
+
value: searchText
|
|
513
|
+
});
|
|
594
514
|
}
|
|
595
515
|
|
|
596
516
|
}
|
|
@@ -601,41 +521,6 @@ SearchTextInput.defaultProps = {
|
|
|
601
521
|
}
|
|
602
522
|
};
|
|
603
523
|
SearchTextInput.__IS_SEARCH_TEXT_INPUT__ = true;
|
|
604
|
-
const styles$4 = StyleSheet.create({
|
|
605
|
-
inputContainer: {
|
|
606
|
-
flexDirection: "row",
|
|
607
|
-
border: `1px solid ${Color.offBlack16}`,
|
|
608
|
-
borderRadius: Spacing.xxxSmall_4,
|
|
609
|
-
alignItems: "center",
|
|
610
|
-
height: DROPDOWN_ITEM_HEIGHT,
|
|
611
|
-
minHeight: DROPDOWN_ITEM_HEIGHT
|
|
612
|
-
},
|
|
613
|
-
focused: {
|
|
614
|
-
border: `1px solid ${Color.blue}`
|
|
615
|
-
},
|
|
616
|
-
searchIcon: {
|
|
617
|
-
marginLeft: Spacing.xSmall_8,
|
|
618
|
-
marginRight: Spacing.xSmall_8
|
|
619
|
-
},
|
|
620
|
-
dismissIcon: {
|
|
621
|
-
margin: 0,
|
|
622
|
-
":hover": {
|
|
623
|
-
border: "none"
|
|
624
|
-
}
|
|
625
|
-
},
|
|
626
|
-
inputStyleReset: {
|
|
627
|
-
display: "flex",
|
|
628
|
-
flex: 1,
|
|
629
|
-
background: "inherit",
|
|
630
|
-
border: "none",
|
|
631
|
-
outline: "none",
|
|
632
|
-
"::placeholder": {
|
|
633
|
-
color: Color.offBlack64
|
|
634
|
-
},
|
|
635
|
-
width: "100%",
|
|
636
|
-
color: "inherit"
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
524
|
|
|
640
525
|
function getDropdownMenuHeight(items, initialHeight = 0) {
|
|
641
526
|
return items.slice(0, MAX_VISIBLE_ITEMS).reduce((sum, item) => {
|
package/dist/index.js
CHANGED
|
@@ -178,12 +178,6 @@ module.exports = require("@khanacademy/wonder-blocks-core");
|
|
|
178
178
|
|
|
179
179
|
/***/ }),
|
|
180
180
|
/* 6 */
|
|
181
|
-
/***/ (function(module, exports) {
|
|
182
|
-
|
|
183
|
-
module.exports = require("@khanacademy/wonder-blocks-icon");
|
|
184
|
-
|
|
185
|
-
/***/ }),
|
|
186
|
-
/* 7 */
|
|
187
181
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
188
182
|
|
|
189
183
|
"use strict";
|
|
@@ -238,209 +232,73 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
238
232
|
});
|
|
239
233
|
|
|
240
234
|
/***/ }),
|
|
241
|
-
/*
|
|
235
|
+
/* 7 */
|
|
242
236
|
/***/ (function(module, exports) {
|
|
243
237
|
|
|
244
238
|
module.exports = require("react-dom");
|
|
245
239
|
|
|
246
240
|
/***/ }),
|
|
247
|
-
/*
|
|
248
|
-
/***/ (function(module, exports) {
|
|
249
|
-
|
|
250
|
-
module.exports = require("@khanacademy/wonder-blocks-typography");
|
|
251
|
-
|
|
252
|
-
/***/ }),
|
|
253
|
-
/* 10 */
|
|
241
|
+
/* 8 */
|
|
254
242
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
255
243
|
|
|
256
244
|
"use strict";
|
|
257
245
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SearchTextInput; });
|
|
258
246
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
259
247
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
260
|
-
/* harmony import */ var
|
|
261
|
-
/* harmony import */ var
|
|
262
|
-
/* harmony import */ var
|
|
263
|
-
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2__);
|
|
264
|
-
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
|
|
265
|
-
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
266
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon_button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(29);
|
|
267
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon_button__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon_button__WEBPACK_IMPORTED_MODULE_4__);
|
|
268
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6);
|
|
269
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__);
|
|
270
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2);
|
|
271
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6__);
|
|
272
|
-
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3);
|
|
273
|
-
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7__);
|
|
274
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
|
|
248
|
+
/* harmony import */ var _khanacademy_wonder_blocks_search_field__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(29);
|
|
249
|
+
/* harmony import */ var _khanacademy_wonder_blocks_search_field__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_search_field__WEBPACK_IMPORTED_MODULE_1__);
|
|
250
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
|
|
275
251
|
// A TextField with a search icon on its left side and X icon on its right side
|
|
276
252
|
|
|
277
253
|
|
|
278
254
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
255
|
class SearchTextInput extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
286
|
-
constructor(...args) {
|
|
287
|
-
super(...args);
|
|
288
|
-
this.state = {
|
|
289
|
-
focused: false,
|
|
290
|
-
labels: {
|
|
291
|
-
clearSearch: _util_constants_js__WEBPACK_IMPORTED_MODULE_8__[/* defaultLabels */ "e"].clearSearch,
|
|
292
|
-
filter: _util_constants_js__WEBPACK_IMPORTED_MODULE_8__[/* defaultLabels */ "e"].filter,
|
|
293
|
-
...this.props.labels
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
this.handleChange = e => {
|
|
298
|
-
e.preventDefault();
|
|
299
|
-
this.props.onChange(e.target.value);
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
this.handleDismiss = () => {
|
|
303
|
-
const {
|
|
304
|
-
onClick,
|
|
305
|
-
onChange
|
|
306
|
-
} = this.props; // Empty the search text and focus the SearchTextInput
|
|
307
|
-
|
|
308
|
-
onChange("");
|
|
309
|
-
|
|
310
|
-
if (onClick) {
|
|
311
|
-
onClick();
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
this.handleBlur = e => {
|
|
316
|
-
this.setState({
|
|
317
|
-
focused: false
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
this.handleFocus = e => {
|
|
322
|
-
this.setState({
|
|
323
|
-
focused: true
|
|
324
|
-
});
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
|
|
328
256
|
static isClassOf(instance) {
|
|
329
257
|
return instance && instance.type && instance.type.__IS_SEARCH_TEXT_INPUT__;
|
|
330
258
|
}
|
|
331
259
|
|
|
332
|
-
componentDidUpdate(prevProps) {
|
|
333
|
-
if (this.props.labels !== prevProps.labels) {
|
|
334
|
-
// eslint-disable-next-line react/no-did-update-set-state
|
|
335
|
-
this.setState({
|
|
336
|
-
labels: { ...this.state.labels,
|
|
337
|
-
...this.props.labels
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
maybeRenderDismissIconButton() {
|
|
344
|
-
const {
|
|
345
|
-
searchText
|
|
346
|
-
} = this.props;
|
|
347
|
-
const {
|
|
348
|
-
clearSearch
|
|
349
|
-
} = this.state.labels;
|
|
350
|
-
|
|
351
|
-
if (searchText.length > 0) {
|
|
352
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_icon_button__WEBPACK_IMPORTED_MODULE_4___default.a, {
|
|
353
|
-
icon: _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__["icons"].dismiss,
|
|
354
|
-
kind: "tertiary",
|
|
355
|
-
onClick: this.handleDismiss,
|
|
356
|
-
style: styles.dismissIcon,
|
|
357
|
-
"aria-label": clearSearch
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return null;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
260
|
render() {
|
|
365
261
|
const {
|
|
262
|
+
labels,
|
|
263
|
+
onChange,
|
|
366
264
|
onClick,
|
|
367
265
|
itemRef,
|
|
368
266
|
searchText,
|
|
369
267
|
style,
|
|
370
268
|
testId
|
|
371
269
|
} = this.props;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
270
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_search_field__WEBPACK_IMPORTED_MODULE_1___default.a, {
|
|
271
|
+
clearAriaLabel: labels.clearSearch,
|
|
272
|
+
onChange: onChange,
|
|
376
273
|
onClick: onClick,
|
|
377
|
-
|
|
378
|
-
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5___default.a, {
|
|
379
|
-
icon: _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__["icons"].search,
|
|
380
|
-
size: "medium",
|
|
381
|
-
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6___default.a.offBlack64,
|
|
382
|
-
style: styles.searchIcon,
|
|
383
|
-
"aria-hidden": "true"
|
|
384
|
-
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("input", {
|
|
385
|
-
type: "text",
|
|
386
|
-
onChange: this.handleChange,
|
|
387
|
-
onFocus: this.handleFocus,
|
|
388
|
-
onBlur: this.handleBlur,
|
|
274
|
+
placeholder: labels.filter,
|
|
389
275
|
ref: itemRef,
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}), this.maybeRenderDismissIconButton());
|
|
276
|
+
style: style,
|
|
277
|
+
testId: testId,
|
|
278
|
+
value: searchText
|
|
279
|
+
});
|
|
395
280
|
}
|
|
396
281
|
|
|
397
282
|
}
|
|
398
283
|
SearchTextInput.defaultProps = {
|
|
399
284
|
labels: {
|
|
400
|
-
clearSearch:
|
|
401
|
-
filter:
|
|
285
|
+
clearSearch: _util_constants_js__WEBPACK_IMPORTED_MODULE_2__[/* defaultLabels */ "e"].clearSearch,
|
|
286
|
+
filter: _util_constants_js__WEBPACK_IMPORTED_MODULE_2__[/* defaultLabels */ "e"].filter
|
|
402
287
|
}
|
|
403
288
|
};
|
|
404
289
|
SearchTextInput.__IS_SEARCH_TEXT_INPUT__ = true;
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
},
|
|
418
|
-
focused: {
|
|
419
|
-
border: `1px solid ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6___default.a.blue}`
|
|
420
|
-
},
|
|
421
|
-
searchIcon: {
|
|
422
|
-
marginLeft: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7___default.a.xSmall_8,
|
|
423
|
-
marginRight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7___default.a.xSmall_8
|
|
424
|
-
},
|
|
425
|
-
dismissIcon: {
|
|
426
|
-
margin: 0,
|
|
427
|
-
":hover": {
|
|
428
|
-
border: "none"
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
inputStyleReset: {
|
|
432
|
-
display: "flex",
|
|
433
|
-
flex: 1,
|
|
434
|
-
background: "inherit",
|
|
435
|
-
border: "none",
|
|
436
|
-
outline: "none",
|
|
437
|
-
"::placeholder": {
|
|
438
|
-
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_6___default.a.offBlack64
|
|
439
|
-
},
|
|
440
|
-
width: "100%",
|
|
441
|
-
color: "inherit"
|
|
442
|
-
}
|
|
443
|
-
});
|
|
290
|
+
|
|
291
|
+
/***/ }),
|
|
292
|
+
/* 9 */
|
|
293
|
+
/***/ (function(module, exports) {
|
|
294
|
+
|
|
295
|
+
module.exports = require("@khanacademy/wonder-blocks-icon");
|
|
296
|
+
|
|
297
|
+
/***/ }),
|
|
298
|
+
/* 10 */
|
|
299
|
+
/***/ (function(module, exports) {
|
|
300
|
+
|
|
301
|
+
module.exports = require("@khanacademy/wonder-blocks-typography");
|
|
444
302
|
|
|
445
303
|
/***/ }),
|
|
446
304
|
/* 11 */
|
|
@@ -466,7 +324,7 @@ module.exports = require("@khanacademy/wonder-blocks-clickable");
|
|
|
466
324
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__);
|
|
467
325
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3);
|
|
468
326
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__);
|
|
469
|
-
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
327
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(10);
|
|
470
328
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__);
|
|
471
329
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(11);
|
|
472
330
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7__);
|
|
@@ -630,7 +488,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
630
488
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
631
489
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
|
|
632
490
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__);
|
|
633
|
-
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
491
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
|
|
634
492
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__);
|
|
635
493
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
|
|
636
494
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__);
|
|
@@ -859,7 +717,7 @@ DropdownOpener.defaultProps = {
|
|
|
859
717
|
"use strict";
|
|
860
718
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
861
719
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
862
|
-
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
720
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
863
721
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
864
722
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
865
723
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
@@ -871,13 +729,13 @@ DropdownOpener.defaultProps = {
|
|
|
871
729
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__);
|
|
872
730
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5);
|
|
873
731
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6__);
|
|
874
|
-
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
|
|
732
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(10);
|
|
875
733
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_7__);
|
|
876
734
|
/* harmony import */ var _khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(18);
|
|
877
735
|
/* harmony import */ var _khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_8__);
|
|
878
736
|
/* harmony import */ var _dropdown_core_virtualized_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(27);
|
|
879
|
-
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(
|
|
880
|
-
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(
|
|
737
|
+
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(6);
|
|
738
|
+
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(8);
|
|
881
739
|
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(1);
|
|
882
740
|
/* harmony import */ var _dropdown_popper_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(30);
|
|
883
741
|
/* harmony import */ var _util_dropdown_menu_styles_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(16);
|
|
@@ -1574,8 +1432,8 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
|
1574
1432
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
|
1575
1433
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_0__);
|
|
1576
1434
|
/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
|
|
1577
|
-
/* harmony import */ var _components_separator_item_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
1578
|
-
/* harmony import */ var _components_search_text_input_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
1435
|
+
/* harmony import */ var _components_separator_item_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
|
|
1436
|
+
/* harmony import */ var _components_search_text_input_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8);
|
|
1579
1437
|
|
|
1580
1438
|
|
|
1581
1439
|
|
|
@@ -1653,11 +1511,11 @@ module.exports = require("@khanacademy/wonder-blocks-timing");
|
|
|
1653
1511
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
1654
1512
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(11);
|
|
1655
1513
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5__);
|
|
1656
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
1514
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9);
|
|
1657
1515
|
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_6__);
|
|
1658
1516
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3);
|
|
1659
1517
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7__);
|
|
1660
|
-
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
|
|
1518
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(10);
|
|
1661
1519
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_8__);
|
|
1662
1520
|
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1);
|
|
1663
1521
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -1887,7 +1745,7 @@ module.exports = require("react-window");
|
|
|
1887
1745
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ActionMenu; });
|
|
1888
1746
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1889
1747
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1890
|
-
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
1748
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
1891
1749
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
1892
1750
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
1893
1751
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
@@ -2101,13 +1959,13 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
|
2101
1959
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SingleSelect; });
|
|
2102
1960
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
2103
1961
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2104
|
-
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
1962
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
2105
1963
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
2106
1964
|
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(15);
|
|
2107
1965
|
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
|
|
2108
1966
|
/* harmony import */ var _select_opener_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(19);
|
|
2109
1967
|
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
|
|
2110
|
-
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
1968
|
+
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8);
|
|
2111
1969
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2112
1970
|
|
|
2113
1971
|
|
|
@@ -2377,14 +2235,14 @@ SingleSelect.defaultProps = {
|
|
|
2377
2235
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return MultiSelect; });
|
|
2378
2236
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
2379
2237
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2380
|
-
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
2238
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
2381
2239
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
2382
2240
|
/* harmony import */ var _action_item_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12);
|
|
2383
2241
|
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
|
|
2384
2242
|
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(14);
|
|
2385
|
-
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
2243
|
+
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
|
|
2386
2244
|
/* harmony import */ var _select_opener_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(19);
|
|
2387
|
-
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
|
|
2245
|
+
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6);
|
|
2388
2246
|
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
|
|
2389
2247
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2390
2248
|
|
|
@@ -2795,7 +2653,7 @@ module.exports = require("react-router-dom");
|
|
|
2795
2653
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
2796
2654
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
2797
2655
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
2798
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
2656
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
|
|
2799
2657
|
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_3__);
|
|
2800
2658
|
|
|
2801
2659
|
|
|
@@ -2854,7 +2712,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
2854
2712
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
2855
2713
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
|
|
2856
2714
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
2857
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
2715
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9);
|
|
2858
2716
|
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_4__);
|
|
2859
2717
|
|
|
2860
2718
|
|
|
@@ -2940,15 +2798,15 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
2940
2798
|
"use strict";
|
|
2941
2799
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
2942
2800
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2943
|
-
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
2801
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
2944
2802
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
2945
2803
|
/* harmony import */ var react_window__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20);
|
|
2946
2804
|
/* harmony import */ var react_window__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_window__WEBPACK_IMPORTED_MODULE_2__);
|
|
2947
2805
|
/* harmony import */ var _khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(18);
|
|
2948
2806
|
/* harmony import */ var _khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_3__);
|
|
2949
2807
|
/* harmony import */ var _dropdown_core_virtualized_item_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(28);
|
|
2950
|
-
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
2951
|
-
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
2808
|
+
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
|
|
2809
|
+
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6);
|
|
2952
2810
|
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1);
|
|
2953
2811
|
/* harmony import */ var _util_dropdown_menu_styles_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(16);
|
|
2954
2812
|
|
|
@@ -3138,7 +2996,7 @@ class DropdownCoreVirtualized extends react__WEBPACK_IMPORTED_MODULE_0__["Compon
|
|
|
3138
2996
|
"use strict";
|
|
3139
2997
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
3140
2998
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
3141
|
-
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
2999
|
+
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
|
|
3142
3000
|
|
|
3143
3001
|
|
|
3144
3002
|
|
|
@@ -3189,7 +3047,7 @@ class DropdownVirtualizedItem extends react__WEBPACK_IMPORTED_MODULE_0__["Compon
|
|
|
3189
3047
|
/* 29 */
|
|
3190
3048
|
/***/ (function(module, exports) {
|
|
3191
3049
|
|
|
3192
|
-
module.exports = require("@khanacademy/wonder-blocks-
|
|
3050
|
+
module.exports = require("@khanacademy/wonder-blocks-search-field");
|
|
3193
3051
|
|
|
3194
3052
|
/***/ }),
|
|
3195
3053
|
/* 30 */
|
|
@@ -3199,7 +3057,7 @@ module.exports = require("@khanacademy/wonder-blocks-icon-button");
|
|
|
3199
3057
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DropdownPopper; });
|
|
3200
3058
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
3201
3059
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
3202
|
-
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
3060
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
3203
3061
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
3204
3062
|
/* harmony import */ var react_popper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(31);
|
|
3205
3063
|
/* harmony import */ var react_popper__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_popper__WEBPACK_IMPORTED_MODULE_2__);
|
|
@@ -3289,13 +3147,13 @@ module.exports = require("@khanacademy/wonder-blocks-modal");
|
|
|
3289
3147
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
3290
3148
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
3291
3149
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
3292
|
-
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
3150
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
|
|
3293
3151
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2__);
|
|
3294
3152
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
3295
3153
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__);
|
|
3296
3154
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
|
|
3297
3155
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
3298
|
-
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
3156
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9);
|
|
3299
3157
|
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__);
|
|
3300
3158
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
|
|
3301
3159
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__);
|
|
@@ -3472,7 +3330,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3472
3330
|
/* harmony import */ var _components_option_item_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(13);
|
|
3473
3331
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OptionItem", function() { return _components_option_item_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
|
|
3474
3332
|
|
|
3475
|
-
/* harmony import */ var _components_separator_item_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
3333
|
+
/* harmony import */ var _components_separator_item_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
|
|
3476
3334
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SeparatorItem", function() { return _components_separator_item_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
|
|
3477
3335
|
|
|
3478
3336
|
/* harmony import */ var _components_action_menu_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-dropdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Dropdown variants for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@khanacademy/wonder-blocks-icon-button": "^3.4.6",
|
|
25
25
|
"@khanacademy/wonder-blocks-layout": "^1.4.9",
|
|
26
26
|
"@khanacademy/wonder-blocks-modal": "^2.3.1",
|
|
27
|
+
"@khanacademy/wonder-blocks-search-field": "^1.0.4",
|
|
27
28
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
28
29
|
"@khanacademy/wonder-blocks-timing": "^2.1.0",
|
|
29
30
|
"@khanacademy/wonder-blocks-typography": "^1.1.31"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
4
|
-
import "
|
|
3
|
+
import {render, screen} from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
import SearchTextInput from "../search-text-input.js";
|
|
7
7
|
|
|
8
8
|
describe("SearchTextInput", () => {
|
|
9
|
-
|
|
9
|
+
test("text input container should be focused when focusing on the input", () => {
|
|
10
10
|
// Arrange
|
|
11
|
-
|
|
11
|
+
render(
|
|
12
12
|
<SearchTextInput
|
|
13
13
|
searchText=""
|
|
14
14
|
testId="search-text-input"
|
|
@@ -16,18 +16,18 @@ describe("SearchTextInput", () => {
|
|
|
16
16
|
/>,
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
const input =
|
|
19
|
+
const input = screen.getByTestId("search-text-input");
|
|
20
20
|
|
|
21
21
|
// Act
|
|
22
|
-
input.
|
|
22
|
+
input.focus();
|
|
23
23
|
|
|
24
24
|
// Assert
|
|
25
|
-
expect(
|
|
25
|
+
expect(input).toHaveFocus();
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
test("text input should not be focused when losing focus", () => {
|
|
29
29
|
// Arrange
|
|
30
|
-
|
|
30
|
+
render(
|
|
31
31
|
<SearchTextInput
|
|
32
32
|
searchText=""
|
|
33
33
|
testId="search-text-input"
|
|
@@ -35,23 +35,23 @@ describe("SearchTextInput", () => {
|
|
|
35
35
|
/>,
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
const input =
|
|
38
|
+
const input = screen.getByTestId("search-text-input");
|
|
39
39
|
// focus in
|
|
40
|
-
input.
|
|
40
|
+
input.focus();
|
|
41
41
|
|
|
42
42
|
// Act
|
|
43
43
|
// focus out
|
|
44
|
-
input.
|
|
44
|
+
input.blur();
|
|
45
45
|
|
|
46
46
|
// Assert
|
|
47
|
-
expect(
|
|
47
|
+
expect(input).not.toHaveFocus();
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
test("onChange should be invoked if text input changes", () => {
|
|
51
51
|
// Arrange
|
|
52
52
|
const onChangeMock = jest.fn();
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
render(
|
|
55
55
|
<SearchTextInput
|
|
56
56
|
searchText=""
|
|
57
57
|
testId="search-text-input"
|
|
@@ -59,87 +59,154 @@ describe("SearchTextInput", () => {
|
|
|
59
59
|
/>,
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
-
const input =
|
|
62
|
+
const input = screen.getByTestId("search-text-input");
|
|
63
63
|
|
|
64
64
|
// Act
|
|
65
|
-
|
|
66
|
-
target: {value: "query"},
|
|
67
|
-
preventDefault: jest.fn(),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
wrapper.update();
|
|
65
|
+
userEvent.paste(input, "value");
|
|
71
66
|
|
|
72
67
|
// Assert
|
|
73
|
-
expect(onChangeMock).toHaveBeenCalledWith("
|
|
68
|
+
expect(onChangeMock).toHaveBeenCalledWith("value");
|
|
74
69
|
});
|
|
75
70
|
|
|
76
|
-
|
|
71
|
+
test("displays the dismiss button when search text exists", () => {
|
|
77
72
|
// Arrange
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
const SearchFieldWrapper = () => {
|
|
74
|
+
const [value, setValue] = React.useState("");
|
|
75
|
+
return (
|
|
76
|
+
<SearchTextInput
|
|
77
|
+
searchText={value}
|
|
78
|
+
testId="search-text-input"
|
|
79
|
+
onChange={setValue}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
render(<SearchFieldWrapper />);
|
|
85
|
+
|
|
86
|
+
const input = screen.getByTestId("search-text-input");
|
|
87
|
+
|
|
88
|
+
// Act
|
|
89
|
+
userEvent.paste(input, "value");
|
|
90
|
+
|
|
91
|
+
// Assert
|
|
92
|
+
const clearIconButton = screen.queryByRole("button");
|
|
93
|
+
expect(clearIconButton).toBeInTheDocument();
|
|
94
|
+
});
|
|
86
95
|
|
|
87
|
-
|
|
96
|
+
test("search should be cleared if the clear icon is clicked", () => {
|
|
97
|
+
// Arrange
|
|
98
|
+
const SearchFieldWrapper = () => {
|
|
99
|
+
const [value, setValue] = React.useState("initial value");
|
|
100
|
+
return (
|
|
101
|
+
<SearchTextInput
|
|
102
|
+
searchText={value}
|
|
103
|
+
testId="search-text-input"
|
|
104
|
+
onChange={setValue}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
render(<SearchFieldWrapper />);
|
|
110
|
+
|
|
111
|
+
const input = screen.getByTestId("search-text-input");
|
|
112
|
+
const clearIconButton = screen.queryByRole("button");
|
|
88
113
|
|
|
89
114
|
// Act
|
|
90
|
-
|
|
91
|
-
target: {value: "query"},
|
|
92
|
-
preventDefault: jest.fn(),
|
|
93
|
-
});
|
|
115
|
+
userEvent.click(clearIconButton);
|
|
94
116
|
|
|
95
117
|
// Assert
|
|
96
|
-
expect(
|
|
118
|
+
expect(input).toHaveValue("");
|
|
97
119
|
});
|
|
98
120
|
|
|
99
|
-
|
|
121
|
+
test("focus should return to the input element after clear button is clicked", () => {
|
|
100
122
|
// Arrange
|
|
101
|
-
const
|
|
123
|
+
const SearchFieldWrapper = () => {
|
|
124
|
+
const [value, setValue] = React.useState("");
|
|
125
|
+
return (
|
|
126
|
+
<SearchTextInput
|
|
127
|
+
searchText={value}
|
|
128
|
+
testId="search-text-input"
|
|
129
|
+
onChange={setValue}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
render(<SearchFieldWrapper />);
|
|
135
|
+
|
|
136
|
+
const input = screen.getByTestId("search-text-input");
|
|
137
|
+
userEvent.paste(input, "something");
|
|
102
138
|
|
|
103
|
-
|
|
139
|
+
// Act
|
|
140
|
+
const clearIconButton = screen.queryByRole("button");
|
|
141
|
+
userEvent.click(clearIconButton);
|
|
142
|
+
|
|
143
|
+
// Assert
|
|
144
|
+
expect(input).toHaveFocus();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("placeholder should be updated by the parent component", () => {
|
|
148
|
+
// Arrange
|
|
149
|
+
const {rerender} = render(
|
|
104
150
|
<SearchTextInput
|
|
105
151
|
searchText="query"
|
|
106
|
-
onChange={() =>
|
|
107
|
-
|
|
152
|
+
onChange={() => {}}
|
|
153
|
+
labels={{
|
|
154
|
+
clearSearch: "Clear",
|
|
155
|
+
filter: "Filter",
|
|
156
|
+
}}
|
|
157
|
+
testId="search-text-input"
|
|
108
158
|
/>,
|
|
109
159
|
);
|
|
110
160
|
|
|
111
|
-
const
|
|
161
|
+
const input = screen.getByTestId("search-text-input");
|
|
112
162
|
|
|
113
163
|
// Act
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
164
|
+
rerender(
|
|
165
|
+
<SearchTextInput
|
|
166
|
+
searchText="query"
|
|
167
|
+
onChange={() => {}}
|
|
168
|
+
labels={{
|
|
169
|
+
clearSearch: "Dismiss",
|
|
170
|
+
filter: "Search",
|
|
171
|
+
}}
|
|
172
|
+
testId="search-text-input"
|
|
173
|
+
/>,
|
|
174
|
+
);
|
|
117
175
|
|
|
118
176
|
// Assert
|
|
119
|
-
expect(
|
|
177
|
+
expect(input).toHaveAttribute("placeholder", "Search");
|
|
120
178
|
});
|
|
121
179
|
|
|
122
|
-
|
|
180
|
+
test("button label should be updated by the parent component", () => {
|
|
123
181
|
// Arrange
|
|
124
|
-
const
|
|
182
|
+
const {rerender} = render(
|
|
125
183
|
<SearchTextInput
|
|
126
184
|
searchText="query"
|
|
127
|
-
onChange={() =>
|
|
185
|
+
onChange={() => {}}
|
|
128
186
|
labels={{
|
|
129
187
|
clearSearch: "Clear",
|
|
130
188
|
filter: "Filter",
|
|
131
189
|
}}
|
|
190
|
+
testId="search-text-input"
|
|
132
191
|
/>,
|
|
133
192
|
);
|
|
134
193
|
|
|
135
|
-
|
|
136
|
-
wrapper.setProps({labels: {clearSearch: "Dismiss", filter: "Search"}});
|
|
194
|
+
const clearIconButton = screen.queryByRole("button");
|
|
137
195
|
|
|
138
|
-
|
|
196
|
+
// Act
|
|
197
|
+
rerender(
|
|
198
|
+
<SearchTextInput
|
|
199
|
+
searchText="query"
|
|
200
|
+
onChange={() => {}}
|
|
201
|
+
labels={{
|
|
202
|
+
clearSearch: "Dismiss",
|
|
203
|
+
filter: "Search",
|
|
204
|
+
}}
|
|
205
|
+
testId="search-text-input"
|
|
206
|
+
/>,
|
|
207
|
+
);
|
|
139
208
|
|
|
140
209
|
// Assert
|
|
141
|
-
expect(
|
|
142
|
-
labels: {clearSearch: "Dismiss", filter: "Search"},
|
|
143
|
-
});
|
|
210
|
+
expect(clearIconButton).toHaveAttribute("aria-label", "Dismiss");
|
|
144
211
|
});
|
|
145
212
|
});
|
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
// A TextField with a search icon on its left side and X icon on its right side
|
|
3
3
|
|
|
4
4
|
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {styles as typographyStyles} from "@khanacademy/wonder-blocks-typography";
|
|
8
|
-
import {View} from "@khanacademy/wonder-blocks-core";
|
|
9
|
-
import IconButton from "@khanacademy/wonder-blocks-icon-button";
|
|
10
|
-
import Icon, {icons} from "@khanacademy/wonder-blocks-icon";
|
|
11
|
-
import Color from "@khanacademy/wonder-blocks-color";
|
|
12
|
-
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
5
|
+
|
|
6
|
+
import SearchField from "@khanacademy/wonder-blocks-search-field";
|
|
13
7
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
14
8
|
|
|
15
|
-
import {defaultLabels
|
|
9
|
+
import {defaultLabels} from "../util/constants.js";
|
|
16
10
|
|
|
17
11
|
type Labels = {|
|
|
18
12
|
clearSearch: string,
|
|
@@ -63,16 +57,7 @@ type DefaultProps = {|
|
|
|
63
57
|
labels: $PropertyType<Props, "labels">,
|
|
64
58
|
|};
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
focused: boolean,
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The object containing the custom labels used inside this component.
|
|
71
|
-
*/
|
|
72
|
-
labels: Labels,
|
|
73
|
-
|};
|
|
74
|
-
|
|
75
|
-
export default class SearchTextInput extends React.Component<Props, State> {
|
|
60
|
+
export default class SearchTextInput extends React.Component<Props> {
|
|
76
61
|
static isClassOf(instance: React.Element<any>): boolean {
|
|
77
62
|
return (
|
|
78
63
|
instance && instance.type && instance.type.__IS_SEARCH_TEXT_INPUT__
|
|
@@ -86,142 +71,23 @@ export default class SearchTextInput extends React.Component<Props, State> {
|
|
|
86
71
|
},
|
|
87
72
|
};
|
|
88
73
|
|
|
89
|
-
state: State = {
|
|
90
|
-
focused: false,
|
|
91
|
-
labels: {
|
|
92
|
-
clearSearch: defaultLabels.clearSearch,
|
|
93
|
-
filter: defaultLabels.filter,
|
|
94
|
-
...this.props.labels,
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
componentDidUpdate(prevProps: Props) {
|
|
99
|
-
if (this.props.labels !== prevProps.labels) {
|
|
100
|
-
// eslint-disable-next-line react/no-did-update-set-state
|
|
101
|
-
this.setState({
|
|
102
|
-
labels: {...this.state.labels, ...this.props.labels},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
74
|
static __IS_SEARCH_TEXT_INPUT__: boolean = true;
|
|
108
75
|
|
|
109
|
-
handleChange: (e: SyntheticInputEvent<>) => void = (e) => {
|
|
110
|
-
e.preventDefault();
|
|
111
|
-
this.props.onChange(e.target.value);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
handleDismiss: () => void = () => {
|
|
115
|
-
const {onClick, onChange} = this.props;
|
|
116
|
-
// Empty the search text and focus the SearchTextInput
|
|
117
|
-
onChange("");
|
|
118
|
-
if (onClick) {
|
|
119
|
-
onClick();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
handleBlur: (e: SyntheticInputEvent<>) => void = (e) => {
|
|
124
|
-
this.setState({focused: false});
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
handleFocus: (e: SyntheticInputEvent<>) => void = (e) => {
|
|
128
|
-
this.setState({focused: true});
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
maybeRenderDismissIconButton(): React.Node {
|
|
132
|
-
const {searchText} = this.props;
|
|
133
|
-
const {clearSearch} = this.state.labels;
|
|
134
|
-
|
|
135
|
-
if (searchText.length > 0) {
|
|
136
|
-
return (
|
|
137
|
-
<IconButton
|
|
138
|
-
icon={icons.dismiss}
|
|
139
|
-
kind="tertiary"
|
|
140
|
-
onClick={this.handleDismiss}
|
|
141
|
-
style={styles.dismissIcon}
|
|
142
|
-
aria-label={clearSearch}
|
|
143
|
-
/>
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
76
|
render(): React.Node {
|
|
150
|
-
const {onClick, itemRef, searchText, style, testId} =
|
|
151
|
-
|
|
77
|
+
const {labels, onChange, onClick, itemRef, searchText, style, testId} =
|
|
78
|
+
this.props;
|
|
152
79
|
|
|
153
80
|
return (
|
|
154
|
-
<
|
|
81
|
+
<SearchField
|
|
82
|
+
clearAriaLabel={labels.clearSearch}
|
|
83
|
+
onChange={onChange}
|
|
155
84
|
onClick={onClick}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
<Icon
|
|
163
|
-
icon={icons.search}
|
|
164
|
-
size="medium"
|
|
165
|
-
color={Color.offBlack64}
|
|
166
|
-
style={styles.searchIcon}
|
|
167
|
-
aria-hidden="true"
|
|
168
|
-
/>
|
|
169
|
-
<input
|
|
170
|
-
type="text"
|
|
171
|
-
onChange={this.handleChange}
|
|
172
|
-
onFocus={this.handleFocus}
|
|
173
|
-
onBlur={this.handleBlur}
|
|
174
|
-
ref={itemRef}
|
|
175
|
-
placeholder={filter}
|
|
176
|
-
value={searchText}
|
|
177
|
-
className={css(
|
|
178
|
-
styles.inputStyleReset,
|
|
179
|
-
typographyStyles.LabelMedium,
|
|
180
|
-
)}
|
|
181
|
-
data-test-id={testId}
|
|
182
|
-
/>
|
|
183
|
-
{this.maybeRenderDismissIconButton()}
|
|
184
|
-
</View>
|
|
85
|
+
placeholder={labels.filter}
|
|
86
|
+
ref={itemRef}
|
|
87
|
+
style={style}
|
|
88
|
+
testId={testId}
|
|
89
|
+
value={searchText}
|
|
90
|
+
/>
|
|
185
91
|
);
|
|
186
92
|
}
|
|
187
93
|
}
|
|
188
|
-
|
|
189
|
-
const styles = StyleSheet.create({
|
|
190
|
-
inputContainer: {
|
|
191
|
-
flexDirection: "row",
|
|
192
|
-
border: `1px solid ${Color.offBlack16}`,
|
|
193
|
-
borderRadius: Spacing.xxxSmall_4,
|
|
194
|
-
alignItems: "center",
|
|
195
|
-
// The height of the text input is 40 in design spec and we need to
|
|
196
|
-
// specify the height as well as minHeight to make sure the search text
|
|
197
|
-
// input takes enough height to render. (otherwise, it will get
|
|
198
|
-
// squashed)
|
|
199
|
-
height: DROPDOWN_ITEM_HEIGHT,
|
|
200
|
-
minHeight: DROPDOWN_ITEM_HEIGHT,
|
|
201
|
-
},
|
|
202
|
-
focused: {
|
|
203
|
-
border: `1px solid ${Color.blue}`,
|
|
204
|
-
},
|
|
205
|
-
searchIcon: {
|
|
206
|
-
marginLeft: Spacing.xSmall_8,
|
|
207
|
-
marginRight: Spacing.xSmall_8,
|
|
208
|
-
},
|
|
209
|
-
dismissIcon: {
|
|
210
|
-
margin: 0,
|
|
211
|
-
":hover": {
|
|
212
|
-
border: "none",
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
inputStyleReset: {
|
|
216
|
-
display: "flex",
|
|
217
|
-
flex: 1,
|
|
218
|
-
background: "inherit",
|
|
219
|
-
border: "none",
|
|
220
|
-
outline: "none",
|
|
221
|
-
"::placeholder": {
|
|
222
|
-
color: Color.offBlack64,
|
|
223
|
-
},
|
|
224
|
-
width: "100%",
|
|
225
|
-
color: "inherit",
|
|
226
|
-
},
|
|
227
|
-
});
|