@khanacademy/wonder-blocks-dropdown 2.8.2 → 2.9.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 +28 -0
- package/dist/es/index.js +18 -9
- package/dist/index.js +41 -30
- package/docs.md +4 -11
- package/package.json +9 -10
- package/src/components/__docs__/single-select.stories.js +54 -0
- package/src/components/__tests__/single-select.test.js +95 -0
- package/src/components/dropdown-core.js +7 -7
- package/src/components/multi-select.js +1 -1
- package/src/components/single-select.js +42 -4
- package/src/index.js +2 -1
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +0 -4548
- package/src/__tests__/generated-snapshot.test.js +0 -1612
- package/src/components/action-menu.md +0 -338
- package/src/components/multi-select.md +0 -718
- package/src/components/single-select.md +0 -520
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-dropdown
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3bae2aba: Added `labels` prop to be able to translate some internal texts (already supported by MultiSelect)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [3bae2aba]
|
|
12
|
+
- @khanacademy/wonder-blocks-icon@1.2.31
|
|
13
|
+
- @khanacademy/wonder-blocks-modal@2.3.8
|
|
14
|
+
- @khanacademy/wonder-blocks-search-field@1.0.10
|
|
15
|
+
|
|
16
|
+
## 2.8.3
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [6ee20af9]
|
|
21
|
+
- @khanacademy/wonder-blocks-core@4.4.0
|
|
22
|
+
- @khanacademy/wonder-blocks-button@3.0.3
|
|
23
|
+
- @khanacademy/wonder-blocks-clickable@2.3.1
|
|
24
|
+
- @khanacademy/wonder-blocks-icon@1.2.30
|
|
25
|
+
- @khanacademy/wonder-blocks-icon-button@3.4.11
|
|
26
|
+
- @khanacademy/wonder-blocks-layout@1.4.11
|
|
27
|
+
- @khanacademy/wonder-blocks-modal@2.3.7
|
|
28
|
+
- @khanacademy/wonder-blocks-search-field@1.0.9
|
|
29
|
+
- @khanacademy/wonder-blocks-typography@1.1.33
|
|
30
|
+
|
|
3
31
|
## 2.8.2
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -902,7 +902,8 @@ class DropdownCore extends React.Component {
|
|
|
902
902
|
itemRefs: [],
|
|
903
903
|
sameItemsFocusable: false,
|
|
904
904
|
labels: _extends({
|
|
905
|
-
noResults: defaultLabels.noResults
|
|
905
|
+
noResults: defaultLabels.noResults,
|
|
906
|
+
someResults: defaultLabels.someSelected
|
|
906
907
|
}, props.labels)
|
|
907
908
|
};
|
|
908
909
|
this.virtualizedListRef = React.createRef();
|
|
@@ -1245,7 +1246,7 @@ class DropdownCore extends React.Component {
|
|
|
1245
1246
|
"aria-relevant": "additions text",
|
|
1246
1247
|
style: styles$3.srOnly,
|
|
1247
1248
|
"data-test-id": "dropdown-live-region"
|
|
1248
|
-
}, open && labels.
|
|
1249
|
+
}, open && labels.someResults(totalItems));
|
|
1249
1250
|
}
|
|
1250
1251
|
|
|
1251
1252
|
render() {
|
|
@@ -1271,7 +1272,7 @@ DropdownCore.defaultProps = {
|
|
|
1271
1272
|
clearSearch: defaultLabels.clearSearch,
|
|
1272
1273
|
filter: defaultLabels.filter,
|
|
1273
1274
|
noResults: defaultLabels.noResults,
|
|
1274
|
-
|
|
1275
|
+
someResults: defaultLabels.someSelected
|
|
1275
1276
|
},
|
|
1276
1277
|
light: false,
|
|
1277
1278
|
selectionType: "single"
|
|
@@ -1810,7 +1811,7 @@ const _generateStyles = (light, placeholder) => {
|
|
|
1810
1811
|
return stateStyles[styleKey];
|
|
1811
1812
|
};
|
|
1812
1813
|
|
|
1813
|
-
const _excluded$1 = ["children", "disabled", "id", "light", "opener", "placeholder", "selectedValue", "testId", "alignment", "dropdownStyle", "isFilterable", "onChange", "onToggle", "opened", "style", "className"];
|
|
1814
|
+
const _excluded$1 = ["children", "disabled", "id", "light", "opener", "placeholder", "selectedValue", "testId", "alignment", "dropdownStyle", "isFilterable", "labels", "onChange", "onToggle", "opened", "style", "className"];
|
|
1814
1815
|
class SingleSelect extends React.Component {
|
|
1815
1816
|
constructor(props) {
|
|
1816
1817
|
super(props);
|
|
@@ -1963,11 +1964,12 @@ class SingleSelect extends React.Component {
|
|
|
1963
1964
|
const {
|
|
1964
1965
|
alignment,
|
|
1965
1966
|
children,
|
|
1967
|
+
className,
|
|
1966
1968
|
dropdownStyle,
|
|
1967
1969
|
isFilterable,
|
|
1970
|
+
labels,
|
|
1968
1971
|
light,
|
|
1969
|
-
style
|
|
1970
|
-
className
|
|
1972
|
+
style
|
|
1971
1973
|
} = this.props;
|
|
1972
1974
|
const {
|
|
1973
1975
|
searchText
|
|
@@ -1991,7 +1993,8 @@ class SingleSelect extends React.Component {
|
|
|
1991
1993
|
className: className,
|
|
1992
1994
|
isFilterable: isFilterable,
|
|
1993
1995
|
onSearchTextChanged: isFilterable ? this.handleSearchTextChanged : null,
|
|
1994
|
-
searchText: isFilterable ? searchText : ""
|
|
1996
|
+
searchText: isFilterable ? searchText : "",
|
|
1997
|
+
labels: labels
|
|
1995
1998
|
});
|
|
1996
1999
|
}
|
|
1997
2000
|
|
|
@@ -1999,7 +2002,13 @@ class SingleSelect extends React.Component {
|
|
|
1999
2002
|
SingleSelect.defaultProps = {
|
|
2000
2003
|
alignment: "left",
|
|
2001
2004
|
disabled: false,
|
|
2002
|
-
light: false
|
|
2005
|
+
light: false,
|
|
2006
|
+
labels: {
|
|
2007
|
+
clearSearch: defaultLabels.clearSearch,
|
|
2008
|
+
filter: defaultLabels.filter,
|
|
2009
|
+
noResults: defaultLabels.noResults,
|
|
2010
|
+
someResults: defaultLabels.someSelected
|
|
2011
|
+
}
|
|
2003
2012
|
};
|
|
2004
2013
|
|
|
2005
2014
|
const _excluded = ["disabled", "id", "light", "opener", "testId", "alignment", "dropdownStyle", "implicitAllEnabled", "isFilterable", "labels", "onChange", "onToggle", "opened", "selectedValues", "shortcuts", "style", "className"];
|
|
@@ -2305,7 +2314,7 @@ class MultiSelect extends React.Component {
|
|
|
2305
2314
|
clearSearch,
|
|
2306
2315
|
filter,
|
|
2307
2316
|
noResults,
|
|
2308
|
-
someSelected
|
|
2317
|
+
someResults: someSelected
|
|
2309
2318
|
}
|
|
2310
2319
|
});
|
|
2311
2320
|
}
|
package/dist/index.js
CHANGED
|
@@ -93,12 +93,6 @@ module.exports = require("react");
|
|
|
93
93
|
|
|
94
94
|
/***/ }),
|
|
95
95
|
/* 1 */
|
|
96
|
-
/***/ (function(module, exports) {
|
|
97
|
-
|
|
98
|
-
module.exports = require("@khanacademy/wonder-blocks-color");
|
|
99
|
-
|
|
100
|
-
/***/ }),
|
|
101
|
-
/* 2 */
|
|
102
96
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
103
97
|
|
|
104
98
|
"use strict";
|
|
@@ -151,6 +145,12 @@ const defaultLabels = {
|
|
|
151
145
|
allSelected: "All items"
|
|
152
146
|
};
|
|
153
147
|
|
|
148
|
+
/***/ }),
|
|
149
|
+
/* 2 */
|
|
150
|
+
/***/ (function(module, exports) {
|
|
151
|
+
|
|
152
|
+
module.exports = require("@khanacademy/wonder-blocks-color");
|
|
153
|
+
|
|
154
154
|
/***/ }),
|
|
155
155
|
/* 3 */
|
|
156
156
|
/***/ (function(module, exports) {
|
|
@@ -202,7 +202,7 @@ module.exports = _extends, module.exports.__esModule = true, module.exports["def
|
|
|
202
202
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
203
203
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
204
204
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
205
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
205
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
206
206
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
207
207
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
|
|
208
208
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__);
|
|
@@ -287,7 +287,7 @@ module.exports = require("@khanacademy/wonder-blocks-clickable");
|
|
|
287
287
|
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_3__);
|
|
288
288
|
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(17);
|
|
289
289
|
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_4__);
|
|
290
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
290
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2);
|
|
291
291
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__);
|
|
292
292
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
|
|
293
293
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__);
|
|
@@ -297,7 +297,7 @@ module.exports = require("@khanacademy/wonder-blocks-clickable");
|
|
|
297
297
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_8__);
|
|
298
298
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(5);
|
|
299
299
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_9__);
|
|
300
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(
|
|
300
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1);
|
|
301
301
|
|
|
302
302
|
|
|
303
303
|
|
|
@@ -452,7 +452,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
|
452
452
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
453
453
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
454
454
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
455
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
455
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
456
456
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__);
|
|
457
457
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3);
|
|
458
458
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__);
|
|
@@ -462,7 +462,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
|
462
462
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6__);
|
|
463
463
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(11);
|
|
464
464
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7__);
|
|
465
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
|
|
465
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
|
|
466
466
|
/* harmony import */ var _check_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(26);
|
|
467
467
|
/* harmony import */ var _checkbox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(27);
|
|
468
468
|
|
|
@@ -690,7 +690,7 @@ DropdownOpener.defaultProps = {
|
|
|
690
690
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
691
691
|
/* harmony import */ var react_window__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(20);
|
|
692
692
|
/* harmony import */ var react_window__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_window__WEBPACK_IMPORTED_MODULE_3__);
|
|
693
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
693
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
|
|
694
694
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__);
|
|
695
695
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3);
|
|
696
696
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__);
|
|
@@ -704,7 +704,7 @@ DropdownOpener.defaultProps = {
|
|
|
704
704
|
/* harmony import */ var _khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_9__);
|
|
705
705
|
/* harmony import */ var _dropdown_core_virtualized_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(29);
|
|
706
706
|
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(7);
|
|
707
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(
|
|
707
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(1);
|
|
708
708
|
/* harmony import */ var _dropdown_popper_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(31);
|
|
709
709
|
/* harmony import */ var _util_helpers_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(21);
|
|
710
710
|
/* harmony import */ var _util_dropdown_menu_styles_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(16);
|
|
@@ -1001,6 +1001,8 @@ class DropdownCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1001
1001
|
sameItemsFocusable: false,
|
|
1002
1002
|
labels: {
|
|
1003
1003
|
noResults: _util_constants_js__WEBPACK_IMPORTED_MODULE_12__[/* defaultLabels */ "d"].noResults,
|
|
1004
|
+
// In case we are not overriding this from the caller.
|
|
1005
|
+
someResults: _util_constants_js__WEBPACK_IMPORTED_MODULE_12__[/* defaultLabels */ "d"].someSelected,
|
|
1004
1006
|
...props.labels
|
|
1005
1007
|
}
|
|
1006
1008
|
};
|
|
@@ -1431,7 +1433,7 @@ class DropdownCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1431
1433
|
"aria-relevant": "additions text",
|
|
1432
1434
|
style: styles.srOnly,
|
|
1433
1435
|
"data-test-id": "dropdown-live-region"
|
|
1434
|
-
}, open && labels.
|
|
1436
|
+
}, open && labels.someResults(totalItems));
|
|
1435
1437
|
}
|
|
1436
1438
|
|
|
1437
1439
|
render() {
|
|
@@ -1457,7 +1459,7 @@ DropdownCore.defaultProps = {
|
|
|
1457
1459
|
clearSearch: _util_constants_js__WEBPACK_IMPORTED_MODULE_12__[/* defaultLabels */ "d"].clearSearch,
|
|
1458
1460
|
filter: _util_constants_js__WEBPACK_IMPORTED_MODULE_12__[/* defaultLabels */ "d"].filter,
|
|
1459
1461
|
noResults: _util_constants_js__WEBPACK_IMPORTED_MODULE_12__[/* defaultLabels */ "d"].noResults,
|
|
1460
|
-
|
|
1462
|
+
someResults: _util_constants_js__WEBPACK_IMPORTED_MODULE_12__[/* defaultLabels */ "d"].someSelected
|
|
1461
1463
|
},
|
|
1462
1464
|
light: false,
|
|
1463
1465
|
selectionType: "single"
|
|
@@ -1519,7 +1521,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
|
1519
1521
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return generateDropdownMenuStyles; });
|
|
1520
1522
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
|
1521
1523
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_0__);
|
|
1522
|
-
/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
1524
|
+
/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
|
|
1523
1525
|
/* harmony import */ var _components_separator_item_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
|
|
1524
1526
|
|
|
1525
1527
|
|
|
@@ -1590,7 +1592,7 @@ module.exports = require("@khanacademy/wonder-blocks-timing");
|
|
|
1590
1592
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
1591
1593
|
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(17);
|
|
1592
1594
|
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_3__);
|
|
1593
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
1595
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
|
|
1594
1596
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__);
|
|
1595
1597
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
|
|
1596
1598
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__);
|
|
@@ -1602,7 +1604,7 @@ module.exports = require("@khanacademy/wonder-blocks-timing");
|
|
|
1602
1604
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_8__);
|
|
1603
1605
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(10);
|
|
1604
1606
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_9__);
|
|
1605
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(
|
|
1607
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1);
|
|
1606
1608
|
|
|
1607
1609
|
|
|
1608
1610
|
|
|
@@ -2108,7 +2110,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_3__["StyleSheet"].create({
|
|
|
2108
2110
|
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
|
|
2109
2111
|
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(14);
|
|
2110
2112
|
/* harmony import */ var _select_opener_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(19);
|
|
2111
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
2113
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
|
|
2112
2114
|
|
|
2113
2115
|
|
|
2114
2116
|
|
|
@@ -2286,6 +2288,7 @@ class SingleSelect extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
|
2286
2288
|
alignment,
|
|
2287
2289
|
dropdownStyle,
|
|
2288
2290
|
isFilterable,
|
|
2291
|
+
labels,
|
|
2289
2292
|
onChange,
|
|
2290
2293
|
onToggle,
|
|
2291
2294
|
opened,
|
|
@@ -2321,11 +2324,12 @@ class SingleSelect extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
|
2321
2324
|
const {
|
|
2322
2325
|
alignment,
|
|
2323
2326
|
children,
|
|
2327
|
+
className,
|
|
2324
2328
|
dropdownStyle,
|
|
2325
2329
|
isFilterable,
|
|
2330
|
+
labels,
|
|
2326
2331
|
light,
|
|
2327
|
-
style
|
|
2328
|
-
className
|
|
2332
|
+
style
|
|
2329
2333
|
} = this.props;
|
|
2330
2334
|
const {
|
|
2331
2335
|
searchText
|
|
@@ -2349,7 +2353,8 @@ class SingleSelect extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
|
2349
2353
|
className: className,
|
|
2350
2354
|
isFilterable: isFilterable,
|
|
2351
2355
|
onSearchTextChanged: isFilterable ? this.handleSearchTextChanged : null,
|
|
2352
|
-
searchText: isFilterable ? searchText : ""
|
|
2356
|
+
searchText: isFilterable ? searchText : "",
|
|
2357
|
+
labels: labels
|
|
2353
2358
|
});
|
|
2354
2359
|
}
|
|
2355
2360
|
|
|
@@ -2357,7 +2362,13 @@ class SingleSelect extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
|
2357
2362
|
SingleSelect.defaultProps = {
|
|
2358
2363
|
alignment: "left",
|
|
2359
2364
|
disabled: false,
|
|
2360
|
-
light: false
|
|
2365
|
+
light: false,
|
|
2366
|
+
labels: {
|
|
2367
|
+
clearSearch: _util_constants_js__WEBPACK_IMPORTED_MODULE_6__[/* defaultLabels */ "d"].clearSearch,
|
|
2368
|
+
filter: _util_constants_js__WEBPACK_IMPORTED_MODULE_6__[/* defaultLabels */ "d"].filter,
|
|
2369
|
+
noResults: _util_constants_js__WEBPACK_IMPORTED_MODULE_6__[/* defaultLabels */ "d"].noResults,
|
|
2370
|
+
someResults: _util_constants_js__WEBPACK_IMPORTED_MODULE_6__[/* defaultLabels */ "d"].someSelected
|
|
2371
|
+
}
|
|
2361
2372
|
};
|
|
2362
2373
|
|
|
2363
2374
|
/***/ }),
|
|
@@ -2377,7 +2388,7 @@ SingleSelect.defaultProps = {
|
|
|
2377
2388
|
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(14);
|
|
2378
2389
|
/* harmony import */ var _select_opener_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(19);
|
|
2379
2390
|
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7);
|
|
2380
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
|
|
2391
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
|
|
2381
2392
|
|
|
2382
2393
|
|
|
2383
2394
|
|
|
@@ -2748,7 +2759,7 @@ class MultiSelect extends react__WEBPACK_IMPORTED_MODULE_1__["Component"] {
|
|
|
2748
2759
|
clearSearch,
|
|
2749
2760
|
filter,
|
|
2750
2761
|
noResults,
|
|
2751
|
-
someSelected
|
|
2762
|
+
someResults: someSelected
|
|
2752
2763
|
}
|
|
2753
2764
|
});
|
|
2754
2765
|
}
|
|
@@ -2778,7 +2789,7 @@ module.exports = require("react-router-dom");
|
|
|
2778
2789
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2779
2790
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
2780
2791
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
2781
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
2792
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
2782
2793
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
2783
2794
|
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
|
|
2784
2795
|
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_3__);
|
|
@@ -2835,7 +2846,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
2835
2846
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2836
2847
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
2837
2848
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
2838
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
2849
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
2839
2850
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
2840
2851
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
|
|
2841
2852
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
@@ -2939,7 +2950,7 @@ module.exports = require("@khanacademy/wonder-blocks-search-field");
|
|
|
2939
2950
|
/* harmony import */ var _khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_3__);
|
|
2940
2951
|
/* harmony import */ var _dropdown_core_virtualized_item_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(30);
|
|
2941
2952
|
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7);
|
|
2942
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
2953
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
|
|
2943
2954
|
/* harmony import */ var _util_dropdown_menu_styles_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(16);
|
|
2944
2955
|
|
|
2945
2956
|
|
|
@@ -3273,7 +3284,7 @@ module.exports = require("@khanacademy/wonder-blocks-modal");
|
|
|
3273
3284
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
3274
3285
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
|
|
3275
3286
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_3__);
|
|
3276
|
-
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
3287
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
|
|
3277
3288
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__);
|
|
3278
3289
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
|
|
3279
3290
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__);
|
|
@@ -3283,7 +3294,7 @@ module.exports = require("@khanacademy/wonder-blocks-modal");
|
|
|
3283
3294
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_7__);
|
|
3284
3295
|
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(35);
|
|
3285
3296
|
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_8__);
|
|
3286
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(
|
|
3297
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1);
|
|
3287
3298
|
|
|
3288
3299
|
|
|
3289
3300
|
|
package/docs.md
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
component is portalled to a place in the DOM that prevents is from being clipped
|
|
3
|
-
by an overflow: auto container. This would be either as a child of `body` or the
|
|
4
|
-
modal launcher portal if the dropdown is used in a modal.
|
|
1
|
+
Documentation for `@khanacademy/wonder-blocks-dropdown` is now in Storybook.
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
For keyboard use, use space/down key to open the menu and up/down arrow keys for
|
|
10
|
-
item navigation. Space may be used for selection on option items. The tab or
|
|
11
|
-
escape key may be used to close the menu (tab would also shift focus to the next
|
|
12
|
-
element on the page).
|
|
3
|
+
Visit the [Storybook
|
|
4
|
+
Dropdown](https://khan.github.io/wonder-blocks/?path=/docs/dropdown) docs on
|
|
5
|
+
GitHub Pages.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-dropdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Dropdown variants for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,18 +16,16 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.18.6",
|
|
19
|
-
"@khanacademy/wonder-blocks-
|
|
20
|
-
"@khanacademy/wonder-blocks-clickable": "^2.3.0",
|
|
19
|
+
"@khanacademy/wonder-blocks-clickable": "^2.3.1",
|
|
21
20
|
"@khanacademy/wonder-blocks-color": "^1.2.0",
|
|
22
|
-
"@khanacademy/wonder-blocks-core": "^4.
|
|
23
|
-
"@khanacademy/wonder-blocks-icon": "^1.2.
|
|
24
|
-
"@khanacademy/wonder-blocks-
|
|
25
|
-
"@khanacademy/wonder-blocks-
|
|
26
|
-
"@khanacademy/wonder-blocks-
|
|
27
|
-
"@khanacademy/wonder-blocks-search-field": "^1.0.8",
|
|
21
|
+
"@khanacademy/wonder-blocks-core": "^4.4.0",
|
|
22
|
+
"@khanacademy/wonder-blocks-icon": "^1.2.31",
|
|
23
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.11",
|
|
24
|
+
"@khanacademy/wonder-blocks-modal": "^2.3.8",
|
|
25
|
+
"@khanacademy/wonder-blocks-search-field": "^1.0.10",
|
|
28
26
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
29
27
|
"@khanacademy/wonder-blocks-timing": "^2.1.0",
|
|
30
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
28
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.33"
|
|
31
29
|
},
|
|
32
30
|
"peerDependencies": {
|
|
33
31
|
"@popperjs/core": "^2.10.1",
|
|
@@ -40,6 +38,7 @@
|
|
|
40
38
|
"react-window": "^1.8.5"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
41
|
+
"@khanacademy/wonder-blocks-button": "^3.0.4",
|
|
43
42
|
"wb-dev-build-settings": "^0.4.0"
|
|
44
43
|
}
|
|
45
44
|
}
|
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
OptionItem,
|
|
18
18
|
SeparatorItem,
|
|
19
19
|
} from "@khanacademy/wonder-blocks-dropdown";
|
|
20
|
+
|
|
21
|
+
import type {SingleSelectLabels} from "@khanacademy/wonder-blocks-dropdown";
|
|
22
|
+
|
|
20
23
|
import ComponentInfo from "../../../../../.storybook/components/component-info.js";
|
|
21
24
|
import {name, version} from "../../../package.json";
|
|
22
25
|
import singleSelectArgtypes from "./base-select.argtypes.js";
|
|
@@ -462,3 +465,54 @@ CustomOpener.parameters = {
|
|
|
462
465
|
},
|
|
463
466
|
},
|
|
464
467
|
};
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Custom labels
|
|
471
|
+
*/
|
|
472
|
+
const translatedItems = [
|
|
473
|
+
<OptionItem label="Banano" value="banano" />,
|
|
474
|
+
<OptionItem label="Fresa" value="fresa" disabled />,
|
|
475
|
+
<OptionItem label="Pera" value="pera" />,
|
|
476
|
+
<OptionItem label="Naranja" value="naranja" />,
|
|
477
|
+
<OptionItem label="Sandia" value="sandia" />,
|
|
478
|
+
<OptionItem label="Manzana" value="manzana" />,
|
|
479
|
+
<OptionItem label="Uva" value="uva" />,
|
|
480
|
+
<OptionItem label="Limon" value="limon" />,
|
|
481
|
+
<OptionItem label="Mango" value="mango" />,
|
|
482
|
+
];
|
|
483
|
+
|
|
484
|
+
export const CustomLabels: StoryComponentType = () => {
|
|
485
|
+
const [value, setValue] = React.useState(null);
|
|
486
|
+
const [opened, setOpened] = React.useState(true);
|
|
487
|
+
|
|
488
|
+
const translatedLabels: $Shape<SingleSelectLabels> = {
|
|
489
|
+
clearSearch: "Limpiar busqueda",
|
|
490
|
+
filter: "Filtrar",
|
|
491
|
+
noResults: "Sin resultados",
|
|
492
|
+
someResults: (numResults) => `${numResults} frutas`,
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
return (
|
|
496
|
+
<View style={styles.wrapper}>
|
|
497
|
+
<SingleSelect
|
|
498
|
+
isFilterable={true}
|
|
499
|
+
onChange={setValue}
|
|
500
|
+
selectedValue={value}
|
|
501
|
+
labels={translatedLabels}
|
|
502
|
+
opened={opened}
|
|
503
|
+
onToggle={setOpened}
|
|
504
|
+
placeholder="Selecciona una fruta"
|
|
505
|
+
>
|
|
506
|
+
{translatedItems}
|
|
507
|
+
</SingleSelect>
|
|
508
|
+
</View>
|
|
509
|
+
);
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
CustomLabels.parameters = {
|
|
513
|
+
docs: {
|
|
514
|
+
description: {
|
|
515
|
+
story: "This example illustrates how you can pass custom labels to the `SingleSelect` component.",
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
};
|
|
@@ -5,6 +5,7 @@ import userEvent from "@testing-library/user-event";
|
|
|
5
5
|
|
|
6
6
|
import OptionItem from "../option-item.js";
|
|
7
7
|
import SingleSelect from "../single-select.js";
|
|
8
|
+
import type {SingleSelectLabels} from "../single-select.js";
|
|
8
9
|
|
|
9
10
|
describe("SingleSelect", () => {
|
|
10
11
|
const onChange = jest.fn();
|
|
@@ -457,6 +458,7 @@ describe("SingleSelect", () => {
|
|
|
457
458
|
// Arrange
|
|
458
459
|
render(
|
|
459
460
|
<SingleSelect
|
|
461
|
+
light={true}
|
|
460
462
|
onChange={onChange}
|
|
461
463
|
isFilterable={true}
|
|
462
464
|
placeholder="Choose"
|
|
@@ -715,4 +717,97 @@ describe("SingleSelect", () => {
|
|
|
715
717
|
expect(liveRegionText).toEqual("1 items");
|
|
716
718
|
});
|
|
717
719
|
});
|
|
720
|
+
|
|
721
|
+
describe("Custom labels", () => {
|
|
722
|
+
const translatedItems = [
|
|
723
|
+
<OptionItem label="Banano" value="banano" />,
|
|
724
|
+
<OptionItem label="Fresa" value="fresa" disabled />,
|
|
725
|
+
<OptionItem label="Pera" value="pera" />,
|
|
726
|
+
<OptionItem label="Naranja" value="naranja" />,
|
|
727
|
+
<OptionItem label="Sandia" value="sandia" />,
|
|
728
|
+
<OptionItem label="Manzana" value="manzana" />,
|
|
729
|
+
<OptionItem label="Uva" value="uva" />,
|
|
730
|
+
<OptionItem label="Limon" value="limon" />,
|
|
731
|
+
<OptionItem label="Mango" value="mango" />,
|
|
732
|
+
];
|
|
733
|
+
|
|
734
|
+
it("passes the custom label to the search input field", () => {
|
|
735
|
+
// Arrange
|
|
736
|
+
const labels: $Shape<SingleSelectLabels> = {
|
|
737
|
+
filter: "Filtrar",
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
// Act
|
|
741
|
+
render(
|
|
742
|
+
<SingleSelect
|
|
743
|
+
onChange={onChange}
|
|
744
|
+
placeholder="Escoge una fruta"
|
|
745
|
+
isFilterable={true}
|
|
746
|
+
opened={true}
|
|
747
|
+
labels={labels}
|
|
748
|
+
>
|
|
749
|
+
{translatedItems}
|
|
750
|
+
</SingleSelect>,
|
|
751
|
+
);
|
|
752
|
+
|
|
753
|
+
// Assert
|
|
754
|
+
expect(screen.getByPlaceholderText("Filtrar")).toBeInTheDocument();
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
it("passes the custom label to the dismiss filter icon", () => {
|
|
758
|
+
// Arrange
|
|
759
|
+
const labels: $Shape<SingleSelectLabels> = {
|
|
760
|
+
clearSearch: "Limpiar busqueda",
|
|
761
|
+
filter: "Filtrar",
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
render(
|
|
765
|
+
<SingleSelect
|
|
766
|
+
onChange={onChange}
|
|
767
|
+
placeholder="Escoge una fruta"
|
|
768
|
+
isFilterable={true}
|
|
769
|
+
opened={true}
|
|
770
|
+
labels={labels}
|
|
771
|
+
>
|
|
772
|
+
{translatedItems}
|
|
773
|
+
</SingleSelect>,
|
|
774
|
+
);
|
|
775
|
+
|
|
776
|
+
// Act
|
|
777
|
+
// Add text to the filter input to display the dismiss icon button.
|
|
778
|
+
userEvent.type(screen.getByPlaceholderText("Filtrar"), "m");
|
|
779
|
+
|
|
780
|
+
// Assert
|
|
781
|
+
expect(
|
|
782
|
+
screen.getByLabelText("Limpiar busqueda"),
|
|
783
|
+
).toBeInTheDocument();
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
it("passes the custom label to the no results label", () => {
|
|
787
|
+
// Arrange
|
|
788
|
+
const labels: $Shape<SingleSelectLabels> = {
|
|
789
|
+
filter: "Filtrar",
|
|
790
|
+
noResults: "No hay resultados",
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
render(
|
|
794
|
+
<SingleSelect
|
|
795
|
+
onChange={onChange}
|
|
796
|
+
placeholder="Escoge una fruta"
|
|
797
|
+
isFilterable={true}
|
|
798
|
+
opened={true}
|
|
799
|
+
labels={labels}
|
|
800
|
+
>
|
|
801
|
+
{translatedItems}
|
|
802
|
+
</SingleSelect>,
|
|
803
|
+
);
|
|
804
|
+
|
|
805
|
+
// Act
|
|
806
|
+
// Add text to the filter input with a random word.
|
|
807
|
+
userEvent.type(screen.getByPlaceholderText("Filtrar"), "invalid");
|
|
808
|
+
|
|
809
|
+
// Assert
|
|
810
|
+
expect(screen.getByText("No hay resultados")).toBeInTheDocument();
|
|
811
|
+
});
|
|
812
|
+
});
|
|
718
813
|
});
|