@khanacademy/wonder-blocks-dropdown 2.4.3 → 2.5.2
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/dist/es/index.js +15 -20
- package/dist/index.js +86 -97
- package/package.json +19 -19
- package/src/components/__tests__/action-item.test.js +10 -21
- package/src/components/__tests__/action-menu.test.js +33 -0
- package/src/components/__tests__/dropdown-core-virtualized.test.js +8 -0
- package/src/components/__tests__/dropdown-core.test.js +8 -0
- package/src/components/__tests__/multi-select.test.js +8 -0
- package/src/components/__tests__/single-select.test.js +6 -11
- package/src/components/action-item.js +10 -8
- package/src/components/action-menu-opener-core.js +0 -7
- package/src/components/action-menu.js +2 -1
- package/src/components/checkbox.js +1 -2
- package/src/components/dropdown-core.js +2 -3
- package/src/components/multi-select.stories.js +4 -6
- package/src/components/option-item.js +0 -6
- package/src/components/select-opener.js +13 -17
- package/src/components/single-select.stories.js +11 -14
package/dist/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from '@babel/runtime/helpers/extends';
|
|
|
2
2
|
import { Component, createElement, Fragment, cloneElement, Children, createRef } from 'react';
|
|
3
3
|
import { StyleSheet, css } from 'aphrodite';
|
|
4
4
|
import { Link } from 'react-router-dom';
|
|
5
|
-
import {
|
|
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
8
|
import { LabelMedium, styles as styles$a, LabelLarge } from '@khanacademy/wonder-blocks-typography';
|
|
@@ -76,7 +76,7 @@ class ActionItem extends Component {
|
|
|
76
76
|
return instance && instance.type && instance.type.__IS_ACTION_ITEM__;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
renderClickableBehavior(router) {
|
|
80
80
|
const {
|
|
81
81
|
skipClientNav,
|
|
82
82
|
disabled,
|
|
@@ -89,9 +89,6 @@ class ActionItem extends Component {
|
|
|
89
89
|
style,
|
|
90
90
|
testId
|
|
91
91
|
} = this.props;
|
|
92
|
-
const {
|
|
93
|
-
router
|
|
94
|
-
} = this.context;
|
|
95
92
|
const ClickableBehavior = getClickableBehavior(href, skipClientNav, router);
|
|
96
93
|
return /*#__PURE__*/createElement(ClickableBehavior, {
|
|
97
94
|
disabled: disabled,
|
|
@@ -136,10 +133,11 @@ class ActionItem extends Component {
|
|
|
136
133
|
});
|
|
137
134
|
}
|
|
138
135
|
|
|
136
|
+
render() {
|
|
137
|
+
return /*#__PURE__*/createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
|
|
138
|
+
}
|
|
139
|
+
|
|
139
140
|
}
|
|
140
|
-
ActionItem.contextTypes = {
|
|
141
|
-
router: any
|
|
142
|
-
};
|
|
143
141
|
ActionItem.defaultProps = {
|
|
144
142
|
disabled: false,
|
|
145
143
|
indent: false,
|
|
@@ -380,9 +378,6 @@ class OptionItem extends Component {
|
|
|
380
378
|
}
|
|
381
379
|
|
|
382
380
|
}
|
|
383
|
-
OptionItem.contextTypes = {
|
|
384
|
-
router: any
|
|
385
|
-
};
|
|
386
381
|
OptionItem.defaultProps = {
|
|
387
382
|
disabled: false,
|
|
388
383
|
onToggle: () => void 0,
|
|
@@ -1564,9 +1559,6 @@ class ActionMenuOpenerCore extends Component {
|
|
|
1564
1559
|
}
|
|
1565
1560
|
|
|
1566
1561
|
}
|
|
1567
|
-
ActionMenuOpenerCore.contextTypes = {
|
|
1568
|
-
router: any
|
|
1569
|
-
};
|
|
1570
1562
|
const sharedStyles = StyleSheet.create({
|
|
1571
1563
|
shared: {
|
|
1572
1564
|
position: "relative",
|
|
@@ -1773,10 +1765,12 @@ class ActionMenu extends Component {
|
|
|
1773
1765
|
const {
|
|
1774
1766
|
disabled,
|
|
1775
1767
|
menuText,
|
|
1776
|
-
opened,
|
|
1777
1768
|
opener,
|
|
1778
1769
|
testId
|
|
1779
1770
|
} = this.props;
|
|
1771
|
+
const {
|
|
1772
|
+
opened
|
|
1773
|
+
} = this.state;
|
|
1780
1774
|
return /*#__PURE__*/createElement(DropdownOpener, {
|
|
1781
1775
|
onClick: this.handleClick,
|
|
1782
1776
|
disabled: numItems === 0 || disabled,
|
|
@@ -1866,7 +1860,7 @@ class SelectOpener extends Component {
|
|
|
1866
1860
|
};
|
|
1867
1861
|
}
|
|
1868
1862
|
|
|
1869
|
-
|
|
1863
|
+
renderClickableBehavior(router) {
|
|
1870
1864
|
const _this$props = this.props,
|
|
1871
1865
|
{
|
|
1872
1866
|
children,
|
|
@@ -1879,7 +1873,7 @@ class SelectOpener extends Component {
|
|
|
1879
1873
|
} = _this$props,
|
|
1880
1874
|
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$4);
|
|
1881
1875
|
|
|
1882
|
-
const ClickableBehavior = getClickableBehavior(
|
|
1876
|
+
const ClickableBehavior = getClickableBehavior(router);
|
|
1883
1877
|
return /*#__PURE__*/createElement(ClickableBehavior, {
|
|
1884
1878
|
disabled: disabled,
|
|
1885
1879
|
onClick: this.handleClick
|
|
@@ -1915,10 +1909,11 @@ class SelectOpener extends Component {
|
|
|
1915
1909
|
});
|
|
1916
1910
|
}
|
|
1917
1911
|
|
|
1912
|
+
render() {
|
|
1913
|
+
return /*#__PURE__*/createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1918
1916
|
}
|
|
1919
|
-
SelectOpener.contextTypes = {
|
|
1920
|
-
router: any
|
|
1921
|
-
};
|
|
1922
1917
|
SelectOpener.defaultProps = {
|
|
1923
1918
|
disabled: false,
|
|
1924
1919
|
light: false,
|
package/dist/index.js
CHANGED
|
@@ -453,8 +453,8 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
453
453
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
454
454
|
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23);
|
|
455
455
|
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
|
|
456
|
-
/* harmony import */ var
|
|
457
|
-
/* harmony import */ var
|
|
456
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16);
|
|
457
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_3__);
|
|
458
458
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
|
|
459
459
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_4__);
|
|
460
460
|
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3);
|
|
@@ -498,7 +498,7 @@ class ActionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
498
498
|
return instance && instance.type && instance.type.__IS_ACTION_ITEM__;
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
-
|
|
501
|
+
renderClickableBehavior(router) {
|
|
502
502
|
const {
|
|
503
503
|
skipClientNav,
|
|
504
504
|
disabled,
|
|
@@ -511,9 +511,6 @@ class ActionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
511
511
|
style,
|
|
512
512
|
testId
|
|
513
513
|
} = this.props;
|
|
514
|
-
const {
|
|
515
|
-
router
|
|
516
|
-
} = this.context;
|
|
517
514
|
const ClickableBehavior = Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_7__["getClickableBehavior"])(href, skipClientNav, router);
|
|
518
515
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ClickableBehavior, {
|
|
519
516
|
disabled: disabled,
|
|
@@ -557,10 +554,11 @@ class ActionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
557
554
|
});
|
|
558
555
|
}
|
|
559
556
|
|
|
557
|
+
render() {
|
|
558
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router__WEBPACK_IMPORTED_MODULE_3__["__RouterContext"].Consumer, null, router => this.renderClickableBehavior(router));
|
|
559
|
+
}
|
|
560
|
+
|
|
560
561
|
}
|
|
561
|
-
ActionItem.contextTypes = {
|
|
562
|
-
router: prop_types__WEBPACK_IMPORTED_MODULE_3__["any"]
|
|
563
|
-
};
|
|
564
562
|
ActionItem.defaultProps = {
|
|
565
563
|
disabled: false,
|
|
566
564
|
indent: false,
|
|
@@ -611,12 +609,6 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
611
609
|
|
|
612
610
|
/***/ }),
|
|
613
611
|
/* 13 */
|
|
614
|
-
/***/ (function(module, exports) {
|
|
615
|
-
|
|
616
|
-
module.exports = require("prop-types");
|
|
617
|
-
|
|
618
|
-
/***/ }),
|
|
619
|
-
/* 14 */
|
|
620
612
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
621
613
|
|
|
622
614
|
"use strict";
|
|
@@ -625,21 +617,19 @@ module.exports = require("prop-types");
|
|
|
625
617
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
626
618
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
627
619
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
628
|
-
/* harmony import */ var
|
|
629
|
-
/* harmony import */ var
|
|
630
|
-
/* harmony import */ var
|
|
631
|
-
/* harmony import */ var
|
|
632
|
-
/* harmony import */ var
|
|
633
|
-
/* harmony import */ var
|
|
634
|
-
/* harmony import */ var
|
|
635
|
-
/* harmony import */ var
|
|
636
|
-
/* harmony import */ var
|
|
637
|
-
/* harmony import */ var
|
|
638
|
-
/* harmony import */ var
|
|
639
|
-
/* harmony import */ var
|
|
640
|
-
/* harmony import */ var
|
|
641
|
-
/* harmony import */ var _check_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(24);
|
|
642
|
-
/* harmony import */ var _checkbox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(25);
|
|
620
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
|
|
621
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
622
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
|
|
623
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3__);
|
|
624
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
|
|
625
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__);
|
|
626
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
|
|
627
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__);
|
|
628
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(10);
|
|
629
|
+
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_6__);
|
|
630
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2);
|
|
631
|
+
/* harmony import */ var _check_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(24);
|
|
632
|
+
/* harmony import */ var _checkbox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(25);
|
|
643
633
|
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); }
|
|
644
634
|
|
|
645
635
|
|
|
@@ -653,7 +643,6 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
653
643
|
|
|
654
644
|
|
|
655
645
|
|
|
656
|
-
|
|
657
646
|
/**
|
|
658
647
|
* For option items that can be selected in a dropdown, selection denoted either
|
|
659
648
|
* with a check ✔️ or a checkbox ☑️. Use as children in SingleSelect or
|
|
@@ -683,9 +672,9 @@ class OptionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
683
672
|
|
|
684
673
|
getCheckComponent() {
|
|
685
674
|
if (this.props.variant === "check") {
|
|
686
|
-
return
|
|
675
|
+
return _check_js__WEBPACK_IMPORTED_MODULE_8__[/* default */ "a"];
|
|
687
676
|
} else {
|
|
688
|
-
return
|
|
677
|
+
return _checkbox_js__WEBPACK_IMPORTED_MODULE_9__[/* default */ "a"];
|
|
689
678
|
}
|
|
690
679
|
}
|
|
691
680
|
|
|
@@ -708,7 +697,7 @@ class OptionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
708
697
|
/* eslint-enable no-unused-vars */
|
|
709
698
|
...sharedProps
|
|
710
699
|
} = this.props;
|
|
711
|
-
const ClickableBehavior = Object(
|
|
700
|
+
const ClickableBehavior = Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_6__["getClickableBehavior"])();
|
|
712
701
|
const CheckComponent = this.getCheckComponent();
|
|
713
702
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ClickableBehavior, {
|
|
714
703
|
disabled: disabled,
|
|
@@ -722,7 +711,7 @@ class OptionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
722
711
|
} = state;
|
|
723
712
|
const defaultStyle = [styles.itemContainer, pressed ? styles.active : (hovered || focused) && styles.focus, disabled && styles.disabled, // pass optional styles from react-window (if applies)
|
|
724
713
|
style];
|
|
725
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](
|
|
714
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__["View"], _extends({}, sharedProps, {
|
|
726
715
|
testId: testId,
|
|
727
716
|
style: defaultStyle,
|
|
728
717
|
"aria-selected": selected ? "true" : "false",
|
|
@@ -733,16 +722,13 @@ class OptionItem extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
733
722
|
pressed: pressed,
|
|
734
723
|
hovered: hovered,
|
|
735
724
|
focused: focused
|
|
736
|
-
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](
|
|
725
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelMedium"], {
|
|
737
726
|
style: styles.label
|
|
738
727
|
}, label));
|
|
739
728
|
});
|
|
740
729
|
}
|
|
741
730
|
|
|
742
731
|
}
|
|
743
|
-
OptionItem.contextTypes = {
|
|
744
|
-
router: prop_types__WEBPACK_IMPORTED_MODULE_2__["any"]
|
|
745
|
-
};
|
|
746
732
|
OptionItem.defaultProps = {
|
|
747
733
|
disabled: false,
|
|
748
734
|
onToggle: () => void 0,
|
|
@@ -755,19 +741,19 @@ const {
|
|
|
755
741
|
white,
|
|
756
742
|
offBlack,
|
|
757
743
|
offBlack32
|
|
758
|
-
} =
|
|
744
|
+
} = _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a;
|
|
759
745
|
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
760
746
|
itemContainer: {
|
|
761
747
|
flexDirection: "row",
|
|
762
748
|
backgroundColor: white,
|
|
763
749
|
color: offBlack,
|
|
764
750
|
alignItems: "center",
|
|
765
|
-
height:
|
|
766
|
-
minHeight:
|
|
751
|
+
height: _util_constants_js__WEBPACK_IMPORTED_MODULE_7__[/* DROPDOWN_ITEM_HEIGHT */ "a"],
|
|
752
|
+
minHeight: _util_constants_js__WEBPACK_IMPORTED_MODULE_7__[/* DROPDOWN_ITEM_HEIGHT */ "a"],
|
|
767
753
|
border: 0,
|
|
768
754
|
outline: 0,
|
|
769
|
-
paddingLeft:
|
|
770
|
-
paddingRight:
|
|
755
|
+
paddingLeft: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default.a.xSmall_8,
|
|
756
|
+
paddingRight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default.a.medium_16,
|
|
771
757
|
whiteSpace: "nowrap",
|
|
772
758
|
cursor: "default"
|
|
773
759
|
},
|
|
@@ -776,8 +762,8 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
776
762
|
background: blue
|
|
777
763
|
},
|
|
778
764
|
active: {
|
|
779
|
-
color: Object(
|
|
780
|
-
background: Object(
|
|
765
|
+
color: Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["fade"])(blue, 0.32), white),
|
|
766
|
+
background: Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__["mix"])(offBlack32, blue)
|
|
781
767
|
},
|
|
782
768
|
disabled: {
|
|
783
769
|
color: offBlack32,
|
|
@@ -786,7 +772,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
786
772
|
label: {
|
|
787
773
|
whiteSpace: "nowrap",
|
|
788
774
|
userSelect: "none",
|
|
789
|
-
marginLeft:
|
|
775
|
+
marginLeft: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_3___default.a.xSmall_8,
|
|
790
776
|
// added to truncate strings that are longer than expected
|
|
791
777
|
overflow: "hidden",
|
|
792
778
|
textOverflow: "ellipsis"
|
|
@@ -797,7 +783,7 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
|
797
783
|
});
|
|
798
784
|
|
|
799
785
|
/***/ }),
|
|
800
|
-
/*
|
|
786
|
+
/* 14 */
|
|
801
787
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
802
788
|
|
|
803
789
|
"use strict";
|
|
@@ -858,7 +844,7 @@ DropdownOpener.defaultProps = {
|
|
|
858
844
|
/* harmony default export */ __webpack_exports__["a"] = (DropdownOpener);
|
|
859
845
|
|
|
860
846
|
/***/ }),
|
|
861
|
-
/*
|
|
847
|
+
/* 15 */
|
|
862
848
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
863
849
|
|
|
864
850
|
"use strict";
|
|
@@ -1506,6 +1492,12 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_3__["StyleSheet"].create({
|
|
|
1506
1492
|
});
|
|
1507
1493
|
/* harmony default export */ __webpack_exports__["a"] = (Object(_khanacademy_wonder_blocks_timing__WEBPACK_IMPORTED_MODULE_10__["withActionScheduler"])(DropdownCore));
|
|
1508
1494
|
|
|
1495
|
+
/***/ }),
|
|
1496
|
+
/* 16 */
|
|
1497
|
+
/***/ (function(module, exports) {
|
|
1498
|
+
|
|
1499
|
+
module.exports = require("react-router");
|
|
1500
|
+
|
|
1509
1501
|
/***/ }),
|
|
1510
1502
|
/* 17 */
|
|
1511
1503
|
/***/ (function(module, exports) {
|
|
@@ -1522,8 +1514,8 @@ module.exports = require("@khanacademy/wonder-blocks-timing");
|
|
|
1522
1514
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1523
1515
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
1524
1516
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
1525
|
-
/* harmony import */ var
|
|
1526
|
-
/* harmony import */ var
|
|
1517
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
|
|
1518
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_2__);
|
|
1527
1519
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
|
|
1528
1520
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__);
|
|
1529
1521
|
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
|
|
@@ -1575,7 +1567,7 @@ class SelectOpener extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1575
1567
|
};
|
|
1576
1568
|
}
|
|
1577
1569
|
|
|
1578
|
-
|
|
1570
|
+
renderClickableBehavior(router) {
|
|
1579
1571
|
const {
|
|
1580
1572
|
children,
|
|
1581
1573
|
disabled,
|
|
@@ -1588,7 +1580,7 @@ class SelectOpener extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1588
1580
|
onOpenChanged,
|
|
1589
1581
|
...sharedProps
|
|
1590
1582
|
} = this.props;
|
|
1591
|
-
const ClickableBehavior = Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5__["getClickableBehavior"])(
|
|
1583
|
+
const ClickableBehavior = Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_5__["getClickableBehavior"])(router);
|
|
1592
1584
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ClickableBehavior, {
|
|
1593
1585
|
disabled: disabled,
|
|
1594
1586
|
onClick: this.handleClick
|
|
@@ -1624,10 +1616,11 @@ class SelectOpener extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1624
1616
|
});
|
|
1625
1617
|
}
|
|
1626
1618
|
|
|
1619
|
+
render() {
|
|
1620
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router__WEBPACK_IMPORTED_MODULE_2__["__RouterContext"].Consumer, null, router => this.renderClickableBehavior(router));
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1627
1623
|
}
|
|
1628
|
-
SelectOpener.contextTypes = {
|
|
1629
|
-
router: prop_types__WEBPACK_IMPORTED_MODULE_2__["any"]
|
|
1630
|
-
};
|
|
1631
1624
|
SelectOpener.defaultProps = {
|
|
1632
1625
|
disabled: false,
|
|
1633
1626
|
light: false,
|
|
@@ -1767,10 +1760,10 @@ module.exports = require("react-window");
|
|
|
1767
1760
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
1768
1761
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
1769
1762
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
1770
|
-
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
1763
|
+
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
|
|
1771
1764
|
/* harmony import */ var _action_item_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12);
|
|
1772
|
-
/* harmony import */ var _option_item_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
1773
|
-
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
1765
|
+
/* harmony import */ var _option_item_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(13);
|
|
1766
|
+
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(15);
|
|
1774
1767
|
/* harmony import */ var _action_menu_opener_core_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(31);
|
|
1775
1768
|
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); }
|
|
1776
1769
|
|
|
@@ -1898,10 +1891,12 @@ class ActionMenu extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
1898
1891
|
const {
|
|
1899
1892
|
disabled,
|
|
1900
1893
|
menuText,
|
|
1901
|
-
opened,
|
|
1902
1894
|
opener,
|
|
1903
1895
|
testId
|
|
1904
1896
|
} = this.props;
|
|
1897
|
+
const {
|
|
1898
|
+
opened
|
|
1899
|
+
} = this.state;
|
|
1905
1900
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_dropdown_opener_js__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"], {
|
|
1906
1901
|
onClick: this.handleClick,
|
|
1907
1902
|
disabled: numItems === 0 || disabled,
|
|
@@ -1977,8 +1972,8 @@ const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
|
1977
1972
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1978
1973
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
|
|
1979
1974
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
1980
|
-
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
1981
|
-
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
1975
|
+
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(15);
|
|
1976
|
+
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
|
|
1982
1977
|
/* harmony import */ var _select_opener_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(18);
|
|
1983
1978
|
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2);
|
|
1984
1979
|
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(11);
|
|
@@ -2254,8 +2249,8 @@ SingleSelect.defaultProps = {
|
|
|
2254
2249
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
|
|
2255
2250
|
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
2256
2251
|
/* harmony import */ var _action_item_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12);
|
|
2257
|
-
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
2258
|
-
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
2252
|
+
/* harmony import */ var _dropdown_core_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
|
|
2253
|
+
/* harmony import */ var _dropdown_opener_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(14);
|
|
2259
2254
|
/* harmony import */ var _search_text_input_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(11);
|
|
2260
2255
|
/* harmony import */ var _select_opener_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(18);
|
|
2261
2256
|
/* harmony import */ var _separator_item_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(8);
|
|
@@ -3112,21 +3107,19 @@ module.exports = require("@khanacademy/wonder-blocks-icon-button");
|
|
|
3112
3107
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
3113
3108
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
|
|
3114
3109
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
3115
|
-
/* harmony import */ var
|
|
3116
|
-
/* harmony import */ var
|
|
3117
|
-
/* harmony import */ var
|
|
3118
|
-
/* harmony import */ var
|
|
3119
|
-
/* harmony import */ var
|
|
3120
|
-
/* harmony import */ var
|
|
3121
|
-
/* harmony import */ var
|
|
3122
|
-
/* harmony import */ var
|
|
3123
|
-
/* harmony import */ var
|
|
3124
|
-
/* harmony import */ var
|
|
3125
|
-
/* harmony import */ var
|
|
3126
|
-
/* harmony import */ var
|
|
3127
|
-
/* harmony import */ var
|
|
3128
|
-
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_8__);
|
|
3129
|
-
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(2);
|
|
3110
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
|
|
3111
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2__);
|
|
3112
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
|
|
3113
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__);
|
|
3114
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
|
|
3115
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
3116
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6);
|
|
3117
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__);
|
|
3118
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
|
|
3119
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6__);
|
|
3120
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(32);
|
|
3121
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_7__);
|
|
3122
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2);
|
|
3130
3123
|
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); }
|
|
3131
3124
|
|
|
3132
3125
|
|
|
@@ -3138,8 +3131,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3138
3131
|
|
|
3139
3132
|
|
|
3140
3133
|
|
|
3141
|
-
|
|
3142
|
-
const StyledButton = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_5__["addStyle"])("button");
|
|
3134
|
+
const StyledButton = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__["addStyle"])("button");
|
|
3143
3135
|
/**
|
|
3144
3136
|
* Although this component shares a lot with ButtonCore there are a couple
|
|
3145
3137
|
* of differences:
|
|
@@ -3161,13 +3153,13 @@ class ActionMenuOpenerCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component
|
|
|
3161
3153
|
"aria-label": ariaLabel,
|
|
3162
3154
|
...restProps
|
|
3163
3155
|
} = this.props;
|
|
3164
|
-
const buttonColor =
|
|
3156
|
+
const buttonColor = _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__["SemanticColor"].controlDefault;
|
|
3165
3157
|
|
|
3166
3158
|
const buttonStyles = _generateStyles(buttonColor);
|
|
3167
3159
|
|
|
3168
3160
|
const disabled = disabledProp;
|
|
3169
3161
|
const defaultStyle = [sharedStyles.shared, disabled && sharedStyles.disabled, buttonStyles.default, disabled && buttonStyles.disabled, !disabled && pressed && buttonStyles.active];
|
|
3170
|
-
const label = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](
|
|
3162
|
+
const label = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_2__["LabelLarge"], {
|
|
3171
3163
|
style: sharedStyles.text
|
|
3172
3164
|
}, children);
|
|
3173
3165
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledButton, _extends({
|
|
@@ -3179,30 +3171,27 @@ class ActionMenuOpenerCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component
|
|
|
3179
3171
|
type: "button"
|
|
3180
3172
|
}, restProps, {
|
|
3181
3173
|
"data-test-id": testId
|
|
3182
|
-
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](
|
|
3174
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__["View"], {
|
|
3183
3175
|
style: !disabled && (hovered || focused) && buttonStyles.focus
|
|
3184
|
-
}, label), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](
|
|
3185
|
-
size:
|
|
3186
|
-
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](
|
|
3176
|
+
}, label), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_7__["Strut"], {
|
|
3177
|
+
size: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xxxSmall_4
|
|
3178
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5___default.a, {
|
|
3187
3179
|
size: "small",
|
|
3188
3180
|
color: "currentColor",
|
|
3189
|
-
icon:
|
|
3181
|
+
icon: _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_5__["icons"].caretDown
|
|
3190
3182
|
}));
|
|
3191
3183
|
}
|
|
3192
3184
|
|
|
3193
3185
|
}
|
|
3194
|
-
ActionMenuOpenerCore.contextTypes = {
|
|
3195
|
-
router: prop_types__WEBPACK_IMPORTED_MODULE_2__["any"]
|
|
3196
|
-
};
|
|
3197
3186
|
const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
3198
3187
|
shared: {
|
|
3199
3188
|
position: "relative",
|
|
3200
3189
|
display: "inline-flex",
|
|
3201
3190
|
alignItems: "center",
|
|
3202
3191
|
justifyContent: "center",
|
|
3203
|
-
height:
|
|
3192
|
+
height: _util_constants_js__WEBPACK_IMPORTED_MODULE_8__[/* DROPDOWN_ITEM_HEIGHT */ "a"],
|
|
3204
3193
|
border: "none",
|
|
3205
|
-
borderRadius:
|
|
3194
|
+
borderRadius: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xxxSmall_4,
|
|
3206
3195
|
cursor: "pointer",
|
|
3207
3196
|
outline: "none",
|
|
3208
3197
|
textDecoration: "none",
|
|
@@ -3219,7 +3208,7 @@ const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create
|
|
|
3219
3208
|
cursor: "auto"
|
|
3220
3209
|
},
|
|
3221
3210
|
small: {
|
|
3222
|
-
height:
|
|
3211
|
+
height: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_6___default.a.xLarge_32
|
|
3223
3212
|
},
|
|
3224
3213
|
text: {
|
|
3225
3214
|
textAlign: "left",
|
|
@@ -3251,8 +3240,8 @@ const _generateStyles = color => {
|
|
|
3251
3240
|
|
|
3252
3241
|
const {
|
|
3253
3242
|
offBlack32
|
|
3254
|
-
} =
|
|
3255
|
-
const activeColor = Object(
|
|
3243
|
+
} = _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default.a;
|
|
3244
|
+
const activeColor = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__["mix"])(offBlack32, color);
|
|
3256
3245
|
let newStyles = {};
|
|
3257
3246
|
newStyles = {
|
|
3258
3247
|
default: {
|
|
@@ -3298,7 +3287,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3298
3287
|
/* harmony import */ var _components_action_item_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
|
|
3299
3288
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionItem", function() { return _components_action_item_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
|
|
3300
3289
|
|
|
3301
|
-
/* harmony import */ var _components_option_item_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
3290
|
+
/* harmony import */ var _components_option_item_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(13);
|
|
3302
3291
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OptionItem", function() { return _components_option_item_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
|
|
3303
3292
|
|
|
3304
3293
|
/* harmony import */ var _components_separator_item_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-dropdown",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Dropdown variants for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,31 +15,31 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@babel/runtime": "^7.
|
|
19
|
-
"@khanacademy/wonder-blocks-button": "^2.
|
|
20
|
-
"@khanacademy/wonder-blocks-clickable": "^2.1
|
|
21
|
-
"@khanacademy/wonder-blocks-color": "^1.1.
|
|
22
|
-
"@khanacademy/wonder-blocks-core": "^
|
|
23
|
-
"@khanacademy/wonder-blocks-icon": "^1.2.
|
|
24
|
-
"@khanacademy/wonder-blocks-icon-button": "^3.
|
|
25
|
-
"@khanacademy/wonder-blocks-layout": "^1.4.
|
|
26
|
-
"@khanacademy/wonder-blocks-modal": "^2.1.
|
|
27
|
-
"@khanacademy/wonder-blocks-spacing": "^3.0.
|
|
28
|
-
"@khanacademy/wonder-blocks-timing": "^2.0.
|
|
29
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
18
|
+
"@babel/runtime": "^7.16.3",
|
|
19
|
+
"@khanacademy/wonder-blocks-button": "^2.10.2",
|
|
20
|
+
"@khanacademy/wonder-blocks-clickable": "^2.2.1",
|
|
21
|
+
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
22
|
+
"@khanacademy/wonder-blocks-core": "^4.0.0",
|
|
23
|
+
"@khanacademy/wonder-blocks-icon": "^1.2.24",
|
|
24
|
+
"@khanacademy/wonder-blocks-icon-button": "^3.4.1",
|
|
25
|
+
"@khanacademy/wonder-blocks-layout": "^1.4.6",
|
|
26
|
+
"@khanacademy/wonder-blocks-modal": "^2.1.45",
|
|
27
|
+
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
28
|
+
"@khanacademy/wonder-blocks-timing": "^2.0.3",
|
|
29
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.28"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@popperjs/core": "^2.10.1",
|
|
33
33
|
"aphrodite": "^1.2.5",
|
|
34
|
-
"
|
|
35
|
-
"react": "
|
|
36
|
-
"react-dom": "^16.4.1",
|
|
34
|
+
"react": "16.14.0",
|
|
35
|
+
"react-dom": "16.14.0",
|
|
37
36
|
"react-popper": "^2.0.0",
|
|
38
|
-
"react-router
|
|
37
|
+
"react-router": "5.2.1",
|
|
38
|
+
"react-router-dom": "5.3.0",
|
|
39
39
|
"react-window": "^1.8.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"wb-dev-build-settings": "^0.
|
|
42
|
+
"wb-dev-build-settings": "^0.2.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "9ebea88533e702011165072f090a377e02fa3f0f"
|
|
45
45
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import renderer from "react-test-renderer";
|
|
3
|
-
import {Link} from "react-router-dom";
|
|
4
|
-
import {
|
|
5
|
-
import ReactRouterEnzymeContext from "react-router-enzyme-context";
|
|
3
|
+
import {MemoryRouter, Link} from "react-router-dom";
|
|
4
|
+
import {mount} from "enzyme";
|
|
6
5
|
|
|
7
6
|
import ActionItem from "../action-item.js";
|
|
8
7
|
|
|
@@ -16,28 +15,18 @@ describe("ActionItem", () => {
|
|
|
16
15
|
});
|
|
17
16
|
|
|
18
17
|
it("should render an anchor if there's no router", () => {
|
|
19
|
-
const wrapper =
|
|
18
|
+
const wrapper = mount(<ActionItem href="/foo" />);
|
|
20
19
|
|
|
21
|
-
expect(
|
|
22
|
-
wrapper
|
|
23
|
-
// call the props.children(state, handlers) with empty objects for both params
|
|
24
|
-
.renderProp("children")({}, {})
|
|
25
|
-
// shallow render the first child of that result to unwrap StyledAnchor HOC
|
|
26
|
-
.first()
|
|
27
|
-
.shallow()
|
|
28
|
-
// check that it includes an <a> tag
|
|
29
|
-
.find("a"),
|
|
30
|
-
).toHaveLength(1);
|
|
20
|
+
expect(wrapper.find("a")).toHaveLength(1);
|
|
31
21
|
});
|
|
32
22
|
|
|
33
23
|
it("should render a Link if there's a router", () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
const wrapper = mount(
|
|
25
|
+
<MemoryRouter>
|
|
26
|
+
<ActionItem href="/foo" />
|
|
27
|
+
</MemoryRouter>,
|
|
28
|
+
);
|
|
38
29
|
|
|
39
|
-
expect(
|
|
40
|
-
wrapper.renderProp("children")({}, {}).first().shallow().find(Link),
|
|
41
|
-
).toHaveLength(1);
|
|
30
|
+
expect(wrapper.find(Link)).toHaveLength(1);
|
|
42
31
|
});
|
|
43
32
|
});
|
|
@@ -8,6 +8,7 @@ import SeparatorItem from "../separator-item.js";
|
|
|
8
8
|
import ActionMenu from "../action-menu.js";
|
|
9
9
|
import DropdownOpener from "../dropdown-opener.js";
|
|
10
10
|
import {keyCodes} from "../../util/constants.js";
|
|
11
|
+
import ActionMenuOpenerCore from "../action-menu-opener-core.js";
|
|
11
12
|
|
|
12
13
|
jest.mock("../dropdown-core-virtualized.js");
|
|
13
14
|
|
|
@@ -143,6 +144,38 @@ describe("ActionMenu", () => {
|
|
|
143
144
|
expect(menu.state("opened")).toBe(false);
|
|
144
145
|
});
|
|
145
146
|
|
|
147
|
+
it("updates the aria-expanded value when opening and closing", () => {
|
|
148
|
+
// Arrange
|
|
149
|
+
const menu = mount(
|
|
150
|
+
<ActionMenu
|
|
151
|
+
menuText={"Action menu!"}
|
|
152
|
+
testId="openTest"
|
|
153
|
+
onChange={onChange}
|
|
154
|
+
selectedValues={[]}
|
|
155
|
+
>
|
|
156
|
+
<ActionItem label="Action" onClick={onClick} />
|
|
157
|
+
<SeparatorItem />
|
|
158
|
+
<OptionItem label="Toggle" value="toggle" onClick={onToggle} />
|
|
159
|
+
</ActionMenu>,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
let opener = menu.find(DropdownOpener);
|
|
163
|
+
let openerCore = menu.find(ActionMenuOpenerCore);
|
|
164
|
+
expect(openerCore.prop("opened")).toBe(false);
|
|
165
|
+
expect(opener.find("[aria-expanded='false']")).toExist();
|
|
166
|
+
|
|
167
|
+
// Act
|
|
168
|
+
opener.simulate("keydown", {keyCode: keyCodes.enter});
|
|
169
|
+
opener.simulate("keyup", {keyCode: keyCodes.enter});
|
|
170
|
+
menu.update();
|
|
171
|
+
openerCore = menu.find(ActionMenuOpenerCore);
|
|
172
|
+
opener = menu.find(DropdownOpener);
|
|
173
|
+
|
|
174
|
+
// Assert
|
|
175
|
+
expect(openerCore.prop("opened")).toBe(true);
|
|
176
|
+
expect(opener.find("[aria-expanded='true']")).toExist();
|
|
177
|
+
});
|
|
178
|
+
|
|
146
179
|
it("triggers actions", () => {
|
|
147
180
|
// Arrange
|
|
148
181
|
const onChange = jest.fn();
|
|
@@ -8,6 +8,8 @@ import SeparatorItem from "../separator-item.js";
|
|
|
8
8
|
import DropdownCoreVirtualized from "../dropdown-core-virtualized.js";
|
|
9
9
|
import SearchTextInput from "../search-text-input.js";
|
|
10
10
|
|
|
11
|
+
import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
|
|
12
|
+
|
|
11
13
|
describe("DropdownCoreVirtualized", () => {
|
|
12
14
|
beforeEach(() => {
|
|
13
15
|
jest.useFakeTimers();
|
|
@@ -24,6 +26,12 @@ describe("DropdownCoreVirtualized", () => {
|
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
afterEach(() => {
|
|
29
|
+
// We have to explicitly unmount before clearing mocks, otherwise jest
|
|
30
|
+
// timers will throw because we'll try to clear an animation frame that
|
|
31
|
+
// we set with a setTimeout but are clearing with clearAnimationFrame
|
|
32
|
+
// because we restored the clearAnimationFrame mock (and we won't
|
|
33
|
+
// have cleared the timeout we actually set!)
|
|
34
|
+
unmountAll();
|
|
27
35
|
jest.restoreAllMocks();
|
|
28
36
|
});
|
|
29
37
|
|
|
@@ -8,6 +8,8 @@ import SearchTextInput from "../search-text-input.js";
|
|
|
8
8
|
import DropdownCore from "../dropdown-core.js";
|
|
9
9
|
import {keyCodes} from "../../util/constants.js";
|
|
10
10
|
|
|
11
|
+
import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
|
|
12
|
+
|
|
11
13
|
jest.mock("../dropdown-core-virtualized.js");
|
|
12
14
|
|
|
13
15
|
const elementAtIndex = (wrapper, index) =>
|
|
@@ -87,6 +89,12 @@ describe("DropdownCore", () => {
|
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
afterEach(() => {
|
|
92
|
+
// We have to explicitly unmount before clearing mocks, otherwise jest
|
|
93
|
+
// timers will throw because we'll try to clear an animation frame that
|
|
94
|
+
// we set with a setTimeout but are clearing with clearAnimationFrame
|
|
95
|
+
// because we restored the clearAnimationFrame mock (and we won't
|
|
96
|
+
// have cleared the timeout we actually set!)
|
|
97
|
+
unmountAll();
|
|
90
98
|
jest.restoreAllMocks();
|
|
91
99
|
});
|
|
92
100
|
|
|
@@ -14,6 +14,8 @@ import MultiSelect from "../multi-select.js";
|
|
|
14
14
|
import {keyCodes} from "../../util/constants.js";
|
|
15
15
|
import SearchTextInput from "../search-text-input.js";
|
|
16
16
|
|
|
17
|
+
import {unmountAll} from "../../../../../utils/testing/enzyme-shim.js";
|
|
18
|
+
|
|
17
19
|
import type {Labels} from "../multi-select.js";
|
|
18
20
|
|
|
19
21
|
jest.useFakeTimers();
|
|
@@ -68,6 +70,12 @@ describe("MultiSelect", () => {
|
|
|
68
70
|
});
|
|
69
71
|
|
|
70
72
|
afterEach(() => {
|
|
73
|
+
// We have to explicitly unmount before clearing mocks, otherwise jest
|
|
74
|
+
// timers will throw because we'll try to clear an animation frame that
|
|
75
|
+
// we set with a setTimeout but are clearing with clearAnimationFrame
|
|
76
|
+
// because we restored the clearAnimationFrame mock (and we won't
|
|
77
|
+
// have cleared the timeout we actually set!)
|
|
78
|
+
unmountAll();
|
|
71
79
|
jest.restoreAllMocks();
|
|
72
80
|
});
|
|
73
81
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
//@flow
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {render, screen} from "@testing-library/react";
|
|
4
|
-
// eslint-disable-next-line import/no-unassigned-import
|
|
5
|
-
import "@testing-library/jest-dom/extend-expect";
|
|
6
4
|
|
|
7
5
|
import OptionItem from "../option-item.js";
|
|
8
6
|
import SingleSelect from "../single-select.js";
|
|
@@ -25,8 +23,7 @@ describe("SingleSelect", () => {
|
|
|
25
23
|
afterEach(() => {
|
|
26
24
|
window.scrollTo.mockClear();
|
|
27
25
|
onChange.mockReset();
|
|
28
|
-
|
|
29
|
-
console.error.mockReset(); // eslint-disable-line no-console
|
|
26
|
+
jest.spyOn(console, "error").mockReset();
|
|
30
27
|
});
|
|
31
28
|
|
|
32
29
|
afterEach(() => {
|
|
@@ -52,7 +49,7 @@ describe("SingleSelect", () => {
|
|
|
52
49
|
userEvent.click(opener);
|
|
53
50
|
|
|
54
51
|
// Assert
|
|
55
|
-
expect(screen.
|
|
52
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
56
53
|
});
|
|
57
54
|
|
|
58
55
|
it("should focus the first item in the dropdown", () => {
|
|
@@ -121,9 +118,7 @@ describe("SingleSelect", () => {
|
|
|
121
118
|
userEvent.keyboard(key);
|
|
122
119
|
|
|
123
120
|
// Assert
|
|
124
|
-
expect(
|
|
125
|
-
screen.queryByRole("listbox"),
|
|
126
|
-
).toBeInTheDocument();
|
|
121
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
127
122
|
});
|
|
128
123
|
|
|
129
124
|
it("should focus the first item in the dropdown", () => {
|
|
@@ -152,7 +147,7 @@ describe("SingleSelect", () => {
|
|
|
152
147
|
|
|
153
148
|
// Assert
|
|
154
149
|
expect(onChange).not.toHaveBeenCalled();
|
|
155
|
-
expect(screen.
|
|
150
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
156
151
|
});
|
|
157
152
|
|
|
158
153
|
it("should select an item when pressing {space}", () => {
|
|
@@ -278,7 +273,7 @@ describe("SingleSelect", () => {
|
|
|
278
273
|
userEvent.click(screen.getByText("Choose"));
|
|
279
274
|
|
|
280
275
|
// Assert
|
|
281
|
-
expect(screen.
|
|
276
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
282
277
|
});
|
|
283
278
|
|
|
284
279
|
it("closes the menu when the anchor is clicked", () => {
|
|
@@ -321,7 +316,7 @@ describe("SingleSelect", () => {
|
|
|
321
316
|
userEvent.click(opener);
|
|
322
317
|
|
|
323
318
|
// Assert
|
|
324
|
-
expect(screen.
|
|
319
|
+
expect(screen.getByRole("listbox")).toBeInTheDocument();
|
|
325
320
|
});
|
|
326
321
|
|
|
327
322
|
it("calls the custom onClick handler", () => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import {StyleSheet} from "aphrodite";
|
|
5
5
|
import {Link} from "react-router-dom";
|
|
6
|
-
import
|
|
6
|
+
import {__RouterContext} from "react-router";
|
|
7
7
|
|
|
8
8
|
import Color, {mix, fade} from "@khanacademy/wonder-blocks-color";
|
|
9
9
|
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
@@ -103,10 +103,6 @@ type DefaultProps = {|
|
|
|
103
103
|
role: $PropertyType<ActionProps, "role">,
|
|
104
104
|
|};
|
|
105
105
|
|
|
106
|
-
type ContextTypes = {|
|
|
107
|
-
router: $FlowFixMe,
|
|
108
|
-
|};
|
|
109
|
-
|
|
110
106
|
const StyledAnchor = addStyle("a");
|
|
111
107
|
const StyledButton = addStyle("button");
|
|
112
108
|
const StyledLink = addStyle(Link);
|
|
@@ -120,7 +116,6 @@ export default class ActionItem extends React.Component<ActionProps> {
|
|
|
120
116
|
static isClassOf(instance: React.Element<any>): boolean {
|
|
121
117
|
return instance && instance.type && instance.type.__IS_ACTION_ITEM__;
|
|
122
118
|
}
|
|
123
|
-
static contextTypes: ContextTypes = {router: PropTypes.any};
|
|
124
119
|
static defaultProps: DefaultProps = {
|
|
125
120
|
disabled: false,
|
|
126
121
|
indent: false,
|
|
@@ -128,7 +123,7 @@ export default class ActionItem extends React.Component<ActionProps> {
|
|
|
128
123
|
};
|
|
129
124
|
static __IS_ACTION_ITEM__: boolean = true;
|
|
130
125
|
|
|
131
|
-
|
|
126
|
+
renderClickableBehavior(router: any): React.Node {
|
|
132
127
|
const {
|
|
133
128
|
skipClientNav,
|
|
134
129
|
disabled,
|
|
@@ -141,7 +136,6 @@ export default class ActionItem extends React.Component<ActionProps> {
|
|
|
141
136
|
style,
|
|
142
137
|
testId,
|
|
143
138
|
} = this.props;
|
|
144
|
-
const {router} = this.context;
|
|
145
139
|
|
|
146
140
|
const ClickableBehavior = getClickableBehavior(
|
|
147
141
|
href,
|
|
@@ -220,6 +214,14 @@ export default class ActionItem extends React.Component<ActionProps> {
|
|
|
220
214
|
</ClickableBehavior>
|
|
221
215
|
);
|
|
222
216
|
}
|
|
217
|
+
|
|
218
|
+
render(): React.Node {
|
|
219
|
+
return (
|
|
220
|
+
<__RouterContext.Consumer>
|
|
221
|
+
{(router) => this.renderClickableBehavior(router)}
|
|
222
|
+
</__RouterContext.Consumer>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
223
225
|
}
|
|
224
226
|
|
|
225
227
|
const styles = StyleSheet.create({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {StyleSheet} from "aphrodite";
|
|
4
|
-
import * as PropTypes from "prop-types";
|
|
5
4
|
|
|
6
5
|
import {LabelLarge} from "@khanacademy/wonder-blocks-typography";
|
|
7
6
|
import Color, {SemanticColor, mix} from "@khanacademy/wonder-blocks-color";
|
|
@@ -39,10 +38,6 @@ type Props = {|
|
|
|
39
38
|
opened: boolean,
|
|
40
39
|
|};
|
|
41
40
|
|
|
42
|
-
type ContextTypes = {|
|
|
43
|
-
router: $FlowFixMe,
|
|
44
|
-
|};
|
|
45
|
-
|
|
46
41
|
const StyledButton = addStyle<"button">("button");
|
|
47
42
|
|
|
48
43
|
/**
|
|
@@ -52,8 +47,6 @@ const StyledButton = addStyle<"button">("button");
|
|
|
52
47
|
* - the down caret icon is smaller that the one that would be used by ButtonCore
|
|
53
48
|
*/
|
|
54
49
|
export default class ActionMenuOpenerCore extends React.Component<Props> {
|
|
55
|
-
static contextTypes: ContextTypes = {router: PropTypes.any};
|
|
56
|
-
|
|
57
50
|
render(): React.Node {
|
|
58
51
|
const {
|
|
59
52
|
children,
|
|
@@ -226,7 +226,8 @@ export default class ActionMenu extends React.Component<Props, State> {
|
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
renderOpener(numItems: number): React.Element<typeof DropdownOpener> {
|
|
229
|
-
const {disabled, menuText,
|
|
229
|
+
const {disabled, menuText, opener, testId} = this.props;
|
|
230
|
+
const {opened} = this.state;
|
|
230
231
|
|
|
231
232
|
return (
|
|
232
233
|
<DropdownOpener
|
|
@@ -14,8 +14,7 @@ import type {IconAsset} from "@khanacademy/wonder-blocks-icon";
|
|
|
14
14
|
// If the intended icon is a check without a checkbox, you should be using
|
|
15
15
|
// icons.check from the Wonder Blocks Icon package.
|
|
16
16
|
const checkboxCheck: IconAsset = {
|
|
17
|
-
small:
|
|
18
|
-
"M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z",
|
|
17
|
+
small: "M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z",
|
|
19
18
|
};
|
|
20
19
|
const {blue, white, offBlack16, offBlack32, offBlack50, offWhite} = Color;
|
|
21
20
|
|
|
@@ -522,9 +522,8 @@ class DropdownCore extends React.Component<Props, State> {
|
|
|
522
522
|
// appropriate item in handleKeyDown
|
|
523
523
|
this.itemsClicked = true;
|
|
524
524
|
this.focusedIndex = index;
|
|
525
|
-
this.focusedOriginalIndex =
|
|
526
|
-
this.focusedIndex
|
|
527
|
-
].originalIndex;
|
|
525
|
+
this.focusedOriginalIndex =
|
|
526
|
+
this.state.itemRefs[this.focusedIndex].originalIndex;
|
|
528
527
|
};
|
|
529
528
|
|
|
530
529
|
handleDropdownMouseUp: (event: SyntheticMouseEvent<>) => void = (event) => {
|
|
@@ -83,12 +83,10 @@ export const customStyles: StoryComponentType = () => (
|
|
|
83
83
|
<MultiSelectWithCustomStyles />
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
customStyles.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
disable: true,
|
|
91
|
-
},
|
|
86
|
+
customStyles.parameters = {
|
|
87
|
+
chromatic: {
|
|
88
|
+
// we don't need screenshots because this story only tests behavior.
|
|
89
|
+
disableSnapshot: true,
|
|
92
90
|
},
|
|
93
91
|
};
|
|
94
92
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import {StyleSheet} from "aphrodite";
|
|
5
|
-
import * as PropTypes from "prop-types";
|
|
6
5
|
|
|
7
6
|
import Color, {mix, fade} from "@khanacademy/wonder-blocks-color";
|
|
8
7
|
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
@@ -79,10 +78,6 @@ type OptionProps = {|
|
|
|
79
78
|
style?: StyleType,
|
|
80
79
|
|};
|
|
81
80
|
|
|
82
|
-
type ContextTypes = {|
|
|
83
|
-
router: $FlowFixMe,
|
|
84
|
-
|};
|
|
85
|
-
|
|
86
81
|
type DefaultProps = {|
|
|
87
82
|
disabled: $PropertyType<OptionProps, "disabled">,
|
|
88
83
|
onToggle: $PropertyType<OptionProps, "onToggle">,
|
|
@@ -99,7 +94,6 @@ export default class OptionItem extends React.Component<OptionProps> {
|
|
|
99
94
|
static isClassOf(instance: React.Element<any>): boolean {
|
|
100
95
|
return instance && instance.type && instance.type.__IS_OPTION_ITEM__;
|
|
101
96
|
}
|
|
102
|
-
static contextTypes: ContextTypes = {router: PropTypes.any};
|
|
103
97
|
static defaultProps: DefaultProps = {
|
|
104
98
|
disabled: false,
|
|
105
99
|
onToggle: () => void 0,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import {StyleSheet} from "aphrodite";
|
|
5
|
-
import
|
|
5
|
+
import {__RouterContext} from "react-router";
|
|
6
6
|
|
|
7
7
|
import type {AriaProps} from "@khanacademy/wonder-blocks-core";
|
|
8
8
|
|
|
@@ -16,15 +16,8 @@ import {DROPDOWN_ITEM_HEIGHT} from "../util/constants.js";
|
|
|
16
16
|
|
|
17
17
|
const StyledButton = addStyle("button");
|
|
18
18
|
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
white,
|
|
22
|
-
white50,
|
|
23
|
-
offBlack,
|
|
24
|
-
offBlack16,
|
|
25
|
-
offBlack32,
|
|
26
|
-
offBlack64,
|
|
27
|
-
} = Color;
|
|
19
|
+
const {blue, white, white50, offBlack, offBlack16, offBlack32, offBlack64} =
|
|
20
|
+
Color;
|
|
28
21
|
|
|
29
22
|
type SelectOpenerProps = {|
|
|
30
23
|
...AriaProps,
|
|
@@ -77,10 +70,6 @@ type SelectOpenerProps = {|
|
|
|
77
70
|
open: boolean,
|
|
78
71
|
|};
|
|
79
72
|
|
|
80
|
-
type ContextTypes = {|
|
|
81
|
-
router: $FlowFixMe,
|
|
82
|
-
|};
|
|
83
|
-
|
|
84
73
|
type DefaultProps = {|
|
|
85
74
|
disabled: $PropertyType<SelectOpenerProps, "disabled">,
|
|
86
75
|
light: $PropertyType<SelectOpenerProps, "light">,
|
|
@@ -91,7 +80,6 @@ type DefaultProps = {|
|
|
|
91
80
|
* An opener that opens select boxes.
|
|
92
81
|
*/
|
|
93
82
|
export default class SelectOpener extends React.Component<SelectOpenerProps> {
|
|
94
|
-
static contextTypes: ContextTypes = {router: PropTypes.any};
|
|
95
83
|
static defaultProps: DefaultProps = {
|
|
96
84
|
disabled: false,
|
|
97
85
|
light: false,
|
|
@@ -103,7 +91,7 @@ export default class SelectOpener extends React.Component<SelectOpenerProps> {
|
|
|
103
91
|
this.props.onOpenChanged(!open);
|
|
104
92
|
};
|
|
105
93
|
|
|
106
|
-
|
|
94
|
+
renderClickableBehavior(router: any): React.Node {
|
|
107
95
|
const {
|
|
108
96
|
children,
|
|
109
97
|
disabled,
|
|
@@ -117,7 +105,7 @@ export default class SelectOpener extends React.Component<SelectOpenerProps> {
|
|
|
117
105
|
...sharedProps
|
|
118
106
|
} = this.props;
|
|
119
107
|
|
|
120
|
-
const ClickableBehavior = getClickableBehavior(
|
|
108
|
+
const ClickableBehavior = getClickableBehavior(router);
|
|
121
109
|
|
|
122
110
|
return (
|
|
123
111
|
<ClickableBehavior disabled={disabled} onClick={this.handleClick}>
|
|
@@ -173,6 +161,14 @@ export default class SelectOpener extends React.Component<SelectOpenerProps> {
|
|
|
173
161
|
</ClickableBehavior>
|
|
174
162
|
);
|
|
175
163
|
}
|
|
164
|
+
|
|
165
|
+
render(): React.Node {
|
|
166
|
+
return (
|
|
167
|
+
<__RouterContext.Consumer>
|
|
168
|
+
{(router) => this.renderClickableBehavior(router)}
|
|
169
|
+
</__RouterContext.Consumer>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
176
172
|
}
|
|
177
173
|
|
|
178
174
|
const buttonRadius = 4;
|
|
@@ -106,12 +106,10 @@ const styles = StyleSheet.create({
|
|
|
106
106
|
|
|
107
107
|
export const WithFilter: StoryComponentType = () => <SingleSelectWithFilter />;
|
|
108
108
|
|
|
109
|
-
WithFilter.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
disable: true,
|
|
114
|
-
},
|
|
109
|
+
WithFilter.parameters = {
|
|
110
|
+
chromatic: {
|
|
111
|
+
// we don't need screenshots because this story only tests behavior.
|
|
112
|
+
disableSnapshot: true,
|
|
115
113
|
},
|
|
116
114
|
};
|
|
117
115
|
|
|
@@ -163,13 +161,12 @@ export const DropdownInModal: StoryComponentType = () => {
|
|
|
163
161
|
);
|
|
164
162
|
};
|
|
165
163
|
|
|
166
|
-
DropdownInModal.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
164
|
+
DropdownInModal.storyName = "Dropdown in a modal";
|
|
165
|
+
|
|
166
|
+
DropdownInModal.parameters = {
|
|
167
|
+
chromatic: {
|
|
168
|
+
// We don't need screenshots because this story can be tested after
|
|
169
|
+
// the modal is opened.
|
|
170
|
+
disableSnapshot: true,
|
|
174
171
|
},
|
|
175
172
|
};
|