@atlaskit/select 16.1.1 → 16.1.3
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 +13 -0
- package/dist/cjs/AsyncCreatableSelect.js +0 -5
- package/dist/cjs/AsyncSelect.js +0 -5
- package/dist/cjs/CheckboxSelect.js +1 -15
- package/dist/cjs/CountrySelect.js +20 -29
- package/dist/cjs/CreatableSelect.js +0 -5
- package/dist/cjs/PopupSelect/PopupSelect.js +36 -113
- package/dist/cjs/PopupSelect/components.js +15 -31
- package/dist/cjs/PopupSelect/index.js +0 -2
- package/dist/cjs/RadioSelect.js +1 -13
- package/dist/cjs/Select.js +1 -8
- package/dist/cjs/components/index.js +0 -10
- package/dist/cjs/components/indicators.js +1 -13
- package/dist/cjs/components/input-options.js +43 -84
- package/dist/cjs/createSelect.js +12 -42
- package/dist/cjs/data/countries.js +3 -2
- package/dist/cjs/entry-points/async-creatable-select.js +0 -2
- package/dist/cjs/entry-points/async-select.js +0 -2
- package/dist/cjs/entry-points/creatable-select.js +0 -2
- package/dist/cjs/entry-points/select.js +0 -4
- package/dist/cjs/extract-react-types/ert.js +0 -1
- package/dist/cjs/extract-react-types/react-popper-props.js +1 -1
- package/dist/cjs/extract-react-types/react-select-async.js +1 -1
- package/dist/cjs/extract-react-types/react-select-creatable.js +1 -1
- package/dist/cjs/extract-react-types/react-select-props.js +1 -1
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/styles.js +5 -30
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/CheckboxSelect.js +2 -3
- package/dist/es2019/CountrySelect.js +14 -18
- package/dist/es2019/PopupSelect/PopupSelect.js +29 -85
- package/dist/es2019/PopupSelect/components.js +6 -6
- package/dist/es2019/RadioSelect.js +2 -3
- package/dist/es2019/Select.js +1 -1
- package/dist/es2019/components/indicators.js +0 -1
- package/dist/es2019/components/input-options.js +23 -29
- package/dist/es2019/createSelect.js +6 -14
- package/dist/es2019/data/countries.js +3 -1
- package/dist/es2019/extract-react-types/react-popper-props.js +1 -0
- package/dist/es2019/extract-react-types/react-select-async.js +1 -0
- package/dist/es2019/extract-react-types/react-select-creatable.js +1 -0
- package/dist/es2019/extract-react-types/react-select-props.js +1 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/styles.js +34 -35
- package/dist/es2019/version.json +1 -1
- package/dist/esm/CheckboxSelect.js +1 -8
- package/dist/esm/CountrySelect.js +20 -24
- package/dist/esm/PopupSelect/PopupSelect.js +36 -114
- package/dist/esm/PopupSelect/components.js +16 -18
- package/dist/esm/RadioSelect.js +1 -7
- package/dist/esm/Select.js +1 -1
- package/dist/esm/components/index.js +0 -2
- package/dist/esm/components/indicators.js +0 -1
- package/dist/esm/components/input-options.js +43 -72
- package/dist/esm/createSelect.js +12 -30
- package/dist/esm/data/countries.js +3 -1
- package/dist/esm/extract-react-types/react-popper-props.js +1 -0
- package/dist/esm/extract-react-types/react-select-async.js +1 -0
- package/dist/esm/extract-react-types/react-select-creatable.js +1 -0
- package/dist/esm/extract-react-types/react-select-props.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/styles.js +5 -25
- package/dist/esm/version.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/select
|
|
2
2
|
|
|
3
|
+
## 16.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`22b754d311f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/22b754d311f) - Updates usage of removed design token `utilities.UNSAFE_util.transparent` in favour of its replacement `utilities.UNSAFE.transparent`
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 16.1.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`18aeca8c199`](https://bitbucket.org/atlassian/atlassian-frontend/commits/18aeca8c199) - Internal change to update token references. There is no expected behaviour or visual change.
|
|
15
|
+
|
|
3
16
|
## 16.1.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _asyncCreatable = _interopRequireDefault(require("react-select/async-creatable"));
|
|
11
|
-
|
|
12
9
|
var _createSelect = _interopRequireDefault(require("./createSelect"));
|
|
13
|
-
|
|
14
10
|
var _default = (0, _createSelect.default)(_asyncCreatable.default);
|
|
15
|
-
|
|
16
11
|
exports.default = _default;
|
package/dist/cjs/AsyncSelect.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _async = _interopRequireDefault(require("react-select/async"));
|
|
11
|
-
|
|
12
9
|
var _createSelect = _interopRequireDefault(require("./createSelect"));
|
|
13
|
-
|
|
14
10
|
var _default = (0, _createSelect.default)(_async.default);
|
|
15
|
-
|
|
16
11
|
exports.default = _default;
|
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
12
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
19
|
-
|
|
20
13
|
var _inputOptions = require("./components/input-options");
|
|
21
|
-
|
|
22
14
|
var _excluded = ["components"];
|
|
23
|
-
|
|
24
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
-
|
|
26
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
-
|
|
28
17
|
var CheckboxSelect = function CheckboxSelect(_ref) {
|
|
29
18
|
var components = _ref.components,
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
32
20
|
var temp = _objectSpread(_objectSpread({}, components), {}, {
|
|
33
21
|
Option: _inputOptions.CheckboxOption
|
|
34
22
|
});
|
|
35
|
-
|
|
36
23
|
return /*#__PURE__*/_react.default.createElement(_Select.default, (0, _extends2.default)({
|
|
37
24
|
closeMenuOnSelect: false,
|
|
38
25
|
hideSelectedOptions: false,
|
|
@@ -40,6 +27,5 @@ var CheckboxSelect = function CheckboxSelect(_ref) {
|
|
|
40
27
|
components: temp
|
|
41
28
|
}, props));
|
|
42
29
|
};
|
|
43
|
-
|
|
44
30
|
var _default = CheckboxSelect;
|
|
45
31
|
exports.default = _default;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _react = require("@emotion/react");
|
|
13
|
-
|
|
14
10
|
var _countries = require("./data/countries");
|
|
15
|
-
|
|
16
11
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
17
|
-
|
|
18
12
|
/** @jsx jsx */
|
|
13
|
+
|
|
19
14
|
// custom option renderer
|
|
20
15
|
var labelStyles = (0, _react.css)({
|
|
21
16
|
alignItems: 'center',
|
|
@@ -24,46 +19,43 @@ var labelStyles = (0, _react.css)({
|
|
|
24
19
|
});
|
|
25
20
|
var flagStyles = (0, _react.css)({
|
|
26
21
|
fontSize: '18px',
|
|
27
|
-
|
|
28
|
-
marginRight: "var(--ds-scale-100, 8px)"
|
|
22
|
+
marginRight: "var(--ds-space-100, 8px)"
|
|
29
23
|
});
|
|
30
|
-
|
|
31
24
|
var Opt = function Opt(_ref) {
|
|
32
25
|
var children = _ref.children,
|
|
33
|
-
|
|
26
|
+
icon = _ref.icon;
|
|
34
27
|
return (0, _react.jsx)("div", {
|
|
35
28
|
css: labelStyles
|
|
36
29
|
}, (0, _react.jsx)("span", {
|
|
37
30
|
css: flagStyles
|
|
38
31
|
}, icon), children);
|
|
39
|
-
};
|
|
40
|
-
|
|
32
|
+
};
|
|
41
33
|
|
|
34
|
+
// return the country name; used for searching
|
|
42
35
|
var getOptionLabel = function getOptionLabel(_ref2) {
|
|
43
36
|
var abbr = _ref2.abbr,
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
code = _ref2.code,
|
|
38
|
+
name = _ref2.name;
|
|
46
39
|
return "".concat(name, " (").concat(abbr.toUpperCase(), ") +").concat(code);
|
|
47
|
-
};
|
|
48
|
-
|
|
40
|
+
};
|
|
49
41
|
|
|
42
|
+
// set the country's abbreviation for the option value, (also searchable)
|
|
50
43
|
var getOptionValue = function getOptionValue(opt) {
|
|
51
44
|
return opt.abbr;
|
|
52
|
-
};
|
|
53
|
-
|
|
45
|
+
};
|
|
54
46
|
|
|
47
|
+
// the text node of the control
|
|
55
48
|
var controlLabel = function controlLabel(opt) {
|
|
56
49
|
return (0, _react.jsx)(Opt, {
|
|
57
50
|
icon: opt.icon
|
|
58
51
|
}, opt.abbr.toUpperCase());
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
};
|
|
53
|
+
// the text node for an option
|
|
62
54
|
var optionLabel = function optionLabel(_ref3) {
|
|
63
55
|
var abbr = _ref3.abbr,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
code = _ref3.code,
|
|
57
|
+
icon = _ref3.icon,
|
|
58
|
+
name = _ref3.name;
|
|
67
59
|
return (0, _react.jsx)(Opt, {
|
|
68
60
|
icon: icon
|
|
69
61
|
}, getOptionLabel({
|
|
@@ -71,15 +63,15 @@ var optionLabel = function optionLabel(_ref3) {
|
|
|
71
63
|
code: code,
|
|
72
64
|
name: name
|
|
73
65
|
}));
|
|
74
|
-
};
|
|
75
|
-
|
|
66
|
+
};
|
|
76
67
|
|
|
68
|
+
// switch formatters based on render context (menu | value)
|
|
77
69
|
var formatOptionLabel = function formatOptionLabel(opt, _ref4) {
|
|
78
70
|
var context = _ref4.context;
|
|
79
71
|
return context === 'value' ? controlLabel(opt) : optionLabel(opt);
|
|
80
|
-
};
|
|
81
|
-
|
|
72
|
+
};
|
|
82
73
|
|
|
74
|
+
// put it all together
|
|
83
75
|
var CountrySelect = function CountrySelect(props) {
|
|
84
76
|
return (0, _react.jsx)(_Select.default, (0, _extends2.default)({
|
|
85
77
|
isClearable: false,
|
|
@@ -90,6 +82,5 @@ var CountrySelect = function CountrySelect(props) {
|
|
|
90
82
|
options: _countries.groupedCountries
|
|
91
83
|
}, props));
|
|
92
84
|
};
|
|
93
|
-
|
|
94
85
|
var _default = CountrySelect;
|
|
95
86
|
exports.default = _default;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _creatable = _interopRequireDefault(require("react-select/creatable"));
|
|
11
|
-
|
|
12
9
|
var _createSelect = _interopRequireDefault(require("./createSelect"));
|
|
13
|
-
|
|
14
10
|
var _default = (0, _createSelect.default)(_creatable.default);
|
|
15
|
-
|
|
16
11
|
exports.default = _default;
|
|
@@ -1,81 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = void 0;
|
|
11
|
-
|
|
12
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
-
|
|
18
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
-
|
|
20
13
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
21
|
-
|
|
22
14
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
-
|
|
24
15
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
|
-
|
|
26
16
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
|
-
|
|
28
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
29
|
-
|
|
30
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
31
|
-
|
|
32
19
|
var _reactDom = require("react-dom");
|
|
33
|
-
|
|
34
20
|
var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
|
|
35
|
-
|
|
36
21
|
var _reactSelect = _interopRequireWildcard(require("react-select"));
|
|
37
|
-
|
|
38
22
|
var _reactUid = require("react-uid");
|
|
39
|
-
|
|
40
23
|
var _reactPopper = require("react-popper");
|
|
41
|
-
|
|
42
24
|
var _reactNodeResolver = _interopRequireDefault(require("react-node-resolver"));
|
|
43
|
-
|
|
44
25
|
var _objects = _interopRequireDefault(require("shallow-equal/objects"));
|
|
45
|
-
|
|
46
26
|
var _colors = require("@atlaskit/theme/colors");
|
|
47
|
-
|
|
48
27
|
var _components = require("./components");
|
|
49
|
-
|
|
50
28
|
var _styles = _interopRequireDefault(require("../styles"));
|
|
51
|
-
|
|
52
29
|
var _bindEventListener = require("bind-event-listener");
|
|
53
|
-
|
|
54
30
|
var _excluded = ["footer", "maxMenuWidth", "minMenuWidth", "target"];
|
|
55
|
-
|
|
56
31
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
57
|
-
|
|
58
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
59
|
-
|
|
60
33
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
61
|
-
|
|
62
34
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
63
|
-
|
|
64
35
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
65
|
-
|
|
66
36
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
67
|
-
|
|
68
37
|
/** Are we rendering on the client or server? */
|
|
69
38
|
var canUseDOM = function canUseDOM() {
|
|
70
39
|
return Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
71
|
-
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// ==============================
|
|
72
43
|
// Types
|
|
73
44
|
// ==============================
|
|
74
45
|
|
|
75
|
-
|
|
76
46
|
// ==============================
|
|
77
47
|
// Class
|
|
78
48
|
// ==============================
|
|
49
|
+
|
|
79
50
|
var modifiers = [{
|
|
80
51
|
name: 'offset',
|
|
81
52
|
options: {
|
|
@@ -95,27 +66,19 @@ var defaultPopperProps = {
|
|
|
95
66
|
modifiers: modifiers,
|
|
96
67
|
placement: 'bottom-start'
|
|
97
68
|
};
|
|
98
|
-
|
|
99
69
|
var isEmpty = function isEmpty(obj) {
|
|
100
70
|
return Object.keys(obj).length === 0;
|
|
101
71
|
};
|
|
102
|
-
|
|
103
72
|
var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
104
73
|
(0, _inherits2.default)(PopupSelect, _PureComponent);
|
|
105
|
-
|
|
106
74
|
var _super = _createSuper(PopupSelect);
|
|
107
|
-
|
|
108
75
|
function PopupSelect() {
|
|
109
76
|
var _this$defaultOpenStat;
|
|
110
|
-
|
|
111
77
|
var _this;
|
|
112
|
-
|
|
113
78
|
(0, _classCallCheck2.default)(this, PopupSelect);
|
|
114
|
-
|
|
115
79
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
116
80
|
args[_key] = arguments[_key];
|
|
117
81
|
}
|
|
118
|
-
|
|
119
82
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
120
83
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "menuRef", null);
|
|
121
84
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectRef", null);
|
|
@@ -145,12 +108,9 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
145
108
|
case 'Escape':
|
|
146
109
|
case 'Esc':
|
|
147
110
|
_this.close();
|
|
148
|
-
|
|
149
111
|
break;
|
|
150
|
-
|
|
151
112
|
default:
|
|
152
113
|
}
|
|
153
|
-
|
|
154
114
|
if (_this.props.onKeyDown) {
|
|
155
115
|
/* @ts-ignore - updating type of event React.KeyboardEvent effects the unbindWindowsKeyDown listener. Check if this can be fixed once the component gets refactor to functional */
|
|
156
116
|
_this.props.onKeyDown(event);
|
|
@@ -158,34 +118,32 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
158
118
|
});
|
|
159
119
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClick", function (_ref) {
|
|
160
120
|
var target = _ref.target;
|
|
161
|
-
var isOpen = _this.state.isOpen;
|
|
162
|
-
|
|
121
|
+
var isOpen = _this.state.isOpen;
|
|
122
|
+
// appease flow
|
|
163
123
|
if (!(target instanceof Element)) {
|
|
164
124
|
return;
|
|
165
|
-
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// NOTE: Why not use the <Blanket /> component to close?
|
|
166
128
|
// We don't want to interupt the user's flow. Taking this approach allows
|
|
167
129
|
// user to click "through" to other elements and close the popout.
|
|
168
|
-
|
|
169
|
-
|
|
170
130
|
if (isOpen && _this.menuRef && !_this.menuRef.contains(target)) {
|
|
171
131
|
_this.close();
|
|
172
|
-
}
|
|
173
|
-
// property to the target
|
|
174
|
-
|
|
132
|
+
}
|
|
175
133
|
|
|
134
|
+
// open on target click -- we can't trust consumers to spread the onClick
|
|
135
|
+
// property to the target
|
|
176
136
|
if (!isOpen && _this.targetRef && _this.targetRef.contains(target)) {
|
|
177
137
|
_this.open();
|
|
178
138
|
}
|
|
179
139
|
});
|
|
180
140
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSelectChange", function (value, actionMeta) {
|
|
181
141
|
var _this$props = _this.props,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
142
|
+
closeMenuOnSelect = _this$props.closeMenuOnSelect,
|
|
143
|
+
onChange = _this$props.onChange;
|
|
185
144
|
if (closeMenuOnSelect && actionMeta.action !== 'clear') {
|
|
186
145
|
_this.close();
|
|
187
146
|
}
|
|
188
|
-
|
|
189
147
|
if (onChange) {
|
|
190
148
|
onChange(value, actionMeta);
|
|
191
149
|
}
|
|
@@ -200,28 +158,22 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
200
158
|
});
|
|
201
159
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "open", function (options) {
|
|
202
160
|
var onOpen = _this.props.onOpen;
|
|
203
|
-
|
|
204
161
|
if (!(options !== null && options !== void 0 && options.controlOverride) && _this.isOpenControlled) {
|
|
205
162
|
// Prevent popup opening if it's open state is already being controlled
|
|
206
163
|
return;
|
|
207
164
|
}
|
|
208
|
-
|
|
209
165
|
if (onOpen) {
|
|
210
166
|
onOpen();
|
|
211
167
|
}
|
|
212
|
-
|
|
213
168
|
_this.setState({
|
|
214
169
|
isOpen: true
|
|
215
170
|
});
|
|
216
|
-
|
|
217
171
|
if (_this.selectRef) {
|
|
218
172
|
_this.selectRef.openMenu('first');
|
|
219
173
|
}
|
|
220
|
-
|
|
221
174
|
if (typeof window === 'undefined') {
|
|
222
175
|
return;
|
|
223
176
|
}
|
|
224
|
-
|
|
225
177
|
_this.unbindWindowKeydown = (0, _bindEventListener.bind)(window, {
|
|
226
178
|
type: 'keydown',
|
|
227
179
|
listener: _this.handleKeyDown,
|
|
@@ -232,34 +184,26 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
232
184
|
});
|
|
233
185
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "close", function (options) {
|
|
234
186
|
var _this$unbindWindowKey, _this2;
|
|
235
|
-
|
|
236
187
|
var onClose = _this.props.onClose;
|
|
237
|
-
|
|
238
188
|
if (!(options !== null && options !== void 0 && options.controlOverride) && _this.isOpenControlled) {
|
|
239
189
|
// Prevent popup closing if it's open state is already being controlled
|
|
240
190
|
return;
|
|
241
191
|
}
|
|
242
|
-
|
|
243
192
|
if (onClose) {
|
|
244
193
|
onClose();
|
|
245
194
|
}
|
|
246
|
-
|
|
247
195
|
_this.setState({
|
|
248
196
|
isOpen: false
|
|
249
197
|
});
|
|
250
|
-
|
|
251
198
|
_this.setState({
|
|
252
199
|
focusLockEnabled: false
|
|
253
200
|
});
|
|
254
|
-
|
|
255
201
|
if (_this.targetRef != null) {
|
|
256
202
|
_this.targetRef.focus();
|
|
257
203
|
}
|
|
258
|
-
|
|
259
204
|
if (typeof window === 'undefined') {
|
|
260
205
|
return;
|
|
261
206
|
}
|
|
262
|
-
|
|
263
207
|
(_this$unbindWindowKey = (_this2 = _this).unbindWindowKeydown) === null || _this$unbindWindowKey === void 0 ? void 0 : _this$unbindWindowKey.call(_this2);
|
|
264
208
|
_this.unbindWindowKeydown = null;
|
|
265
209
|
});
|
|
@@ -268,7 +212,6 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
268
212
|
// avoid thrashing fn calls
|
|
269
213
|
if (!_this.targetRef && popperRef && ref) {
|
|
270
214
|
_this.targetRef = ref;
|
|
271
|
-
|
|
272
215
|
if (typeof popperRef === 'function') {
|
|
273
216
|
popperRef(ref);
|
|
274
217
|
} else {
|
|
@@ -280,7 +223,6 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
280
223
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolveMenuRef", function (popperRef) {
|
|
281
224
|
return function (ref) {
|
|
282
225
|
_this.menuRef = ref;
|
|
283
|
-
|
|
284
226
|
if (typeof popperRef === 'function') {
|
|
285
227
|
popperRef(ref);
|
|
286
228
|
} else {
|
|
@@ -307,14 +249,12 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
307
249
|
});
|
|
308
250
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getMaxHeight", function () {
|
|
309
251
|
var maxMenuHeight = _this.props.maxMenuHeight;
|
|
310
|
-
|
|
311
252
|
if (!_this.selectRef) {
|
|
312
253
|
return maxMenuHeight;
|
|
313
|
-
}
|
|
314
|
-
|
|
254
|
+
}
|
|
315
255
|
|
|
256
|
+
// subtract the control height to maintain consistency
|
|
316
257
|
var showSearchControl = _this.showSearchControl();
|
|
317
|
-
|
|
318
258
|
var controlRef = _this.selectRef.controlRef;
|
|
319
259
|
var offsetHeight = showSearchControl && controlRef ? controlRef.offsetHeight : 0;
|
|
320
260
|
var maxHeight = maxMenuHeight - offsetHeight;
|
|
@@ -322,47 +262,40 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
322
262
|
});
|
|
323
263
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "showSearchControl", function () {
|
|
324
264
|
var _this$props2 = _this.props,
|
|
325
|
-
|
|
326
|
-
|
|
265
|
+
searchThreshold = _this$props2.searchThreshold,
|
|
266
|
+
isSearchable = _this$props2.isSearchable;
|
|
327
267
|
return isSearchable && _this.getItemCount() > searchThreshold;
|
|
328
268
|
});
|
|
329
269
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderSelect", function () {
|
|
330
270
|
var _this$props3 = _this.props,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
271
|
+
footer = _this$props3.footer,
|
|
272
|
+
maxMenuWidth = _this$props3.maxMenuWidth,
|
|
273
|
+
minMenuWidth = _this$props3.minMenuWidth,
|
|
274
|
+
target = _this$props3.target,
|
|
275
|
+
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
336
276
|
var _this$state = _this.state,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
277
|
+
focusLockEnabled = _this$state.focusLockEnabled,
|
|
278
|
+
isOpen = _this$state.isOpen,
|
|
279
|
+
mergedComponents = _this$state.mergedComponents,
|
|
280
|
+
mergedPopperProps = _this$state.mergedPopperProps;
|
|
342
281
|
var showSearchControl = _this.showSearchControl();
|
|
343
|
-
|
|
344
282
|
var portalDestination = canUseDOM() ? document.body : null;
|
|
345
|
-
|
|
346
283
|
var components = _objectSpread(_objectSpread({}, mergedComponents), {}, {
|
|
347
284
|
Control: showSearchControl ? mergedComponents.Control : _components.DummyControl
|
|
348
285
|
});
|
|
349
|
-
|
|
350
286
|
if (!portalDestination || !isOpen) {
|
|
351
287
|
return null;
|
|
352
288
|
}
|
|
353
|
-
|
|
354
289
|
var popper = /*#__PURE__*/_react.default.createElement(_reactPopper.Popper, (0, _extends2.default)({}, mergedPopperProps, {
|
|
355
290
|
onFirstUpdate: function onFirstUpdate(state) {
|
|
356
291
|
var _mergedPopperProps$on;
|
|
357
|
-
|
|
358
292
|
_this.handleFirstPopperUpdate();
|
|
359
|
-
|
|
360
293
|
(_mergedPopperProps$on = mergedPopperProps.onFirstUpdate) === null || _mergedPopperProps$on === void 0 ? void 0 : _mergedPopperProps$on.call(mergedPopperProps, state);
|
|
361
294
|
}
|
|
362
295
|
}), function (_ref2) {
|
|
363
296
|
var placement = _ref2.placement,
|
|
364
|
-
|
|
365
|
-
|
|
297
|
+
ref = _ref2.ref,
|
|
298
|
+
style = _ref2.style;
|
|
366
299
|
return /*#__PURE__*/_react.default.createElement(_reactNodeResolver.default, {
|
|
367
300
|
innerRef: _this.resolveMenuRef(ref)
|
|
368
301
|
}, /*#__PURE__*/_react.default.createElement(_components.MenuDialog, {
|
|
@@ -389,19 +322,16 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
389
322
|
onChange: _this.handleSelectChange
|
|
390
323
|
})), footer)));
|
|
391
324
|
});
|
|
392
|
-
|
|
393
325
|
return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/(0, _reactDom.createPortal)(popper, portalDestination);
|
|
394
326
|
});
|
|
395
327
|
return _this;
|
|
396
328
|
}
|
|
397
|
-
|
|
398
329
|
(0, _createClass2.default)(PopupSelect, [{
|
|
399
330
|
key: "componentDidMount",
|
|
400
331
|
value: function componentDidMount() {
|
|
401
332
|
if (typeof window === 'undefined') {
|
|
402
333
|
return;
|
|
403
334
|
}
|
|
404
|
-
|
|
405
335
|
this.unbindWindowClick = (0, _bindEventListener.bind)(window, {
|
|
406
336
|
type: 'click',
|
|
407
337
|
listener: this.handleClick,
|
|
@@ -414,11 +344,9 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
414
344
|
key: "componentWillUnmount",
|
|
415
345
|
value: function componentWillUnmount() {
|
|
416
346
|
var _this$unbindWindowCli, _this$unbindWindowKey2;
|
|
417
|
-
|
|
418
347
|
if (typeof window === 'undefined') {
|
|
419
348
|
return;
|
|
420
349
|
}
|
|
421
|
-
|
|
422
350
|
(_this$unbindWindowCli = this.unbindWindowClick) === null || _this$unbindWindowCli === void 0 ? void 0 : _this$unbindWindowCli.call(this);
|
|
423
351
|
this.unbindWindowClick = null;
|
|
424
352
|
(_this$unbindWindowKey2 = this.unbindWindowKeydown) === null || _this$unbindWindowKey2 === void 0 ? void 0 : _this$unbindWindowKey2.call(this);
|
|
@@ -428,7 +356,6 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
428
356
|
key: "componentDidUpdate",
|
|
429
357
|
value: function componentDidUpdate(prevProps) {
|
|
430
358
|
var isOpen = this.props.isOpen;
|
|
431
|
-
|
|
432
359
|
if (prevProps.isOpen !== isOpen) {
|
|
433
360
|
if (isOpen === true) {
|
|
434
361
|
this.open({
|
|
@@ -440,14 +367,14 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
440
367
|
});
|
|
441
368
|
}
|
|
442
369
|
}
|
|
443
|
-
}
|
|
444
|
-
// ==============================
|
|
370
|
+
}
|
|
445
371
|
|
|
372
|
+
// Event Handlers
|
|
373
|
+
// ==============================
|
|
446
374
|
}, {
|
|
447
375
|
key: "render",
|
|
448
376
|
value: function render() {
|
|
449
377
|
var _this3 = this;
|
|
450
|
-
|
|
451
378
|
var target = this.props.target;
|
|
452
379
|
var isOpen = this.state.isOpen;
|
|
453
380
|
return /*#__PURE__*/_react.default.createElement(_reactPopper.Manager, null, /*#__PURE__*/_react.default.createElement(_reactPopper.Reference, null, function (_ref3) {
|
|
@@ -464,31 +391,27 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
464
391
|
}], [{
|
|
465
392
|
key: "getDerivedStateFromProps",
|
|
466
393
|
value: function getDerivedStateFromProps(props, state) {
|
|
467
|
-
var newState = {};
|
|
394
|
+
var newState = {};
|
|
468
395
|
|
|
396
|
+
// Merge consumer and default popper props
|
|
469
397
|
var mergedPopperProps = _objectSpread(_objectSpread({}, defaultPopperProps), props.popperProps);
|
|
470
|
-
|
|
471
398
|
if (!(0, _objects.default)(mergedPopperProps, state.mergedPopperProps)) {
|
|
472
399
|
newState.mergedPopperProps = mergedPopperProps;
|
|
473
|
-
}
|
|
474
|
-
|
|
400
|
+
}
|
|
475
401
|
|
|
402
|
+
// Merge consumer and default components
|
|
476
403
|
var mergedComponents = _objectSpread(_objectSpread({}, _components.defaultComponents), props.components);
|
|
477
|
-
|
|
478
404
|
if (!(0, _objects.default)(mergedComponents, state.mergedComponents)) {
|
|
479
405
|
newState.mergedComponents = mergedComponents;
|
|
480
406
|
}
|
|
481
|
-
|
|
482
407
|
if (!isEmpty(newState)) {
|
|
483
408
|
return newState;
|
|
484
409
|
}
|
|
485
|
-
|
|
486
410
|
return null;
|
|
487
411
|
}
|
|
488
412
|
}]);
|
|
489
413
|
return PopupSelect;
|
|
490
414
|
}(_react.PureComponent);
|
|
491
|
-
|
|
492
415
|
exports.default = PopupSelect;
|
|
493
416
|
(0, _defineProperty2.default)(PopupSelect, "defaultProps", {
|
|
494
417
|
closeMenuOnSelect: true,
|